Search in sources :

Example 26 with ObjectData

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

the class VersioningActor method checkOut.

private JSONObject checkOut(PostRequest request) throws CmisObjectNotFoundException, CmisUpdateConflictException, CmisNotSupportedException, CmisInvalidArgumentException, CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "post")) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    String objectId = request.getObjectId();
    boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    Holder<String> objectsId = new Holder<String>(objectId.toString());
    String pwcId = CmisVersioningServices.Impl.checkOut(request.getRepositoryId(), objectsId, null, null, request.getUserName());
    ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), pwcId, request.getUserName(), BaseTypeId.CMIS_DOCUMENT);
    if (object == null) {
        throw new CmisRuntimeException("New document is null!");
    }
    // return object
    JSONObject jsonObject = JSONConverter.convert(object, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
    return jsonObject;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) Holder(org.apache.chemistry.opencmis.commons.spi.Holder) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 27 with ObjectData

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

the class ServletHelpers method queryHttpToBaseMessage.

static BaseMessage queryHttpToBaseMessage(QueryStringHttpServletRequestWrapper request, String[] pathFragments, IUserObject userObject) {
    QueryGetRequest queryRequest = new QueryGetRequest();
    queryRequest.setParameterMap(request.getParameterMap());
    queryRequest.setBaseUrl((String) request.getAttribute(BrowserConstants.BASE_URL_ATTRIBUTE));
    queryRequest.setScheme(request.getScheme());
    queryRequest.setServerName(request.getServerName());
    queryRequest.setServerPort(request.getServerPort());
    queryRequest.setContextPath(request.getContextPath());
    queryRequest.setServletPath(request.getServletPath());
    queryRequest.setRange(request.getHeader("Range"));
    String objectId = HttpUtils.getStringParameter(request, BrowserConstants.PARAM_OBJECT_ID);
    queryRequest.setObjectId(objectId);
    if (userObject != null) {
        queryRequest.setUserName(userObject.getUserDN());
        queryRequest.setUserObject(userObject);
    }
    if (pathFragments.length > 0) {
        queryRequest.setRepositoryId(pathFragments[0]);
    }
    // selector is the actionName
    String selector = HttpUtils.getStringParameter(request, BrowserConstants.PARAM_SELECTOR);
    if (pathFragments.length > 1) {
        queryRequest.setPathFragments(pathFragments);
        // nested url
        String repositoryId = pathFragments[0];
        try {
            ObjectData object = null;
            // Example objectId format-typeID::primaryKey::primaryKeyValue
            if (objectId != null && objectId.contains("::")) {
                String[] inputs = objectId.split("::");
                // getObjectForRestAPI method is used to get the object.
                object = CmisObjectService.Impl.getObjectForRestAPI(repositoryId, inputs[0], inputs[1], inputs[2], "cmis:objectId,cmis:objectTypeId,cmis:baseTypeId", false, IncludeRelationships.NONE, "cmis:none", false, false, null, "");
            } else {
                object = ServletHelpers.getObjectDataFor(repositoryId, objectId, pathFragments);
            }
            // reset object id again here
            objectId = object.getId();
            queryRequest.setObjectId(objectId);
            String typeId = getStringPropertyValue(object, PropertyIds.OBJECT_TYPE_ID);
            queryRequest.setTypeId(typeId);
            BaseTypeId baseTypeId = BaseTypeId.fromValue(getStringPropertyValue(object, PropertyIds.BASE_TYPE_ID));
            queryRequest.setBaseTypeId(baseTypeId);
            if (selector == null) {
                switch(baseTypeId) {
                    case CMIS_DOCUMENT:
                        selector = BrowserConstants.SELECTOR_CONTENT;
                        break;
                    case CMIS_FOLDER:
                        selector = BrowserConstants.SELECTOR_CHILDREN;
                        break;
                    default:
                        selector = BrowserConstants.SELECTOR_OBJECT;
                        break;
                }
            }
        } catch (Exception e) {
            selector = BrowserConstants.SELECTOR_OBJECT;
        }
    }
    selector = selector == null ? "GetRepositories".toLowerCase() : selector;
    BaseMessage bm = BaseMessage.create("", selector, queryRequest);
    return bm;
}
Also used : BaseMessage(com.pogeyan.cmis.api.BaseMessage) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) QueryGetRequest(com.pogeyan.cmis.api.messages.QueryGetRequest) CmisStreamNotSupportedException(org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException) CmisContentAlreadyExistsException(org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException) CmisConstraintException(org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException) CmisPermissionDeniedException(org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) CmisServiceUnavailableException(org.apache.chemistry.opencmis.commons.exceptions.CmisServiceUnavailableException) CmisNameConstraintViolationException(org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException) CmisFilterNotValidException(org.apache.chemistry.opencmis.commons.exceptions.CmisFilterNotValidException) CmisTooManyRequestsException(org.apache.chemistry.opencmis.commons.exceptions.CmisTooManyRequestsException) CmisBaseException(org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException) CmisStorageException(org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException) CmisNotSupportedException(org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException) IOException(java.io.IOException) CmisUpdateConflictException(org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException) CmisVersioningException(org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException) CmisInvalidArgumentException(org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)

