use of org.apache.chemistry.opencmis.commons.data.ObjectData in project structr by structr.
the class CMISObjectService method getObjectByPath.
@Override
public ObjectData getObjectByPath(final String repositoryId, final String path, final String propertyFilter, final Boolean includeAllowableActions, final IncludeRelationships includeRelationships, final String renditionFilter, final Boolean includePolicyIds, final Boolean includeAcl, final ExtensionsData extension) {
final PropertyKey<String> pathKey = StructrApp.key(AbstractFile.class, "path");
final App app = StructrApp.getInstance();
ObjectData result = null;
try (final Tx tx = app.tx()) {
final AbstractFile file = app.nodeQuery(AbstractFile.class).and(pathKey, path).getFirst();
if (file != null) {
result = CMISObjectWrapper.wrap(file, propertyFilter, includeAllowableActions);
}
tx.success();
} catch (Throwable t) {
logger.warn("", t);
}
if (result != null) {
return result;
}
throw new CmisObjectNotFoundException("Object with path " + path + " does not exist");
}
use of org.apache.chemistry.opencmis.commons.data.ObjectData in project iaf by ibissource.
the class ObjectServiceImpl method getObject.
@Override
public ObjectData getObject(String repositoryId, String objectId, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extensions) {
boolean bypass = AppConstants.getInstance().getBoolean("cmis.proxy.bypass.getObject", false);
if (!bypass) {
ObjectData objectData = objectService.getObject(repositoryId, objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, extensions);
return objectData;
} else {
XmlBuilder cmisXml = new XmlBuilder("cmis");
cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
cmisXml.addSubElement(buildXml("objectId", objectId));
cmisXml.addSubElement(buildXml("filter", filter));
cmisXml.addSubElement(buildXml("includeAllowableActions", includeAllowableActions));
cmisXml.addSubElement(buildXml("includePolicies", includePolicyIds));
cmisXml.addSubElement(buildXml("includeAcl", includeAcl));
ObjectDataImpl impl = new ObjectDataImpl();
try {
IPipeLineSession messageContext = new PipeLineSessionBase();
String result = CmisServletDispatcher.getInstance().getCmisListener().processRequest(null, cmisXml.toXML(), messageContext);
Element cmisElement;
if (XmlUtils.isWellFormed(result, "cmis")) {
cmisElement = XmlUtils.buildElement(result);
} else {
cmisElement = XmlUtils.buildElement("<cmis/>");
}
// Handle allowable actions
Element allowableActionsElem = XmlUtils.getFirstChildTag(cmisElement, "allowableActions");
if (allowableActionsElem != null) {
AllowableActionsImpl allowableActions = new AllowableActionsImpl();
Set<Action> actions = EnumSet.noneOf(Action.class);
Iterator<Node> actionIterator = XmlUtils.getChildTags(allowableActionsElem, "action").iterator();
while (actionIterator.hasNext()) {
String property = XmlUtils.getStringValue((Element) actionIterator.next());
actions.add(Action.fromValue(property));
}
allowableActions.setAllowableActions(actions);
impl.setAllowableActions(allowableActions);
}
// Handle isExactAcl
impl.setIsExactAcl(XmlUtils.getChildTagAsBoolean(cmisElement, "isExactAcl"));
// Handle policyIds
Element policyIdsElem = XmlUtils.getFirstChildTag(cmisElement, "policyIds");
if (policyIdsElem != null) {
PolicyIdListImpl policyIdList = new PolicyIdListImpl();
List<String> policies = new ArrayList<String>();
Iterator<Node> policyIterator = XmlUtils.getChildTags(allowableActionsElem, "policyId").iterator();
while (policyIterator.hasNext()) {
String policyId = XmlUtils.getStringValue((Element) policyIterator.next());
policies.add(policyId);
}
policyIdList.setPolicyIds(policies);
impl.setPolicyIds(policyIdList);
}
// Handle properties
impl.setProperties(processProperties(cmisElement));
} catch (Exception e) {
log.error("error creating CMIS objectData: " + e.getMessage(), e.getCause());
}
impl.setRenditions(null);
impl.setExtensions(null);
impl.setChangeEventInfo(null);
impl.setRelationships(null);
return impl;
}
}
use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.
the class ObjectActor method appendContent.
private JSONObject appendContent(PostRequest request) throws 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();
String changeToken = request.getParameter(QueryGetRequest.PARAM_CHANGE_TOKEN);
boolean isLastChunk = request.getBooleanParameter(QueryGetRequest.CONTROL_IS_LAST_CHUNK, false);
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
Holder<String> objectIdHolder = new Holder<String>(objectId);
Holder<String> changeTokenHolder = (changeToken == null ? null : new Holder<String>(changeToken));
if (request.getContentStream() == null) {
CmisObjectService.Impl.appendContentStream(request.getRepositoryId(), objectIdHolder, changeTokenHolder, null, isLastChunk);
} else {
CmisObjectService.Impl.appendContentStream(request.getRepositoryId(), objectIdHolder, changeTokenHolder, request.getContentStream(), isLastChunk);
}
String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_DOCUMENT);
if (object == null) {
throw new CmisRuntimeException("Object is null!");
}
// return object
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.
the class ObjectActor method update.
@SuppressWarnings("unused")
private JSONObject update(PostRequest request) throws CmisRuntimeException, CmisObjectNotFoundException, CmisRuntimeException, CmisUpdateConflictException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String objectId = request.getObjectId();
IBaseObject data = DBUtils.BaseDAO.getByObjectId(request.getRepositoryId(), objectId, null);
String typeId = CmisPropertyConverter.Impl.getTypeIdForObject(request.getRepositoryId(), objectId);
String changeToken = request.getParameter(QueryGetRequest.CONTROL_CHANGE_TOKEN);
String token = request.getParameter(QueryGetRequest.PARAM_TOKEN);
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
Holder<String> objectIdHolder = new Holder<String>(objectId.toString());
Holder<String> changeTokenHolder = (changeToken == null ? null : new Holder<String>(changeToken));
Properties properties = CmisPropertyConverter.Impl.createUpdateProperties(request.getPropertyData(), typeId, null, Collections.singletonList(objectId.toString()), request.getRepositoryId(), data);
CmisObjectService.Impl.updateProperties(request.getRepositoryId(), objectIdHolder, changeTokenHolder, properties, null, null, request.getUserObject());
String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), request.getBaseTypeId());
if (object == null) {
throw new CmisRuntimeException("Object is null!");
}
// return object
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.
the class ObjectActor method createItem.
private JSONObject createItem(PostRequest request) throws CmisInvalidArgumentException, CmisObjectNotFoundException, IllegalArgumentException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
String principalId = request.getUserObject().getUserDN();
IUserGroupObject[] groups = request.getUserObject().getGroups();
if (!Helpers.getGroupPermission(permission, groups)) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String folderId = request.getObjectId() != null ? request.getObjectId() : null;
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
Properties prop = CmisPropertyConverter.Impl.createNewProperties(request.getPropertyData(), request.getRepositoryId());
Acl aclImp = CmisUtils.Object.getAcl(request.getAddAcl(), principalId, permission);
String newObjectId = CmisObjectService.Impl.createItem(request.getRepositoryId(), prop, folderId, request.getPolicies(), aclImp, request.getRemoveAcl(), request.getUserObject().getUserDN());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_ITEM);
if (object == null) {
throw new CmisRuntimeException("New folder is null!");
}
// return object
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
return jsonObject;
}
Aggregations