chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1515275 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory: server/ storedobj/api/ storedobj/impl/
Date Mon, 19 Aug 2013 05:48:40 GMT
Author: jens
Date: Mon Aug 19 05:48:40 2013
New Revision: 1515275

URL: http://svn.apache.org/r1515275
Log:
InMemory: simplify interfaces

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.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/InMemoryMultiFilingServiceImpl.java?rev=1515275&r1=1515274&r2=1515275&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java
Mon Aug 19 05:48:40 2013
@@ -22,7 +22,6 @@ import java.util.List;
 
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
@@ -30,7 +29,6 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Filing;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStoreMultiFiling;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
 import org.slf4j.Logger;
@@ -53,15 +51,15 @@ public class InMemoryMultiFilingServiceI
             throw new CmisNotSupportedException(
                     "Cannot add object to folder, version specific filing is not supported.");
         }
-
+        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
         StoredObject[] sos = validator.addObjectToFolder(context, repositoryId, objectId,
folderId, allVersions, extension);
 
         StoredObject so = sos[0];
         StoredObject folder = sos[1];
-        ObjectStoreMultiFiling osmf = checkObjects(repositoryId, so, folder);
+        checkObjects(repositoryId, so, folder);
 
         Folder newParent = (Folder) folder;
-        osmf.addParent(so, newParent);
+        objStore.addParent(so, newParent);
         if (context.isObjectInfoRequired()) {
             ObjectInfoImpl objectInfo = new ObjectInfoImpl();
             fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
@@ -77,14 +75,15 @@ public class InMemoryMultiFilingServiceI
 
         LOG.debug("Begin removeObjectFromFolder()");
 
+        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
         StoredObject[] sos = validator.removeObjectFromFolder(context, repositoryId, objectId,
folderId, extension);
         StoredObject so = sos[0];
         if (null != folderId) {
             StoredObject folder = sos[1];
-            ObjectStoreMultiFiling osmf = checkObjects(repositoryId, so, folder);
+            checkObjects(repositoryId, so, folder);
             Folder parent = (Folder) folder;
 
-            osmf.removeParent(so, parent);
+            objStore.removeParent(so, parent);
 
             // To be able to provide all Atom links in the response we need
             // additional information:
@@ -95,11 +94,11 @@ public class InMemoryMultiFilingServiceI
                 objectInfos.addObjectInfo(objectInfo);
             }
         } else {
-            ObjectStoreMultiFiling osmf = checkObjects(repositoryId, so, null);
-            List<String> parentIds = osmf.getParentIds((Filing) so,  context.getUsername());
+            checkObjects(repositoryId, so, null);
+            List<String> parentIds = objStore.getParentIds((Filing) so,  context.getUsername());
             for (String parentId: parentIds) {
-                Folder parent = (Folder) ((ObjectStore)osmf).getObjectById(parentId);
-                osmf.removeParent(so, parent);
+                Folder parent = (Folder) objStore.getObjectById(parentId);
+                objStore.removeParent(so, parent);
             }
 
             // To be able to provide all Atom links in the response we need
@@ -114,12 +113,7 @@ public class InMemoryMultiFilingServiceI
         LOG.debug("End removeObjectFromFolder()");
     }
 
