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;
}
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;
}
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;
}
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;
}
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");
}
Aggregations