chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1514619 [3/4] - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory: ./ query/ server/ storedobj/api/ storedobj/impl/ types/
Date Fri, 16 Aug 2013 08:47:51 GMT
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java Fri Aug 16 08:47:50 2013
@@ -40,16 +40,18 @@ import org.apache.chemistry.opencmis.inm
 
 /**
  * A class representing a single version of a document
- *
+ * 
  * @author Jens
- *
+ * 
  */
 public class DocumentVersionImpl extends StoredObjectImpl implements DocumentVersion, MultiFiling {
 
-    private static final Long MAX_CONTENT_SIZE_KB = ConfigurationSettings.getConfigurationValueAsLong(ConfigConstants.MAX_CONTENT_SIZE_KB);
+    private static final Long MAX_CONTENT_SIZE_KB = ConfigurationSettings
+            .getConfigurationValueAsLong(ConfigConstants.MAX_CONTENT_SIZE_KB);
 
     private ContentStreamDataImpl fContent;
-    private final VersionedDocumentImpl fContainer; // the document this version belongs to
+    private final VersionedDocumentImpl fContainer; // the document this version
+                                                    // belongs to
     private String fComment; // checkin comment
     private boolean fIsMajor;
     private boolean fIsPwc; // true if this is the PWC
@@ -59,12 +61,12 @@ public class DocumentVersionImpl extends
         super();
         setRepositoryId(repositoryId);
         fContainer = (VersionedDocumentImpl) container;
-        setContentIntern(content, false);
+        setContentIntern(content);
         fIsMajor = verState == VersioningState.MAJOR || verState == null;
         fIsPwc = verState == VersioningState.CHECKEDOUT;
         fProperties = new HashMap<String, PropertyData<?>>();
         // copy user properties from latest version
-        DocumentVersionImpl src = (DocumentVersionImpl)container.getLatestVersion(false);
+        DocumentVersionImpl src = (DocumentVersionImpl) container.getLatestVersion(false);
         if (null != src && null != src.fProperties) {
             for (Entry<String, PropertyData<?>> prop : src.fProperties.entrySet()) {
                 fProperties.put(prop.getKey(), prop.getValue());
@@ -73,11 +75,11 @@ public class DocumentVersionImpl extends
     }
 
     @Override
-	public void setContent(ContentStream content, boolean mustPersist) {
-        setContentIntern(content, mustPersist);
+    public void setContent(ContentStream content, boolean mustPersist) {
+        setContentIntern(content);
     }
-    
-    private void setContentIntern(ContentStream content, boolean mustPersist) {
+
+    private void setContentIntern(ContentStream content) {
         if (null == content) {
             fContent = null;
         } else {
@@ -94,10 +96,11 @@ public class DocumentVersionImpl extends
     }
 
     @Override
-	public void appendContent(ContentStream content) {
+    public void appendContent(ContentStream content) {
         if (null == content) {
             return;
-        } if (null == fContent) {
+        }
+        if (null == fContent) {
             setContent(content, true);
         } else {
             try {
@@ -109,12 +112,12 @@ public class DocumentVersionImpl extends
     }
 
     @Override
-	public void setCheckinComment(String comment) {
+    public void setCheckinComment(String comment) {
         fComment = comment;
     }
 
     @Override
-	public String getCheckinComment() {
+    public String getCheckinComment() {
         return fComment;
     }
 
@@ -138,23 +141,23 @@ public class DocumentVersionImpl extends
     }
 
     @Override
-	public boolean isMajor() {
+    public boolean isMajor() {
         return fIsMajor && !isPwc();
     }
 
     @Override
-	public boolean isPwc() {
+    public boolean isPwc() {
         return fIsPwc;
     }
 
     @Override
-	public void commit(boolean isMajor) {
+    public void commit(boolean isMajor) {
         fIsPwc = false; // unset working copy flag
         fIsMajor = isMajor;
     }
 
     @Override
-	public ContentStream getContent(long offset, long length) {
+    public ContentStream getContent(long offset, long length) {
         if (offset <= 0 && length < 0) {
             return fContent;
         } else {
@@ -163,7 +166,7 @@ public class DocumentVersionImpl extends
     }
 
     @Override
-	public VersionedDocument getParentDocument() {
+    public VersionedDocument getParentDocument() {
         return fContainer;
     }
 
@@ -172,16 +175,16 @@ public class DocumentVersionImpl extends
         boolean hasPwc = null != fContainer.getPwc();
         boolean isLatestVersion;
         if (hasPwc) {
-        	// CMIS 1.1 forbids it for PWC
-            isLatestVersion = allVers.size() > 1 && allVers.get(allVers.size() - 2).equals(this);        	
+            // CMIS 1.1 forbids it for PWC
+            isLatestVersion = allVers.size() > 1 && allVers.get(allVers.size() - 2).equals(this);
         } else {
-            isLatestVersion = allVers.get(allVers.size() - 1).equals(this);        	
+            isLatestVersion = allVers.get(allVers.size() - 1).equals(this);
         }
         if (hasPwc) {
             // CMIS 1.1 forbids it for PWC
-            isLatestVersion = allVers.size() > 1 && allVers.get(allVers.size() - 2).equals(this);          
+            isLatestVersion = allVers.size() > 1 && allVers.get(allVers.size() - 2).equals(this);
         } else {
-            isLatestVersion = allVers.get(allVers.size() - 1).equals(this);            
+            isLatestVersion = allVers.get(allVers.size() - 1).equals(this);
         }
         return isLatestVersion;
     }
@@ -200,15 +203,10 @@ public class DocumentVersionImpl extends
             }
         }
 
-        boolean isLatestMajorVersion = latestMajor == this; 
+        boolean isLatestMajorVersion = latestMajor == this;
         return isLatestMajorVersion;
     }
 
-    // public void persist() {
-    // if (null==fId)
-    // fId = UUID.randomUUID().toString();
-    // }
-
     @Override
     public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
             List<String> requestedIds) {
@@ -224,67 +222,76 @@ public class DocumentVersionImpl extends
         // and set some properties specific to the version
         super.fillProperties(properties, objFactory, requestedIds);
 
-
         if (FilterParser.isContainedInFilter(PropertyIds.IS_IMMUTABLE, requestedIds)) {
-            properties.put(PropertyIds.IS_IMMUTABLE, objFactory.createPropertyBooleanData(PropertyIds.IS_IMMUTABLE,
-                    false));
+            properties.put(PropertyIds.IS_IMMUTABLE,
+                    objFactory.createPropertyBooleanData(PropertyIds.IS_IMMUTABLE, false));
         }
 
         // fill the version related properties
         if (FilterParser.isContainedInFilter(PropertyIds.IS_LATEST_VERSION, requestedIds)) {
-            properties.put(PropertyIds.IS_LATEST_VERSION, objFactory.createPropertyBooleanData(
-                    PropertyIds.IS_LATEST_VERSION, isLatestVersion()));
+            properties.put(PropertyIds.IS_LATEST_VERSION,
+                    objFactory.createPropertyBooleanData(PropertyIds.IS_LATEST_VERSION, isLatestVersion()));
         }
         if (FilterParser.isContainedInFilter(PropertyIds.IS_MAJOR_VERSION, requestedIds)) {
-            properties.put(PropertyIds.IS_MAJOR_VERSION, objFactory.createPropertyBooleanData(
-                    PropertyIds.IS_MAJOR_VERSION, fIsMajor));
+            properties.put(PropertyIds.IS_MAJOR_VERSION,
+                    objFactory.createPropertyBooleanData(PropertyIds.IS_MAJOR_VERSION, fIsMajor));
         }
         if (FilterParser.isContainedInFilter(PropertyIds.IS_LATEST_MAJOR_VERSION, requestedIds)) {
-            properties.put(PropertyIds.IS_LATEST_MAJOR_VERSION, objFactory.createPropertyBooleanData(
-                    PropertyIds.IS_LATEST_MAJOR_VERSION, isLatestMajorVersion()));
+            properties.put(PropertyIds.IS_LATEST_MAJOR_VERSION,
+                    objFactory.createPropertyBooleanData(PropertyIds.IS_LATEST_MAJOR_VERSION, isLatestMajorVersion()));
         }
         if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_ID, requestedIds)) {
-            properties.put(PropertyIds.VERSION_SERIES_ID, objFactory.createPropertyIdData(
-                    PropertyIds.VERSION_SERIES_ID, fContainer.getId()));
+            properties.put(PropertyIds.VERSION_SERIES_ID,
+                    objFactory.createPropertyIdData(PropertyIds.VERSION_SERIES_ID, fContainer.getId()));
         }
         if (FilterParser.isContainedInFilter(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
-            properties.put(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, objFactory.createPropertyBooleanData(
-                    PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, fContainer.isCheckedOut()));
+            properties.put(
+                    PropertyIds.IS_VERSION_SERIES_CHECKED_OUT,
+                    objFactory.createPropertyBooleanData(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT,
+                            fContainer.isCheckedOut()));
         }
         if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
-            properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, objFactory.createPropertyStringData(
-                    PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, fContainer.getCheckedOutBy()));
+            properties.put(
+                    PropertyIds.VERSION_SERIES_CHECKED_OUT_BY,
+                    objFactory.createPropertyStringData(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY,
+                            fContainer.getCheckedOutBy()));
         }
         if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
-            properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, objFactory.createPropertyIdData(
-                    PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
+            properties.put(
+                    PropertyIds.VERSION_SERIES_CHECKED_OUT_ID,
+                    objFactory.createPropertyIdData(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID,
+                            pwc == null ? null : pwc.getId()));
         }
         if (FilterParser.isContainedInFilter(PropertyIds.CHECKIN_COMMENT, requestedIds)) {
-            properties.put(PropertyIds.CHECKIN_COMMENT, objFactory.createPropertyStringData(
-                    PropertyIds.CHECKIN_COMMENT, fComment));
+            properties.put(PropertyIds.CHECKIN_COMMENT,
+                    objFactory.createPropertyStringData(PropertyIds.CHECKIN_COMMENT, fComment));
         }
         if (FilterParser.isContainedInFilter(PropertyIds.VERSION_LABEL, requestedIds)) {
-            properties.put(PropertyIds.VERSION_LABEL, objFactory.createPropertyStringData(PropertyIds.VERSION_LABEL,
-                    getVersionLabel()));
+            properties.put(PropertyIds.VERSION_LABEL,
+                    objFactory.createPropertyStringData(PropertyIds.VERSION_LABEL, getVersionLabel()));
         }
 
         // Set the content related properties
         if (null != fContent) {
             if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_FILE_NAME, requestedIds)) {
-                properties.put(PropertyIds.CONTENT_STREAM_FILE_NAME, objFactory.createPropertyStringData(
-                        PropertyIds.CONTENT_STREAM_FILE_NAME, fContent.getFileName()));
+                properties.put(
+                        PropertyIds.CONTENT_STREAM_FILE_NAME,
+                        objFactory.createPropertyStringData(PropertyIds.CONTENT_STREAM_FILE_NAME,
+                                fContent.getFileName()));
             }
             if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_ID, requestedIds)) {
-                properties.put(PropertyIds.CONTENT_STREAM_ID, objFactory.createPropertyStringData(
-                        PropertyIds.CONTENT_STREAM_ID, (String) null));
+                properties.put(PropertyIds.CONTENT_STREAM_ID,
+                        objFactory.createPropertyStringData(PropertyIds.CONTENT_STREAM_ID, (String) null));
             }
             if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_LENGTH, requestedIds)) {
                 properties.put(PropertyIds.CONTENT_STREAM_LENGTH, objFactory.createPropertyIntegerData(
                         PropertyIds.CONTENT_STREAM_LENGTH, fContent.getBigLength()));
             }
             if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_MIME_TYPE, requestedIds)) {
-                properties.put(PropertyIds.CONTENT_STREAM_MIME_TYPE, objFactory.createPropertyStringData(
-                        PropertyIds.CONTENT_STREAM_MIME_TYPE, fContent.getMimeType()));
+                properties.put(
+                        PropertyIds.CONTENT_STREAM_MIME_TYPE,
+                        objFactory.createPropertyStringData(PropertyIds.CONTENT_STREAM_MIME_TYPE,
+                                fContent.getMimeType()));
             }
         }
 
