Plumbing for CMIS Allowable Actions

- add CMIS enum for Allowable Actions
- introduce Action Evaluator, with Permission based and fixed boolean implementations
- registry of available action evaluators based on CMIS type
- CMIS Type Definition has getter for applicable action evaluators
- couple of CMIS actions registered

TODO:
- register all actions as defined in spec
- serialize in AtomPub binding

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13816 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2009-04-02 17:20:26 +00:00
parent 8b86152153
commit 79c938f0b4
15 changed files with 443 additions and 5 deletions

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis;
import org.alfresco.service.cmr.repository.NodeRef;
public interface CMISActionEvaluator
{
/**
* Gets the CMIS Allowed Action
*
* @return
*/
public CMISAllowedActionEnum getAction();
/**
* Determines if Action is allowed
*
* @param nodeRef
* @return
*/
public boolean isAllowed(NodeRef nodeRef);
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis;
/**
* CMIS Allowed Action Enum
*
* @author davidc
*/
public enum CMISAllowedActionEnum implements EnumLabel
{
CAN_DELETE("canDelete"),
CAN_UPDATE_PROPERTIES("canUpdateProperties"),
CAN_GET_PROPERTIES("canGetProperties"),
CAN_GET_RELATIONSHIPS("canGetRelationships"),
CAN_GET_PARENTS("canGetParents"),
CAN_GET_FOLDER_PARENT("canGetFolderParents"),
CAN_GET_DESCENDANTS("canGetDescendants"),
CAN_MOVE("canMove"),
CAN_DELETE_VERSION("canDeleteVersion"),
CAN_DELETE_CONTENT("canDeleteContent"),
CAN_CHECKOUT("canCheckout"),
CAN_CANCEL_CHECKOUT("canCancelCheckout"),
CAN_CHECKIN("canCheckin"),
CAN_SET_CONTENT("canSetContent"),
CAN_GET_ALL_VERSIONS("canGetAllVersions"),
CAN_ADD_TO_FOLDER("canAddToFolder"),
CAN_REMOVE_FROM_FOLDER("canRemoveFromFolder"),
CAN_VIEW_CONTENT("canViewContent"),
CAN_ADD_POLICY("canAddPolicy"),
CAN_GET_APPLIED_POLICIES("canGetAppliedPolicies"),
CAN_REMOVE_POLICY("canRemovePolicy"),
CAN_GET_CHILDREN("canGetChildren"),
CAN_CREATE_DOCUMENT("canCreateDocument"),
CAN_CREATE_FOLDER("canCreateFolder"),
CAN_CREATE_RELATIONSHIP("canCreateRelationship"),
CAN_CREATE_POLICY("canCreatePolicy"),
CAN_DELETE_TREE("canDeleteTree");
private String label;
/**
* Construct
*
* @param label
*/
CMISAllowedActionEnum(String label)
{
this.label = label;
}
/* (non-Javadoc)
* @see org.alfresco.cmis.EnumLabel#label()
*/
public String getLabel()
{
return label;
}
public static EnumFactory<CMISAllowedActionEnum> FACTORY = new EnumFactory<CMISAllowedActionEnum>(CMISAllowedActionEnum.class);
}

View File

@@ -168,6 +168,12 @@ public interface CMISTypeDefinition
* *
* @return * @return
*/ */
public Map<CMISPropertyId, CMISPropertyDefinition> getOwnedPropertyDefinitions(); public Map<CMISPropertyId, CMISPropertyDefinition> getOwnedPropertyDefinitions();
/**
* Gets the Action evaluators for this type
*
* @return
*/
public Map<CMISAllowedActionEnum, CMISActionEvaluator> getActionEvaluators();
} }

View File

@@ -158,6 +158,7 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
logger.debug("Registered type " + typeDef.getTypeId() + " (scope=" + typeDef.getTypeId().getScope() + ", public=" + typeDef.isPublic() + ")"); logger.debug("Registered type " + typeDef.getTypeId() + " (scope=" + typeDef.getTypeId().getScope() + ", public=" + typeDef.isPublic() + ")");
logger.debug(" QName: " + typeDef.getTypeId().getQName()); logger.debug(" QName: " + typeDef.getTypeId().getQName());
logger.debug(" Table: " + typeDef.getQueryName()); logger.debug(" Table: " + typeDef.getQueryName());
logger.debug(" Action Evaluators: " + typeDef.getActionEvaluators().size());
} }
} }

View File

