org.apache.chemistry.opencmis.commons.enums.Action Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.enums.Action. 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: RuntimePropertyAccessorMapping.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Register an Action Evaluator
 * 
 * @param scope BaseTypeId
 * @param evaluator CMISActionEvaluator
 */
private void registerEvaluator(BaseTypeId scope, CMISActionEvaluator evaluator)
{
    Map<Action, CMISActionEvaluator> evaluators = actionEvaluators.get(scope);
    if (evaluators == null)
    {
        evaluators = new LinkedHashMap<Action, CMISActionEvaluator>();
        actionEvaluators.put(scope, evaluators);
    }
    if (evaluators.get(evaluator.getAction()) != null)
    {
        throw new AlfrescoRuntimeException("Already registered Action Evaluator " + evaluator.getAction()
                + " for scope " + scope);
    }
    evaluators.put(evaluator.getAction(), evaluator);

    if (logger.isDebugEnabled())
        logger.debug("Registered Action Evaluator: scope=" + scope + ", evaluator=" + evaluator);
}
 
Example #2
Source File: CmisSender.java    From iaf with Apache License 2.0 6 votes vote down vote up
private String sendMessageForActionDelete(String message, IPipeLineSession session) throws SenderException, TimeOutException {
	if (StringUtils.isEmpty(message)) {
		throw new SenderException(getLogPrefix() + "input string cannot be empty but must contain a documentId");
	}
	CmisObject object = null;
	try {
		object = getCmisObject(message);
	} catch (CmisObjectNotFoundException e) {
		if (StringUtils.isNotEmpty(getResultOnNotFound())) {
			log.info(getLogPrefix() + "document with id [" + message + "] not found", e);
			return getResultOnNotFound();
		} else {
			throw new SenderException(e);
		}
	}
	if (object.hasAllowableAction(Action.CAN_DELETE_OBJECT)) { //// You can delete
		Document suppDoc = (Document) object;
		suppDoc.delete(true);
		String correlationID = session==null ? null : session.getMessageId();
		return correlationID;

	} else {  //// You can't delete
		throw new SenderException(getLogPrefix() + "Document cannot be deleted");
	}
}
 
Example #3
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #4
Source File: CmisTestObject.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public AllowableActions getAllowableActions() {
	AllowableActions actions = mock(AllowableActions.class);
	Set<Action> actionSet = new HashSet<Action>() {} ;
	Action action = Action.CAN_CREATE_DOCUMENT;
	actionSet.add(action);
	when(actions.getAllowableActions()).thenReturn(actionSet);
	return actions;
}
 
Example #5
Source File: RuntimePropertyAccessorMapping.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the Action Evaluators applicable for the given CMIS Scope
 * 
 * @param scope BaseTypeId
 */
public Map<Action, CMISActionEvaluator> getActionEvaluators(BaseTypeId scope)
{
    Map<Action, CMISActionEvaluator> evaluators = actionEvaluators.get(scope);
    if (evaluators == null)
    {
        evaluators = Collections.emptyMap();
    }
    return evaluators;
}
 
Example #6
Source File: CanDeleteDocumentEvaluator.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Construct
 * 
 * @param serviceRegistry ServiceRegistry
 */
protected CanDeleteDocumentEvaluator(ServiceRegistry serviceRegistry)
{
    super(serviceRegistry, Action.CAN_DELETE_OBJECT);
    this.currentVersionEvaluator = new PermissionActionEvaluator(serviceRegistry,
            Action.CAN_DELETE_OBJECT, PermissionService.DELETE_NODE);
}
 
Example #7
Source File: CanCancelCheckOutActionEvaluator.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Construct
 */
protected CanCancelCheckOutActionEvaluator(ServiceRegistry serviceRegistry)
{
    super(serviceRegistry, Action.CAN_CANCEL_CHECK_OUT);
    permissionEvaluator = new PermissionActionEvaluator(
            serviceRegistry,
            Action.CAN_CANCEL_CHECK_OUT,
            PermissionService.CANCEL_CHECK_OUT);
}
 
Example #8
Source File: CanCheckInActionEvaluator.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Construct
 */
protected CanCheckInActionEvaluator(ServiceRegistry serviceRegistry)
{
    super(serviceRegistry, Action.CAN_CHECK_IN);
    permissionEvaluator = new PermissionActionEvaluator(
            serviceRegistry,
            Action.CAN_CHECK_IN,
            PermissionService.CHECK_IN);
}
 
Example #9
Source File: CanCheckOutActionEvaluator.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Construct
 */
protected CanCheckOutActionEvaluator(ServiceRegistry serviceRegistry)
{
    super(serviceRegistry, Action.CAN_CHECK_OUT);
    permissionEvaluator = new PermissionActionEvaluator(
            serviceRegistry,
            Action.CAN_CHECK_OUT,
            PermissionService.CHECK_OUT);
    lockService = serviceRegistry.getLockService();
}
 
