chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfermig...@apache.org
Subject svn commit: r1096340 [4/7] - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/ chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/j...
Date Sun, 24 Apr 2011 16:12:31 GMT
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.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/server/InMemoryServiceFactoryImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java Sun Apr 24 16:12:27 2011
@@ -62,41 +62,45 @@ public class InMemoryServiceFactoryImpl 
     private boolean fUseOverrideCtx = false;
     private StoreManager storeManager; // singleton root of everything
     private CleanManager cleanManager = null;
-    
+
     @Override
     public void init(Map<String, String> parameters) {
         LOG.info("Initializing in-memory repository...");
 
         inMemoryServiceParameters = parameters;
         String overrideCtx = parameters.get(ConfigConstants.OVERRIDE_CALL_CONTEXT);
-        if (null != overrideCtx)
+        if (null != overrideCtx) {
             fUseOverrideCtx = true;
+        }
 
         ConfigurationSettings.init(parameters);
 
         String repositoryClassName = (String) parameters.get(ConfigConstants.REPOSITORY_CLASS);
-        if (null == repositoryClassName)
+        if (null == repositoryClassName) {
             repositoryClassName = StoreManagerImpl.class.getName();
+        }
 
-        if (null == storeManager)
+        if (null == storeManager) {
             storeManager = StoreManagerFactory.createInstance(repositoryClassName);
-        
+        }
+
         Date deploymentTime = new Date();
         String strDate = new SimpleDateFormat("EEE MMM dd hh:mm:ss a z yyyy", Locale.US).format(deploymentTime);
 
         parameters.put(ConfigConstants.DEPLOYMENT_TIME, strDate);
-        
+
         initStorageManager(parameters);
 
-        fillRepositoryIfConfigured(parameters);                
-        
+        fillRepositoryIfConfigured(parameters);
+
         Long cleanInterval = ConfigurationSettings.getConfigurationValueAsLong(ConfigConstants.CLEAN_REPOSITORY_INTERVAL);
-        if (null != cleanInterval && cleanInterval > 0)
+        if (null != cleanInterval && cleanInterval > 0) {
             scheduleCleanRepositoryJob(cleanInterval);
+        }
 
         LOG.info("...initialized in-memory repository.");
     }
-    
+
     public static void setOverrideCallContext(CallContext ctx) {
         OVERRIDE_CTX = ctx;
     }
