Search in sources :

Example 1 with WebApiDescription

use of org.alfresco.rest.framework.WebApiDescription in project alfresco-remote-api by Alfresco.

the class TaskVariablesRelation method readAll.

/**
 * List the tasks variables.
 *
 * @see org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction.Read#readAll(java.lang.String, org.alfresco.rest.framework.resource.parameters.Parameters)
 */
@Override
@WebApiDescription(title = "Get Task Variables", description = "Get a paged list of the task variables")
public CollectionWithPagingInfo<TaskVariable> readAll(String taskId, Parameters parameters) {
    VariableScope scope = VariableScope.ANY;
    if (parameters.getQuery() != null) {
        TaskVariablesWalkerCallback callback = new TaskVariablesWalkerCallback();
        QueryHelper.walk(parameters.getQuery(), callback);
        scope = callback.getScope();
    }
    return tasks.getTaskVariables(taskId, parameters.getPaging(), scope);
}
Also used : TaskVariablesWalkerCallback(org.alfresco.rest.workflow.api.impl.TaskVariablesWalkerCallback) VariableScope(org.alfresco.rest.workflow.api.model.VariableScope) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 2 with WebApiDescription

use of org.alfresco.rest.framework.WebApiDescription in project alfresco-remote-api by Alfresco.

the class NodeParentsRelation method readAll.

/**
 * List child node's parent(s) based on (parent ->) child associations.
 * Returns primary parent & also secondary parents, if any.
 *
 * @param childNodeId String id of child node
 */
