Package org.xmldb.api.modules

Examples of org.xmldb.api.modules.CollectionManagementService


    }

    @Test
    public void setGid_createSubCollection_subCollectionGroupInheritedFromParent() throws XMLDBException {
        final Collection test = DatabaseManager.getCollection(baseUri + "/db/securityTest2", "test1", "test1");
        CollectionManagementService cms = (CollectionManagementService)test.getService("CollectionManagementService", "1.0");

        //create /db/securityTest2/parentCollection with owner "test1:users" and mode "rwxrwsrwx"
        Collection parentCollection = cms.createCollection("parentCollection");
        UserManagementService ums = (UserManagementService)parentCollection.getService("UserManagementService", "1.0");
        ums.chmod("rwxrwsrwx");

        //now create the sub-collection /db/securityTest2/parentCollection/subCollection1
        //it should inherit the group ownership 'users' from the parent collection which is setGid
        //and it should inherit the setGid bit
        parentCollection = DatabaseManager.getCollection(baseUri + "/db/securityTest2/parentCollection", "test3", "test3");
        ums = (UserManagementService)parentCollection.getService("UserManagementService", "1.0");
        cms = (CollectionManagementService)parentCollection.getService("CollectionManagementService", "1.0");
        final Collection subCollection = cms.createCollection("subCollection1");

        final Permission permissions = ums.getPermissions(subCollection);
        assertEquals("users", permissions.getGroup().getName());
        assertTrue(permissions.isSetGid());
    }
