use of org.apache.chemistry.opencmis.commons.data.PropertyData in project iaf by ibissource.
the class IbisObjectService method updateProperties.
@Override
public void updateProperties(String repositoryId, Holder<String> objectId, Holder<String> changeToken, Properties properties, ExtensionsData extension) {
if (!eventDispatcher.contains(CmisEvent.UPDATE_PROPERTIES)) {
objectService.updateProperties(repositoryId, objectId, changeToken, properties, extension);
} else {
XmlBuilder cmisXml = new XmlBuilder("cmis");
cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
if (objectId != null)
cmisXml.addSubElement(buildXml("objectId", objectId.getValue()));
if (changeToken != null)
cmisXml.addSubElement(buildXml("changeToken", changeToken.getValue()));
XmlBuilder propertiesXml = new XmlBuilder("properties");
for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext(); ) {
propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
}
cmisXml.addSubElement(propertiesXml);
eventDispatcher.trigger(CmisEvent.UPDATE_PROPERTIES, cmisXml.toXML(), callContext);
}
}
use of org.apache.chemistry.opencmis.commons.data.PropertyData 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.PropertyData in project iaf by ibissource.
the class CmisUtils method objectData2Xml.
/**
* @param object to translate to xml
* @param cmisXml root XML element (defaults to creating a new 'objectData' element)
* @return the root XML element
*/
public static XmlBuilder objectData2Xml(ObjectData object, XmlBuilder cmisXml) {
if (object.getProperties() != null) {
XmlBuilder propertiesXml = new XmlBuilder("properties");
for (Iterator<PropertyData<?>> it = object.getProperties().getPropertyList().iterator(); it.hasNext(); ) {
propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
}
cmisXml.addSubElement(propertiesXml);
}
if (object.getAllowableActions() != null) {
XmlBuilder allowableActionsXml = new XmlBuilder("allowableActions");
Set<Action> actions = object.getAllowableActions().getAllowableActions();
for (Action action : actions) {
XmlBuilder actionXml = new XmlBuilder("action");
actionXml.setValue(action.value());
allowableActionsXml.addSubElement(actionXml);
}
cmisXml.addSubElement(allowableActionsXml);
}
if (object.getAcl() != null) {
XmlBuilder isExactAclXml = new XmlBuilder("isExactAcl");
isExactAclXml.setValue(object.getAcl().isExact().toString());
cmisXml.addSubElement(isExactAclXml);
}
cmisXml.addAttribute("id", object.getId());
if (object.getBaseTypeId() != null)
cmisXml.addAttribute("baseTypeId", object.getBaseTypeId().name());
PolicyIdList policies = object.getPolicyIds();
if (policies != null) {
XmlBuilder policiesXml = new XmlBuilder("policyIds");
for (String objectId : policies.getPolicyIds()) {
XmlBuilder policyXml = new XmlBuilder("policyId");
policyXml.setValue(objectId);
policiesXml.addSubElement(policyXml);
}
cmisXml.addSubElement(policiesXml);
}
XmlBuilder relationshipsXml = new XmlBuilder("relationships");
List<ObjectData> relationships = object.getRelationships();
if (relationships != null) {
for (ObjectData relation : relationships) {
relationshipsXml.addSubElement(objectData2Xml(relation, new XmlBuilder("relation")));
}
}
cmisXml.addSubElement(relationshipsXml);
return cmisXml;
}
use of org.apache.chemistry.opencmis.commons.data.PropertyData in project iaf by ibissource.
the class IbisObjectService method createDocument.
@Override
public String createDocument(String repositoryId, Properties properties, String folderId, ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
if (!eventDispatcher.contains(CmisEvent.CREATE_DOCUMENT)) {
return objectService.createDocument(repositoryId, properties, folderId, contentStream, versioningState, policies, addAces, removeAces, extension);
} else {
XmlBuilder cmisXml = new XmlBuilder("cmis");
cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
cmisXml.addSubElement(buildXml("folderId", folderId));
cmisXml.addSubElement(buildXml("versioningState", versioningState));
XmlBuilder contentStreamXml = new XmlBuilder("contentStream");
contentStreamXml.addAttribute("filename", contentStream.getFileName());
contentStreamXml.addAttribute("length", contentStream.getLength());
contentStreamXml.addAttribute("mimeType", contentStream.getMimeType());
cmisXml.addSubElement(contentStreamXml);
XmlBuilder propertiesXml = new XmlBuilder("properties");
for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext(); ) {
propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
}
cmisXml.addSubElement(propertiesXml);
PipeLineSession context = new PipeLineSession();
context.put("ContentStream", contentStream.getStream());
context.put(CmisUtils.CMIS_CALLCONTEXT_KEY, callContext);
Element result = eventDispatcher.trigger(CmisEvent.CREATE_DOCUMENT, cmisXml.toXML(), context);
return XmlUtils.getChildTagAsString(result, "id");
}
}
use of org.apache.chemistry.opencmis.commons.data.PropertyData in project iaf by ibissource.
the class IbisObjectService method createItem.
@Override
public String createItem(String repositoryId, Properties properties, String folderId, List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
if (!eventDispatcher.contains(CmisEvent.CREATE_ITEM)) {
return objectService.createItem(repositoryId, properties, folderId, policies, addAces, removeAces, extension);
} else {
XmlBuilder cmisXml = new XmlBuilder("cmis");
cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
cmisXml.addSubElement(buildXml("folderId", folderId));
cmisXml.addSubElement(buildXml("policies", policies));
XmlBuilder propertiesXml = new XmlBuilder("properties");
for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext(); ) {
propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
}
cmisXml.addSubElement(propertiesXml);
Element result = eventDispatcher.trigger(CmisEvent.CREATE_ITEM, cmisXml.toXML(), callContext);
return XmlUtils.getChildTagAsString(result, "id");
}
}
Aggregations