summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/Activity.java')
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/Activity.java103
1 files changed, 61 insertions, 42 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
index a0fe6a0..70b991d 100644
--- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
+++ b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
@@ -26,11 +26,14 @@ import java.util.Map;
import java.util.Vector;
import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.CannotManage;
import com.c2kernel.common.GTimeStamp;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.InvalidCollectionModification;
+import com.c2kernel.common.InvalidData;
+import com.c2kernel.common.InvalidTransition;
+import com.c2kernel.common.ObjectAlreadyExists;
+import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.agent.Job;
import com.c2kernel.events.Event;
@@ -45,7 +48,6 @@ import com.c2kernel.lookup.InvalidAgentPathException;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.Path;
import com.c2kernel.lookup.RolePath;
-import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.outcome.Outcome;
import com.c2kernel.persistency.outcome.Schema;
import com.c2kernel.persistency.outcome.Viewpoint;
@@ -101,13 +103,13 @@ public class Activity extends WfVertex
return new Next(this, vertex);
}
- public StateMachine getStateMachine() throws InvalidDataException {
+ public StateMachine getStateMachine() throws InvalidData {
if (machine == null) {
String name = (String)getProperties().get("StateMachineName");
int version = getVersionNumberProperty("StateMachineVersion");
try {
machine = LocalObjectLoader.getStateMachine(name, version);
- } catch (ObjectNotFoundException ex) {
+ } catch (ObjectNotFound ex) {
if (name.equals(getDefaultSMName()) && version == 0) { // default state machine not imported yet. Fake it.
try {
String marshalledSM = Gateway.getResource().getTextResource(null, "boot/SM/"+getDefaultSMName()+".xml");
@@ -117,24 +119,24 @@ public class Activity extends WfVertex
return bootstrap;
} catch (Exception ex2) {
Logger.error(ex2);
- throw new InvalidDataException("Could not bootstrap default state machine from resources.", "");
+ throw new InvalidData("Could not bootstrap default state machine from resources.");
}
}
Logger.error(ex);
- throw new InvalidDataException("Error loading state machine '"+name+"' v"+version, "");
+ throw new InvalidData("Error loading state machine '"+name+"' v"+version);
}
}
return machine;
}
/** return the current State of the State machine (Used in Serialisation) */
- public int getState() throws InvalidDataException
+ public int getState() throws InvalidData
{
if (state == -1)
state = getStateMachine().getInitialStateCode();
return state;
}
- public String getStateName() throws InvalidDataException
+ public String getStateName() throws InvalidData
{
return getStateMachine().getState(getState()).getName();
}
@@ -145,15 +147,19 @@ public class Activity extends WfVertex
this.state = state;
}
- public boolean isFinished() throws InvalidDataException {
+ public boolean isFinished() throws InvalidData {
return getStateMachine().getState(getState()).isFinished();
}
/** cf Item request
- * @throws ObjectNotFoundException
- * @throws PersistencyException */
- public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException
+ * @throws ObjectNotFound
+ * @throws PersistencyException
+ * @throws ObjectAlreadyExists
+ * @throws ObjectCannotBeUpdated
+ * @throws CannotManage
+ * @throws InvalidCollectionModification */
+ public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransition, InvalidData, ObjectNotFound, PersistencyException, ObjectAlreadyExists, ObjectCannotBeUpdated, CannotManage, InvalidCollectionModification
{
// Find requested transition
@@ -172,7 +178,7 @@ public class Activity extends WfVertex
if (requestData != null && requestData.length()>0)
storeOutcome = true;
else if (transition.getOutcome().isRequired())
- throw new InvalidDataException("Transition requires outcome data, but none was given", "");
+ throw new InvalidData("Transition requires outcome data, but none was given");
}
// Get new state
@@ -212,10 +218,10 @@ public class Activity extends WfVertex
Gateway.getStorage().put(itemPath, currentView, getWf());
}
Gateway.getStorage().commit(getWf());
- } catch (ClusterStorageException ex) {
+ } catch (PersistencyException ex) {
Logger.error(ex);
Gateway.getStorage().abort(getWf());
- throw new PersistencyException("Exception storing event data");
+ throw ex;
}
if (newState.isFinished()) {
@@ -231,7 +237,7 @@ public class Activity extends WfVertex
try {
RolePath myRole = Gateway.getLookup().getRolePath(agentRole);
pushJobsToAgents(itemPath, myRole);
- } catch (ObjectNotFoundException ex) { // non-existent role
+ } catch (ObjectNotFound ex) { // non-existent role
Logger.msg(7, "Activity.pushJobsToAgents() - Activity role '"+agentRole+" not found.");
}
}
@@ -241,7 +247,15 @@ public class Activity extends WfVertex
}
protected String runActivityLogic(AgentPath agent, ItemPath itemPath,
- int transitionID, String requestData) throws InvalidDataException {
+ int transitionID, String requestData) throws
+ InvalidData,
+ InvalidCollectionModification,
+ ObjectAlreadyExists,
+ ObjectCannotBeUpdated,
+ ObjectNotFound,
+ PersistencyException,
+ CannotManage
+ {
// Overriden in predefined steps
return requestData;
}
@@ -309,13 +323,14 @@ public class Activity extends WfVertex
return loop2;
}
/** sets the next activity available if possible
- * @throws ObjectNotFoundException
+ * @throws ObjectNotFound
* @throws AccessRightsException
- * @throws InvalidTransitionException
+ * @throws InvalidTransition
* @throws PersistencyException
- * @throws ObjectAlreadyExistsException */
+ * @throws ObjectAlreadyExists
+ * @throws ObjectCannotBeUpdated */
@Override
- public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidData
{
setActive(false);
try
@@ -353,7 +368,7 @@ public class Activity extends WfVertex
}
}
}
- catch (InvalidDataException s)
+ catch (InvalidData s)
{
setActive(true);
throw s;
@@ -368,10 +383,10 @@ public class Activity extends WfVertex
return null;
}
/** reinitialises the Activity and propagate (for Loop)
- * @throws InvalidDataException
- * @throws ObjectNotFoundException */
+ * @throws InvalidData
+ * @throws ObjectNotFound */
@Override
- public void reinit(int idLoop) throws InvalidDataException
+ public void reinit(int idLoop) throws InvalidData
{
Vertex[] outVertices = getOutGraphables();
setState(getStateMachine().getInitialState().getId());
@@ -391,15 +406,16 @@ public class Activity extends WfVertex
}
/**
* called by precedent Activity runNext() for setting the activity able to be executed
- * @throws InvalidDataException
- * @throws ObjectAlreadyExistsException
+ * @throws InvalidData
+ * @throws ObjectAlreadyExists
* @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws ObjectNotFoundException
+ * @throws InvalidTransition
+ * @throws ObjectNotFound
* @throws PersistencyException
+ * @throws ObjectCannotBeUpdated
*/
@Override
- public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void run(AgentPath agent, ItemPath itemPath) throws InvalidData
{
Logger.debug(8, getPath() + " run " + getState());
@@ -417,15 +433,16 @@ public class Activity extends WfVertex
}
/**
* sets the activity available to be executed on start of Workflow or composite activity (when it is the first one of the (sub)process
- * @throws InvalidDataException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectNotFoundException
+ * @throws InvalidData
+ * @throws ObjectAlreadyExists
+ * @throws ObjectNotFound
* @throws AccessRightsException
- * @throws InvalidTransitionException
+ * @throws InvalidTransition
* @throws PersistencyException
+ * @throws ObjectCannotBeUpdated
*/
@Override
- public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidData
{
Logger.debug(8, getPath() + " runfirst");
run(agent, itemPath);
@@ -458,17 +475,19 @@ public class Activity extends WfVertex
/**
* returns the lists of jobs for the activity and children (cf com.c2kernel.entity.Job)
+ * @throws InvalidData
+ * @throws ObjectNotFound
* @throws InvalidAgentPathException
*/
- public ArrayList<Job> calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
+ public ArrayList<Job> calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFound, InvalidData
{
return calculateJobsBase(agent, itemPath, false);
} //
- public ArrayList<Job> calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
+ public ArrayList<Job> calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFound, InvalidData
{
return calculateJobsBase(agent, itemPath, true);
}
- private ArrayList<Job> calculateJobsBase(AgentPath agent, ItemPath itemPath, boolean includeInactive) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
+ private ArrayList<Job> calculateJobsBase(AgentPath agent, ItemPath itemPath, boolean includeInactive) throws ObjectNotFound, InvalidData, InvalidAgentPathException
{
Logger.msg(7, "calculateJobs - " + getPath());
ArrayList<Job> jobs = new ArrayList<Job>();
@@ -491,7 +510,7 @@ public class Activity extends WfVertex
try {
RolePath myRole = Gateway.getLookup().getRolePath(agentRole);
pushJobsToAgents(itemPath, myRole);
- } catch (ObjectNotFoundException ex) { // non-existent role
+ } catch (ObjectNotFound ex) { // non-existent role
Logger.msg(7, "Activity.pushJobsToAgents() - Activity role '"+agentRole+" not found.");
}
}