Merged HEAD (5.2) to 5.2.N (5.2.1)

126538 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
      123316 jvonka: Nodes (FileFolder) API - add optional include allowableOperations 
      RA-770


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126882 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2016-05-11 12:04:10 +00:00
parent fbd2ca5698
commit 543d2bbf1c
7 changed files with 205 additions and 18 deletions

View File

@@ -728,7 +728,7 @@ public class NodesImpl implements Nodes
return getFolderOrDocument(nodeRef, parentNodeRef, nodeTypeQName, includeParam, null);
}
private Node getFolderOrDocument(final NodeRef nodeRef, NodeRef parentNodeRef, QName nodeTypeQName, List<String> selectParam, Map<String,UserInfo> mapUserInfo)
private Node getFolderOrDocument(final NodeRef nodeRef, NodeRef parentNodeRef, QName nodeTypeQName, List<String> includeParam, Map<String,UserInfo> mapUserInfo)
{
if (mapUserInfo == null)
{
@@ -736,7 +736,7 @@ public class NodesImpl implements Nodes
}
PathInfo pathInfo = null;
if (selectParam.contains(PARAM_INCLUDE_PATH))
if (includeParam.contains(PARAM_INCLUDE_PATH))
{
pathInfo = lookupPathInfo(nodeRef);
}
@@ -777,21 +777,48 @@ public class NodesImpl implements Nodes
throw new RuntimeException("Unexpected - should not reach here: "+type);
}
if (selectParam.size() > 0)
if (includeParam.size() > 0)
{
node.setProperties(mapFromNodeProperties(properties, selectParam, mapUserInfo));
node.setProperties(mapFromNodeProperties(properties, includeParam, mapUserInfo));
}
if (selectParam.contains(PARAM_INCLUDE_ASPECTNAMES))
if (includeParam.contains(PARAM_INCLUDE_ASPECTNAMES))
{
node.setAspectNames(mapFromNodeAspects(nodeService.getAspects(nodeRef)));
}
if (selectParam.contains(PARAM_INCLUDE_ISLINK))
if (includeParam.contains(PARAM_INCLUDE_ISLINK))
{
boolean isLink = isSubClass(nodeTypeQName, ContentModel.TYPE_LINK);
node.setIsLink(isLink);
}
if (includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS))
{
// note: refactor when requirements change
Map<String, String> mapPermsToOps = new HashMap<>(3);
mapPermsToOps.put(PermissionService.DELETE, OP_DELETE);
mapPermsToOps.put(PermissionService.ADD_CHILDREN, OP_CREATE);
mapPermsToOps.put(PermissionService.WRITE, OP_UPDATE);
List<String> allowableOperations = new ArrayList<>(3);
for (Entry<String, String> kv : mapPermsToOps.entrySet())
{
String perm = kv.getKey();
String op = kv.getValue();
// special case: do not return "create" for file
if (! (perm.equals(PermissionService.ADD_CHILDREN) && type.equals(Type.DOCUMENT)))
{
if (permissionService.hasPermission(nodeRef, perm) == AccessStatus.ALLOWED)
{
allowableOperations.add(op);
}
}
}
node.setAllowableOperations((allowableOperations.size() > 0 )? allowableOperations : null);
}
node.setNodeType(nodeTypeQName.toPrefixString(namespaceService));
node.setPath(pathInfo);

View File

@@ -455,23 +455,23 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
return CollectionWithPagingInfo.asPaged(paging, qsLinks, results.hasMore(), new Long(results.getNumberFound()).intValue());
}
private QuickShareLink getQuickShareInfo(String sharedId, boolean noAuth, List<String> selectParam)
private QuickShareLink getQuickShareInfo(String sharedId, boolean noAuth, List<String> includeParam)
{
checkValidShareId(sharedId);
Map<String, Object> map = (Map<String, Object>) quickShareService.getMetaData(sharedId).get("item");
NodeRef nodeRef = new NodeRef((String) map.get("nodeRef"));
return getQuickShareInfo(nodeRef, map, noAuth, selectParam);
return getQuickShareInfo(nodeRef, map, noAuth, includeParam);
}
private QuickShareLink getQuickShareInfo(NodeRef nodeRef, boolean noAuth, List<String> selectParam)
private QuickShareLink getQuickShareInfo(NodeRef nodeRef, boolean noAuth, List<String> includeParam)
{
Map<String, Object> map = (Map<String, Object>) quickShareService.getMetaData(nodeRef).get("item");
return getQuickShareInfo(nodeRef, map , noAuth, selectParam);
return getQuickShareInfo(nodeRef, map , noAuth, includeParam);
}
private QuickShareLink getQuickShareInfo(NodeRef nodeRef, Map<String, Object> map, boolean noAuth, List<String> selectParam)
private QuickShareLink getQuickShareInfo(NodeRef nodeRef, Map<String, Object> map, boolean noAuth, List<String> includeParam)
{
String sharedId = (String)map.get("sharedId");
@@ -502,11 +502,11 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
qs.setModifiedByUser(modifiedByUser);
qs.setSharedByUser(sharedByUser);
if ((! noAuth) && selectParam.contains(PARAM_SELECT_ISLINK))
if ((! noAuth) && includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS))
{
if (canDeleteSharedLink(nodeRef, sharedByUserId))
{
qs.setAllowableOperations(Collections.singletonList("delete"));
qs.setAllowableOperations(Collections.singletonList(Nodes.OP_DELETE));
}
}