@@ -32,6 +32,8 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import org.alfresco.cmis.CMISActionEvaluator;
import org.alfresco.cmis.CMISAllowedActionEnum;
import org.alfresco.cmis.CMISContentStreamAllowedEnum; import org.alfresco.cmis.CMISContentStreamAllowedEnum;
import org.alfresco.cmis.CMISPropertyDefinition; import org.alfresco.cmis.CMISPropertyDefinition;
import org.alfresco.cmis.CMISPropertyId; import org.alfresco.cmis.CMISPropertyId;
@@ -80,7 +82,7 @@ public class CMISAbstractTypeDefinition implements CMISTypeDefinition, Serializa
protected Map<CMISPropertyId, CMISPropertyDefinition> properties = new HashMap<CMISPropertyId, CMISPropertyDefinition>(); protected Map<CMISPropertyId, CMISPropertyDefinition> properties = new HashMap<CMISPropertyId, CMISPropertyDefinition>();
protected Map<CMISPropertyId, CMISPropertyDefinition> inheritedProperties = new HashMap<CMISPropertyId, CMISPropertyDefinition>(); protected Map<CMISPropertyId, CMISPropertyDefinition> inheritedProperties = new HashMap<CMISPropertyId, CMISPropertyDefinition>();
protected Map<CMISPropertyId, CMISPropertyDefinition> ownedProperties = new HashMap<CMISPropertyId, CMISPropertyDefinition>(); protected Map<CMISPropertyId, CMISPropertyDefinition> ownedProperties = new HashMap<CMISPropertyId, CMISPropertyDefinition>();
protected Map<CMISAllowedActionEnum, CMISActionEvaluator> actionEvaluators;
/** /**
@@ -386,6 +388,15 @@ public class CMISAbstractTypeDefinition implements CMISTypeDefinition, Serializa
return ownedProperties; return ownedProperties;
} }
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISTypeDefinition#getActionEvaluators()
*/
public Map<CMISAllowedActionEnum, CMISActionEvaluator> getActionEvaluators()
{
return actionEvaluators;
}
// //
// Document Type specific // Document Type specific
// //

View File

@@ -92,6 +92,8 @@ public class CMISDocumentTypeDefinition extends CMISAbstractTypeDefinition
controllable = false; controllable = false;
includeInSuperTypeQuery = true; includeInSuperTypeQuery = true;
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
// Document type properties // Document type properties
versionable = false; versionable = false;
List<AspectDefinition> defaultAspects = cmisClassDef.getDefaultAspects(); List<AspectDefinition> defaultAspects = cmisClassDef.getDefaultAspects();

View File

@@ -75,6 +75,8 @@ public class CMISFolderTypeDefinition extends CMISAbstractTypeDefinition
} }
} }
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
creatable = true; creatable = true;
queryable = true; queryable = true;
controllable = false; controllable = false;

View File

@@ -71,6 +71,8 @@ public class CMISObjectTypeDefinition extends CMISAbstractTypeDefinition
} }
} }
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
creatable = false; creatable = false;
queryable = false; queryable = false;
controllable = false; controllable = false;

View File

@@ -75,6 +75,9 @@ public class CMISPolicyTypeDefinition extends CMISAbstractTypeDefinition
parentTypeId = CMISDictionaryModel.POLICY_TYPE_ID; parentTypeId = CMISDictionaryModel.POLICY_TYPE_ID;
} }
description = cmisClassDef.getDescription(); description = cmisClassDef.getDescription();
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
creatable = false; creatable = false;
queryable = false; queryable = false;
controllable = false; controllable = false;

View File

@@ -75,6 +75,9 @@ public class CMISRelationshipTypeDefinition extends CMISAbstractTypeDefinition
isPublic = true; isPublic = true;
this.cmisClassDef = cmisClassDef; this.cmisClassDef = cmisClassDef;
objectTypeId = typeId; objectTypeId = typeId;
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
creatable = false; creatable = false;
queryable = false; queryable = false;
controllable = false; controllable = false;

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.mapping;
import org.alfresco.cmis.CMISActionEvaluator;
import org.alfresco.cmis.CMISAllowedActionEnum;
import org.alfresco.service.ServiceRegistry;
/**
* Base class for all action evaluators
*
* @author davidc
*
*/
public abstract class AbstractActionEvaluator implements CMISActionEvaluator
{
private ServiceRegistry serviceRegistry;
private CMISAllowedActionEnum action;
/**
* Construct
*
* @param serviceRegistry
* @param action
*/
protected AbstractActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action)
{
this.serviceRegistry = serviceRegistry;
this.action = action;
}
/**
* @return service registry
*/
protected ServiceRegistry getServiceRegistry()
{
return serviceRegistry;
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISActionEvaluator#getAction()
*/
public CMISAllowedActionEnum getAction()
{
return action;
}
}

View File

