Search in sources :

Example 6 with ObjectData

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

the class PolicyActor method removePolicy.

private JSONObject removePolicy(PostRequest request) throws CmisInvalidArgumentException, CmisObjectNotFoundException, 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();
    CmisPolicyService.Impl.removePolicy(request.getRepositoryId(), request.getPolicyId(), objectId, request.getUserObject().getUserDN());
    ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), objectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_POLICY);
    if (object == null) {
        throw new CmisRuntimeException("Object is null!");
    }
    JSONObject jsonObject = JSONConverter.convert(object, null, 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 7 with ObjectData

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

the class VersioningActor method getObjectOfLatestVersion.

private JSONObject getObjectOfLatestVersion(QueryGetRequest request) throws CmisObjectNotFoundException, CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "get")) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    boolean majorVersion = request.getBooleanParameter(QueryGetRequest.PARAM_MAJOR, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    String objectId = request.getObjectId();
    String versionSeriesId = request.getParameter(QueryGetRequest.PARAM_VERSION_SERIES_ID);
    String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
    Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
    String renditionFilter = request.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
    Boolean includePolicyIds = request.getBooleanParameter(QueryGetRequest.PARAM_POLICY_IDS);
    Boolean includeAcl = request.getBooleanParameter(QueryGetRequest.PARAM_ACL);
    String userName = request.getUserName();
    ObjectData object = CmisVersioningServices.Impl.getObjectOfLatestVersion(request.getRepositoryId(), objectId, versionSeriesId, majorVersion, filter, includeAllowableActions, renditionFilter, includePolicyIds, includeAcl, null, null, userName);
    if (object == null) {
        throw new CmisRuntimeException("object is not present!");
    }
    JSONObject jsonObject = JSONConverter.convert(object, null, 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 8 with ObjectData

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

the class ServletHelpers method postToBaseMessage.

static BaseMessage postToBaseMessage(POSTHttpServletRequestWrapper request, String[] pathFragments, IUserObject userObject) {
    PostRequest postRequest = new PostRequest();
    ControlParser controlParser = new ControlParser(request);
    if (controlParser != null) {
        CmisRequestParameter requestParameter = new CmisRequestParameter();
        postRequest.setPropertyData(controlParser.getProperties());
        postRequest.setAddAcl(requestParameter.createAddAcl(controlParser, postRequest));
        postRequest.setRemoveAcl(requestParameter.createRemoveAcl(controlParser, postRequest));
        postRequest.setPolicies(requestParameter.createPolicies(controlParser, postRequest));
        postRequest.setMultipart(request.isMultiPart());
        postRequest.setContentStream(requestParameter.createContentStream(request));
        postRequest.setObjectIds(requestParameter.getObjectIds(controlParser, postRequest));
        postRequest.setChangeTokens(requestParameter.getChangeTokens(controlParser, postRequest));
        postRequest.setAddSecondaryTypes(requestParameter.addSecondaryTypes(controlParser, postRequest));
        postRequest.setRemoveSecondaryTypes(requestParameter.getChangeTokens(controlParser, postRequest));
        postRequest.setPolicyId(requestParameter.getPolicyId(controlParser, postRequest));
        postRequest.setAclPropagation(requestParameter.getAclPropagation(controlParser, postRequest));
    }
    postRequest.setParameterMap(request.getParameterMap());
    postRequest.setBaseUrl((String) request.getAttribute(BrowserConstants.BASE_URL_ATTRIBUTE));
    postRequest.setScheme(request.getScheme());
    postRequest.setServerName(request.getServerName());
    postRequest.setServerPort(request.getServerPort());
    postRequest.setContextPath(request.getContextPath());
    postRequest.setServletPath(request.getServletPath());
    String cmisAction = HttpUtils.getStringParameter(request, BrowserConstants.CONTROL_CMISACTION);
    postRequest.setCmisAction(cmisAction);
    String objectId = HttpUtils.getStringParameter(request, BrowserConstants.CONTROL_OBJECT_ID);
    postRequest.setObjectId(objectId);
    if (pathFragments.length > 0) {
        postRequest.setRepositoryId(pathFragments[0]);
        if (objectId != null) {
            ObjectData object = ServletHelpers.getObjectDataFor(pathFragments[0], objectId, pathFragments);
            String typeId = getStringPropertyValue(object, PropertyIds.OBJECT_TYPE_ID);
            postRequest.setTypeId(typeId);
            BaseTypeId baseTypeId = BaseTypeId.fromValue(getStringPropertyValue(object, PropertyIds.BASE_TYPE_ID));
            postRequest.setBaseTypeId(baseTypeId);
        }
    }
    String token = HttpUtils.getStringParameter(request, BrowserConstants.CONTROL_TOKEN);
    postRequest.setToken(token);
    postRequest.setRequestBody(request.getRequestBody());
    if (cmisAction == null || cmisAction.length() == 0) {
        throw new CmisNotSupportedException("Unknown action");
    }
    postRequest.setPathFragments(pathFragments);
    if (userObject != null) {
        postRequest.setUserName(userObject.getUserDN());
        postRequest.setUserObject(userObject);
    }
    BaseMessage bm = BaseMessage.create("", cmisAction, postRequest);
    return bm;
}
Also used : CmisNotSupportedException(org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException) PostRequest(com.pogeyan.cmis.api.messages.PostRequest) BaseMessage(com.pogeyan.cmis.api.BaseMessage) ControlParser(com.pogeyan.cmis.browser.shared.ControlParser) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) CmisRequestParameter(com.pogeyan.cmis.browser.shared.CmisRequestParameter)

Example 9 with ObjectData

use of org.apache.chemistry.opencmis.commons.data.ObjectData in project structr by structr.

the class CMISNavigationService method getObjectParents.

@Override
public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String propertyFilter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includeRelativePathSegment, ExtensionsData extension) {
    final App app = StructrApp.getInstance();
    try (final Tx tx = app.tx()) {
        final List<ObjectParentData> data = new LinkedList<>();
        final AbstractFile graphObject = app.get(AbstractFile.class, objectId);
        final Folder parent = graphObject.getParent();
        final ObjectData element = parent != null ? CMISObjectWrapper.wrap(parent, propertyFilter, includeAllowableActions) : new CMISRootFolder(propertyFilter, includeAllowableActions);
        final ObjectParentDataImpl impl = new ObjectParentDataImpl(element);
        impl.setRelativePathSegment(graphObject.getProperty(AbstractNode.name));
        data.add(impl);
        tx.success();
        return data;
    } catch (Throwable t) {
        logger.warn("", t);
    }
    return null;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) ObjectParentData(org.apache.chemistry.opencmis.commons.data.ObjectParentData) AbstractFile(org.structr.web.entity.AbstractFile) Tx(org.structr.core.graph.Tx) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) CMISRootFolder(org.structr.files.cmis.repository.CMISRootFolder) CMISRootFolder(org.structr.files.cmis.repository.CMISRootFolder) Folder(org.structr.web.entity.Folder) ObjectParentDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectParentDataImpl) LinkedList(java.util.LinkedList)

Example 10 with ObjectData

use of org.apache.chemistry.opencmis.commons.data.ObjectData in project structr by structr.

the class CMISObjectService method getObject.

@Override
public ObjectData getObject(final String repositoryId, final String objectId, final String propertyFilter, final Boolean includeAllowableActions, final IncludeRelationships includeRelationships, final String renditionFilter, final Boolean includePolicyIds, final Boolean includeAcl, final ExtensionsData extension) {
    final App app = StructrApp.getInstance();
    try (final Tx tx = app.tx()) {
        final AbstractNode obj = app.get(AbstractNode.class, objectId);
        if (obj != null) {
            final ObjectData data = CMISObjectWrapper.wrap(obj, propertyFilter, includeAllowableActions);
            tx.success();
            return data;
        }
    } catch (Throwable t) {
        logger.warn("", t);
    }
    throw new CmisObjectNotFoundException("Object with ID " + objectId + " does not exist");
}
Also used : App(org.structr.core.app.App) StructrApp(org.structr.core.app.StructrApp) Tx(org.structr.core.graph.Tx) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) AbstractNode(org.structr.core.entity.AbstractNode) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData)

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