View Full Code Here


    }

    @Test
    public void noSetGid_createResource_resourceGroupIsUsersPrimaryGroup() throws XMLDBException {
        final Collection test = DatabaseManager.getCollection(baseUri + "/db/securityTest2", "test1", "test1");
        CollectionManagementService cms = (CollectionManagementService)test.getService("CollectionManagementService", "1.0");

        //create /db/securityTest2/parentCollection with owner "test1:users" and mode "rwxrwxrwx"
        Collection parentCollection = cms.createCollection("parentCollection");
        UserManagementService ums = (UserManagementService)parentCollection.getService("UserManagementService", "1.0");
        ums.chmod("rwxrwxrwx");

        //now create the sub-resource /db/securityTest2/parentCollection/test.xml
        //as "user3:guest", it should have it's group set to the primary group of user3 i.e. 'guest'
View Full Code Here

    }

    @Test
    public void setGid_createResource_resourceGroupInheritedFromParent() throws XMLDBException {
        final Collection test = DatabaseManager.getCollection(baseUri + "/db/securityTest2", "test1", "test1");
        CollectionManagementService cms = (CollectionManagementService)test.getService("CollectionManagementService", "1.0");

        //create /db/securityTest2/parentCollection with owner "test1:users" and mode "rwxrwsrwx"
        Collection parentCollection = cms.createCollection("parentCollection");
        UserManagementService ums = (UserManagementService)parentCollection.getService("UserManagementService", "1.0");
        ums.chmod("rwxrwsrwx");

        //now as "test3:guest" create the sub-resource /db/securityTest2/parentCollection/test.xml
        //it should inherit the group ownership 'users' from the parent which is setGid
View Full Code Here

            user = new UserAider("test3", ums.getGroup("guest"));
            user.setPassword("test3");
            ums.addAccount(user);

            // create a collection /db/securityTest1 as owned by "test1:users" and mode 0770
            CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
            Collection test = cms.createCollection("securityTest1");
            ums = (UserManagementService) test.getService("UserManagementService", "1.0");
            //change ownership to test1
            final Account test1 = ums.getAccount("test1");
            ums.chown(test1, "users");
            // full permissions for user and group, none for world
            ums.chmod(0770);

            test = DatabaseManager.getCollection(baseUri + "/db/securityTest1", "test1", "test1");

            // create a resource /db/securityTest1/test.xml owned by "test1:users" and mode 0770
            Resource resource = test.createResource("test.xml", XMLResource.RESOURCE_TYPE);
            resource.setContent("<test/>");
            test.storeResource(resource);
            ums.chmod(resource, 0770);

            resource = test.createResource("test.bin", BinaryResource.RESOURCE_TYPE);
            resource.setContent("binary-test".getBytes());
            test.storeResource(resource);
            ums.chmod(resource, 0770);

            // create a collection /db/securityTest2 as user "test1"
            cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
            Collection testCol2 = cms.createCollection("securityTest2");
            ums = (UserManagementService) testCol2.getService("UserManagementService", "1.0");
            //change ownership to test1
            ums.chown(test1, "users");
            // full permissions for user and group, none for world
            ums.chmod(0775);

            // create a collection /db/securityTest3 as user "test3"
            cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
            Collection testCol3 = cms.createCollection("securityTest3");
            ums = (UserManagementService) testCol3.getService("UserManagementService", "1.0");
            //change ownership to test3
            final Account test3 = ums.getAccount("test3");
            ums.chown(test3, "users");
            // full permissions for all
View Full Code Here

    @After
    public void cleanup() throws XMLDBException {
        try {
            final Collection root = DatabaseManager.getCollection(baseUri + "/db", "admin", "");
            final CollectionManagementService cms = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");

            final Collection secTest1 = root.getChildCollection("securityTest1");
            if(secTest1 != null) {
                secTest1.close();
                cms.removeCollection("securityTest1");
            }

            final Collection secTest2 = root.getChildCollection("securityTest2");
            if(secTest2 != null) {
                secTest2.close();
                cms.removeCollection("securityTest2");
            }

            final Collection secTest3 = root.getChildCollection("securityTest3");
            if(secTest3 != null) {
                secTest3.close();
                cms.removeCollection("securityTest3");
            }

            final UserManagementService ums = (UserManagementService) root.getService("UserManagementService", "1.0");

            //remove accounts 'test1', 'test2' and 'test3'
View Full Code Here

      Class<?> dbc = Class.forName(driver);
      Database database = (Database) dbc.newInstance();
      DatabaseManager.registerDatabase(database);
      Collection rootColl =
        DatabaseManager.getCollection(baseURI, "admin", "");
      CollectionManagementService cms =
        (CollectionManagementService) rootColl.getService(
          "CollectionManagementService",
          "1.0");
      cms.createCollection("A"); // jmv
      cms.removeCollection("A");
      cms.createCollection("A");
      Collection coll = rootColl.getChildCollection("A");

      XMLResource r =
        (XMLResource) coll.createResource(
          name,
          XMLResource.RESOURCE_TYPE);
      r.setContent(
        "<properties><property key=\"type\">Table</property></properties>");
      coll.storeResource(r);

      XPathQueryService xpqs =
        (XPathQueryService) coll.getService("XPathQueryService", "1.0");
      ResourceSet rs =
        xpqs.query(
          "//properties[property[@key='type' and text()='Table']]");
      for (ResourceIterator i = rs.getIterator();
        i.hasMoreResources();
        ) {
        r = (XMLResource) i.nextResource();
        String s = (String) r.getContent();
        Node content = r.getContentAsDOM();
        System.out.println("Resource: " + r.getId());
        System.out.println("getContent: " + s);
        System.out.println("getContentAsDOM: " + content);
        coll.removeResource(r);
      }

      cms.removeCollection("A");
      DatabaseManager.deregisterDatabase(database);
      DatabaseInstanceManager dim =
        (DatabaseInstanceManager) rootColl.getService(
          "DatabaseInstanceManager",
          "1.0");
View Full Code Here

            try {
                final Collection child = currentCollection.getChildCollection(name);

                if(child != null) {
                    currentCollection.setTriggersEnabled(false);
                    final CollectionManagementService cmgt = (CollectionManagementService)currentCollection.getService("CollectionManagementService", "1.0");
                    cmgt.removeCollection(name);
                    currentCollection.setTriggersEnabled(true);
                }
            } catch(final XMLDBException e) {
                listener.warn("Failed to remove deleted collection: " + name + ": " + e.getMessage());
            }
View Full Code Here

    @Before
    public void setUp() throws XMLDBException {
        //create a test collection
        Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD);
        CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
        Collection testCollection = cms.createCollection(TEST_COLLECTION);
        UserManagementService ums = (UserManagementService) testCollection.getService("UserManagementService", "1.0");
        // change ownership to guest
        Account guest = ums.getAccount(GUEST_UID);
        ums.chown(guest, guest.getPrimaryGroup());
        ums.chmod("rwxr-xr-x");
View Full Code Here

    @After
    public void tearDown() throws XMLDBException {
        //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);
    }
View Full Code Here

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

        Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD);
        CollectionManagementService service = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
        testCollection = service.createCollection(TEST_COLLECTION);
        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.