chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1162542 - 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...
Date Sun, 28 Aug 2011 15:48:15 GMT
Author: fmui
Date: Sun Aug 28 15:48:15 2011
New Revision: 1162542

URL: http://svn.apache.org/viewvc?rev=1162542&view=rev
Log:
Client APi: added getParents() with operation context parameter
TCK: added asserts for ACLs, renditions, policies, relationships

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/FileableCmisObject.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractFilableCmisObject.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.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/FileableCmisObject.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/FileableCmisObject.java?rev=1162542&r1=1162541&r2=1162542&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/FileableCmisObject.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/FileableCmisObject.java
Sun Aug 28 15:48:15 2011
@@ -45,6 +45,11 @@ public interface FileableCmisObject exte
     List<Folder> getParents();
 
     /**
+     * Returns the parents of this object.
+     */
+    List<Folder> getParents(OperationContext context);
+
+    /**
      * Returns the paths of this object.
      */
     List<String> getPaths();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractFilableCmisObject.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/AbstractFilableCmisObject.java?rev=1162542&r1=1162541&r2=1162542&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractFilableCmisObject.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractFilableCmisObject.java
Sun Aug 28 15:48:15 2011
@@ -46,6 +46,10 @@ public abstract class AbstractFilableCmi
     private static final long serialVersionUID = 1L;
 
     public List<Folder> getParents() {
+        return getParents(getSession().getDefaultContext());
+    }
+
+    public List<Folder> getParents(OperationContext context) {
         String objectId = getObjectId();
 
         // get object ids of the parent folders
@@ -69,8 +73,7 @@ public abstract class AbstractFilableCmi
             }
 
             // fetch the object and make sure it is a folder
