mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-4863 Add method validateOrLookupNode without path.
This commit is contained in:
@@ -39,6 +39,8 @@ import org.alfresco.rest.api.model.LockInfo;
|
|||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
import org.alfresco.rest.api.model.PathInfo;
|
import org.alfresco.rest.api.model.PathInfo;
|
||||||
import org.alfresco.rest.api.model.UserInfo;
|
import org.alfresco.rest.api.model.UserInfo;
|
||||||
|
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||||
|
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||||
import org.alfresco.rest.framework.resource.content.BasicContentInfo;
|
import org.alfresco.rest.framework.resource.content.BasicContentInfo;
|
||||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||||
@@ -208,6 +210,16 @@ public interface Nodes
|
|||||||
NodeRef validateNode(StoreRef storeRef, String nodeId);
|
NodeRef validateNode(StoreRef storeRef, String nodeId);
|
||||||
NodeRef validateNode(String nodeId);
|
NodeRef validateNode(String nodeId);
|
||||||
NodeRef validateNode(NodeRef nodeRef);
|
NodeRef validateNode(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that the specified id refers to a valid node.
|
||||||
|
*
|
||||||
|
* @param nodeId The node id to look up using SpacesStore or an alias like -root-.
|
||||||
|
* @return The node ref.
|
||||||
|
* @throws InvalidArgumentException if the specified node id is not a valid format.
|
||||||
|
* @throws EntityNotFoundException if the specified node was not found in the database.
|
||||||
|
*/
|
||||||
|
NodeRef validateOrLookupNode(String nodeId);
|
||||||
NodeRef validateOrLookupNode(String nodeId, String path);
|
NodeRef validateOrLookupNode(String nodeId, String path);
|
||||||
|
|
||||||
boolean nodeMatches(NodeRef nodeRef, Set<QName> expectedTypes, Set<QName> excludedTypes);
|
boolean nodeMatches(NodeRef nodeRef, Set<QName> expectedTypes, Set<QName> excludedTypes);
|
||||||
|
@@ -189,7 +189,7 @@ public class CategoriesImpl implements Categories
|
|||||||
@Override
|
@Override
|
||||||
public List<Category> listCategoriesForNode(final String nodeId, final Parameters parameters)
|
public List<Category> listCategoriesForNode(final String nodeId, final Parameters parameters)
|
||||||
{
|
{
|
||||||
final NodeRef contentNodeRef = nodes.validateOrLookupNode(nodeId, null);
|
final NodeRef contentNodeRef = nodes.validateOrLookupNode(nodeId);
|
||||||
verifyReadPermission(contentNodeRef);
|
verifyReadPermission(contentNodeRef);
|
||||||
verifyNodeType(contentNodeRef);
|
verifyNodeType(contentNodeRef);
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ public class CategoriesImpl implements Categories
|
|||||||
throw new InvalidArgumentException(NOT_A_VALID_CATEGORY);
|
throw new InvalidArgumentException(NOT_A_VALID_CATEGORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
final NodeRef contentNodeRef = nodes.validateOrLookupNode(nodeId, null);
|
final NodeRef contentNodeRef = nodes.validateOrLookupNode(nodeId);
|
||||||
verifyChangePermission(contentNodeRef);
|
verifyChangePermission(contentNodeRef);
|
||||||
verifyNodeType(contentNodeRef);
|
verifyNodeType(contentNodeRef);
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ public class CategoriesImpl implements Categories
|
|||||||
public void unlinkNodeFromCategory(final StoreRef storeRef, final String nodeId, final String categoryId, final Parameters parameters)
|
public void unlinkNodeFromCategory(final StoreRef storeRef, final String nodeId, final String categoryId, final Parameters parameters)
|
||||||
{
|
{
|
||||||
final NodeRef categoryNodeRef = getCategoryNodeRef(storeRef, categoryId);
|
final NodeRef categoryNodeRef = getCategoryNodeRef(storeRef, categoryId);
|
||||||
final NodeRef contentNodeRef = nodes.validateOrLookupNode(nodeId, null);
|
final NodeRef contentNodeRef = nodes.validateOrLookupNode(nodeId);
|
||||||
verifyChangePermission(contentNodeRef);
|
verifyChangePermission(contentNodeRef);
|
||||||
verifyNodeType(contentNodeRef);
|
verifyNodeType(contentNodeRef);
|
||||||
|
|
||||||
|
@@ -649,6 +649,11 @@ public class NodesImpl implements Nodes
|
|||||||
return nodeService.getPrimaryParent(nodeRef).getParentRef();
|
return nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NodeRef validateOrLookupNode(String nodeId)
|
||||||
|
{
|
||||||
|
return validateOrLookupNode(nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
public NodeRef validateOrLookupNode(String nodeId, String path)
|
public NodeRef validateOrLookupNode(String nodeId, String path)
|
||||||
{
|
{
|
||||||
NodeRef parentNodeRef;
|
NodeRef parentNodeRef;
|
||||||
@@ -1356,7 +1361,7 @@ public class NodesImpl implements Nodes
|
|||||||
|
|
||||||
private void calculateRelativePath(String parentFolderNodeId, Node node)
|
private void calculateRelativePath(String parentFolderNodeId, Node node)
|
||||||
{
|
{
|
||||||
NodeRef rootNodeRef = validateOrLookupNode(parentFolderNodeId, null);
|
NodeRef rootNodeRef = validateOrLookupNode(parentFolderNodeId);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// get the path elements
|
// get the path elements
|
||||||
@@ -1741,7 +1746,7 @@ public class NodesImpl implements Nodes
|
|||||||
@Override
|
@Override
|
||||||
public void deleteNode(String nodeId, Parameters parameters)
|
public void deleteNode(String nodeId, Parameters parameters)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = validateOrLookupNode(nodeId, null);
|
NodeRef nodeRef = validateOrLookupNode(nodeId);
|
||||||
|
|
||||||
if (isSpecialNode(nodeRef, getNodeType(nodeRef)))
|
if (isSpecialNode(nodeRef, getNodeType(nodeRef)))
|
||||||
{
|
{
|
||||||
@@ -1785,7 +1790,7 @@ public class NodesImpl implements Nodes
|
|||||||
validateProperties(nodeInfo.getProperties(), EXCLUDED_NS, Arrays.asList());
|
validateProperties(nodeInfo.getProperties(), EXCLUDED_NS, Arrays.asList());
|
||||||
|
|
||||||
// check that requested parent node exists and it's type is a (sub-)type of folder
|
// check that requested parent node exists and it's type is a (sub-)type of folder
|
||||||
NodeRef parentNodeRef = validateOrLookupNode(parentFolderNodeId, null);
|
NodeRef parentNodeRef = validateOrLookupNode(parentFolderNodeId);
|
||||||
|
|
||||||
// node name - mandatory
|
// node name - mandatory
|
||||||
String nodeName = nodeInfo.getName();
|
String nodeName = nodeInfo.getName();
|
||||||
@@ -2290,7 +2295,7 @@ public class NodesImpl implements Nodes
|
|||||||
validateAspects(nodeInfo.getAspectNames(), EXCLUDED_NS, EXCLUDED_ASPECTS);
|
validateAspects(nodeInfo.getAspectNames(), EXCLUDED_NS, EXCLUDED_ASPECTS);
|
||||||
validateProperties(nodeInfo.getProperties(), EXCLUDED_NS, Arrays.asList());
|
validateProperties(nodeInfo.getProperties(), EXCLUDED_NS, Arrays.asList());
|
||||||
|
|
||||||
final NodeRef nodeRef = validateOrLookupNode(nodeId, null);
|
final NodeRef nodeRef = validateOrLookupNode(nodeId);
|
||||||
|
|
||||||
QName nodeTypeQName = getNodeType(nodeRef);
|
QName nodeTypeQName = getNodeType(nodeRef);
|
||||||
|
|
||||||
@@ -2523,8 +2528,8 @@ public class NodesImpl implements Nodes
|
|||||||
throw new InvalidArgumentException("Missing targetParentId");
|
throw new InvalidArgumentException("Missing targetParentId");
|
||||||
}
|
}
|
||||||
|
|
||||||
final NodeRef parentNodeRef = validateOrLookupNode(targetParentId, null);
|
final NodeRef parentNodeRef = validateOrLookupNode(targetParentId);
|
||||||
final NodeRef sourceNodeRef = validateOrLookupNode(sourceNodeId, null);
|
final NodeRef sourceNodeRef = validateOrLookupNode(sourceNodeId);
|
||||||
|
|
||||||
FileInfo fi = moveOrCopyImpl(sourceNodeRef, parentNodeRef, name, isCopy);
|
FileInfo fi = moveOrCopyImpl(sourceNodeRef, parentNodeRef, name, isCopy);
|
||||||
return getFolderOrDocument(fi.getNodeRef().getId(), parameters);
|
return getFolderOrDocument(fi.getNodeRef().getId(), parameters);
|
||||||
@@ -2954,7 +2959,7 @@ public class NodesImpl implements Nodes
|
|||||||
throw new InvalidArgumentException("The request content-type is not multipart: "+parentFolderNodeId);
|
throw new InvalidArgumentException("The request content-type is not multipart: "+parentFolderNodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeRef parentNodeRef = validateOrLookupNode(parentFolderNodeId, null);
|
NodeRef parentNodeRef = validateOrLookupNode(parentFolderNodeId);
|
||||||
if (!nodeMatches(parentNodeRef, Collections.singleton(ContentModel.TYPE_FOLDER), null, false))
|
if (!nodeMatches(parentNodeRef, Collections.singleton(ContentModel.TYPE_FOLDER), null, false))
|
||||||
{
|
{
|
||||||
throw new InvalidArgumentException("NodeId of folder is expected: " + parentNodeRef.getId());
|
throw new InvalidArgumentException("NodeId of folder is expected: " + parentNodeRef.getId());
|
||||||
@@ -3385,7 +3390,7 @@ public class NodesImpl implements Nodes
|
|||||||
@Override
|
@Override
|
||||||
public Node lock(String nodeId, LockInfo lockInfo, Parameters parameters)
|
public Node lock(String nodeId, LockInfo lockInfo, Parameters parameters)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = validateOrLookupNode(nodeId, null);
|
NodeRef nodeRef = validateOrLookupNode(nodeId);
|
||||||
|
|
||||||
if (isSpecialNode(nodeRef, getNodeType(nodeRef)))
|
if (isSpecialNode(nodeRef, getNodeType(nodeRef)))
|
||||||
{
|
{
|
||||||
@@ -3424,7 +3429,7 @@ public class NodesImpl implements Nodes
|
|||||||
@Override
|
@Override
|
||||||
public Node unlock(String nodeId, Parameters parameters)
|
public Node unlock(String nodeId, Parameters parameters)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = validateOrLookupNode(nodeId, null);
|
NodeRef nodeRef = validateOrLookupNode(nodeId);
|
||||||
|
|
||||||
if (isSpecialNode(nodeRef, getNodeType(nodeRef)))
|
if (isSpecialNode(nodeRef, getNodeType(nodeRef)))
|
||||||
{
|
{
|
||||||
|
@@ -185,7 +185,7 @@ public class QueriesImpl implements Queries, InitializingBean
|
|||||||
String rootNodeId = parameters.getParameter(PARAM_ROOT_NODE_ID);
|
String rootNodeId = parameters.getParameter(PARAM_ROOT_NODE_ID);
|
||||||
if (rootNodeId != null)
|
if (rootNodeId != null)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = nodes.validateOrLookupNode(rootNodeId, null);
|
NodeRef nodeRef = nodes.validateOrLookupNode(rootNodeId);
|
||||||
query.append("PATH:\"").append(getQNamePath(nodeRef.getId())).append("//*\" AND (");
|
query.append("PATH:\"").append(getQNamePath(nodeRef.getId())).append("//*\" AND (");
|
||||||
}
|
}
|
||||||
if (term != null)
|
if (term != null)
|
||||||
|
@@ -695,7 +695,7 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
|
|||||||
{
|
{
|
||||||
if (versionLabelId != null)
|
if (versionLabelId != null)
|
||||||
{
|
{
|
||||||
nodeRef = nodes.validateOrLookupNode(nodeRef.getId(), null);
|
nodeRef = nodes.validateOrLookupNode(nodeRef.getId());
|
||||||
VersionHistory vh = versionService.getVersionHistory(nodeRef);
|
VersionHistory vh = versionService.getVersionHistory(nodeRef);
|
||||||
if (vh != null)
|
if (vh != null)
|
||||||
{
|
{
|
||||||
|
@@ -117,7 +117,7 @@ public class TagsImpl implements Tags
|
|||||||
|
|
||||||
public List<Tag> addTags(String nodeId, final List<Tag> tags)
|
public List<Tag> addTags(String nodeId, final List<Tag> tags)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId, null);
|
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId);
|
||||||
if (!typeConstraint.matches(nodeRef))
|
if (!typeConstraint.matches(nodeRef))
|
||||||
{
|
{
|
||||||
throw new UnsupportedResourceOperationException("Cannot tag this node");
|
throw new UnsupportedResourceOperationException("Cannot tag this node");
|
||||||
@@ -241,7 +241,7 @@ public class TagsImpl implements Tags
|
|||||||
|
|
||||||
public CollectionWithPagingInfo<Tag> getTags(String nodeId, Parameters params)
|
public CollectionWithPagingInfo<Tag> getTags(String nodeId, Parameters params)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId, null);
|
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId);
|
||||||
PagingResults<Pair<NodeRef, String>> results = taggingService.getTags(nodeRef, Util.getPagingRequest(params.getPaging()));
|
PagingResults<Pair<NodeRef, String>> results = taggingService.getTags(nodeRef, Util.getPagingRequest(params.getPaging()));
|
||||||
Integer totalItems = results.getTotalResultCount().getFirst();
|
Integer totalItems = results.getTotalResultCount().getFirst();
|
||||||
List<Pair<NodeRef, String>> page = results.getPage();
|
List<Pair<NodeRef, String>> page = results.getPage();
|
||||||
|
@@ -134,7 +134,7 @@ public class RestRuleModelMapper implements RestModelMapper<Rule, org.alfresco.s
|
|||||||
public org.alfresco.service.cmr.rule.Rule toServiceModel(Rule restRuleModel)
|
public org.alfresco.service.cmr.rule.Rule toServiceModel(Rule restRuleModel)
|
||||||
{
|
{
|
||||||
final org.alfresco.service.cmr.rule.Rule serviceRule = new org.alfresco.service.cmr.rule.Rule();
|
final org.alfresco.service.cmr.rule.Rule serviceRule = new org.alfresco.service.cmr.rule.Rule();
|
||||||
final NodeRef nodeRef = (restRuleModel.getId() != null) ? nodes.validateOrLookupNode(restRuleModel.getId(), null) : null;
|
final NodeRef nodeRef = (restRuleModel.getId() != null) ? nodes.validateOrLookupNode(restRuleModel.getId()) : null;
|
||||||
serviceRule.setNodeRef(nodeRef);
|
serviceRule.setNodeRef(nodeRef);
|
||||||
serviceRule.setTitle(restRuleModel.getName());
|
serviceRule.setTitle(restRuleModel.getName());
|
||||||
serviceRule.setDescription(restRuleModel.getDescription());
|
serviceRule.setDescription(restRuleModel.getDescription());
|
||||||
|
@@ -129,7 +129,7 @@ public class RestRuleSimpleConditionModelMapper implements RestModelMapper<Simpl
|
|||||||
parameterValues.put(InCategoryEvaluator.PARAM_CATEGORY_ASPECT, ContentModel.ASPECT_GEN_CLASSIFIABLE);
|
parameterValues.put(InCategoryEvaluator.PARAM_CATEGORY_ASPECT, ContentModel.ASPECT_GEN_CLASSIFIABLE);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
parameterValues.put(InCategoryEvaluator.PARAM_CATEGORY_VALUE, nodes.validateOrLookupNode(parameter, null));
|
parameterValues.put(InCategoryEvaluator.PARAM_CATEGORY_VALUE, nodes.validateOrLookupNode(parameter));
|
||||||
} catch (EntityNotFoundException e) {
|
} catch (EntityNotFoundException e) {
|
||||||
throw new InvalidArgumentException(CATEGORY_INVALID_MSG);
|
throw new InvalidArgumentException(CATEGORY_INVALID_MSG);
|
||||||
}
|
}
|
||||||
|
@@ -173,7 +173,7 @@ public class ActionParameterConverter
|
|||||||
}
|
}
|
||||||
else if (typeQName.isMatch(DataTypeDefinition.NODE_REF))
|
else if (typeQName.isMatch(DataTypeDefinition.NODE_REF))
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = nodes.validateOrLookupNode(stringValue, null);
|
NodeRef nodeRef = nodes.validateOrLookupNode(stringValue);
|
||||||
if (permissionService.hasReadPermission(nodeRef) != ALLOWED)
|
if (permissionService.hasReadPermission(nodeRef) != ALLOWED)
|
||||||
{
|
{
|
||||||
throw new EntityNotFoundException(stringValue);
|
throw new EntityNotFoundException(stringValue);
|
||||||
|
@@ -72,7 +72,7 @@ public class NodeValidator
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final NodeRef nodeRef = nodes.validateOrLookupNode(folderNodeId, null);
|
final NodeRef nodeRef = nodes.validateOrLookupNode(folderNodeId);
|
||||||
validatePermission(requireChangePermission, nodeRef);
|
validatePermission(requireChangePermission, nodeRef);
|
||||||
verifyNodeType(nodeRef, ContentModel.TYPE_FOLDER, null);
|
verifyNodeType(nodeRef, ContentModel.TYPE_FOLDER, null);
|
||||||
|
|
||||||
|
@@ -31,13 +31,9 @@ import org.alfresco.rest.framework.resource.RelationshipResource;
|
|||||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
import org.alfresco.rest.framework.resource.parameters.SortColumn;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@RelationshipResource(name = "action-definitions", entityResource = NodesEntityResource.class, title = "Node action definitions")
|
@RelationshipResource(name = "action-definitions", entityResource = NodesEntityResource.class, title = "Node action definitions")
|
||||||
public class NodeActionDefinitionsRelation extends AbstractNodeRelation
|
public class NodeActionDefinitionsRelation extends AbstractNodeRelation
|
||||||
implements RelationshipResourceAction.Read<ActionDefinition>
|
implements RelationshipResourceAction.Read<ActionDefinition>
|
||||||
@@ -59,7 +55,7 @@ public class NodeActionDefinitionsRelation extends AbstractNodeRelation
|
|||||||
@Override
|
@Override
|
||||||
public CollectionWithPagingInfo<ActionDefinition> readAll(String entityResourceId, Parameters params)
|
public CollectionWithPagingInfo<ActionDefinition> readAll(String entityResourceId, Parameters params)
|
||||||
{
|
{
|
||||||
NodeRef parentNodeRef = nodes.validateOrLookupNode(entityResourceId, null);
|
NodeRef parentNodeRef = nodes.validateOrLookupNode(entityResourceId);
|
||||||
return actions.getActionDefinitions(parentNodeRef, params);
|
return actions.getActionDefinitions(parentNodeRef, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.nodes;
|
package org.alfresco.rest.api.nodes;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.rest.antlr.WhereClauseParser;
|
import org.alfresco.rest.antlr.WhereClauseParser;
|
||||||
import org.alfresco.rest.api.Nodes;
|
import org.alfresco.rest.api.Nodes;
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
@@ -41,11 +46,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
import org.alfresco.service.namespace.QNamePattern;
|
import org.alfresco.service.namespace.QNamePattern;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node Parents
|
* Node Parents
|
||||||
*
|
*
|
||||||
@@ -67,7 +67,7 @@ public class NodeParentsRelation extends AbstractNodeRelation implements Relatio
|
|||||||
@WebApiDescription(title = "Return a list of parent nodes based on child assocs")
|
@WebApiDescription(title = "Return a list of parent nodes based on child assocs")
|
||||||
public CollectionWithPagingInfo<Node> readAll(String childNodeId, Parameters parameters)
|
public CollectionWithPagingInfo<Node> readAll(String childNodeId, Parameters parameters)
|
||||||
{
|
{
|
||||||
NodeRef childNodeRef = nodes.validateOrLookupNode(childNodeId, null);
|
NodeRef childNodeRef = nodes.validateOrLookupNode(childNodeId);
|
||||||
|
|
||||||
QNamePattern assocTypeQNameParam = RegexQNamePattern.MATCH_ALL;
|
QNamePattern assocTypeQNameParam = RegexQNamePattern.MATCH_ALL;
|
||||||
|
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.nodes;
|
package org.alfresco.rest.api.nodes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.rest.api.Nodes;
|
import org.alfresco.rest.api.Nodes;
|
||||||
import org.alfresco.rest.api.model.AssocChild;
|
import org.alfresco.rest.api.model.AssocChild;
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
@@ -41,8 +43,6 @@ import org.alfresco.service.namespace.QName;
|
|||||||
import org.alfresco.service.namespace.QNamePattern;
|
import org.alfresco.service.namespace.QNamePattern;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node Secondary Children
|
* Node Secondary Children
|
||||||
*
|
*
|
||||||
@@ -71,7 +71,7 @@ public class NodeSecondaryChildrenRelation extends AbstractNodeRelation implemen
|
|||||||
@WebApiDescription(title = "Return a paged list of secondary child nodes based on child assocs")
|
@WebApiDescription(title = "Return a paged list of secondary child nodes based on child assocs")
|
||||||
public CollectionWithPagingInfo<Node> readAll(String parentNodeId, Parameters parameters)
|
public CollectionWithPagingInfo<Node> readAll(String parentNodeId, Parameters parameters)
|
||||||
{
|
{
|
||||||
NodeRef parentNodeRef = nodes.validateOrLookupNode(parentNodeId, null);
|
NodeRef parentNodeRef = nodes.validateOrLookupNode(parentNodeId);
|
||||||
|
|
||||||
QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
|
QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
|
||||||
|
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.nodes;
|
package org.alfresco.rest.api.nodes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
import org.alfresco.rest.framework.WebApiDescription;
|
import org.alfresco.rest.framework.WebApiDescription;
|
||||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||||
@@ -35,8 +37,6 @@ import org.alfresco.service.cmr.repository.AssociationRef;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QNamePattern;
|
import org.alfresco.service.namespace.QNamePattern;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node Sources - list node (peer) associations from target to sources
|
* Node Sources - list node (peer) associations from target to sources
|
||||||
*
|
*
|
||||||
@@ -54,7 +54,7 @@ public class NodeSourcesRelation extends AbstractNodeRelation implements Relatio
|
|||||||
@WebApiDescription(title = "Return a paged list of sources nodes based on (peer) assocs")
|
@WebApiDescription(title = "Return a paged list of sources nodes based on (peer) assocs")
|
||||||
public CollectionWithPagingInfo<Node> readAll(String targetNodeId, Parameters parameters)
|
public CollectionWithPagingInfo<Node> readAll(String targetNodeId, Parameters parameters)
|
||||||
{
|
{
|
||||||
NodeRef targetNodeRef = nodes.validateOrLookupNode(targetNodeId, null);
|
NodeRef targetNodeRef = nodes.validateOrLookupNode(targetNodeId);
|
||||||
|
|
||||||
QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
|
QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
|
||||||
|
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.nodes;
|
package org.alfresco.rest.api.nodes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.rest.api.Nodes;
|
import org.alfresco.rest.api.Nodes;
|
||||||
import org.alfresco.rest.api.model.AssocTarget;
|
import org.alfresco.rest.api.model.AssocTarget;
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
@@ -40,8 +42,6 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
|||||||
import org.alfresco.service.namespace.QNamePattern;
|
import org.alfresco.service.namespace.QNamePattern;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node Targets
|
* Node Targets
|
||||||
*
|
*
|
||||||
@@ -64,7 +64,7 @@ public class NodeTargetsRelation extends AbstractNodeRelation implements
|
|||||||
@WebApiDescription(title = "Return a paged list of target nodes based on (peer) assocs")
|
@WebApiDescription(title = "Return a paged list of target nodes based on (peer) assocs")
|
||||||
public CollectionWithPagingInfo<Node> readAll(String sourceNodeId, Parameters parameters)
|
public CollectionWithPagingInfo<Node> readAll(String sourceNodeId, Parameters parameters)
|
||||||
{
|
{
|
||||||
NodeRef sourceNodeRef = nodes.validateOrLookupNode(sourceNodeId, null);
|
NodeRef sourceNodeRef = nodes.validateOrLookupNode(sourceNodeId);
|
||||||
|
|
||||||
QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
|
QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
|
||||||
|
|
||||||
|
@@ -25,6 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.nodes;
|
package org.alfresco.rest.api.nodes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.directurl.DirectAccessUrlDisabledException;
|
import org.alfresco.repo.content.directurl.DirectAccessUrlDisabledException;
|
||||||
import org.alfresco.repo.node.integrity.IntegrityException;
|
import org.alfresco.repo.node.integrity.IntegrityException;
|
||||||
@@ -65,13 +72,6 @@ import org.alfresco.util.ParameterCheck;
|
|||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node Versions - version history
|
* Node Versions - version history
|
||||||
*
|
*
|
||||||
@@ -117,7 +117,7 @@ public class NodeVersionsRelation extends AbstractNodeRelation implements
|
|||||||
@WebApiDescription(title = "Return version history as a paged list of version node infos")
|
@WebApiDescription(title = "Return version history as a paged list of version node infos")
|
||||||
public CollectionWithPagingInfo<Node> readAll(String nodeId, Parameters parameters)
|
public CollectionWithPagingInfo<Node> readAll(String nodeId, Parameters parameters)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId, null);
|
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId);
|
||||||
|
|
||||||
VersionHistory vh = versionService.getVersionHistory(nodeRef);
|
VersionHistory vh = versionService.getVersionHistory(nodeRef);
|
||||||
|
|
||||||
@@ -293,7 +293,7 @@ public class NodeVersionsRelation extends AbstractNodeRelation implements
|
|||||||
|
|
||||||
public Version findVersion(String nodeId, String versionLabelId)
|
public Version findVersion(String nodeId, String versionLabelId)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId, null);
|
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId);
|
||||||
VersionHistory vh = versionService.getVersionHistory(nodeRef);
|
VersionHistory vh = versionService.getVersionHistory(nodeRef);
|
||||||
if (vh != null)
|
if (vh != null)
|
||||||
{
|
{
|
||||||
|
@@ -128,7 +128,7 @@ public class CategoriesImplTest
|
|||||||
{
|
{
|
||||||
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
|
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
|
||||||
given(nodesMock.validateNode(CATEGORY_ID)).willReturn(CATEGORY_NODE_REF);
|
given(nodesMock.validateNode(CATEGORY_ID)).willReturn(CATEGORY_NODE_REF);
|
||||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID, null)).willReturn(CONTENT_NODE_REF);
|
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willReturn(CONTENT_NODE_REF);
|
||||||
given(nodesMock.isSubClass(any(), any(), anyBoolean())).willReturn(true);
|
given(nodesMock.isSubClass(any(), any(), anyBoolean())).willReturn(true);
|
||||||
given(typeConstraint.matches(any())).willReturn(true);
|
given(typeConstraint.matches(any())).willReturn(true);
|
||||||
given(permissionServiceMock.hasReadPermission(any())).willReturn(AccessStatus.ALLOWED);
|
given(permissionServiceMock.hasReadPermission(any())).willReturn(AccessStatus.ALLOWED);
|
||||||
@@ -900,7 +900,7 @@ public class CategoriesImplTest
|
|||||||
// when
|
// when
|
||||||
final List<Category> actualLinkedCategories = objectUnderTest.linkNodeToCategories(CONTENT_NODE_ID, categoryLinks, parametersMock);
|
final List<Category> actualLinkedCategories = objectUnderTest.linkNodeToCategories(CONTENT_NODE_ID, categoryLinks, parametersMock);
|
||||||
|
|
||||||
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID);
|
||||||
then(permissionServiceMock).should().hasPermission(CONTENT_NODE_REF, PermissionService.CHANGE_PERMISSIONS);
|
then(permissionServiceMock).should().hasPermission(CONTENT_NODE_REF, PermissionService.CHANGE_PERMISSIONS);
|
||||||
then(permissionServiceMock).shouldHaveNoMoreInteractions();
|
then(permissionServiceMock).shouldHaveNoMoreInteractions();
|
||||||
then(typeConstraint).should().matches(CONTENT_NODE_REF);
|
then(typeConstraint).should().matches(CONTENT_NODE_REF);
|
||||||
@@ -1011,12 +1011,12 @@ public class CategoriesImplTest
|
|||||||
@Test
|
@Test
|
||||||
public void testLinkNodeToCategories_withInvalidNodeId()
|
public void testLinkNodeToCategories_withInvalidNodeId()
|
||||||
{
|
{
|
||||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID, null)).willThrow(EntityNotFoundException.class);
|
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willThrow(EntityNotFoundException.class);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final Throwable actualException = catchThrowable(() -> objectUnderTest.linkNodeToCategories(CONTENT_NODE_ID, List.of(CATEGORY), parametersMock));
|
final Throwable actualException = catchThrowable(() -> objectUnderTest.linkNodeToCategories(CONTENT_NODE_ID, List.of(CATEGORY), parametersMock));
|
||||||
|
|
||||||
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID);
|
||||||
then(permissionServiceMock).shouldHaveNoInteractions();
|
then(permissionServiceMock).shouldHaveNoInteractions();
|
||||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||||
assertThat(actualException)
|
assertThat(actualException)
|
||||||
@@ -1031,7 +1031,7 @@ public class CategoriesImplTest
|
|||||||
// when
|
// when
|
||||||
final Throwable actualException = catchThrowable(() -> objectUnderTest.linkNodeToCategories(CONTENT_NODE_ID, List.of(CATEGORY), parametersMock));
|
final Throwable actualException = catchThrowable(() -> objectUnderTest.linkNodeToCategories(CONTENT_NODE_ID, List.of(CATEGORY), parametersMock));
|
||||||
|
|
||||||
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID);
|
||||||
then(permissionServiceMock).should().hasPermission(CONTENT_NODE_REF, PermissionService.CHANGE_PERMISSIONS);
|
then(permissionServiceMock).should().hasPermission(CONTENT_NODE_REF, PermissionService.CHANGE_PERMISSIONS);
|
||||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||||
assertThat(actualException)
|
assertThat(actualException)
|
||||||
@@ -1118,7 +1118,7 @@ public class CategoriesImplTest
|
|||||||
objectUnderTest.unlinkNodeFromCategory(CONTENT_NODE_ID, CATEGORY_ID, parametersMock);
|
objectUnderTest.unlinkNodeFromCategory(CONTENT_NODE_ID, CATEGORY_ID, parametersMock);
|
||||||
|
|
||||||
then(nodesMock).should().validateNode(CATEGORY_ID);
|
then(nodesMock).should().validateNode(CATEGORY_ID);
|
||||||
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID);
|
||||||
then(permissionServiceMock).should().hasPermission(CONTENT_NODE_REF, PermissionService.CHANGE_PERMISSIONS);
|
then(permissionServiceMock).should().hasPermission(CONTENT_NODE_REF, PermissionService.CHANGE_PERMISSIONS);
|
||||||
then(permissionServiceMock).shouldHaveNoMoreInteractions();
|
then(permissionServiceMock).shouldHaveNoMoreInteractions();
|
||||||
then(typeConstraint).should().matches(CONTENT_NODE_REF);
|
then(typeConstraint).should().matches(CONTENT_NODE_REF);
|
||||||
@@ -1155,7 +1155,7 @@ public class CategoriesImplTest
|
|||||||
// when
|
// when
|
||||||
final List<Category> actualCategories = objectUnderTest.listCategoriesForNode(CONTENT_NODE_ID, parametersMock);
|
final List<Category> actualCategories = objectUnderTest.listCategoriesForNode(CONTENT_NODE_ID, parametersMock);
|
||||||
|
|
||||||
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID);
|
||||||
then(permissionServiceMock).should().hasReadPermission(CONTENT_NODE_REF);
|
then(permissionServiceMock).should().hasReadPermission(CONTENT_NODE_REF);
|
||||||
then(permissionServiceMock).shouldHaveNoMoreInteractions();
|
then(permissionServiceMock).shouldHaveNoMoreInteractions();
|
||||||
then(typeConstraint).should().matches(CONTENT_NODE_REF);
|
then(typeConstraint).should().matches(CONTENT_NODE_REF);
|
||||||
@@ -1176,12 +1176,12 @@ public class CategoriesImplTest
|
|||||||
@Test
|
@Test
|
||||||
public void testListCategoriesForNode_withInvalidNodeId()
|
public void testListCategoriesForNode_withInvalidNodeId()
|
||||||
{
|
{
|
||||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID, null)).willThrow(EntityNotFoundException.class);
|
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willThrow(EntityNotFoundException.class);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final Throwable actualException = catchThrowable(() -> objectUnderTest.listCategoriesForNode(CONTENT_NODE_ID, parametersMock));
|
final Throwable actualException = catchThrowable(() -> objectUnderTest.listCategoriesForNode(CONTENT_NODE_ID, parametersMock));
|
||||||
|
|
||||||
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID);
|
||||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||||
assertThat(actualException)
|
assertThat(actualException)
|
||||||
.isInstanceOf(EntityNotFoundException.class);
|
.isInstanceOf(EntityNotFoundException.class);
|
||||||
@@ -1195,7 +1195,7 @@ public class CategoriesImplTest
|
|||||||
// when
|
// when
|
||||||
final Throwable actualException = catchThrowable(() -> objectUnderTest.listCategoriesForNode(CONTENT_NODE_ID, parametersMock));
|
final Throwable actualException = catchThrowable(() -> objectUnderTest.listCategoriesForNode(CONTENT_NODE_ID, parametersMock));
|
||||||
|
|
||||||
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID);
|
||||||
then(permissionServiceMock).should().hasReadPermission(CONTENT_NODE_REF);
|
then(permissionServiceMock).should().hasReadPermission(CONTENT_NODE_REF);
|
||||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||||
assertThat(actualException)
|
assertThat(actualException)
|
||||||
|
@@ -422,7 +422,7 @@ public class TagsImplTest
|
|||||||
@Test
|
@Test
|
||||||
public void testAddTags()
|
public void testAddTags()
|
||||||
{
|
{
|
||||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID, null)).willReturn(CONTENT_NODE_REF);
|
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willReturn(CONTENT_NODE_REF);
|
||||||
given(typeConstraintMock.matches(CONTENT_NODE_REF)).willReturn(true);
|
given(typeConstraintMock.matches(CONTENT_NODE_REF)).willReturn(true);
|
||||||
List<Pair<String, NodeRef>> pairs = List.of(new Pair<>("tagA", new NodeRef("tag://A/")), new Pair<>("tagB", new NodeRef("tag://B/")));
|
List<Pair<String, NodeRef>> pairs = List.of(new Pair<>("tagA", new NodeRef("tag://A/")), new Pair<>("tagB", new NodeRef("tag://B/")));
|
||||||
List<String> tagNames = pairs.stream().map(Pair::getFirst).collect(toList());
|
List<String> tagNames = pairs.stream().map(Pair::getFirst).collect(toList());
|
||||||
@@ -438,7 +438,7 @@ public class TagsImplTest
|
|||||||
@Test(expected = InvalidArgumentException.class)
|
@Test(expected = InvalidArgumentException.class)
|
||||||
public void testAddTagsToInvalidNode()
|
public void testAddTagsToInvalidNode()
|
||||||
{
|
{
|
||||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID, null)).willThrow(new InvalidArgumentException());
|
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willThrow(new InvalidArgumentException());
|
||||||
List<Tag> tags = List.of(Tag.builder().tag("tag1").create());
|
List<Tag> tags = List.of(Tag.builder().tag("tag1").create());
|
||||||
|
|
||||||
objectUnderTest.addTags(CONTENT_NODE_ID, tags);
|
objectUnderTest.addTags(CONTENT_NODE_ID, tags);
|
||||||
@@ -447,7 +447,7 @@ public class TagsImplTest
|
|||||||
@Test(expected = UnsupportedResourceOperationException.class)
|
@Test(expected = UnsupportedResourceOperationException.class)
|
||||||
public void testAddTagsToWrongTypeOfNode()
|
public void testAddTagsToWrongTypeOfNode()
|
||||||
{
|
{
|
||||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID, null)).willReturn(CONTENT_NODE_REF);
|
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willReturn(CONTENT_NODE_REF);
|
||||||
given(typeConstraintMock.matches(CONTENT_NODE_REF)).willReturn(false);
|
given(typeConstraintMock.matches(CONTENT_NODE_REF)).willReturn(false);
|
||||||
|
|
||||||
List<Tag> tags = List.of(Tag.builder().tag("tag1").create());
|
List<Tag> tags = List.of(Tag.builder().tag("tag1").create());
|
||||||
@@ -458,7 +458,7 @@ public class TagsImplTest
|
|||||||
@Test
|
@Test
|
||||||
public void testGetTagsForNode()
|
public void testGetTagsForNode()
|
||||||
{
|
{
|
||||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID, null)).willReturn(CONTENT_NODE_REF);
|
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willReturn(CONTENT_NODE_REF);
|
||||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||||
List<Pair<NodeRef, String>> pairs = List.of(new Pair<>(new NodeRef("tag://A/"), "tagA"), new Pair<>(new NodeRef("tag://B/"), "tagB"));
|
List<Pair<NodeRef, String>> pairs = List.of(new Pair<>(new NodeRef("tag://A/"), "tagA"), new Pair<>(new NodeRef("tag://B/"), "tagB"));
|
||||||
given(taggingServiceMock.getTags(eq(CONTENT_NODE_REF), any(PagingRequest.class))).willReturn(pagingResultsMock);
|
given(taggingServiceMock.getTags(eq(CONTENT_NODE_REF), any(PagingRequest.class))).willReturn(pagingResultsMock);
|
||||||
@@ -474,7 +474,7 @@ public class TagsImplTest
|
|||||||
@Test (expected = InvalidArgumentException.class)
|
@Test (expected = InvalidArgumentException.class)
|
||||||
public void testGetTagsFromInvalidNode()
|
public void testGetTagsFromInvalidNode()
|
||||||
{
|
{
|
||||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID, null)).willThrow(new InvalidArgumentException());
|
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willThrow(new InvalidArgumentException());
|
||||||
|
|
||||||
objectUnderTest.getTags(CONTENT_NODE_ID, parametersMock);
|
objectUnderTest.getTags(CONTENT_NODE_ID, parametersMock);
|
||||||
}
|
}
|
||||||
|
@@ -134,7 +134,7 @@ public class RestRuleModelMapperTest
|
|||||||
// when
|
// when
|
||||||
final org.alfresco.service.cmr.rule.Rule actualRuleModel = objectUnderTest.toServiceModel(rule);
|
final org.alfresco.service.cmr.rule.Rule actualRuleModel = objectUnderTest.toServiceModel(rule);
|
||||||
|
|
||||||
then(nodesMock).should().validateOrLookupNode(RULE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(RULE_ID);
|
||||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||||
then(actionMapperMock).should().toServiceModel(List.of(action));
|
then(actionMapperMock).should().toServiceModel(List.of(action));
|
||||||
then(actionMapperMock).shouldHaveNoMoreInteractions();
|
then(actionMapperMock).shouldHaveNoMoreInteractions();
|
||||||
|
@@ -275,7 +275,7 @@ public class RestRuleSimpleConditionModelMapperTest
|
|||||||
{
|
{
|
||||||
final SimpleCondition simpleCondition = createSimpleCondition(PARAM_CATEGORY);
|
final SimpleCondition simpleCondition = createSimpleCondition(PARAM_CATEGORY);
|
||||||
final NodeRef defaultNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARAMETER_DEFAULT);
|
final NodeRef defaultNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARAMETER_DEFAULT);
|
||||||
given(nodesMock.validateOrLookupNode(PARAMETER_DEFAULT, null)).willReturn(defaultNodeRef);
|
given(nodesMock.validateOrLookupNode(PARAMETER_DEFAULT)).willReturn(defaultNodeRef);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final ActionCondition actualActionCondition = objectUnderTest.toServiceModel(simpleCondition);
|
final ActionCondition actualActionCondition = objectUnderTest.toServiceModel(simpleCondition);
|
||||||
|
@@ -44,7 +44,6 @@ import java.io.Serializable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
|
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
|
||||||
import org.alfresco.repo.action.executer.CheckInActionExecuter;
|
import org.alfresco.repo.action.executer.CheckInActionExecuter;
|
||||||
import org.alfresco.repo.action.executer.CheckOutActionExecuter;
|
import org.alfresco.repo.action.executer.CheckOutActionExecuter;
|
||||||
@@ -129,8 +128,8 @@ public class ActionParameterConverterTest
|
|||||||
@Before
|
@Before
|
||||||
public void setUp()
|
public void setUp()
|
||||||
{
|
{
|
||||||
given(nodes.validateOrLookupNode(DUMMY_FOLDER_NODE_ID, null)).willReturn(DUMMY_FOLDER_NODE);
|
given(nodes.validateOrLookupNode(DUMMY_FOLDER_NODE_ID)).willReturn(DUMMY_FOLDER_NODE);
|
||||||
given(nodes.validateOrLookupNode(DUMMY_SCRIPT_NODE_ID, null)).willReturn(DUMMY_SCRIPT_NODE);
|
given(nodes.validateOrLookupNode(DUMMY_SCRIPT_NODE_ID)).willReturn(DUMMY_SCRIPT_NODE);
|
||||||
given(permissionService.hasReadPermission(DUMMY_FOLDER_NODE)).willReturn(ALLOWED);
|
given(permissionService.hasReadPermission(DUMMY_FOLDER_NODE)).willReturn(ALLOWED);
|
||||||
given(permissionService.hasReadPermission(DUMMY_SCRIPT_NODE)).willReturn(ALLOWED);
|
given(permissionService.hasReadPermission(DUMMY_SCRIPT_NODE)).willReturn(ALLOWED);
|
||||||
}
|
}
|
||||||
@@ -598,7 +597,7 @@ public class ActionParameterConverterTest
|
|||||||
String permissionDeniedNodeId = "permission://denied/node";
|
String permissionDeniedNodeId = "permission://denied/node";
|
||||||
final Map<String, Serializable> params = Map.of(PARAM_DESTINATION_FOLDER, permissionDeniedNodeId);
|
final Map<String, Serializable> params = Map.of(PARAM_DESTINATION_FOLDER, permissionDeniedNodeId);
|
||||||
NodeRef permissionDeniedNode = new NodeRef(permissionDeniedNodeId);
|
NodeRef permissionDeniedNode = new NodeRef(permissionDeniedNodeId);
|
||||||
given(nodes.validateOrLookupNode(permissionDeniedNodeId, null)).willReturn(permissionDeniedNode);
|
given(nodes.validateOrLookupNode(permissionDeniedNodeId)).willReturn(permissionDeniedNode);
|
||||||
given(permissionService.hasReadPermission(permissionDeniedNode)).willReturn(DENIED);
|
given(permissionService.hasReadPermission(permissionDeniedNode)).willReturn(DENIED);
|
||||||
|
|
||||||
given(actionService.getActionDefinition(name)).willReturn(actionDefinition);
|
given(actionService.getActionDefinition(name)).willReturn(actionDefinition);
|
||||||
|
@@ -101,7 +101,7 @@ public class NodeValidatorTest
|
|||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
MockitoAnnotations.openMocks(this);
|
MockitoAnnotations.openMocks(this);
|
||||||
given(nodesMock.validateOrLookupNode(eq(FOLDER_NODE_ID), any())).willReturn(folderNodeRef);
|
given(nodesMock.validateOrLookupNode(FOLDER_NODE_ID)).willReturn(folderNodeRef);
|
||||||
given(nodesMock.validateNode(RULE_SET_ID)).willReturn(ruleSetNodeRef);
|
given(nodesMock.validateNode(RULE_SET_ID)).willReturn(ruleSetNodeRef);
|
||||||
given(nodesMock.validateNode(RULE_ID)).willReturn(ruleNodeRef);
|
given(nodesMock.validateNode(RULE_ID)).willReturn(ruleNodeRef);
|
||||||
given(nodesMock.nodeMatches(any(), any(), any())).willReturn(true);
|
given(nodesMock.nodeMatches(any(), any(), any())).willReturn(true);
|
||||||
@@ -115,7 +115,7 @@ public class NodeValidatorTest
|
|||||||
// when
|
// when
|
||||||
final NodeRef nodeRef = nodeValidator.validateFolderNode(FOLDER_NODE_ID, false);
|
final NodeRef nodeRef = nodeValidator.validateFolderNode(FOLDER_NODE_ID, false);
|
||||||
|
|
||||||
then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID);
|
||||||
then(nodesMock).should().nodeMatches(folderNodeRef, Set.of(TYPE_FOLDER), null);
|
then(nodesMock).should().nodeMatches(folderNodeRef, Set.of(TYPE_FOLDER), null);
|
||||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||||
then(permissionServiceMock).should().hasReadPermission(folderNodeRef);
|
then(permissionServiceMock).should().hasReadPermission(folderNodeRef);
|
||||||
@@ -128,13 +128,13 @@ public class NodeValidatorTest
|
|||||||
@Test
|
@Test
|
||||||
public void testValidateFolderNode_notExistingFolder()
|
public void testValidateFolderNode_notExistingFolder()
|
||||||
{
|
{
|
||||||
given(nodesMock.validateOrLookupNode(any(), any())).willThrow(new EntityNotFoundException(FOLDER_NODE_ID));
|
given(nodesMock.validateOrLookupNode(FOLDER_NODE_ID)).willThrow(new EntityNotFoundException(FOLDER_NODE_ID));
|
||||||
|
|
||||||
//when
|
//when
|
||||||
assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(
|
assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(
|
||||||
() -> nodeValidator.validateFolderNode(FOLDER_NODE_ID, false));
|
() -> nodeValidator.validateFolderNode(FOLDER_NODE_ID, false));
|
||||||
|
|
||||||
then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID);
|
||||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||||
then(ruleServiceMock).shouldHaveNoInteractions();
|
then(ruleServiceMock).shouldHaveNoInteractions();
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ public class NodeValidatorTest
|
|||||||
assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy(
|
assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy(
|
||||||
() -> nodeValidator.validateFolderNode(FOLDER_NODE_ID, false));
|
() -> nodeValidator.validateFolderNode(FOLDER_NODE_ID, false));
|
||||||
|
|
||||||
then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null);
|
then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID);
|
||||||
then(nodesMock).should().nodeMatches(folderNodeRef, Set.of(TYPE_FOLDER), null);
|
then(nodesMock).should().nodeMatches(folderNodeRef, Set.of(TYPE_FOLDER), null);
|
||||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||||
then(ruleServiceMock).shouldHaveNoInteractions();
|
then(ruleServiceMock).shouldHaveNoInteractions();
|
||||||
@@ -431,11 +431,12 @@ public class NodeValidatorTest
|
|||||||
then(ruleServiceMock).shouldHaveNoMoreInteractions();
|
then(ruleServiceMock).shouldHaveNoMoreInteractions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetNodesMock() {
|
private void resetNodesMock()
|
||||||
|
{
|
||||||
reset(nodesMock);
|
reset(nodesMock);
|
||||||
given(nodesMock.validateOrLookupNode(eq(FOLDER_NODE_ID), any())).willReturn(folderNodeRef);
|
given(nodesMock.validateOrLookupNode(FOLDER_NODE_ID)).willReturn(folderNodeRef);
|
||||||
given(nodesMock.validateNode(RULE_SET_ID)).willReturn(ruleSetNodeRef);
|
given(nodesMock.validateNode(RULE_SET_ID)).willReturn(ruleSetNodeRef);
|
||||||
given(nodesMock.validateNode(RULE_ID)).willReturn(ruleNodeRef);
|
given(nodesMock.validateNode(RULE_ID)).willReturn(ruleNodeRef);
|
||||||
given(nodesMock.nodeMatches(ruleSetNodeRef, Set.of(ContentModel.TYPE_SYSTEM_FOLDER), null)).willReturn(true);
|
given(nodesMock.nodeMatches(ruleSetNodeRef, Set.of(ContentModel.TYPE_SYSTEM_FOLDER), null)).willReturn(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,10 +37,8 @@ import static org.mockito.ArgumentMatchers.nullable;
|
|||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
import static org.mockito.Mockito.anyBoolean;
|
import static org.mockito.Mockito.anyBoolean;
|
||||||
import static org.mockito.Mockito.anyString;
|
import static org.mockito.Mockito.anyString;
|
||||||
import static org.mockito.Mockito.notNull;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.reset;
|
import static org.mockito.Mockito.notNull;
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -186,7 +184,7 @@ public class ResultMapperTests
|
|||||||
when(sr.getVersionService()).thenReturn(versionService);
|
when(sr.getVersionService()).thenReturn(versionService);
|
||||||
when(sr.getNodeService()).thenReturn(nodeService);
|
when(sr.getNodeService()).thenReturn(nodeService);
|
||||||
|
|
||||||
when(nodes.validateOrLookupNode(nullable(String.class), nullable(String.class))).thenAnswer(invocation ->
|
when(nodes.validateOrLookupNode(nullable(String.class))).thenAnswer(invocation ->
|
||||||
{
|
{
|
||||||
Object[] args = invocation.getArguments();
|
Object[] args = invocation.getArguments();
|
||||||
String aNode = (String)args[0];
|
String aNode = (String)args[0];
|
||||||
|
Reference in New Issue
Block a user