Search in sources :

Example 31 with RunAsWork

use of org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork in project records-management by Alfresco.

the class RM978Test method testCopyDocumentInFolderInRmSite.

public void testCopyDocumentInFolderInRmSite() {
    doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) {

        private NodeRef folder1;

        private NodeRef document1;

        private String document1Name = GUID.generate();

        private NodeRef rmCategory;

        private NodeRef rmFolder;

        public void given() {
            folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
            document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef();
            runAs(new RunAsWork<Void>() {

                public Void doWork() throws Exception {
                    rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
                    rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate());
                    return null;
                }
            }, getAdminUserName());
        }

        public void when() throws FileExistsException, FileNotFoundException {
            runAs(new RunAsWork<Void>() {

                public Void doWork() throws Exception {
                    filePlanPermissionService.setPermission(rmFolder, user, RMPermissionModel.FILING);
                    return null;
                }
            }, getAdminUserName());
            fileFolderService.copy(document1, rmFolder, null);
        }
    });
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RunAsWork(org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) FileExistsException(org.alfresco.service.cmr.model.FileExistsException)

Example 32 with RunAsWork

use of org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork in project records-management by Alfresco.

the class RM978Test method testMoveFolderInFolderInRmSite.

public void testMoveFolderInFolderInRmSite() {
    doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) {

        private NodeRef folder1;

        private NodeRef rmCategory;

        private NodeRef rmFolder;

        public void given() {
            folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
            runAs(new RunAsWork<Void>() {

                public Void doWork() throws Exception {
                    rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
                    rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate());
                    return null;
                }
            }, getAdminUserName());
        }

        public void when() throws FileExistsException, FileNotFoundException {
            fileFolderService.move(folder1, rmFolder, GUID.generate());
        }
    });
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RunAsWork(org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) FileExistsException(org.alfresco.service.cmr.model.FileExistsException)

Example 33 with RunAsWork

use of org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork in project records-management by Alfresco.

the class RM978Test method testMoveDocumentInFolderInRmSite.

public void testMoveDocumentInFolderInRmSite() {
    doBehaviourDrivenTest(new BehaviourDrivenTest(user) {

        private NodeRef folder1;

        private NodeRef document1;

        private String document1Name = GUID.generate();

        private NodeRef rmCategory;

        private NodeRef rmFolder;

        public void given() {
            folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
            document1 = fileFolderService.create(folder1, document1Name, ContentModel.TYPE_CONTENT).getNodeRef();
            runAs(new RunAsWork<Void>() {

                public Void doWork() throws Exception {
                    rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
                    rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate());
                    return null;
                }
            }, getAdminUserName());
        }

        public void when() throws FileExistsException, FileNotFoundException {
            runAs(new RunAsWork<Void>() {

                public Void doWork() throws Exception {
                    filePlanPermissionService.setPermission(rmFolder, user, RMPermissionModel.FILING);
                    return null;
                }
            }, getAdminUserName());
            fileFolderService.move(document1, rmFolder, null);
        }

        public void then() {
            List<ChildAssociationRef> folder1ChildAssocs = nodeService.getChildAssocs(folder1);
            assertEquals(0, folder1ChildAssocs.size());
            List<ChildAssociationRef> rmFolderChildAssocs = nodeService.getChildAssocs(rmFolder);
            assertEquals(1, rmFolderChildAssocs.size());
            NodeRef movedDocument = rmFolderChildAssocs.iterator().next().getChildRef();
            String recordIdentifier = (String) nodeService.getProperty(movedDocument, RecordsManagementModel.PROP_IDENTIFIER);
            assertNotNull(recordIdentifier);
            String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME);
            assertEquals(document1Name + " (" + recordIdentifier + ")", movedDocumentName);
        }
    });
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RunAsWork(org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException) ArrayList(java.util.ArrayList) List(java.util.List) FileExistsException(org.alfresco.service.cmr.model.FileExistsException)

Example 34 with RunAsWork

use of org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork in project records-management by Alfresco.

the class RM978Test method testCopyFolderInFolderInRmSite.

public void testCopyFolderInFolderInRmSite() {
    doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class, user) {

        private NodeRef folder1;

        private NodeRef rmCategory;

        private NodeRef rmFolder;

        public void given() {
            folder1 = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
            runAs(new RunAsWork<Void>() {

                public Void doWork() throws Exception {
                    rmCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
                    rmFolder = recordFolderService.createRecordFolder(rmCategory, GUID.generate());
                    return null;
                }
            }, getAdminUserName());
        }

        public void when() throws FileExistsException, FileNotFoundException {
            fileFolderService.copy(folder1, rmFolder, GUID.generate());
        }
    });
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RunAsWork(org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) FileExistsException(org.alfresco.service.cmr.model.FileExistsException)

Aggregations

RunAsWork (org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork)34 NodeRef (org.alfresco.service.cmr.repository.NodeRef)26 HashMap (java.util.HashMap)11 Serializable (java.io.Serializable)8 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)7 FileNotFoundException (org.alfresco.service.cmr.model.FileNotFoundException)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 FileExistsException (org.alfresco.service.cmr.model.FileExistsException)4 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)4 QName (org.alfresco.service.namespace.QName)4 HashSet (java.util.HashSet)3 Map (java.util.Map)3 Set (java.util.Set)3 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)3 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)3 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)3 Version (org.alfresco.service.cmr.version.Version)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2