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));
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations