Package org.apache.xindice.client.xmldb.services

Examples of org.apache.xindice.client.xmldb.services.CollectionManager


                    System.out.println("ERROR : Collection not found!");
                    return false;
                }

                // Create a collection manager instance for the parent of the collection
                CollectionManager colman = (CollectionManager) col.getService("CollectionManager", XMLDBAPIVERSION);

                // Drop the collection
                colman.dropCollection((String) table.get(XMLTools.NAME_OF));

                System.out.println("Deleted: " + table.get(XMLTools.COLLECTION) + "/" + (String) table.get(XMLTools.NAME_OF));
            } else
                System.out.println("Error : Collection Context and Name required");
View Full Code Here


//      collection = getCollection("xmldb:xindice:///db/");
      collection = getCollection("xmldb:xindice://localhost:8888/db/");
//      collection = getCollection("xmldb:xindice-embed:///db/");

      CollectionManager service = (CollectionManager) collection.getService("CollectionManager", "1.0");

      try{
        service.dropCollection(COLLECTION_NAME);
        System.out.println("Dropped existing collection with name: " + COLLECTION_NAME);
      }
      catch (Exception e) {
                ; // nothing, this may be the first pass.
            }

      // Build up the Collection XML configuration.
      String collectionConfig =
        "<collection compressed=\"true\" name=\""
          + COLLECTION_NAME
          + "\">"
          + "   <filer class=\"org.apache.xindice.core.filer.BTreeFiler\" gzip=\"true\"/>"
          + "</collection>";

      service.createCollection(COLLECTION_NAME, DOMParser.toDocument(collectionConfig));

      System.out.println("Collection " + COLLECTION_NAME + " created.");
    }
    catch (XMLDBException e) {
      System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage());
View Full Code Here

    public Collection createCollection(String parent, String path, Document configuration) throws Exception {
        Collection col = DatabaseManager.getCollection(driver + "/" + parent);
        if (col == null) {
            throw new XindiceException("DatabaseManager.getCollection(" + driver + "/" + parent + ") returned null");
        }
        CollectionManager service = (CollectionManager) col.getService("CollectionManager", "1.0");
        return service.createCollection(path, configuration);
    }
View Full Code Here

    public void dropCollection(String path, String name) throws Exception {
        Collection col = DatabaseManager.getCollection(driver + "/" + path);

        if (col != null) {
            CollectionManager service = (CollectionManager) col.getService("CollectionManager", "1.0");
            service.dropCollection(name);
        }
    }
View Full Code Here

    public void createIndexer(String path, String name, String indexdef) throws Exception {
        Collection col = DatabaseManager.getCollection(driver + "/" + path);
        if (col == null) {
            throw new XindiceException("DatabaseManager.getCollection(" + driver + "/" + path + ") returned null");
        }
        CollectionManager service = (CollectionManager) col.getService("CollectionManager", "1.0");

        service.createIndexer(DOMParser.toDocument(indexdef));
    }
View Full Code Here

    public String[] listIndexes(String path) throws Exception {
        Collection col = DatabaseManager.getCollection(driver + "/" + path);
        if (col == null) {
            throw new XindiceException("DatabaseManager.getCollection(" + driver + "/" + path + ") returned null");
        }
        CollectionManager service = (CollectionManager) col.getService("CollectionManager", "1.0");

        return service.listIndexers();
    }
View Full Code Here

    public void dropIndexer(String path, String name) throws Exception {
        Collection col = DatabaseManager.getCollection(driver + "/" + path);
        if (col == null) {
            throw new XindiceException("DatabaseManager.getCollection(" + driver + "/" + path + ") returned null");
        }
        CollectionManager service = (CollectionManager) col.getService("CollectionManager", "1.0");

        service.dropIndexer(name);
    }
View Full Code Here

                String newcol = (String) table.get(XMLTools.NAME_OF);

                // Create an instance of the collection manager and create the collection

                CollectionManager colman = (CollectionManager) col.getService("CollectionManager", XMLDBAPIVERSION);

                String colName = "";
                String parName = newcol;

                int idx = parName.lastIndexOf("/");

                if (idx != -1) {
                    colName = parName.substring(idx + 1);
                    parName = parName.substring(0, idx);
                } else if (idx == -1) {
                    colName = parName;
                }

                if (colName.equals("")) {
                    System.out.println("Cannot create a NULL collection");
                    return false;
                }

                Document doc = new DocumentImpl();

                Element colEle = doc.createElement("collection");
                colEle.setAttribute("compressed", "true");
                colEle.setAttribute("name", colName);

                doc.appendChild(colEle);

                Element filEle = doc.createElement("filer");
                filEle.setAttribute("class", "org.apache.xindice.core.filer.BTreeFiler");
                //filEle.setAttribute("gzip", "true");
                if (table.containsKey(XMLTools.PAGE_SIZE)) {
                    filEle.setAttribute("pagesize", (String) table.get(XMLTools.PAGE_SIZE));
                }

                if (table.containsKey(XMLTools.MAX_KEY_SIZE)) {
                    filEle.setAttribute("maxkeysize", (String) table.get(XMLTools.MAX_KEY_SIZE));
                }

                colEle.appendChild(filEle);

                tempcol = colman.createCollection(newcol, doc);


                System.out.println("Created : " + table.get(XMLTools.COLLECTION) + "/" + newcol);
            } else {
                System.out.println("ERROR : Collection Context and New Collection name required");
View Full Code Here

                System.out.println("ERROR : Collection not found!");
                return false;
            }

            // Create a collection manager instance for the parent of the collection
            CollectionManager colman = (CollectionManager) col.getService("CollectionManager", XMLDBAPIVERSION);

            String[] idx = colman.listIndexers();

            System.out.println("Indexes:\n");

            for (int i = 0; i < idx.length; i++) {
                System.out.println(idx[i]);
View Full Code Here

                    System.out.println("ERROR : Collection not found!");
                    return false;
                }

                // Create a collection manager instance for the collection
                CollectionManager colman = (CollectionManager) col.getService("CollectionManager", XMLDBAPIVERSION);

                if (table.get(XMLTools.NAME_OF) != null) {
                    colman.dropIndexer((String) table.get(XMLTools.NAME_OF));
                    System.out.println("DELETED: " + (String) table.get(XMLTools.NAME_OF));
                } else {
                    System.out.println("ERROR : Name switch and Indexer name required");
                }
            } else
View Full Code Here

TOP

Related Classes of org.apache.xindice.client.xmldb.services.CollectionManager

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.