@@ -25,9 +25,13 @@
package org.alfresco.cmis.mapping; package org.alfresco.cmis.mapping;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.alfresco.cmis.CMISActionEvaluator;
import org.alfresco.cmis.CMISAllowedActionEnum;
import org.alfresco.cmis.CMISContentStreamAllowedEnum; import org.alfresco.cmis.CMISContentStreamAllowedEnum;
import org.alfresco.cmis.CMISDataTypeEnum; import org.alfresco.cmis.CMISDataTypeEnum;
import org.alfresco.cmis.CMISDictionaryModel; import org.alfresco.cmis.CMISDictionaryModel;
@@ -40,6 +44,7 @@ import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceException; import org.alfresco.service.namespace.NamespaceException;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
@@ -102,6 +107,7 @@ public class CMISMapping implements InitializingBean
private Map<QName, QName> mapAlfrescoQNameToCmisQName = new HashMap<QName, QName>(); private Map<QName, QName> mapAlfrescoQNameToCmisQName = new HashMap<QName, QName>();
private Map<QName, CMISDataTypeEnum> mapAlfrescoToCmisDataType = new HashMap<QName, CMISDataTypeEnum>(); private Map<QName, CMISDataTypeEnum> mapAlfrescoToCmisDataType = new HashMap<QName, CMISDataTypeEnum>();
private Map<String, AbstractProperty> propertyAccessors = new HashMap<String, AbstractProperty>(); private Map<String, AbstractProperty> propertyAccessors = new HashMap<String, AbstractProperty>();
private Map<CMISScope, Map<CMISAllowedActionEnum, CMISActionEvaluator>> actionEvaluators = new HashMap<CMISScope, Map<CMISAllowedActionEnum, CMISActionEvaluator>>();
/* /*
@@ -110,6 +116,10 @@ public class CMISMapping implements InitializingBean
*/ */
public void afterPropertiesSet() throws Exception public void afterPropertiesSet() throws Exception
{ {
//
// Type Mappings
//
mapAlfrescoQNameToTypeId.put(OBJECT_QNAME, OBJECT_TYPE_ID); mapAlfrescoQNameToTypeId.put(OBJECT_QNAME, OBJECT_TYPE_ID);
mapAlfrescoQNameToTypeId.put(FILESYSTEM_OBJECT_QNAME, FILESYSTEM_OBJECT_TYPE_ID); mapAlfrescoQNameToTypeId.put(FILESYSTEM_OBJECT_QNAME, FILESYSTEM_OBJECT_TYPE_ID);
mapAlfrescoQNameToTypeId.put(DOCUMENT_QNAME, CMISDictionaryModel.DOCUMENT_TYPE_ID); mapAlfrescoQNameToTypeId.put(DOCUMENT_QNAME, CMISDictionaryModel.DOCUMENT_TYPE_ID);
@@ -125,6 +135,10 @@ public class CMISMapping implements InitializingBean
mapCmisQNameToAlfrescoQName.put(RELATIONSHIP_QNAME, null); mapCmisQNameToAlfrescoQName.put(RELATIONSHIP_QNAME, null);
mapCmisQNameToAlfrescoQName.put(POLICY_QNAME, null); mapCmisQNameToAlfrescoQName.put(POLICY_QNAME, null);
//
// Data Type Mappings
//
mapAlfrescoToCmisDataType.put(DataTypeDefinition.ANY, null); mapAlfrescoToCmisDataType.put(DataTypeDefinition.ANY, null);
mapAlfrescoToCmisDataType.put(DataTypeDefinition.ASSOC_REF, null); mapAlfrescoToCmisDataType.put(DataTypeDefinition.ASSOC_REF, null);
mapAlfrescoToCmisDataType.put(DataTypeDefinition.BOOLEAN, CMISDataTypeEnum.BOOLEAN); mapAlfrescoToCmisDataType.put(DataTypeDefinition.BOOLEAN, CMISDataTypeEnum.BOOLEAN);
@@ -148,6 +162,10 @@ public class CMISMapping implements InitializingBean
mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_XML, CMISDataTypeEnum.XML); mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_XML, CMISDataTypeEnum.XML);
mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_HTML, CMISDataTypeEnum.HTML); mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_HTML, CMISDataTypeEnum.HTML);
//
// Property Mappings
//
registerPropertyAccessor(new ObjectIdProperty(serviceRegistry)); registerPropertyAccessor(new ObjectIdProperty(serviceRegistry));
registerPropertyAccessor(new FixedValueProperty(serviceRegistry, CMISDictionaryModel.PROP_URI, null)); registerPropertyAccessor(new FixedValueProperty(serviceRegistry, CMISDictionaryModel.PROP_URI, null));
registerPropertyAccessor(new ObjectTypeIdProperty(serviceRegistry)); registerPropertyAccessor(new ObjectTypeIdProperty(serviceRegistry));
@@ -174,9 +192,32 @@ public class CMISMapping implements InitializingBean
registerPropertyAccessor(new ContentStreamUriProperty(serviceRegistry)); registerPropertyAccessor(new ContentStreamUriProperty(serviceRegistry));
registerPropertyAccessor(new ParentProperty(serviceRegistry)); registerPropertyAccessor(new ParentProperty(serviceRegistry));
registerPropertyAccessor(new FixedValueProperty(serviceRegistry, CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS, null)); registerPropertyAccessor(new FixedValueProperty(serviceRegistry, CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS, null));
//
// Action Evaluator Mappings
//
registerActionEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE, PermissionService.DELETE_NODE));
registerActionEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, PermissionService.WRITE_PROPERTIES));
registerActionEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, PermissionService.READ_PROPERTIES));
registerActionEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_RELATIONSHIPS, true));
registerActionEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE, PermissionService.DELETE_NODE));
registerActionEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, PermissionService.WRITE_PROPERTIES));
registerActionEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, PermissionService.READ_PROPERTIES));
registerActionEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_RELATIONSHIPS, true));
registerActionEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE, true));
registerActionEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, false));
registerActionEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, false));
registerActionEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE, false));
registerActionEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, false));
registerActionEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, false));
registerActionEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_RELATIONSHIPS, false));
} }
/** /**
* @param serviceRegistry * @param serviceRegistry
*/ */
@@ -678,4 +719,41 @@ public class CMISMapping implements InitializingBean
propertyAccessors.put(propertyAccessor.getName(), propertyAccessor); propertyAccessors.put(propertyAccessor.getName(), propertyAccessor);
} }
/**
* Gets the Action Evaluators applicable for the given CMIS Scope
*
* @param cmisScope
* @return
*/
public Map<CMISAllowedActionEnum, CMISActionEvaluator> getActionEvaluators(CMISScope scope)
{
Map<CMISAllowedActionEnum, CMISActionEvaluator> evaluators = actionEvaluators.get(scope);
if (evaluators == null)
{
evaluators = Collections.emptyMap();
}
return evaluators;
}
/**
* Register an Action Evaluator
*
* @param scope
* @param evaluator
*/
private void registerActionEvaluator(CMISScope scope, CMISActionEvaluator evaluator)
{
Map<CMISAllowedActionEnum, CMISActionEvaluator> evaluators = actionEvaluators.get(scope);
if (evaluators == null)
{
evaluators = new LinkedHashMap<CMISAllowedActionEnum, 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);
}
} }

