Package org.apache.xindice.core.data

Examples of org.apache.xindice.core.data.Entry


            throws ServletException, IOException {

        String path = col.getCanonicalName() + "/" + name;
        String title = "Document " + path;

        Entry resource;
        try {
            resource = col.getEntry(name);
        } catch (DBException e) {
            log.error(e);
            throw new ServletException(e);
        }

        ServletOutputStream output = startViewer(title, path, res);
        printStartTable(title, output);
        printStartSingleTableBox(output);
        output.print("<a href=\"./?viewer=default\">up to parent collection</a>");
        printEndSingleTableBox(output);
        printStartSingleTableBox(output);
        if (resource.getEntryType() == Entry.DOCUMENT) {
            Xml2HtmlWriter.write((Document) resource.getValue(), output);
        } else {
            output.print("binary resource <a href=\"./");
            output.print(name);
            output.print("\">view content</a>");
        }
View Full Code Here


        } else {
            Collection col = target.getCollection();
            String name = target.getName();

            try {
                Entry resource = col.getEntry(name);

                if (resource != null) {

                    byte[] resultBytes;
                    if (resource.getEntryType() == Entry.DOCUMENT) {
                        resultBytes = TextWriter.toString((Document) resource.getValue()).getBytes();
                        res.setContentType(MimeTable.XML_MIME_TYPE);
                    } else {
                        resultBytes = (byte[]) resource.getValue();
                        res.setContentType(MimeTable.getMimeType(name));
                    }

                    if (resource.getModificationTime() != 0) {
                        res.addDateHeader("Last-Modified", resource.getModificationTime());
                    }
                    res.setContentLength(resultBytes.length);

                    OutputStream output = res.getOutputStream();
                    output.write(resultBytes);
View Full Code Here

            Stopwatch sw = new Stopwatch("Populated Indexes", true);
            RecordSet rs = collection.getFiler().getRecordSet();
            while (rs.hasMoreRecords()) {
                // Read only key, we don't need filer-level value
                Key key = rs.getNextKey();
                Entry entry = collection.getEntry(key);
                if (entry.getEntryType() == Entry.DOCUMENT) {
                    try {
                        new DocumentHandler(symbols, key, (Document) entry.getValue(), DocumentHandler.ACTION_CREATE, list);
                    } catch (Exception e) {
                        if (log.isWarnEnabled()) {
                            log.warn("Failed to index document " + key, e);
                        }
                    }
View Full Code Here

        httpRequest.setPathInfo(collection.getCanonicalName());
        httpRequest.setInput("<?xml version='1.0' encoding='utf-8' ?>" +
                             "<propfind xmlns='DAV:'><allprop/></propfind>");
        method.execute(request, response, new Location(collection.getCanonicalName()));

        Entry entry1 = collection.getEntry(DOC_NAME1);
        Entry entry2 = child.getEntry(DOC_NAME2);
        assertEquals(WebdavStatus.SC_MULTI_STATUS, httpResponse.getStatus());
        String expected =
                "<?xml version='1.0' encoding='utf-8' ?>" +
                "<multistatus xmlns='DAV:'>\n" +
                    "<response>" +
View Full Code Here

            /*
             * If the key has a corresponding value in the cache, return it
             * and save a disk access.
             */
            if (cache != null) {
                Entry entry = cache.getEntry(this, key);
                if (entry != null) {
                    if (log.isTraceEnabled()) {
                        log.trace(localDebugHeader + "Returning cached: " + entry.getValue());
                    }

                    return entry;
                }
            }

            Record record = filer.readRecord(key);
            if (record == null) {
                return null;
            }

            Value value;
            boolean isDocument;
            if (inlineMetaService == null) {
                value = record.getValue();
                isDocument = true;

                if (log.isTraceEnabled()) {
                    log.trace(localDebugHeader + "Type is not available, Length=" + value.getLength());
                }
            } else {
                InlineMetaService.DatabaseEntry databaseEntry = inlineMetaService.readDatabaseEntry(record.getValue());
                Object type = databaseEntry.map.get("type");
                value = databaseEntry.value;
                isDocument = type.equals(ResourceTypeReader.XML);

                if (log.isTraceEnabled()) {
                    log.trace(localDebugHeader + "Type=" + type + ", Length=" + value.getLength());
                }
            }

            Map entryMeta = Entry.createMetaMap(record);
            if (isDocument) {
                Document document;
                if (compressed) {
                    document = new DocumentImpl(value.getData(), symbols, new NodeSource(this, key));
                    if (log.isTraceEnabled()) {
                        log.trace(localDebugHeader +
                                  "Compressed XML document=<" + TextWriter.toString(document) + ">");
                    }
                } else {
                    // FIXME There should be no reason here to re-compress the document & flush symbols table?
                    document = parseDocument(key, value.toString());
                    if (log.isTraceEnabled()) {
                        log.trace(localDebugHeader +
                                  "Uncompressed XML document=<" + TextWriter.toString(document) + ">");
                    }
                }

                // Symbol table could have been updated above, flush it to the disk.
                flushSymbolTable();

                if (cache != null) {
                    cache.putEntry(this, key,
                                   compressed ? DocumentCache.COMPRESSED : DocumentCache.UNCOMPRESSED,
                                   value, entryMeta);
                }

                DBObserver.getInstance().loadDocument(this, record, document);
                return new Entry(key, document, entryMeta);
            } else {
                if (log.isTraceEnabled()) {
                    log.trace(localDebugHeader + "Binary document");
                }

                if (cache != null) {
                    cache.putEntry(this, key, DocumentCache.BINARY, value, entryMeta);
                }

                return new Entry(key, value.getData(), entryMeta);
            }
        }
    }
View Full Code Here

    public final Document getDocument(Object key) throws DBException {
        if (log.isDebugEnabled()) {
            log.debug(debugHeader() + "Get document: " + key);
        }

        Entry entry = getEntry(key);
        if (entry == null) {
            return null;
        }

        if (entry.getEntryType() != Entry.DOCUMENT) {
            throw new DBException(FaultCodes.COL_INVALID_RESULT,
                                  "Resource '" + key + "' in collection '" +
                                  getCanonicalName() + "' is not a document");
        }

        return (Document) entry.getValue();
    }
View Full Code Here

            throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND,
                                  "Collection '" + getCanonicalName() +
                                  "' has no binary resources (inline metadata is not enabled)");
        }

        Entry entry = getEntry(key);
        if (entry == null) {
            return null;
        }

        if (entry.getEntryType() != Entry.BINARY) {
            throw new DBException(FaultCodes.COL_INVALID_RESULT,
                                  "Resource '" + key + "' in collection '" +
                                  getCanonicalName() + "' is not a binary resource");
        }

        return (byte[]) entry.getValue();
    }
