Examples of CollectionManagementServiceImpl


Examples of org.exist.xmldb.CollectionManagementServiceImpl

    BrokerPool.FORCE_CORRUPTION = true;
      @SuppressWarnings("unused")
    BrokerPool pool = startDB();

      org.xmldb.api.base.Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", "");
      CollectionManagementServiceImpl mgr = (CollectionManagementServiceImpl)
        root.getService("CollectionManagementService", "1.0");
      org.xmldb.api.base.Collection test = root.getChildCollection("test");
      if (test == null)
        test = mgr.createCollection("test");
      org.xmldb.api.base.Collection test2 = test.getChildCollection("test2");
      if (test2 == null)
        test2 = mgr.createCollection("test2");

      String existHome = System.getProperty("exist.home");
        File existDir = existHome==null ? new File(".") : new File(existHome);
        File f = new File(existDir,"samples/shakespeare/r_and_j.xml");
        assertNotNull(f);
      Resource res = test2.createResource("test3.xml", "XMLResource");
      res.setContent(f);
      test2.storeResource(res);

      mgr.moveResource(XmldbURI.create(XmldbURI.ROOT_COLLECTION +  "/test2/test3.xml"),
                TestConstants.TEST_COLLECTION_URI, XmldbURI.create("new_test3.xml"));
  }
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

        try {
          pool = startDB();
          assertNotNull(pool);       
          org.xmldb.api.base.Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", "");
          assertNotNull(root);
          CollectionManagementServiceImpl mgr = (CollectionManagementServiceImpl)
              root.getService("CollectionManagementService", "1.0");
          assertNotNull(mgr);
          org.xmldb.api.base.Collection test = root.getChildCollection("test");
          if (test == null)
            test = mgr.createCollection(TestConstants.TEST_COLLECTION_URI.toString());
          assertNotNull(test);
          org.xmldb.api.base.Collection test2 = test.getChildCollection("test2");
          if (test2 == null)
            test2 = mgr.createCollection(TestConstants.TEST_COLLECTION_URI2.toString());
          assertNotNull(test2);       
          Resource res = test2.createResource("test_xmldb.xml", "XMLResource");
          assertNotNull(res);
          res.setContent(TEST_XML);
          test2.storeResource(res);
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

          assertNotNull("Document should not be null", res);
          System.out.println(res.getContent());
         
          org.xmldb.api.base.Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", "");
          assertNotNull(root);
          CollectionManagementServiceImpl mgr = (CollectionManagementServiceImpl)
              root.getService("CollectionManagementService", "1.0");
          assertNotNull(mgr);
          mgr.removeCollection("test");
         
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());  
        }
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

        try {
          pool = startDB();
          assertNotNull(pool);
          org.xmldb.api.base.Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", "");
          assertNotNull(root);         
          CollectionManagementServiceImpl mgr = (CollectionManagementServiceImpl)
              root.getService("CollectionManagementService", "1.0");
          assertNotNull(mgr);
         
          org.xmldb.api.base.Collection test = root.getChildCollection("test");         
          if (test == null)
              test = mgr.createCollection("test");
          assertNotNull(test);
         
          org.xmldb.api.base.Collection test2 = test.getChildCollection("test2");
          if (test2 == null)
              test2 = mgr.createCollection("test2");
          assertNotNull(test2);
         
                String existHome = System.getProperty("exist.home");
                File existDir = existHome==null ? new File(".") : new File(existHome);
          File f = new File(existDir,"samples/biblio.rdf");
          assertNotNull(f);
          Resource res = test2.createResource("test_xmldb.xml", "XMLResource");
          assertNotNull(res);
          res.setContent(f);
          test2.storeResource(res);
         
          org.xmldb.api.base.Collection dest = root.getChildCollection("destination3");
          if (dest == null)         
              dest = mgr.createCollection("destination3");
          assertNotNull(dest);
         
          mgr.move(TestConstants.TEST_COLLECTION_URI2, TestConstants.DESTINATION_COLLECTION_URI3, XmldbURI.create("test3"));
      } catch (Exception e) {           
          fail(e.getMessage());     
      }
    }
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

        try {
          pool = startDB();
          assertNotNull(pool);
          org.xmldb.api.base.Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", "");
          assertNotNull(root);
          CollectionManagementServiceImpl mgr = (CollectionManagementServiceImpl)
              root.getService("CollectionManagementService", "1.0");
          assertNotNull(mgr);
          org.xmldb.api.base.Collection test = root.getChildCollection("test");
          if (test == null)
              test = mgr.createCollection(TestConstants.TEST_COLLECTION_URI.toString());
          assertNotNull(test);
          org.xmldb.api.base.Collection test2 = test.getChildCollection("test2");
          if (test2 == null)
              test2 = mgr.createCollection(TestConstants.TEST_COLLECTION_URI.append("test2").toString());
          assertNotNull(test2);
         
                String existHome = System.getProperty("exist.home");
                File existDir = existHome==null ? new File(".") : new File(existHome);
          File f = new File(existDir,"samples/biblio.rdf");
          assertNotNull(f);
          Resource res = test2.createResource("test_xmldb.xml", "XMLResource");
          assertNotNull(res);
          res.setContent(f);
          test2.storeResource(res);
         
          org.xmldb.api.base.Collection dest = root.getChildCollection("destination");         
          if (dest == null)
              dest = mgr.createCollection("destination");
          assertNotNull(dest);
         
          mgr.copy(TestConstants.TEST_COLLECTION_URI2, XmldbURI.ROOT_COLLECTION_URI.append("destination"), XmldbURI.create("test3"));
      } catch (Exception e) {           
          fail(e.getMessage());
      }
    }
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

          assertNotNull("Document should not be null", res);
          System.out.println(res.getContent());
         
          org.xmldb.api.base.Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", "");
          assertNotNull(root);
          CollectionManagementServiceImpl mgr = (CollectionManagementServiceImpl)
              root.getService("CollectionManagementService", "1.0");
          assertNotNull(mgr);
          mgr.removeCollection("destination");
      } catch (Exception e) {           
          fail(e.getMessage());
      }       
    }
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

    }

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

        //create collection owned by "test1", and group "users" in /db/securityTest3
        Collection source = cms.createCollection("source");

        //create resource owned by "test1", and group "users" in /db/securityTest3/source
        Resource resSource = source.createResource("source1.xml", XMLResource.RESOURCE_TYPE);
        resSource.setContent("<test/>");
        source.storeResource(resSource);

        resSource = source.createResource("source2.xml", XMLResource.RESOURCE_TYPE);
        resSource.setContent("<test/>");
        source.storeResource(resSource);

        //as the 'test3' user copy the collection
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
        cms.copy("/db/securityTest3/source", "/db/securityTest3", "copy-of-source");

        final Collection copyOfSource = test.getChildCollection("copy-of-source");
        assertNotNull(copyOfSource);
        assertEquals(2, copyOfSource.listResources().length);
    }
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

     *      -> /db/securityTest3/copy-of-source
     */
    @Test
    public void copyCollectionWithResources_destExists_destIsWritable() throws XMLDBException {
        Collection test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test1", "test1");
        CollectionManagementServiceImpl cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");

        //create collection owned by "test1", and group "users" in /db/securityTest3
        Collection source = cms.createCollection("source");

        //create resource owned by "test1", and group "users" in /db/securityTest3/source
        Resource resSource = source.createResource("source1.xml", XMLResource.RESOURCE_TYPE);
        resSource.setContent("<test/>");
        source.storeResource(resSource);

        resSource = source.createResource("source2.xml", XMLResource.RESOURCE_TYPE);
        resSource.setContent("<test/>");
        source.storeResource(resSource);
       
        //pre-create the destination and set writable by all
        final Collection dest = cms.createCollection("copy-of-source");
        final UserManagementService ums = (UserManagementService)dest.getService("UserManagementService", "1.0");
        ums.chmod(0777);

       
        //as the 'test3' user copy the collection
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
        cms.copy("/db/securityTest3/source", "/db/securityTest3", "copy-of-source");

        final Collection copyOfSource = test.getChildCollection("copy-of-source");
        assertNotNull(copyOfSource);
        assertEquals(2, copyOfSource.listResources().length);
    }
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

     *      -> /db/securityTest3/copy-of-source
     */
    @Test(expected=XMLDBException.class)
    public void copyCollectionWithResources_destExists_destIsNotWritable() throws XMLDBException {
        Collection test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test1", "test1");
        CollectionManagementServiceImpl cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");

        //create collection owned by "test1", and group "users" in /db/securityTest3
        Collection source = cms.createCollection("source");

        //create resource owned by "test1", and group "users" in /db/securityTest3/source
        Resource resSource = source.createResource("source1.xml", XMLResource.RESOURCE_TYPE);
        resSource.setContent("<test/>");
        source.storeResource(resSource);

        resSource = source.createResource("source2.xml", XMLResource.RESOURCE_TYPE);
        resSource.setContent("<test/>");
        source.storeResource(resSource);
       
        //pre-create the destination with default mode (0755)
        //so that it is not writable by 'test3' user
        final Collection dest = cms.createCollection("copy-of-source");

       
        //as the 'test3' user copy the collection
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
        cms.copy("/db/securityTest3/source", "/db/securityTest3", "copy-of-source");
    }
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

     * permissions on the dest resource must also be writable
     */
    @Test(expected=XMLDBException.class)
    public void copyCollectionWithResources_destResourceExists_destResourceIsNotWritable() throws XMLDBException {
        Collection test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test1", "test1");
        CollectionManagementServiceImpl cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");

        //create collection owned by "test1", and group "users" in /db/securityTest3
        Collection source = cms.createCollection("source");

        //create resource owned by "test1", and group "users" in /db/securityTest3/source
        Resource resSource = source.createResource("source1.xml", XMLResource.RESOURCE_TYPE);
        resSource.setContent("<test1/>");
        source.storeResource(resSource);

        resSource = source.createResource("source2.xml", XMLResource.RESOURCE_TYPE);
        resSource.setContent("<test2/>");
        source.storeResource(resSource);
       
        //pre-create the destination and set writable by all
        final Collection dest = cms.createCollection("copy-of-source");
        UserManagementService ums = (UserManagementService) dest.getService("UserManagementService", "1.0");
        ums.chmod(0777);
       
        //pre-create a destination resource and set no access to group and others
        Resource resDestSource1 = dest.createResource("source1.xml", XMLResource.RESOURCE_TYPE);
        resDestSource1.setContent("<old/>");
        dest.storeResource(resDestSource1);
        ums.chmod(resDestSource1, 0700);
       
       
        //as the 'test3' user copy the collection
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
        cms.copy("/db/securityTest3/source", "/db/securityTest3", "copy-of-source");
       
        final Collection copyOfSource = test.getChildCollection("copy-of-source");
        assertNotNull(copyOfSource);
        assertEquals(2, copyOfSource.listResources().length);
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.