You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2014/08/26 19:16:18 UTC

svn commit: r1620662 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemi...

Author: fmui
Date: Tue Aug 26 17:16:17 2014
New Revision: 1620662

URL: http://svn.apache.org/r1620662
Log:
TCK: added test for path segments and added another convenience method to the Session interface

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java?rev=1620662&r1=1620661&r2=1620662&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java Tue Aug 26 17:16:17 2014
@@ -483,6 +483,56 @@ public interface Session extends Seriali
     CmisObject getObjectByPath(String path, OperationContext context);
 
     /**
+     * Returns a CMIS object from the session cache. If the object is not in the
+     * cache or the cache is turned off per default {@link OperationContext}, it
+     * will load the object from the repository and puts it into the cache.
+     * <p>
+     * This method might return a stale object if the object has been found in
+     * the cache and has been changed in or removed from the repository. Use
+     * {@link CmisObject#refresh()} and {@link CmisObject#refreshIfOld(long)} to
+     * update the object if necessary.
+     * 
+     * @param parentPath
+     *            the path of the parent folder
+     * @param name
+     *            the (path segment) name of the object in the folder
+     * 
+     * @return the requested object
+     * 
+     * @throws CmisObjectNotFoundException
+     *             if an object with the given ID doesn't exist
+     * 
+     * @cmis 1.0
+     */
+    CmisObject getObjectByPath(String parentPath, String name);
+
+    /**
+     * Returns a CMIS object from the session cache. If the object is not in the
+     * cache or the given {@link OperationContext} has caching turned off, it
+     * will load the object from the repository and puts it into the cache.
+     * <p>
+     * This method might return a stale object if the object has been found in
+     * the cache and has been changed in or removed from the repository. Use
+     * {@link CmisObject#refresh()} and {@link CmisObject#refreshIfOld(long)} to
+     * update the object if necessary.
+     * 
+     * @param parentPath
+     *            the path of the parent folder
+     * @param name
+     *            the (path segment) name of the object in the folder
+     * @param context
+     *            the {@link OperationContext} to use
+     * 
+     * @return the requested object
+     * 
+     * @throws CmisObjectNotFoundException
+     *             if an object with the given ID doesn't exist
+     * 
+     * @cmis 1.0
+     */
+    CmisObject getObjectByPath(String parentPath, String name, OperationContext context);
+
+    /**
      * Returns the latest version in a version series.
      * 
      * @param objectId

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java?rev=1620662&r1=1620661&r2=1620662&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java Tue Aug 26 17:16:17 2014
@@ -567,6 +567,31 @@ public class SessionImpl implements Sess
         return result;
     }
 
+    public CmisObject getObjectByPath(String parentPath, String name) {
+        return getObjectByPath(parentPath, name, getDefaultContext());
+    }
+
+    public CmisObject getObjectByPath(String parentPath, String name, OperationContext context) {
+        if (parentPath == null || parentPath.length() < 1) {
+            throw new IllegalArgumentException("Parent path must be set!");
+        }
+        if (parentPath.charAt(0) != '/') {
+            throw new IllegalArgumentException("Parent path must start with a '/'!");
+        }
+        if (name == null || name.length() < 1) {
+            throw new IllegalArgumentException("Name must be set!");
+        }
+
+        StringBuilder path = new StringBuilder();
+        path.append(parentPath);
+        if (!parentPath.endsWith("/")) {
+            path.append('/');
+        }
+        path.append(name);
+
+        return getObjectByPath(path.toString(), context);
+    }
+
     public Document getLatestDocumentVersion(ObjectId objectId) {
         return getLatestDocumentVersion(objectId, false, getDefaultContext());
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java?rev=1620662&r1=1620661&r2=1620662&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java Tue Aug 26 17:16:17 2014
@@ -70,6 +70,8 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
 import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
@@ -1887,6 +1889,31 @@ public abstract class AbstractSessionTes
             addResult(results, createResult(INFO, "Repository doesn't support Order By for getChildren()."));
         }
 
+        // test path segments
+
+        ObjectInFolderList pathSegementChildren = session
+                .getBinding()
+                .getNavigationService()
+                .getChildren(session.getRepositoryInfo().getId(), folder.getId(), "cmis:objectId,cmis:name", null,
+                        null, null, null, Boolean.TRUE, BigInteger.valueOf(10), BigInteger.ZERO, null);
+
+        for (ObjectInFolderData objectInFolder : pathSegementChildren.getObjects()) {
+            String pathSegement = objectInFolder.getPathSegment();
+            String objectId = (String) objectInFolder.getObject().getProperties().getProperties()
+                    .get(PropertyIds.OBJECT_ID).getFirstValue();
+
+            if (pathSegement == null) {
+                addResult(results, createResult(FAILURE, "getChildren omitted path segement! Id: " + objectId));
+            } else {
+                CmisObject pathSegementChild = session.getObjectByPath(folder.getPath(), pathSegement);
+
+                f = createResult(FAILURE,
+                        "Combining the path of the parent folder and the path segement of a child returns a different object! Id: "
+                                + objectId);
+                addResult(results, assertEquals(objectId, pathSegementChild.getId(), null, f));
+            }
+        }
+
         // getDescendants
 
         if (isGetDescendantsSupported(session)) {