Package org.xmldb.api.modules

Examples of org.xmldb.api.modules.CollectionManagementService


    }

    @Test
    public void storeBinaryResource() throws XMLDBException, IOException {
        Collection colTest = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION);
        CollectionManagementService service = (CollectionManagementService) colTest.getService("CollectionManagementService", "1.0");
        Collection testCollection = service.createCollection("test");
        UserManagementService ums = (UserManagementService) testCollection.getService("UserManagementService", "1.0");
        ums.chmod("rwxr-xr-x");

        byte[] data = storeBinaryResourceFromFile(new File( getExistDir(),"webapp/logo.jpg"), testCollection);
        Object content = testCollection.getResource("logo.jpg").getContent();
View Full Code Here


    @Test
    public void testMultipleCreates() throws XMLDBException {
       
        Collection testCol = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION);
        CollectionManagementService cms = (CollectionManagementService)testCol.getService("CollectionManagementService", "1.0");
        assertNotNull(cms);

        cms.createCollection("dummy1");
        printChildren(testCol);
        Collection c1 = testCol.getChildCollection("dummy1");
        assertNotNull(c1);

        cms.setCollection(c1);
        cms.createCollection("dummy2");
        Collection c2 = c1.getChildCollection("dummy2");
        assertNotNull(c2);

        cms.setCollection(c2);
        cms.createCollection("dummy3");
        Collection c3 = c2.getChildCollection("dummy3");
        assertNotNull(c3);

        cms.setCollection(testCol);
        cms.removeCollection("dummy1");
        printChildren(testCol);
        c1 = testCol.getChildCollection("dummy1");
        assertNull(c1);
    }
View Full Code Here

    {
        for (int i = 0; i < INSTANCE_COUNT; i++) {
            Collection root = DatabaseManager.getCollection("xmldb:test" + i + "://" + XmldbURI.ROOT_COLLECTION);
            Collection test = root.getChildCollection("test");
            if (test == null) {
                CollectionManagementService service = (CollectionManagementService)
                    root.getService("CollectionManagementService", "1.0");
                test = service.createCollection("test");
            }

                 String existHome = System.getProperty("exist.home");
                 File existDir = existHome==null ? new File(".") : new File(existHome);
            File samples = new File(existDir,"samples/shakespeare");
View Full Code Here

        long free = rt.freeMemory() / 1024;
        long total = rt.totalMemory() / 1024;
        for (int i = 0; i < INSTANCE_COUNT; i++) {
            System.out.println("Shutting down instance test"+i);
            Collection root = DatabaseManager.getCollection("xmldb:test" + i + "://" + XmldbURI.ROOT_COLLECTION, "admin", null);
            CollectionManagementService service = (CollectionManagementService)
                root.getService("CollectionManagementService", "1.0");
            service.removeCollection("test");

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

      try
    {
      Collection testCollection = root.getChildCollection(collectionName);
      if(testCollection != null)
      {
        CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
        cms.removeCollection(collectionPath);
      }
    }
    catch (XMLDBException e)
    {
      System.err.println("Error removing existing test collection:");
View Full Code Here

      String collectionURI = ROOT_COLLECTION_URI + "/" + collectionName;
      try {
        Collection testCollection = root.getChildCollection(collectionName);
      if(testCollection == null)
      {
        CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
        cms.createCollection(collectionPath);
      }
    } catch(XMLDBException xe) {
      System.err.println("Error determining if test collection already exists:");
      xe.printStackTrace();
      fail(xe.getMessage());
View Full Code Here

      final String XML_RESOURCE_FILENAME = "logo.xml";
     
      try
      {
        //create a test collection
        CollectionManagementService colService = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
      Collection testCollection = colService.createCollection(TEST_BINARY_COLLECTION);
      assertNotNull(testCollection);

      File home = ConfigurationHelper.getExistHome();
            File fLogo;
            if (home != null)
View Full Code Here

        try {
            Connection con = runner.getConnection();
            Collection collection = con.getCollection("benchmark");
            if (collection == null) {
                Collection root = con.getCollection();
                CollectionManagementService cmgt =
                    (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
                collection = cmgt.createCollection("benchmark");
            }
            for (Iterator<?> i = FileUtils.iterateFiles(directory, new String[] { "xml" }, false); i.hasNext(); ) {
                File file = (File) i.next();
                Resource resource = collection.createResource(file.getName(), "XMLResource");
                resource.setContent(file);
View Full Code Here

            "//c:security-manager/string(@last-account-id)";
        result = xqs.query(lastAccountIdQuery);
        assertEquals(RealmImpl.INITIAL_LAST_ACCOUNT_ID + 2, Integer.parseInt(result.getResource(0).getContent().toString())); //last account id should be that of 'jack'

        //create a test collection and give everyone access
        final CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
        final Collection test = cms.createCollection("test");
        final UserManagementService testUms = (UserManagementService)test.getService("UserManagementService", "1.0");
        testUms.chmod("rwxrwxrwx");

        //create and store a new document as 'frank'
        final Collection frankTest = DatabaseManager.getCollection("xmldb:exist:///db/test", FRANK_USER, FRANK_USER);
View Full Code Here

        Database 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");
        Collection testCollection = service.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

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.