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 collection
                CollectionManager colman = (CollectionManager) col.getService("CollectionManager", XMLDBAPIVERSION);

                if (table.get(XMLTools.NAME_OF) != null && table.get(XMLTools.PATTERN) != null) {

                    Document doc = new DocumentImpl();

                    // Create the index element to hold attributes
                    Element idxEle = doc.createElement("index");
                    idxEle.setAttribute("class", XINDICE_VAL_INDEXER);
                    idxEle.setAttribute("name", (String) table.get(XMLTools.NAME_OF));
                    idxEle.setAttribute("pattern", (String) table.get(XMLTools.PATTERN));


                    // Setup optional index attributes
                    if (table.containsKey(XMLTools.TYPE)) {
                        String t = (String) table.get(XMLTools.TYPE);
                        if (t.equalsIgnoreCase("name")) {
                            idxEle.setAttribute("class", XINDICE_NAME_INDEXER);
                        } else {
                            idxEle.setAttribute("type", (String) table.get(XMLTools.TYPE));
                        }
                    }

                    if (table.containsKey(XMLTools.PAGE_SIZE)) {
                        idxEle.setAttribute("pagesize", (String) table.get(XMLTools.PAGE_SIZE));
                    }

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

                    // Add Element to the document
                    doc.appendChild(idxEle);

                    //If in verbose mode, show....
                    if ((String) table.get(XMLTools.VERBOSE) == "true") {
                        String indexstr = TextWriter.toString(doc);
                        System.out.println("Index node element = ");
                        System.out.println("\t" + indexstr + "\n");
                    }


                    // Create the indexer for this collection manager
                    colman.createIndexer(doc);

                    System.out.println("CREATED : " + table.get(XMLTools.NAME_OF));

                } else {
                    System.out.println("ERROR : Name and Pattern required");
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, Document indexDoc) 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(indexDoc);
    }
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

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

                // Create an instance of the collection manager and create the collection
                CollectionManager colman = (CollectionManager) col.getService("CollectionManager", XMLDBAPIVERSION);

                String colPath = (String) table.get(XMLTools.NAME_OF);
                String colName = "";

                int idx = colPath.lastIndexOf("/");
                if (idx != -1) {
                    colName = colPath.substring(idx + 1);
                } else if (idx == -1) {
                    colName = colPath;
                }

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

                Document doc = new DocumentImpl();

                Element colEle = doc.createElement("collection");
                colEle.setAttribute("name", colName);
                // FIXME Make this configurable
                colEle.setAttribute("compressed", "true");
                colEle.setAttribute("inline-metadata", "true");

                doc.appendChild(colEle);

                Element filEle = doc.createElement("filer");
                String filerClass = "org.apache.xindice.core.filer.BTreeFiler";
                // see if user specified filer type
                if (table.containsKey(XMLTools.FILER)) {
                    String filer = (String) table.get(XMLTools.FILER);
                    if ("HashFiler".equals(filer)) {
                        filerClass = "org.apache.xindice.core.filer.HashFiler";
                    } else if (!"BTreeFiler".equals(filer)) {
                        System.out.println("Unknown filer: " + filer);
                        return false;
                    }
                }

                filEle.setAttribute("class", filerClass);
                if (table.containsKey(XMLTools.PAGE_SIZE)) {
                    filEle.setAttribute(XMLTools.PAGE_SIZE, (String) table.get(XMLTools.PAGE_SIZE));
                }
                if (table.containsKey(XMLTools.MAX_KEY_SIZE)) {
                    filEle.setAttribute(XMLTools.MAX_KEY_SIZE, (String) table.get(XMLTools.MAX_KEY_SIZE));
                }
                if (table.containsKey(XMLTools.PAGE_COUNT)) {
                  filEle.setAttribute(XMLTools.PAGE_COUNT, (String) table.get(XMLTools.PAGE_COUNT));
                }

                colEle.appendChild(filEle);

                tempcol = colman.createCollection(colPath, doc);

                System.out.println("Created : " + table.get(XMLTools.COLLECTION) + "/" + colPath);
            } 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

                    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 && table.get(XMLTools.PATTERN) != null) {

                    Document doc = new DocumentImpl();

                    // Create the index element to hold attributes
                    Element idxEle = doc.createElement("index");
                    idxEle.setAttribute("class", XINDICE_VAL_INDEXER);
                    idxEle.setAttribute("name", (String) table.get(XMLTools.NAME_OF));
                    idxEle.setAttribute("pattern", (String) table.get(XMLTools.PATTERN));


                    // Setup optional index attributes
                    if (table.containsKey(XMLTools.TYPE)) {
                        String t = (String) table.get(XMLTools.TYPE);
                        if (t.equalsIgnoreCase("name")) {
                            idxEle.setAttribute("class", XINDICE_NAME_INDEXER);
                        } else {
                            idxEle.setAttribute("type", (String) table.get(XMLTools.TYPE));
                        }
                    }

                    if (table.containsKey(XMLTools.PAGE_SIZE)) {
                        idxEle.setAttribute(XMLTools.PAGE_SIZE, (String) table.get(XMLTools.PAGE_SIZE));
                    }
                    if (table.containsKey(XMLTools.MAX_KEY_SIZE)) {
                        idxEle.setAttribute(XMLTools.MAX_KEY_SIZE, (String) table.get(XMLTools.MAX_KEY_SIZE));
                    }
                    if (table.containsKey(XMLTools.PAGE_COUNT)) {
                      idxEle.setAttribute(XMLTools.PAGE_COUNT, (String) table.get(XMLTools.PAGE_COUNT));
                    }


                    // Add Element to the document
                    doc.appendChild(idxEle);

                    // If in verbose mode, show....
                    if ("true".equals(table.get(XMLTools.VERBOSE))) {
                        String indexstr = TextWriter.toString(doc);
                        System.out.println("Index node element = ");
                        System.out.println("\t" + indexstr + "\n");
                    }


                    // Create the indexer for this collection manager
                    colman.createIndexer(doc);

                    System.out.println("CREATED : " + table.get(XMLTools.NAME_OF));
                } else {
                    System.out.println("ERROR : Name and Pattern required");
                }
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.