View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.mapping;
import org.alfresco.cmis.CMISAllowedActionEnum;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Alfresco Permission based Action Evaluator
*
* @author davidc
*
*/
public class FixedValueActionEvaluator extends AbstractActionEvaluator
{
private boolean allowed;
/**
* Construct
*
* @param serviceRegistry
* @param action
*/
protected FixedValueActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action, boolean allowed)
{
super(serviceRegistry, action);
this.allowed = allowed;
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(org.alfresco.service.cmr.repository.NodeRef)
*/
public boolean isAllowed(NodeRef nodeRef)
{
return allowed;
}
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.mapping;
import org.alfresco.cmis.CMISAllowedActionEnum;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
/**
* Alfresco Permission based Action Evaluator
*
* @author davidc
*
*/
public class PermissionActionEvaluator extends AbstractActionEvaluator
{
private String[] permissions;
private PermissionService permissionService;
/**
* Construct
*
* @param serviceRegistry
* @param permission
*/
protected PermissionActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action, String... permission)
{
super(serviceRegistry, action);
this.permissions = permission;
this.permissionService = serviceRegistry.getPermissionService();
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(org.alfresco.service.cmr.repository.NodeRef)
*/
public boolean isAllowed(NodeRef nodeRef)
{
for (String permission : permissions)
{
if (permissionService.hasPermission(nodeRef, permission) == AccessStatus.DENIED)
{
return false;
}
}
return true;
}
}

View File

@@ -27,13 +27,11 @@ package org.alfresco.service.cmr.security;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.alfresco.repo.security.permissions.PermissionReference;
import org.alfresco.service.Auditable; import org.alfresco.service.Auditable;
import org.alfresco.service.PublicService; import org.alfresco.service.PublicService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.apache.axis.wsdl.symbolTable.Parameters;
/** /**
* The public API for a permission service The implementation may be changed in the application configuration * The public API for a permission service The implementation may be changed in the application configuration