@@ -129,33 +133,37 @@ public class InMemoryServiceFactoryImpl 
 
     @Override
     public void destroy() {
-        if (null != cleanManager)
+        if (null != cleanManager) {
             cleanManager.stopCleanRepositoryJob();
+        }
         threadLocalService = null;
     }
 
     private void initStorageManager(Map<String, String> parameters) {
         // initialize in-memory management
         String repositoryClassName = (String) parameters.get(ConfigConstants.REPOSITORY_CLASS);
-        if (null == repositoryClassName)
+        if (null == repositoryClassName) {
             repositoryClassName = StoreManagerImpl.class.getName();
+        }
 
-        if (null == storeManager)
+        if (null == storeManager) {
             storeManager = StoreManagerFactory.createInstance(repositoryClassName);
+        }
 
         String repositoryId = parameters.get(ConfigConstants.REPOSITORY_ID);
 
         List<String> allAvailableRepositories = storeManager.getAllRepositoryIds();
 
         // init existing repositories
-        for (String existingRepId : allAvailableRepositories)
+        for (String existingRepId : allAvailableRepositories) {
             storeManager.initRepository(existingRepId);
+        }
 
         // create repository if configured as a startup parameter
         if (null != repositoryId) {
-            if (allAvailableRepositories.contains(repositoryId))
+            if (allAvailableRepositories.contains(repositoryId)) {
                 LOG.warn("Repostory " + repositoryId + " already exists and will not be created.");
-            else {
+            } else {
                 String typeCreatorClassName = parameters.get(ConfigConstants.TYPE_CREATOR_CLASS);
                 storeManager.createAndInitRepository(repositoryId, typeCreatorClassName);
             }
@@ -163,20 +171,21 @@ public class InMemoryServiceFactoryImpl 
 
     }
 
-    private List<String> readPropertiesToSetFromConfig(Map<String, String> parameters, String keyPrefix) {
+    private static List<String> readPropertiesToSetFromConfig(Map<String, String> parameters, String keyPrefix) {
       List<String> propsToSet = new ArrayList<String>();
       for (int i = 0;; ++i) {
           String propertyKey = keyPrefix + Integer.toString(i);
           String propertyToAdd = parameters.get(propertyKey);
-          if (null == propertyToAdd)
-              break;
-          else
-              propsToSet.add(propertyToAdd);
+          if (null == propertyToAdd) {
+            break;
+        } else {
+            propsToSet.add(propertyToAdd);
+        }
       }
       return propsToSet;
     }
 
-    
+
     private void fillRepositoryIfConfigured(Map<String, String> parameters) {
 
       class DummyCallContext implements CallContext {
@@ -208,7 +217,7 @@ public class InMemoryServiceFactoryImpl 
           public BigInteger getLength() {
               return null;
           }
-          
+
           public String getPassword() {
               return null;
           }
@@ -226,38 +235,44 @@ public class InMemoryServiceFactoryImpl 
       if (doFillRepository /* && !allAvailableRepositories.contains(repositoryId) */ ) {
 
           // create an initial temporary service instance to fill the repository
-          
+
           InMemoryService svc = new InMemoryService(inMemoryServiceParameters, storeManager);
-                  
+
           BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();
 
           String levelsStr = parameters.get(ConfigConstants.FILLER_DEPTH);
           int levels = 1;
-          if (null != levelsStr)
-              levels = Integer.parseInt(levelsStr);
+          if (null != levelsStr) {
+            levels = Integer.parseInt(levelsStr);
+        }
 
           String docsPerLevelStr = parameters.get(ConfigConstants.FILLER_DOCS_PER_FOLDER);
           int docsPerLevel = 1;
-          if (null != docsPerLevelStr)
-              docsPerLevel = Integer.parseInt(docsPerLevelStr);
+          if (null != docsPerLevelStr) {
+            docsPerLevel = Integer.parseInt(docsPerLevelStr);
+        }
 
           String childrenPerLevelStr = parameters.get(ConfigConstants.FILLER_FOLDERS_PER_FOLDER);
           int childrenPerLevel = 2;
-          if (null != childrenPerLevelStr)
-              childrenPerLevel = Integer.parseInt(childrenPerLevelStr);
+          if (null != childrenPerLevelStr) {
+            childrenPerLevel = Integer.parseInt(childrenPerLevelStr);
+        }
 
           String documentTypeId = parameters.get(ConfigConstants.FILLER_DOCUMENT_TYPE_ID);
-          if (null == documentTypeId)
-              documentTypeId = BaseTypeId.CMIS_DOCUMENT.value();
+          if (null == documentTypeId) {
+            documentTypeId = BaseTypeId.CMIS_DOCUMENT.value();
+        }
 
           String folderTypeId = parameters.get(ConfigConstants.FILLER_FOLDER_TYPE_ID);
-          if (null == folderTypeId)
-              folderTypeId = BaseTypeId.CMIS_FOLDER.value();
+          if (null == folderTypeId) {
+            folderTypeId = BaseTypeId.CMIS_FOLDER.value();
+        }
 
           int contentSizeKB = 0;
           String contentSizeKBStr = parameters.get(ConfigConstants.FILLER_CONTENT_SIZE);
-          if (null != contentSizeKBStr)
-              contentSizeKB = Integer.parseInt(contentSizeKBStr);
+          if (null != contentSizeKBStr) {
+            contentSizeKB = Integer.parseInt(contentSizeKBStr);
+        }
 
           // Create a hierarchy of folders and fill it with some documents
           ObjectGenerator gen = new ObjectGenerator(objectFactory, svc, svc, repositoryId);
@@ -279,12 +294,14 @@ public class InMemoryServiceFactoryImpl 
           // Note: must be valid properties in configured document and folder type
 
           List<String> propsToSet = readPropertiesToSetFromConfig(parameters, ConfigConstants.FILLER_DOCUMENT_PROPERTY);
-          if (null != propsToSet)
-              gen.setDocumentPropertiesToGenerate(propsToSet);
+          if (null != propsToSet) {
+            gen.setDocumentPropertiesToGenerate(propsToSet);
+        }
 
           propsToSet = readPropertiesToSetFromConfig(parameters, ConfigConstants.FILLER_FOLDER_PROPERTY);
-          if (null != propsToSet)
-              gen.setFolderPropertiesToGenerate(propsToSet);
+          if (null != propsToSet) {
+            gen.setFolderPropertiesToGenerate(propsToSet);
+        }
 
           // Simulate a runtime context with configuration parameters
           // Attach the CallContext to a thread local context that can be accessed
@@ -304,35 +321,35 @@ public class InMemoryServiceFactoryImpl 
               LOG.error("Could not create folder hierarchy with documents. " + e);
               e.printStackTrace();
           }
-      } // if 
-          
+      } // if
+
     } // fillRepositoryIfConfigured
- 
+
     class CleanManager {
-        
+
         private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
         ScheduledFuture<?> cleanerHandle = null;
-        
+
         public void startCleanRepositoryJob (long intervalInMinutes) {
-            
+
             final Runnable cleaner = new Runnable() {
-                public void run() { 
+                public void run() {
                     LOG.info("Cleaning repository as part of a scheduled maintenance job.");
                     for(String repositoryId: storeManager.getAllRepositoryIds()) {
                         ObjectStore store = storeManager.getObjectStore(repositoryId);
-                        store.clear();             
-                        fillRepositoryIfConfigured(ConfigurationSettings.getParameters());  
+                        store.clear();
+                        fillRepositoryIfConfigured(ConfigurationSettings.getParameters());
                     }
                     LOG.info("Repository cleaned. Freeing memory.");
                     System.gc();
                 }
             };
-            
+
             LOG.info("Repository Clean Job starting clean job, interval " + intervalInMinutes + " min");
             cleanerHandle =
                 scheduler.scheduleAtFixedRate(cleaner, intervalInMinutes, intervalInMinutes, TimeUnit.MINUTES);
         }
-        
+
         public void stopCleanRepositoryJob() {
             LOG.info("Repository Clean Job cancelling clean job.");
             boolean ok = cleanerHandle.cancel(true);
@@ -341,7 +358,7 @@ public class InMemoryServiceFactoryImpl 
         }
     }
 
-    private void scheduleCleanRepositoryJob(long minutes) {                 
+    private void scheduleCleanRepositoryJob(long minutes) {
         cleanManager = new CleanManager();
         cleanManager.startCleanRepositoryJob(minutes);
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.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/server/InMemoryVersioningServiceImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java Sun Apr 24 16:12:27 2011
@@ -63,8 +63,8 @@ public class InMemoryVersioningServiceIm
 
     public void cancelCheckOut(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
 
-        StoredObject so = validator.cancelCheckOut(context, repositoryId, objectId, extension); 
-            
+        StoredObject so = validator.cancelCheckOut(context, repositoryId, objectId, extension);
+
         String user = context.getUsername();
         VersionedDocument verDoc = testHasProperCheckedOutStatus(so, user);
 
@@ -75,18 +75,20 @@ public class InMemoryVersioningServiceIm
             Properties properties, ContentStream contentStream, String checkinComment, List<String> policies,
             Acl addAces, Acl removeAces, ExtensionsData extension, ObjectInfoHandler objectInfos) {
 
-        StoredObject so = validator.checkIn(context, repositoryId, objectId, extension); 
-            
+        StoredObject so = validator.checkIn(context, repositoryId, objectId, extension);
+
         String user = context.getUsername();
         VersionedDocument verDoc = testHasProperCheckedOutStatus(so, user);
 
         DocumentVersion pwc = verDoc.getPwc();
 
-        if (null != contentStream)
+        if (null != contentStream) {
             pwc.setContent(contentStream, false);
+        }
 
-        if (null != properties && null != properties.getProperties())
+        if (null != properties && null != properties.getProperties()) {
             pwc.setCustomProperties(properties.getProperties());
+        }
 
         verDoc.checkIn(major, checkinComment, user);
 
@@ -102,13 +104,14 @@ public class InMemoryVersioningServiceIm
     public void checkOut(CallContext context, String repositoryId, Holder<String> objectId,
             ExtensionsData extension, Holder<Boolean> contentCopied, ObjectInfoHandler objectInfos) {
 
-        StoredObject so = validator.checkOut(context, repositoryId, objectId, extension, contentCopied); 
-            
+        StoredObject so = validator.checkOut(context, repositoryId, objectId, extension, contentCopied);
+
         TypeDefinition typeDef = getTypeDefinition(repositoryId, so);
-        if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT))
+        if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT)) {
             throw new CmisNotSupportedException("Only documents can be checked-out.");
-        else if (!((DocumentTypeDefinition) typeDef).isVersionable())
+        } else if (!((DocumentTypeDefinition) typeDef).isVersionable()) {
             throw new CmisNotSupportedException("Object can't be checked-out, type is not versionable.");
+        }
 
         checkIsVersionableObject(so);
 
@@ -123,8 +126,9 @@ public class InMemoryVersioningServiceIm
             content = ((VersionedDocument) so).getLatestVersion(false).getContent(0, -1);
         }
 
-        if (verDoc.isCheckedOut())
+        if (verDoc.isCheckedOut()) {
             throw new CmisUpdateConflictException("Document " + objectId.getValue() + " is already checked out.");
+        }
 
         String user = context.getUsername();
         checkHasUser(user);
@@ -144,13 +148,15 @@ public class InMemoryVersioningServiceIm
     public List<ObjectData> getAllVersions(CallContext context, String repositoryId, String objectId, String versionSeriesId,
             String filter, Boolean includeAllowableActions, ExtensionsData extension, ObjectInfoHandler objectInfos) {
 
-        if (null == versionSeriesId)
+        if (null == versionSeriesId) {
             throw new CmisInvalidArgumentException("getAllVersions requires a version series id, but ist was null.");
+        }
 
-        StoredObject so = validator.getAllVersions(context, repositoryId, objectId, versionSeriesId, extension);             
+        StoredObject so = validator.getAllVersions(context, repositoryId, objectId, versionSeriesId, extension);
 
-        if (!(so instanceof VersionedDocument))
+        if (!(so instanceof VersionedDocument)) {
             throw new CmisInvalidArgumentException("Object is not instance of a VersionedDocument (version series)");
+        }
 
         VersionedDocument verDoc = (VersionedDocument) so;
         List<ObjectData> res = new ArrayList<ObjectData>();
@@ -176,8 +182,8 @@ public class InMemoryVersioningServiceIm
             String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension,
             ObjectInfoHandler objectInfos) {
 
-        StoredObject so = validator.getObjectOfLatestVersion(context, repositoryId, objectId, versionSeriesId, extension); 
-            
+        StoredObject so = validator.getObjectOfLatestVersion(context, repositoryId, objectId, versionSeriesId, extension);
+
         ObjectData objData = null;
 
         if (so instanceof VersionedDocument) {
@@ -188,8 +194,9 @@ public class InMemoryVersioningServiceIm
         } else if (so instanceof Document) {
             objData = getObject(context, repositoryId, so.getId(), filter, includeAllowableActions, extension,
                     objectInfos);
-        } else
+        } else {
             throw new CmisInvalidArgumentException("Object is not instance of a document (version series)");
+        }
 
         // provide information for Atom links for version series:
         if (context.isObjectInfoRequired()) {
@@ -204,7 +211,7 @@ public class InMemoryVersioningServiceIm
     public Properties getPropertiesOfLatestVersion(CallContext context, String repositoryId, String objectId, String versionSeriesId,
             Boolean major, String filter, ExtensionsData extension) {
 
-        StoredObject so = validator.getPropertiesOfLatestVersion(context, repositoryId, objectId, versionSeriesId, extension); 
+        StoredObject so = validator.getPropertiesOfLatestVersion(context, repositoryId, objectId, versionSeriesId, extension);
 
         StoredObject latestVersionObject = null;
 
@@ -213,12 +220,13 @@ public class InMemoryVersioningServiceIm
             latestVersionObject = verDoc.getLatestVersion(major);
         } else if (so instanceof Document) {
             latestVersionObject = so;
-        } else
+        } else {
             throw new CmisInvalidArgumentException("Object is not instance of a document (version series)");
+        }
 
         List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
         TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
-        Properties props = PropertyCreationHelper.getPropertiesFromObject(latestVersionObject, td, 
+        Properties props = PropertyCreationHelper.getPropertiesFromObject(latestVersionObject, td,
                 requestedIds, true);
 
         return props;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.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/AbstractMultiFilingImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java Sun Apr 24 16:12:27 2011
@@ -28,10 +28,10 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.MultiFiling;
 
 /**
+ * AbstractMultiPathImpl is the common superclass of all objects hold in the
+ * repository that have multiple parent folders, these are: Folders
+ *
  * @author Jens
- * 
- *         AbstractMultiPathImpl is the common superclass of all objects hold in
- *         the repository that have multiple parent folders, these are: Folders
  */
 public abstract class AbstractMultiFilingImpl extends StoredObjectImpl implements MultiFiling {
 
@@ -41,15 +41,7 @@ public abstract class AbstractMultiFilin
         super(objStore);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#addParent(
-     * org.apache.opencmis.inmemory.storedobj.api.Folder)
-     */
     public void addParent(Folder parent) {
-
       try {
           fObjStore.lock();
           addParentIntern(parent);
@@ -59,25 +51,18 @@ public abstract class AbstractMultiFilin
     }
 
     private void addParentIntern(Folder parent) {
-
-        if (parent.hasChild(getName()))
+        if (parent.hasChild(getName())) {
             throw new IllegalArgumentException(
                     "Cannot assign new parent folder, this name already exists in target folder.");
+        }
 
-        if (null == fParents)
+        if (null == fParents) {
             fParents = new ArrayList<Folder>();
+        }
 
         fParents.add(parent);
-      }
-    
-    
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#removeParent
-     * (org.apache.opencmis.inmemory.storedobj.api.Folder)
-     */
+    }
+
     public void removeParent(Folder parent) {
         try {
             fObjStore.lock();
@@ -89,16 +74,11 @@ public abstract class AbstractMultiFilin
 
     private void removeParentIntern(Folder parent) {
         fParents.remove(parent);
-        if (fParents.isEmpty())
+        if (fParents.isEmpty()) {
             fParents = null;
+        }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#getParents()
-     */
     public List<Folder> getParents() {
         return fParents;
     }
@@ -106,26 +86,11 @@ public abstract class AbstractMultiFilin
     public boolean hasParent() {
       return null != fParents && !fParents.isEmpty();
     }
-      
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#getPathSegment
-     * ()
-     */
+
     public String getPathSegment() {
         return getName();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.inmemory.storedobj.api.Path#move(org.apache.opencmis
-     * .inmemory.storedobj.api.Folder,
-     * org.apache.opencmis.inmemory.storedobj.api.Folder)
-     */
     public void move(Folder oldParent, Folder newParent) {
         try {
             fObjStore.lock();
@@ -136,21 +101,26 @@ public abstract class AbstractMultiFilin
         }
     }
 
+    @Override
     public void rename(String newName) {
         try {
-            if (!NameValidator.isValidId(newName))
+            if (!NameValidator.isValidId(newName)) {
                 throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+            }
             fObjStore.lock();
             for (Folder folder : fParents) {
-              if (folder == null)
-                  throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
-              if (folder.hasChild(newName))
-                  throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
+              if (folder == null) {
+                throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
+            }
+              if (folder.hasChild(newName)) {
+                throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
                           + ". This path already exists in parent " + folder.getPath() + ".");
             }
+            }
             setName(newName);
         } finally {
           fObjStore.unlock();
         }
     }
+
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.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/AbstractSingleFilingImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java Sun Apr 24 16:12:27 2011
@@ -30,14 +30,11 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
 
 /**
- * 
+ * AbstractPathImpl is the common superclass of all objects hold in the
+ * repository that have a single parent, these are: Folders.
+ *
  * @author Jens
- * 
- *         AbstractPathImpl is the common superclass of all objects hold in the
- *         repository that have a single parent, these are: Folders
- * 
  */
-
 public abstract class AbstractSingleFilingImpl extends StoredObjectImpl implements SingleFiling {
 
     protected FolderImpl fParent;
@@ -46,18 +43,12 @@ public abstract class AbstractSingleFili
         super(objStore);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getPath()
-     */
     public String getPath() {
         StringBuffer path = new StringBuffer(getName());
-        if (null == getParent())
-            path.replace(0, path.length(), PATH_SEPARATOR); // root folder-->
-        // set /
-        else {
+        if (null == getParent()) {
+            path.replace(0, path.length(), PATH_SEPARATOR);
+        } else {
+            // root folder-->
             Folder f = getParent();
             while (f.getParent() != null) {
                 path.insert(0, PATH_SEPARATOR);
@@ -71,13 +62,6 @@ public abstract class AbstractSingleFili
         return path.toString();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getParent
-     * ()
-     */
     public Folder getParent() {
         return fParent;
     }
@@ -87,20 +71,13 @@ public abstract class AbstractSingleFili
     }
 
     public List<Folder> getParents() {
-        if (null == fParent)
+        if (null == fParent) {
             return Collections.emptyList();
-        else
+        } else {
             return Collections.singletonList((Folder) fParent);
+        }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObjectWithPath
-     * #
-     * setParent(org.opencmis.client.provider.spi.inmemory.storedobj.api.Folder)
-     */
     public void setParent(Folder parent) {
         try {
             fObjStore.lock();
@@ -110,16 +87,20 @@ public abstract class AbstractSingleFili
         }
     }
 
+    @Override
     public void rename(String newName) {
-        if (!NameValidator.isValidId(newName))
+        if (!NameValidator.isValidId(newName)) {
             throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+        }
         try {
             fObjStore.lock();
-            if (getParent() == null)
+            if (getParent() == null) {
                 throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
-            if (getParent().hasChild(newName))
+            }
+            if (getParent().hasChild(newName)) {
                 throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
                         + ". This path already exists.");
+            }
 
             setName(newName);
         } finally {
@@ -128,18 +109,20 @@ public abstract class AbstractSingleFili
     }
 
     public void move(Folder oldParent, Folder newParent) {
-
         try {
             fObjStore.lock();
-            if (this instanceof Document || this instanceof VersionedDocument)
+            if (this instanceof Document || this instanceof VersionedDocument) {
                 fParent.moveChildDocument(this, oldParent, newParent);
-            else {// it must be a folder
-                if (getParent() == null)
+            } else {// it must be a folder
+                if (getParent() == null) {
                     throw new IllegalArgumentException("Root folder cannot be moved.");
-                if (newParent == null)
+                }
+                if (newParent == null) {
                     throw new IllegalArgumentException("null is not a valid move target.");
-                if (newParent.hasChild(getName()))
+                }
+                if (newParent.hasChild(getName())) {
                     throw new IllegalArgumentException("Cannot move folder, this name already exists in target.");
+                }
 
                 setParent(newParent);
             }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.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/ContentStreamDataImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java Sun Apr 24 16:12:27 2011
@@ -51,7 +51,7 @@ public class ContentStreamDataImpl imple
     public ContentStreamDataImpl(long maxAllowedContentSizeKB) {
         sizeLimitKB = maxAllowedContentSizeKB;
     }
-    
+
     public void setContent(InputStream in) throws IOException {
         fStreamLimitOffset = fStreamLimitLength = -1;
         if (null == in) {
@@ -63,9 +63,10 @@ public class ContentStreamDataImpl imple
             for (int len = 0; (len = in.read(buffer)) != -1;) {
                 contentStream.write(buffer, 0, len);
                 fLength += len;
-                if (sizeLimitKB > 0 && fLength > sizeLimitKB * 1024)
+                if (sizeLimitKB > 0 && fLength > sizeLimitKB * 1024) {
                     throw new CmisInvalidArgumentException("Content size exceeds max. allowed size of " + sizeLimitKB
                             + "KB.");
+                }
             }
             fContent = contentStream.toByteArray();
             fLength = contentStream.size();
@@ -103,13 +104,14 @@ public class ContentStreamDataImpl imple
     }
 
     public InputStream getStream() {
-        if (null == fContent)
+        if (null == fContent) {
             return null;
-        else if (fStreamLimitOffset <= 0 && fStreamLimitLength < 0)
+        } else if (fStreamLimitOffset <= 0 && fStreamLimitLength < 0) {
             return new ByteArrayInputStream(fContent);
-        else
+        } else {
             return new ByteArrayInputStream(fContent, (int) (fStreamLimitOffset < 0 ? 0 : fStreamLimitOffset),
                     (int) (fStreamLimitLength < 0 ? fLength : fStreamLimitLength));
+        }
     }
 
     public ContentStream getCloneWithLimits(long offset, long length) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.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/DocumentImpl.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java Sun Apr 24 16:12:27 2011
@@ -36,9 +36,9 @@ import org.apache.commons.logging.LogFac
 /**
  * InMemory Stored Document A document is a stored object that has a path and
  * (optional) content
- * 
+ *
  * @author Jens
- * 
+ *
  */
 
 public class DocumentImpl extends AbstractMultiFilingImpl implements Document {
@@ -46,45 +46,35 @@ public class DocumentImpl extends Abstra
 
     private static final Log LOG = LogFactory.getLog(AbstractSingleFilingImpl.class.getName());
     private final Long MAX_CONTENT_SIZE_KB = ConfigurationSettings.getConfigurationValueAsLong(ConfigConstants.MAX_CONTENT_SIZE_KB);
-    
+
     DocumentImpl(ObjectStoreImpl objStore) { // visibility should be package
         super(objStore);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opencmis.client.provider.spi.inmemory.IDocument#getContent()
-     */
     public ContentStream getContent(long offset, long length) {
-        if (null == fContent)
+        if (null == fContent) {
             return null;
-        else if (offset <= 0 && length < 0)
+        } else if (offset <= 0 && length < 0) {
             return fContent;
-        else
+        } else {
             return fContent.getCloneWithLimits(offset, length);
+        }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IDocument#setContent(org.opencmis
-     * .client.provider .ContentStreamData)
-     */
     public void setContent(ContentStream content, boolean mustPersist) {
-
         if (null == content) {
             fContent = null;
         } else {
             fContent = new ContentStreamDataImpl(MAX_CONTENT_SIZE_KB == null ? 0 : MAX_CONTENT_SIZE_KB);
             String fileName = content.getFileName();
-            if (null == fileName || fileName.length() <= 0)
+            if (null == fileName || fileName.length() <= 0) {
                 fileName = getName(); // use name of document as fallback
+            }
             fContent.setFileName(fileName);
             String mimeType = content.getMimeType();
-            if (null == mimeType || mimeType.length() <= 0)
-                mimeType = "application/octet-stream";  // use as fallback
+            if (null == mimeType || mimeType.length() <= 0) {
+                mimeType = "application/octet-stream"; // use as fallback
+            }
             fContent.setMimeType(mimeType);
             try {
                 fContent.setContent(content.getStream());
@@ -95,6 +85,7 @@ public class DocumentImpl extends Abstra
         }
     }
 
+    @Override
     public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
             List<String> requestedIds) {
 

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=1096340&r1=1096339&r2=1096340&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 Sun Apr 24 16:12:27 2011
@@ -37,9 +37,9 @@ import org.apache.chemistry.opencmis.inm
 
 /**
  * A class representing a single version of a document
- * 
+ *
  * @author Jens
- * 
+ *
  */
 public class DocumentVersionImpl extends StoredObjectImpl implements DocumentVersion {
 
@@ -96,10 +96,12 @@ public class DocumentVersionImpl extends
             if (ver.isMajor()) {
                 ++majorNo;
                 minorNo = 0;
-            } else
+            } else {
                 ++minorNo;
-            if (ver == this)
+            }
+            if (ver == this) {
                 break;
+            }
         }
         String label = "V " + majorNo + "." + minorNo;
         return label;
@@ -119,10 +121,11 @@ public class DocumentVersionImpl extends
     }
 
     public ContentStream getContent(long offset, long length) {
-        if (offset <= 0 && length < 0)
+        if (offset <= 0 && length < 0) {
             return fContent;
-        else
+        } else {
             return fContent.getCloneWithLimits(offset, length);
+        }
     }
 
     public VersionedDocument getParentDocument() {
@@ -132,23 +135,27 @@ public class DocumentVersionImpl extends
     private boolean isLatestVersion() {
         List<DocumentVersion> allVers = fContainer.getAllVersions();
         boolean isLatestVersion;
-        if (isPwc())
+        if (isPwc()) {
             isLatestVersion = allVers.size() > 1 && allVers.get(allVers.size() - 2).equals(this);
-        else
+        } else {
             isLatestVersion = allVers.get(allVers.size() - 1).equals(this);
+        }
         return isLatestVersion;
     }
 
     private boolean isLatestMajorVersion() {
-        if (!fIsMajor)
+        if (!fIsMajor) {
             return false;
+        }
 
         List<DocumentVersion> allVersions = fContainer.getAllVersions();
         DocumentVersion latestMajor = null;
 
-        for (DocumentVersion ver : allVersions)
-            if (ver.isMajor() && !ver.isPwc())
+        for (DocumentVersion ver : allVersions) {
+            if (ver.isMajor() && !ver.isPwc()) {
                 latestMajor = ver;
+            }
+        }
 
         boolean isLatestMajorVersion = latestMajor == this;
         return isLatestMajorVersion;
@@ -159,6 +166,7 @@ public class DocumentVersionImpl extends
     // fId = UUID.randomUUID().toString();
     // }
 
+    @Override
     public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
             List<String> requestedIds) {
 

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=1096340&r1=1096339&r2=1096340&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 Sun Apr 24 16:12:27 2011
@@ -63,8 +63,9 @@ public class FolderImpl extends Abstract
             boolean hasChild;
             String name = folder.getName();
             hasChild = hasChild(name);
-            if (hasChild)
+            if (hasChild) {
                 throw new CmisNameConstraintViolationException("Cannot create folder " + name + ". Name already exists in parent folder");
+            }
             folder.setParent(this);
             folder.persist();
         } finally {
@@ -74,7 +75,7 @@ public class FolderImpl extends Abstract
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see
      * org.opencmis.client.provider.spi.inmemory.IFolder#addChildDocument(org
      * .opencmis.client.provider .spi.inmemory.storedobj.impl.DocumentImpl)
@@ -91,32 +92,31 @@ public class FolderImpl extends Abstract
         try {
             fObjStore.lock();
             String name = so.getName();
-            if (!NameValidator.isValidId(name))
+            if (!NameValidator.isValidId(name)) {
                 throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+            }
 
             boolean hasChild;
             hasChild = hasChild(name);
-            if (hasChild)
-                throw new CmisNameConstraintViolationException("Cannot create object: " + name + ". Name already exists in parent folder");
+            if (hasChild) {
+                throw new CmisNameConstraintViolationException(
+                        "Cannot create object: " + name + ". Name already exists in parent folder");
+            }
 
-            if (so instanceof SingleFiling)
+            if (so instanceof SingleFiling) {
                 ((SingleFiling) so).setParent(this);
-            else if (so instanceof MultiFiling)
+            } else if (so instanceof MultiFiling) {
                 ((MultiFiling) so).addParent(this);
-            else
+            } else {
                 throw new CmisInvalidArgumentException("Cannot create document, object is not fileable.");
-            
+            }
+
             so.persist();
         } finally {
             fObjStore.unlock();
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opencmis.client.provider.spi.inmemory.IFolder#getChildren()
-     */
     public List<StoredObject> getChildren(int maxItems, int skipCount) {
         List<StoredObject> result = new ArrayList<StoredObject>();
         for (String id : fObjStore.getIds()) {
@@ -135,30 +135,27 @@ public class FolderImpl extends Abstract
         }
         sortFolderList(result);
 
-        if (maxItems < 0)
+        if (maxItems < 0) {
             maxItems = result.size();
-        if (skipCount < 0)
+        }
+        if (skipCount < 0) {
             skipCount = 0;
+        }
         int from = Math.min(skipCount, result.size());
         int to = Math.min(maxItems + from, result.size());
         result = result.subList(from, to);
         return result;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IFolder#getFolderChildren()
-     */
     public List<Folder> getFolderChildren(int maxItems, int skipCount) {
         List<Folder> result = new ArrayList<Folder>();
         for (String id : fObjStore.getIds()) {
             StoredObject obj = fObjStore.getObject(id);
             if (obj instanceof SingleFiling) {
                 SingleFiling pathObj = (SingleFiling) obj;
-                if (pathObj.getParent() == this && pathObj instanceof Folder)
+                if (pathObj.getParent() == this && pathObj instanceof Folder) {
                     result.add((Folder) obj);
+                }
             }
         }
         sortFolderList(result);
@@ -168,25 +165,20 @@ public class FolderImpl extends Abstract
         return result;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IFolder#hasChild(java.lang.
-     * String)
-     */
     public boolean hasChild(String name) {
         for (String id : fObjStore.getIds()) {
             StoredObject obj = fObjStore.getObject(id);
             if (obj instanceof Filing) {
                 Filing pathObj = (Filing) obj;
-                if (pathObj.getParents().contains(this) && obj.getName().equals(name))
+                if (pathObj.getParents().contains(this) && obj.getName().equals(name)) {
                     return true;
+                }
             }
         }
         return false;
     }
 
+    @Override
     public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
             List<String> requestedIds) {
 
@@ -196,9 +188,10 @@ public class FolderImpl extends Abstract
 
         if (FilterParser.isContainedInFilter(PropertyIds.PARENT_ID, requestedIds)) {
             String parentId = getParent() == null ? null : getParent().getId();
-            if (parentId != null)
+            if (parentId != null) {
                 properties.put(PropertyIds.PARENT_ID, objFactory.createPropertyIdData(PropertyIds.PARENT_ID,
                         parentId));
+            }
         }
 
         if (FilterParser.isContainedInFilter(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, requestedIds)) {
@@ -215,14 +208,14 @@ public class FolderImpl extends Abstract
 
     // Helper functions
     private void init(String name, Folder parent) {
-        if (!NameValidator.isValidId(name))
+        if (!NameValidator.isValidId(name)) {
             throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+        }
         setName(name);
         setParent(parent);
     }
 
-    private void sortFolderList(List<? extends StoredObject> list) {
-
+    private static void sortFolderList(List<? extends StoredObject> list) {
         // TODO evaluate orderBy, for now sort by path segment
         class FolderComparator implements Comparator<StoredObject> {
 
@@ -240,10 +233,12 @@ public class FolderImpl extends Abstract
     public void moveChildDocument(StoredObject so, Folder oldParent, Folder newParent) {
         try {
             fObjStore.lock();
-            if (newParent.hasChild(so.getName()))
+            if (newParent.hasChild(so.getName())) {
                 throw new IllegalArgumentException("Cannot move object, this name already exists in target.");
-            if (!(so instanceof Filing))
+            }
+            if (!(so instanceof Filing)) {
                 throw new IllegalArgumentException("Cannot move object, object does not have a path.");
+            }
 
             if (so instanceof SingleFiling) {
                 SingleFiling pathObj = (SingleFiling) 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=1096340&r1=1096339&r2=1096340&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 Sun Apr 24 16:12:27 2011
@@ -41,27 +41,28 @@ import org.apache.chemistry.opencmis.inm
 /**
  * The object store is the central core of the in-memory repository. It is based on huge HashMap
  * map mapping ids to objects in memory. To allow access from multiple threads a Java concurrent
- * HashMap is used that allows parallel access methods. 
- * 
- * Certain methods in the in-memory repository must guarantee constraints. For example a folder 
+ * HashMap is used that allows parallel access methods.
+ * <p>
+ * Certain methods in the in-memory repository must guarantee constraints. For example a folder
  * enforces that each child has a unique name. Therefore certain operations must occur in an
- * atomic manner. In the example it must be guaranteed that no write access occurs to the 
+ * atomic manner. In the example it must be guaranteed that no write access occurs to the
  * map between acquiring the iterator to find the children and finishing the add operation when
  * no name conflicts can occur. For this purpose this class has methods to lock an unlock the
  * state of the repository. It is very important that the caller acquiring the lock enforces an
- * unlock under all circumstances. Typical code is: 
- * 
+ * unlock under all circumstances. Typical code is:
+ * <p>
+ * <pre>
  * ObjectStoreImpl os = ... ;
  * try {
  *     os.lock();
  * } finally {
  *     os.unlock();
  * }
- * 
+ * </pre>
+ *
  * The locking is very coarse-grained. Productive implementations would probably implement finer
  * grained locks on a folder or document rather than the complete repository.
  */
-
 public class ObjectStoreImpl implements ObjectStore {
 
     /**
@@ -73,9 +74,9 @@ public class ObjectStoreImpl implements 
      * a concurrent HashMap as core element to hold all objects in the repository
      */
     private final Map<String, StoredObject> fStoredObjectMap = new ConcurrentHashMap<String, StoredObject>();
-    
+
     private final Lock fLock = new ReentrantLock();
-    
+
     final String fRepositoryId;
     FolderImpl fRootFolder = null;
 
@@ -91,36 +92,22 @@ public class ObjectStoreImpl implements 
     public void lock() {
       fLock.lock();
     }
-    
+
     public void unlock() {
       fLock.unlock();
     }
-    
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#
-     * getRootFolder()
-     */
+
     public Folder getRootFolder() {
         return fRootFolder;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#
-     * getFolderByPath(java.lang .String)
-     */
     public StoredObject getObjectByPath(String path) {
-
         for (StoredObject so : fStoredObjectMap.values()) {
             if (so instanceof SingleFiling) {
                 String soPath = ((SingleFiling) so).getPath();
-                if (soPath.equals(path))
+                if (soPath.equals(path)) {
                     return so;
+                }
             } else if (so instanceof MultiFiling) {
                 MultiFiling mfo = (MultiFiling) so;
                 List<Folder> parents = mfo.getParents();
@@ -128,41 +115,30 @@ public class ObjectStoreImpl implements 
                     String parentPath = parent.getPath();
                     String mfPath = parentPath.equals(Folder.PATH_SEPARATOR) ? parentPath + mfo.getPathSegment()
                             : parentPath + Folder.PATH_SEPARATOR + mfo.getPathSegment();
-                    if (mfPath.equals(path))
+                    if (mfPath.equals(path)) {
                         return so;
+                    }
                 }
-            } else
+            } else {
                 return null;
+            }
         }
         return null;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#
-     * getObjectById(java.lang .String)
-     */
     public StoredObject getObjectById(String objectId) {
         // we use path as id so we just can look it up in the map
         StoredObject so = fStoredObjectMap.get(objectId);
         return so;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#
-     * deleteObject(java.lang .String)
-     */
     public void deleteObject(String objectId) {
         String path = objectId; // currently the same
         StoredObject obj = fStoredObjectMap.get(path);
 
-        if (null == obj)
+        if (null == obj) {
             throw new RuntimeException("Cannot delete object with id  " + objectId + ". Object does not exist.");
+        }
 
         if (obj instanceof FolderImpl) {
             deleteFolder(objectId);
@@ -171,8 +147,9 @@ public class ObjectStoreImpl implements 
             VersionedDocument parentDoc = vers.getParentDocument();
             fStoredObjectMap.remove(path);
             boolean otherVersionsExist = vers.getParentDocument().deleteVersion(vers);
-            if (!otherVersionsExist)
+            if (!otherVersionsExist) {
                 fStoredObjectMap.remove(parentDoc.getId());
+            }
         } else {
             fStoredObjectMap.remove(path);
         }
@@ -181,8 +158,9 @@ public class ObjectStoreImpl implements 
     public void removeVersion(DocumentVersion vers) {
         StoredObject found = fStoredObjectMap.remove(vers.getId());
 
-        if (null == found)
+        if (null == found) {
             throw new CmisInvalidArgumentException("Cannot delete object with id  " + vers.getId() + ". Object does not exist.");
+        }
     }
 
     // public void changePath(StoredObject obj, String oldPath, String newPath)
@@ -201,8 +179,9 @@ public class ObjectStoreImpl implements 
     public String storeObject(StoredObject so) {
         String id = so.getId();
         // check if update or create
-        if (null == id)
+        if (null == id) {
             id = getNextId().toString();
+        }
         fStoredObjectMap.put(id, so);
         return id;
     }
@@ -219,7 +198,7 @@ public class ObjectStoreImpl implements 
         Set<String> entries = fStoredObjectMap.keySet();
         return entries;
     }
-    
+
     /**
      * Clear repository and remove all data.
      */
@@ -233,7 +212,7 @@ public class ObjectStoreImpl implements 
     public long getObjectCount() {
         return fStoredObjectMap.size();
     }
-    
+
     // /////////////////////////////////////////
     // private helper methods
 
@@ -287,8 +266,9 @@ public class ObjectStoreImpl implements 
 
     private void deleteFolder(String folderId) {
         StoredObject folder = fStoredObjectMap.get(folderId);
-        if (folder == null)
+        if (folder == null) {
             throw new CmisInvalidArgumentException("Unknown object with id:  " + folderId);
+        }
 
         if (!(folder instanceof FolderImpl)) {
             throw new CmisInvalidArgumentException("Cannot delete folder with id:  " + folderId
@@ -297,8 +277,9 @@ public class ObjectStoreImpl implements 
 
         // check if children exist
         List<StoredObject> children = ((Folder) folder).getChildren(-1, -1);
-        if (children != null && !children.isEmpty())
+        if (children != null && !children.isEmpty()) {
             throw new CmisConstraintException("Cannot delete folder with id:  " + folderId + ". Folder is not empty.");
+        }
 
         fStoredObjectMap.remove(folderId);
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerFactory.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/StoreManagerFactory.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerFactory.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerFactory.java Sun Apr 24 16:12:27 2011
@@ -24,13 +24,16 @@ import org.apache.commons.logging.LogFac
 
 /**
  * create objects that are stored in a persistent store
- * 
+ *
  * @author Jens
  */
-
 public class StoreManagerFactory {
+
     private static final Log log = LogFactory.getLog(StoreManagerFactory.class);
 
+    private StoreManagerFactory() {
+    }
+
     public static StoreManager createInstance(String className) {
 
         Class<?> clazz = null;
@@ -54,9 +57,9 @@ public class StoreManagerFactory {
             e.printStackTrace();
         }
 
-        if (obj instanceof StoreManager)
+        if (obj instanceof StoreManager) {
             return (StoreManager) obj;
-        else {
+        } else {
             log.error("Failed to create StoredObjectCreator, class " + className
                     + " does not implement interface StoredObjectCreator");
             return null;

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=1096340&r1=1096339&r2=1096340&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 Sun Apr 24 16:12:27 2011
@@ -59,13 +59,13 @@ import org.apache.commons.logging.LogFac
 
 /**
  * factory to create objects that are stored in the InMemory store
- * 
+ *
  * @author Jens
  */
 public class StoreManagerImpl implements StoreManager {
 
     private static final Log LOG = LogFactory.getLog(StoreManagerImpl.class);
-    
+
     protected final BindingsObjectFactory fObjectFactory;
     protected RepositoryInfo fRepositoryInfo;
     protected CmisServiceValidator validator;
@@ -102,8 +102,9 @@ public class StoreManagerImpl implements
 
     public void createAndInitRepository(String repositoryId, String typeCreatorClassName) {
         if (fMapRepositoryToObjectStore.containsKey(repositoryId)
-                || fMapRepositoryToTypeManager.containsKey(repositoryId))
+                || fMapRepositoryToTypeManager.containsKey(repositoryId)) {
             throw new RuntimeException("Cannot add repository, repository " + repositoryId + " already exists.");
+        }
 
         fMapRepositoryToObjectStore.put(repositoryId, new ObjectStoreImpl(repositoryId));
         fMapRepositoryToTypeManager.put(repositoryId, new TypeManagerImpl());
@@ -126,8 +127,9 @@ public class StoreManagerImpl implements
 
     public TypeDefinitionContainer getTypeById(String repositoryId, String typeId) {
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-        if (null == typeManager)
+        if (null == typeManager) {
             throw new RuntimeException("Unknown repository " + repositoryId);
+        }
 
         return typeManager.getTypeById(typeId);
     }
@@ -135,8 +137,9 @@ public class StoreManagerImpl implements
     public TypeDefinitionContainer getTypeById(String repositoryId, String typeId, boolean includePropertyDefinitions,
             int depth) {
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-        if (null == typeManager)
+        if (null == typeManager) {
             throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
+        }
 
         TypeDefinitionContainer tc = typeManager.getTypeById(typeId);
         List<TypeDefinitionContainer> result = null;
@@ -144,11 +147,12 @@ public class StoreManagerImpl implements
         if (tc != null) {
             if (depth == -1) {
                 result = tc.getChildren();
-                if (!includePropertyDefinitions)
+                if (!includePropertyDefinitions) {
                     cloneTypeList(depth - 1, false, result);
-            } else if (depth == 0 || depth < -1)
+                }
+            } else if (depth == 0 || depth < -1) {
                 throw new CmisInvalidArgumentException("illegal depth value: " + depth);
-            else {
+            } else {
                 result = tc.getChildren();
                 cloneTypeList(depth - 1, includePropertyDefinitions, result);
             }
@@ -160,8 +164,9 @@ public class StoreManagerImpl implements
             boolean includePropertyDefinitions) {
         Collection<TypeDefinitionContainer> result;
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-        if (null == typeManager)
+        if (null == typeManager) {
             throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
+        }
         Collection<TypeDefinitionContainer> typeColl = typeManager.getTypeDefinitionList();
         if (includePropertyDefinitions) {
             result = typeColl;
@@ -185,8 +190,9 @@ public class StoreManagerImpl implements
 
     public List<TypeDefinitionContainer> getRootTypes(String repositoryId) {
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-        if (null == typeManager)
+        if (null == typeManager) {
             throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
+        }
         List<TypeDefinitionContainer> rootTypes = typeManager.getRootTypes();
 
         return rootTypes;
@@ -194,8 +200,9 @@ public class StoreManagerImpl implements
 
     public RepositoryInfo getRepositoryInfo(String repositoryId) {
         ObjectStore sm = fMapRepositoryToObjectStore.get(repositoryId);
-        if (null == sm)
+        if (null == sm) {
             return null;
+        }
 
         RepositoryInfo repoInfo = createDefaultRepositoryInfo(repositoryId);
 
@@ -204,8 +211,9 @@ public class StoreManagerImpl implements
 
     public void clearTypeSystem(String repositoryId) {
         TypeManagerImpl typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-        if (null == typeManager)
+        if (null == typeManager) {
             throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
+        }
 
         typeManager.clearTypeSystem();
     }
@@ -231,9 +239,10 @@ public class StoreManagerImpl implements
             if (obj instanceof RepositoryInfoCreator) {
                 repoCreator = (RepositoryInfoCreator) obj;
                 fRepositoryInfo = repoCreator.createRepositoryInfo();
-            } else
+            } else {
                 throw new RuntimeException(
                         "Illegal class to create repository info, must implement RepositoryInfoCreator interface.");
+            }
         } else {
             // create a default repository info
             createDefaultRepositoryInfo(repositoryId);
@@ -261,10 +270,11 @@ public class StoreManagerImpl implements
                         "Illegal class to create type system, must implement TypeCreator interface.", e);
             }
 
-            if (obj instanceof TypeCreator)
+            if (obj instanceof TypeCreator) {
                 typeCreator = (TypeCreator) obj;
-            else
+            } else {
                 throw new RuntimeException("Illegal class to create type system, must implement TypeCreator interface.");
+            }
 
             // retrieve the list of available types from the configured class.
             // test
@@ -278,11 +288,13 @@ public class StoreManagerImpl implements
 
         List<TypeDefinition> typeDefs = null;
         TypeManagerImpl typeManager = fMapRepositoryToTypeManager.get(repositoryId);
-        if (null == typeManager)
+        if (null == typeManager) {
             throw new RuntimeException("Unknown repository " + repositoryId);
+        }
 
-        if (null != typeCreatorClassName)
+        if (null != typeCreatorClassName) {
             typeDefs = initTypeSystem(typeCreatorClassName);
+        }
 
         typeManager.initTypeSystem(typeDefs);
     }
@@ -342,7 +354,7 @@ public class StoreManagerImpl implements
     /**
      * traverse tree and replace each need node with a clone. remove properties
      * on clone if requested, cut children of clone if depth is exceeded.
-     * 
+     *
      * @param depth
      * @param types
      */
@@ -352,8 +364,9 @@ public class StoreManagerImpl implements
         while (it.hasNext()) {
             TypeDefinitionContainer tdc = it.next();
             AbstractTypeDefinition td = ((AbstractTypeDefinition) tdc.getTypeDefinition()).clone();
-            if (!includePropertyDefinitions)
+            if (!includePropertyDefinitions) {
                 td.setPropertyDefinitions(null);
+            }
             TypeDefinitionContainerImpl tdcClone = new TypeDefinitionContainerImpl(td);
             if (depth > 0) {
                 ArrayList<TypeDefinitionContainer> children = new ArrayList<TypeDefinitionContainer>(tdc.getChildren()

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=1096340&r1=1096339&r2=1096340&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 Sun Apr 24 16:12:27 2011
@@ -33,18 +33,13 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
 
 /**
- * InMemory Stored Object
- * 
- * @author Jens
- * 
- */
-
-/**
  * StoredObject is the common superclass of all objects hold in the repository
  * Documents, Folders, Relationships and Policies
+ *
+ * @author Jens
  */
-
 public class StoredObjectImpl implements StoredObject {
+
     protected String fId;
     protected String fName;
     protected String fTypeId;
@@ -64,135 +59,54 @@ public class StoredObjectImpl implements
         fObjStore = objStore;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getId()
-     */
     public String getId() {
         return fId;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getName()
-     */
     public String getName() {
         return fName;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#setName(java.
-     * lang.String)
-     */
     public void setName(String name) {
         fName = name;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opencmis.client.provider.spi.inmemory.IStoredObject#getTypeId()
-     */
     public String getTypeId() {
         return fTypeId;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#setTypeId(java
-     * .lang.String)
-     */
     public void setTypeId(String type) {
         fTypeId = type;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedBy()
-     */
     public String getCreatedBy() {
         return fCreatedBy;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedBy(
-     * java.lang.String)
-     */
     public void setCreatedBy(String createdBy) {
         this.fCreatedBy = createdBy;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedBy()
-     */
     public String getModifiedBy() {
         return fModifiedBy;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedBy
-     * (java.lang.String)
-     */
     public void setModifiedBy(String modifiedBy) {
         this.fModifiedBy = modifiedBy;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#getCreatedAt()
-     */
     public GregorianCalendar getCreatedAt() {
         return fCreatedAt;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCreatedAt(
-     * java.util.GregorianCalendar)
-     */
     public void setCreatedAt(GregorianCalendar createdAt) {
         this.fCreatedAt = createdAt;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#getModifiedAt()
-     */
     public GregorianCalendar getModifiedAt() {
         return fModifiedAt;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#setModifiedAtNow
-     * ()
-     */
     public void setModifiedAtNow() {
         this.fModifiedAt = getNow();
     }
@@ -205,34 +119,14 @@ public class StoredObjectImpl implements
         return fRepositoryId;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#setProperties
-     * (java.util.Map)
-     */
     public void setProperties(Map<String, PropertyData<?>> props) {
         fProperties = props;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#getProperties()
-     */
     public Map<String, PropertyData<?>> getProperties() {
         return fProperties;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObject#
-     * getChangeToken()
-     */
     public String getChangeToken() {
         GregorianCalendar lastModified = getModifiedAt();
         String token = Long.valueOf(lastModified.getTimeInMillis()).toString();
@@ -243,34 +137,14 @@ public class StoredObjectImpl implements
         setName(newName);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.opencmis.client.provider.spi.inmemory.IStoredObject#
-     * createSystemBasePropertiesWhenCreated(java.util.Map, java.lang.String)
-     */
     public void createSystemBasePropertiesWhenCreated(Map<String, PropertyData<?>> properties, String user) {
         addSystemBaseProperties(properties, user, true);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.opencmis.client.provider.spi.inmemory.IStoredObject#
-     * updateSystemBasePropertiesWhenModified(java.util.Map, java.lang.String)
-     */
     public void updateSystemBasePropertiesWhenModified(Map<String, PropertyData<?>> properties, String user) {
         addSystemBaseProperties(properties, user, false);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#fillProperties
-     * (java.util.List, org.opencmis.client.provider.ProviderObjectFactory,
-     * java.util.List)
-     */
     public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
             List<String> requestedIds) {
 
@@ -315,8 +189,9 @@ public class StoredObjectImpl implements
         // add custom properties of type definition to the collection
         if (null != fProperties) {
             for (Entry<String, PropertyData<?>> prop : fProperties.entrySet()) {
-                if (FilterParser.isContainedInFilter(prop.getKey(), requestedIds))
+                if (FilterParser.isContainedInFilter(prop.getKey(), requestedIds)) {
                     properties.put(prop.getKey(), prop.getValue());
+                }
             }
         }
     }
@@ -324,13 +199,6 @@ public class StoredObjectImpl implements
     // ///////////////////////////////////////////
     // private helper methods
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.IStoredObject#setCustomProperties
-     * (java.util.Map)
-     */
     public void setCustomProperties(Map<String, PropertyData<?>> properties) {
         properties = new HashMap<String, PropertyData<?>>(properties); // get a
         // writable
@@ -339,7 +207,7 @@ public class StoredObjectImpl implements
         setProperties(properties);
     }
 
-    private GregorianCalendar getNow() {
+    private static GregorianCalendar getNow() {
         GregorianCalendar now = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
         return now;
     }
@@ -350,8 +218,9 @@ public class StoredObjectImpl implements
      * list of properties with current values
      */
     private void addSystemBaseProperties(Map<String, PropertyData<?>> properties, String user, boolean isCreated) {
-        if (user == null)
+        if (user == null) {
             user = "unknown";
+        }
 
         // Note that initial creation and modification date is set in
         // constructor.
@@ -383,7 +252,7 @@ public class StoredObjectImpl implements
      * CMIS_NAME CMIS_OBJECT_ID CMIS_OBJECT_TYPE_ID CMIS_BASE_TYPE_ID
      * CMIS_CREATED_BY CMIS_CREATION_DATE CMIS_LAST_MODIFIED_BY
      * CMIS_LAST_MODIFICATION_DATE CMIS_CHANGE_TOKEN
-     * 
+     *
      * // ---- document ---- CMIS_IS_IMMUTABLE CMIS_IS_LATEST_VERSION
      * CMIS_IS_MAJOR_VERSION CMIS_IS_LATEST_MAJOR_VERSION CMIS_VERSION_LABEL
      * CMIS_VERSION_SERIES_ID CMIS_IS_VERSION_SERIES_CHECKED_OUT
@@ -391,85 +260,113 @@ public class StoredObjectImpl implements
      * CMIS_CHECKIN_COMMENT CMIS_CONTENT_STREAM_LENGTH
      * CMIS_CONTENT_STREAM_MIME_TYPE CMIS_CONTENT_STREAM_FILE_NAME
      * CMIS_CONTENT_STREAM_ID
-     * 
+     *
      * // ---- folder ---- CMIS_PARENT_ID CMIS_ALLOWED_CHILD_OBJECT_TYPE_IDS
      * CMIS_PATH
-     * 
+     *
      * // ---- relationship ---- CMIS_SOURCE_ID CMIS_TARGET_ID
-     * 
+     *
      * // ---- policy ---- CMIS_POLICY_TEXT
      */
-    private void removeAllSystemProperties(Map<String, PropertyData<?>> properties) {
+    private static void removeAllSystemProperties(Map<String, PropertyData<?>> properties) {
         // ---- base ----
-        if (properties.containsKey(PropertyIds.NAME))
+        if (properties.containsKey(PropertyIds.NAME)) {
             properties.remove(PropertyIds.NAME);
-        if (properties.containsKey(PropertyIds.OBJECT_ID))
+        }
+        if (properties.containsKey(PropertyIds.OBJECT_ID)) {
             properties.remove(PropertyIds.OBJECT_ID);
-        if (properties.containsKey(PropertyIds.OBJECT_TYPE_ID))
+        }
+        if (properties.containsKey(PropertyIds.OBJECT_TYPE_ID)) {
             properties.remove(PropertyIds.OBJECT_TYPE_ID);
-        if (properties.containsKey(PropertyIds.BASE_TYPE_ID))
+        }
+        if (properties.containsKey(PropertyIds.BASE_TYPE_ID)) {
             properties.remove(PropertyIds.BASE_TYPE_ID);
-        if (properties.containsKey(PropertyIds.CREATED_BY))
+        }
+        if (properties.containsKey(PropertyIds.CREATED_BY)) {
             properties.remove(PropertyIds.CREATED_BY);
-        if (properties.containsKey(PropertyIds.CREATION_DATE))
+        }
+        if (properties.containsKey(PropertyIds.CREATION_DATE)) {
             properties.remove(PropertyIds.CREATION_DATE);
-        if (properties.containsKey(PropertyIds.LAST_MODIFIED_BY))
+        }
+        if (properties.containsKey(PropertyIds.LAST_MODIFIED_BY)) {
             properties.remove(PropertyIds.LAST_MODIFIED_BY);
-        if (properties.containsKey(PropertyIds.LAST_MODIFICATION_DATE))
+        }
+        if (properties.containsKey(PropertyIds.LAST_MODIFICATION_DATE)) {
             properties.remove(PropertyIds.LAST_MODIFICATION_DATE);
-        if (properties.containsKey(PropertyIds.CHANGE_TOKEN))
+        }
+        if (properties.containsKey(PropertyIds.CHANGE_TOKEN)) {
             properties.remove(PropertyIds.CHANGE_TOKEN);
+        }
         // ---- document ----
-        if (properties.containsKey(PropertyIds.IS_IMMUTABLE))
+        if (properties.containsKey(PropertyIds.IS_IMMUTABLE)) {
             properties.remove(PropertyIds.IS_IMMUTABLE);
-        if (properties.containsKey(PropertyIds.IS_LATEST_VERSION))
+        }
+        if (properties.containsKey(PropertyIds.IS_LATEST_VERSION)) {
             properties.remove(PropertyIds.IS_LATEST_VERSION);
-        if (properties.containsKey(PropertyIds.IS_MAJOR_VERSION))
+        }
+        if (properties.containsKey(PropertyIds.IS_MAJOR_VERSION)) {
             properties.remove(PropertyIds.IS_MAJOR_VERSION);
-        if (properties.containsKey(PropertyIds.IS_LATEST_MAJOR_VERSION))
+        }
+        if (properties.containsKey(PropertyIds.IS_LATEST_MAJOR_VERSION)) {
             properties.remove(PropertyIds.IS_LATEST_MAJOR_VERSION);
-        if (properties.containsKey(PropertyIds.VERSION_LABEL))
+        }
+        if (properties.containsKey(PropertyIds.VERSION_LABEL)) {
             properties.remove(PropertyIds.VERSION_LABEL);
-        if (properties.containsKey(PropertyIds.VERSION_SERIES_ID))
+        }
+        if (properties.containsKey(PropertyIds.VERSION_SERIES_ID)) {
             properties.remove(PropertyIds.VERSION_SERIES_ID);
-        if (properties.containsKey(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT))
+        }
+        if (properties.containsKey(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT)) {
             properties.remove(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
-        if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY))
+        }
+        if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY)) {
             properties.remove(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY);
-        if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID))
+        }
+        if (properties.containsKey(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID)) {
             properties.remove(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID);
-        if (properties.containsKey(PropertyIds.CHECKIN_COMMENT))
+        }
+        if (properties.containsKey(PropertyIds.CHECKIN_COMMENT)) {
             properties.remove(PropertyIds.CHECKIN_COMMENT);
-        if (properties.containsKey(PropertyIds.CONTENT_STREAM_LENGTH))
+        }
+        if (properties.containsKey(PropertyIds.CONTENT_STREAM_LENGTH)) {
             properties.remove(PropertyIds.CONTENT_STREAM_LENGTH);
-        if (properties.containsKey(PropertyIds.CONTENT_STREAM_MIME_TYPE))
+        }
+        if (properties.containsKey(PropertyIds.CONTENT_STREAM_MIME_TYPE)) {
             properties.remove(PropertyIds.CONTENT_STREAM_MIME_TYPE);
-        if (properties.containsKey(PropertyIds.CONTENT_STREAM_FILE_NAME))
+        }
+        if (properties.containsKey(PropertyIds.CONTENT_STREAM_FILE_NAME)) {
             properties.remove(PropertyIds.CONTENT_STREAM_FILE_NAME);
-        if (properties.containsKey(PropertyIds.CONTENT_STREAM_ID))
+        }
+        if (properties.containsKey(PropertyIds.CONTENT_STREAM_ID)) {
             properties.remove(PropertyIds.CONTENT_STREAM_ID);
+        }
         // ---- folder ----
-        if (properties.containsKey(PropertyIds.PARENT_ID))
+        if (properties.containsKey(PropertyIds.PARENT_ID)) {
             properties.remove(PropertyIds.PARENT_ID);
-        if (properties.containsKey(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS))
+        }
+        if (properties.containsKey(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS)) {
             properties.remove(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
-        if (properties.containsKey(PropertyIds.PATH))
+        }
+        if (properties.containsKey(PropertyIds.PATH)) {
             properties.remove(PropertyIds.PATH);
+        }
         // ---- relationship ----
-        if (properties.containsKey(PropertyIds.SOURCE_ID))
+        if (properties.containsKey(PropertyIds.SOURCE_ID)) {
             properties.remove(PropertyIds.SOURCE_ID);
-        if (properties.containsKey(PropertyIds.TARGET_ID))
+        }
+        if (properties.containsKey(PropertyIds.TARGET_ID)) {
             properties.remove(PropertyIds.TARGET_ID);
+        }
         // ---- policy ----
-        if (properties.containsKey(PropertyIds.POLICY_TEXT))
+        if (properties.containsKey(PropertyIds.POLICY_TEXT)) {
             properties.remove(PropertyIds.POLICY_TEXT);
+        }
     }
 
     public void persist() {
         // in-memory implementation does not need to to anything to persist,
         // but after this call the id should be set.
         fId = fObjStore.storeObject(this);
-
     }
 
 }

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=1096340&r1=1096339&r2=1096340&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 Sun Apr 24 16:12:27 2011
@@ -47,8 +47,9 @@ public class VersionedDocumentImpl exten
 
     public DocumentVersion addVersion(ContentStream content, VersioningState verState, String user) {
 
-        if (isCheckedOut())
+        if (isCheckedOut()) {
             throw new CmisConstraintException("Cannot add a version to document, document is checked out.");
+        }
 
         DocumentVersionImpl ver = new DocumentVersionImpl(fRepositoryId, this, content, verState, fObjStore);
         ver.setSystemBasePropertiesWhenCreatedDirect(getName(), getTypeId(), user); // copy
@@ -71,11 +72,13 @@ public class VersionedDocumentImpl exten
     }
 
     public boolean deleteVersion(DocumentVersion version) {
-        if (fIsCheckedOut)
+        if (fIsCheckedOut) {
             throw new CmisInvalidArgumentException("version cannot be deleted if document is checked-out: " + version.getId());
+        }
         boolean found = fVersions.remove(version);
-        if (!found)
+        if (!found) {
             throw new CmisInvalidArgumentException("Version is not contained in the document:" + version.getId());
+        }
 
         return !fVersions.isEmpty();
     }
@@ -97,9 +100,10 @@ public class VersionedDocumentImpl exten
                 throw new CmisConstraintException("Error: Can't checkin. Document " + getId() + " user " + user
                         + " has not checked out the document");
             }
-        } else
+        } else {
             throw new CmisConstraintException("Error: Can't cancel checkout, Document " + getId()
                     + " is not checked out.");
+        }
 
         DocumentVersion pwc = getPwc();
         pwc.setCheckinComment(checkinComment);
@@ -130,8 +134,9 @@ public class VersionedDocumentImpl exten
         DocumentVersion latest = null;
         if (major) {
             for (DocumentVersion ver : fVersions) {
-                if (ver.isMajor())
+                if (ver.isMajor()) {
                     latest = ver;
+                }
             }
         } else {
             latest = fVersions.get(fVersions.size() - 1);
@@ -149,12 +154,14 @@ public class VersionedDocumentImpl exten
 
     public DocumentVersion getPwc() {
         for (DocumentVersion ver : fVersions) {
-            if (ver.isPwc())
+            if (ver.isPwc()) {
                 return ver;
+            }
         }
         return null;
     }
 
+    @Override
     public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
             List<String> requestedIds) {
 

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=1096340&r1=1096339&r2=1096340&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 Sun Apr 24 16:12:27 2011
@@ -60,16 +60,18 @@ public class DefaultTypeSystemCreator im
     }
 
     public static TypeDefinition getTypeById(String typeId) {
-        for (TypeDefinition typeDef : singletonTypes)
-            if (typeDef.getId().equals(typeId))
+        for (TypeDefinition typeDef : singletonTypes) {
+            if (typeDef.getId().equals(typeId)) {
                 return typeDef;
+            }
+        }
         return null;
     }
 
     /**
-     * create root types and a collection of sample types
-     * 
-     * @return typesMap map filled with created types
+     * Create root types and a collection of sample types.
+     *
+     * @return typesMap a map filled with created types
      */
     private static List<TypeDefinition> buildTypesList() {
         // always add CMIS default types
@@ -208,7 +210,7 @@ public class DefaultTypeSystemCreator im
         prop9.setChoices(choiceList);
         prop9.setDefaultValue(Collections.singletonList("blue"));
         propertyDefinitions.put(prop9.getId(), prop9);
-        
+
         /*
          * try short form: / PropertyCreationHelper.addElemToPicklist(prop9,
          * "red"); PropertyCreationHelper.addElemToPicklist(prop9, "green");

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.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/DocumentTypeCreationHelper.java?rev=1096340&r1=1096339&r2=1096340&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DocumentTypeCreationHelper.java Sun Apr 24 16:12:27 2011
@@ -38,6 +38,9 @@ public class DocumentTypeCreationHelper 
 
     private static final List<TypeDefinition> defaultTypes = createCmisDefaultTypes();
 
+    private DocumentTypeCreationHelper() {
+    }
+
     public static List<TypeDefinition> createMapWithDefaultTypes() {
         List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
         typesList.addAll(defaultTypes);
@@ -69,7 +72,7 @@ public class DocumentTypeCreationHelper 
 
     /**
      * create root types and a collection of sample types
-     * 
+     *
      * @return typesMap map filled with created types
      */
     public static List<TypeDefinition> createDefaultTypes() {
@@ -245,9 +248,10 @@ public class DocumentTypeCreationHelper 
     public static void mergePropertyDefinitions(Map<String, PropertyDefinition<?>> existingPpropertyDefinitions,
             Map<String, PropertyDefinition<?>> newPropertyDefinitions) {
         for (String propId : newPropertyDefinitions.keySet()) {
-            if (existingPpropertyDefinitions.containsKey(propId))
+            if (existingPpropertyDefinitions.containsKey(propId)) {
                 throw new RuntimeException("You can't set a property with id " + propId
                         + ". This property id already exists already or exists in supertype");
+            }
         }
         existingPpropertyDefinitions.putAll(newPropertyDefinitions);
     }



Mime
View raw message