use of org.apache.chemistry.opencmis.commons.data.Properties in project alfresco-remote-api by Alfresco.
the class RepoService method getProperties.
/*
* Get (CMIS) node properties
*/
private Properties getProperties(NodeRef nodeRef) {
CMISNodeInfoImpl nodeInfo = cmisConnector.createNodeInfo(nodeRef);
final Properties properties = cmisConnector.getNodeProperties(nodeInfo, null);
// fake the title property, which CMIS doesn't give us
String title = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE);
final PropertyStringImpl titleProp = new PropertyStringImpl(ContentModel.PROP_TITLE.toString(), title);
Properties wrapProperties = new Properties() {
@Override
public List<CmisExtensionElement> getExtensions() {
return properties.getExtensions();
}
@Override
public void setExtensions(List<CmisExtensionElement> extensions) {
properties.setExtensions(extensions);
}
@Override
public Map<String, PropertyData<?>> getProperties() {
Map<String, PropertyData<?>> updatedProperties = new HashMap<String, PropertyData<?>>(properties.getProperties());
updatedProperties.put(titleProp.getId(), titleProp);
return updatedProperties;
}
@Override
public List<PropertyData<?>> getPropertyList() {
List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>(properties.getPropertyList());
propertyList.add(titleProp);
return propertyList;
}
};
return wrapProperties;
}
use of org.apache.chemistry.opencmis.commons.data.Properties 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.Properties 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;
}
use of org.apache.chemistry.opencmis.commons.data.Properties in project copper-cms by PogeyanOSS.
the class ObjectActor method createRelationship.
private JSONObject createRelationship(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.");
}
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
Properties prop = CmisPropertyConverter.Impl.createNewProperties(request.getPropertyData(), request.getRepositoryId());
String folderId = request.getObjectId() != null ? request.getObjectId() : null;
Acl aclImp = CmisUtils.Object.getAcl(request.getAddAcl(), principalId, permission);
String newObjectId = CmisObjectService.Impl.createRelationship(request.getRepositoryId(), folderId, prop, request.getPolicies(), aclImp, request.getRemoveAcl(), request.getUserObject().getUserDN());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_RELATIONSHIP);
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;
}
use of org.apache.chemistry.opencmis.commons.data.Properties in project copper-cms by PogeyanOSS.
the class ObjectActor method createPolicy.
private JSONObject createPolicy(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.createPolicy(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_POLICY);
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