Examples of CollectionManagementServiceImpl


Examples of org.exist.xmldb.CollectionManagementServiceImpl


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

        //create the /db/securityTest2/test.xml resource
        Resource resource = test.createResource("test.xml", XMLResource.RESOURCE_TYPE);
        resource.setContent("<test/>");
        test.storeResource(resource);

        //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 copy /db/securityTest2/test.xml to /db/securityTest2/parentCollection/test.xml
        //as user3, it should have it's group set to the primary group of user3 i.e. 'guest'
        //as the collection is NOT setGid and it should not have the setGid bit
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest2", "test3", "test3");
        cms = (CollectionManagementServiceImpl)test.getService("CollectionManagementService", "1.0");
        cms.copyResource("test.xml", "/db/securityTest2/parentCollection", "test.xml");
        ums = (UserManagementService)parentCollection.getService("UserManagementService", "1.0");

        parentCollection = test.getChildCollection("parentCollection");
        resource = parentCollection.getResource("test.xml");
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

    }

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

        //create the /db/securityTest2/test.xml resource
        Resource resource = test.createResource("test.xml", XMLResource.RESOURCE_TYPE);
        resource.setContent("<test/>");
        test.storeResource(resource);
        ums.chgrp(resource, "extusers");

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

        //now copy /db/securityTest2/test.xml to /db/securityTest2/parentCollection/test.xml
        //as "user3:guest", it should inherit the group ownership 'users' from the parent collection which is setGid
        //and it should NOT have its setGid bit set as it is a resource
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest2", "test3", "test3");
        cms = (CollectionManagementServiceImpl)test.getService("CollectionManagementService", "1.0");
        cms.copyResource("test.xml", "/db/securityTest2/parentCollection", "test.xml");
        ums = (UserManagementService)parentCollection.getService("UserManagementService", "1.0");

        parentCollection = test.getChildCollection("parentCollection");
        resource = parentCollection.getResource("test.xml");
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

                    log( msg, Project.MSG_ERR );
                }

            } else {
                log( "Create collection management service for collection " + base.getName(), Project.MSG_DEBUG );
                final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl)base.getService( "CollectionManagementService", "1.0" );

                if( resource != null ) {
                    log( "Copying resource: " + resource, Project.MSG_INFO );
                    final Resource res = base.getResource( resource );

                    if( res == null ) {
                        final String msg = "Resource " + resource + " not found.";

                        if( failonerror ) {
                            throw( new BuildException( msg ) );
                        } else {
                            log( msg, Project.MSG_ERR );
                        }
                    } else {

                        //XmldbURI resource = XmldbURI.create(resource);
                        service.copyResource( XmldbURI.xmldbUriFor( resource ), XmldbURI.xmldbUriFor( destination ), XmldbURI.xmldbUriFor( name ) );
                    }

                } else {
                    log( "Copying collection: " + collection, Project.MSG_INFO );
                    service.copy( XmldbURI.xmldbUriFor( collection ), XmldbURI.xmldbUriFor( destination ), XmldbURI.xmldbUriFor( name ) );
                }
            }
        }
        catch( final XMLDBException e ) {
            final String msg = "XMLDB exception during copy: " + e.getMessage();
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

                final Resource resource = collection.getResource(doc.toString());
                if (resource == null) {
                    logger.error( "Resource " + doc + " not found");
                    throw new XPathException(this, "Resource " + doc + " not found");
                }
                final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl) collection.getService("CollectionManagementService", "1.0");
                service.moveResource(doc, destination, null);
            } catch (final XMLDBException e) {
                logger.error(e.getMessage());
                throw new XPathException(this, "XMLDB exception caught: " + e.getMessage(), e);
            }
        } else {
            try {
                final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl) collection.getService("CollectionManagementService", "1.0");
                service.move(XmldbURI.xmldbUriFor(collection.getName()),
                        destination, null);

            } catch (final XMLDBException e) {
                logger.error(e.getMessage());
                throw new XPathException(this, "Cannot move collection: " + e.getMessage(), e);
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

                final Resource resource = collection.getResource(doc.toString());
                if (resource == null) {
        logger.error("Resource " + doc + " not found");
                    throw new XPathException(this, "Resource " + doc + " not found");
                }
                final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl) collection.getService("CollectionManagementService", "1.0");
                service.copyResource(doc, destination, null);
            } catch (final XMLDBException e) {
    logger.error("XMLDB exception caught: ", e);
                throw new XPathException(this, "XMLDB exception caught: " + e.getMessage(), e);
            }
           
        } else {
            try {
                final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl) collection.getService("CollectionManagementService", "1.0");
                // DWES to check not sure about XmldbURI.xmldbUriFor() here.
                service.copy(XmldbURI.xmldbUriFor(collection.getName()), destination, null);

            } catch (final XMLDBException e) {
    logger.error("Cannot copy collection: ", e);
                throw new XPathException(this, "Cannot copy collection: " + e.getMessage(), e);
View Full Code Here

Examples of org.exist.xmldb.CollectionManagementServiceImpl

                    logger.error("Resource " + doc + " not found");

          throw new XPathException(this, "Resource " + doc + " not found");
                }
               final String newName = args[2].itemAt(0).getStringValue();
         final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl)
          collection.getService("CollectionManagementService", "1.0");
        service.moveResource(doc, (XmldbURI) null,
                        XmldbURI.xmldbUriFor(newName));
      } catch (final XMLDBException e) {
                logger.error(e.getMessage());

        throw new XPathException(this, "XMLDB exception caught: " + e.getMessage(), e);
               
      } catch (final URISyntaxException e) {
                logger.error(e.getMessage());

                throw new XPathException(this, "URI exception: " + e.getMessage(), e);
            }

    } else {
      try {
                final String newName = args[1].itemAt(0).getStringValue();
        final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl)
          collection.getService("CollectionManagementService", "1.0");
        service.move(XmldbURI.xmldbUriFor(collection.getName()), null,
                        XmldbURI.xmldbUriFor(newName));

      } catch (final XMLDBException e) {
                logger.error("Cannot rename collection: " + e.getMessage());
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.