use of org.alfresco.service.cmr.model.FileNotFoundException in project records-management by Alfresco.
the class RM2190Test method testUploadDocumentsSimultaneouslyWithRules.
public void testUploadDocumentsSimultaneouslyWithRules() {
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
rootFolder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef();
Action createAction = actionService.createAction(CreateRecordAction.NAME);
createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan);
Rule declareRule = new Rule();
declareRule.setRuleType(INBOUND);
declareRule.setTitle(generate());
declareRule.setAction(createAction);
declareRule.setExecuteAsynchronously(true);
declareRule.applyToChildren(true);
ruleService.saveRule(rootFolder, declareRule);
folder1 = fileFolderService.create(rootFolder, generate(), TYPE_FOLDER).getNodeRef();
folder2 = fileFolderService.create(rootFolder, generate(), TYPE_FOLDER).getNodeRef();
Action fileAction = actionService.createAction(FileToAction.NAME);
fileAction.setParameterValue(FileToAction.PARAM_PATH, PATH);
fileAction.setParameterValue(FileToAction.PARAM_CREATE_RECORD_PATH, true);
Rule fileRule = new Rule();
fileRule.setRuleType(INBOUND);
fileRule.setTitle(generate());
fileRule.setAction(fileAction);
fileRule.setExecuteAsynchronously(true);
ruleService.saveRule(unfiledContainer, fileRule);
return null;
}
@Override
public void test(Void result) throws Exception {
assertFalse(ruleService.getRules(rootFolder).isEmpty());
assertFalse(ruleService.getRules(unfiledContainer).isEmpty());
}
});
doTestInTransaction(new Test<Void>() {
@Override
public Void run() throws FileNotFoundException, InterruptedException {
Thread thread1 = new Thread() {
public void run() {
List<NodeRef> files = addFilesToFolder(folder1);
waitForFilesToBeDeclared(files);
}
};
Thread thread2 = new Thread() {
public void run() {
List<NodeRef> files = addFilesToFolder(folder2);
waitForFilesToBeDeclared(files);
}
};
thread1.start();
thread2.start();
thread1.join(300000);
thread2.join(300000);
return null;
}
@Override
public void test(Void result) throws Exception {
FileInfo category = fileFolderService.resolveNamePath(filePlan, asList(tokenizeToStringArray(PATH, "/", false, true)));
assertEquals(NUMBER_IN_BATCH * 2, nodeService.getChildAssocs(category.getNodeRef()).size());
}
});
}
use of org.alfresco.service.cmr.model.FileNotFoundException in project records-management by Alfresco.
the class CopyMoveLinkFileToBaseAction method executeImpl.
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
protected synchronized void executeImpl(final Action action, final NodeRef actionedUponNodeRef) {
String actionName = action.getActionDefinitionName();
if (isOkToProceedWithAction(actionedUponNodeRef, actionName)) {
QName actionedUponType = getNodeService().getType(actionedUponNodeRef);
boolean targetIsUnfiledRecords;
if (ACTION_FILETO.equals(action.getActionDefinitionName())) {
targetIsUnfiledRecords = false;
} else {
targetIsUnfiledRecords = (getDictionaryService().isSubClass(actionedUponType, ContentModel.TYPE_CONTENT) && !getRecordService().isFiled(actionedUponNodeRef)) || TYPE_UNFILED_RECORD_FOLDER.equals(actionedUponType);
}
// first look to see if the destination record folder has been specified
NodeRef recordFolder = (NodeRef) action.getParameterValue(PARAM_DESTINATION_RECORD_FOLDER);
if (recordFolder == null) {
recordFolder = createOrResolvePath(action, actionedUponNodeRef, targetIsUnfiledRecords);
}
// now we have the reference to the target folder we can do some final checks to see if the action is valid
validateActionPostPathResolution(actionedUponNodeRef, recordFolder, actionName, targetIsUnfiledRecords);
final NodeRef finalRecordFolder = recordFolder;
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
@Override
public Void doWork() {
try {
if (getMode() == CopyMoveLinkFileToActionMode.MOVE) {
fileFolderService.move(actionedUponNodeRef, finalRecordFolder, null);
} else if (getMode() == CopyMoveLinkFileToActionMode.COPY) {
fileFolderService.copy(actionedUponNodeRef, finalRecordFolder, null);
} else if (getMode() == CopyMoveLinkFileToActionMode.LINK) {
getRecordService().link(actionedUponNodeRef, finalRecordFolder);
}
} catch (FileNotFoundException fileNotFound) {
throw new AlfrescoRuntimeException("Unable to execute file to action, because the " + (mode == CopyMoveLinkFileToActionMode.MOVE ? "move" : "copy") + " operation failed.", fileNotFound);
}
return null;
}
});
}
}
use of org.alfresco.service.cmr.model.FileNotFoundException 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);
}
});
}
use of org.alfresco.service.cmr.model.FileNotFoundException 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());
}
});
}
use of org.alfresco.service.cmr.model.FileNotFoundException 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);
}
});
}
Aggregations