-            ObjectId parentId = getSession().createObjectId((String) idProperty.getFirstValue());
-            CmisObject parentFolder = getSession().getObject(parentId);
+            CmisObject parentFolder = getSession().getObject((String) idProperty.getFirstValue(),
context);
             if (!(parentFolder instanceof Folder)) {
                 // the repository sent an object that is not a folder...
                 throw new CmisRuntimeException("Repository sent invalid data! Object is not
a folder!");
@@ -123,7 +126,7 @@ public abstract class AbstractFilableCmi
     public FileableCmisObject move(ObjectId sourceFolderId, ObjectId targetFolderId) {
         return move(sourceFolderId, targetFolderId, getSession().getDefaultContext());
     }
-    
+
     public FileableCmisObject move(ObjectId sourceFolderId, ObjectId targetFolderId, OperationContext
context) {
         String objectId = getObjectId();
         Holder<String> objectIdHolder = new Holder<String>(objectId);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.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/FolderImpl.java?rev=1162542&r1=1162541&r2=1162542&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
Sun Aug 28 15:48:15 2011
@@ -401,7 +401,7 @@ public class FolderImpl extends Abstract
     }
 
     @Override
-    public List<Folder> getParents() {
+    public List<Folder> getParents(OperationContext context) {
         if (isRootFolder()) {
             return Collections.emptyList();
         }
@@ -424,8 +424,7 @@ public class FolderImpl extends Abstract
         }
 
         // fetch the object and make sure it is a folder
-        ObjectId parentId = getSession().createObjectId((String) idProperty.getFirstValue());
-        CmisObject parentFolder = getSession().getObject(parentId);
+        CmisObject parentFolder = getSession().getObject((String) idProperty.getFirstValue(),
context);
         if (!(parentFolder instanceof Folder)) {
             // the repository sent an object that is not a folder...
             throw new CmisRuntimeException("Repository sent invalid data! Object is not a
folder!");

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=1162542&r1=1162541&r2=1162542&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
Sun Aug 28 15:48:15 2011
@@ -376,6 +376,22 @@ public abstract class AbstractSessionTes
                     "Newly created document is invalid! Exception: " + e.getMessage(), e,
true));
         }
 
+        if (parent != null) {
+            List<Folder> parents = result.getParents(SELECT_ALL_NO_CACHE_OC);
+            boolean found = false;
+            for (Folder folder : parents) {
+                if (parent.getId().equals(folder.getId())) {
+                    found = true;
+                    break;
+                }
+            }
+
+            if (!found) {
+                addResult(createResult(FAILURE,
+                        "The folder the document has been created in is not in the list of
the document parents!"));
+            }
+        }
+
         return result;
     }
 
@@ -1601,7 +1617,7 @@ public abstract class AbstractSessionTes
                 CmisObject objectById = session.getObject(child.getId(), SELECT_ALL_NO_CACHE_OC);
 
                 f = createResult(FAILURE, "Child and object fetched by id don't match! Id:
" + child.getId());
-                addResult(results, assertEquals(child, objectById, null, f));
+                addResult(results, assertEquals(child, objectById, null, f, false, false));
 
                 // get object by path and compare
                 List<String> paths = ((FileableCmisObject) child).getPaths();
@@ -1612,8 +1628,13 @@ public abstract class AbstractSessionTes
                     for (String path : paths) {
                         CmisObject objectByPath = session.getObjectByPath(path, SELECT_ALL_NO_CACHE_OC);
 
-                        f = createResult(FAILURE, "Child and object fetched by path don't
match! Id: " + child.getId());
-                        addResult(results, assertEquals(child, objectByPath, null, f));
+                        f = createResult(FAILURE, "Child and object fetched by path don't
match! Id: " + child.getId()
+                                + " / Path: " + path);
+                        addResult(results, assertEquals(child, objectByPath, null, f, false,
false));
+
+                        f = createResult(FAILURE, "Object fetched by id and object fetched
by path don't match! Id: "
+                                + child.getId() + " / Path: " + path);
+                        addResult(results, assertEquals(objectById, objectByPath, null, f,
true, true));
                     }
                 }
             }
@@ -2209,7 +2230,7 @@ public abstract class AbstractSessionTes
     }
 
     protected CmisTestResult assertEquals(CmisObject expected, CmisObject actual, CmisTestResult
success,
-            CmisTestResult failure) {
+            CmisTestResult failure, boolean checkAcls, boolean checkPolicies) {
 
         List<CmisTestResult> results = new ArrayList<CmisTestResult>();
 
@@ -2248,10 +2269,75 @@ public abstract class AbstractSessionTes
         f = createResult(FAILURE, "Allowable actions don't match!");
         addResult(results, assertEquals(expected.getAllowableActions(), actual.getAllowableActions(),
null, f));
 
-        // TODO: compare ACLs
-        // TODO: compare renditions
-        // TODO: compare policies
-        // TODO: compare relationships
+        if (checkAcls) {
+            f = createResult(FAILURE, "ACLs don't match!");
+            addResult(results, assertEquals(expected.getAcl(), actual.getAcl(), null, f));
+        }
+
+        if (checkPolicies) {
+            f = createResult(FAILURE, "Policies don't match!");
+            addResult(results, assertEqualObjectList(expected.getPolicies(), actual.getPolicies(),
null, f));
+        }
+
+        f = createResult(FAILURE, "Relationships don't match!");
+        addResult(results, assertEqualObjectList(expected.getRelationships(), actual.getRelationships(),
null, f));
+
+        f = createResult(FAILURE, "Renditions don't match!");
+        addResult(results, assertEqualRenditionLists(expected.getRenditions(), actual.getRenditions(),
null, f));
+
+        if (getWorst(results).getLevel() <= OK.getLevel()) {
+            for (CmisTestResult result : results) {
+                addResultChild(success, result);
+            }
+
+            return success;
+        } else {
+            for (CmisTestResult result : results) {
+                addResultChild(failure, result);
+            }
+
+            return failure;
+        }
+    }
+
+    protected CmisTestResult assertEqualObjectList(List<? extends CmisObject> expected,
+            List<? extends CmisObject> actual, CmisTestResult success, CmisTestResult
failure) {
+
+        List<CmisTestResult> results = new ArrayList<CmisTestResult>();
+
+        CmisTestResult f;
+
+        if ((expected == null) && (actual == null)) {
+            return success;
+        }
+
+        if (expected == null) {
+            f = createResult(FAILURE, "Expected list of CMIS objects is null, but actual
list of CMIS objects is not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        if (actual == null) {
+            f = createResult(FAILURE, "Actual list of CMIS objects is null, but expected
list of CMIS objects is not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        if (expected.size() != actual.size()) {
+            addResult(
+                    results,
+                    createResult(
+                            CmisTestResultStatus.INFO,
+                            "Object list sizes don't match! expected: " + expected.size()
+ " / actual: "
+                                    + actual.size()));
+        } else {
+            for (int i = 0; i < expected.size(); i++) {
+                f = createResult(FAILURE, "Objects at position " + i + "  dont't match!");
+                addResult(results, assertEquals(expected.get(i), actual.get(i), null, f,
true, false));
+            }
+        }
 
         if (getWorst(results).getLevel() <= OK.getLevel()) {
             for (CmisTestResult result : results) {
@@ -2357,6 +2443,254 @@ public abstract class AbstractSessionTes
         }
     }
 
+    protected CmisTestResult assertEquals(Acl expected, Acl actual, CmisTestResult success,
CmisTestResult failure) {
+
+        List<CmisTestResult> results = new ArrayList<CmisTestResult>();
+
+        CmisTestResult f;
+
+        if ((expected == null) && (actual == null)) {
+            return success;
+        }
+
+        if (expected == null) {
+            f = createResult(FAILURE, "Expected ACL is null, but actual ACL is not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        if (actual == null) {
+            f = createResult(FAILURE, "Actual ACL is null, but expected ACL is not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        f = createResult(FAILURE, "ACEs don't match!");
+        addResult(results, assertEqualAceLists(expected.getAces(), actual.getAces(), null,
f));
+
+        f = createResult(FAILURE, "Exact flags dont't match!");
+        addResult(results, assertEquals(expected.isExact(), actual.isExact(), null, f));
+
+        if (getWorst(results).getLevel() <= OK.getLevel()) {
+            for (CmisTestResult result : results) {
+                addResultChild(success, result);
+            }
+
+            return success;
+        } else {
+            for (CmisTestResult result : results) {
+                addResultChild(failure, result);
+            }
+
+            return failure;
+        }
+    }
+
+    protected CmisTestResult assertEqualAceLists(List<Ace> expected, List<Ace>
actual, CmisTestResult success,
+            CmisTestResult failure) {
+
+        List<CmisTestResult> results = new ArrayList<CmisTestResult>();
+
+        CmisTestResult f;
+
+        if (expected == null && actual == null) {
+            return success;
+        }
+
+        if (expected == null) {
+            return addResultChild(failure, createResult(CmisTestResultStatus.INFO, "Expected
ACE list is null!"));
+        }
+
+        if (actual == null) {
+            return addResultChild(failure, createResult(CmisTestResultStatus.INFO, "Actual
ACE list is null!"));
+        }
+
+        if (expected.size() != actual.size()) {
+            addResult(
+                    results,
+                    createResult(CmisTestResultStatus.INFO, "ACE list sizes don't match!
expected: " + expected.size()
+                            + " / actual: " + actual.size()));
+        } else {
+            for (int i = 0; i < expected.size(); i++) {
+                f = createResult(FAILURE, "ACEs at position " + i + "  dont't match!");
+                addResult(results, assertEquals(expected.get(i), actual.get(i), null, f));
+            }
+        }
+
+        if (getWorst(results).getLevel() <= OK.getLevel()) {
+            for (CmisTestResult result : results) {
+                addResultChild(success, result);
+            }
+
+            return success;
+        } else {
+            for (CmisTestResult result : results) {
+                addResultChild(failure, result);
+            }
+
+            return failure;
+        }
+    }
+
+    protected CmisTestResult assertEquals(Ace expected, Ace actual, CmisTestResult success,
CmisTestResult failure) {
+
+        List<CmisTestResult> results = new ArrayList<CmisTestResult>();
+
+        CmisTestResult f;
+
+        if ((expected == null) && (actual == null)) {
+            return success;
+        }
+
+        if (expected == null) {
+            f = createResult(FAILURE, "Expected ACE is null, but actual ACE is not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        if (actual == null) {
+            f = createResult(FAILURE, "Actual ACE is null, but expected ACE is not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        f = createResult(FAILURE, "Principal ids dont't match!");
+        addResult(results, assertEquals(expected.getPrincipalId(), actual.getPrincipalId(),
null, f));
+
+        f = createResult(FAILURE, "Permissions dont't match!");
+        addResult(results, assertEqualLists(expected.getPermissions(), actual.getPermissions(),
null, f));
+
+        if (getWorst(results).getLevel() <= OK.getLevel()) {
+            for (CmisTestResult result : results) {
+                addResultChild(success, result);
+            }
+
+            return success;
+        } else {
+            for (CmisTestResult result : results) {
+                addResultChild(failure, result);
+            }
+
+            return failure;
+        }
+    }
+
+    protected CmisTestResult assertEqualRenditionLists(List<Rendition> expected, List<Rendition>
actual,
+            CmisTestResult success, CmisTestResult failure) {
+
+        List<CmisTestResult> results = new ArrayList<CmisTestResult>();
+
+        CmisTestResult f;
+
+        if (expected == null && actual == null) {
+            return success;
+        }
+
+        if (expected == null) {
+            return addResultChild(failure, createResult(CmisTestResultStatus.INFO, "Expected
rendition list is null!"));
+        }
+
+        if (actual == null) {
+            return addResultChild(failure, createResult(CmisTestResultStatus.INFO, "Actual
rendition list is null!"));
+        }
+
+        if (expected.size() != actual.size()) {
+            addResult(
+                    results,
+                    createResult(
+                            CmisTestResultStatus.INFO,
+                            "Rendition list sizes don't match! expected: " + expected.size()
+ " / actual: "
+                                    + actual.size()));
+        } else {
+            for (int i = 0; i < expected.size(); i++) {
+                f = createResult(FAILURE, "Renditions at position " + i + "  dont't match!");
+                addResult(results, assertEquals(expected.get(i), actual.get(i), null, f));
+            }
+        }
+
+        if (getWorst(results).getLevel() <= OK.getLevel()) {
+            for (CmisTestResult result : results) {
+                addResultChild(success, result);
+            }
+
+            return success;
+        } else {
+            for (CmisTestResult result : results) {
+                addResultChild(failure, result);
+            }
+
+            return failure;
+        }
+    }
+
+    protected CmisTestResult assertEquals(Rendition expected, Rendition actual, CmisTestResult
success,
+            CmisTestResult failure) {
+
+        List<CmisTestResult> results = new ArrayList<CmisTestResult>();
+
+        CmisTestResult f;
+
+        if ((expected == null) && (actual == null)) {
+            return success;
+        }
+
+        if (expected == null) {
+            f = createResult(FAILURE, "Expected rendition is null, but actual rendition is
not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        if (actual == null) {
+            f = createResult(FAILURE, "Actual rendition is null, but expected rendition is
not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        f = createResult(FAILURE, "Stream ids dont't match!");
+        addResult(results, assertEquals(expected.getStreamId(), actual.getStreamId(), null,
f));
+
+        f = createResult(FAILURE, "Kinds dont't match!");
+        addResult(results, assertEquals(expected.getKind(), actual.getKind(), null, f));
+
+        f = createResult(FAILURE, "MIME types dont't match!");
+        addResult(results, assertEquals(expected.getMimeType(), actual.getMimeType(), null,
f));
+
+        f = createResult(FAILURE, "Titles dont't match!");
+        addResult(results, assertEquals(expected.getTitle(), actual.getTitle(), null, f));
+
+        f = createResult(FAILURE, "Lengths dont't match!");
+        addResult(results, assertEquals(expected.getLength(), actual.getLength(), null, f));
+
+        f = createResult(FAILURE, "Heights dont't match!");
+        addResult(results, assertEquals(expected.getBigHeight(), actual.getBigHeight(), null,
f));
+
+        f = createResult(FAILURE, "Widths dont't match!");
+        addResult(results, assertEquals(expected.getBigWidth(), actual.getBigWidth(), null,
f));
+
+        f = createResult(FAILURE, "Rendition document ids dont't match!");
+        addResult(results, assertEquals(expected.getRenditionDocumentId(), actual.getRenditionDocumentId(),
null, f));
+
+        if (getWorst(results).getLevel() <= OK.getLevel()) {
+            for (CmisTestResult result : results) {
+                addResultChild(success, result);
+            }
+
+            return success;
+        } else {
+            for (CmisTestResult result : results) {
+                addResultChild(failure, result);
+            }
+
+            return failure;
+        }
+    }
+
     protected CmisTestResult assertEquals(ContentStream expected, ContentStream actual, CmisTestResult
success,
             CmisTestResult failure) {
 



Mime
View raw message