View Full Code Here

        // Symbol table could have been updated above, flush it to the disk.
        flushSymbolTable();

        key = getIdentityKey(key);
        Entry entry;
        synchronized (key) {
            // Temporary until insert and update are separate
            entry = getEntry(key);

            if (action == ACTION_INSERT && entry != null) {
                throw new DBException(FaultCodes.COL_DUPLICATE_RESOURCE);
            } else if (action == ACTION_UPDATE && entry == null) {
                throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND);
            }

            if (entry != null && entry.getEntryType() == Entry.DOCUMENT) {
                indexManager.removeDocument(key, (Document) entry.getValue());
            }
            indexManager.addDocument(key, document);

            // Construct the Value object and store in the filer.
            Record record = writeRecord(key, true, documentBytes);
View Full Code Here

     * <li>FaultCodes.COL_DOCUMENT_NOT_FOUND If entry with that key is not present in
     * collection and action is ACTION_UPDATE
     * </ul>
     */
    private boolean putBinary(Key key, byte[] bytes, byte action) throws DBException {
        Entry entry;

        synchronized (getIdentityKey(key)) {
            entry = getEntry(key);
            if (action == ACTION_INSERT && entry != null) {
                    throw new DBException(FaultCodes.COL_DUPLICATE_RESOURCE,
                                          "Error inserting binary resource '" + key + "' in '" + getCanonicalName() +
                                          "': key is already in database");
            } else if (action == ACTION_UPDATE && entry == null) {
                    throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND,
                                          "Error updating binary resource '" + key + "' in '" + getCanonicalName() +
                                          "': key does not exist in database");
            }

            if (entry != null && entry.getEntryType() == Entry.DOCUMENT) {
                // binary resources aren't stored in indexes
                indexManager.removeDocument(key, (Document) entry.getValue());
            }

            // Construct the Value object and store in the filer.
            Record record = writeRecord(key, false, bytes);

View Full Code Here

        checkFiler(FaultCodes.COL_NO_FILER);

        Key objKey = getIdentityKey(createNewKey(id));
        synchronized (objKey) {
            Entry entry = getEntry(objKey);
            if (entry != null && entry.getEntryType() == Entry.DOCUMENT) {
                indexManager.removeDocument(objKey, (Document) entry.getValue());
            }

            if (cache != null) {
                cache.removeEntry(this, objKey);
            }
View Full Code Here

TOP

Related Classes of org.apache.xindice.core.data.Entry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.