use of org.alfresco.rm.rest.api.model.UploadInfo 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.rm.rest.api.model.UploadInfo in project records-management by Alfresco.
the class UnfiledContainerChildrenRelation method create.
@Override
@WebApiDescription(title = "Upload file content and meta-data into a unfiled record container identified by 'unfiledContainerId'.")
@WebApiParam(name = "formData", title = "A single form data", description = "A single form data which holds FormFields.")
public UnfiledContainerChild create(String unfiledContainerId, FormData formData, Parameters parameters, WithResponse withResponse) {
checkNotBlank("unfiledContainerId", unfiledContainerId);
mandatory("formData", formData);
mandatory("parameters", parameters);
UploadInfo uploadInfo = new UploadInfo(formData);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
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.createUnfiledContainerChild(info, parameters, null, false);
}
use of org.alfresco.rm.rest.api.model.UploadInfo in project records-management by Alfresco.
the class UnfiledRecordFolderChildrenRelation 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 UnfiledRecordFolderChild create(String unfiledRecordFolderId, FormData formData, Parameters parameters, WithResponse withResponse) {
checkNotBlank("unfiledRecordFolderId", unfiledRecordFolderId);
mandatory("formData", formData);
mandatory("parameters", parameters);
// Retrieve the input data and resolve the parent node
final UploadInfo uploadInfo = new UploadInfo(formData);
// Create the record - returns pair(newNode,parentNode)
RetryingTransactionCallback<Pair<NodeRef, NodeRef>> callback = new RetryingTransactionCallback<Pair<NodeRef, NodeRef>>() {
public Pair<NodeRef, NodeRef> execute() {
final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, uploadInfo.getRelativePath());
NodeRef newNode = apiUtils.uploadRecord(parentNodeRef, uploadInfo, parameters);
return new Pair<NodeRef, NodeRef>(newNode, parentNodeRef);
}
};
Pair<NodeRef, NodeRef> nodeAndParentInfo = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
NodeRef newNode = nodeAndParentInfo.getFirst();
NodeRef parent = nodeAndParentInfo.getSecond();
// Get file info for response
FileInfo info = fileFolderService.getFileInfo(newNode);
apiUtils.postActivity(info, parent, ActivityType.FILE_ADDED);
return nodesModelFactory.createUnfiledRecordFolderChild(info, parameters, null, false);
}
Aggregations