mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.N (5.2.2) to HEAD (5.2)
134045 cturlica: REPO-1684: We should not return properties that are empty - Empty (zero length) string values are considered to be null values, and will be represented the same as null values (i.e. by non-existence of the property). git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@137334 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1197,6 +1197,15 @@ public class NodesImpl implements Nodes
|
||||
{
|
||||
value = Node.lookupUserInfo((String)value, mapUserInfo, sr.getPersonService());
|
||||
}
|
||||
|
||||
// Empty (zero length) string values are considered to be
|
||||
// null values, and will be represented the same as null
|
||||
// values (i.e. by non-existence of the property).
|
||||
if (value != null && value instanceof String && ((String) value).isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
props.put(qName.toPrefixString(namespaceService), value);
|
||||
}
|
||||
}
|
||||
|
@@ -3544,6 +3544,49 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
||||
assertEquals("The quick brown fox jumps over the lazy dog", textContent);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNodeWithEmptyProperties() throws Exception
|
||||
{
|
||||
setRequestContext(user1);
|
||||
|
||||
String myNodeId = getMyNodeId();
|
||||
|
||||
// create folder f1
|
||||
Folder folderResp = createFolder(myNodeId, "fld1_" + RUNID);
|
||||
String f1Id = folderResp.getId();
|
||||
|
||||
String nodeName = "f1 link";
|
||||
String nodeType = "app:folderlink";
|
||||
String propertyName = "cm:destination";
|
||||
|
||||
Map<String, Object> props = new HashMap<>();
|
||||
props.put(propertyName, "");
|
||||
|
||||
Node nodeResp = createNode(f1Id, nodeName, nodeType, props);
|
||||
String nodeId = nodeResp.getId();
|
||||
|
||||
Node n1 = new Node();
|
||||
n1.setName(nodeName);
|
||||
n1.setNodeType(nodeType);
|
||||
n1.setIsFolder(true);
|
||||
// note: parent of the link (not where it is pointing)
|
||||
n1.setParentId(f1Id);
|
||||
n1.setAspectNames(Collections.singletonList("cm:auditable"));
|
||||
// Empty (zero length) string values are considered to be
|
||||
// null values, and will be represented the same as null
|
||||
// values (i.e. by non-existence of the property).
|
||||
n1.setProperties(null);
|
||||
|
||||
// Check create response.
|
||||
n1.expected(nodeResp);
|
||||
|
||||
HttpResponse httpResponse = getSingle(NodesEntityResource.class, nodeId, null, 200);
|
||||
nodeResp = RestApiUtil.parseRestApiEntry(httpResponse.getJsonResponse(), Node.class);
|
||||
|
||||
// Check get response.
|
||||
n1.expected(nodeResp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests optional lookup of Allowable Operations (eg. when getting node info, listing node children, ...)
|
||||
*
|
||||
|
@@ -77,6 +77,7 @@ public class TestPeople extends EnterpriseTestApi
|
||||
private static final QName PROP_TELEHASH = QName.createQName("test.people.api", "telehash");
|
||||
private static final QName ASPECT_LUNCHABLE = QName.createQName("test.people.api", "lunchable");
|
||||
private static final QName PROP_LUNCH = QName.createQName("test.people.api", "lunch");
|
||||
private static final QName PROP_LUNCH_COMMENTS = QName.createQName("test.people.api", "lunchcomments");
|
||||
private People people;
|
||||
private Iterator<TestNetwork> accountsIt;
|
||||
private TestNetwork account1;
|
||||
@@ -577,6 +578,7 @@ public class TestPeople extends EnterpriseTestApi
|
||||
Map<QName, Serializable> nodeProps = new HashMap<>();
|
||||
// The papi:lunchable aspect should be auto-added for the papi:lunch property
|
||||
nodeProps.put(PROP_LUNCH, "Falafel wrap");
|
||||
nodeProps.put(PROP_LUNCH_COMMENTS, "");
|
||||
|
||||
// These properties should not be present when a person is retrieved
|
||||
// since they are present as top-level fields.
|
||||
@@ -630,6 +632,11 @@ public class TestPeople extends EnterpriseTestApi
|
||||
assertEquals("Falafel wrap", person.getProperties().get("papi:lunch"));
|
||||
assertTrue(person.getAspectNames().contains("papi:lunchable"));
|
||||
|
||||
// Empty (zero length) string values are considered to be
|
||||
// null values, and will be represented the same as null
|
||||
// values (i.e. by non-existence of the property).
|
||||
assertNull(person.getProperties().get("papi:lunchcomments"));
|
||||
|
||||
// Check that no properties are present that should have been filtered by namespace.
|
||||
for (String key : person.getProperties().keySet())
|
||||
{
|
||||
|
@@ -49,6 +49,10 @@
|
||||
<type>d:text</type>
|
||||
<mandatory>false</mandatory>
|
||||
</property>
|
||||
<property name="papi:lunchcomments">
|
||||
<type>d:text</type>
|
||||
<mandatory>false</mandatory>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
|
||||
|
Reference in New Issue
Block a user