use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class RecordFolderChildrenRelation method create.
@Override
@WebApiDescription(title = "Upload file content and meta-data into the repository.")
@WebApiParam(name = "formData", title = "A single form data", description = "A single form data which holds FormFields.")
public Record create(String recordFolderId, FormData formData, Parameters parameters, WithResponse withResponse) {
checkNotBlank("recordFolderId", recordFolderId);
mandatory("formData", formData);
mandatory("parameters", parameters);
// Retrieve the input data and resolve the parent node
final UploadInfo uploadInfo = new UploadInfo(formData);
final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER, uploadInfo.getRelativePath());
// Create the record
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>() {
public NodeRef execute() {
return apiUtils.uploadRecord(parentNodeRef, uploadInfo, parameters);
}
};
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Get file info for response
FileInfo info = fileFolderService.getFileInfo(newNode);
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
return nodesModelFactory.createRecord(info, parameters, null, false);
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class TransferContainerEntityResource method update.
@Override
@WebApiDescription(title = "Update transfer container", description = "Updates a transfer container with id 'transferContainerId'")
public TransferContainer update(String transferContainerId, TransferContainer transferContainerInfo, Parameters parameters) {
checkNotBlank("transferContainerId", transferContainerId);
mandatory("transferContainerInfo", transferContainerInfo);
mandatory("parameters", parameters);
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(transferContainerId, RecordsManagementModel.TYPE_TRANSFER_CONTAINER);
// update info
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>() {
public Void execute() {
apiUtils.updateTransferContainer(nodeRef, transferContainerInfo, parameters);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>() {
public FileInfo execute() {
return fileFolderService.getFileInfo(nodeRef);
}
};
FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
return nodesModelFactory.createTransferContainer(info, parameters, null, false);
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class TransferContainerEntityResource method readById.
@WebApiDescription(title = "Get transfer container information", description = "Gets information for a transfer container with id 'transferContainerId'")
@WebApiParam(name = "transferContainerId", title = "The transfer container id")
@Override
public TransferContainer readById(String transferContainerId, Parameters parameters) throws EntityNotFoundException {
checkNotBlank("transferContainerId", transferContainerId);
mandatory("parameters", parameters);
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(transferContainerId, RecordsManagementModel.TYPE_TRANSFER_CONTAINER);
FileInfo info = fileFolderService.getFileInfo(nodeRef);
return nodesModelFactory.createTransferContainer(info, parameters, null, false);
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class TransferChildrenRelation method readAll.
@Override
@WebApiDescription(title = "Return a paged list of record folders or records for the transfer identified by 'transferId'")
public CollectionWithPagingInfo<TransferChild> readAll(String transferId, Parameters parameters) {
checkNotBlank("transferId", transferId);
mandatory("parameters", parameters);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(transferId, RecordsManagementModel.TYPE_TRANSFER);
// list record folder, electronic record or non electronic record
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, null, null, null, apiUtils.getSortProperties(parameters), null, Util.getPagingRequest(parameters.getPaging()));
final List<FileInfo> page = pagingResults.getPage();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
List<TransferChild> nodes = new AbstractList<TransferChild>() {
@Override
public TransferChild get(int index) {
FileInfo info = page.get(index);
return nodesModelFactory.createTransferChild(info, parameters, mapUserInfo, true);
}
@Override
public int size() {
return page.size();
}
};
Transfer sourceEntity = null;
if (parameters.includeSource()) {
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
sourceEntity = nodesModelFactory.createTransfer(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 RM1027Test method testCopyingAClosedFolder.
public void testCopyingAClosedFolder() throws Exception {
final NodeRef recordFolder = doTestInTransaction(new Test<NodeRef>() {
@Override
public NodeRef run() {
// create a folder and close it
NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, "My Closed Record Folder");
utils.closeFolder(recordFolder);
assertTrue((Boolean) nodeService.getProperty(recordFolder, PROP_IS_CLOSED));
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((Boolean) nodeService.getProperty(copy, PROP_IS_CLOSED));
}
});
}
Aggregations