-    private ObjectStoreMultiFiling checkObjects(String repositoryId, StoredObject so, StoredObject
folder) {
-        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
-        if (!(objStore instanceof ObjectStoreMultiFiling)) {
-            throw new CmisInvalidArgumentException("Repository Id " + repositoryId + " does
not support multi-filing");
-        }
-
+    private void checkObjects(String repositoryId, StoredObject so, StoredObject folder)
{
         if ((so instanceof Folder)) {
             throw new CmisConstraintException("Cannot add object to folder, object id " +
folder.getId()
                     + " is a folder and folders are not multi-filed.");
@@ -128,9 +122,7 @@ public class InMemoryMultiFilingServiceI
         if (folder != null && !(folder instanceof Folder)) {
             throw new CmisConstraintException("Cannot add object to folder, folder id " +
folder.getId()
                     + " does not refer to a folder.");
-        }
-        
-        return (ObjectStoreMultiFiling) objStore;
+        }        
     }
 
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.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/InMemoryNavigationServiceImpl.java?rev=1515275&r1=1515274&r2=1515275&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
Mon Aug 19 05:48:40 2013
@@ -54,7 +54,6 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Item;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStoreFiling;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
@@ -277,7 +276,6 @@ public class InMemoryNavigationServiceIm
         List<ObjectInFolderData> folderList = new ArrayList<ObjectInFolderData>();
         ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
         StoredObject so = objStore.getObjectById(folderId);
-        ObjectStoreFiling objStoreFiling = (ObjectStoreFiling) objStore;
         boolean cmis11 = InMemoryServiceContext.getCallContext().getCmisVersion() != CmisVersion.CMIS_1_0;
 
         if (so == null) {
@@ -288,8 +286,8 @@ public class InMemoryNavigationServiceIm
             return null; // it is a document and has no children
         }
 
-        ObjectStoreFiling.ChildrenResult children = folderOnly ? objStoreFiling.getFolderChildren((Folder)
so,
-                maxItems, skipCount, user) : objStoreFiling.getChildren((Folder) so, maxItems,
skipCount, user,
+        ObjectStore.ChildrenResult children = folderOnly ? objStore.getFolderChildren((Folder)
so,
+                maxItems, skipCount, user) : objStore.getChildren((Folder) so, maxItems,
skipCount, user,
                 includePwc);
 
         for (Fileable child : children.getChildren()) {
@@ -367,7 +365,7 @@ public class InMemoryNavigationServiceIm
         List<ObjectParentData> result = null;
         result = new ArrayList<ObjectParentData>();
         ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
-        List<String> parentIds = ((ObjectStoreFiling) objStore).getParentIds(sop, user);
+        List<String> parentIds = objStore.getParentIds(sop, user);
         if (null != parentIds) {
             for (String parentId : parentIds) {
                 ObjectParentDataImpl parentData = new ObjectParentDataImpl();
@@ -398,7 +396,7 @@ public class InMemoryNavigationServiceIm
         ObjectDataImpl parent = new ObjectDataImpl();
 
         ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
-        List<String> parents = ((ObjectStoreFiling) objStore).getParentIds(sop, user);
+        List<String> parents = objStore.getParentIds(sop, user);
         if (null == parents || parents.isEmpty()) {
             return null;
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.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/InMemoryObjectServiceImpl.java?rev=1515275&r1=1515274&r2=1515275&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
Mon Aug 19 05:48:40 2013
@@ -77,8 +77,6 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Filing;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStoreFiling;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStoreFiling.ChildrenResult;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
@@ -518,7 +516,7 @@ public class InMemoryObjectServiceImpl e
         }
 
         boolean foundOldParent = false;
-        for (String parentId : ((ObjectStoreFiling)objectStore).getParentIds(spo, user))
{
+        for (String parentId : objectStore.getParentIds(spo, user)) {
             if (parentId.equals(soSource.getId())) {
                 foundOldParent = true;
                 break;
@@ -533,11 +531,7 @@ public class InMemoryObjectServiceImpl e
             throw new CmisNotSupportedException("Destination of a move cannot be a subfolder
of the source");
         }
 
-        if (objectStore instanceof ObjectStoreFiling) {
-            ((ObjectStoreFiling) objectStore).move(so, sourceFolder, targetFolder);
-        } else {
-            throw new CmisInvalidArgumentException("Repository " + repositoryId + "does not
support Filing");
-        }
+        objectStore.move(so, sourceFolder, targetFolder);
         objectId.setValue(so.getId());
 
         LOG.debug("stop moveObject()");
@@ -726,8 +720,7 @@ public class InMemoryObjectServiceImpl e
                 throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
             }
             // Note: the test for duplicated name in folder is left to the object store
-            ObjectStoreFiling objStoreFiling = (ObjectStoreFiling) objStore;
-            objStoreFiling.rename((Fileable)so, (String) pd.getFirstValue()); 
+            objStore.rename((Fileable)so, (String) pd.getFirstValue()); 
             hasUpdatedProp = true;
         }
 
@@ -1199,7 +1192,7 @@ public class InMemoryObjectServiceImpl e
             if (targetId.equals(sourceId)) {
                 return true;
             }
-            List<String>parentIds = ((ObjectStoreFiling)objStore).getParentIds(folder,
user);
+            List<String>parentIds = objStore.getParentIds(folder, user);
             targetId = parentIds == null || parentIds.isEmpty() ? null : parentIds.get(0);
   
             if (null != targetId) {
                 folder = (Folder) objStore.getObjectById(targetId);
@@ -1223,8 +1216,7 @@ public class InMemoryObjectServiceImpl e
     private boolean deleteRecursive(ObjectStore objStore, Folder parentFolder, boolean continueOnFailure,
             boolean allVersions, List<String> failedToDeleteIds, String user) {
         
-        ObjectStoreFiling filingStore = (ObjectStoreFiling) objStore;
-        ChildrenResult childrenResult = filingStore.getChildren(parentFolder, -1, -1, "Admin",
true);
+        ObjectStore.ChildrenResult childrenResult = objStore.getChildren(parentFolder, -1,
-1, "Admin", true);
         List<Fileable> children = childrenResult.getChildren();
 
         if (null == children) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.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/api/ObjectStore.java?rev=1515275&r1=1515274&r2=1515275&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java
Mon Aug 19 05:48:40 2013
@@ -42,6 +42,24 @@ import org.apache.chemistry.opencmis.com
  */
 public interface ObjectStore {
 
+    public static class ChildrenResult {
+        private int noItems;
+        private List<Fileable> children;
+
+        public ChildrenResult(List<Fileable> children, int noItems) {
+            this.children = children;
+            this.noItems = noItems;
+        }
+
+        public int getNoItems() {
+            return noItems;
+        }
+
+        public List<Fileable> getChildren() {
+            return children;
+        }
+    }
+
     /**
      * Get the root folder of this object store
      * 
@@ -197,6 +215,64 @@ public interface ObjectStore {
             Acl addACEs, Acl removeACEs);
 
     /**
+     * get all the children of this folder. To support paging an initial offset
+     * and a maximum number of children to retrieve can be passed
+     * 
+     * @param folder
+     *            folder to get children from
+     * @param maxItems
+     *            max. number of items to return
+     * @param skipCount
+     *            initial offset where to start fetching
+     * @param user
+     *            user to determine visible children
+     * @param usePwc
+     *            if true return private working copy otherwise return latest
+     *            version;
+     * 
+     * @return list of children objects
+     */
+    ChildrenResult getChildren(Folder folder, int maxItems, int skipCount, String user, boolean
usePwc);
+
+    /**
+     * get all the children of this folder which are folders. To support paging
+     * an initial offset and a maximum number of children to retrieve can be
+     * passed.
+     * 
+     * @param folder
+     *            folder to get children from
+     * @param maxItems
+     *            max. number of items to return
+     * @param skipCount
+     *            initial offset where to start fetching
+     * @param user
+     * @return list of children folders
+     */
+    ChildrenResult getFolderChildren(Folder folder, int maxItems, int skipCount, String user);
+
+    /**
+     * Move an object to a different folder.
+     * 
+     * @param so
+     *            object to be moved
+     * @param oldParent
+     *            old parent folder for the object
+     * @param newParent
+     *            new parent folder for the object
+     */
+    void move(StoredObject so, Folder oldParent, Folder newParent);
+
+    /**
+     * Rename an object
+     * 
+     * @param so
+     *            object to be renamed
+     * @param newName
+     *            new name to be assigned
+     */
+    void rename(Fileable so, String newName);
+
+    /**
      * Persist a new version in the store (created from a check-out)
      * 
      * @param version
@@ -338,4 +414,32 @@ public interface ObjectStore {
      * @return ACL of this id
      */
     Acl getAcl(int aclId);
+
+    
+    // Multifiling methods:
+    /**
+     * get all parent ids of this object visible for a user
+     * 
+     * @param user
+     *            user who can see parents
+     * @return list of folder ids
+     */
+    List<String> getParentIds(Filing spo, String user);
+
+    /**
+     * Add this document to a new parent folder as child object
+     * 
+     * @param parentId
+     *            id of parent folder the document is to be added to
+     */
+    void addParent(StoredObject so, Folder parent);
+
+    /**
+     * Remove this object from the children of parent
+     * 
+     * @param parentId
+     *            id of parent folder the document is to be removed from
+     */
+    void removeParent(StoredObject so, Folder parent);
+
 }
\ No newline at end of file

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=1515275&r1=1515274&r2=1515275&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
Mon Aug 19 05:48:40 2013
@@ -49,7 +49,6 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.MultiFiling;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStoreMultiFiling;
 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;
@@ -84,7 +83,7 @@ import org.apache.chemistry.opencmis.inm
  * implement finer grained locks on a folder or document rather than the
  * complete repository.
  */
-public class ObjectStoreImpl implements ObjectStore, ObjectStoreMultiFiling {
+public class ObjectStoreImpl implements ObjectStore {
 
     private static final int FIRST_ID = 100;
 



Mime
View raw message