use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class RecordFolderChildrenRelation method readAll.
@Override
@WebApiDescription(title = "Return a paged list of records for the record folder identified by 'recordFolderId'")
public CollectionWithPagingInfo<Record> readAll(String recordFolderId, Parameters parameters) {
checkNotBlank("recordFolderId", recordFolderId);
mandatory("parameters", parameters);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
// list record folders
// FIXME searchParam
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForUnfiledEndpoint(parameters, null);
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, null, searchTypeQNames, null, apiUtils.getSortProperties(parameters), null, Util.getPagingRequest(parameters.getPaging()));
final List<FileInfo> page = pagingResults.getPage();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
List<Record> nodes = new AbstractList<Record>() {
@Override
public Record get(int index) {
FileInfo info = page.get(index);
return nodesModelFactory.createRecord(info, parameters, mapUserInfo, true);
}
@Override
public int size() {
return page.size();
}
};
RecordFolder sourceEntity = null;
if (parameters.includeSource()) {
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
sourceEntity = nodesModelFactory.createRecordFolder(info, parameters, mapUserInfo, true);
}
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class RecordFolderChildrenRelation method create.
@Override
@WebApiDescription(title = "Create one (or more) records as children of a record folder identified by 'recordFolderId'")
public List<Record> create(String recordFolderId, List<Record> nodeInfos, Parameters parameters) {
checkNotBlank("recordFolderId", recordFolderId);
mandatory("nodeInfos", nodeInfos);
mandatory("parameters", parameters);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>() {
public List<NodeRef> execute() {
List<NodeRef> createdNodes = new LinkedList<>();
for (Record nodeInfo : nodeInfos) {
NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo, parameters);
createdNodes.add(newNodeRef);
}
return createdNodes;
}
};
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Get the nodes info
List<Record> result = new LinkedList<>();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
for (NodeRef newNodeRef : createdNodes) {
FileInfo info = fileFolderService.getFileInfo(newNodeRef);
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
result.add(nodesModelFactory.createRecord(info, parameters, mapUserInfo, false));
}
return result;
}
use of org.alfresco.service.cmr.model.FileInfo 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.FileInfo in project records-management by Alfresco.
the class RM1027Test method testCopyingAFolderWithADispositionSchedule.
public void testCopyingAFolderWithADispositionSchedule() throws Exception {
final NodeRef recordFolder = doTestInTransaction(new Test<NodeRef>() {
@Override
public NodeRef run() {
// create a folder
NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, "My Closed Record Folder");
// show that the default disposition schedule has been applied
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
return recordFolder;
}
});
doTestInTransaction(new Test<NodeRef>() {
@Override
public NodeRef run() throws Exception {
// create a destination for the copy
NodeRef destination = filePlanService.createRecordCategory(filePlan, "Copy Destination");
// try and copy the closed record folder
FileInfo copyInfo = fileFolderService.copy(recordFolder, destination, null);
return copyInfo.getNodeRef();
}
@Override
public void test(NodeRef copy) throws Exception {
assertNotNull(copy);
assertNotNull(nodeService.getProperty(copy, PROP_IDENTIFIER));
assertFalse(nodeService.hasAspect(copy, ASPECT_DISPOSITION_LIFECYCLE));
}
});
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class FilePlanChildrenRelation method create.
@Override
@WebApiDescription(title = "Create one (or more) record categories as children of container identified by 'filePlanId'")
public List<RecordCategory> create(String filePlanId, List<RecordCategory> nodeInfos, Parameters parameters) {
checkNotBlank("filePlanId", filePlanId);
mandatory("nodeInfos", nodeInfos);
mandatory("parameters", parameters);
QName filePlanType = apiUtils.getFilePlanType();
if (// rm site not created
filePlanType == null) {
throw new EntityNotFoundException(filePlanId);
}
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>() {
public List<NodeRef> execute() {
List<NodeRef> createdNodes = new LinkedList<>();
for (RecordCategory nodeInfo : nodeInfos) {
// Create the node
nodeInfo.setNodeType(RECORD_CATEGORY_TYPE);
NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo, parameters);
createdNodes.add(newNodeRef);
}
return createdNodes;
}
};
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Get the nodes info
List<RecordCategory> result = new ArrayList<>(nodeInfos.size());
Map<String, UserInfo> mapUserInfo = new HashMap<>();
for (NodeRef newNodeRef : createdNodes) {
FileInfo info = fileFolderService.getFileInfo(newNodeRef);
result.add(nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, false));
}
return result;
}
Aggregations