Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B00808FEE for ; Sun, 28 Aug 2011 15:48:43 +0000 (UTC) Received: (qmail 2944 invoked by uid 500); 28 Aug 2011 15:48:43 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 2900 invoked by uid 500); 28 Aug 2011 15:48:43 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 2892 invoked by uid 99); 28 Aug 2011 15:48:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Aug 2011 15:48:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Aug 2011 15:48:38 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2801F2388A02; Sun, 28 Aug 2011 15:48:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110828154816.2801F2388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 getParents(); /** + * Returns the parents of this object. + */ + List getParents(OperationContext context); + + /** * Returns the paths of this object. */ List 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 getParents() { + return getParents(getSession().getDefaultContext()); + } + + public List 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 objectIdHolder = new Holder(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 getParents() { + public List 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 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 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 results = new ArrayList(); @@ -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 expected, + List actual, CmisTestResult success, CmisTestResult failure) { + + List results = new ArrayList(); + + 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 results = new ArrayList(); + + 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 expected, List actual, CmisTestResult success, + CmisTestResult failure) { + + List results = new ArrayList(); + + 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 results = new ArrayList(); + + 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 expected, List actual, + CmisTestResult success, CmisTestResult failure) { + + List results = new ArrayList(); + + 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 results = new ArrayList(); + + 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) {