Package org.xmldb.api.modules

Examples of org.xmldb.api.modules.CollectionManagementService


        Database database = (Database) cl.newInstance();
        DatabaseManager.registerDatabase(database);

        Collection root = DatabaseManager.getCollection(baseURI + "/db", "admin", "");
       
        CollectionManagementService mgmt =
                (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
        Collection test = mgmt.createCollection("rpctest");
        IndexQueryService idxs = (IndexQueryService) test.getService("IndexQueryService", "1.0");
        idxs.configureCollection(COLLECTION_CONFIG);

        Resource resource = test.createResource("strings.xml", "XMLResource");
        resource.setContent(new File("samples/shakespeare/macbeth.xml"));
View Full Code Here


       
        System.out.println("\n\nStop server...\n");

        try {
            Collection root = DatabaseManager.getCollection(baseURI + "/db", "admin", "");
            CollectionManagementService mgmt =
                (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
            mgmt.removeCollection("rpctest");

            Collection config = DatabaseManager.getCollection(baseURI + "/db/system/config/db", "admin", "");
            mgmt =
                (CollectionManagementService) config.getService("CollectionManagementService", "1.0");
            mgmt.removeCollection("rpctest");
        } catch (XMLDBException e) {
            e.printStackTrace();
        }
        server.shutdown();
        server = null;
View Full Code Here

        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

    protected void createCol(final String collectionName, final String uid, final String pwd) throws ApiException {
       
        Collection col = null;
        try {
            col = DatabaseManager.getCollection(baseUri + "/db", uid, pwd);
            CollectionManagementService cms = (CollectionManagementService)col.getService("CollectionManagementService", "1.0");
            cms.createCollection(collectionName);
        } catch(final XMLDBException xmldbe) {
            throw new ApiException(xmldbe);
        } finally {
            if(col != null) {
                try {
View Full Code Here

        try {
            col = DatabaseManager.getCollection(baseUri + "/db", uid, pwd);
            final Collection child = col.getChildCollection(collectionName);
            if(child != null) {
                child.close();
                final CollectionManagementService cms = (CollectionManagementService)col.getService("CollectionManagementService", "1.0");
                cms.removeCollection(collectionName);
            }
        } catch(final XMLDBException xmldbe) {
            throw new ApiException(xmldbe);
        } finally {
            if(col != null) {
View Full Code Here

      Collection root =
        DatabaseManager.getCollection(
            uri,
            "admin",
            null);
      CollectionManagementService service =
        (CollectionManagementService) root.getService(
            "CollectionManagementService",
        "1.0");
      testCollection = service.createCollection("test");
      assertNotNull(testCollection);
     
      Resource xr = testCollection.createResource("hamlet.xml", "XMLResource");
            String existHome = System.getProperty("exist.home");
            File existDir = existHome == null ? new File(".") : new File(existHome);
      File f = new File(existDir,"samples/shakespeare/hamlet.xml");
      xr.setContent(f);
      testCollection.storeResource(xr);
     
      xmlrpcCollection = service.createCollection("xmlrpc");
      assertNotNull(xmlrpcCollection);
     
      Resource br = xmlrpcCollection.createResource(TestConstants.TEST_MODULE_URI.toString(), "BinaryResource");
      ((EXistResource) br).setMimeType(MimeType.XQUERY_TYPE.getName());
            br.setContent(XmlRpcTest.MODULE_DATA);
View Full Code Here

            Class<?> cl = Class.forName(DRIVER);
            Database database = (Database) cl.newInstance();
            database.setProperty("create-database", "true");
            DatabaseManager.registerDatabase(database);
            Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD);
            CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
            Collection test = cms.createCollection(TEST_COLLECTION);
            UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
            // change ownership to guest
            Account guest = ums.getAccount(GUEST_UID);
            ums.chown(guest, guest.getPrimaryGroup());
            ums.chmod(Permission.DEFAULT_COLLECTION_PERM);
View Full Code Here

    @After
    public void tearDown() throws Exception {

        //delete the test collection
        Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD);
        CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
        cms.removeCollection(TEST_COLLECTION);

        DatabaseInstanceManager dim = (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0");
        dim.shutdown();
    }
View Full Code Here

   
    @Test
    public void createCollections() throws XMLDBException {

        Collection testCollection = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION);
        CollectionManagementService service = (CollectionManagementService) testCollection.getService("CollectionManagementService", "1.0");
        Collection validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION);
        assertNotNull(validationCollection);

        validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION + "/" + TestTools.VALIDATION_TMP_COLLECTION);
        assertNotNull(validationCollection);

        validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION + "/" + TestTools.VALIDATION_XSD_COLLECTION);
        assertNotNull(validationCollection);

        validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION + "/" + TestTools.VALIDATION_DTD_COLLECTION);
        assertNotNull(validationCollection);
    }
View Full Code Here

public class CollectionTest {

    @Test
    public void create() throws XMLDBException {
        Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD);
        CollectionManagementService service = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
        Collection testCollection = service.createCollection(TestConstants.SPECIAL_NAME);
        assertNotNull(testCollection);
    }
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.