use of com.pogeyan.cmis.api.messages.PostRequest 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;
}
Aggregations