Example 28 with ObjectData

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

the class NavigationActor method getParent.

private JSONObject getParent(QueryGetRequest request) throws CmisInvalidArgumentException, CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "get")) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    String objectId = request.getObjectId();
    String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    ObjectData parent = CmisNavigationService.Impl.getFolderParent(request.getRepositoryId(), objectId, filter, null, request.getUserObject().getUserDN());
    if (parent == null) {
        throw new CmisRuntimeException("Parent is null!");
    }
    JSONObject jsonObject = JSONConverter.convert(parent, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
    return jsonObject;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 29 with ObjectData

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

the class AbstractSessionTest method checkObject.

protected CmisTestResult checkObject(Session session, CmisObject object, String[] properties, String message) {
    List<CmisTestResult> results = new ArrayList<CmisTestResult>();
    CmisTestResult f;
    f = createResult(FAILURE, "Object is null!", true);
    addResult(results, assertNotNull(object, null, f));
    if (object != null) {
        f = createResult(FAILURE, "Object ID is not set!");
        addResult(results, assertStringNotEmpty(object.getId(), null, f));
        GregorianCalendar creationDate = null;
        GregorianCalendar lastModificationDate = null;
        // properties
        for (String propId : properties) {
            Property<?> prop = object.getProperty(propId);
            // values of non-spec properties are not checked here
            PropertyCheckEnum propertyCheck = PropertyCheckEnum.NO_VALUE_CHECK;
            // known properties that are strings and must be set
            if (PropertyIds.OBJECT_ID.equals(propId) || PropertyIds.BASE_TYPE_ID.equals(propId) || PropertyIds.OBJECT_TYPE_ID.equals(propId) || PropertyIds.PATH.equals(propId) || PropertyIds.SOURCE_ID.equals(propId) || PropertyIds.TARGET_ID.equals(propId)) {
                propertyCheck = PropertyCheckEnum.STRING_MUST_NOT_BE_EMPTY;
            }
            if (!(object instanceof Relationship)) {
                if (PropertyIds.CREATED_BY.equals(propId) || PropertyIds.LAST_MODIFIED_BY.equals(propId)) {
                    propertyCheck = PropertyCheckEnum.STRING_MUST_NOT_BE_EMPTY;
                }
            }
            // known properties that are strings and should be set
            if (PropertyIds.NAME.equals(propId) || PropertyIds.POLICY_TEXT.equals(propId)) {
                propertyCheck = PropertyCheckEnum.STRING_SHOULD_NOT_BE_EMPTY;
            }
            // known properties that are not strings and must be set
            if (PropertyIds.IS_IMMUTABLE.equals(propId)) {
                propertyCheck = PropertyCheckEnum.MUST_BE_SET;
            }
            if (!(object instanceof Relationship)) {
                if (PropertyIds.CREATION_DATE.equals(propId) || PropertyIds.LAST_MODIFICATION_DATE.equals(propId)) {
                    propertyCheck = PropertyCheckEnum.MUST_BE_SET;
                }
            }
            // special case: parent
            if (PropertyIds.PARENT_ID.equals(propId)) {
                if (object instanceof Folder) {
                    if (((Folder) object).isRootFolder()) {
                        propertyCheck = PropertyCheckEnum.MUST_NOT_BE_SET;
                    } else {
                        propertyCheck = PropertyCheckEnum.STRING_MUST_NOT_BE_EMPTY;
                    }
                } else {
                    addResult(results, createResult(FAILURE, "Property " + PropertyIds.PARENT_ID + " is only defined for folders!"));
                }
            }
            // special case: path
            if (PropertyIds.PATH.equals(propId) && prop.getFirstValue() != null) {
                Object path = prop.getFirstValue();
                if (path instanceof String) {
                    f = createResult(FAILURE, "Path does not start with '/': " + path);
                    addResult(results, assertIsTrue(((String) path).length() > 0 && ((String) path).charAt(0) == '/', null, f));
                } else {
                    addResult(results, createResult(FAILURE, "Property " + PropertyIds.PATH + " is not a string!"));
                }
            }
            // check property
            addResult(results, checkProperty(prop, "Property " + propId, propertyCheck));
            // catch creationDate and lastModificationDate
            if (PropertyIds.CREATION_DATE.equals(propId)) {
                if (prop != null) {
                    creationDate = (GregorianCalendar) prop.getFirstValue();
                }
            } else if (PropertyIds.LAST_MODIFICATION_DATE.equals(propId)) {
                if (prop != null) {
                    lastModificationDate = (GregorianCalendar) prop.getFirstValue();
                }
            }
        }
        // check creationDate <= lastModificationDate
        if (creationDate != null && lastModificationDate != null) {
            f = createResult(FAILURE, "Last modification date precedes creation date!");
            addResult(results, assertIsTrue(creationDate.getTimeInMillis() <= lastModificationDate.getTimeInMillis(), null, f));
            f = createResult(WARNING, "Creation date and last modification date have different timezones.");
            addResult(assertIsTrue(creationDate.getTimeZone().hasSameRules(lastModificationDate.getTimeZone()), null, f));
        }
        // allowable actions
        if ((object.getAllowableActions() == null) || (object.getAllowableActions().getAllowableActions() == null)) {
            addResult(results, createResult(FAILURE, "Object has no allowable actions!"));
        } else {
            Set<Action> actions = object.getAllowableActions().getAllowableActions();
            f = createResult(FAILURE, "Object has no CAN_GET_PROPERTIES allowable action!");
            addResult(results, assertAllowableAction(object, Action.CAN_GET_PROPERTIES, null, f));
            addResult(results, assertIsTrue(object.hasAllowableAction(Action.CAN_GET_PROPERTIES), null, f));
            if (object instanceof Document) {
                if (actions.contains(Action.CAN_CHECK_OUT) && actions.contains(Action.CAN_CHECK_IN)) {
                    addResult(results, createResult(FAILURE, "Document object has CAN_CHECK_OUT and CAN_CHECK_IN allowable actions!"));
                }
                if (actions.contains(Action.CAN_CHECK_OUT) && actions.contains(Action.CAN_CANCEL_CHECK_OUT)) {
                    addResult(results, createResult(FAILURE, "Document object has CAN_CHECK_OUT and CAN_CANCEL_CHECK_OUT allowable actions!"));
                }
                Document doc = (Document) object;
                DocumentTypeDefinition docType = (DocumentTypeDefinition) doc.getType();
                if (doc.isVersionSeriesCheckedOut() != null) {
                    if (doc.isVersionSeriesCheckedOut()) {
                        f = createResult(WARNING, "Document is checked out and has CAN_CHECK_OUT allowable action!");
                        addResult(results, assertNotAllowableAction(object, Action.CAN_CHECK_OUT, null, f));
                        if (doc.getVersionSeriesCheckedOutId() == null) {
                            addResult(results, createResult(WARNING, "Document is checked out and but the property cmis:versionSeriesCheckedOutId is not set!"));
                        } else {
                            if (doc.getVersionSeriesCheckedOutId().equals(object.getId())) {
                                // object is PWC
                                f = createResult(FAILURE, "PWC doesn't have CAN_CHECK_IN allowable action!");
                                addResult(results, assertAllowableAction(object, Action.CAN_CHECK_IN, null, f));
                                f = createResult(FAILURE, "PWC doesn't have CAN_CANCEL_CHECK_OUT allowable action!");
                                addResult(results, assertAllowableAction(object, Action.CAN_CANCEL_CHECK_OUT, null, f));
                            } else {
                                // object is not PWC
                                f = createResult(WARNING, "Non-PWC has CAN_CHECK_IN allowable action!");
                                addResult(results, assertNotAllowableAction(object, Action.CAN_CHECK_IN, null, f));
                                f = createResult(WARNING, "Non-PWC has CAN_CANCEL_CHECK_OUT allowable action!");
                                addResult(results, assertNotAllowableAction(object, Action.CAN_CANCEL_CHECK_OUT, null, f));
                            }
                        }
                    } else {
                        f = createResult(FAILURE, "Document is not checked out and has CAN_CHECK_IN allowable action!");
                        addResult(results, assertNotAllowableAction(object, Action.CAN_CHECK_IN, null, f));
                        f = createResult(FAILURE, "Document is not checked out and has CAN_CANCEL_CHECK_OUT allowable action!");
                        addResult(results, assertNotAllowableAction(object, Action.CAN_CANCEL_CHECK_OUT, null, f));
                        // versionable check
                        if (docType.isVersionable()) {
                            // 
                            if (Boolean.TRUE.equals(doc.isLatestVersion())) {
                                f = createResult(WARNING, "Document is versionable and not checked but has no CAN_CHECK_OUT allowable action!");
                                addResult(results, assertAllowableAction(object, Action.CAN_CHECK_OUT, null, f));
                            }
                        } else {
                            f = createResult(FAILURE, "Document is not versionable but has CAN_CHECK_OUT allowable action!");
                            addResult(results, assertNotAllowableAction(object, Action.CAN_CHECK_OUT, null, f));
                        }
                    }
                } else {
                    addResult(results, createResult(WARNING, "Property cmis:isVersionSeriesCheckedOut is not set!"));
                }
                // immutable check
                if (Boolean.TRUE.equals(doc.isImmutable())) {
                    f = createResult(FAILURE, "Document is immutable and has CAN_UPDATE_PROPERTIES allowable action!");
                    addResult(results, assertNotAllowableAction(object, Action.CAN_UPDATE_PROPERTIES, null, f));
                    f = createResult(FAILURE, "Document is immutable and has CAN_DELETE_OBJECT allowable action!");
                    addResult(results, assertNotAllowableAction(object, Action.CAN_DELETE_OBJECT, null, f));
                }
            } else {
                f = createResult(FAILURE, "Non-Document object has CAN_CHECK_IN allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_CHECK_IN, null, f));
                f = createResult(FAILURE, "Non-Document object has CAN_CHECK_OUT allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_CHECK_OUT, null, f));
                f = createResult(FAILURE, "Non-Document object has CAN_CANCEL_CHECK_OUT allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_CANCEL_CHECK_OUT, null, f));
                f = createResult(FAILURE, "Non-Document object has CAN_GET_CONTENT_STREAM allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_GET_CONTENT_STREAM, null, f));
                f = createResult(FAILURE, "Non-Document object has CAN_DELETE_CONTENT_STREAM allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_DELETE_CONTENT_STREAM, null, f));
                f = createResult(FAILURE, "Non-Document object has CAN_GET_ALL_VERSIONS allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_GET_ALL_VERSIONS, null, f));
            }
            if (object instanceof Folder) {
                Folder folder = (Folder) object;
                if (folder.isRootFolder()) {
                    f = createResult(FAILURE, "Root folder has CAN_DELETE_OBJECT allowable action!");
                    addResult(results, assertNotAllowableAction(object, Action.CAN_DELETE_OBJECT, null, f));
                    f = createResult(FAILURE, "Root folder has CAN_GET_FOLDER_PARENT allowable action!");
                    addResult(results, assertNotAllowableAction(object, Action.CAN_GET_FOLDER_PARENT, null, f));
                    f = createResult(FAILURE, "Root folder has CAN_MOVE_OBJECT allowable action!");
                    addResult(results, assertNotAllowableAction(object, Action.CAN_MOVE_OBJECT, null, f));
                }
            } else {
                f = createResult(FAILURE, "Non-Folder object has CAN_GET_DESCENDANTS allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_GET_DESCENDANTS, null, f));
                f = createResult(FAILURE, "Non-Folder object has CAN_GET_FOLDER_PARENT allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_GET_FOLDER_PARENT, null, f));
                f = createResult(FAILURE, "Non-Folder object has CAN_GET_CHILDREN allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_GET_CHILDREN, null, f));
                f = createResult(FAILURE, "Non-Folder object has CAN_DELETE_TREE allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_DELETE_TREE, null, f));
                f = createResult(FAILURE, "Non-Folder object has CAN_GET_FOLDER_PARENT allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_GET_FOLDER_PARENT, null, f));
                f = createResult(FAILURE, "Non-Folder object has CAN_CREATE_DOCUMENT allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_CREATE_DOCUMENT, null, f));
                f = createResult(FAILURE, "Non-Folder object has CAN_CREATE_FOLDER allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_CREATE_FOLDER, null, f));
            }
            if (!(object instanceof FileableCmisObject) || (object instanceof Folder)) {
                f = createResult(FAILURE, "Non-Filable object or folder has CAN_ADD_OBJECT_TO_FOLDER allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_ADD_OBJECT_TO_FOLDER, null, f));
                f = createResult(FAILURE, "Non-Filable object or folder has CAN_REMOVE_OBJECT_FROM_FOLDER allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_REMOVE_OBJECT_FROM_FOLDER, null, f));
            }
            if (!(object instanceof FileableCmisObject)) {
                f = createResult(FAILURE, "Non-Fileable object has CAN_MOVE_OBJECT allowable action!");
                addResult(results, assertNotAllowableAction(object, Action.CAN_MOVE_OBJECT, null, f));
            }
            // get allowable actions again
            AllowableActions allowableActions = session.getBinding().getObjectService().getAllowableActions(session.getRepositoryInfo().getId(), object.getId(), null);
            if (allowableActions.getAllowableActions() == null) {
                addResult(results, createResult(FAILURE, "getAllowableActions() didn't returned allowable actions!"));
            } else {
                f = createResult(FAILURE, "Object allowable actions don't match the allowable actions returned by getAllowableActions()!");
                addResult(results, assertEqualSet(object.getAllowableActions().getAllowableActions(), allowableActions.getAllowableActions(), null, f));
            }
        }
        // check ACL
        if (object.getAcl() != null && object.getAcl().getAces() != null) {
            addResult(results, checkACL(session, object.getAcl(), true, "ACL"));
        }
        // check policies
        if (hasPolicies(session)) {
            try {
                List<ObjectData> appliedPolicies = session.getBinding().getPolicyService().getAppliedPolicies(session.getRepositoryInfo().getId(), object.getId(), "*", null);
                if (appliedPolicies == null) {
                    appliedPolicies = Collections.emptyList();
                }
                List<Policy> objectPolicies = object.getPolicies();
                if (objectPolicies == null) {
                    objectPolicies = Collections.emptyList();
                }
                f = createResult(FAILURE, "The number of policies returned by getAppliedPolicies() and the number of object policies don't match!");
                addResult(results, assertEquals(appliedPolicies.size(), objectPolicies.size(), null, f));
            } catch (CmisNotSupportedException e) {
                addResult(results, createResult(WARNING, "getAppliedPolicies() not supported for object: " + object.getId()));
            }
        }
        // check relationships
        checkRelationships(session, results, object);
        // check document content
        checkDocumentContent(session, results, object);
        // check renditions
        if (object.getRenditions() != null) {
            addResult(results, checkRenditions(session, object, "Rendition check"));
        }
        // check allowed child object type ids
        if (object instanceof Folder) {
            List<String> otids = object.getPropertyValue(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
            if (otids != null) {
                for (String otid : otids) {
                    try {
                        session.getTypeDefinition(otid);
                    } catch (CmisBaseException e) {
                        addResult(results, createResult(FAILURE, "The cmis:allowedChildObjectTypeIds property contains the type ID '" + otid + "' but the type doesn't exists. Folder ID: " + object.getId()));
                    }
                }
            }
        }
        // check path
        if (object instanceof FileableCmisObject) {
            List<String> paths = ((FileableCmisObject) object).getPaths();
            if (object instanceof Folder) {
                f = createResult(FAILURE, "Folder does not have excatly one path! This is an OpenCMIS bug!");
                addResult(results, assertEquals(1, paths.size(), null, f));
            } else {
                if (Boolean.FALSE.equals(session.getRepositoryInfo().getCapabilities().isMultifilingSupported())) {
                    f = createResult(FAILURE, "Repository does not support multi-filing, but the object has more than one parent!");
                    addResult(results, assertIsTrue(paths.size() < 2, null, f));
                }
            }
        }
    }
    CmisTestResultImpl result = createResult(getWorst(results), message);
    result.getChildren().addAll(results);
    return result.getStatus().getLevel() <= OK.getLevel() ? null : result;
}
Also used : Policy(org.apache.chemistry.opencmis.client.api.Policy) CmisNotSupportedException(org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException) Action(org.apache.chemistry.opencmis.commons.enums.Action) DocumentTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition) ArrayList(java.util.ArrayList) GregorianCalendar(java.util.GregorianCalendar) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) Folder(org.apache.chemistry.opencmis.client.api.Folder) Document(org.apache.chemistry.opencmis.client.api.Document) CmisBaseException(org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException) CmisTestResult(org.apache.chemistry.opencmis.tck.CmisTestResult) Relationship(org.apache.chemistry.opencmis.client.api.Relationship) AllowableActions(org.apache.chemistry.opencmis.commons.data.AllowableActions) FileableCmisObject(org.apache.chemistry.opencmis.client.api.FileableCmisObject) CmisObject(org.apache.chemistry.opencmis.client.api.CmisObject) FileableCmisObject(org.apache.chemistry.opencmis.client.api.FileableCmisObject)

Example 30 with ObjectData

use of org.apache.chemistry.opencmis.commons.data.ObjectData 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

ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)32 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)23 DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)22 JSONObject (org.apache.chemistry.opencmis.commons.impl.json.JSONObject)20 Properties (org.apache.chemistry.opencmis.commons.data.Properties)8 Holder (org.apache.chemistry.opencmis.commons.spi.Holder)7 IUserGroupObject (com.pogeyan.cmis.api.auth.IUserGroupObject)6 Acl (org.apache.chemistry.opencmis.commons.data.Acl)6 CmisNotSupportedException (org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException)3 CmisTestResult (org.apache.chemistry.opencmis.tck.CmisTestResult)3 App (org.structr.core.app.App)3 StructrApp (org.structr.core.app.StructrApp)3 Tx (org.structr.core.graph.Tx)3 BaseMessage (com.pogeyan.cmis.api.BaseMessage)2 IBaseObject (com.pogeyan.cmis.api.data.IBaseObject)2 ArrayList (java.util.ArrayList)2 Document (org.apache.chemistry.opencmis.client.api.Document)2 Folder (org.apache.chemistry.opencmis.client.api.Folder)2 Policy (org.apache.chemistry.opencmis.client.api.Policy)2 ObjectParentData (org.apache.chemistry.opencmis.commons.data.ObjectParentData)2