diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-10-03 17:30:41 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-10-03 17:30:41 +0200 |
| commit | 275d0bbf555c8917be82ce4cc21eb4cabb00f4c5 (patch) | |
| tree | ddcc6b14077d90d1b970b67829f07120547dbb62 /src/main/java/com/c2kernel/entity/agent | |
| parent | a139f95bfeca603333b8c0310ae09c6805e58584 (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/entity/agent')
4 files changed, 44 insertions, 43 deletions
diff --git a/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java b/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java index 197a360..4f3f622 100644 --- a/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java +++ b/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java @@ -21,11 +21,12 @@ package com.c2kernel.entity.agent;
import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.CannotManage;
+import com.c2kernel.common.InvalidCollectionModification;
+import com.c2kernel.common.InvalidData;
+import com.c2kernel.common.InvalidTransition;
+import com.c2kernel.common.ObjectAlreadyExists;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.common.PersistencyException;
import com.c2kernel.common.SystemKey;
import com.c2kernel.entity.AgentPOA;
@@ -85,7 +86,7 @@ public class ActiveEntity extends AgentPOA @Override
public String queryData(String path)
throws AccessRightsException,
- ObjectNotFoundException,
+ ObjectNotFound,
PersistencyException
{
synchronized (this) {
@@ -107,14 +108,14 @@ public class ActiveEntity extends AgentPOA }
@Override
- public void addRole(String roleName) throws CannotManageException, ObjectNotFoundException {
+ public void addRole(String roleName) throws CannotManage, ObjectNotFound {
synchronized (this) {
mAgentImpl.addRole(roleName);
}
}
@Override
- public void removeRole(String roleName) throws CannotManageException, ObjectNotFoundException {
+ public void removeRole(String roleName) throws CannotManage, ObjectNotFound {
synchronized (this) {
mAgentImpl.removeRole(roleName);
}
@@ -123,7 +124,7 @@ public class ActiveEntity extends AgentPOA @Override
public void initialise(SystemKey agentId, String propString, String initWfString,
String initCollsString) throws AccessRightsException,
- InvalidDataException, PersistencyException, ObjectNotFoundException {
+ InvalidData, PersistencyException, ObjectNotFound {
synchronized (this) {
mAgentImpl.initialise(agentId, propString, initWfString, initCollsString);
}
@@ -133,9 +134,9 @@ public class ActiveEntity extends AgentPOA @Override
public String requestAction(SystemKey agentID, String stepPath, int transitionID,
String requestData) throws AccessRightsException,
- InvalidTransitionException, ObjectNotFoundException,
- InvalidDataException, PersistencyException,
- ObjectAlreadyExistsException {
+ InvalidTransition, ObjectNotFound,
+ InvalidData, PersistencyException,
+ ObjectAlreadyExists, InvalidCollectionModification {
synchronized (this) {
return mAgentImpl.requestAction(agentID, stepPath, transitionID, requestData);
@@ -145,7 +146,7 @@ public class ActiveEntity extends AgentPOA @Override
public String queryLifeCycle(SystemKey agentId, boolean filter)
- throws AccessRightsException, ObjectNotFoundException,
+ throws AccessRightsException, ObjectNotFound,
PersistencyException {
synchronized (this) {
return mAgentImpl.queryLifeCycle(agentId, filter);
diff --git a/src/main/java/com/c2kernel/entity/agent/ActiveLocator.java b/src/main/java/com/c2kernel/entity/agent/ActiveLocator.java index ecc9d42..4b389ec 100644 --- a/src/main/java/com/c2kernel/entity/agent/ActiveLocator.java +++ b/src/main/java/com/c2kernel/entity/agent/ActiveLocator.java @@ -24,7 +24,7 @@ package com.c2kernel.entity.agent; import java.nio.ByteBuffer;
import java.sql.Timestamp;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.common.SystemKey;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.InvalidItemPathException;
@@ -73,7 +73,7 @@ public class ActiveLocator extends org.omg.PortableServer.ServantLocatorPOA return Gateway.getCorbaServer().getAgent(syskey);
}
- catch (ObjectNotFoundException ex)
+ catch (ObjectNotFound ex)
{
Logger.error("ObjectNotFoundException::ActiveLocator::preinvoke() "+ex.toString());
throw new org.omg.CORBA.OBJECT_NOT_EXIST();
diff --git a/src/main/java/com/c2kernel/entity/agent/AgentImplementation.java b/src/main/java/com/c2kernel/entity/agent/AgentImplementation.java index c9eee73..97f5ae4 100644 --- a/src/main/java/com/c2kernel/entity/agent/AgentImplementation.java +++ b/src/main/java/com/c2kernel/entity/agent/AgentImplementation.java @@ -20,9 +20,9 @@ */
package com.c2kernel.entity.agent;
-import com.c2kernel.common.CannotManageException;
+import com.c2kernel.common.CannotManage;
import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.common.SystemKey;
import com.c2kernel.entity.AgentOperations;
import com.c2kernel.entity.ItemImplementation;
@@ -77,22 +77,22 @@ public class AgentImplementation extends ItemImplementation implements }
@Override
- public void addRole(String roleName) throws CannotManageException, ObjectNotFoundException {
+ public void addRole(String roleName) throws CannotManage, ObjectNotFound {
RolePath newRole = Gateway.getLookup().getRolePath(roleName);
try {
Gateway.getLookupManager().addRole(mAgentPath, newRole);
} catch (ObjectCannotBeUpdated ex) {
- throw new CannotManageException("Could not update role");
+ throw new CannotManage("Could not update role");
}
}
@Override
- public void removeRole(String roleName) throws CannotManageException, ObjectNotFoundException {
+ public void removeRole(String roleName) throws CannotManage, ObjectNotFound {
RolePath rolePath = Gateway.getLookup().getRolePath(roleName);
try {
Gateway.getLookupManager().removeRole(mAgentPath, rolePath);
} catch (ObjectCannotBeUpdated ex) {
- throw new CannotManageException("Could not update role");
+ throw new CannotManage("Could not update role");
}
}
diff --git a/src/main/java/com/c2kernel/entity/agent/Job.java b/src/main/java/com/c2kernel/entity/agent/Job.java index 3e400da..7172bbb 100644 --- a/src/main/java/com/c2kernel/entity/agent/Job.java +++ b/src/main/java/com/c2kernel/entity/agent/Job.java @@ -22,8 +22,9 @@ package com.c2kernel.entity.agent; import java.util.HashMap;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.InvalidData;
+import com.c2kernel.common.ObjectNotFound;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.entity.proxy.ItemProxy;
import com.c2kernel.lifecycle.instance.Activity;
@@ -33,7 +34,6 @@ import com.c2kernel.lookup.InvalidAgentPathException; import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.outcome.Outcome;
import com.c2kernel.persistency.outcome.OutcomeInitiator;
import com.c2kernel.persistency.outcome.Schema;
@@ -100,7 +100,7 @@ public class Job implements C2KLocalObject {
}
- public Job(Activity act, ItemPath itemPath, Transition transition, AgentPath agent, String role) throws InvalidDataException, ObjectNotFoundException, InvalidAgentPathException {
+ public Job(Activity act, ItemPath itemPath, Transition transition, AgentPath agent, String role) throws InvalidData, ObjectNotFound, InvalidAgentPathException {
setItemPath(itemPath);
setStepPath(act.getPath());
@@ -192,7 +192,7 @@ public class Job implements C2KLocalObject this.transition = transition;
}
- public AgentPath getAgentPath() throws ObjectNotFoundException {
+ public AgentPath getAgentPath() throws ObjectNotFound {
if (agentPath == null && getAgentName() != null) {
agentPath = Gateway.getLookup().getAgentPath(getAgentName());
}
@@ -218,7 +218,7 @@ public class Job implements C2KLocalObject try {
if (getAgentPath() != null)
return getAgentPath().getUUID().toString();
- } catch (ObjectNotFoundException e) { }
+ } catch (ObjectNotFound e) { }
return null;
}
@@ -229,7 +229,7 @@ public class Job implements C2KLocalObject return agentName;
}
- public void setAgentName(String agentName) throws ObjectNotFoundException
+ public void setAgentName(String agentName) throws ObjectNotFound
{
this.agentName = agentName;
agentPath = Gateway.getLookup().getAgentPath(agentName);
@@ -243,7 +243,7 @@ public class Job implements C2KLocalObject agentRole = role;
}
- public String getSchemaName() throws InvalidDataException, ObjectNotFoundException {
+ public String getSchemaName() throws InvalidData, ObjectNotFound {
if (transition.hasOutcome(actProps)) {
Schema schema = transition.getSchema(actProps);
return schema.docType;
@@ -251,7 +251,7 @@ public class Job implements C2KLocalObject return null;
}
- public int getSchemaVersion() throws InvalidDataException, ObjectNotFoundException {
+ public int getSchemaVersion() throws InvalidData, ObjectNotFound {
if (transition.hasOutcome(actProps)) {
Schema schema = transition.getSchema(actProps);
return schema.docVersion;
@@ -271,7 +271,7 @@ public class Job implements C2KLocalObject return null;
}
- public int getScriptVersion() throws InvalidDataException {
+ public int getScriptVersion() throws InvalidData {
if (transition.hasScript(actProps)) {
return transition.getScriptVersion(actProps);
}
@@ -303,7 +303,7 @@ public class Job implements C2KLocalObject }
}
- public ItemProxy getItemProxy() throws ObjectNotFoundException, InvalidItemPathException {
+ public ItemProxy getItemProxy() throws ObjectNotFound, InvalidItemPathException {
if (item == null)
item = Gateway.getProxyManager().getProxy(itemPath);
return item;
@@ -333,26 +333,26 @@ public class Job implements C2KLocalObject }
}
- public String getLastView() throws InvalidDataException {
+ public String getLastView() throws InvalidData {
String viewName = (String) getActProp("Viewpoint");
if (viewName.length() > 0) {
// find schema
String schemaName;
try {
schemaName = getSchemaName();
- } catch (ObjectNotFoundException e1) {
- throw new InvalidDataException("Schema "+getActProp("SchemaType")+" v"+getActProp("SchemaVersion")+" not found");
+ } catch (ObjectNotFound e1) {
+ throw new InvalidData("Schema "+getActProp("SchemaType")+" v"+getActProp("SchemaVersion")+" not found");
}
try {
Viewpoint view = (Viewpoint) Gateway.getStorage().get(itemPath,
ClusterStorage.VIEWPOINT + "/" + schemaName + "/" + viewName, null);
return view.getOutcome().getData();
- } catch (ObjectNotFoundException ex) { // viewpoint doesn't exist yet
+ } catch (ObjectNotFound ex) { // viewpoint doesn't exist yet
return null;
- } catch (ClusterStorageException e) {
+ } catch (PersistencyException e) {
Logger.error(e);
- throw new InvalidDataException("ViewpointOutcomeInitiator: ClusterStorageException loading viewpoint "
+ throw new InvalidData("ViewpointOutcomeInitiator: PersistencyException loading viewpoint "
+ ClusterStorage.VIEWPOINT + "/" + schemaName + "/" + viewName+" in item "+itemPath.getUUID());
}
}
@@ -360,7 +360,7 @@ public class Job implements C2KLocalObject return null;
}
- public OutcomeInitiator getOutcomeInitiator() throws InvalidDataException {
+ public OutcomeInitiator getOutcomeInitiator() throws InvalidData {
String ocInitName = (String) getActProp("OutcomeInit");
OutcomeInitiator ocInit;
if (ocInitName.length() > 0) {
@@ -370,13 +370,13 @@ public class Job implements C2KLocalObject if (ocInit == null) {
Object ocInitObj;
if (!Gateway.getProperties().containsKey(ocPropName)) {
- throw new InvalidDataException("Outcome instantiator "+ocPropName+" isn't defined", "");
+ throw new InvalidData("Outcome instantiator "+ocPropName+" isn't defined");
}
try {
ocInitObj = Gateway.getProperties().getInstance(ocPropName);
} catch (Exception e) {
Logger.error(e);
- throw new InvalidDataException("Outcome instantiator "+ocPropName+" couldn't be instantiated", "");
+ throw new InvalidData("Outcome instantiator "+ocPropName+" couldn't be instantiated");
}
ocInit = (OutcomeInitiator)ocInitObj; // throw runtime class cast if it isn't one
ocInitCache.put(ocPropName, ocInit);
@@ -388,7 +388,7 @@ public class Job implements C2KLocalObject return null;
}
- public String getOutcomeString() throws InvalidDataException
+ public String getOutcomeString() throws InvalidData
{
if (outcomeData == null && transition.hasOutcome(actProps)) {
outcomeData = getLastView();
@@ -402,7 +402,7 @@ public class Job implements C2KLocalObject return outcomeData;
}
- public Outcome getOutcome() throws InvalidDataException, ObjectNotFoundException
+ public Outcome getOutcome() throws InvalidData, ObjectNotFound
{
return new Outcome(-1, getOutcomeString(), getSchemaName(), getSchemaVersion());
}
|
