You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2010/11/16 17:49:25 UTC
svn commit: r1035689 - in
/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src:
main/java/org/apache/chemistry/opencmis/inmemory/
test/java/org/apache/chemistry/opencmis/inmemory/
Author: jens
Date: Tue Nov 16 16:49:25 2010
New Revision: 1035689
URL: http://svn.apache.org/viewvc?rev=1035689&view=rev
Log:
Fix NPE in InMemoryRepository if no objectId is in property filter
Modified:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java?rev=1035689&r1=1035688&r2=1035689&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java Tue Nov 16 16:49:25 2010
@@ -22,10 +22,13 @@ package org.apache.chemistry.opencmis.in
* @author Jens
*/
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+
public class FilterParser {
public static boolean isContainedInFilter(String propertyId, List<String> requestedIds) {
@@ -41,6 +44,13 @@ public class FilterParser {
List<String> requestedIds = Arrays.asList(filter.split(",\\s*")); // comma
// plus
// whitespace
+
+ // add object id because this is always needed in AtomPub binding:
+ if (!(requestedIds.contains(PropertyIds.OBJECT_ID))) {
+ requestedIds = new ArrayList<String>(requestedIds); // copy immutable list
+ requestedIds.add(PropertyIds.OBJECT_ID);
+ }
+
if (requestedIds.contains("*"))
requestedIds = Collections.singletonList("*");
return requestedIds;
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java?rev=1035689&r1=1035688&r2=1035689&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java Tue Nov 16 16:49:25 2010
@@ -842,6 +842,23 @@ public class ObjectServiceTest extends A
log.info("... testDefaultPropertiesFolder() finished.");
}
+ @Test
+ public void testGetObjectNoObjectIdInFilter() {
+ log.info("starting testGetObjectNoObjectIdInFilter() ...");
+ log.info(" creating object");
+ String id = createDocument(fRootFolderId, false);
+ if (id != null)
+ log.info(" createDocument succeeded with created id: " + id);
+
+ log.info(" getting object");
+ String filter = PropertyIds.NAME + "," + PropertyIds.CREATION_DATE + "," + PropertyIds.LAST_MODIFICATION_DATE;
+ ObjectData res = fObjSvc.getObject(fRepositoryId, id, filter, false, IncludeRelationships.NONE, null, false, false, null);
+
+ String returnedId = res.getId();
+ assertEquals(id, returnedId);
+ log.info("... testGetObjectNoObjectIdInFilter() finished.");
+ }
+
private void verifyAllowableActionsDocument(Set<Action> actions, boolean isVersioned, boolean hasContent) {
assertTrue(actions.contains(Action.CAN_DELETE_OBJECT));
assertTrue(actions.contains(Action.CAN_UPDATE_PROPERTIES));
@@ -979,11 +996,15 @@ public class ObjectServiceTest extends A
Map<String, PropertyData<?>> props) {
super.testReturnedProperties(objectId, props);
- PropertyData<?> pd = props.get(PropertyIds.NAME);
- assertNotNull(pd);
- assertEquals(objectName, pd.getFirstValue());
- pd = props.get(PropertyIds.OBJECT_TYPE_ID);
- assertEquals(typeId, pd.getFirstValue());
+ if (null != objectName) {
+ PropertyData<?> pd = props.get(PropertyIds.NAME);
+ assertNotNull(pd);
+ assertEquals(objectName, pd.getFirstValue());
+ }
+ if (null != typeId) {
+ PropertyData<?> pd = props.get(PropertyIds.OBJECT_TYPE_ID);
+ assertEquals(typeId, pd.getFirstValue());
+ }
}
private String createDocumentWithCustomType(String folderId, boolean withContent) {
@@ -1198,5 +1219,5 @@ public class ObjectServiceTest extends A
return cmisFolderType;
}
}
-
+
}