Java Code Examples for org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl#setRelationships()
The following examples show how to use
org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl#setRelationships() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Converter.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Converts a CMIS object * * @param object the object to convert * * @return the converted object */ public static ObjectData convert(CmisObjectType object) { if (object == null) { return null; } ObjectDataImpl result = new ObjectDataImpl(); result.setAcl(convert(object.getAcl(), object.isExactACL())); result.setAllowableActions(convert(object.getAllowableActions())); if (object.getChangeEventInfo() != null) { ChangeEventInfoDataImpl changeEventInfo = new ChangeEventInfoDataImpl(); if (object.getChangeEventInfo().getChangeTime() != null) { changeEventInfo.setChangeTime(object.getChangeEventInfo().getChangeTime().toGregorianCalendar()); } changeEventInfo.setChangeType(convert(ChangeType.class, object.getChangeEventInfo().getChangeType())); convertExtension(object.getChangeEventInfo(), changeEventInfo); result.setChangeEventInfo(changeEventInfo); } result.setIsExactAcl(object.isExactACL()); result.setPolicyIds(convert(object.getPolicyIds())); result.setProperties(convert(object.getProperties())); List<ObjectData> relationships = new ArrayList<ObjectData>(); for (CmisObjectType cmisObject : object.getRelationship()) { relationships.add(convert(cmisObject)); } result.setRelationships(relationships); List<RenditionData> renditions = new ArrayList<RenditionData>(); for (CmisRenditionType rendition : object.getRendition()) { renditions.add(convert(rendition)); } result.setRenditions(renditions); // handle extensions convertExtension(object, result); return result; }
Example 2
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") private ObjectData createCMISObjectImpl(final CMISNodeInfo info, Properties nodeProps, String filter, boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, boolean includePolicyIds, boolean includeAcl) { final ObjectDataImpl result = new ObjectDataImpl(); // set allowable actions if (includeAllowableActions) { result.setAllowableActions(getAllowableActions(info)); } // set policy ids if (includePolicyIds) { result.setPolicyIds(new PolicyIdListImpl()); } if (info.isRelationship()) { // set properties result.setProperties(getAssocProperties(info, filter)); // set ACL if (includeAcl) { // association have no ACL - return an empty list of ACEs result.setAcl(new AccessControlListImpl((List<Ace>) Collections.EMPTY_LIST)); result.setIsExactAcl(Boolean.FALSE); } } else { // set properties result.setProperties(nodeProps); // set relationships if (includeRelationships != IncludeRelationships.NONE) { result.setRelationships(getRelationships(info.getNodeRef(), includeRelationships)); } // set renditions if (!RENDITION_NONE.equals(renditionFilter)) { List<RenditionData> renditions = getRenditions(info.getNodeRef(), renditionFilter, null, null); if ((renditions != null) && (!renditions.isEmpty())) { result.setRenditions(renditions); } else { result.setRenditions(Collections.EMPTY_LIST); } } // set ACL if (includeAcl) { AuthenticationUtil.runAsSystem(new RunAsWork<Void>() { @Override public Void doWork() throws Exception { Acl acl = getACL(info.getCurrentNodeNodeRef(), false); if (acl != null) { result.setAcl(acl); result.setIsExactAcl(acl.isExact()); } return null; } }); } // add aspects List<CmisExtensionElement> extensions = getAspectExtensions(info, filter, result.getProperties() .getProperties().keySet()); if (!extensions.isEmpty()) { result.getProperties().setExtensions( Collections.singletonList((CmisExtensionElement) new CmisExtensionElementImpl( ALFRESCO_EXTENSION_NAMESPACE, ASPECTS, null, extensions))); } } return result; }
Example 3
Source File: CmisUtils.java From iaf with Apache License 2.0 | 4 votes |
public static ObjectData xml2ObjectData(Element cmisElement, IPipeLineSession context) { ObjectDataImpl impl = new ObjectDataImpl(); // 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 String isExactAcl = XmlUtils.getChildTagAsString(cmisElement, "isExactAcl"); if(isExactAcl != null) { impl.setIsExactAcl(Boolean.parseBoolean(isExactAcl)); } // If the original object exists copy the permissions over. These cannot (and shouldn't) be changed) if(context != null) { CmisObject object = (CmisObject) context.get(CmisUtils.ORIGINAL_OBJECT_KEY); if(object != null) { impl.setAcl(object.getAcl()); } } // 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(CmisUtils.processProperties(cmisElement)); Element relationshipsElem = XmlUtils.getFirstChildTag(cmisElement, "relationships"); if(relationshipsElem != null) { List<ObjectData> relationships = new ArrayList<ObjectData>(); for (Node type : XmlUtils.getChildTags(relationshipsElem, "relation")) { ObjectData data = xml2ObjectData((Element) type, null); relationships.add(data); } impl.setRelationships(relationships); } impl.setRenditions(null); impl.setExtensions(null); impl.setChangeEventInfo(null); return impl; }