Author: jens
Date: Wed Aug  7 19:13:38 2013
New Revision: 1511442

URL: http://svn.apache.org/r1511442
Log:
InMemory: small fix to avoid potential NPE

Modified:
    
chemistry/opencmis/branches/inmemory-refactoring/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java

Modified: 
chemistry/opencmis/branches/inmemory-refactoring/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/branches/inmemory-refactoring/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java?rev=1511442&r1=1511441&r2=1511442&view=diff
==============================================================================
--- 
chemistry/opencmis/branches/inmemory-refactoring/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
 (original)
+++ 
chemistry/opencmis/branches/inmemory-refactoring/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
 Wed Aug  7 19:13:38 2013
@@ -669,17 +669,17 @@ public class InMemoryObjectServiceImpl e
 
                 PropertyData<?> value = properties.getProperties().get(key);
                 PropertyDefinition<?> propDef = 
typeDef.getPropertyDefinitions().get(key);
+                if (cmis11 && null == propDef) {
+                    TypeDefinition typeDefSecondary = 
getSecondaryTypeDefinition(repositoryId, secondaryTypeIds, key);
+                    if (null == typeDefSecondary)
+                        throw new CmisInvalidArgumentException("Cannot update 
property " + key
+                                + ": not contained in type");
+                    propDef = 
typeDefSecondary.getPropertyDefinitions().get(key);
+                }
+                
                 if (null == propDef) {
-                    if (cmis11) {
-                        TypeDefinition typeDefSecondary = 
getSecondaryTypeDefinition(repositoryId, secondaryTypeIds, key);
-                        if (null == typeDefSecondary)
-                            throw new CmisInvalidArgumentException("Cannot 
update property " + key
-                                    + ": not contained in type");
-                        propDef = 
typeDefSecondary.getPropertyDefinitions().get(key);
-                    } else {
-                        throw new CmisInvalidArgumentException("Unknown 
property " + key
-                                + ": not contained in type");                  
      
-                    }
+                    throw new CmisInvalidArgumentException("Unknown property " 
+ key
+                            + ": not contained in type (or any secondary 
type)");                        
                 }
 
                 if (value.getValues() == null || value.getFirstValue() == 
null) {
@@ -693,12 +693,12 @@ public class InMemoryObjectServiceImpl e
                     oldProperties.remove(key);
                     hasUpdatedProp = true;
                 } else {
-                    if 
(propDef.getUpdatability().equals(Updatability.WHENCHECKEDOUT)) {
+                    if (propDef.getUpdatability() == 
Updatability.WHENCHECKEDOUT) {
                         if (!isCheckedOut)
                             throw new CmisUpdateConflictException(
                                     "updateProperties failed, following 
property can't be updated, because it is not checked-out: "
                                             + key);
-                    } else if 
(!propDef.getUpdatability().equals(Updatability.READWRITE)) {
+                    } else if (propDef.getUpdatability() != 
Updatability.READWRITE) {
                         throw new CmisConstraintException(
                                 "updateProperties failed, following property 
can't be updated, because it is not writable: "
                                         + key);


Reply via email to