mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fix MNT-21991 customizable personLookupProperties for REST API (#191)
* Fix MNT-21991 custom personLookupProperties * Fix MNT-21991 test case for cm:owner
This commit is contained in:
@@ -229,10 +229,13 @@ public class NodesImpl implements Nodes
|
||||
private Repository repositoryHelper;
|
||||
private ServiceRegistry sr;
|
||||
private Set<String> defaultIgnoreTypesAndAspects;
|
||||
private Set<String> defaultPersonLookupProperties;
|
||||
|
||||
// ignore types/aspects
|
||||
private Set<QName> ignoreQNames;
|
||||
|
||||
private Set<QName> personLookupProperties = new HashSet<>();
|
||||
|
||||
private ConcurrentHashMap<String,NodeRef> ddCache = new ConcurrentHashMap<>();
|
||||
|
||||
private Set<String> nonAttachContentTypes = Collections.emptySet(); // pre-configured whitelist, eg. images & pdf
|
||||
@@ -276,6 +279,14 @@ public class NodesImpl implements Nodes
|
||||
ignoreQNames.add(createQName(type));
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultPersonLookupProperties != null)
|
||||
{
|
||||
for (String property : defaultPersonLookupProperties)
|
||||
{
|
||||
personLookupProperties.add(createQName(property));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setServiceRegistry(ServiceRegistry sr)
|
||||
@@ -303,6 +314,10 @@ public class NodesImpl implements Nodes
|
||||
this.defaultIgnoreTypesAndAspects = ignoreTypesAndAspects;
|
||||
}
|
||||
|
||||
public void setPersonLookupProperties(Set<String> personLookupProperties) {
|
||||
this.defaultPersonLookupProperties = personLookupProperties;
|
||||
}
|
||||
|
||||
public void setPoster(ActivityPoster poster)
|
||||
{
|
||||
this.poster = poster;
|
||||
@@ -338,13 +353,6 @@ public class NodesImpl implements Nodes
|
||||
ContentModel.PROP_AUTO_VERSION_PROPS,
|
||||
ContentModel.PROP_AUTO_VERSION);
|
||||
|
||||
public static final List<QName> PROPS_USERLOOKUP = Arrays.asList(
|
||||
ContentModel.PROP_CREATOR,
|
||||
ContentModel.PROP_MODIFIER,
|
||||
ContentModel.PROP_OWNER,
|
||||
ContentModel.PROP_LOCK_OWNER,
|
||||
ContentModel.PROP_WORKING_COPY_OWNER);
|
||||
|
||||
public final static Map<String,QName> PARAM_SYNONYMS_QNAME;
|
||||
static
|
||||
{
|
||||
@@ -1222,9 +1230,9 @@ public class NodesImpl implements Nodes
|
||||
Serializable value = nodeProps.get(qName);
|
||||
if (value != null)
|
||||
{
|
||||
if (PROPS_USERLOOKUP.contains(qName))
|
||||
if (personLookupProperties.contains(qName))
|
||||
{
|
||||
value = Node.lookupUserInfo((String)value, mapUserInfo, sr.getPersonService());
|
||||
value = Node.lookupUserInfo((String) value, mapUserInfo, personService);
|
||||
}
|
||||
|
||||
// Empty (zero length) string values are considered to be
|
||||
|
@@ -25,15 +25,12 @@
|
||||
*/
|
||||
package org.alfresco.rest.api.lookups;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.transaction.TransactionalResourceHelper;
|
||||
import org.alfresco.rest.api.impl.NodesImpl;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -63,10 +60,9 @@ public class PersonPropertyLookup implements PropertyLookup<String>
|
||||
return supported;
|
||||
}
|
||||
|
||||
public void setSupported(List<String> supported)
|
||||
public void setSupported(Set<String> supported)
|
||||
{
|
||||
NodesImpl.PROPS_USERLOOKUP.forEach(entry -> this.supported.add(entry.toString()));
|
||||
this.supported.addAll(supported);
|
||||
this.supported = supported;
|
||||
}
|
||||
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
|
@@ -518,6 +518,18 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="nodes.personLookupProperties" class="org.springframework.beans.factory.config.SetFactoryBean">
|
||||
<property name="sourceSet">
|
||||
<set>
|
||||
<value>{http://www.alfresco.org/model/content/1.0}creator</value>
|
||||
<value>{http://www.alfresco.org/model/content/1.0}modifier</value>
|
||||
<value>{http://www.alfresco.org/model/content/1.0}owner</value>
|
||||
<value>{http://www.alfresco.org/model/content/1.0}lockOwner</value>
|
||||
<value>{http://www.alfresco.org/model/content/1.0}workingCopyOwner</value>
|
||||
</set>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="nodeDefinitionMapper" class="org.alfresco.rest.api.impl.NodeDefinitionMapperImpl"/>
|
||||
|
||||
<bean id="nodes" class="org.alfresco.rest.api.impl.NodesImpl" init-method="init">
|
||||
@@ -527,6 +539,7 @@
|
||||
<property name="behaviourFilter" ref="policyBehaviourFilter"/>
|
||||
<property name="ignoreTypes" ref="nodes.ignoreTypes"/>
|
||||
<property name="nonAttachContentTypes" ref="nodes.nonAttachContentTypes"/>
|
||||
<property name="personLookupProperties" ref="nodes.personLookupProperties"/>
|
||||
<property name="poster" ref="activitiesPoster" />
|
||||
<property name="smartStore" ref="smartStore"/>
|
||||
<property name="nodeDefinitionMapper" ref="nodeDefinitionMapper" />
|
||||
@@ -835,14 +848,15 @@
|
||||
<bean id="publicapi.personPropertyLookup" class="org.alfresco.rest.api.lookups.PersonPropertyLookup">
|
||||
<property name="serviceRegistry" ref="ServiceRegistry"/>
|
||||
<property name="supported">
|
||||
<list>
|
||||
<value>cm:creator</value>
|
||||
<value>cm:modifier</value>
|
||||
<value>cm:owner</value>
|
||||
<value>creator</value>
|
||||
<value>modifier</value>
|
||||
<value>owner</value>
|
||||
</list>
|
||||
<bean parent="nodes.personLookupProperties" class="org.springframework.beans.factory.config.SetFactoryBean">
|
||||
<property name="sourceSet">
|
||||
<set merge="true">
|
||||
<value>creator</value>
|
||||
<value>modifier</value>
|
||||
<value>owner</value>
|
||||
</set>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
@@ -710,6 +710,7 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
||||
String title = "test title";
|
||||
Map<String,String> docProps = new HashMap<>();
|
||||
docProps.put("cm:title", title);
|
||||
docProps.put("cm:owner", user2);
|
||||
String contentName = "content " + RUNID + ".txt";
|
||||
String content1Id = createTextFile(folderB_Id, contentName, "The quick brown fox jumps over the lazy dog.", "UTF-8", docProps).getId();
|
||||
|
||||
@@ -743,9 +744,10 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
||||
props.put("cm:title", title);
|
||||
props.put("cm:versionLabel", "1.0");
|
||||
props.put("cm:versionType", "MAJOR");
|
||||
props.put("cm:owner", new UserInfo(user2).toJSON());
|
||||
|
||||
d1.setProperties(props);
|
||||
d1.setAspectNames(Arrays.asList("cm:auditable","cm:titled","cm:versionable","cm:author"));
|
||||
d1.setAspectNames(Arrays.asList("cm:auditable","cm:titled","cm:versionable","cm:author","cm:ownable"));
|
||||
|
||||
// Note: Path is not part of the default info
|
||||
d1.expected(documentResp);
|
||||
|
Reference in New Issue
Block a user