mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged mward/5.2.n-repo1636-contentinfo (5.2.1) to 5.2.N (5.2.1)
133306 mward: REPO-1636: Now filter the entire "usr" namespace, rather than just usr:enabled git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@133310 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -273,10 +273,11 @@ public interface Nodes
|
|||||||
* @param nodeProps
|
* @param nodeProps
|
||||||
* @param selectParam
|
* @param selectParam
|
||||||
* @param mapUserInfo
|
* @param mapUserInfo
|
||||||
|
* @param excludedNS
|
||||||
* @param excludedProps
|
* @param excludedProps
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, Object> mapFromNodeProperties(Map<QName, Serializable> nodeProps, List<String> selectParam, Map<String,UserInfo> mapUserInfo, List<QName> excludedProps);
|
Map<String, Object> mapFromNodeProperties(Map<QName, Serializable> nodeProps, List<String> selectParam, Map<String,UserInfo> mapUserInfo, List<String> excludedNS, List<QName> excludedProps);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map from the JSON API format of properties (String to Object) to
|
* Map from the JSON API format of properties (String to Object) to
|
||||||
@@ -293,10 +294,11 @@ public interface Nodes
|
|||||||
* by the API JSON response for get nodes, get person etc.
|
* by the API JSON response for get nodes, get person etc.
|
||||||
*
|
*
|
||||||
* @param nodeAspects
|
* @param nodeAspects
|
||||||
|
* @param excludedNS
|
||||||
* @param excludedAspects
|
* @param excludedAspects
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<String> mapFromNodeAspects(Set<QName> nodeAspects, List<QName> excludedAspects);
|
List<String> mapFromNodeAspects(Set<QName> nodeAspects, List<String> excludedNS, List<QName> excludedAspects);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add aspects to the specified NodeRef. Aspects that appear in the exclusions list
|
* Add aspects to the specified NodeRef. Aspects that appear in the exclusions list
|
||||||
|
@@ -890,14 +890,14 @@ public class NodesImpl implements Nodes
|
|||||||
|
|
||||||
if (includeParam.size() > 0)
|
if (includeParam.size() > 0)
|
||||||
{
|
{
|
||||||
node.setProperties(mapFromNodeProperties(properties, includeParam, mapUserInfo, EXCLUDED_PROPS));
|
node.setProperties(mapFromNodeProperties(properties, includeParam, mapUserInfo, EXCLUDED_NS, EXCLUDED_PROPS));
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<QName> aspects = null;
|
Set<QName> aspects = null;
|
||||||
if (includeParam.contains(PARAM_INCLUDE_ASPECTNAMES))
|
if (includeParam.contains(PARAM_INCLUDE_ASPECTNAMES))
|
||||||
{
|
{
|
||||||
aspects = nodeService.getAspects(nodeRef);
|
aspects = nodeService.getAspects(nodeRef);
|
||||||
node.setAspectNames(mapFromNodeAspects(aspects, EXCLUDED_ASPECTS));
|
node.setAspectNames(mapFromNodeAspects(aspects, EXCLUDED_NS, EXCLUDED_ASPECTS));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeParam.contains(PARAM_INCLUDE_ISLINK))
|
if (includeParam.contains(PARAM_INCLUDE_ISLINK))
|
||||||
@@ -1161,7 +1161,7 @@ public class NodesImpl implements Nodes
|
|||||||
return nodeProps;
|
return nodeProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> mapFromNodeProperties(Map<QName, Serializable> nodeProps, List<String> selectParam, Map<String,UserInfo> mapUserInfo, List<QName> excludedProps)
|
public Map<String, Object> mapFromNodeProperties(Map<QName, Serializable> nodeProps, List<String> selectParam, Map<String,UserInfo> mapUserInfo, List<String> excludedNS, List<QName> excludedProps)
|
||||||
{
|
{
|
||||||
List<QName> selectedProperties;
|
List<QName> selectedProperties;
|
||||||
|
|
||||||
@@ -1171,7 +1171,7 @@ public class NodesImpl implements Nodes
|
|||||||
selectedProperties = new ArrayList<>(nodeProps.size());
|
selectedProperties = new ArrayList<>(nodeProps.size());
|
||||||
for (QName propQName : nodeProps.keySet())
|
for (QName propQName : nodeProps.keySet())
|
||||||
{
|
{
|
||||||
if ((! EXCLUDED_NS.contains(propQName.getNamespaceURI())) && (! excludedProps.contains(propQName)))
|
if ((! excludedNS.contains(propQName.getNamespaceURI())) && (! excludedProps.contains(propQName)))
|
||||||
{
|
{
|
||||||
selectedProperties.add(propQName);
|
selectedProperties.add(propQName);
|
||||||
}
|
}
|
||||||
@@ -1209,13 +1209,13 @@ public class NodesImpl implements Nodes
|
|||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> mapFromNodeAspects(Set<QName> nodeAspects, List<QName> excludedAspects)
|
public List<String> mapFromNodeAspects(Set<QName> nodeAspects, List<String> excludedNS, List<QName> excludedAspects)
|
||||||
{
|
{
|
||||||
List<String> aspectNames = new ArrayList<>(nodeAspects.size());
|
List<String> aspectNames = new ArrayList<>(nodeAspects.size());
|
||||||
|
|
||||||
for (QName aspectQName : nodeAspects)
|
for (QName aspectQName : nodeAspects)
|
||||||
{
|
{
|
||||||
if ((! EXCLUDED_NS.contains(aspectQName.getNamespaceURI())) && (! excludedAspects.contains(aspectQName)))
|
if ((! excludedNS.contains(aspectQName.getNamespaceURI())) && (! excludedAspects.contains(aspectQName)))
|
||||||
{
|
{
|
||||||
aspectNames.add(aspectQName.toPrefixString(namespaceService));
|
aspectNames.add(aspectQName.toPrefixString(namespaceService));
|
||||||
}
|
}
|
||||||
|
@@ -58,6 +58,7 @@ import org.alfresco.service.cmr.security.PersonService;
|
|||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
import org.alfresco.service.cmr.thumbnail.ThumbnailService;
|
import org.alfresco.service.cmr.thumbnail.ThumbnailService;
|
||||||
import org.alfresco.service.cmr.usage.ContentUsageService;
|
import org.alfresco.service.cmr.usage.ContentUsageService;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
@@ -79,6 +80,9 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class PeopleImpl implements People
|
public class PeopleImpl implements People
|
||||||
{
|
{
|
||||||
|
private static final List<String> EXCLUDED_NS = Arrays.asList(
|
||||||
|
NamespaceService.SYSTEM_MODEL_1_0_URI,
|
||||||
|
"http://www.alfresco.org/model/user/1.0");
|
||||||
private static final List<QName> EXCLUDED_ASPECTS = Arrays.asList();
|
private static final List<QName> EXCLUDED_ASPECTS = Arrays.asList();
|
||||||
private static final List<QName> EXCLUDED_PROPS = Arrays.asList(
|
private static final List<QName> EXCLUDED_PROPS = Arrays.asList(
|
||||||
ContentModel.PROP_USERNAME,
|
ContentModel.PROP_USERNAME,
|
||||||
@@ -105,8 +109,7 @@ public class PeopleImpl implements People
|
|||||||
ContentModel.PROP_SIZE_QUOTA,
|
ContentModel.PROP_SIZE_QUOTA,
|
||||||
ContentModel.PROP_SIZE_CURRENT,
|
ContentModel.PROP_SIZE_CURRENT,
|
||||||
ContentModel.PROP_EMAIL_FEED_DISABLED,
|
ContentModel.PROP_EMAIL_FEED_DISABLED,
|
||||||
ContentModel.PROP_PREFERENCE_VALUES,
|
ContentModel.PROP_PREFERENCE_VALUES);
|
||||||
ContentModel.PROP_ENABLED);
|
|
||||||
protected Nodes nodes;
|
protected Nodes nodes;
|
||||||
protected Sites sites;
|
protected Sites sites;
|
||||||
|
|
||||||
@@ -400,14 +403,14 @@ public class PeopleImpl implements People
|
|||||||
if (include.contains(PARAM_INCLUDE_PROPERTIES))
|
if (include.contains(PARAM_INCLUDE_PROPERTIES))
|
||||||
{
|
{
|
||||||
Map<String, Object> custProps = new HashMap<>();
|
Map<String, Object> custProps = new HashMap<>();
|
||||||
custProps.putAll(nodes.mapFromNodeProperties(nodeProps, new ArrayList<>(), new HashMap<>(), EXCLUDED_PROPS));
|
custProps.putAll(nodes.mapFromNodeProperties(nodeProps, new ArrayList<>(), new HashMap<>(), EXCLUDED_NS, EXCLUDED_PROPS));
|
||||||
person.setProperties(custProps);
|
person.setProperties(custProps);
|
||||||
}
|
}
|
||||||
if (include.contains(PARAM_INCLUDE_ASPECTNAMES))
|
if (include.contains(PARAM_INCLUDE_ASPECTNAMES))
|
||||||
{
|
{
|
||||||
// Expose aspect names
|
// Expose aspect names
|
||||||
Set<QName> aspects = nodeService.getAspects(personNode);
|
Set<QName> aspects = nodeService.getAspects(personNode);
|
||||||
person.setAspectNames(nodes.mapFromNodeAspects(aspects, EXCLUDED_ASPECTS));
|
person.setAspectNames(nodes.mapFromNodeAspects(aspects, EXCLUDED_NS, EXCLUDED_ASPECTS));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get avatar information
|
// get avatar information
|
||||||
|
@@ -40,6 +40,7 @@ import org.alfresco.rest.api.tests.client.data.Person;
|
|||||||
import org.alfresco.service.cmr.preference.PreferenceService;
|
import org.alfresco.service.cmr.preference.PreferenceService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
@@ -487,7 +488,7 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
// Create the person directly using the Java services - we don't want to test
|
// Create the person directly using the Java services - we don't want to test
|
||||||
// the REST API's "create person" function here, so we're isolating this test from it.
|
// the REST API's "create person" function here, so we're isolating this test from it.
|
||||||
PersonService personService = applicationContext.getBean("PersonService", PersonService.class);
|
PersonService personService = applicationContext.getBean("PersonService", PersonService.class);
|
||||||
NodeService nodeService = applicationContext.getBean("NodeService", NodeService.class);
|
MutableAuthenticationService authService = applicationContext.getBean("AuthenticationService", MutableAuthenticationService.class);
|
||||||
PreferenceService prefService = applicationContext.getBean("PreferenceService", PreferenceService.class);
|
PreferenceService prefService = applicationContext.getBean("PreferenceService", PreferenceService.class);
|
||||||
Map<QName, Serializable> nodeProps = new HashMap<>();
|
Map<QName, Serializable> nodeProps = new HashMap<>();
|
||||||
// The cm:titled aspect should be auto-added for the cm:title property
|
// The cm:titled aspect should be auto-added for the cm:title property
|
||||||
@@ -522,10 +523,14 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
nodeProps.put(ContentModel.PROP_EMAIL_FEED_DISABLED, false);
|
nodeProps.put(ContentModel.PROP_EMAIL_FEED_DISABLED, false);
|
||||||
// TODO: PROP_PERSON_DESCRIPTION?
|
// TODO: PROP_PERSON_DESCRIPTION?
|
||||||
|
|
||||||
// Namespace that should be filtered
|
// Namespaces that should be filtered
|
||||||
|
nodeProps.put(ContentModel.PROP_ENABLED, true);
|
||||||
nodeProps.put(ContentModel.PROP_SYS_NAME, "name-value");
|
nodeProps.put(ContentModel.PROP_SYS_NAME, "name-value");
|
||||||
|
|
||||||
|
// Create a password and enable the user so that we can check the usr:* props aren't present later.
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser("admin@"+account1.getId());
|
AuthenticationUtil.setFullyAuthenticatedUser("admin@"+account1.getId());
|
||||||
|
authService.createAuthentication(userName, "password".toCharArray());
|
||||||
|
authService.setAuthenticationEnabled(userName, true);
|
||||||
personService.createPerson(nodeProps);
|
personService.createPerson(nodeProps);
|
||||||
|
|
||||||
// Set a preference, so that we can test that we're filtering this property correctly.
|
// Set a preference, so that we can test that we're filtering this property correctly.
|
||||||
@@ -568,16 +573,13 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
assertFalse(person.getProperties().containsKey("cm:sizeCurrent"));
|
assertFalse(person.getProperties().containsKey("cm:sizeCurrent"));
|
||||||
assertFalse(person.getProperties().containsKey("cm:emailFeedDisabled"));
|
assertFalse(person.getProperties().containsKey("cm:emailFeedDisabled"));
|
||||||
assertFalse(person.getProperties().containsKey("cm:persondescription"));
|
assertFalse(person.getProperties().containsKey("cm:persondescription"));
|
||||||
assertFalse(person.getProperties().containsKey("usr:enabled"));
|
|
||||||
// TODO: others, e.g. usr:* ?
|
|
||||||
// We also don't want cm:preferenceValues (see REPO-1636)
|
// We also don't want cm:preferenceValues (see REPO-1636)
|
||||||
assertFalse(person.getProperties().containsKey("cm:preferenceValues"));
|
assertFalse(person.getProperties().containsKey("cm:preferenceValues"));
|
||||||
|
|
||||||
|
// Check that no properties are present that should have been filtered by namespace.
|
||||||
// Check that no properties are present that should have been filtered.
|
|
||||||
for (String key : person.getProperties().keySet())
|
for (String key : person.getProperties().keySet())
|
||||||
{
|
{
|
||||||
if (key.startsWith("sys:"))
|
if (key.startsWith("sys:") || key.startsWith("usr:"))
|
||||||
{
|
{
|
||||||
Object value = person.getProperties().get(key);
|
Object value = person.getProperties().get(key);
|
||||||
String keyValueStr = String.format("(key=%s, value=%s)", key, value);
|
String keyValueStr = String.format("(key=%s, value=%s)", key, value);
|
||||||
|
Reference in New Issue
Block a user