Search in sources :

Example 1 with ObjectInFolderData

use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderData in project copper-cms by PogeyanOSS.

the class AbstractSessionTest method checkChildren.

protected CmisTestResult checkChildren(Session session, Folder folder, String message) {
    List<CmisTestResult> results = new ArrayList<CmisTestResult>();
    CmisTestResult f;
    if (folder == null) {
        return createResult(FAILURE, "Folder is null!");
    }
    // getChildren
    boolean supportsOrderByName = isOrderByNameSupported(session);
    OperationContext orderContext = (supportsOrderByName ? SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME : SELECT_ALL_NO_CACHE_OC);
    long childrenCount = 0;
    long childrenFolderCount = 0;
    ItemIterable<CmisObject> children = folder.getChildren(orderContext);
    int orderByNameIssues = 0;
    String lastName = null;
    for (CmisObject child : children) {
        childrenCount++;
        if (child instanceof Folder) {
            childrenFolderCount++;
        }
        checkChild(session, results, folder, child);
        if (lastName != null && child.getName() != null) {
            if (child.getName().compareToIgnoreCase(lastName) < 0) {
                orderByNameIssues++;
            }
        }
        lastName = child.getName();
    }
    if (children.getTotalNumItems() >= 0) {
        f = createResult(WARNING, "Number of children doesn't match the reported total number of items!");
        addResult(results, assertEquals(childrenCount, children.getTotalNumItems(), null, f));
    } else {
        addResult(results, createResult(WARNING, "getChildren did not report the total number of items!"));
    }
    if (supportsOrderByName) {
        f = createResult(WARNING, "Children should be ordered by cmis:name, but they are not! (It might be a collation mismtach.)");
        addResult(results, assertEquals(0, orderByNameIssues, null, f));
    } else {
        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);
    if (pathSegementChildren != null && pathSegementChildren.getObjects() != 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));
            }
        }
    }
    if (isGetDescendantsSupported(session)) {
        long descendantsCount = 0;
        List<Tree<FileableCmisObject>> descendants = folder.getDescendants(1, SELECT_ALL_NO_CACHE_OC);
        for (Tree<FileableCmisObject> child : descendants) {
            descendantsCount++;
            if (child == null) {
                addResult(results, createResult(FAILURE, "Folder descendants contain a null tree!"));
            } else {
                checkChild(session, results, folder, child.getItem());
            }
        }
        f = createResult(FAILURE, "Number of descendants doesn't match the number of children returned by getChildren!");
        addResult(results, assertEquals(childrenCount, descendantsCount, null, f));
    } else {
        addResult(results, createResult(SKIPPED, "getDescendants is not supported."));
    }
    if (isGetFolderTreeSupported(session)) {
        long folderTreeCount = 0;
        List<Tree<FileableCmisObject>> folderTree = folder.getFolderTree(1, SELECT_ALL_NO_CACHE_OC);
        for (Tree<FileableCmisObject> child : folderTree) {
            folderTreeCount++;
            if (child == null) {
                addResult(results, createResult(FAILURE, "Folder tree contains a null tree!"));
            } else {
                checkChild(session, results, folder, child.getItem());
            }
        }
        f = createResult(FAILURE, "Number of folders doesn't match the number of folders returned by getChildren!");
        addResult(results, assertEquals(childrenFolderCount, folderTreeCount, null, f));
    } else {
        addResult(results, createResult(SKIPPED, "getFolderTree is not supported."));
    }
    // --- wrap up ---
    CmisTestResultImpl result = createResult(getWorst(results), message);
    result.getChildren().addAll(results);
    return result.getStatus().getLevel() <= OK.getLevel() ? null : result;
}
Also used : OperationContext(org.apache.chemistry.opencmis.client.api.OperationContext) ArrayList(java.util.ArrayList) Folder(org.apache.chemistry.opencmis.client.api.Folder) ObjectInFolderList(org.apache.chemistry.opencmis.commons.data.ObjectInFolderList) CmisTestResult(org.apache.chemistry.opencmis.tck.CmisTestResult) Tree(org.apache.chemistry.opencmis.client.api.Tree) FileableCmisObject(org.apache.chemistry.opencmis.client.api.FileableCmisObject) CmisObject(org.apache.chemistry.opencmis.client.api.CmisObject) FileableCmisObject(org.apache.chemistry.opencmis.client.api.FileableCmisObject) ObjectInFolderData(org.apache.chemistry.opencmis.commons.data.ObjectInFolderData)

Example 2 with ObjectInFolderData

use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderData in project copper-cms by PogeyanOSS.

the class OperationContextTest method runLowLevelApiTests.

/**
 * Checks for change events and path segments.
 */
public void runLowLevelApiTests(Session session, Folder testFolder, Document testDocument) {
    CmisTestResult f;
    String repositoryId = session.getRepositoryInfo().getId();
    String filter = "cmis:objectId,cmis:baseTypeId,cmis:objectTypeId";
    // get the object
    ObjectData doc1 = session.getBinding().getObjectService().getObject(repositoryId, testDocument.getId(), filter, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, Boolean.FALSE, null);
    // check for change events
    f = createResult(CmisTestResultStatus.WARNING, "getObject() delivered a change event, which doesn't make sense.");
    addResult(assertNull(doc1.getChangeEventInfo(), null, f));
    // get the test folder children
    ObjectInFolderList children = session.getBinding().getNavigationService().getChildren(repositoryId, testFolder.getId(), filter, null, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null, BigInteger.ZERO, null);
    // check for path segments
    for (ObjectInFolderData child : children.getObjects()) {
        f = createResult(CmisTestResultStatus.WARNING, "getChildren() delivered a path segment, although it hasn't been requested.");
        addResult(assertNull(child.getPathSegment(), null, f));
    }
    // get the document parent
    List<ObjectParentData> parents = session.getBinding().getNavigationService().getObjectParents(repositoryId, testDocument.getId(), filter, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null);
    // check for relative path segments
    for (ObjectParentData parent : parents) {
        f = createResult(CmisTestResultStatus.WARNING, "getObjectParents() delivered a relative path segment, although it hasn't been requested.");
        addResult(assertNull(parent.getRelativePathSegment(), null, f));
    }
}
Also used : ObjectParentData(org.apache.chemistry.opencmis.commons.data.ObjectParentData) ObjectInFolderList(org.apache.chemistry.opencmis.commons.data.ObjectInFolderList) CmisTestResult(org.apache.chemistry.opencmis.tck.CmisTestResult) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) ObjectInFolderData(org.apache.chemistry.opencmis.commons.data.ObjectInFolderData)

Aggregations

ObjectInFolderData (org.apache.chemistry.opencmis.commons.data.ObjectInFolderData)2 ObjectInFolderList (org.apache.chemistry.opencmis.commons.data.ObjectInFolderList)2 CmisTestResult (org.apache.chemistry.opencmis.tck.CmisTestResult)2 ArrayList (java.util.ArrayList)1 CmisObject (org.apache.chemistry.opencmis.client.api.CmisObject)1 FileableCmisObject (org.apache.chemistry.opencmis.client.api.FileableCmisObject)1 Folder (org.apache.chemistry.opencmis.client.api.Folder)1 OperationContext (org.apache.chemistry.opencmis.client.api.OperationContext)1 Tree (org.apache.chemistry.opencmis.client.api.Tree)1 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)1 ObjectParentData (org.apache.chemistry.opencmis.commons.data.ObjectParentData)1