org.apache.chemistry.opencmis.commons.data.AllowableActions Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.data.AllowableActions. 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 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 #2
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // what kind of object is it?
    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");

    return connector.getAllowableActions(info);
}
 
Example #3
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkId("Object Id", objectId);

    try {
        return getWrappedService().getAllowableActions(repositoryId, objectId, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #4
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 #5
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 #6
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 #7
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 #8
Source File: LDCmisService.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension) {
	validateSession();
	return getRepository().getAllowableActions(getCallContext(), objectId);
}
 
Example #9
Source File: AbstractCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension) {
    return service.getAllowableActions(repositoryId, objectId, extension);
}
 
Example #10
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public AllowableActions getAllowableActions(String objectId)
{
    CmisObject o = getObject(objectId);
    AllowableActions res = o.getAllowableActions();
    return res;
}
 
Example #11
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 #12
Source File: FilterCmisService.java    From iaf with Apache License 2.0 4 votes vote down vote up
@Override
public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension) {
	return getObjectService().getAllowableActions(repositoryId, objectId, extension);
}
 
Example #13
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * CMIS getAllowableActions
 * 
 * @param context the call context
 * @param objectId identifier of the file/folder
 * 
 * @return the allowable actions
 */
public AllowableActions getAllowableActions(CallContext context, String objectId) {
	debug("getAllowableActions");
	return compileAllowableActions(getObject(objectId));
}