@@ -293,42 +300,41 @@ public class DocumentVersionImpl extends
             properties.put(PropertyIds.IS_PRIVATE_WORKING_COPY,
                     objFactory.createPropertyBooleanData(PropertyIds.IS_PRIVATE_WORKING_COPY, isPwc()));
         }
-        
-        
+
     }
 
     @Override
     public int getAclId() {
-        return ((StoredObjectImpl)fContainer).getAclId();
-    }    
+        return ((StoredObjectImpl) fContainer).getAclId();
+    }
 
     @Override
     public void setAclId(int id) {
-        ((StoredObjectImpl)fContainer).setAclId(id);
-    }    
-    
+        ((StoredObjectImpl) fContainer).setAclId(id);
+    }
+
     @Override
-	public List<String> getParentIds() {
+    public List<String> getParentIds() {
         return fContainer.getParentIds();
     }
 
     @Override
-	public String getPathSegment() {
+    public String getPathSegment() {
         return fContainer.getPathSegment();
     }
 
     @Override
-	public boolean hasContent() {
+    public boolean hasContent() {
         return null != fContent;
     }
 
     @Override
-	public boolean hasParent() {
-      return fContainer.hasParent();
+    public boolean hasParent() {
+        return fContainer.hasParent();
     }
 
     @Override
-	public String getVersionLabel() {
+    public String getVersionLabel() {
         return createVersionLabel();
     }
 
@@ -342,5 +348,4 @@ public class DocumentVersionImpl extends
         fContainer.removeParentId(parentId);
     }
 
-
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FilingImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FilingImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FilingImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FilingImpl.java Fri Aug 16 08:47:50 2013
@@ -25,9 +25,9 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.MultiFiling;
 
 public class FilingImpl extends StoredObjectImpl implements Fileable, MultiFiling {
-    
+
     private List<String> parentIds = new ArrayList<String>(1);
-    
+
     FilingImpl() {
         super();
     }
@@ -46,7 +46,7 @@ public class FilingImpl extends StoredOb
     public String getPathSegment() {
         return super.getName();
     }
-    
+
     @Override
     public void addParentId(String parentId) {
         parentIds.add(parentId);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java Fri Aug 16 08:47:50 2013
@@ -1,4 +1,5 @@
 package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
+
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,7 +21,6 @@ package org.apache.chemistry.opencmis.in
  *
  */
 
-
 import java.io.IOException;
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory;
 public class FolderImpl extends StoredObjectImpl implements Folder {
     private static final Logger LOG = LoggerFactory.getLogger(FilingImpl.class.getName());
     private String parentId;
-    
+
     public FolderImpl() {
         super();
     }
@@ -55,7 +55,6 @@ public class FolderImpl extends StoredOb
         init(name, parentId);
     }
 
-
     @Override
     public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
             List<String> requestedIds) {
@@ -65,33 +64,32 @@ public class FolderImpl extends StoredOb
         // add folder specific properties
 
         if (FilterParser.isContainedInFilter(PropertyIds.PARENT_ID, requestedIds)) {
-            properties.put(PropertyIds.PARENT_ID, objFactory.createPropertyIdData(PropertyIds.PARENT_ID,
-                    parentId));
+            properties.put(PropertyIds.PARENT_ID, objFactory.createPropertyIdData(PropertyIds.PARENT_ID, parentId));
         }
 
         if (FilterParser.isContainedInFilter(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, requestedIds)) {
             String allowedChildObjects = null; // TODO: not yet supported
-            properties.put(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, objFactory.createPropertyIdData(
-                    PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, allowedChildObjects));
+            properties.put(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS,
+                    objFactory.createPropertyIdData(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, allowedChildObjects));
         }
 
     }
 
     @Override
-	public List<String> getAllowedChildObjectTypeIds() {
+    public List<String> getAllowedChildObjectTypeIds() {
         // TODO implement this.
         return null;
     }
 
     @Override
-	public List<RenditionData> getRenditions(String renditionFilter, long maxItems, long skipCount) {
-        if (null==renditionFilter) {
+    public List<RenditionData> getRenditions(String renditionFilter, long maxItems, long skipCount) {
+        if (null == renditionFilter) {
             return null;
         }
         String tokenizer = "[\\s;]";
         String[] formats = renditionFilter.split(tokenizer);
         boolean isImageRendition = testRenditionFilterForImage(formats);
- 
+
         if (isImageRendition) {
             List<RenditionData> renditions = new ArrayList<RenditionData>(1);
             RenditionDataImpl rendition = new RenditionDataImpl();
@@ -112,7 +110,7 @@ public class FolderImpl extends StoredOb
     }
 
     @Override
-	public ContentStream getRenditionContent(String streamId, long offset, long length) {
+    public ContentStream getRenditionContent(String streamId, long offset, long length) {
         try {
             return getIconFromResourceDir("/folder.png");
         } catch (IOException e) {
@@ -122,7 +120,7 @@ public class FolderImpl extends StoredOb
     }
 
     @Override
-	public boolean hasRendition(String user) {
+    public boolean hasRendition(String user) {
         return true;
     }
 
@@ -151,17 +149,17 @@ public class FolderImpl extends StoredOb
     }
 
     @Override
-    public void setParentId (String parentId) {
+    public void setParentId(String parentId) {
         this.parentId = parentId;
     }
-    
+
     // Helper functions
     private void init(String name, String parentId) {
         if (!NameValidator.isValidName(name)) {
             throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
         }
         setName(name);
-        this.parentId = parentId;;
+        this.parentId = parentId;
     }
 
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ImageThumbnailGenerator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ImageThumbnailGenerator.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ImageThumbnailGenerator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ImageThumbnailGenerator.java Fri Aug 16 08:47:50 2013
@@ -36,6 +36,7 @@ import org.apache.chemistry.opencmis.com
 
 public class ImageThumbnailGenerator {
 
+    private static final int DEFAULT_LENGTH = 100;
     private static final String RENDITION_MIME_TYPE = "image/jpeg";;
     private InputStream image;
     private int thumbWidth;
@@ -93,7 +94,7 @@ public class ImageThumbnailGenerator {
         int longerSideLength = longerSideLengthParam;
         
         if (longerSideLength <= 0) {
-            longerSideLength = 100;
+            longerSideLength = DEFAULT_LENGTH;
         }
         
         if (bi.getWidth() > bi.getHeight()) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryAcl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryAcl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryAcl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryAcl.java Fri Aug 16 08:47:50 2013
@@ -27,18 +27,18 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
 
-public class InMemoryAcl implements Cloneable{
-    
+public class InMemoryAcl implements Cloneable {
+
     private List<InMemoryAce> acl;
     private int id;
+
     @SuppressWarnings("serial")
-    private static final InMemoryAcl DEFAULT_ACL = new InMemoryAcl(new ArrayList<InMemoryAce>() {{ add(InMemoryAce.getDefaultAce()); }} );
     private static class AceComparator<T extends InMemoryAce> implements Comparator<T> {
 
         @Override
-		public int compare(T o1, T o2) {
+        public int compare(T o1, T o2) {
             if (null == o1 || null == o2) {
-                if (o1 == o2) {
+                if (o1 == o2) { // NOSONAR
                     return 0;
                 } else if (o1 == null) {
                     return 1;
@@ -49,11 +49,15 @@ public class InMemoryAcl implements Clon
             int res = o1.getPrincipalId().compareTo(o2.getPrincipalId());
             return res;
         }
-        
     };
-    
+
     private static final Comparator<? super InMemoryAce> COMP = new AceComparator<InMemoryAce>();
-    
+    private static final InMemoryAcl DEFAULT_ACL = new InMemoryAcl(new ArrayList<InMemoryAce>() {
+        {
+            add(InMemoryAce.getDefaultAce());
+        }
+    });
+
     public static InMemoryAcl createFromCommonsAcl(Acl commonsAcl) {
         InMemoryAcl acl = new InMemoryAcl();
         for (Ace cace : commonsAcl.getAces()) {
@@ -66,7 +70,7 @@ public class InMemoryAcl implements Clon
             } else {
                 acl.addAce(new InMemoryAce(cace));
             }
-            
+
         }
         return acl;
     }
@@ -74,44 +78,44 @@ public class InMemoryAcl implements Clon
     public static InMemoryAcl getDefaultAcl() {
         return DEFAULT_ACL;
     }
-    
+
     public InMemoryAcl() {
         acl = new ArrayList<InMemoryAce>(3);
     }
 
-    public InMemoryAcl(final List<InMemoryAce> arg ) {        
+    public InMemoryAcl(final List<InMemoryAce> arg) {
         this.acl = new ArrayList<InMemoryAce>(arg);
         Collections.sort(this.acl, COMP);
-        for (int i=0 ; i<acl.size(); i++) {
+        for (int i = 0; i < acl.size(); i++) {
             InMemoryAce ace = acl.get(i);
             if (ace == null) {
                 throw new IllegalArgumentException("Cannot create ACLs with a null principal id or permission.");
-            }        
+            }
         }
-        for (int i=0 ; i<acl.size()-1; i++) {
-            if (acl.get(i).equals(acl.get(i+1))) {
+        for (int i = 0; i < acl.size() - 1; i++) {
+            if (acl.get(i).equals(acl.get(i + 1))) {
                 throw new IllegalArgumentException("Cannot create ACLs with same principal id in more than one ACE.");
             }
         }
     }
-    
+
     public void setId(int id) {
         this.id = id;
     }
-    
+
     public int getId() {
         return id;
     }
-    
+
     public final List<InMemoryAce> getAces() {
         return acl;
     }
-    
+
     public boolean addAce(InMemoryAce ace) {
         if (ace == null) {
             return false;
         }
-        for (InMemoryAce ace2: acl) {
+        for (InMemoryAce ace2 : acl) {
             if (ace2.getPrincipalId().equals(ace.getPrincipalId())) {
                 return false;
             }
@@ -120,17 +124,17 @@ public class InMemoryAcl implements Clon
         Collections.sort(acl, COMP);
         return true;
     }
-    
+
     public boolean removeAce(InMemoryAce ace) {
         return acl.remove(ace);
     }
-    
+
     public void mergeAcl(InMemoryAcl acl2) {
         if (acl2 == null) {
             return;
         }
-        for (InMemoryAce ace: acl2.getAces()) {
-            InMemoryAce existingAce  = getAce(ace.getPrincipalId());
+        for (InMemoryAce ace : acl2.getAces()) {
+            InMemoryAce existingAce = getAce(ace.getPrincipalId());
             if (existingAce == null) {
                 acl.add(ace);
             } else if (existingAce.getPermission().ordinal() < ace.getPermission().ordinal()) {
@@ -139,17 +143,17 @@ public class InMemoryAcl implements Clon
         }
         Collections.sort(this.acl, COMP);
     }
-    
+
     public Permission getPermission(String principalId) {
         InMemoryAce ace = getAce(principalId);
-        return ace== null ? Permission.NONE : ace.getPermission();
+        return ace == null ? Permission.NONE : ace.getPermission();
     }
 
     private InMemoryAce getAce(String principalId) {
         if (null == principalId) {
             return null;
         }
-        
+
         for (InMemoryAce ace : acl) {
             if (ace.getPrincipalId().equals(principalId)) {
                 return ace;
@@ -162,7 +166,7 @@ public class InMemoryAcl implements Clon
         if (null == permission) {
             return false;
         }
-        
+
         if (null == principalId) {
             for (InMemoryAce ace : acl) {
                 if (ace.getPrincipalId().equals(InMemoryAce.getAnonymousUser())) {
@@ -170,7 +174,7 @@ public class InMemoryAcl implements Clon
                 }
             }
         }
-       
+
         for (InMemoryAce ace : acl) {
             if (ace.getPrincipalId().equals(principalId) || ace.getPrincipalId().equals(InMemoryAce.getAnyoneUser())
                     || ace.getPrincipalId().equals(InMemoryAce.getAnonymousUser())) {
@@ -180,7 +184,7 @@ public class InMemoryAcl implements Clon
         return false;
     }
 
-    public void setPermission(String principalId, Permission permission) {        
+    public void setPermission(String principalId, Permission permission) {
         for (InMemoryAce ace : acl) {
             if (ace.getPrincipalId().equals(principalId)) {
                 ace.setPermission(permission);
@@ -188,11 +192,11 @@ public class InMemoryAcl implements Clon
         }
         throw new IllegalArgumentException("Unknown principalId in setPermission: " + principalId);
     }
-   
+
     public int size() {
         return acl.size();
     }
-     
+
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -227,9 +231,9 @@ public class InMemoryAcl implements Clon
     public String toString() {
         return "InMemoryAcl [acl=" + acl + "]";
     }
-            
+
     private boolean hasPrincipal(String principalId) {
-        for (InMemoryAce ace: acl) {
+        for (InMemoryAce ace : acl) {
             if (ace.getPrincipalId().equals(principalId)) {
                 return true;
             }
@@ -242,13 +246,13 @@ public class InMemoryAcl implements Clon
         for (InMemoryAce memAce : acl) {
             commonsAcl.add(memAce.toCommonsAce());
         }
-        
-        return new AccessControlListImpl(commonsAcl); 
+
+        return new AccessControlListImpl(commonsAcl);
     }
 
     @Override
-	public InMemoryAcl clone() throws CloneNotSupportedException {
+    public InMemoryAcl clone() throws CloneNotSupportedException {
         InMemoryAcl newAcl = new InMemoryAcl(acl);
-        return newAcl; 
+        return newAcl;
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java Fri Aug 16 08:47:50 2013
@@ -392,8 +392,7 @@ public class InMemoryServiceValidatorImp
             throw new CmisConstraintException("ACLs on policies are not suported.");
         }
 
-        StoredObject so = super
-                .createPolicy(context, repositoryId, folderId, addAces, removeAces, policyIds, extension);
+        StoredObject so = super.createPolicy(context, repositoryId, folderId, addAces, removeAces, policyIds, extension);
         checkAllAccess(repositoryId, context.getUsername(), so);
         return so;
     }
@@ -650,8 +649,6 @@ public class InMemoryServiceValidatorImp
             ExtensionsData extension, Holder<Boolean> contentCopied) {
 
         StoredObject so = super.checkOut(context, repositoryId, objectId, extension, contentCopied);
-        // StoredObject container = so instanceof DocumentVersion ?
-        // ((DocumentVersion)so).getParentDocument() : so;
         checkWriteAccess(repositoryId, context.getUsername(), so);
         return so;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java Fri Aug 16 08:47:50 2013
@@ -53,8 +53,6 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Relationship;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * The object store is the central core of the in-memory repository. It is based
@@ -88,7 +86,7 @@ import org.slf4j.LoggerFactory;
  */
 public class ObjectStoreImpl implements ObjectStore, ObjectStoreMultiFiling {
 
-    private static final Logger LOG = LoggerFactory.getLogger(ObjectStoreImpl.class);
+    private static final int FIRST_ID = 100;
 
     /**
      * user id for administrator always having all rights
@@ -98,7 +96,7 @@ public class ObjectStoreImpl implements 
     /**
      * Simple id generator that uses just an integer
      */
-    private static int nextUnusedId = 100;
+    private static int nextUnusedId = FIRST_ID;
 
     /**
      * a concurrent HashMap as core element to hold all objects in the
@@ -115,7 +113,7 @@ public class ObjectStoreImpl implements 
 
     private final Lock fLock = new ReentrantLock();
 
-    final String fRepositoryId;
+    private final String fRepositoryId;
     private FolderImpl fRootFolder = null;
 
     public ObjectStoreImpl(String repositoryId) {
@@ -252,7 +250,7 @@ public class ObjectStoreImpl implements 
     // /////////////////////////////////////////
     // private helper methods
 
-    private void createRootFolder() {
+    private final void createRootFolder() {
         FolderImpl rootFolder = new FolderImpl();
         rootFolder.setName("RootFolder");
         rootFolder.setParentId(null);
@@ -289,6 +287,7 @@ public class ObjectStoreImpl implements 
         }
         String id = storeObject(doc);
         doc.setId(id);
+        applyAcl(doc, addACEs, removeACEs);
         return doc;
     }
 
@@ -314,6 +313,7 @@ public class ObjectStoreImpl implements 
         item.setAclId(aclId);
         String id = storeObject(item);
         item.setId(id);
+        applyAcl(item, addACEs, removeACEs);
         return item;
     }
 
@@ -345,6 +345,7 @@ public class ObjectStoreImpl implements 
         }
         id = storeObject(version);
         version.setId(id);
+        applyAcl(doc, addACEs, removeACEs);
         return version;
     }
 
@@ -352,7 +353,9 @@ public class ObjectStoreImpl implements 
     public Folder createFolder(String name, Map<String, PropertyData<?>> propMap, String user, Folder parent,
             List<String> policies, Acl addACEs, Acl removeACEs) {
 
-        if (null != parent && hasChild(parent, name)) {
+        if (null == parent) {
+            throw new CmisInvalidArgumentException("Cannot create root folder.");            
+        } else if (hasChild(parent, name)) {
             throw new CmisNameConstraintViolationException("Cannot create folder, this name already exists in parent folder.");
         }
         FolderImpl folder = new FolderImpl(name, parent.getId());
@@ -370,6 +373,7 @@ public class ObjectStoreImpl implements 
 
         String id = storeObject(folder);
         folder.setId(id);
+        applyAcl(folder, addACEs, removeACEs);
         return folder;
     }
 
@@ -380,7 +384,7 @@ public class ObjectStoreImpl implements 
     }
 
     @Override
-    public StoredObject createPolicy(String name, String policyText, Map<String, PropertyData<?>> propMap, String user) {
+    public StoredObject createPolicy(String name, String policyText, Map<String, PropertyData<?>> propMap, String user, Acl addACEs, Acl removeACEs) {
         PolicyImpl policy = new PolicyImpl();
         policy.createSystemBasePropertiesWhenCreated(propMap, user);
         policy.setCustomProperties(propMap);
@@ -389,6 +393,7 @@ public class ObjectStoreImpl implements 
         policy.setPolicyText(policyText);
         String id = storeObject(policy);
         policy.setId(id);
+        applyAcl(policy, addACEs, removeACEs);
         return policy;
     }
 
@@ -407,10 +412,9 @@ public class ObjectStoreImpl implements 
         if (null != targetObject) {
             rel.setTarget(targetObject.getId());
         }
-        int aclId = getAclId(null, addACEs, removeACEs);
-        rel.setAclId(aclId);
         String id = storeObject(rel);
         rel.setId(id);
+        applyAcl(rel, addACEs, removeACEs);
         return rel;
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/PolicyImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/PolicyImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/PolicyImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/PolicyImpl.java Fri Aug 16 08:47:50 2013
@@ -34,28 +34,27 @@ public class PolicyImpl extends StoredOb
     }
 
     private String policyText;
-    
 
     public void setPolicyText(String text) {
         policyText = text;
     }
-    
+
     @Override
-	public String getPolicyText() {
+    public String getPolicyText() {
         return policyText;
     }
-    
+
     @Override
     public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
             List<String> requestedIds) {
 
-       super.fillProperties(properties, objFactory, requestedIds);
-        
+        super.fillProperties(properties, objFactory, requestedIds);
+
         if (FilterParser.isContainedInFilter(PropertyIds.POLICY_TEXT, requestedIds)) {
-            properties.put(PropertyIds.POLICY_TEXT, objFactory.createPropertyStringData(
-                    PropertyIds.POLICY_TEXT, policyText) );
+            properties.put(PropertyIds.POLICY_TEXT,
+                    objFactory.createPropertyStringData(PropertyIds.POLICY_TEXT, policyText));
         }
-        
+
     }
 
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/RelationshipImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/RelationshipImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/RelationshipImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/RelationshipImpl.java Fri Aug 16 08:47:50 2013
@@ -28,7 +28,7 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Relationship;
 
 public class RelationshipImpl extends StoredObjectImpl implements Relationship {
-    
+
     private String sourceObjId;
     private String targetObjId;
 
@@ -37,7 +37,7 @@ public class RelationshipImpl extends St
     }
 
     @Override
-	public String getSourceObjectId() {
+    public String getSourceObjectId() {
         return sourceObjId;
     }
 
@@ -46,7 +46,7 @@ public class RelationshipImpl extends St
     }
 
     @Override
-	public String getTargetObjectId() {
+    public String getTargetObjectId() {
         return targetObjId;
     }
 
@@ -58,21 +58,18 @@ public class RelationshipImpl extends St
     public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
             List<String> requestedIds) {
 
-       super.fillProperties(properties, objFactory, requestedIds);
-        
+        super.fillProperties(properties, objFactory, requestedIds);
+
         if (FilterParser.isContainedInFilter(PropertyIds.SOURCE_ID, requestedIds)) {
-            properties.put(PropertyIds.SOURCE_ID, objFactory.createPropertyStringData(
-                    PropertyIds.SOURCE_ID, sourceObjId) );
+            properties.put(PropertyIds.SOURCE_ID,
+                    objFactory.createPropertyStringData(PropertyIds.SOURCE_ID, sourceObjId));
         }
-        
+
         if (FilterParser.isContainedInFilter(PropertyIds.TARGET_ID, requestedIds)) {
-            properties.put(PropertyIds.TARGET_ID, objFactory.createPropertyStringData(
-                    PropertyIds.TARGET_ID, targetObjId));
+            properties.put(PropertyIds.TARGET_ID,
+                    objFactory.createPropertyStringData(PropertyIds.TARGET_ID, targetObjId));
         }
-        
-    }
 
-    
-    
+    }
 
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java Fri Aug 16 08:47:50 2013
@@ -86,7 +86,7 @@ public class StoreManagerImpl implements
     private static final String CMIS_ALL = "cmis:all";
 
     private final BindingsObjectFactory fObjectFactory;
-    
+
     private static final String OPENCMIS_VERSION;
     private static final String OPENCMIS_SERVER;
 
@@ -121,7 +121,7 @@ public class StoreManagerImpl implements
     }
 
     @Override
-	public List<String> getAllRepositoryIds() {
+    public List<String> getAllRepositoryIds() {
         Set<String> repIds = fMapRepositoryToObjectStore.keySet();
         List<String> result = new ArrayList<String>();
         result.addAll(repIds);
@@ -129,16 +129,17 @@ public class StoreManagerImpl implements
     }
 
     @Override
-	public void initRepository(String repositoryId) {
+    public void initRepository(String repositoryId) {
         fMapRepositoryToObjectStore.put(repositoryId, new ObjectStoreImpl(repositoryId));
         fMapRepositoryToTypeManager.put(repositoryId, new TypeManagerImpl());
     }
 
     @Override
-	public void createAndInitRepository(String repositoryId, String typeCreatorClassName) {
+    public void createAndInitRepository(String repositoryId, String typeCreatorClassName) {
         if (fMapRepositoryToObjectStore.containsKey(repositoryId)
                 || fMapRepositoryToTypeManager.containsKey(repositoryId)) {
-            throw new CmisInvalidArgumentException("Cannot add repository, repository " + repositoryId + " already exists.");
+            throw new CmisInvalidArgumentException("Cannot add repository, repository " + repositoryId
+                    + " already exists.");
         }
 
         fMapRepositoryToObjectStore.put(repositoryId, new ObjectStoreImpl(repositoryId));
@@ -149,22 +150,22 @@ public class StoreManagerImpl implements
     }
 
     @Override
-	public ObjectStore getObjectStore(String repositoryId) {
+    public ObjectStore getObjectStore(String repositoryId) {
         return fMapRepositoryToObjectStore.get(repositoryId);
     }
 
     @Override
-	public CmisServiceValidator getServiceValidator() {
+    public CmisServiceValidator getServiceValidator() {
         return new InMemoryServiceValidatorImpl(this);
     }
 
     @Override
-	public BindingsObjectFactory getObjectFactory() {
+    public BindingsObjectFactory getObjectFactory() {
         return fObjectFactory;
     }
 
     @Override
-	public TypeDefinitionContainer getTypeById(String repositoryId, String typeId) {
+    public TypeDefinitionContainer getTypeById(String repositoryId, String typeId) {
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
         if (null == typeManager) {
             throw new CmisObjectNotFoundException(UNKNOWN_REPOSITORY + repositoryId);
@@ -184,7 +185,7 @@ public class StoreManagerImpl implements
     }
 
     @Override
-	public TypeDefinitionContainer getTypeById(String repositoryId, String typeId, boolean includePropertyDefinitions,
+    public TypeDefinitionContainer getTypeById(String repositoryId, String typeId, boolean includePropertyDefinitions,
             int depthParam) {
         int depth = depthParam;
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
@@ -212,7 +213,7 @@ public class StoreManagerImpl implements
     }
 
     @Override
-	public Collection<TypeDefinitionContainer> getTypeDefinitionList(String repositoryId,
+    public Collection<TypeDefinitionContainer> getTypeDefinitionList(String repositoryId,
             boolean includePropertyDefinitions) {
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
         if (null == typeManager) {
@@ -223,20 +224,20 @@ public class StoreManagerImpl implements
     }
 
     @Override
-	public List<TypeDefinitionContainer> getRootTypes(String repositoryId, boolean includePropertyDefinitions) {
+    public List<TypeDefinitionContainer> getRootTypes(String repositoryId, boolean includePropertyDefinitions) {
         List<TypeDefinitionContainer> result;
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
         if (null == typeManager) {
             throw new CmisInvalidArgumentException(UNKNOWN_REPOSITORY + repositoryId);
         }
         List<TypeDefinitionContainer> rootTypes = typeManager.getRootTypes();
-        
+
         // remove cmis:item and cmis:secondary for CMIS 1.0
         boolean cmis11 = InMemoryServiceContext.getCallContext().getCmisVersion() != CmisVersion.CMIS_1_0;
         if (!cmis11) {
             rootTypes = new ArrayList<TypeDefinitionContainer>(rootTypes);
             TypeDefinitionContainer tcItem = null, tcSecondary = null;
-            for(TypeDefinitionContainer tc : rootTypes) {
+            for (TypeDefinitionContainer tc : rootTypes) {
                 if (tc.getTypeDefinition().getId().equals(BaseTypeId.CMIS_ITEM.value())) {
                     tcItem = tc;
                 }
@@ -251,7 +252,7 @@ public class StoreManagerImpl implements
                 rootTypes.remove(tcSecondary);
             }
         }
-        
+
         if (includePropertyDefinitions) {
             result = rootTypes;
         } else {
@@ -269,7 +270,7 @@ public class StoreManagerImpl implements
     }
 
     @Override
-	public RepositoryInfo getRepositoryInfo(String repositoryId) {
+    public RepositoryInfo getRepositoryInfo(String repositoryId) {
         ObjectStore sm = fMapRepositoryToObjectStore.get(repositoryId);
         if (null == sm) {
             return null;
@@ -296,23 +297,21 @@ public class StoreManagerImpl implements
             Object obj = null;
             TypeCreator typeCreator = null;
 
+            final String message = "Illegal class to create type system, must implement TypeCreator interface.";
             try {
                 obj = Class.forName(typeCreatorClassName).newInstance();
             } catch (InstantiationException e) {
-                throw new CmisRuntimeException(
-                        "Illegal class to create type system, must implement TypeCreator interface.", e);
+                throw new CmisRuntimeException(message, e);
             } catch (IllegalAccessException e) {
-                throw new CmisRuntimeException(
-                        "Illegal class to create type system, must implement TypeCreator interface.", e);
+                throw new CmisRuntimeException(message, e);
             } catch (ClassNotFoundException e) {
-                throw new CmisRuntimeException(
-                        "Illegal class to create type system, must implement TypeCreator interface.", e);
+                throw new CmisRuntimeException(message, e);
             }
 
             if (obj instanceof TypeCreator) {
                 typeCreator = (TypeCreator) obj;
             } else {
-                throw new CmisRuntimeException("Illegal class to create type system, must implement TypeCreator interface.");
+                throw new CmisRuntimeException(message);
             }
 
             // retrieve the list of available types from the configured class.
@@ -427,21 +426,16 @@ public class StoreManagerImpl implements
         list.add(createMapping(PermissionMapping.CAN_SET_CONTENT_DOCUMENT, CMIS_WRITE));
         list.add(createMapping(PermissionMapping.CAN_DELETE_CONTENT_DOCUMENT, CMIS_WRITE));
         list.add(createMapping(PermissionMapping.CAN_ADD_TO_FOLDER_OBJECT, CMIS_WRITE));
-        ;
-        list.add(createMapping(PermissionMapping.CAN_ADD_TO_FOLDER_FOLDER, CMIS_WRITE));
         list.add(createMapping(PermissionMapping.CAN_REMOVE_FROM_FOLDER_OBJECT, CMIS_WRITE));
-        list.add(createMapping(PermissionMapping.CAN_REMOVE_FROM_FOLDER_FOLDER, CMIS_WRITE));
         list.add(createMapping(PermissionMapping.CAN_CHECKOUT_DOCUMENT, CMIS_WRITE));
         list.add(createMapping(PermissionMapping.CAN_CANCEL_CHECKOUT_DOCUMENT, CMIS_WRITE));
-        ;
+
         list.add(createMapping(PermissionMapping.CAN_CHECKIN_DOCUMENT, CMIS_WRITE));
         list.add(createMapping(PermissionMapping.CAN_GET_ALL_VERSIONS_VERSION_SERIES, CMIS_READ));
         list.add(createMapping(PermissionMapping.CAN_GET_OBJECT_RELATIONSHIPS_OBJECT, CMIS_READ));
         list.add(createMapping(PermissionMapping.CAN_ADD_POLICY_OBJECT, CMIS_WRITE));
-        list.add(createMapping(PermissionMapping.CAN_ADD_POLICY_POLICY, CMIS_WRITE));
         list.add(createMapping(PermissionMapping.CAN_REMOVE_POLICY_OBJECT, CMIS_WRITE));
-        list.add(createMapping(PermissionMapping.CAN_REMOVE_POLICY_POLICY, CMIS_WRITE));
-        ;
+
         list.add(createMapping(PermissionMapping.CAN_GET_APPLIED_POLICIES_OBJECT, CMIS_READ));
         list.add(createMapping(PermissionMapping.CAN_GET_ACL_OBJECT, CMIS_READ));
         list.add(createMapping(PermissionMapping.CAN_APPLY_ACL_OBJECT, CMIS_ALL));
@@ -450,28 +444,32 @@ public class StoreManagerImpl implements
         for (PermissionMapping pm : list) {
             map.put(pm.getKey(), pm);
         }
-        
+
         List<BaseTypeId> changesOnType;
         // CMIS 1.1 extensions
         if (cmis11) {
             repoInfo.setCmisVersionSupported(CmisVersion.CMIS_1_1.value());
             repoInfo.setCmisVersion(CmisVersion.CMIS_1_1);
-            changesOnType = new ArrayList<BaseTypeId>() {{
-                add(BaseTypeId.CMIS_DOCUMENT);
-                add(BaseTypeId.CMIS_FOLDER);
-                add(BaseTypeId.CMIS_ITEM);
-            }};
-            
-            Set<PropertyType> propertyTypeSet = new HashSet<PropertyType>() {{
-                add(PropertyType.BOOLEAN);
-                add(PropertyType.DATETIME);
-                add(PropertyType.DECIMAL);
-                add(PropertyType.HTML);
-                add(PropertyType.ID);
-                add(PropertyType.INTEGER);
-                add(PropertyType.STRING);
-                add(PropertyType.URI);
-            }};
+            changesOnType = new ArrayList<BaseTypeId>() {
+                {
+                    add(BaseTypeId.CMIS_DOCUMENT);
+                    add(BaseTypeId.CMIS_FOLDER);
+                    add(BaseTypeId.CMIS_ITEM);
+                }
+            };
+
+            Set<PropertyType> propertyTypeSet = new HashSet<PropertyType>() {
+                {
+                    add(PropertyType.BOOLEAN);
+                    add(PropertyType.DATETIME);
+                    add(PropertyType.DECIMAL);
+                    add(PropertyType.HTML);
+                    add(PropertyType.ID);
+                    add(PropertyType.INTEGER);
+                    add(PropertyType.STRING);
+                    add(PropertyType.URI);
+                }
+            };
             CreatablePropertyTypesImpl creatablePropertyTypes = new CreatablePropertyTypesImpl();
             creatablePropertyTypes.setCanCreate(propertyTypeSet);
             caps.setCreatablePropertyTypes(creatablePropertyTypes);
@@ -479,10 +477,12 @@ public class StoreManagerImpl implements
         } else {
             repoInfo.setCmisVersionSupported(CmisVersion.CMIS_1_0.value());
             repoInfo.setCmisVersion(CmisVersion.CMIS_1_0);
-            changesOnType = new ArrayList<BaseTypeId>() {{
-                add(BaseTypeId.CMIS_DOCUMENT);
-                add(BaseTypeId.CMIS_FOLDER);
-            }};
+            changesOnType = new ArrayList<BaseTypeId>() {
+                {
+                    add(BaseTypeId.CMIS_DOCUMENT);
+                    add(BaseTypeId.CMIS_FOLDER);
+                }
+            };
         }
         repoInfo.setChangesOnType(changesOnType);
 
@@ -548,25 +548,23 @@ public class StoreManagerImpl implements
     }
 
     @Override
-	public TypeManagerCreatable getTypeManager(String repositoryId) {
+    public TypeManagerCreatable getTypeManager(String repositoryId) {
         TypeManagerCreatable typeManager = fMapRepositoryToTypeManager.get(repositoryId);
         return typeManager;
     }
 
     @Override
-    public
-	boolean supportsSingleFiling(String repositoryId) {
-    	return false;
+    public boolean supportsSingleFiling(String repositoryId) {
+        return false;
     }
-    
+
     @Override
-    public
-	boolean supportsMultiFilings(String repositoryId) {
-    	return true;
+    public boolean supportsMultiFilings(String repositoryId) {
+        return true;
     }
-    
+
     @Override
-	public ObjectList query(String user, String repositoryId, String statement, Boolean searchAllVersions,
+    public ObjectList query(String user, String repositoryId, String statement, Boolean searchAllVersions,
             Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
             BigInteger maxItems, BigInteger skipCount) {
         TypeManager tm = getTypeManager(repositoryId);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java Fri Aug 16 08:47:50 2013
@@ -50,6 +50,7 @@ import org.apache.chemistry.opencmis.inm
  */
 public class StoredObjectImpl implements StoredObject {
 
+    private static final int BUFFER_SIZE = 65536;
     private static final String UNKNOWN_USER = "unknown";
     public static final String RENDITION_MIME_TYPE_JPEG = "image/jpeg";
     public static final String RENDITION_MIME_TYPE_PNG = "image/png";
@@ -524,13 +525,16 @@ public class StoredObjectImpl implements
         content.setMimeType("image/png");
 
         ByteArrayOutputStream ba = new ByteArrayOutputStream();
-        byte[] buffer = new byte[65536];
+        byte[] buffer = new byte[BUFFER_SIZE];
         int noBytesRead = 0;
-
-        while ((noBytesRead = imageStream.read(buffer)) >= 0) {
-            ba.write(buffer, 0, noBytesRead);
+        try {
+            while ((noBytesRead = imageStream.read(buffer)) >= 0) {
+                ba.write(buffer, 0, noBytesRead);
+            }
+        } finally {
+            ba.close();
+            imageStream.close();
         }
-
         content.setContent(new ByteArrayInputStream(ba.toByteArray()));
         return content;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java Fri Aug 16 08:47:50 2013
@@ -47,7 +47,7 @@ public class VersionedDocumentImpl exten
     }
 
     @Override
-	public DocumentVersion addVersion(ContentStream content, VersioningState verState, String user) {
+    public DocumentVersion addVersion(ContentStream content, VersioningState verState, String user) {
 
         if (isCheckedOut()) {
             throw new CmisConstraintException("Cannot add a version to document, document is checked out.");
@@ -66,13 +66,13 @@ public class VersionedDocumentImpl exten
     }
 
     @Override
-	public boolean deleteVersion(DocumentVersion version) {
+    public boolean deleteVersion(DocumentVersion version) {
         if (fIsCheckedOut) {
             // Note: Do not throw an exception here if the document is
             // checked-out. In AtomPub binding cancelCheckout
             // mapped to a deleteVersion() call!
             DocumentVersion pwc = getPwc();
-            if (pwc == version) { //NOSONAR
+            if (pwc == version) { // NOSONAR
                 cancelCheckOut(false); // note object is already deleted from
                                        // map in ObjectStore
                 return !fVersions.isEmpty();
@@ -87,12 +87,12 @@ public class VersionedDocumentImpl exten
     }
 
     @Override
-	public void cancelCheckOut(String user) {
+    public void cancelCheckOut(String user) {
         cancelCheckOut(true);
     }
 
     @Override
-	public void checkIn(boolean isMajor, Properties properties, ContentStream content, String checkinComment,
+    public void checkIn(boolean isMajor, Properties properties, ContentStream content, String checkinComment,
             List<String> policyIds, String user) {
         if (fIsCheckedOut) {
             if (fCheckedOutUser.equals(user)) {
@@ -119,13 +119,13 @@ public class VersionedDocumentImpl exten
 
         pwc.setCheckinComment(checkinComment);
         pwc.commit(isMajor);
-        if (policyIds != null && policyIds.size() > 0 ) {
+        if (policyIds != null && policyIds.size() > 0) {
             ((DocumentVersionImpl) pwc).setAppliedPolicies(policyIds);
         }
     }
 
     @Override
-	public DocumentVersion checkOut(ContentStream content, String user) {
+    public DocumentVersion checkOut(ContentStream content, String user) {
         if (fIsCheckedOut) {
             throw new CmisConstraintException("Error: Can't checkout, Document " + getId() + " is already checked out.");
         }
@@ -137,12 +137,12 @@ public class VersionedDocumentImpl exten
     }
 
     @Override
-	public List<DocumentVersion> getAllVersions() {
+    public List<DocumentVersion> getAllVersions() {
         return fVersions;
     }
 
     @Override
-	public DocumentVersion getLatestVersion(boolean major) {
+    public DocumentVersion getLatestVersion(boolean major) {
 
         DocumentVersion latest = null;
         if (fVersions.size() == 0) {
@@ -156,13 +156,13 @@ public class VersionedDocumentImpl exten
                 }
             }
         } else {
-        	if (null == getPwc()) {
-        		latest = fVersions.get(fVersions.size() - 1);
-        	} else if (fVersions.size() > 1) {
-        		latest = fVersions.get(fVersions.size() - 2);
-        	} else {
-        		latest = null;
-        	}
+            if (null == getPwc()) {
+                latest = fVersions.get(fVersions.size() - 1);
+            } else if (fVersions.size() > 1) {
+                latest = fVersions.get(fVersions.size() - 2);
+            } else {
+                latest = null;
+            }
             if (null == getPwc()) {
                 latest = fVersions.get(fVersions.size() - 1);
             } else if (fVersions.size() > 1) {
@@ -175,17 +175,17 @@ public class VersionedDocumentImpl exten
     }
 
     @Override
-	public boolean isCheckedOut() {
+    public boolean isCheckedOut() {
         return fIsCheckedOut;
     }
 
     @Override
-	public String getCheckedOutBy() {
+    public String getCheckedOutBy() {
         return fCheckedOutUser;
     }
 
     @Override
-	public DocumentVersion getPwc() {
+    public DocumentVersion getPwc() {
         for (DocumentVersion ver : fVersions) {
             if (ver.isPwc()) {
                 return ver;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java Fri Aug 16 08:47:50 2013
@@ -62,7 +62,7 @@ public class DefaultTypeSystemCreator im
      * the required types for testing
      */
     @Override
-	public List<TypeDefinition> createTypesList() {
+    public List<TypeDefinition> createTypesList() {
         return SINGLETON_TYPES;
     }
 
@@ -86,107 +86,110 @@ public class DefaultTypeSystemCreator im
      */
     private static List<TypeDefinition> buildTypesList() {
         // always add CMIS default types
-        TypeDefinitionFactory typeFactory =  DocumentTypeCreationHelper.getTypeDefinitionFactory();
+        TypeDefinitionFactory typeFactory = DocumentTypeCreationHelper.getTypeDefinitionFactory();
 
         List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
 
-        MutableDocumentTypeDefinition cmisType1;        
+        MutableDocumentTypeDefinition cmisType1;
         try {
-            cmisType1 = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            cmisType1 = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+                    .getCmisDocumentType().getId());
             cmisType1.setId("MyDocType1");
             cmisType1.setDisplayName("My Type 1 Level 1");
             cmisType1.setDescription("Builtin InMemory type definition MyDocType1");
             typesList.add(cmisType1);
 
-            MutableDocumentTypeDefinition cmisType2;        
-            cmisType2 = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            MutableDocumentTypeDefinition cmisType2;
+            cmisType2 = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+                    .getCmisDocumentType().getId());
             cmisType2.setId("MyDocType2");
             cmisType2.setDisplayName("My Type 2 Level 1");
             cmisType2.setDescription("Builtin InMemory type definition MyDocType2");
             typesList.add(cmisType2);
 
-            MutableTypeDefinition cmisType11;        
+            MutableTypeDefinition cmisType11;
             cmisType11 = typeFactory.createChildTypeDefinition(cmisType1, "MyDocType1.1");
             cmisType11.setDisplayName("My Type 3 Level 2");
             cmisType11.setDescription("Builtin InMemory type definition MyDocType1.1");
             typesList.add(cmisType11);
 
-            MutableTypeDefinition cmisType111;        
+            MutableTypeDefinition cmisType111;
             cmisType111 = typeFactory.createChildTypeDefinition(cmisType11, "MyDocType1.1.1");
             cmisType111.setDisplayName("My Type 4 Level 3");
             cmisType111.setDescription("Builtin InMemory type definition MyDocType1.1.1");
             typesList.add(cmisType111);
 
-            MutableTypeDefinition cmisType112;        
+            MutableTypeDefinition cmisType112;
             cmisType112 = typeFactory.createChildTypeDefinition(cmisType11, "MyDocType1.1.2");
             cmisType112.setId("MyDocType1.1.2");
             cmisType112.setDisplayName("My Type 5 Level 3");
             cmisType112.setDescription("Builtin InMemory type definition MyDocType1.1.2");
             typesList.add(cmisType112);
 
-            MutableTypeDefinition cmisType12;        
+            MutableTypeDefinition cmisType12;
             cmisType12 = typeFactory.createChildTypeDefinition(cmisType1, "MyDocType1.2");
             cmisType12.setDisplayName("My Type 6 Level 2");
             cmisType12.setDescription("Builtin InMemory type definition MyDocType1.2");
             typesList.add(cmisType12);
 
-            MutableTypeDefinition cmisType21;        
+            MutableTypeDefinition cmisType21;
             cmisType21 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.1");
             cmisType21.setDisplayName("My Type 7 Level 2");
             cmisType21.setDescription("Builtin InMemory type definition MyDocType2.1");
             typesList.add(cmisType21);
 
-            MutableTypeDefinition cmisType22;        
+            MutableTypeDefinition cmisType22;
             cmisType22 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.2");
             cmisType22.setDisplayName("My Type 8 Level 2");
             cmisType22.setDescription("Builtin InMemory type definition MyDocType2.2");
             typesList.add(cmisType22);
 
-            MutableTypeDefinition cmisType23;        
+            MutableTypeDefinition cmisType23;
             cmisType23 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.3");
             cmisType23.setDisplayName("My Type 9 Level 2");
             cmisType23.setDescription("Builtin InMemory type definition MyDocType2.3");
             typesList.add(cmisType23);
 
-            MutableTypeDefinition cmisType24;        
+            MutableTypeDefinition cmisType24;
             cmisType24 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.4");
             cmisType24.setDisplayName("My Type 10 Level 2");
             cmisType24.setDescription("Builtin InMemory type definition MyDocType2.4");
             typesList.add(cmisType24);
 
-            MutableTypeDefinition cmisType25;        
+            MutableTypeDefinition cmisType25;
             cmisType25 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.5");
             cmisType25.setDisplayName("My Type 11 Level 2");
             cmisType25.setDescription("Builtin InMemory type definition MyDocType2.5");
             typesList.add(cmisType25);
 
-            MutableTypeDefinition cmisType26;        
+            MutableTypeDefinition cmisType26;
             cmisType26 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.6");
             cmisType26.setDisplayName("My Type 12 Level 2");
             cmisType26.setDescription("Builtin InMemory type definition MyDocType2.6");
             typesList.add(cmisType26);
 
-            MutableTypeDefinition cmisType27;        
+            MutableTypeDefinition cmisType27;
             cmisType27 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.7");
             cmisType27.setDisplayName("My Type 13 Level 2");
             cmisType27.setDescription("Builtin InMemory type definition MyDocType2.7");
             typesList.add(cmisType27);
 
-            MutableTypeDefinition cmisType28;        
+            MutableTypeDefinition cmisType28;
             cmisType28 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.8");
             cmisType28.setDisplayName("My Type 14 Level 2");
             cmisType28.setDescription("Builtin InMemory type definition MyDocType2.8");
             typesList.add(cmisType28);
 
-            MutableTypeDefinition cmisType29;        
+            MutableTypeDefinition cmisType29;
             cmisType29 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.9");
             cmisType29.setDisplayName("My Type 15 Level 2");
             cmisType29.setDescription("Builtin InMemory type definition MyDocType2.9");
             typesList.add(cmisType29);
 
             // create a complex type with properties
-            MutableDocumentTypeDefinition cmisComplexType;        
-            cmisComplexType = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            MutableDocumentTypeDefinition cmisComplexType;
+            cmisComplexType = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+                    .getCmisDocumentType().getId());
             cmisComplexType.setId(COMPLEX_TYPE);
             cmisComplexType.setDisplayName("Complex type with properties, Level 1");
             cmisComplexType.setDescription("Builtin InMemory type definition ComplexType");
@@ -243,8 +246,8 @@ public class DefaultTypeSystemCreator im
                     "Sample String Property", Updatability.READWRITE);
             cmisComplexType.addPropertyDefinition(prop7);
 
-            PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp", "Sample Uri Property",
-                    Updatability.READWRITE);
+            PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp",
+                    "Sample Uri Property", Updatability.READWRITE);
             cmisComplexType.addPropertyDefinition(prop8);
 
             prop8 = PropertyCreationHelper.createUriMultiDefinition("UriPropMV", "Sample Uri multi-value Property",
@@ -274,18 +277,19 @@ public class DefaultTypeSystemCreator im
             typesList.add(cmisComplexType);
 
             // create a type hierarchy with inherited properties
-            MutableDocumentTypeDefinition cmisDocTypeTopLevel;        
-            cmisDocTypeTopLevel = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            MutableDocumentTypeDefinition cmisDocTypeTopLevel;
+            cmisDocTypeTopLevel = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1,
+                    DocumentTypeCreationHelper.getCmisDocumentType().getId());
             cmisDocTypeTopLevel.setId(TOPLEVEL_TYPE);
             cmisDocTypeTopLevel.setDisplayName("Document type with properties, Level 1");
             cmisDocTypeTopLevel.setDescription(BUILTIN_IN_MEMORY_TYPE_DEFINITION_DESCR + TOPLEVEL_TYPE);
 
-            MutableTypeDefinition cmisDocTypeLevel1;        
+            MutableTypeDefinition cmisDocTypeLevel1;
             cmisDocTypeLevel1 = typeFactory.createChildTypeDefinition(cmisDocTypeTopLevel, LEVEL1_TYPE);
             cmisDocTypeLevel1.setDisplayName("Document type with inherited properties, Level 2");
-            cmisDocTypeLevel1 .setDescription(BUILTIN_IN_MEMORY_TYPE_DEFINITION_DESCR + LEVEL1_TYPE);
+            cmisDocTypeLevel1.setDescription(BUILTIN_IN_MEMORY_TYPE_DEFINITION_DESCR + LEVEL1_TYPE);
 
-            MutableTypeDefinition cmisDocTypeLevel2;        
+            MutableTypeDefinition cmisDocTypeLevel2;
             cmisDocTypeLevel2 = typeFactory.createChildTypeDefinition(cmisDocTypeLevel1, LEVEL2_TYPE);
             cmisDocTypeLevel2.setDisplayName("Document type with inherited properties, Level 3");
             cmisDocTypeLevel2.setDescription(BUILTIN_IN_MEMORY_TYPE_DEFINITION_DESCR + LEVEL2_TYPE);
@@ -308,12 +312,14 @@ public class DefaultTypeSystemCreator im
             typesList.add(cmisDocTypeLevel2);
 
             // Create a type that is versionable
-            MutableDocumentTypeDefinition cmisVersionedType;        
-            cmisVersionedType = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            MutableDocumentTypeDefinition cmisVersionedType;
+            cmisVersionedType = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1,
+                    DocumentTypeCreationHelper.getCmisDocumentType().getId());
             cmisVersionedType.setId(VERSIONED_TYPE);
             cmisVersionedType.setDisplayName("Versioned Type");
             cmisVersionedType.setDescription(BUILTIN_IN_MEMORY_TYPE_DEFINITION_DESCR + VERSIONED_TYPE);
-            cmisVersionedType.setIsVersionable(true); // make it a versionable type
+            cmisVersionedType.setIsVersionable(true); // make it a versionable
+                                                      // type
 
             // create a single String property definition
             PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition("VersionedStringProp",
@@ -325,8 +331,9 @@ public class DefaultTypeSystemCreator im
 
             // CMIS 1.1 create an item item type
 
-            MutableItemTypeDefinition itemType;        
-            itemType = typeFactory.createItemTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisItemType().getId());
+            MutableItemTypeDefinition itemType;
+            itemType = typeFactory.createItemTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+                    .getCmisItemType().getId());
             itemType.setId(ITEM_TYPE);
             itemType.setDisplayName("MyItemType");
             itemType.setDescription(BUILTIN_IN_MEMORY_TYPE_DEFINITION_DESCR + ITEM_TYPE);
@@ -334,35 +341,36 @@ public class DefaultTypeSystemCreator im
 
             // create a single String property definition
 
-            prop1 = PropertyCreationHelper.createStringDefinition("ItemStringProp",
-                    "Item String Property", Updatability.READWRITE);
+            prop1 = PropertyCreationHelper.createStringDefinition("ItemStringProp", "Item String Property",
+                    Updatability.READWRITE);
             itemType.addPropertyDefinition(prop1);
             // add type to types collection
             typesList.add(itemType);
 
-
-            MutableSecondaryTypeDefinition cmisSecondaryType;        
-            cmisSecondaryType = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisSecondaryType().getId());
+            MutableSecondaryTypeDefinition cmisSecondaryType;
+            cmisSecondaryType = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1,
+                    DocumentTypeCreationHelper.getCmisSecondaryType().getId());
             cmisSecondaryType.setId(SECONDARY_TYPE_ID);
             cmisSecondaryType.setDisplayName("MySecondaryType");
             cmisSecondaryType.setDescription(BUILTIN_IN_MEMORY_TYPE_DEFINITION_DESCR + SECONDARY_TYPE_ID);
             DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisSecondaryType);
             cmisSecondaryType.setIsFileable(false);
-            
+
             // create a single String property definition
             PropertyStringDefinitionImpl propS1 = PropertyCreationHelper.createStringDefinition("SecondaryStringProp",
                     "Secondary String Property", Updatability.READWRITE);
             cmisSecondaryType.addPropertyDefinition(propS1);
-            PropertyIntegerDefinitionImpl propS2 = PropertyCreationHelper.createIntegerDefinition("SecondaryIntegerProp",
-                    "Secondary Integer Property", Updatability.READWRITE);
+            PropertyIntegerDefinitionImpl propS2 = PropertyCreationHelper.createIntegerDefinition(
+                    "SecondaryIntegerProp", "Secondary Integer Property", Updatability.READWRITE);
             propS2.setIsRequired(true);
             cmisSecondaryType.addPropertyDefinition(propS2);
             // add type to types collection
             typesList.add(cmisSecondaryType);
 
             // add relationship type
-            MutableRelationshipTypeDefinition relType;        
-            relType = typeFactory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisRelationshipType().getId());
+            MutableRelationshipTypeDefinition relType;
+            relType = typeFactory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+                    .getCmisRelationshipType().getId());
             relType.setId("CrossReferenceType");
             relType.setDisplayName("CrossReferenceType");
             relType.setDescription("Builtin InMemory type definition CrossReferenceType");
@@ -371,14 +379,15 @@ public class DefaultTypeSystemCreator im
 
             // create a single String property definition
 
-            prop1 = PropertyCreationHelper.createStringDefinition("CrossReferenceKind",
-                    "CrossReferenceType", Updatability.READWRITE);
+            prop1 = PropertyCreationHelper.createStringDefinition("CrossReferenceKind", "CrossReferenceType",
+                    Updatability.READWRITE);
             relType.addPropertyDefinition(prop1);
-            typesList.add(relType);            
+            typesList.add(relType);
 
             // add a policy type
-            MutablePolicyTypeDefinition polType;        
-            polType = typeFactory.createPolicyTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisPolicyType().getId());
+            MutablePolicyTypeDefinition polType;
+            polType = typeFactory.createPolicyTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+                    .getCmisPolicyType().getId());
             polType.setId("AuditPolicy");
             polType.setDisplayName("Audit Policy");
             polType.setDescription("Builtin InMemory type definition AuditPolicy");
@@ -386,10 +395,10 @@ public class DefaultTypeSystemCreator im
             polType.setIsFileable(false);
 
             // create a String property definition
-            prop1 = PropertyCreationHelper.createStringDefinition("AuditSettings",
-                    "Audit Kind Property", Updatability.READWRITE);
+            prop1 = PropertyCreationHelper.createStringDefinition("AuditSettings", "Audit Kind Property",
+                    Updatability.READWRITE);
             polType.addPropertyDefinition(prop1);
-            typesList.add(polType);            
+            typesList.add(polType);
 
             return typesList;
         } catch (Exception e) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java Fri Aug 16 08:47:50 2013
@@ -269,8 +269,9 @@ public final class PropertyCreationHelpe
         return props;
     }
 
-    public static Properties getPropertiesFromObject(StoredObject so, ObjectStore objectStore, TypeDefinition primaryType, List<TypeDefinition> secondaryTypes,
-            Map<String, String> requestedIds, Map<String, String> requestedFuncs) {
+    public static Properties getPropertiesFromObject(StoredObject so, ObjectStore objectStore,
+            TypeDefinition primaryType, List<TypeDefinition> secondaryTypes, Map<String, String> requestedIds,
+            Map<String, String> requestedFuncs) {
         // build properties collection
 
         List<String> idList = new ArrayList<String>(requestedIds.values());
@@ -290,7 +291,7 @@ public final class PropertyCreationHelpe
         }
 
         Map<String, PropertyData<?>> mappedProperties = new HashMap<String, PropertyData<?>>();
-        
+
         // primary type:
         if (requestedIds.containsValue("*")) {
             for (Map.Entry<String, PropertyData<?>> prop : properties.entrySet()) {
@@ -316,7 +317,7 @@ public final class PropertyCreationHelpe
                 }
             }
         }
-        
+
         // secondary types:
         if (null != secondaryTypes) {
             for (TypeDefinition typeDef : secondaryTypes) {
@@ -342,10 +343,10 @@ public final class PropertyCreationHelpe
                             addNotSetPropertyToMap(mappedProperties, typeDef, propAlias.getValue(), queryNameOrAlias);
                         }
                     }
-                }            
+                }
             }
         }
-        
+
         // add functions:
         for (Entry<String, String> funcEntry : requestedFuncs.entrySet()) {
             String queryName;
@@ -393,12 +394,12 @@ public final class PropertyCreationHelpe
             String queryName = propDef.getQueryName();
             String localName = propDef.getLocalName();
             String displayName = propDef.getDisplayName();
-            
+
             AbstractPropertyData<?> ad = clonePropertyData(propData);
             ad.setQueryName(queryNameOrAlias == null ? queryName : queryNameOrAlias);
             ad.setLocalName(localName);
             ad.setDisplayName(displayName);
-            
+
             mappedProperties.put(queryName, ad);
         }
     }
@@ -429,7 +430,8 @@ public final class PropertyCreationHelpe
         }
 
         if (null != includeACL && includeACL) {
-            int aclId = so instanceof DocumentVersion ? ((DocumentVersion) so).getParentDocument().getAclId() : so.getAclId();
+            int aclId = so instanceof DocumentVersion ? ((DocumentVersion) so).getParentDocument().getAclId() : so
+                    .getAclId();
             Acl acl = objectStore.getAcl(aclId);
             od.setAcl(acl);
         }
@@ -465,7 +467,8 @@ public final class PropertyCreationHelpe
         ObjectDataImpl od = new ObjectDataImpl();
 
         // build properties collection
-        Properties props = getPropertiesFromObject(so, objectStore, primaryType, secondaryTypes, requestedProperties, requestedFuncs);
+        Properties props = getPropertiesFromObject(so, objectStore, primaryType, secondaryTypes, requestedProperties,
+                requestedFuncs);
 
         // fill output object
         if (null != includeAllowableActions && includeAllowableActions) {
@@ -498,9 +501,7 @@ public final class PropertyCreationHelpe
             String displayName, Cardinality card, Updatability upd) {
 
         if (!NameValidator.isValidId(id)) {
-            if (!NameValidator.isValidId(id)) {
-                throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-            }
+            throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
         }
 
         prop.setId(id);
@@ -542,25 +543,25 @@ public final class PropertyCreationHelpe
     }
 
     private static AbstractPropertyData<?> getEmptyValue(PropertyDefinition<?> propDef) {
-    	AbstractPropertyData<?> emptyValue;
+        AbstractPropertyData<?> emptyValue;
         if (propDef.getPropertyType().equals(PropertyType.BOOLEAN)) {
-            emptyValue =  new PropertyBooleanImpl(propDef.getId(), (Boolean) null);
+            emptyValue = new PropertyBooleanImpl(propDef.getId(), (Boolean) null);
         } else if (propDef.getPropertyType().equals(PropertyType.DATETIME)) {
-            emptyValue =  new PropertyDateTimeImpl(propDef.getId(), (GregorianCalendar) null);
+            emptyValue = new PropertyDateTimeImpl(propDef.getId(), (GregorianCalendar) null);
         } else if (propDef.getPropertyType().equals(PropertyType.DECIMAL)) {
-            emptyValue =  new PropertyDecimalImpl(propDef.getId(), (BigDecimal) null);
+            emptyValue = new PropertyDecimalImpl(propDef.getId(), (BigDecimal) null);
         } else if (propDef.getPropertyType().equals(PropertyType.HTML)) {
-            emptyValue =  new PropertyHtmlImpl(propDef.getId(), (String) null);
+            emptyValue = new PropertyHtmlImpl(propDef.getId(), (String) null);
         } else if (propDef.getPropertyType().equals(PropertyType.ID)) {
-            emptyValue =  new PropertyIdImpl(propDef.getId(), (String) null);
+            emptyValue = new PropertyIdImpl(propDef.getId(), (String) null);
         } else if (propDef.getPropertyType().equals(PropertyType.INTEGER)) {
-            emptyValue =  new PropertyIntegerImpl(propDef.getId(), (BigInteger) null);
+            emptyValue = new PropertyIntegerImpl(propDef.getId(), (BigInteger) null);
         } else if (propDef.getPropertyType().equals(PropertyType.STRING)) {
-            emptyValue =  new PropertyStringImpl(propDef.getId(), (String) null);
+            emptyValue = new PropertyStringImpl(propDef.getId(), (String) null);
         } else if (propDef.getPropertyType().equals(PropertyType.URI)) {
-            emptyValue =  new PropertyUriImpl(propDef.getId(), (String) null);
+            emptyValue = new PropertyUriImpl(propDef.getId(), (String) null);
         } else {
-            emptyValue =  null;
+            throw new CmisRuntimeException("Unknown property type " + propDef.getPropertyType());
         }
         emptyValue.setDisplayName(propDef.getDisplayName());
         emptyValue.setQueryName(propDef.getQueryName());



Mime
View raw message