org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl Java Examples
The following examples show how to use
org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl.
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: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public AllowableActions getAllowableActions(CMISNodeInfo info) { AllowableActionsImpl result = new AllowableActionsImpl(); Set<Action> allowableActions = new HashSet<Action>(); result.setAllowableActions(allowableActions); for (CMISActionEvaluator evaluator : info.getType().getActionEvaluators().values()) { if (evaluator.isAllowed(info)) { allowableActions.add(evaluator.getAction()); } } return result; }
Example #2
Source File: IbisObjectService.java From iaf with Apache License 2.0 | 5 votes |
@Override public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension) { if(!eventDispatcher.contains(CmisEvent.GET_ALLOWABLE_ACTIONS)) { return objectService.getAllowableActions(repositoryId, objectId, extension); } else { XmlBuilder cmisXml = new XmlBuilder("cmis"); cmisXml.addSubElement(buildXml("repositoryId", repositoryId)); cmisXml.addSubElement(buildXml("objectId", objectId)); AllowableActionsImpl allowableActions = new AllowableActionsImpl(); Element cmisElement = eventDispatcher.trigger(CmisEvent.GET_ALLOWABLE_ACTIONS, cmisXml.toXML(), callContext); Element allowableActionsElem = XmlUtils.getFirstChildTag(cmisElement, "allowableActions"); if(allowableActionsElem != null) { 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); } return allowableActions; } }
Example #3
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
/** * Compiles the allowable actions for a file or folder. */ private AllowableActions compileAllowableActions(PersistentObject object) { if (object == null) { throw new IllegalArgumentException("Object must not be null!"); } boolean write = checkPermission(object, null, Permission.WRITE); boolean download = checkPermission(object, null, Permission.DOWNLOAD); boolean isFolder = object instanceof Folder; boolean isWorkspace = isFolder && ((Folder) object).getType() == Folder.TYPE_WORKSPACE; boolean isRoot = root.equals(object); Set<Action> aas = new HashSet<Action>(); addAction(aas, Action.CAN_GET_OBJECT_PARENTS, !isRoot); addAction(aas, Action.CAN_GET_PROPERTIES, true); addAction(aas, Action.CAN_GET_ACL, true); if (isFolder) { addAction(aas, Action.CAN_GET_DESCENDANTS, true); addAction(aas, Action.CAN_GET_CHILDREN, true); addAction(aas, Action.CAN_GET_FOLDER_PARENT, !isRoot); addAction(aas, Action.CAN_GET_FOLDER_TREE, true); addAction(aas, Action.CAN_CREATE_DOCUMENT, write); addAction(aas, Action.CAN_CREATE_FOLDER, write); addAction(aas, Action.CAN_ADD_OBJECT_TO_FOLDER, write); addAction(aas, Action.CAN_UPDATE_PROPERTIES, write && !isWorkspace); addAction(aas, Action.CAN_MOVE_OBJECT, write && download && !isWorkspace); addAction(aas, Action.CAN_DELETE_OBJECT, write && !isWorkspace); addAction(aas, Action.CAN_DELETE_TREE, write && !isWorkspace); } else if (object instanceof Document) { Document doc = (Document) object; addAction(aas, Action.CAN_UPDATE_PROPERTIES, write); addAction(aas, Action.CAN_MOVE_OBJECT, write && download); addAction(aas, Action.CAN_DELETE_OBJECT, write); addAction(aas, Action.CAN_GET_CONTENT_STREAM, true); addAction(aas, Action.CAN_GET_ALL_VERSIONS, true); addAction(aas, Action.CAN_SET_CONTENT_STREAM, write); addAction(aas, Action.CAN_CHECK_OUT, doc.getStatus() == Document.DOC_UNLOCKED && write); addAction(aas, Action.CAN_CHECK_IN, doc.getStatus() == Document.DOC_CHECKED_OUT && doc.getLockUserId().longValue() == getSessionUser().getId() && write); addAction(aas, Action.CAN_CANCEL_CHECK_OUT, doc.getStatus() != Document.DOC_UNLOCKED && (doc.getLockUserId().longValue() == getSessionUser().getId() || getSessionUser().isMemberOf("admin"))); } else { addAction(aas, Action.CAN_GET_CONTENT_STREAM, true); } AllowableActionsImpl result = new AllowableActionsImpl(); result.setAllowableActions(aas); return result; }
Example #4
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 4 votes |
static AllowableActions compileAllowableActions(TypeDefinition type, Object object, boolean isRoot, boolean isPrincipalReadOnly) { AllowableActionsImpl result = new AllowableActionsImpl(); Set<Action> aas = EnumSet.noneOf(Action.class); addAction(aas, Action.CAN_GET_OBJECT_PARENTS, false /*!isRoot*/); addAction(aas, Action.CAN_GET_PROPERTIES, true); addAction(aas, Action.CAN_UPDATE_PROPERTIES, !isPrincipalReadOnly /*&& !isReadOnly*/); addAction(aas, Action.CAN_MOVE_OBJECT, false /*!userReadOnly && !isRoot*/); addAction(aas, Action.CAN_DELETE_OBJECT, !isPrincipalReadOnly && !isRoot /*!userReadOnly && !isReadOnly && !isRoot*/); addAction(aas, Action.CAN_GET_ACL, false /*true*/); boolean folder = type.getId().equals(BaseTypeId.CMIS_FOLDER.value()); if (folder) { addAction(aas, Action.CAN_GET_DESCENDANTS, false); addAction(aas, Action.CAN_GET_CHILDREN, true); addAction(aas, Action.CAN_GET_FOLDER_PARENT, !isRoot); addAction(aas, Action.CAN_GET_FOLDER_TREE, true); addAction(aas, Action.CAN_CREATE_DOCUMENT, !isPrincipalReadOnly); addAction(aas, Action.CAN_CREATE_FOLDER, !isPrincipalReadOnly); addAction(aas, Action.CAN_DELETE_TREE, !isPrincipalReadOnly /*&& !isReadOnly*/); } else { ContentStreamAllowed allowed = ((DocumentTypeDefinition)type).getContentStreamAllowed(); if (allowed == ContentStreamAllowed.ALLOWED || allowed == ContentStreamAllowed.REQUIRED) { addAction(aas, Action.CAN_GET_CONTENT_STREAM, contentLength(object) > 0); addAction(aas, Action.CAN_SET_CONTENT_STREAM, !isPrincipalReadOnly /*&& !isReadOnly*/); addAction(aas, Action.CAN_DELETE_CONTENT_STREAM, !isPrincipalReadOnly /*&& !isReadOnly*/); addAction(aas, Action.CAN_GET_ALL_VERSIONS, true); } if (((DocumentTypeDefinition)type).isVersionable()) { addAction(aas, Action.CAN_CHECK_IN, true); addAction(aas, Action.CAN_CHECK_OUT, true); addAction(aas, Action.CAN_CANCEL_CHECK_OUT, true); } } result.setAllowableActions(aas); return result; }
Example #5
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; }