Search in sources :

Example 1 with ControlParser

use of com.pogeyan.cmis.browser.shared.ControlParser 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)

Aggregations

BaseMessage (com.pogeyan.cmis.api.BaseMessage)1 PostRequest (com.pogeyan.cmis.api.messages.PostRequest)1 CmisRequestParameter (com.pogeyan.cmis.browser.shared.CmisRequestParameter)1 ControlParser (com.pogeyan.cmis.browser.shared.ControlParser)1 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)1 BaseTypeId (org.apache.chemistry.opencmis.commons.enums.BaseTypeId)1 CmisNotSupportedException (org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException)1