Search in sources :

Example 51 with WebApiDescription

use of org.alfresco.rest.framework.WebApiDescription in project records-management by Alfresco.

the class FilePlanEntityResource method update.

@Override
@WebApiDescription(title = "Update file plan", description = "Updates a filePlan with id 'filePlanId'")
public FilePlan update(String filePlanId, FilePlan filePlanInfo, Parameters parameters) {
    checkNotBlank("filePlanId", filePlanId);
    mandatory("filePlanInfo", filePlanInfo);
    mandatory("parameters", parameters);
    QName filePlanType = apiUtils.getFilePlanType();
    if (// rm site not created
    filePlanType == null) {
        throw new EntityNotFoundException(filePlanId);
    }
    NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
    RetryingTransactionCallback<Void> updateCallback = new RetryingTransactionCallback<Void>() {

        public Void execute() {
            apiUtils.updateNode(nodeRef, filePlanInfo, parameters);
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(updateCallback, 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.createFilePlan(info, parameters, null, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) QName(org.alfresco.service.namespace.QName) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 52 with WebApiDescription

use of org.alfresco.rest.framework.WebApiDescription in project records-management by Alfresco.

the class FilePlanEntityResource method readById.

@WebApiDescription(title = "Get file plan information", description = "Get information for a file plan with id 'filePlanId'")
@WebApiParam(name = "filePlanId", title = "The file plan id")
public FilePlan readById(String filePlanId, Parameters parameters) {
    checkNotBlank("filePlanId", filePlanId);
    mandatory("parameters", parameters);
    QName filePlanType = apiUtils.getFilePlanType();
    if (// rm site not created
    filePlanType == null) {
        throw new EntityNotFoundException(filePlanId);
    }
    NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
    FileInfo info = fileFolderService.getFileInfo(nodeRef);
    return nodesModelFactory.createFilePlan(info, parameters, null, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) QName(org.alfresco.service.namespace.QName) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Aggregations

WebApiDescription (org.alfresco.rest.framework.WebApiDescription)52 NodeRef (org.alfresco.service.cmr.repository.NodeRef)47 FileInfo (org.alfresco.service.cmr.model.FileInfo)34 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)16 HashMap (java.util.HashMap)14 UserInfo (org.alfresco.rest.api.model.UserInfo)13 WebApiParam (org.alfresco.rest.framework.WebApiParam)13 AbstractList (java.util.AbstractList)12 QName (org.alfresco.service.namespace.QName)11 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)8 LinkedList (java.util.LinkedList)5 List (java.util.List)5 QNamePattern (org.alfresco.service.namespace.QNamePattern)5 ArrayList (java.util.ArrayList)4 Operation (org.alfresco.rest.framework.Operation)4 Version (org.alfresco.service.cmr.version.Version)4 RegexQNamePattern (org.alfresco.service.namespace.RegexQNamePattern)4 FilterProp (org.alfresco.repo.node.getchildren.FilterProp)3 IntegrityException (org.alfresco.repo.node.integrity.IntegrityException)3 Node (org.alfresco.rest.api.model.Node)3