Example #10
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@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 #11
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Rule addRule(boolean isAppliedToChildren, String title)
{

    // Rule properties
    Map<String, Serializable> conditionProps = new HashMap<String, Serializable>();
    conditionProps.put(ComparePropertyValueEvaluator.PARAM_VALUE, ".txt");

    Map<String, Serializable> actionProps = new HashMap<String, Serializable>();
    actionProps.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);

    List<String> ruleTypes = new ArrayList<String>(1);
    ruleTypes.add(RuleType.INBOUND);

    // Create the action
    org.alfresco.service.cmr.action.Action action = actionService.createAction(title);
    action.setParameterValues(conditionProps);

    ActionCondition actionCondition = actionService.createActionCondition(ComparePropertyValueEvaluator.NAME);
    actionCondition.setParameterValues(conditionProps);
    action.addActionCondition(actionCondition);

    // Create the rule
    Rule rule = new Rule();
    rule.setRuleTypes(ruleTypes);
    rule.setTitle(title);
    rule.setDescription("description");
    rule.applyToChildren(isAppliedToChildren);
    rule.setAction(action);

    return rule;
}
 
Example #12
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 4 votes vote down vote up
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 #13
Source File: CmisTestObject.java    From iaf with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasAllowableAction(Action action) {
	// TODO Auto-generated method stub
	return false;
}
 
Example #14
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 4 votes vote down vote up
static void addAction(Set<Action> aas, Action action, boolean condition) {
	if (condition) {
		aas.add(action);
	}
}
 
Example #15
Source File: CmisUtils.java    From iaf with Apache License 2.0 4 votes vote down vote up
public static void cmisObject2Xml(XmlBuilder cmisXml, CmisObject object) {
	if(object.getProperties() != null) {
		XmlBuilder propertiesXml = new XmlBuilder("properties");
		for (Iterator<Property<?>> it = object.getProperties().iterator(); it.hasNext();) {
			Property<?> property = (Property<?>) it.next();
			propertiesXml.addSubElement(CmisUtils.getPropertyXml(property));
		}
		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);
	}

	List<ObjectId> policies = object.getPolicyIds();
	if(policies != null) {
		XmlBuilder policiesXml = new XmlBuilder("policyIds");
		for (ObjectId objectId : policies) {
			XmlBuilder policyXml = new XmlBuilder("policyId");
			policyXml.setValue(objectId.getId());
			policiesXml.addSubElement(policyXml);
		}
		cmisXml.addSubElement(policiesXml);
	}

	XmlBuilder relationshipsXml = new XmlBuilder("relationships");
	List<Relationship> relationships = object.getRelationships();
	if(relationships != null) {
		for (Relationship relation : relationships) {
			XmlBuilder relationXml = new XmlBuilder("relation");
			relationXml.setValue(relation.getId());
			relationshipsXml.addSubElement(relationXml);
		}
	}
	cmisXml.addSubElement(relationshipsXml);
}
 
Example #16
Source File: CmisUtils.java    From iaf with Apache License 2.0 4 votes vote down vote up
/**
 * @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;
}
 
Example #17
Source File: CmisUtils.java    From iaf with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #18
Source File: Converter.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Converts an AllowableActions object
 * 
 * @param allowableActions the object to convert
 * 
 * @return the conversion
 */
public static CmisAllowableActionsType convert(AllowableActions allowableActions) {
	if (allowableActions == null) {
		return null;
	}

	CmisAllowableActionsType result = new CmisAllowableActionsType();

	if (allowableActions.getAllowableActions() != null) {
		Set<Action> set = allowableActions.getAllowableActions();

		result.setCanAddObjectToFolder(set.contains(Action.CAN_ADD_OBJECT_TO_FOLDER));
		result.setCanApplyACL(set.contains(Action.CAN_APPLY_ACL));
		result.setCanApplyPolicy(set.contains(Action.CAN_APPLY_POLICY));
		result.setCanCancelCheckOut(set.contains(Action.CAN_CANCEL_CHECK_OUT));
		result.setCanCheckIn(set.contains(Action.CAN_CHECK_IN));
		result.setCanCheckOut(set.contains(Action.CAN_CHECK_OUT));
		result.setCanCreateDocument(set.contains(Action.CAN_CREATE_DOCUMENT));
		result.setCanCreateFolder(set.contains(Action.CAN_CREATE_FOLDER));
		result.setCanCreateRelationship(set.contains(Action.CAN_CREATE_RELATIONSHIP));
		result.setCanDeleteContentStream(set.contains(Action.CAN_DELETE_CONTENT_STREAM));
		result.setCanDeleteObject(set.contains(Action.CAN_DELETE_OBJECT));
		result.setCanDeleteTree(set.contains(Action.CAN_DELETE_TREE));
		result.setCanGetACL(set.contains(Action.CAN_GET_ACL));
		result.setCanGetAllVersions(set.contains(Action.CAN_GET_ALL_VERSIONS));
		result.setCanGetAppliedPolicies(set.contains(Action.CAN_GET_APPLIED_POLICIES));
		result.setCanGetChildren(set.contains(Action.CAN_GET_CHILDREN));
		result.setCanGetContentStream(set.contains(Action.CAN_GET_CONTENT_STREAM));
		result.setCanGetDescendants(set.contains(Action.CAN_GET_DESCENDANTS));
		result.setCanGetFolderParent(set.contains(Action.CAN_GET_FOLDER_PARENT));
		result.setCanGetFolderTree(set.contains(Action.CAN_GET_FOLDER_TREE));
		result.setCanGetObjectParents(set.contains(Action.CAN_GET_OBJECT_PARENTS));
		result.setCanGetObjectRelationships(set.contains(Action.CAN_GET_OBJECT_RELATIONSHIPS));
		result.setCanGetProperties(set.contains(Action.CAN_GET_PROPERTIES));
		result.setCanGetRenditions(set.contains(Action.CAN_GET_RENDITIONS));
		result.setCanMoveObject(set.contains(Action.CAN_MOVE_OBJECT));
		result.setCanRemoveObjectFromFolder(set.contains(Action.CAN_REMOVE_OBJECT_FROM_FOLDER));
		result.setCanRemovePolicy(set.contains(Action.CAN_REMOVE_POLICY));
		result.setCanSetContentStream(set.contains(Action.CAN_SET_CONTENT_STREAM));
		result.setCanUpdateProperties(set.contains(Action.CAN_UPDATE_PROPERTIES));

	}

	// handle extensions
	convertExtension(allowableActions, result);

	return result;
}
 
