Search in sources :

Example 66 with CollectionManagementService

use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.

the class DBUtils method removeCollection.

public static void removeCollection(final Collection parent, final String name) throws XMLDBException {
    final CollectionManagementService service = getCollectionManagementService(parent);
    service.removeCollection(name);
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService)

Example 67 with CollectionManagementService

use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.

the class RemoteDatabaseImplTest method testGetCollection.

@Test
public void testGetCollection() throws ClassNotFoundException, IllegalAccessException, InstantiationException, XMLDBException, SyntaxException, PermissionDeniedException {
    Class<?> cl = Class.forName(DB_DRIVER);
    Database database = (Database) cl.newInstance();
    DatabaseManager.registerDatabase(database);
    Collection rootCollection = DatabaseManager.getCollection(getUri() + XmldbURI.ROOT_COLLECTION, "admin", "");
    CollectionManagementService cms = (CollectionManagementService) rootCollection.getService("CollectionManagementService", "1.0");
    Collection adminCollection = cms.createCollection(ADMIN_COLLECTION_NAME);
    UserManagementService ums = (UserManagementService) rootCollection.getService("UserManagementService", "1.0");
    if (ums != null) {
        Permission p = ums.getPermissions(adminCollection);
        p.setMode(Permission.USER_STRING + "=+read,+write," + Permission.GROUP_STRING + "=-read,-write," + Permission.OTHER_STRING + "=-read,-write");
        ums.setPermissions(adminCollection, p);
        Collection guestCollection = DatabaseManager.getCollection(getUri() + XmldbURI.ROOT_COLLECTION + "/" + ADMIN_COLLECTION_NAME, "guest", "guest");
        Resource resource = guestCollection.createResource("testguest", "BinaryResource");
        resource.setContent("123".getBytes());
        try {
            guestCollection.storeResource(resource);
            fail();
        } catch (XMLDBException e) {
        }
        cms.removeCollection(ADMIN_COLLECTION_NAME);
    }
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) Database(org.xmldb.api.base.Database) Permission(org.exist.security.Permission) Resource(org.xmldb.api.base.Resource) Collection(org.xmldb.api.base.Collection) XMLDBException(org.xmldb.api.base.XMLDBException) Test(org.junit.Test)

Example 68 with CollectionManagementService

use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.

the class AnnotationsTest method setUp.

@BeforeClass
public static void setUp() throws XMLDBException, ClassNotFoundException, InstantiationException, IllegalAccessException {
    CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
    Collection testCollection = service.createCollection("test");
    assertNotNull(testCollection);
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) Collection(org.xmldb.api.base.Collection) BeforeClass(org.junit.BeforeClass)

Example 69 with CollectionManagementService

use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.

the class CleanupTest method tearDown.

@After
public void tearDown() throws XMLDBException {
    final CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
    service.removeCollection("test");
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService)

Example 70 with CollectionManagementService

use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.

the class RenameCollectionTest method setUp.

@Before
public void setUp() throws XMLDBException {
    final Collection root = DatabaseManager.getCollection(getBaseUri() + "/db", TestUtils.ADMIN_DB_USER, TestUtils.ADMIN_DB_PWD);
    final CollectionManagementService service = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
    testCollection = service.createCollection(TEST_COLLECTION_NAME);
    assertNotNull(testCollection);
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) Collection(org.xmldb.api.base.Collection) Before(org.junit.Before)

Aggregations

CollectionManagementService (org.xmldb.api.modules.CollectionManagementService)148 Collection (org.xmldb.api.base.Collection)84 XMLResource (org.xmldb.api.modules.XMLResource)33 Resource (org.xmldb.api.base.Resource)25 Before (org.junit.Before)23 EXistCollectionManagementService (org.exist.xmldb.EXistCollectionManagementService)21 After (org.junit.After)21 Test (org.junit.Test)19 UserManagementService (org.exist.xmldb.UserManagementService)14 ResourceSet (org.xmldb.api.base.ResourceSet)14 BinaryResource (org.xmldb.api.modules.BinaryResource)13 XPathQueryService (org.xmldb.api.modules.XPathQueryService)9 Account (org.exist.security.Account)7 IndexQueryService (org.exist.xmldb.IndexQueryService)6 AfterClass (org.junit.AfterClass)6 Database (org.xmldb.api.base.Database)6 XMLDBException (org.xmldb.api.base.XMLDBException)6 Path (java.nio.file.Path)5 BeforeClass (org.junit.BeforeClass)5 InputStream (java.io.InputStream)4