mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126359 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 119631 jvonka: RA-639: FileFolder API - update node info (metadata) - add &/or remove aspects - TODO add tests (across the board) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126705 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -884,7 +884,6 @@ public class NodesImpl implements Nodes
|
||||
|
||||
public Node updateNode(String nodeId, Node nodeInfo, Parameters parameters)
|
||||
{
|
||||
|
||||
final NodeRef nodeRef = validateNode(nodeId);
|
||||
|
||||
final Set<QName> fileOrFolder = new HashSet<>(Arrays.asList(ContentModel.TYPE_FOLDER, ContentModel.TYPE_CONTENT));
|
||||
@@ -911,6 +910,61 @@ public class NodesImpl implements Nodes
|
||||
props.put(ContentModel.PROP_NAME, name);
|
||||
}
|
||||
|
||||
List<String> aspectNames = nodeInfo.getAspectNames();
|
||||
if (aspectNames != null)
|
||||
{
|
||||
// note: can be empty (eg. to remove existing aspects (+ aspect properties) ... apart from cm:auditable, sys:referencable, sys:localized)
|
||||
Set<QName> aspectQNames = new HashSet<>(aspectNames.size());
|
||||
for (String aspectName : aspectNames)
|
||||
{
|
||||
QName aspectQName = QName.createQName(aspectName, namespaceService);
|
||||
aspectQNames.add(aspectQName);
|
||||
}
|
||||
|
||||
Set<QName> existingAspects = nodeService.getAspects(nodeRef);
|
||||
|
||||
Set<QName> aspectsToAdd = new HashSet<>(3);
|
||||
Set<QName> aspectsToRemove = new HashSet<>(3);
|
||||
|
||||
for (QName aspectQName : aspectQNames)
|
||||
{
|
||||
if (EXCLUDED_ASPECTS.contains(aspectQName) || aspectQName.equals(ContentModel.ASPECT_AUDITABLE))
|
||||
{
|
||||
continue; // ignore
|
||||
}
|
||||
|
||||
if (! existingAspects.contains(aspectQName))
|
||||
{
|
||||
aspectsToAdd.add(aspectQName);
|
||||
}
|
||||
}
|
||||
|
||||
for (QName existingAspect : existingAspects)
|
||||
{
|
||||
if (EXCLUDED_ASPECTS.contains(existingAspect) || existingAspect.equals(ContentModel.ASPECT_AUDITABLE))
|
||||
{
|
||||
continue; // ignore
|
||||
}
|
||||
|
||||
if (! aspectQNames.contains(existingAspect))
|
||||
{
|
||||
aspectsToRemove.add(existingAspect);
|
||||
}
|
||||
}
|
||||
|
||||
// Note: for now, if aspectNames are sent then all that are required should be sent (to avoid properties from other existing aspects being removed)
|
||||
// TODO: optional PATCH mechanism to add one new new aspect (with some related aspect properties) without affecting existing aspects/properties
|
||||
for (QName aQName : aspectsToRemove)
|
||||
{
|
||||
nodeService.removeAspect(nodeRef, aQName);
|
||||
}
|
||||
|
||||
for (QName aQName : aspectsToAdd)
|
||||
{
|
||||
nodeService.addAspect(nodeRef, aQName, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (props.size() > 0)
|
||||
{
|
||||
nodeService.addProperties(nodeRef, props);
|
||||
|
@@ -114,7 +114,7 @@ public class Node implements Comparable<Node>
|
||||
public static UserInfo lookupUserInfo(String userName, Map<String, UserInfo> mapUserInfo, PersonService personService) {
|
||||
|
||||
UserInfo userInfo = mapUserInfo.get(userName);
|
||||
if (userInfo == null)
|
||||
if ((userInfo == null) && (userName != null))
|
||||
{
|
||||
String sysUserName = AuthenticationUtil.getSystemUserName();
|
||||
if (userName.equals(sysUserName) || (AuthenticationUtil.isMtEnabled() && userName.startsWith(sysUserName + "@")))
|
||||
|
Reference in New Issue
Block a user