Example #19
Source File: AbstractTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Map<Action, CMISActionEvaluator> getActionEvaluators()
{
    return actionEvaluators;
}
 
Example #20
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Extracts metadata for the node.
 *
 * @param nodeRef NodeRef
 */
public void extractMetadata(NodeRef nodeRef)
{
	org.alfresco.service.cmr.action.Action action = actionService.createAction(ContentMetadataExtracter.EXECUTOR_NAME);
	actionService.executeAction(action, nodeRef, true, false);
}
 
Example #21
Source File: AbstractActionEvaluator.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Action getAction()
{
    return action;
}
 
Example #22
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static void addAction(Set<Action> aas, Action action, boolean condition) {
	if (condition) {
		aas.add(action);
	}
}
 
Example #23
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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 #24
Source File: CurrentVersionEvaluator.java    From alfresco-repository with GNU Lesser General Public License v3.0 3 votes vote down vote up
/**
 * Construct
 *
 * @param serviceRegistry ServiceRegistry
 * @param action Action
 * @param currentVersionValue boolean
 * @param nonCurrentVersionValue boolean
 */
protected CurrentVersionEvaluator(ServiceRegistry serviceRegistry, Action action, boolean currentVersionValue,
        boolean nonCurrentVersionValue)
{
    super(serviceRegistry, action);
    this.currentVersionValue = currentVersionValue;
    this.nonCurrentVersionValue = nonCurrentVersionValue;
}
 
Example #25
Source File: PermissionActionEvaluator.java    From alfresco-repository with GNU Lesser General Public License v3.0 3 votes vote down vote up
/**
 * Construct
 * 
 * @param serviceRegistry ServiceRegistry
 * @param action Action
 * @param permission String...
 */
protected PermissionActionEvaluator(ServiceRegistry serviceRegistry, Action action, String... permission)
{
    super(serviceRegistry, action);
    this.permissions = permission;
    this.permissionService = serviceRegistry.getPermissionService();
}
 
Example #26
Source File: PropertyAccessorMapping.java    From alfresco-data-model with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Gets the Action Evaluators applicable for the given CMIS Scope
 * 
 * @param scope BaseTypeId
 */
public Map<Action, CMISActionEvaluator> getActionEvaluators(BaseTypeId scope);
 
Example #27
Source File: CMISActionEvaluator.java    From alfresco-data-model with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Gets the CMIS Allowed Action
 * 
 * @return Action
 */
public Action getAction();
 
Example #28
Source File: AbstractActionEvaluator.java    From alfresco-repository with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Construct
 * 
 * @param serviceRegistry ServiceRegistry
 * @param action Action
 */
protected AbstractActionEvaluator(ServiceRegistry serviceRegistry, Action action)
{
    this.serviceRegistry = serviceRegistry;
    this.action = action;
}
 
Example #29
Source File: FixedValueActionEvaluator.java    From alfresco-repository with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Construct
 * 
 * @param serviceRegistry ServiceRegistry
 * @param action Action
 * @param allowed boolean
 */
protected FixedValueActionEvaluator(ServiceRegistry serviceRegistry, Action action, boolean allowed)
{
    super(serviceRegistry, action);
    this.allowed = allowed;
}
 
Example #30
Source File: TypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 votes vote down vote up
Map<Action, CMISActionEvaluator> getActionEvaluators();