summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntje Fuhrmann2013-02-20 05:01:41 (EST)
committer Sven Rottstock2013-03-11 04:54:36 (EDT)
commit22ba075a6ca9b0492696664267929915074dfe7e (patch)
tree3ca9afbee2e8f57975fa225202986ac5fb042be0
parentc92584fcbb2c31f4533932d2b50b8c6fd658bf21 (diff)
downloadorg.eclipse.stardust.engine-22ba075a6ca9b0492696664267929915074dfe7e.zip
org.eclipse.stardust.engine-22ba075a6ca9b0492696664267929915074dfe7e.tar.gz
org.eclipse.stardust.engine-22ba075a6ca9b0492696664267929915074dfe7e.tar.bz2
Jira-ID: CRNT-28027
Evaluation of modeled ExcludeUser action for WorklistQuery and ActivityInstanceQuery should be possible to be enabled/disabled by property git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/engine@63110 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/RuntimeInstanceQueryEvaluator.java5
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/removethis/KernelTweakingProperties.java2
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/AbstractAuthorization2Predicate.java284
3 files changed, 157 insertions, 134 deletions
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/RuntimeInstanceQueryEvaluator.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/RuntimeInstanceQueryEvaluator.java
index f8b66be..0396ce8 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/RuntimeInstanceQueryEvaluator.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/RuntimeInstanceQueryEvaluator.java
@@ -41,6 +41,7 @@ import org.eclipse.stardust.engine.core.persistence.jdbc.TypeDescriptor;
import org.eclipse.stardust.engine.core.runtime.beans.BpmRuntimeEnvironment;
import org.eclipse.stardust.engine.core.runtime.beans.ProcessInstanceBean;
import org.eclipse.stardust.engine.core.runtime.beans.interceptors.PropertyLayerProviderInterceptor;
+import org.eclipse.stardust.engine.core.runtime.beans.removethis.KernelTweakingProperties;
import org.eclipse.stardust.engine.core.runtime.beans.removethis.SecurityProperties;
import org.eclipse.stardust.engine.core.runtime.setup.DataCluster;
import org.eclipse.stardust.engine.core.runtime.setup.RuntimeSetup;
@@ -144,11 +145,13 @@ public class RuntimeInstanceQueryEvaluator implements QueryEvaluator
{
final BpmRuntimeEnvironment runtimeEnvironment = PropertyLayerProviderInterceptor.getCurrent();
Authorization2Predicate authorizationPredicate = runtimeEnvironment.getAuthorizationPredicate();
+ boolean excludedUserEnabled = Parameters.instance().getBoolean(
+ KernelTweakingProperties.ENGINE_EXCLUDE_USER_EVALUATION, false);
if (authorizationPredicate != null)
{
authorizationPredicate.addPrefetchDataHints(query);
}
- else if (query.getPolicy(ExcludeUserPolicy.class) != null
+ else if (excludedUserEnabled && query.getPolicy(ExcludeUserPolicy.class) != null
&& SecurityProperties.getUser().hasRole(
PredefinedConstants.ADMINISTRATOR_ROLE))
{
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/removethis/KernelTweakingProperties.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/removethis/KernelTweakingProperties.java
index 53cf813..77848ad 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/removethis/KernelTweakingProperties.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/removethis/KernelTweakingProperties.java
@@ -209,4 +209,6 @@ public final class KernelTweakingProperties
public static final String ASSIGN_TO_INVALID_USER = "Infinity.Engine.Activity.AssignToInvalidUser";
public static final String INFINITY_DMS_SHARED_DATA_EXIST = "Infinity.Dms.SharedDataExist";
+
+ public static final String ENGINE_EXCLUDE_USER_EVALUATION = "Engine.Tuning.Query.ExcludeUser.Evaluation";
} \ No newline at end of file
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/AbstractAuthorization2Predicate.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/AbstractAuthorization2Predicate.java
index 4f97aa3..9ed60b7 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/AbstractAuthorization2Predicate.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/AbstractAuthorization2Predicate.java
@@ -25,6 +25,7 @@ import java.util.Set;
import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.common.Pair;
import org.eclipse.stardust.common.StringUtils;
+import org.eclipse.stardust.common.config.Parameters;
import org.eclipse.stardust.common.error.AccessForbiddenException;
import org.eclipse.stardust.common.log.LogManager;
import org.eclipse.stardust.common.log.Logger;
@@ -76,6 +77,7 @@ import org.eclipse.stardust.engine.core.runtime.beans.IUser;
import org.eclipse.stardust.engine.core.runtime.beans.ModelManager;
import org.eclipse.stardust.engine.core.runtime.beans.ModelManagerFactory;
import org.eclipse.stardust.engine.core.runtime.beans.ProcessInstanceBean;
+import org.eclipse.stardust.engine.core.runtime.beans.removethis.KernelTweakingProperties;
import org.eclipse.stardust.engine.core.runtime.beans.removethis.SecurityProperties;
import org.eclipse.stardust.engine.core.spi.extensions.runtime.AccessPathEvaluationContext;
import org.eclipse.stardust.engine.core.spi.extensions.runtime.ExtendedAccessPathEvaluator;
@@ -486,79 +488,83 @@ public abstract class AbstractAuthorization2Predicate implements Authorization2P
public void getExcludeUserFilter(FilterAndTerm queryFilter)
{
- List<IModel> activeModels = ModelManagerFactory.getCurrent().findActiveModels();
- for (IModel model : activeModels)
+ if (isExcludeUserEvaluationEnabled())
{
- String modelId = model.getId();
- for (IProcessDefinition process : model.getProcessDefinitions())
+ List<IModel> activeModels = ModelManagerFactory.getCurrent().findActiveModels();
+ for (IModel model : activeModels)
{
- for (IActivity activity : process.getActivities())
+ String modelId = model.getId();
+ for (IProcessDefinition process : model.getProcessDefinitions())
{
- if (activity
- .hasEventHandlers(PredefinedConstants.ACTIVITY_ON_ASSIGNMENT_CONDITION))
+ for (IActivity activity : process.getActivities())
{
- for (int k = 0; k < activity.getEventHandlers().size(); ++k)
+ if (activity
+ .hasEventHandlers(PredefinedConstants.ACTIVITY_ON_ASSIGNMENT_CONDITION))
{
- IEventHandler handler = (IEventHandler) activity.getEventHandlers()
- .get(k);
- if (((IEventConditionType) handler.getType()).getImplementation() != EventType.Pull)
+ for (int k = 0; k < activity.getEventHandlers().size(); ++k)
{
- for (Iterator l = handler.getAllEventActions(); l.hasNext();)
+ IEventHandler handler = (IEventHandler) activity
+ .getEventHandlers().get(k);
+ if (((IEventConditionType) handler.getType()).getImplementation() != EventType.Pull)
{
- IEventAction action = (IEventAction) l.next();
- PluggableType type = action.getType();
- String instanceName = type
- .getStringAttribute(PredefinedConstants.ACTION_CLASS_ATT);
- String excludeUserAction = PredefinedConstants.EXCLUDE_USER_ACTION_CLASS;
- Class classFromClassName = Reflect.getClassFromClassName(
- excludeUserAction, false);
- if (classFromClassName != null)
+ for (Iterator l = handler.getAllEventActions(); l.hasNext();)
{
- excludeUserAction = classFromClassName.getName();
- }
-
- if (instanceName.equals(excludeUserAction))
- {
- Map<String, Object> attributes = action.getAllAttributes();
- String dataId = (String) attributes
- .get(PredefinedConstants.EXCLUDED_PERFORMER_DATA);
- String dataPath = (String) attributes
- .get(PredefinedConstants.EXCLUDED_PERFORMER_DATAPATH);
-
- IData data = getData(model, dataId);
- if (data != null && !isStructuredType(data))
+ IEventAction action = (IEventAction) l.next();
+ PluggableType type = action.getType();
+ String instanceName = type
+ .getStringAttribute(PredefinedConstants.ACTION_CLASS_ATT);
+ String excludeUserAction = PredefinedConstants.EXCLUDE_USER_ACTION_CLASS;
+ Class classFromClassName = Reflect.getClassFromClassName(
+ excludeUserAction, false);
+ if (classFromClassName != null)
{
- dataPath = null;
+ excludeUserAction = classFromClassName.getName();
}
- Pair<String, String> dataKey = new Pair("{" + modelId + "}"
- + dataId, dataPath);
- if (!distinctData.contains(dataKey))
+ if (instanceName.equals(excludeUserAction))
{
- distinctData.add(dataKey);
- orderedPrefetchData.add(dataKey);
-
- DataPrefetchHint filter = new DataPrefetchHint("{"
- + modelId + "}" + dataId,
- StringUtils.isEmpty(dataPath) ? null : dataPath);
- if (trace.isDebugEnabled())
+ Map<String, Object> attributes = action
+ .getAllAttributes();
+ String dataId = (String) attributes
+ .get(PredefinedConstants.EXCLUDED_PERFORMER_DATA);
+ String dataPath = (String) attributes
+ .get(PredefinedConstants.EXCLUDED_PERFORMER_DATAPATH);
+
+ IData data = getData(model, dataId);
+ if (data != null && !isStructuredType(data))
{
- trace.debug("Adding prefetch filter: " + filter);
+ dataPath = null;
}
- if (!queryFilter.getParts().contains(filter))
- {
- queryFilter.and(filter);
- dataPrefetchHintFilter.put(dataId, filter);
- }
- else
+ Pair<String, String> dataKey = new Pair("{" + modelId
+ + "}" + dataId, dataPath);
+ if (!distinctData.contains(dataKey))
{
- int idx = queryFilter.getParts().indexOf(filter);
- filter = idx < 0
- ? filter
- : (DataPrefetchHint) queryFilter.getParts()
- .get(idx);
- dataPrefetchHintFilter.put(dataId, filter);
+ distinctData.add(dataKey);
+ orderedPrefetchData.add(dataKey);
+
+ DataPrefetchHint filter = new DataPrefetchHint("{"
+ + modelId + "}" + dataId,
+ StringUtils.isEmpty(dataPath) ? null : dataPath);
+ if (trace.isDebugEnabled())
+ {
+ trace.debug("Adding prefetch filter: " + filter);
+ }
+
+ if (!queryFilter.getParts().contains(filter))
+ {
+ queryFilter.and(filter);
+ dataPrefetchHintFilter.put(dataId, filter);
+ }
+ else
+ {
+ int idx = queryFilter.getParts().indexOf(filter);
+ filter = idx < 0
+ ? filter
+ : (DataPrefetchHint) queryFilter.getParts()
+ .get(idx);
+ dataPrefetchHintFilter.put(dataId, filter);
+ }
}
}
}
@@ -570,6 +576,12 @@ public abstract class AbstractAuthorization2Predicate implements Authorization2P
}
}
}
+
+ boolean isExcludeUserEvaluationEnabled()
+ {
+ return Parameters.instance().getBoolean(
+ KernelTweakingProperties.ENGINE_EXCLUDE_USER_EVALUATION, false);
+ }
private IData getData(IModel model, String id)
{
@@ -603,94 +615,100 @@ public abstract class AbstractAuthorization2Predicate implements Authorization2P
public boolean isExcludedUser(long activityRtOid, long processInstanceOID,
long modelOid, Map<String, Long> dataValueOids)
{
- if (processInstanceOID == 0)
+ if (isExcludeUserEvaluationEnabled())
{
- return false;
- }
+ if (processInstanceOID == 0)
+ {
+ return false;
+ }
- long dataValueOid = 0;
- IUser currentUser = SecurityProperties.getUser();
- long currentPerformer = currentUser.getOID();
+ long dataValueOid = 0;
+ IUser currentUser = SecurityProperties.getUser();
+ long currentPerformer = currentUser.getOID();
- ModelManager mm = getModelManager();
- IActivity activity = mm.findActivity(modelOid, activityRtOid);
+ ModelManager mm = getModelManager();
+ IActivity activity = mm.findActivity(modelOid, activityRtOid);
- if (activity.hasEventHandlers(PredefinedConstants.ACTIVITY_ON_ASSIGNMENT_CONDITION))
- {
- for (int k = 0; k < activity.getEventHandlers().size(); ++k)
+ if (activity
+ .hasEventHandlers(PredefinedConstants.ACTIVITY_ON_ASSIGNMENT_CONDITION))
{
- IEventHandler handler = (IEventHandler) activity.getEventHandlers().get(k);
- if (((IEventConditionType) handler.getType()).getImplementation() != EventType.Pull)
+ for (int k = 0; k < activity.getEventHandlers().size(); ++k)
{
- for (Iterator l = handler.getAllEventActions(); l.hasNext();)
+ IEventHandler handler = (IEventHandler) activity.getEventHandlers().get(k);
+ if (((IEventConditionType) handler.getType()).getImplementation() != EventType.Pull)
{
- IEventAction action = (IEventAction) l.next();
- PluggableType type = action.getType();
- String instanceName = type
- .getStringAttribute(PredefinedConstants.ACTION_CLASS_ATT);
- String excludeUserAction = PredefinedConstants.EXCLUDE_USER_ACTION_CLASS;
- Class classFromClassName = Reflect.getClassFromClassName(
- excludeUserAction, false);
- if (classFromClassName != null)
+ for (Iterator l = handler.getAllEventActions(); l.hasNext();)
{
- excludeUserAction = classFromClassName.getName();
- }
-
- if (instanceName.equals(excludeUserAction))
- {
- Map<String, Object> attributes = action.getAllAttributes();
- String dataId = (String) attributes
- .get(PredefinedConstants.EXCLUDED_PERFORMER_DATA);
- String dataPath = (String) attributes
- .get(PredefinedConstants.EXCLUDED_PERFORMER_DATAPATH);
- IData data = ModelUtils.getData(activity.getProcessDefinition(),
- dataId);
- if (dataValueOids.containsKey(dataId))
- {
- dataValueOid = dataValueOids.get(dataId);
- }
- if (PredefinedConstants.LAST_ACTIVITY_PERFORMER.equals(data.getId()))
+ IEventAction action = (IEventAction) l.next();
+ PluggableType type = action.getType();
+ String instanceName = type
+ .getStringAttribute(PredefinedConstants.ACTION_CLASS_ATT);
+ String excludeUserAction = PredefinedConstants.EXCLUDE_USER_ACTION_CLASS;
+ Class classFromClassName = Reflect.getClassFromClassName(
+ excludeUserAction, false);
+ if (classFromClassName != null)
{
- IUser lastActivityPerformer = ActivityInstanceBean
- .getLastActivityPerformer(processInstanceOID);
- Object value = lastActivityPerformer != null
- ? lastActivityPerformer.getPrimaryKey()
- : null;
- dataValueOid = getDataValueOid(value);
- }
- if (PredefinedConstants.STARTING_USER.equals(data.getId()))
- {
- IProcessInstance processInstance = ProcessInstanceBean
- .findByOID(processInstanceOID);
- IDataValue dataValue = processInstance.getDataValue(data);
- Object value = dataValue.getValue();
- dataValueOid = getDataValueOid(value);
- }
- boolean isPrimitiveStructType = false;
- if (StructuredTypeRtUtils.isStructuredType(data.getType().getId()))
- {
- IXPathMap xPathMap = DataXPathMap.getXPathMap(data);
- TypedXPath typedXPath = xPathMap.getXPath(dataPath);
- isPrimitiveStructType = StructuredDataXPathUtils
- .isPrimitiveType(typedXPath);
- }
- if (!isPrimitiveStructType && !StringUtils.isEmpty(dataPath))
- {
- IProcessInstance processInstance = ProcessInstanceBean
- .findByOID(processInstanceOID);
- IDataValue dataValue = processInstance.getDataValue(data);
- ExtendedAccessPathEvaluator evaluator = SpiUtils
- .createExtendedAccessPathEvaluator(data, dataPath);
- AccessPathEvaluationContext evaluationContext = new AccessPathEvaluationContext(
- processInstance, null, null, null);
- Object value = evaluator.evaluate(data, dataValue.getValue(),
- dataPath, evaluationContext);
- dataValueOid = getDataValueOid(value);
+ excludeUserAction = classFromClassName.getName();
}
- if (currentPerformer == dataValueOid)
+ if (instanceName.equals(excludeUserAction))
{
- return true;
+ Map<String, Object> attributes = action.getAllAttributes();
+ String dataId = (String) attributes
+ .get(PredefinedConstants.EXCLUDED_PERFORMER_DATA);
+ String dataPath = (String) attributes
+ .get(PredefinedConstants.EXCLUDED_PERFORMER_DATAPATH);
+ IData data = ModelUtils.getData(activity.getProcessDefinition(),
+ dataId);
+ if (dataValueOids.containsKey(dataId))
+ {
+ dataValueOid = dataValueOids.get(dataId);
+ }
+ if (PredefinedConstants.LAST_ACTIVITY_PERFORMER.equals(data
+ .getId()))
+ {
+ IUser lastActivityPerformer = ActivityInstanceBean
+ .getLastActivityPerformer(processInstanceOID);
+ Object value = lastActivityPerformer != null
+ ? lastActivityPerformer.getPrimaryKey()
+ : null;
+ dataValueOid = getDataValueOid(value);
+ }
+ if (PredefinedConstants.STARTING_USER.equals(data.getId()))
+ {
+ IProcessInstance processInstance = ProcessInstanceBean
+ .findByOID(processInstanceOID);
+ IDataValue dataValue = processInstance.getDataValue(data);
+ Object value = dataValue.getValue();
+ dataValueOid = getDataValueOid(value);
+ }
+ boolean isPrimitiveStructType = false;
+ if (StructuredTypeRtUtils
+ .isStructuredType(data.getType().getId()))
+ {
+ IXPathMap xPathMap = DataXPathMap.getXPathMap(data);
+ TypedXPath typedXPath = xPathMap.getXPath(dataPath);
+ isPrimitiveStructType = StructuredDataXPathUtils
+ .isPrimitiveType(typedXPath);
+ }
+ if (!isPrimitiveStructType && !StringUtils.isEmpty(dataPath))
+ {
+ IProcessInstance processInstance = ProcessInstanceBean
+ .findByOID(processInstanceOID);
+ IDataValue dataValue = processInstance.getDataValue(data);
+ ExtendedAccessPathEvaluator evaluator = SpiUtils
+ .createExtendedAccessPathEvaluator(data, dataPath);
+ AccessPathEvaluationContext evaluationContext = new AccessPathEvaluationContext(
+ processInstance, null, null, null);
+ Object value = evaluator.evaluate(data, dataValue.getValue(),
+ dataPath, evaluationContext);
+ dataValueOid = getDataValueOid(value);
+ }
+
+ if (currentPerformer == dataValueOid)
+ {
+ return true;
+ }
}
}
}