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