use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class ContentAsDOMTest method setUp.
@Before
public void setUp() throws Exception {
CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
Collection testCollection = service.createCollection(TEST_COLLECTION);
UserManagementService ums = (UserManagementService) testCollection.getService("UserManagementService", "1.0");
// change ownership to guest
Account guest = ums.getAccount(GUEST_DB_USER);
ums.chown(guest, guest.getPrimaryGroup());
ums.chmod(Permission.DEFAULT_COLLECTION_PERM);
Resource resource = testCollection.createResource("test.xml", "XMLResource");
resource.setContent(XML);
testCollection.storeResource(resource);
// change resource ownership to guest
ums.chown(resource, guest, GUEST_DB_USER);
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class TestEXistXMLSerialize method setUp.
@Before
public void setUp() throws Exception {
CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
Collection testCollection = service.createCollection(TEST_COLLECTION);
UserManagementService ums = (UserManagementService) testCollection.getService("UserManagementService", "1.0");
// change ownership to guest
Account guest = ums.getAccount(GUEST_DB_USER);
ums.chown(guest, guest.getPrimaryGroup());
ums.chmod("rwxr-xr-x");
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class MultiDBTest method store.
@Test
public void store() throws XMLDBException, IOException {
for (int i = 0; i < INSTANCE_COUNT; i++) {
Collection root = DatabaseManager.getCollection("xmldb:test" + i + "://" + XmldbURI.ROOT_COLLECTION, TestUtils.ADMIN_DB_USER, TestUtils.ADMIN_DB_PWD);
Collection test = root.getChildCollection("test");
if (test == null) {
CollectionManagementService service = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
test = service.createCollection("test");
}
for (final String sampleName : SAMPLES.getShakespeareXmlSampleNames()) {
loadFile(SAMPLES.getShakespeareSample(sampleName), test, sampleName);
}
doQuery(test, "//SPEECH[SPEAKER='HAMLET']");
}
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class RemoteDBTest method removeCollection.
protected void removeCollection() {
try {
Collection rootCollection = DatabaseManager.getCollection(getUri() + XmldbURI.ROOT_COLLECTION, "admin", "");
assertNotNull(rootCollection);
CollectionManagementService cms = (CollectionManagementService) rootCollection.getService("CollectionManagementService", "1.0");
cms.removeCollection(CHILD_COLLECTION);
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class RemoteDBTest method setUpRemoteDatabase.
protected void setUpRemoteDatabase() throws ClassNotFoundException, IllegalAccessException, InstantiationException, XMLDBException {
// Connect to the DB
Class<?> cl = Class.forName(DB_DRIVER);
Database database = (Database) cl.newInstance();
assertNotNull(database);
DatabaseManager.registerDatabase(database);
// Get the root collection...
Collection rootCollection = DatabaseManager.getCollection(getUri() + XmldbURI.ROOT_COLLECTION, "admin", "");
assertNotNull(rootCollection);
CollectionManagementService cms = (CollectionManagementService) rootCollection.getService("CollectionManagementService", "1.0");
// Creates the child collection
Collection childCollection = cms.createCollection(CHILD_COLLECTION);
assertNotNull(childCollection);
// ... and work from it
setCollection((RemoteCollection) childCollection);
assertNotNull(childCollection);
}
Aggregations