summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lifecycle/instance/stateMachine
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-10-03 17:30:41 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-10-03 17:30:41 +0200
commit275d0bbf555c8917be82ce4cc21eb4cabb00f4c5 (patch)
treeddcc6b14077d90d1b970b67829f07120547dbb62 /src/main/java/com/c2kernel/lifecycle/instance/stateMachine
parenta139f95bfeca603333b8c0310ae09c6805e58584 (diff)
Huge exception overhaul: Merged ClusterStorageException with
PersistencyException. Replaced MembershipException with InvalidCollectionModification CORBA Exception. Made all predef steps throw more accurate exceptions when they go wrong, and let more exceptions bubble through from underneath.
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/stateMachine')
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/stateMachine/StateMachine.java12
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/stateMachine/Transition.java22
2 files changed, 17 insertions, 17 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/StateMachine.java b/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/StateMachine.java
index efa5667..54a7267 100644
--- a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/StateMachine.java
+++ b/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/StateMachine.java
@@ -25,9 +25,9 @@ import java.util.HashMap;
import java.util.Map;
import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.InvalidData;
+import com.c2kernel.common.InvalidTransition;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.lifecycle.instance.Activity;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.utils.DescriptionObject;
@@ -142,7 +142,7 @@ public class StateMachine implements DescriptionObject
return stateCodes.get(stateID);
}
- public Map<Transition, String> getPossibleTransitions(Activity act, AgentPath agent) throws ObjectNotFoundException, InvalidDataException {
+ public Map<Transition, String> getPossibleTransitions(Activity act, AgentPath agent) throws ObjectNotFound, InvalidData {
HashMap<Transition, String> returnList = new HashMap<Transition, String>();
State currentState = getState(act.getState());
for (Integer transCode : currentState.getPossibleTransitionIds()) {
@@ -158,14 +158,14 @@ public class StateMachine implements DescriptionObject
return returnList;
}
- public State traverse(Activity act, Transition transition, AgentPath agent) throws InvalidTransitionException, AccessRightsException, ObjectNotFoundException, InvalidDataException {
+ public State traverse(Activity act, Transition transition, AgentPath agent) throws InvalidTransition, AccessRightsException, ObjectNotFound, InvalidData {
State currentState = getState(act.getState());
if (transition.originState.equals(currentState)) {
transition.getPerformingRole(act, agent);
return transition.targetState;
}
else
- throw new InvalidTransitionException("Transition '"+transition.getName()+"' not valid from state '"+currentState.getName(), "");
+ throw new InvalidTransition("Transition '"+transition.getName()+"' not valid from state '"+currentState.getName());
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/Transition.java b/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/Transition.java
index 8c6502f..78786da 100644
--- a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/Transition.java
+++ b/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/Transition.java
@@ -25,8 +25,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.InvalidData;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.lifecycle.instance.Activity;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.RolePath;
@@ -188,15 +188,15 @@ public class Transition {
this.targetStateId = targetStateId;
}
- public String getPerformingRole(Activity act, AgentPath agent) throws ObjectNotFoundException, AccessRightsException {
+ public String getPerformingRole(Activity act, AgentPath agent) throws ObjectNotFound, AccessRightsException {
// check available
if (!isEnabled(act.getProperties()))
- throw new AccessRightsException("Transition '"+name+"' is disabled by the '"+enabledProp+"' property.", "");
+ throw new AccessRightsException("Transition '"+name+"' is disabled by the '"+enabledProp+"' property.");
// check active
if (isRequiresActive() && !act.getActive())
- throw new AccessRightsException("Activity must be active to perform this transition", "");
+ throw new AccessRightsException("Activity must be active to perform this transition");
RolePath role = null;
String overridingRole = resolveValue(roleOverride, act.getProperties());
@@ -224,7 +224,7 @@ public class Transition {
// Decide the access
if (isOwned && !override && !isOwner)
throw new AccessRightsException("Agent '"+agent.getAgentName()
- +"' cannot perform this transition because the activity '"+act.getName()+"' is currently owned by "+agentName, "");
+ +"' cannot perform this transition because the activity '"+act.getName()+"' is currently owned by "+agentName);
if (role != null) {
if (agent.hasRole(role))
@@ -233,7 +233,7 @@ public class Transition {
return "Admin";
else
throw new AccessRightsException("Agent '"+agent.getAgentName()
- +"' does not hold a suitable role '"+role.getName()+"' for the activity "+act.getName(), "");
+ +"' does not hold a suitable role '"+role.getName()+"' for the activity "+act.getName());
}
else
return null;
@@ -284,13 +284,13 @@ public class Transition {
return true;
}
- public Schema getSchema(CastorHashMap actProps) throws InvalidDataException, ObjectNotFoundException {
+ public Schema getSchema(CastorHashMap actProps) throws InvalidData, ObjectNotFound {
if (hasOutcome(actProps))
try {
return LocalObjectLoader.getSchema(resolveValue(outcome.schemaName, actProps),
Integer.parseInt(resolveValue(outcome.schemaVersion, actProps)));
} catch (NumberFormatException ex) {
- throw new InvalidDataException("Bad schema version number: "+outcome.schemaVersion+" ("+resolveValue(outcome.schemaVersion, actProps)+")", "");
+ throw new InvalidData("Bad schema version number: "+outcome.schemaVersion+" ("+resolveValue(outcome.schemaVersion, actProps)+")");
}
else
return null;
@@ -300,11 +300,11 @@ public class Transition {
return resolveValue(script.scriptName, actProps);
}
- public int getScriptVersion(CastorHashMap actProps) throws InvalidDataException {
+ public int getScriptVersion(CastorHashMap actProps) throws InvalidData {
try {
return Integer.parseInt(resolveValue(script.scriptVersion, actProps));
} catch (NumberFormatException ex) {
- throw new InvalidDataException("Bad Script version number: "+script.scriptVersion+" ("+resolveValue(script.scriptVersion, actProps)+")", "");
+ throw new InvalidData("Bad Script version number: "+script.scriptVersion+" ("+resolveValue(script.scriptVersion, actProps)+")");
}
}