Search in sources :

Example 11 with FileExistsException

use of org.alfresco.service.cmr.model.FileExistsException 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 12 with FileExistsException

use of org.alfresco.service.cmr.model.FileExistsException 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

FileExistsException (org.alfresco.service.cmr.model.FileExistsException)12 NodeRef (org.alfresco.service.cmr.repository.NodeRef)10 FileNotFoundException (org.alfresco.service.cmr.model.FileNotFoundException)8 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)4 RunAsWork (org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork)4 FileInfo (org.alfresco.service.cmr.model.FileInfo)4 Serializable (java.io.Serializable)3 HashMap (java.util.HashMap)3 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)3 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)3 ContentData (org.alfresco.service.cmr.repository.ContentData)3 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)3 IOException (java.io.IOException)2 Map (java.util.Map)2 IntegrityException (org.alfresco.repo.node.integrity.IntegrityException)2 ContentIOException (org.alfresco.service.cmr.repository.ContentIOException)2 NodeService (org.alfresco.service.cmr.repository.NodeService)2 QName (org.alfresco.service.namespace.QName)2 ConcurrencyFailureException (org.springframework.dao.ConcurrencyFailureException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1