Search in sources :

Example 26 with WebApiDescription

use of org.alfresco.rest.framework.WebApiDescription 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 27 with WebApiDescription

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

the class NodeSecondaryChildrenRelation method delete.

@Override
@WebApiDescription(title = "Remove secondary child assoc(s)")
public void delete(String parentNodeId, String childNodeId, Parameters parameters) {
    NodeRef parentNodeRef = nodes.validateNode(parentNodeId);
    NodeRef childNodeRef = nodes.validateNode(childNodeId);
    String assocTypeStr = parameters.getParameter(Nodes.PARAM_ASSOC_TYPE);
    QName assocTypeQName = nodes.getAssocType(assocTypeStr, false);
    List<ChildAssociationRef> assocRefs = nodeService.getChildAssocs(parentNodeRef);
    boolean found = false;
    for (ChildAssociationRef assocRef : assocRefs) {
        if (!assocRef.getChildRef().equals(childNodeRef)) {
            continue;
        }
        if (assocTypeQName != null) {
            if (assocTypeQName.equals(assocRef.getTypeQName())) {
                if (assocRef.isPrimary()) {
                    throw new InvalidArgumentException("Cannot use secondary-children to delete primary assoc: " + parentNodeId + "," + assocTypeStr + "," + childNodeId);
                }
                boolean existed = nodeService.removeSecondaryChildAssociation(assocRef);
                if (existed) {
                    found = true;
                }
            }
        } else {
            if (!assocRef.isPrimary()) {
                boolean existed = nodeService.removeSecondaryChildAssociation(assocRef);
                if (existed) {
                    found = true;
                }
            }
        }
    }
    if (!found) {
        throw new EntityNotFoundException(parentNodeId + "," + assocTypeStr + "," + childNodeId);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) QName(org.alfresco.service.namespace.QName) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 28 with WebApiDescription

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

the class NodeSecondaryChildrenRelation method readAll.

/**
 * List secondary children only
 *
 * @param parentNodeId String id of parent node
 */
@Override
@WebApiDescription(title = "Return a paged list of secondary child nodes based on child assocs")
public CollectionWithPagingInfo<Node> readAll(String parentNodeId, Parameters parameters) {
    NodeRef parentNodeRef = nodes.validateOrLookupNode(parentNodeId, null);
    QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
    List<ChildAssociationRef> childAssocRefs = null;
    if (assocTypeQNameParam.equals(RegexQNamePattern.MATCH_ALL)) {
        childAssocRefs = nodeService.getChildAssocs(parentNodeRef);
    } else {
        childAssocRefs = nodeService.getChildAssocs(parentNodeRef, assocTypeQNameParam, RegexQNamePattern.MATCH_ALL);
    }
    return listNodeChildAssocs(childAssocRefs, parameters, false, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) 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 29 with WebApiDescription

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

the class NodeSourcesRelation method readAll.

/**
 * List sources
 *
 * @param targetNodeId String id of target node
 */
@Override
@WebApiDescription(title = "Return a paged list of sources nodes based on (peer) assocs")
public CollectionWithPagingInfo<Node> readAll(String targetNodeId, Parameters parameters) {
    NodeRef targetNodeRef = nodes.validateOrLookupNode(targetNodeId, null);
    QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
    List<AssociationRef> assocRefs = nodeAssocService.getSourceAssocs(targetNodeRef, assocTypeQNameParam);
    return listNodePeerAssocs(assocRefs, parameters, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QNamePattern(org.alfresco.service.namespace.QNamePattern) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 30 with WebApiDescription

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

the class NodeTargetsRelation method readAll.

/**
 * List targets
 *
 * @param sourceNodeId String id of source node
 */
@Override
@WebApiDescription(title = "Return a paged list of target nodes based on (peer) assocs")
public CollectionWithPagingInfo<Node> readAll(String sourceNodeId, Parameters parameters) {
    NodeRef sourceNodeRef = nodes.validateOrLookupNode(sourceNodeId, null);
    QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
    List<AssociationRef> assocRefs = nodeAssocService.getTargetAssocs(sourceNodeRef, assocTypeQNameParam);
    return listNodePeerAssocs(assocRefs, parameters, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) QNamePattern(org.alfresco.service.namespace.QNamePattern) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) 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