@Override
@WebApiDescription(title = "Return a list of parent nodes based on child assocs")
public CollectionWithPagingInfo<Node> readAll(String childNodeId, Parameters parameters) {
    NodeRef childNodeRef = nodes.validateOrLookupNode(childNodeId, null);
    QNamePattern assocTypeQNameParam = RegexQNamePattern.MATCH_ALL;
    Boolean isPrimary = null;
    Query q = parameters.getQuery();
    if (q != null) {
        MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(WHERE_PARAMS_PARENTS, null);
        QueryHelper.walk(q, propertyWalker);
        isPrimary = propertyWalker.getProperty(Nodes.PARAM_ISPRIMARY, WhereClauseParser.EQUALS, Boolean.class);
        String assocTypeQNameStr = propertyWalker.getProperty(Nodes.PARAM_ASSOC_TYPE, WhereClauseParser.EQUALS, String.class);
        if (assocTypeQNameStr != null) {
            assocTypeQNameParam = nodes.getAssocType(assocTypeQNameStr);
        }
    }
    List<ChildAssociationRef> childAssocRefs = null;
    if (assocTypeQNameParam.equals(RegexQNamePattern.MATCH_ALL)) {
        childAssocRefs = nodeService.getParentAssocs(childNodeRef);
    } else {
        childAssocRefs = nodeService.getParentAssocs(childNodeRef, assocTypeQNameParam, RegexQNamePattern.MATCH_ALL);
    }
    return listNodeChildAssocs(childAssocRefs, parameters, isPrimary, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Query(org.alfresco.rest.framework.resource.parameters.where.Query) MapBasedQueryWalker(org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) QNamePattern(org.alfresco.service.namespace.QNamePattern) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 3 with WebApiDescription

use of org.alfresco.rest.framework.WebApiDescription in project alfresco-remote-api by Alfresco.

the class NodeTargetsRelation method delete.

@Override
@WebApiDescription(title = "Remove node assoc(s)")
public void delete(String sourceNodeId, String targetNodeId, Parameters parameters) {
    NodeRef srcNodeRef = nodes.validateNode(sourceNodeId);
    NodeRef tgtNodeRef = nodes.validateNode(targetNodeId);
    String assocTypeStr = parameters.getParameter(Nodes.PARAM_ASSOC_TYPE);
    QNamePattern assocTypeQName = nodes.getAssocType(assocTypeStr, false);
    if (assocTypeQName == null) {
        assocTypeQName = RegexQNamePattern.MATCH_ALL;
    }
    // note: even if assocType is provided, we currently don't use nodeService.removeAssociation(srcNodeRef, tgtNodeRef, assocTypeQName);
    // since silent it returns void even if nothing deleted, where as we return 404
    boolean found = false;
    List<AssociationRef> assocRefs = nodeAssocService.getTargetAssocs(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, sourceNodeId), assocTypeQName);
    for (AssociationRef assocRef : assocRefs) {
        if (assocRef.getTargetRef().equals(tgtNodeRef)) {
            nodeAssocService.removeAssociation(srcNodeRef, tgtNodeRef, assocRef.getTypeQName());
            found = true;
        }
    }
    if (!found) {
        throw new EntityNotFoundException(sourceNodeId + "," + assocTypeStr + "," + targetNodeId);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) QNamePattern(org.alfresco.service.namespace.QNamePattern) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 4 with WebApiDescription

use of org.alfresco.rest.framework.WebApiDescription in project alfresco-remote-api by Alfresco.

the class NodeVersionsRelation method revertById.

@Operation("revert")
@WebApiDescription(title = "Revert Version", description = "Reverts (ie. promotes) specified version to become a new, most recent, version", successStatus = HttpServletResponse.SC_OK)
public Node revertById(String nodeId, String versionId, VersionOptions versionOptions, Parameters parameters, WithResponse withResponse) {
    Version v = findVersion(nodeId, versionId);
    if (v != null) {
        CheckOutCheckInService cociService = sr.getCheckOutCheckInService();
        NodeRef nodeRef = v.getVersionedNodeRef();
        String versionComment = versionOptions.getComment();
        VersionType versionType = VersionType.MINOR;
        Boolean versionMajor = versionOptions.getMajorVersion();
        if ((versionMajor != null) && (versionMajor)) {
            versionType = VersionType.MAJOR;
        }
        Map<String, Serializable> versionProperties = new HashMap<>(2);
        versionProperties.put(VersionModel.PROP_VERSION_TYPE, versionType);
        if (versionComment != null) {
            versionProperties.put(VersionModel.PROP_DESCRIPTION, versionComment);
        }
        // cancel editing if we want to revert
        if (sr.getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) {
            nodeRef = cociService.cancelCheckout(nodeRef);
        }
        // TODO review default for deep and/or whether we should make it an option
        versionService.revert(nodeRef, v, false);
        // Checkout/Checkin the node - to store the new version in version history
        NodeRef wcNodeRef = cociService.checkout(nodeRef);
        cociService.checkin(wcNodeRef, versionProperties);
        // get latest version
        v = versionService.getVersionHistory(nodeRef).getHeadVersion();
        Node node = nodes.getFolderOrDocumentFullInfo(v.getFrozenStateNodeRef(), null, null, parameters, null);
        mapVersionInfo(v, node);
        return node;
    }
    throw new EntityNotFoundException(nodeId + "-" + versionId);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) CheckOutCheckInService(org.alfresco.service.cmr.coci.CheckOutCheckInService) Version(org.alfresco.service.cmr.version.Version) HashMap(java.util.HashMap) Node(org.alfresco.rest.api.model.Node) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) VersionType(org.alfresco.service.cmr.version.VersionType) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) Operation(org.alfresco.rest.framework.Operation)

Example 5 with WebApiDescription

use of org.alfresco.rest.framework.WebApiDescription in project alfresco-remote-api by Alfresco.

the class NodeVersionsRelation method readById.

@Override
@WebApiDescription(title = "Get version node info", description = "Return metadata for a specific version node")
public Node readById(String nodeId, String versionId, Parameters parameters) {
    Version v = findVersion(nodeId, versionId);
    if (v != null) {
        Node node = nodes.getFolderOrDocumentFullInfo(v.getFrozenStateNodeRef(), null, null, parameters, null);
        mapVersionInfo(v, node);
        return node;
    }
    throw new EntityNotFoundException(nodeId + "-" + versionId);
}
Also used : Version(org.alfresco.service.cmr.version.Version) Node(org.alfresco.rest.api.model.Node) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

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