Package org.xmldb.api.modules

Examples of org.xmldb.api.modules.CollectionManagementService


        rootCol = DBUtils.setupDB(URI);
       

        testCol = rootCol.getChildCollection(XmldbURI.ROOT_COLLECTION + "/test");
        if(testCol != null) {
            CollectionManagementService mgr = DBUtils.getCollectionManagementService(rootCol);
            mgr.removeCollection(XmldbURI.ROOT_COLLECTION + "/test");
        }
       
        testCol = DBUtils.addCollection(rootCol, "test");
        assertNotNull(testCol);
       
View Full Code Here


      database.setProperty("create-database", "true");
      DatabaseManager.registerDatabase(database);
      col = DatabaseManager.getCollection(URI + "/" + XSLT_COLLECTION);
      if (col == null) {
        Collection root = DatabaseManager.getCollection(URI);
        CollectionManagementService mgtService =
          (CollectionManagementService) root.getService(
            "CollectionManagementService",
            "1.0");
        col = mgtService.createCollection(XSLT_COLLECTION);
        System.out.println("collection created.");
      }
     
      BrokerPool.getInstance().getConfiguration().setProperty(
          TransformerFactoryAllocator.PROPERTY_TRANSFORMER_CLASS,
View Full Code Here

    database.setProperty("create-database", "true");
    DatabaseManager.registerDatabase(database);

    Collection root =
      DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", "");
    CollectionManagementService service =
      (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
    testCollection = service.createCollection("test");
    Assert.assertNotNull(testCollection);
       
    File dir = new File(TEST_DIR);
    files = dir.listFiles(new XMLFilenameFilter());
    for (File file : files) {
View Full Code Here

    @After
    public void clearDB() {
        try {
      org.xmldb.api.base.Collection root = DatabaseManager.getCollection("xmldb:exist:///db/test", "admin", null);
      CollectionManagementService service = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
      service.removeCollection(".");
        } catch (XMLDBException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
    }
View Full Code Here

            Database database = (Database) cl.newInstance();
            database.setProperty("create-database", "true");
            DatabaseManager.registerDatabase(database);

            Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", "");
            CollectionManagementService mgmt = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
            Collection collection = mgmt.createCollection("protected");

            IndexQueryService idxConf = (IndexQueryService) collection.getService("IndexQueryService", "1.0");
            idxConf.configureCollection(COLLECTION_CONFIG);
            XMLResource hamlet = (XMLResource) collection.createResource("hamlet.xml", "XMLResource");
            hamlet.setContent(new File("samples/shakespeare/hamlet.xml"));
            collection.storeResource(hamlet);

            mgmt = (CollectionManagementService) collection.getService("CollectionManagementService", "1.0");
           
            TestDataGenerator generator = new TestDataGenerator("xdb", DOCUMENT_COUNT);
            for (int i = 0; i < COLLECTION_COUNT; i++) {
                Collection currentColl = mgmt.createCollection("test" + i);
                System.out.println("Generating " + DOCUMENT_COUNT + " files...");
                File[] files = generator.generate(currentColl, generateXQ);
                for (int j = 0; j < files.length; j++) {
                    XMLResource resource = (XMLResource) currentColl.createResource("xdb" + j + ".xml", "XMLResource");
                    resource.setContent(files[j]);
View Full Code Here

    @AfterClass
    public static void closeDB() {
        try {
            Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", "");
            CollectionManagementService cmgr = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
            cmgr.removeCollection("protected");
           
            DatabaseInstanceManager mgr = (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0");
            mgr.shutdown();
        } catch (XMLDBException e) {
            e.printStackTrace();
View Full Code Here

      Class<?> cl = Class.forName("org.exist.xmldb.DatabaseImpl");
      Database database = (Database) cl.newInstance();
      database.setProperty("create-database", "true");
      DatabaseManager.registerDatabase(database);
      root = DatabaseManager.getCollection( XmldbURI.LOCAL_DB, "admin", "");
      CollectionManagementService service =
        (CollectionManagementService) root.getService(
          "CollectionManagementService",
          "1.0");
      root = service.createCollection("test");
      FILE_STORED = "big.xml";
      doc = (XMLResource) root.createResource(FILE_STORED, "XMLResource");
    } catch (ClassNotFoundException e) {
    } catch (InstantiationException e) {
    } catch (IllegalAccessException e) {
View Full Code Here

    }


    protected final Collection mkcol( Collection rootCollection, String baseURI, String path, String relPath ) throws XMLDBException
    {
        CollectionManagementService mgtService;
        Collection                  current   = rootCollection;
        Collection                  collection;
        String                      token;

        ///TODO : use dedicated function in XmldbURI
        final StringTokenizer             tokenizer = new StringTokenizer( relPath, "/" );

        while( tokenizer.hasMoreTokens() ) {

            token = tokenizer.nextToken();

            if( path != null ) {
                path = path + "/" + token;
            } else {
                path = "/" + token;
            }

            log( "Get collection " + baseURI + path, Project.MSG_DEBUG );
            collection = DatabaseManager.getCollection( baseURI + path, user, password );

            if( collection == null ) {
                log( "Create collection management service for collection " + current.getName(), Project.MSG_DEBUG );
                mgtService = (CollectionManagementService)current.getService( "CollectionManagementService", "1.0" );
                log( "Create child collection " + token, Project.MSG_DEBUG );
                current = mgtService.createCollection( token );
                log( "Created collection " + current.getName() + '.', Project.MSG_DEBUG );

            } else {
                current = collection;
            }
View Full Code Here

    }


    private Collection mkcol( Collection root, String base, /*String path,*/  String relPath ) throws XMLDBException, URISyntaxException
    {
        CollectionManagementService mgtService;
        Collection                  current  = root;
        Collection                  c;
        XmldbURI                    baseUri  = XmldbURI.xmldbUriFor( base );
        final XmldbURI                    collPath = XmldbURI.xmldbUriFor( relPath );
        log( "BASEURI=" + baseUri, Project.MSG_DEBUG );
        log( "RELPATH=" + relPath, Project.MSG_DEBUG );

        //log("PATH=" + path, Project.MSG_DEBUG);

        final XmldbURI[] segments = collPath.getPathSegments();

        for( final XmldbURI segment : segments ) {
            baseUri = baseUri.append( segment );

            log( "Get collection " + baseUri, Project.MSG_DEBUG );
            c = DatabaseManager.getCollection( baseUri.toString(), user, password );

            if( c == null ) {
                log( "Create collection management service for collection " + current.getName(), Project.MSG_DEBUG );
                mgtService = (CollectionManagementService)current.getService( "CollectionManagementService", "1.0" );
                log( "Create child collection " + segment );
                current = mgtService.createCollection( segment.toString() );
                log( "Created collection " + current.getName() + '.' );

            } else {
                current = c;
            }
View Full Code Here

    return res;
  }

  private Collection setupTestCollection() throws XMLDBException {
    Collection root = DatabaseManager.getCollection(URI, "admin", "");
    CollectionManagementService rootcms = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
    Collection c = root.getChildCollection("test");
    if(c != null) rootcms.removeCollection("test");
    rootcms.createCollection("test");
    c = DatabaseManager.getCollection(URI+"/test", "admin", "");
    assertNotNull(c);
    return c;
  }
View Full Code Here

TOP

Related Classes of org.xmldb.api.modules.CollectionManagementService

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.