From 275d0bbf555c8917be82ce4cc21eb4cabb00f4c5 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 3 Oct 2014 17:30:41 +0200 Subject: 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. --- src/main/java/com/c2kernel/entity/agent/Job.java | 44 ++++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/main/java/com/c2kernel/entity/agent/Job.java') 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()); } -- cgit v1.2.3