Search in sources :

Example 6 with WebApiParam

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);
}
Also used : UploadInfo(org.alfresco.rm.rest.api.model.UploadInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Example 7 with WebApiParam

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));
}
Also used : NodeRating(org.alfresco.rest.api.model.NodeRating) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Example 8 with WebApiParam

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);
}
Also used : UploadInfo(org.alfresco.rm.rest.api.model.UploadInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) Pair(org.alfresco.util.Pair) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Example 9 with WebApiParam

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Example 10 with WebApiParam

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Aggregations

WebApiParam (org.alfresco.rest.framework.WebApiParam)14 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)13 FileInfo (org.alfresco.service.cmr.model.FileInfo)11 NodeRef (org.alfresco.service.cmr.repository.NodeRef)11 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)3 UploadInfo (org.alfresco.rm.rest.api.model.UploadInfo)3 ArrayList (java.util.ArrayList)2 Annotation (java.lang.annotation.Annotation)1 NodeRating (org.alfresco.rest.api.model.NodeRating)1 Person (org.alfresco.rest.api.model.Person)1 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)1 MultiPartRelationshipResourceAction (org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction)1 RelationshipResourceAction (org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction)1 QName (org.alfresco.service.namespace.QName)1 Pair (org.alfresco.util.Pair)1