use of org.alfresco.rest.framework.WebApiParam 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.rest.framework.WebApiParam in project alfresco-remote-api by Alfresco.
the class NodeRatingsRelation method create.
/**
* Create a rating for the node with id 'nodeId'.
*/
@Override
@WebApiDescription(title = "Rate a node for 'nodeId'.")
@WebApiParam(name = "ratingEntity", title = "A single rating", description = "A single node rating, multiple ratings are not supported.", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple = false, required = true)
public List<NodeRating> create(String nodeId, List<NodeRating> ratingEntity, Parameters parameters) {
// There will always be 1 value because allowMultiple=false
NodeRating rating = ratingEntity.get(0);
String ratingSchemeId = rating.getScheme();
nodeRatings.addRating(nodeId, ratingSchemeId, rating.getMyRating());
return Collections.singletonList(nodeRatings.getNodeRating(nodeId, ratingSchemeId));
}
use of org.alfresco.rest.framework.WebApiParam 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);
}
use of org.alfresco.rest.framework.WebApiParam in project records-management by Alfresco.
the class UnfiledRecordFolderEntityResource method readById.
@WebApiDescription(title = "Get unfiled record folder information", description = "Gets information for an unfiled record folder with id 'unfiledRecordFolderId'")
@WebApiParam(name = "unfiledRecordFolderId", title = "The unfiled record folder id")
public UnfiledRecordFolder readById(String unfiledRecordFolderId, Parameters parameters) {
checkNotBlank("unfiledRecordFolderId", unfiledRecordFolderId);
mandatory("parameters", parameters);
String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, relativePath, true);
FileInfo info = fileFolderService.getFileInfo(nodeRef);
return nodesModelFactory.createUnfiledRecordFolder(info, parameters, null, false);
}
use of org.alfresco.rest.framework.WebApiParam in project records-management by Alfresco.
the class RecordCategoriesEntityResource method readById.
@WebApiDescription(title = "Get record category information", description = "Gets information for a record category with id 'recordCategoryId'")
@WebApiParam(name = "recordCategoryId", title = "The record category id")
public RecordCategory readById(String recordCategoryId, Parameters parameters) {
checkNotBlank("recordCategoryId", recordCategoryId);
mandatory("parameters", parameters);
String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY, relativePath, true);
FileInfo info = fileFolderService.getFileInfo(nodeRef);
return nodesModelFactory.createRecordCategory(info, parameters, null, false);
}
Aggregations