Package org.apache.xindice.core

Examples of org.apache.xindice.core.Collection


        if (!message.containsKey(NAME)) {
            throw new Exception(MISSING_NAME_PARAM);
        }

        Collection col = getCollection((String) message.get(COLLECTION));
        Object obj = col.getEntry(message.get(NAME));

        Hashtable result = new Hashtable();
        if (obj == null) {
            // Return empty result
        } else if (obj instanceof byte[]) {
            // Binary resource
            result.put(RESULT, obj);
        } else if (message.containsKey(COMPRESSED)) {
            SymbolSerializer symbolSerializer = null;
            try {
                symbolSerializer = new SymbolSerializer(col.getSymbols());
            } catch (Exception e) {
                // It's ok (in theory) for a Collection to have no symbol table
                if (log.isWarnEnabled()) {
                    log.warn("ignored exception", e);
                }
View Full Code Here


        if (!message.containsKey(QUERY)) {
            throw new Exception(MISSING_QUERY_PARAM);
        }

        Collection col = getCollection((String) message.get(COLLECTION));
        NodeSet ns = null;

        if (message.containsKey(NAME)) {
            ns = col.queryDocument((String) message.get(TYPE),
                                   (String) message.get(QUERY),
                                   mapNamespaces((Hashtable) message.get(NAMESPACES)),
                                   message.get(NAME));
        } else {
            ns = col.queryCollection((String) message.get(TYPE),
                                     (String) message.get(QUERY),
                                     mapNamespaces((Hashtable) message.get(NAMESPACES)));
        }

        Hashtable result = new Hashtable();
View Full Code Here

    protected static String getHierarchy(XPathPseudoParser parser, String contextPath, Database db) throws DBException, Exception {
        StringBuffer result = new StringBuffer();

        String path = parser.getPath();

        Collection col;
        if (!path.equals("")) {
            col = db.getCollection(parser.getPath());
        } else {
            col = db;
        }

        if (col == null) {
            result.append("Collection not found! " + parser.getPath());
            return result.toString();
        }

        String[] cols = col.listCollections();
        String dbLoc = parser.getDatabase();
        String parserPath = parser.getPath();
        StringBuffer baseHref = new StringBuffer();
        baseHref.append("<a href=\"" + contextPath + "/?" + dbLoc);
        if(parserPath.startsWith("/") || dbLoc.endsWith("/")) {
            baseHref.append(parserPath);
        } else {
            baseHref.append("/" + parserPath);
        }

        for (int i = 0; i < cols.length; i++) {
            result.append(baseHref);
            if(!baseHref.toString().endsWith("/")) {
                result.append("/");
            }
            result.append(cols[i]);
            result.append("\">");
            result.append(cols[i]);
            result.append("</a><br>");
        }

        try {
            String[] docs = col.listDocuments();
            for (int i = 0; i < docs.length; i++) {
                result.append(baseHref);
                result.append("&");
                result.append(docs[i]);
                result.append("\">");
View Full Code Here

        return result.toString();
    }

    protected static String getDetailView(XPathPseudoParser parser, Database db) throws Exception {
        Collection col = db.getCollection(parser.getPath());

        String document = parser.getDocument();
        if (document == null) {
            return "";
        }

        Document doc = col.getDocument(document);
        if (doc == null) {
            return "Document '" + document + "' not found";
        }

        return "Document '" + document + "'<p>\n"
View Full Code Here

        }

        Hashtable result = new Hashtable();
        try {
                       
            Collection col = getCollection((String) message.get(COLLECTION) + "/" + childName);
            col.dropCollection(col);
            result.put(RESULT, "yes");

        } catch (Exception e) {
            // FIXME "No such collection" is when col == null
            /* No such collection... */
 
View Full Code Here

            index.setAttribute("pattern", (String) message.get(PATTERN));

            doc.appendChild(index);
        }

        Collection col = getCollection((String) message.get(COLLECTION));
        Configuration config = new Configuration(doc.getDocumentElement(), false);
        col.createIndexer(config);

        Hashtable result = new Hashtable();
        result.put(RESULT, message.get(NAME));
        return result;
    }
View Full Code Here

        if (!message.containsKey(COLLECTION)) {
            throw new Exception(MISSING_COLLECTION_PARAM);
        }

        Collection col = getCollection((String) message.get(COLLECTION));

        Hashtable result = new Hashtable();
        result.put(RESULT, col.createNewOID().toString());
        return result;
    }
View Full Code Here

        if (!message.containsKey(DOCUMENT)) {
            throw new Exception(MISSING_DOCUMENT_PARAM);
        }

        Collection col = getCollection((String) message.get(COLLECTION));

        Document doc = DOMParser.toDocument((String) message.get(DOCUMENT));
        if (doc == null) {
            throw new Exception("Unable to parse Document");
        }

        String id = (String) message.get(NAME);
        col.setDocument(id, doc);

        Hashtable result = new Hashtable();
        result.put(RESULT, id);
        return result;
    }
View Full Code Here

            Database db = Database.getDatabase(dbName);
            if (db == null) {
                // TODO: Pass an error code. Current XMLPRC does not provide place for detailed error code.
                throw new Exception("Database " + dbName + " could not be found");
            }
            Collection col = db.getCollection(colName);
            if (col == null) {
                throw new Exception("Collection " + colName + " could not be found");
            }

            return col;
View Full Code Here

        if (!message.containsKey(NAME)) {
            throw new Exception(MISSING_NAME_PARAM);
        }

        Collection col = getCollection((String) message.get(COLLECTION));

        col.remove(message.get(NAME));

        Hashtable result = new Hashtable();
        result.put(RESULT, "yes");
        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.xindice.core.Collection

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.