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/CorbaServer.java | 30 +++---- .../com/c2kernel/entity/ItemImplementation.java | 73 +++++++-------- .../java/com/c2kernel/entity/TraceableEntity.java | 28 +++--- .../java/com/c2kernel/entity/TraceableLocator.java | 4 +- .../com/c2kernel/entity/agent/ActiveEntity.java | 27 +++--- .../com/c2kernel/entity/agent/ActiveLocator.java | 4 +- .../c2kernel/entity/agent/AgentImplementation.java | 12 +-- src/main/java/com/c2kernel/entity/agent/Job.java | 44 ++++----- .../com/c2kernel/entity/imports/ImportAgent.java | 16 ++-- .../c2kernel/entity/imports/ImportAggregation.java | 12 +-- .../c2kernel/entity/imports/ImportDependency.java | 8 +- .../com/c2kernel/entity/imports/ImportItem.java | 54 +++++------ .../com/c2kernel/entity/imports/ImportOutcome.java | 4 +- .../com/c2kernel/entity/imports/ImportRole.java | 10 +-- .../java/com/c2kernel/entity/proxy/AgentProxy.java | 100 +++++++++++---------- .../java/com/c2kernel/entity/proxy/ItemProxy.java | 81 +++++++++-------- .../c2kernel/entity/proxy/MemberSubscription.java | 6 +- .../entity/proxy/ProxyClientConnection.java | 6 +- .../com/c2kernel/entity/proxy/ProxyManager.java | 14 +-- .../com/c2kernel/entity/proxy/ProxyMessage.java | 10 +-- .../entity/proxy/ProxyServerConnection.java | 4 +- .../com/c2kernel/entity/transfer/TransferItem.java | 6 +- 22 files changed, 274 insertions(+), 279 deletions(-) (limited to 'src/main/java/com/c2kernel/entity') diff --git a/src/main/java/com/c2kernel/entity/CorbaServer.java b/src/main/java/com/c2kernel/entity/CorbaServer.java index f2b2316..76637c6 100644 --- a/src/main/java/com/c2kernel/entity/CorbaServer.java +++ b/src/main/java/com/c2kernel/entity/CorbaServer.java @@ -27,10 +27,10 @@ import org.omg.PortableServer.POAManager; import org.omg.PortableServer.Servant; import org.omg.PortableServer.POAManagerPackage.AdapterInactive; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.agent.ActiveEntity; import com.c2kernel.entity.agent.ActiveLocator; import com.c2kernel.lookup.AgentPath; @@ -57,7 +57,7 @@ public class CorbaServer { private POA mAgentPOA; private POAManager mPOAManager; - public CorbaServer() throws InvalidDataException { + public CorbaServer() throws InvalidData { mItemCache = new SoftCache(50); // init POA @@ -66,7 +66,7 @@ public class CorbaServer { mPOAManager.activate(); } catch (Exception ex) { Logger.error(ex); - throw new InvalidDataException("Error initialising POA", ""); + throw new InvalidData("Error initialising POA"); } new Thread(new Runnable() { @@ -136,11 +136,11 @@ public class CorbaServer { /************************************************************************** * Returns a CORBA servant for a pre-existing entity - * @throws ObjectNotFoundException + * @throws ObjectNotFound **************************************************************************/ - public TraceableEntity getItem(ItemPath itemPath) throws ObjectNotFoundException { + public TraceableEntity getItem(ItemPath itemPath) throws ObjectNotFound { Servant item = null; - if (!itemPath.exists()) throw new ObjectNotFoundException(itemPath+" does not exist", ""); + if (!itemPath.exists()) throw new ObjectNotFound(itemPath+" does not exist"); synchronized (mItemCache) { item = mItemCache.get(itemPath); if (item == null) { @@ -155,9 +155,9 @@ public class CorbaServer { /************************************************************************** * Returns a CORBA servant for a pre-existing entity **************************************************************************/ - public ActiveEntity getAgent(AgentPath agentPath) throws InvalidAgentPathException, ObjectNotFoundException { + public ActiveEntity getAgent(AgentPath agentPath) throws InvalidAgentPathException, ObjectNotFound { Servant agent = null; - if (!agentPath.exists()) throw new ObjectNotFoundException(agentPath+" does not exist", ""); + if (!agentPath.exists()) throw new ObjectNotFound(agentPath+" does not exist"); synchronized (mItemCache) { agent = mItemCache.get(agentPath); if (agent == null) { @@ -175,9 +175,9 @@ public class CorbaServer { * @param itemPath * @return */ - public TraceableEntity createItem(ItemPath itemPath) throws CannotManageException, ObjectAlreadyExistsException { + public TraceableEntity createItem(ItemPath itemPath) throws CannotManage, ObjectAlreadyExists { - if (itemPath.exists()) throw new ObjectAlreadyExistsException(); + if (itemPath.exists()) throw new ObjectAlreadyExists(); org.omg.CORBA.Object obj = mItemPOA.create_reference_with_id(itemPath.getOID(), ItemHelper.id()); itemPath.setIOR(obj); TraceableEntity item = new TraceableEntity(itemPath, mItemPOA); @@ -187,8 +187,8 @@ public class CorbaServer { return item; } - public ActiveEntity createAgent(AgentPath agentPath) throws CannotManageException, ObjectAlreadyExistsException { - if (agentPath.exists()) throw new ObjectAlreadyExistsException(); + public ActiveEntity createAgent(AgentPath agentPath) throws CannotManage, ObjectAlreadyExists { + if (agentPath.exists()) throw new ObjectAlreadyExists(); org.omg.CORBA.Object obj = mAgentPOA.create_reference_with_id(agentPath.getOID(), AgentHelper.id()); agentPath.setIOR(obj); ActiveEntity agent; diff --git a/src/main/java/com/c2kernel/entity/ItemImplementation.java b/src/main/java/com/c2kernel/entity/ItemImplementation.java index 23080f1..a33607b 100644 --- a/src/main/java/com/c2kernel/entity/ItemImplementation.java +++ b/src/main/java/com/c2kernel/entity/ItemImplementation.java @@ -25,10 +25,11 @@ import java.util.UUID; import com.c2kernel.collection.Collection; import com.c2kernel.collection.CollectionArrayList; import com.c2kernel.common.AccessRightsException; -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.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.common.SystemKey; import com.c2kernel.entity.agent.JobArrayList; @@ -43,7 +44,6 @@ import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.InvalidItemPathException; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.TransactionManager; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.persistency.outcome.Viewpoint; @@ -74,7 +74,7 @@ public class ItemImplementation implements ItemOperations { @Override public void initialise(SystemKey agentId, String propString, String initWfString, String initCollsString) throws AccessRightsException, - InvalidDataException, PersistencyException + InvalidData, PersistencyException { Logger.msg(5, "Item::initialise("+mItemPath+") - agent:"+agentId); Object locker = new Object(); @@ -88,7 +88,7 @@ public class ItemImplementation implements ItemOperations { // must supply properties if (propString == null || propString.length() == 0) { - throw new InvalidDataException("No properties supplied", ""); + throw new InvalidData("No properties supplied"); } // store properties @@ -102,7 +102,7 @@ public class ItemImplementation implements ItemOperations { + ") - Properties were invalid: " + propString); Logger.error(ex); mStorage.abort(locker); - throw new InvalidDataException("Properties were invalid", ""); + throw new InvalidData("Properties were invalid"); } // Store an event and the initial properties @@ -120,7 +120,7 @@ public class ItemImplementation implements ItemOperations { + ") - Could not store event and outcome."); Logger.error(ex); mStorage.abort(locker); - throw new PersistencyException("Error storing event and outcome", ""); + throw new PersistencyException("Error storing event and outcome"); } // create wf @@ -138,7 +138,7 @@ public class ItemImplementation implements ItemOperations { + ") - Workflow was invalid: " + initWfString); Logger.error(ex); mStorage.abort(locker); - throw new InvalidDataException("Workflow was invalid", ""); + throw new InvalidData("Workflow was invalid"); } // init collections @@ -155,7 +155,7 @@ public class ItemImplementation implements ItemOperations { + initCollsString); Logger.error(ex); mStorage.abort(locker); - throw new InvalidDataException("Collections were invalid"); + throw new InvalidData("Collections were invalid"); } } @@ -173,9 +173,9 @@ public class ItemImplementation implements ItemOperations { @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 { try { @@ -200,44 +200,42 @@ public class ItemImplementation implements ItemOperations { } catch (AccessRightsException ex) { Logger.msg("Propagating AccessRightsException back to the calling agent"); throw ex; - } catch (InvalidTransitionException ex) { + } catch (InvalidTransition ex) { Logger.msg("Propagating InvalidTransitionException back to the calling agent"); throw ex; - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { Logger.msg("Propagating ObjectNotFoundException back to the calling agent"); throw ex; // errors - } catch (ClusterStorageException ex) { - Logger.error(ex); - throw new PersistencyException("Error on storage: " - + ex.getMessage(), ""); } catch (InvalidItemPathException ex) { Logger.error(ex); - throw new AccessRightsException("Invalid Agent Id: " + agentId, - ""); - } catch (InvalidDataException ex) { + throw new AccessRightsException("Invalid Agent Id: " + agentId); + } catch (InvalidData ex) { Logger.error(ex); Logger.msg("Propagating InvalidDataException back to the calling agent"); throw ex; - } catch (ObjectAlreadyExistsException ex) { + } catch (ObjectAlreadyExists ex) { Logger.error(ex); Logger.msg("Propagating ObjectAlreadyExistsException back to the calling agent"); throw ex; - // non-CORBA exception hasn't been caught! - } catch (Throwable ex) { + } catch (InvalidCollectionModification ex) { + Logger.error(ex); + Logger.msg("Propagating InvalidCollectionModification back to the calling agent"); + throw ex; + } catch (Throwable ex) { // non-CORBA exception hasn't been caught! Logger.error("Unknown Error: requestAction on " + mItemPath + " by " + agentId + " executing " + stepPath); Logger.error(ex); - throw new InvalidDataException( + throw new InvalidData( "Extraordinary Exception during execution:" + ex.getClass().getName() + " - " - + ex.getMessage(), ""); + + ex.getMessage()); } } @Override public String queryLifeCycle(SystemKey agentId, boolean filter) - throws AccessRightsException, ObjectNotFoundException, + throws AccessRightsException, ObjectNotFound, PersistencyException { Logger.msg(1, "TraceableEntity::queryLifeCycle(" + mItemPath + ") - agent: " + agentId); @@ -250,15 +248,8 @@ public class ItemImplementation implements ItemOperations { + " doesn't exist"); } Workflow wf; - try { - wf = (Workflow) mStorage.get(mItemPath, - ClusterStorage.LIFECYCLE + "/workflow", null); - } catch (ClusterStorageException e) { - Logger.error("TraceableEntity::queryLifeCycle(" - + mItemPath + ") - Error loading workflow"); - Logger.error(e); - throw new PersistencyException("Error loading workflow"); - } + wf = (Workflow) mStorage.get(mItemPath, + ClusterStorage.LIFECYCLE + "/workflow", null); JobArrayList jobBag = new JobArrayList(); CompositeActivity domainWf = (CompositeActivity) wf .search("workflow/domain"); @@ -284,7 +275,7 @@ public class ItemImplementation implements ItemOperations { @Override public String queryData(String path) throws AccessRightsException, - ObjectNotFoundException, PersistencyException { + ObjectNotFound, PersistencyException { String result = ""; @@ -312,13 +303,13 @@ public class ItemImplementation implements ItemOperations { // marshall it, or in the case of an outcome get the data. result = Gateway.getMarshaller().marshall(obj); } - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { throw ex; } catch (Throwable ex) { Logger.warning("TraceableEntity::queryData(" + mItemPath + ") - " + path + " Failed: " + ex.getClass().getName()); throw new PersistencyException("Server exception: " - + ex.getClass().getName(), ""); + + ex.getClass().getName()); } if (Logger.doLog(9)) diff --git a/src/main/java/com/c2kernel/entity/TraceableEntity.java b/src/main/java/com/c2kernel/entity/TraceableEntity.java index 3c7a317..18bb987 100644 --- a/src/main/java/com/c2kernel/entity/TraceableEntity.java +++ b/src/main/java/com/c2kernel/entity/TraceableEntity.java @@ -22,10 +22,11 @@ package com.c2kernel.entity; import com.c2kernel.common.AccessRightsException; -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.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.common.SystemKey; import com.c2kernel.lookup.ItemPath; @@ -109,7 +110,7 @@ public class TraceableEntity extends ItemPOA String initCollsString ) throws AccessRightsException, - InvalidDataException, + InvalidData, PersistencyException { synchronized (this) { @@ -117,7 +118,8 @@ public class TraceableEntity extends ItemPOA } } - /************************************************************************** + /** + * @throws InvalidCollectionModification * **************************************************************************/ //requestdata is xmlstring @@ -128,11 +130,11 @@ public class TraceableEntity extends ItemPOA String requestData ) throws AccessRightsException, - InvalidTransitionException, - ObjectNotFoundException, - InvalidDataException, + InvalidTransition, + ObjectNotFound, + InvalidData, PersistencyException, - ObjectAlreadyExistsException + ObjectAlreadyExists, InvalidCollectionModification { synchronized (this) { return mItemImpl.requestAction(agentId, stepPath, transitionID, requestData); @@ -147,7 +149,7 @@ public class TraceableEntity extends ItemPOA boolean filter ) throws AccessRightsException, - ObjectNotFoundException, + ObjectNotFound, PersistencyException { synchronized (this) { @@ -164,12 +166,12 @@ public class TraceableEntity extends ItemPOA * @return The result string in xml format * except 'all' which returns a comma sep list * - * @exception ObjectNotFoundException + * @exception ObjectNotFound * ************************************************************************/ @Override public String queryData(String path) throws AccessRightsException, - ObjectNotFoundException, + ObjectNotFound, PersistencyException { synchronized (this) { diff --git a/src/main/java/com/c2kernel/entity/TraceableLocator.java b/src/main/java/com/c2kernel/entity/TraceableLocator.java index faad884..4fc695e 100644 --- a/src/main/java/com/c2kernel/entity/TraceableLocator.java +++ b/src/main/java/com/c2kernel/entity/TraceableLocator.java @@ -24,7 +24,7 @@ package com.c2kernel.entity; 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.ItemPath; import com.c2kernel.process.Gateway; @@ -68,7 +68,7 @@ public class TraceableLocator extends org.omg.PortableServer.ServantLocatorPOA try { return Gateway.getCorbaServer().getItem(syskey); - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { Logger.error("ObjectNotFoundException::TraceableLocator::preinvoke() " + ex.toString()); throw new org.omg.CORBA.OBJECT_NOT_EXIST(); } 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()); } diff --git a/src/main/java/com/c2kernel/entity/imports/ImportAgent.java b/src/main/java/com/c2kernel/entity/imports/ImportAgent.java index a436a03..33619fa 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportAgent.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportAgent.java @@ -22,10 +22,10 @@ package com.c2kernel.entity.imports; import java.util.ArrayList; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.ObjectAlreadyExistsException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.ObjectAlreadyExists; import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.agent.ActiveEntity; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; @@ -51,7 +51,7 @@ public class ImportAgent extends ModuleImport { } @Override - public void create(AgentPath agentPath, boolean reset) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException { + public void create(AgentPath agentPath, boolean reset) throws ObjectNotFound, ObjectCannotBeUpdated, CannotManage, ObjectAlreadyExists { AgentPath newAgent = new AgentPath(getItemPath(), name); newAgent.setPassword(password); ActiveEntity newAgentEnt = Gateway.getCorbaServer().createAgent(newAgent); @@ -63,14 +63,14 @@ public class ImportAgent extends ModuleImport { newAgentEnt.initialise(agentPath.getSystemKey(), Gateway.getMarshaller().marshall(new PropertyArrayList(properties)), null, null); } catch (Exception ex) { Logger.error(ex); - throw new CannotManageException("Error initialising new agent"); + throw new CannotManage("Error initialising new agent"); } for (String role : roles) { RolePath thisRole; try { thisRole = Gateway.getLookup().getRolePath(role); - } catch (ObjectNotFoundException ex) { - throw new ObjectNotFoundException("Role "+role+" does not exist.", ""); + } catch (ObjectNotFound ex) { + throw new ObjectNotFound("Role "+role+" does not exist."); } Gateway.getLookupManager().addRole(newAgent, thisRole); } @@ -83,7 +83,7 @@ public class ImportAgent extends ModuleImport { try { AgentPath existAgent = Gateway.getLookup().getAgentPath(name); itemPath = existAgent; - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { itemPath = new AgentPath(new ItemPath(), name); } } diff --git a/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java b/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java index b8e9eb2..5d2c350 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java @@ -25,8 +25,9 @@ import java.util.ArrayList; import com.c2kernel.collection.Aggregation; import com.c2kernel.collection.AggregationDescription; import com.c2kernel.collection.AggregationInstance; -import com.c2kernel.collection.MembershipException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.InvalidItemPathException; @@ -52,7 +53,7 @@ public class ImportAggregation { this.isDescription = isDescription; } - public com.c2kernel.collection.Aggregation create() throws MembershipException, ObjectNotFoundException { + public com.c2kernel.collection.Aggregation create() throws InvalidCollectionModification, ObjectNotFound, ObjectAlreadyExists { Aggregation newAgg = isDescription?new AggregationDescription(name):new AggregationInstance(name); if (version!= null) newAgg.setVersion(version); for (ImportAggregationMember thisMem : aggregationMemberList) { @@ -73,15 +74,16 @@ public class ImportAggregation { classProps.append((classProps.length()>0?",":"")).append(pd.getName()); } } + ItemPath itemPath = null; if (thisMem.itemPath != null && thisMem.itemPath.length()>0) { - ItemPath itemPath; + try { itemPath = new ItemPath(thisMem.itemPath); } catch (InvalidItemPathException ex) { itemPath = new DomainPath(thisMem.itemPath).getItemPath(); } - newAgg.addMember(itemPath, thisMem.props, classProps.toString(), new GraphPoint(thisMem.geometry.x, thisMem.geometry.y), thisMem.geometry.width, thisMem.geometry.height); } + newAgg.addMember(itemPath, thisMem.props, classProps.toString(), new GraphPoint(thisMem.geometry.x, thisMem.geometry.y), thisMem.geometry.width, thisMem.geometry.height); } return newAgg; } diff --git a/src/main/java/com/c2kernel/entity/imports/ImportDependency.java b/src/main/java/com/c2kernel/entity/imports/ImportDependency.java index 3f528bf..7373bdb 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportDependency.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportDependency.java @@ -24,8 +24,9 @@ import java.util.ArrayList; import com.c2kernel.collection.Dependency; import com.c2kernel.collection.DependencyDescription; -import com.c2kernel.collection.MembershipException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.InvalidItemPathException; import com.c2kernel.lookup.ItemPath; @@ -64,8 +65,9 @@ public class ImportDependency { /** * @return + * @throws ObjectAlreadyExists */ - public com.c2kernel.collection.Dependency create() throws MembershipException, ObjectNotFoundException { + public com.c2kernel.collection.Dependency create() throws InvalidCollectionModification, ObjectNotFound, ObjectAlreadyExists { Dependency newDep = isDescription?new DependencyDescription(name):new Dependency(name); if (version!= null) newDep.setVersion(version); if (itemDescriptionPath != null && itemDescriptionPath.length()>0) { diff --git a/src/main/java/com/c2kernel/entity/imports/ImportItem.java b/src/main/java/com/c2kernel/entity/imports/ImportItem.java index ba24289..74362d5 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportItem.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportItem.java @@ -29,12 +29,13 @@ import org.custommonkey.xmlunit.XMLUnit; import com.c2kernel.collection.Aggregation; import com.c2kernel.collection.CollectionArrayList; import com.c2kernel.collection.Dependency; -import com.c2kernel.collection.MembershipException; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectAlreadyExists; import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.TraceableEntity; import com.c2kernel.events.Event; import com.c2kernel.events.History; @@ -44,7 +45,6 @@ import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; 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.Viewpoint; import com.c2kernel.process.Gateway; @@ -90,7 +90,7 @@ public class ImportItem extends ModuleImport { if (existingItem.exists()) { try { itemPath = existingItem.getItemPath(); - } catch (ObjectNotFoundException ex) { } + } catch (ObjectNotFound ex) { } } } if (itemPath == null) itemPath = new ItemPath(); @@ -109,12 +109,12 @@ public class ImportItem extends ModuleImport { } @Override - public void create(AgentPath agentPath, boolean reset) throws ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException { + public void create(AgentPath agentPath, boolean reset) throws ObjectCannotBeUpdated, ObjectNotFound, CannotManage, ObjectAlreadyExists, InvalidCollectionModification { DomainPath domPath = new DomainPath(new DomainPath(initialPath), name); if (domPath.exists()) { ItemPath domItem = domPath.getItemPath(); if (!getItemPath().equals(domItem)) - throw new CannotManageException("Item "+domPath+" was found with the wrong itemPath ("+domPath.getItemPath()+" vs "+getItemPath()+")", ""); + throw new CannotManage("Item "+domPath+" was found with the wrong itemPath ("+domPath.getItemPath()+" vs "+getItemPath()+")"); } TraceableEntity newItem; @@ -139,32 +139,22 @@ public class ImportItem extends ModuleImport { else usedWfVer = workflowVer.intValue(); try { compact = (CompositeActivityDef)LocalObjectLoader.getActDef(workflow, usedWfVer); - } catch (ObjectNotFoundException ex) { - throw new CannotManageException("Could not find workflow "+workflow+"v"+usedWfVer+" for item "+domPath, ""); - } catch (InvalidDataException e) { - throw new CannotManageException("Workflow def "+workflow+" v"+usedWfVer+" for item "+domPath+" was not valid", ""); + } catch (ObjectNotFound ex) { + throw new CannotManage("Could not find workflow "+workflow+"v"+usedWfVer+" for item "+domPath); + } catch (InvalidData e) { + throw new CannotManage("Workflow def "+workflow+" v"+usedWfVer+" for item "+domPath+" was not valid"); } // create collections CollectionArrayList colls = new CollectionArrayList(); for (ImportDependency element: dependencyList) { - try { - Dependency newDep = element.create(); - colls.put(newDep); - } catch (MembershipException ex) { - Logger.error(ex); - throw new CannotManageException("A specified member is not of the correct type in "+element.name, ""); - } + Dependency newDep = element.create(); + colls.put(newDep); } for (ImportAggregation element : aggregationList) { - try { - Aggregation newAgg = element.create(); - colls.put(newAgg); - } catch (MembershipException ex) { - Logger.error(ex); - throw new CannotManageException("A specified member is not of the correct type in "+element.name, ""); - } + Aggregation newAgg = element.create(); + colls.put(newAgg); } // (re)initialise the new item with properties, workflow and collections @@ -177,7 +167,7 @@ public class ImportItem extends ModuleImport { } catch (Exception ex) { Logger.error("Error initialising new item "+name ); Logger.error(ex); - throw new CannotManageException("Problem initialising new item. See server log.", ""); + throw new CannotManage("Problem initialising new item. See server log."); } // import outcomes @@ -202,12 +192,12 @@ public class ImportItem extends ModuleImport { continue; } } - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { Logger.msg(3, "View "+thisOutcome.schema+"/"+thisOutcome.viewname+" not found in "+name+". Creating."); impView = new Viewpoint(getItemPath(), thisOutcome.schema, thisOutcome.viewname, thisOutcome.version, -1); - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { throw new ObjectCannotBeUpdated("Could not check data for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name); - } catch (InvalidDataException e) { + } catch (InvalidData e) { throw new ObjectCannotBeUpdated("Could not check previous event for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name); } @@ -219,7 +209,7 @@ public class ImportItem extends ModuleImport { try { Gateway.getStorage().put(getItemPath(), newOutcome, null); Gateway.getStorage().put(getItemPath(), impView, null); - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { throw new ObjectCannotBeUpdated("Could not store data for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name); } } diff --git a/src/main/java/com/c2kernel/entity/imports/ImportOutcome.java b/src/main/java/com/c2kernel/entity/imports/ImportOutcome.java index 60279dc..915f52d 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportOutcome.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportOutcome.java @@ -20,7 +20,7 @@ */ package com.c2kernel.entity.imports; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.process.Gateway; public class ImportOutcome { @@ -38,7 +38,7 @@ public class ImportOutcome { this.path = path; } - public String getData(String ns) throws ObjectNotFoundException { + public String getData(String ns) throws ObjectNotFound { if (data == null) data = Gateway.getResource().getTextResource(ns, path); return data; diff --git a/src/main/java/com/c2kernel/entity/imports/ImportRole.java b/src/main/java/com/c2kernel/entity/imports/ImportRole.java index 25e6c36..2c24887 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportRole.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportRole.java @@ -22,10 +22,10 @@ package com.c2kernel.entity.imports; import java.util.Iterator; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.ObjectAlreadyExistsException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.ObjectAlreadyExists; import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.Path; import com.c2kernel.lookup.RolePath; @@ -40,7 +40,7 @@ public class ImportRole extends ModuleImport { } @Override - public void create(AgentPath agentPath, boolean reset) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException, ObjectNotFoundException { + public void create(AgentPath agentPath, boolean reset) throws ObjectAlreadyExists, ObjectCannotBeUpdated, CannotManage, ObjectNotFound { RolePath parent = new RolePath(); if (name.indexOf('/') > -1) { String[] roleComp = name.split("/"); @@ -55,7 +55,7 @@ public class ImportRole extends ModuleImport { break; } } - if (!found) throw new ObjectNotFoundException("Parent role "+roleComp[i]+" was not found", ""); + if (!found) throw new ObjectNotFound("Parent role "+roleComp[i]+" was not found"); } name = roleComp[roleComp.length-1]; } diff --git a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java index 10a8f02..7e6b3e4 100644 --- a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java @@ -24,10 +24,11 @@ import java.util.Date; import java.util.Iterator; import com.c2kernel.common.AccessRightsException; -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.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.Agent; import com.c2kernel.entity.AgentHelper; @@ -68,7 +69,7 @@ public class AgentProxy extends ItemProxy **************************************************************************/ protected AgentProxy( org.omg.CORBA.Object ior, AgentPath agentPath) - throws ObjectNotFoundException + throws ObjectNotFound { super(ior, agentPath); mAgentPath = agentPath; @@ -83,12 +84,12 @@ public class AgentProxy extends ItemProxy } @Override - public Agent narrow() throws ObjectNotFoundException + public Agent narrow() throws ObjectNotFound { try { return AgentHelper.narrow(mIOR); } catch (org.omg.CORBA.BAD_PARAM ex) { } - throw new ObjectNotFoundException("CORBA Object was not an Agent, or the server is down."); + throw new ObjectNotFound("CORBA Object was not an Agent, or the server is down."); } /** @@ -97,21 +98,22 @@ public class AgentProxy extends ItemProxy * * @param job * @throws AccessRightsException - * @throws InvalidDataException - * @throws InvalidTransitionException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws InvalidTransition + * @throws ObjectNotFound * @throws PersistencyException - * @throws ObjectAlreadyExistsException + * @throws ObjectAlreadyExists * @throws ScriptErrorException + * @throws InvalidCollectionModification */ public String execute(Job job) throws AccessRightsException, - InvalidDataException, - InvalidTransitionException, - ObjectNotFoundException, + InvalidData, + InvalidTransition, + ObjectNotFound, PersistencyException, - ObjectAlreadyExistsException, - ScriptErrorException + ObjectAlreadyExists, + ScriptErrorException, InvalidCollectionModification { ItemProxy item = Gateway.getProxyManager().getProxy(job.getItemPath()); OutcomeValidator validator = null; @@ -128,12 +130,12 @@ public class AgentProxy extends ItemProxy Schema schema = LocalObjectLoader.getSchema(schemaName, schemaVersion); if (schema == null) - throw new InvalidDataException("Job references outcome type "+schemaName+" version "+schemaVersion+" that does not exist in this centre.", ""); + throw new InvalidData("Job references outcome type "+schemaName+" version "+schemaVersion+" that does not exist in this centre."); try { validator = OutcomeValidator.getValidator(schema); } catch (Exception e) { - throw new InvalidDataException("Could not create validator: "+e.getMessage(), ""); + throw new InvalidData("Could not create validator: "+e.getMessage()); } } @@ -147,7 +149,7 @@ public class AgentProxy extends ItemProxy String error = validator.validate(job.getOutcomeString()); if (error.length() > 0) { Logger.error("Outcome not valid: \n " + error); - throw new InvalidDataException(error, ""); + throw new InvalidData(error); } } @@ -162,7 +164,7 @@ public class AgentProxy extends ItemProxy Logger.warning("Script errors: "+errorString); } catch (ScriptingEngineException ex) { Logger.error(ex); - throw new InvalidDataException(ex.getMessage(), ""); + throw new InvalidData(ex.getMessage()); } } @@ -170,7 +172,7 @@ public class AgentProxy extends ItemProxy Logger.msg(3, "AgentProxy - validating outcome"); String error = validator.validate(job.getOutcomeString()); if (error.length() > 0) - throw new InvalidDataException(error, ""); + throw new InvalidData(error); } job.setAgentPath(mAgentPath); @@ -192,18 +194,18 @@ public class AgentProxy extends ItemProxy public String execute(ItemProxy item, String predefStep, C2KLocalObject obj) throws AccessRightsException, - InvalidDataException, - InvalidTransitionException, - ObjectNotFoundException, + InvalidData, + InvalidTransition, + ObjectNotFound, PersistencyException, - ObjectAlreadyExistsException + ObjectAlreadyExists, InvalidCollectionModification { String param; try { param = marshall(obj); } catch (Exception ex) { Logger.error(ex); - throw new InvalidDataException("Error on marshall", ""); + throw new InvalidData("Error on marshall"); } return execute(item, predefStep, param); } @@ -220,19 +222,20 @@ public class AgentProxy extends ItemProxy * @return The outcome after processing. May have been altered by the step. * * @throws AccessRightsException The agent was not allowed to execute this step - * @throws InvalidDataException The parameters supplied were incorrect - * @throws InvalidTransitionException The step wasn't available - * @throws ObjectNotFoundException Thrown by some steps that try to locate additional objects + * @throws InvalidData The parameters supplied were incorrect + * @throws InvalidTransition The step wasn't available + * @throws ObjectNotFound Thrown by some steps that try to locate additional objects * @throws PersistencyException Problem writing or reading the database - * @throws ObjectAlreadyExistsException Thrown by steps that create additional object + * @throws ObjectAlreadyExists Thrown by steps that create additional object + * @throws InvalidCollectionModification */ public String execute(ItemProxy item, String predefStep, String[] params) throws AccessRightsException, - InvalidDataException, - InvalidTransitionException, - ObjectNotFoundException, + InvalidData, + InvalidTransition, + ObjectNotFound, PersistencyException, - ObjectAlreadyExistsException + ObjectAlreadyExists, InvalidCollectionModification { String schemaName = PredefinedStep.getPredefStepSchemaName(predefStep); String param; @@ -254,20 +257,21 @@ public class AgentProxy extends ItemProxy * @param param * @return * @throws AccessRightsException - * @throws InvalidDataException - * @throws InvalidTransitionException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws InvalidTransition + * @throws ObjectNotFound * @throws PersistencyException - * @throws ObjectAlreadyExistsException + * @throws ObjectAlreadyExists + * @throws InvalidCollectionModification */ public String execute(ItemProxy item, String predefStep, String param) throws AccessRightsException, - InvalidDataException, - InvalidTransitionException, - ObjectNotFoundException, + InvalidData, + InvalidTransition, + ObjectNotFound, PersistencyException, - ObjectAlreadyExistsException + ObjectAlreadyExists, InvalidCollectionModification { return execute(item, predefStep, new String[] {param }); } @@ -282,24 +286,24 @@ public class AgentProxy extends ItemProxy } /** Let scripts resolve items */ - public ItemProxy searchItem(String name) throws ObjectNotFoundException { + public ItemProxy searchItem(String name) throws ObjectNotFound { Iterator results = Gateway.getLookup().search(new DomainPath(""),name); Path returnPath = null; if (!results.hasNext()) - throw new ObjectNotFoundException(name, ""); + throw new ObjectNotFound(name); while(results.hasNext()) { Path nextMatch = results.next(); if (returnPath != null && nextMatch.getUUID() != null && !returnPath.getUUID().equals(nextMatch.getUUID())) - throw new ObjectNotFoundException("Too many items with that name"); + throw new ObjectNotFound("Too many items with that name"); returnPath = nextMatch; } return Gateway.getProxyManager().getProxy(returnPath); } - public ItemProxy getItem(String itemPath) throws ObjectNotFoundException { + public ItemProxy getItem(String itemPath) throws ObjectNotFound { return (getItem(new DomainPath(itemPath))); } @@ -308,11 +312,11 @@ public class AgentProxy extends ItemProxy return mAgentPath; } - public ItemProxy getItem(Path itemPath) throws ObjectNotFoundException { + public ItemProxy getItem(Path itemPath) throws ObjectNotFound { return Gateway.getProxyManager().getProxy(itemPath); } - public ItemProxy getItemByUUID(String uuid) throws ObjectNotFoundException, InvalidItemPathException { + public ItemProxy getItemByUUID(String uuid) throws ObjectNotFound, InvalidItemPathException { return Gateway.getProxyManager().getProxy(new ItemPath(uuid)); } } diff --git a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java index 503e408..f5b0be7 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java @@ -32,10 +32,11 @@ import org.exolab.castor.xml.ValidationException; import com.c2kernel.collection.Collection; import com.c2kernel.collection.CollectionArrayList; import com.c2kernel.common.AccessRightsException; -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.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.Item; @@ -47,7 +48,6 @@ import com.c2kernel.lifecycle.instance.Workflow; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.outcome.Viewpoint; import com.c2kernel.process.Gateway; import com.c2kernel.property.Property; @@ -89,18 +89,18 @@ public class ItemProxy return mItemPath; } - protected Item getItem() throws ObjectNotFoundException { + protected Item getItem() throws ObjectNotFound { if (mItem == null) mItem = narrow(); return mItem; } - public Item narrow() throws ObjectNotFoundException + public Item narrow() throws ObjectNotFound { try { return ItemHelper.narrow(mIOR); } catch (org.omg.CORBA.BAD_PARAM ex) { } - throw new ObjectNotFoundException("CORBA Object was not an Item, or the server is down."); + throw new ObjectNotFound("CORBA Object was not an Item, or the server is down."); } public void initialise( AgentPath agentId, @@ -108,11 +108,11 @@ public class ItemProxy CompositeActivity workflow, CollectionArrayList colls ) - throws AccessRightsException, InvalidDataException, PersistencyException, ObjectNotFoundException, MarshalException, ValidationException, IOException, MappingException + throws AccessRightsException, InvalidData, PersistencyException, ObjectNotFound, MarshalException, ValidationException, IOException, MappingException, InvalidCollectionModification { Logger.msg(7, "ItemProxy::initialise - started"); CastorXMLUtility xml = Gateway.getMarshaller(); - if (itemProps == null) throw new InvalidDataException("No initial properties supplied"); + if (itemProps == null) throw new InvalidData("No initial properties supplied"); String propString = xml.marshall(itemProps); String wfString = ""; if (workflow != null) wfString = xml.marshall(workflow); @@ -124,7 +124,7 @@ public class ItemProxy public void setProperty(AgentProxy agent, String name, String value) throws AccessRightsException, - PersistencyException, InvalidDataException + PersistencyException, InvalidData { String[] params = new String[2]; params[0] = name; @@ -135,34 +135,37 @@ public class ItemProxy throw (e); } catch (PersistencyException e) { throw (e); - } catch (InvalidDataException e) { + } catch (InvalidData e) { throw (e); } catch (Exception e) { Logger.error(e); - throw new PersistencyException("Could not store property", ""); + throw new PersistencyException("Could not store property"); } } - /************************************************************************** + + /** + * @throws InvalidCollectionModification * **************************************************************************/ public String requestAction( Job thisJob ) throws AccessRightsException, - InvalidTransitionException, - ObjectNotFoundException, - InvalidDataException, + InvalidTransition, + ObjectNotFound, + InvalidData, PersistencyException, - ObjectAlreadyExistsException + ObjectAlreadyExists, + InvalidCollectionModification { String outcome = thisJob.getOutcomeString(); // check fields that should have been filled in if (outcome==null) if (thisJob.isOutcomeRequired()) - throw new InvalidDataException("Outcome is required.", ""); + throw new InvalidData("Outcome is required."); else outcome=""; if (thisJob.getAgentPath() == null) - throw new InvalidDataException("No Agent specified.", ""); + throw new InvalidData("No Agent specified."); Logger.msg(7, "ItemProxy - executing "+thisJob.getStepPath()+" for "+thisJob.getAgentName()); return getItem().requestAction (thisJob.getAgentPath().getSystemKey(), thisJob.getStepPath(), @@ -174,7 +177,7 @@ public class ItemProxy **************************************************************************/ private ArrayList getJobList(AgentPath agentPath, boolean filter) throws AccessRightsException, - ObjectNotFoundException, + ObjectNotFound, PersistencyException { JobArrayList thisJobList; @@ -184,14 +187,14 @@ public class ItemProxy } catch (Exception e) { Logger.error(e); - throw new PersistencyException("Exception::ItemProxy::getJobList() - Cannot unmarshall the jobs", null); + throw new PersistencyException("Exception::ItemProxy::getJobList() - Cannot unmarshall the jobs"); } return thisJobList.list; } public ArrayList getJobList(AgentProxy agent) throws AccessRightsException, - ObjectNotFoundException, + ObjectNotFound, PersistencyException { return getJobList(agent.getPath(), true); @@ -199,7 +202,7 @@ public class ItemProxy private Job getJobByName(String actName, AgentPath agent) throws AccessRightsException, - ObjectNotFoundException, + ObjectNotFound, PersistencyException { ArrayList jobList = getJobList(agent, true); @@ -211,21 +214,21 @@ public class ItemProxy } - public Collection getCollection(String collName) throws ObjectNotFoundException { + public Collection getCollection(String collName) throws ObjectNotFound { return (Collection)getObject(ClusterStorage.COLLECTION+"/"+collName+"/last"); } - public Workflow getWorkflow() throws ObjectNotFoundException { + public Workflow getWorkflow() throws ObjectNotFound { return (Workflow)getObject(ClusterStorage.LIFECYCLE+"/workflow"); } - public Viewpoint getViewpoint(String schemaName, String viewName) throws ObjectNotFoundException { + public Viewpoint getViewpoint(String schemaName, String viewName) throws ObjectNotFound { return (Viewpoint)getObject(ClusterStorage.VIEWPOINT+"/"+schemaName+"/"+viewName); } public Job getJobByName(String actName, AgentProxy agent) throws AccessRightsException, - ObjectNotFoundException, + ObjectNotFound, PersistencyException { return getJobByName(actName, agent.getPath()); } @@ -245,7 +248,7 @@ public class ItemProxy * **************************************************************************/ public String queryData( String path ) - throws ObjectNotFoundException + throws ObjectNotFound { try { @@ -263,7 +266,7 @@ public class ItemProxy } C2KLocalObject target = Gateway.getStorage().get(mItemPath, path, null); return Gateway.getMarshaller().marshall(target); - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { throw e; } catch (Exception e) { Logger.error(e); @@ -271,11 +274,11 @@ public class ItemProxy } } - public String[] getContents( String path ) throws ObjectNotFoundException { + public String[] getContents( String path ) throws ObjectNotFound { try { return Gateway.getStorage().getClusterContents(mItemPath, path.substring(0, path.length())); - } catch (ClusterStorageException e) { - throw new ObjectNotFoundException(e.toString()); + } catch (PersistencyException e) { + throw new ObjectNotFound(e.toString()); } } @@ -284,24 +287,24 @@ public class ItemProxy * **************************************************************************/ public C2KLocalObject getObject( String xpath ) - throws ObjectNotFoundException + throws ObjectNotFound { // load from storage, falling back to proxy loader if not found in others try { return Gateway.getStorage().get( mItemPath, xpath , null); } - catch( ClusterStorageException ex ) + catch( PersistencyException ex ) { Logger.msg(4, "Exception loading object :"+mItemPath+"/"+xpath); - throw new ObjectNotFoundException( ex.toString() ); + throw new ObjectNotFound( ex.toString() ); } } public String getProperty( String name ) - throws ObjectNotFoundException + throws ObjectNotFound { Logger.msg(5, "Get property "+name+" from item "+mItemPath); Property prop = (Property)getObject("Property/"+name); @@ -311,7 +314,7 @@ public class ItemProxy } catch (NullPointerException ex) { - throw new ObjectNotFoundException(); + throw new ObjectNotFound(); } } @@ -319,7 +322,7 @@ public class ItemProxy { try { return getProperty("Name"); - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { return null; } } diff --git a/src/main/java/com/c2kernel/entity/proxy/MemberSubscription.java b/src/main/java/com/c2kernel/entity/proxy/MemberSubscription.java index 60e5233..5e063ed 100644 --- a/src/main/java/com/c2kernel/entity/proxy/MemberSubscription.java +++ b/src/main/java/com/c2kernel/entity/proxy/MemberSubscription.java @@ -23,7 +23,7 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.StringTokenizer; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.utils.Logger; @@ -70,7 +70,7 @@ public class MemberSubscription implements Runnable { newMember = (C)subject.getObject(interest+"/"+newChild); contents.remove(newChild); observer.add(newMember); - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { observer.control(ERROR, "Listed member "+newChild+" was not found."); } catch (ClassCastException ex) { Logger.error(ex); @@ -117,7 +117,7 @@ public class MemberSubscription implements Runnable { Logger.msg(4, "Adding "+path); contents.add(name); observer.add(newMember); - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { Logger.error("Member Subscription: could not load "+path); Logger.error(e); } diff --git a/src/main/java/com/c2kernel/entity/proxy/ProxyClientConnection.java b/src/main/java/com/c2kernel/entity/proxy/ProxyClientConnection.java index 4aff44b..02dc665 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ProxyClientConnection.java +++ b/src/main/java/com/c2kernel/entity/proxy/ProxyClientConnection.java @@ -30,7 +30,7 @@ import java.net.SocketException; import java.util.ArrayList; import java.util.Iterator; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.lookup.ItemPath; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -110,7 +110,7 @@ public class ProxyClientConnection implements SocketHandler { thisMessage = new ProxyMessage(input); processMessage(thisMessage); } catch (InterruptedIOException ex) { //timeout - } catch (InvalidDataException ex) { // invalid proxy message + } catch (InvalidData ex) { // invalid proxy message Logger.error("ProxyClientConnection "+thisClientId+" - Invalid proxy message: "+input); } @@ -123,7 +123,7 @@ public class ProxyClientConnection implements SocketHandler { Logger.msg(1, "ProxyClientConnection "+thisClientId+" closed."); } - private void processMessage(ProxyMessage message) throws InvalidDataException { + private void processMessage(ProxyMessage message) throws InvalidData { // proxy disconnection if (message.getPath().equals(ProxyMessage.BYEPATH)) { diff --git a/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java b/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java index aa38ea8..8824951 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java +++ b/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java @@ -25,8 +25,8 @@ import java.util.ConcurrentModificationException; import java.util.HashMap; import java.util.Iterator; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.ItemPath; @@ -103,7 +103,7 @@ public class ProxyManager } } - protected void processMessage(ProxyMessage thisMessage) throws InvalidDataException { + protected void processMessage(ProxyMessage thisMessage) throws InvalidData { if (Logger.doLog(9)) Logger.msg(9, thisMessage.toString()); if (thisMessage.getPath().equals(ProxyMessage.PINGPATH)) // ping response @@ -166,7 +166,7 @@ public class ProxyManager **************************************************************************/ private ItemProxy createProxy( org.omg.CORBA.Object ior, ItemPath itemPath) - throws ObjectNotFoundException + throws ObjectNotFound { ItemProxy newProxy = null; @@ -201,7 +201,7 @@ public class ProxyManager **************************************************************************/ private ItemProxy getProxy( org.omg.CORBA.Object ior, ItemPath itemPath) - throws ObjectNotFoundException + throws ObjectNotFound { synchronized(proxyPool) { @@ -224,7 +224,7 @@ public class ProxyManager * Proxy from Alias **************************************************************************/ public ItemProxy getProxy( Path path ) - throws ObjectNotFoundException + throws ObjectNotFound { ItemPath itemPath; if (path instanceof ItemPath) itemPath = (ItemPath)path; @@ -236,7 +236,7 @@ public class ProxyManager } public AgentProxy getAgentProxy( AgentPath path ) - throws ObjectNotFoundException + throws ObjectNotFound { return (AgentProxy) getProxy(path); } diff --git a/src/main/java/com/c2kernel/entity/proxy/ProxyMessage.java b/src/main/java/com/c2kernel/entity/proxy/ProxyMessage.java index 5aabf7e..fc69992 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ProxyMessage.java +++ b/src/main/java/com/c2kernel/entity/proxy/ProxyMessage.java @@ -23,7 +23,7 @@ package com.c2kernel.entity.proxy; import java.io.IOException; import java.net.DatagramPacket; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.lookup.InvalidItemPathException; import com.c2kernel.lookup.ItemPath; @@ -65,17 +65,17 @@ public class ProxyMessage { setState(state); } - public ProxyMessage(String line) throws InvalidDataException, IOException { + public ProxyMessage(String line) throws InvalidData, IOException { if (line == null) throw new IOException("Null proxy message"); String[] tok = line.split(":"); if (tok.length != 2) - throw new InvalidDataException("String '"+line+"' does not constitute a valid proxy message.", ""); + throw new InvalidData("String '"+line+"' does not constitute a valid proxy message."); if (tok[0].length() > 0 && !tok[0].equals("tree")) { try { itemPath = new ItemPath(tok[0]); } catch (InvalidItemPathException e) { - throw new InvalidDataException("Item in proxy message "+line+" was not valid"); + throw new InvalidData("Item in proxy message "+line+" was not valid"); } } path = tok[1]; @@ -85,7 +85,7 @@ public class ProxyMessage { } } - public ProxyMessage(DatagramPacket packet) throws InvalidDataException, IOException { + public ProxyMessage(DatagramPacket packet) throws InvalidData, IOException { this(new String(packet.getData())); } diff --git a/src/main/java/com/c2kernel/entity/proxy/ProxyServerConnection.java b/src/main/java/com/c2kernel/entity/proxy/ProxyServerConnection.java index 25a7216..edcbd44 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ProxyServerConnection.java +++ b/src/main/java/com/c2kernel/entity/proxy/ProxyServerConnection.java @@ -27,7 +27,7 @@ import java.io.InterruptedIOException; import java.io.PrintWriter; import java.net.Socket; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.utils.Logger; @@ -76,7 +76,7 @@ public class ProxyServerConnection extends Thread manager.processMessage(thisMessage); } catch (InterruptedIOException ex) { // timeout - send a ping sendMessage(ProxyMessage.pingMessage); - } catch (InvalidDataException ex) { // invalid proxy message + } catch (InvalidData ex) { // invalid proxy message if (input != null) Logger.error("EntityProxyManager - Invalid proxy message: "+input); } diff --git a/src/main/java/com/c2kernel/entity/transfer/TransferItem.java b/src/main/java/com/c2kernel/entity/transfer/TransferItem.java index 0e8123b..34c3ce3 100644 --- a/src/main/java/com/c2kernel/entity/transfer/TransferItem.java +++ b/src/main/java/com/c2kernel/entity/transfer/TransferItem.java @@ -26,7 +26,7 @@ import java.util.Iterator; import com.c2kernel.collection.Collection; import com.c2kernel.collection.CollectionArrayList; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.TraceableEntity; import com.c2kernel.lifecycle.instance.Workflow; @@ -51,7 +51,7 @@ public class TransferItem { public TransferItem() throws Exception { try { importAgentId = Gateway.getLookup().getAgentPath("system"); - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { Logger.error("TransferItem - System user not found!"); throw e; } @@ -99,7 +99,7 @@ public class TransferItem { File dumpPath = new File(dir.getCanonicalPath() + ".xml"); FileStringUtility.string2File(dumpPath, Gateway.getMarshaller().marshall(obj)); return; - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { } // not an object } } -- cgit v1.2.3