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/idl/CommonExceptions.idl | 31 ++--- src/main/idl/Entity.idl | 26 +++-- .../java/com/c2kernel/collection/Aggregation.java | 33 +++--- .../collection/AggregationDescription.java | 16 +-- .../c2kernel/collection/AggregationInstance.java | 16 +-- .../com/c2kernel/collection/AggregationMember.java | 31 +++-- .../collection/AggregationVertexFactory.java | 5 +- .../AggregationVertexOutlineCreator.java | 6 +- .../java/com/c2kernel/collection/Collection.java | 46 ++++++-- .../c2kernel/collection/CollectionArrayList.java | 10 +- .../c2kernel/collection/CollectionDescription.java | 9 +- .../com/c2kernel/collection/CollectionMember.java | 10 +- .../java/com/c2kernel/collection/Dependency.java | 36 +++--- .../c2kernel/collection/DependencyDescription.java | 14 ++- .../com/c2kernel/collection/DependencyMember.java | 17 +-- .../c2kernel/collection/MembershipException.java | 39 ------- .../java/com/c2kernel/collection/package-info.java | 20 +--- 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 +- src/main/java/com/c2kernel/events/Event.java | 6 +- src/main/java/com/c2kernel/events/History.java | 6 +- .../com/c2kernel/graph/model/GraphableVertex.java | 6 +- .../java/com/c2kernel/lifecycle/ActivityDef.java | 8 +- .../com/c2kernel/lifecycle/ActivitySlotDef.java | 10 +- .../c2kernel/lifecycle/CompositeActivityDef.java | 8 +- .../java/com/c2kernel/lifecycle/WfVertexDef.java | 6 +- .../com/c2kernel/lifecycle/instance/Activity.java | 103 ++++++++++------- .../lifecycle/instance/AdvancementCalculator.java | 6 +- .../com/c2kernel/lifecycle/instance/AndSplit.java | 8 +- .../lifecycle/instance/CompositeActivity.java | 44 ++++--- .../java/com/c2kernel/lifecycle/instance/Join.java | 34 +++--- .../java/com/c2kernel/lifecycle/instance/Loop.java | 12 +- .../com/c2kernel/lifecycle/instance/OrSplit.java | 8 +- .../com/c2kernel/lifecycle/instance/Split.java | 32 +++--- .../com/c2kernel/lifecycle/instance/WfVertex.java | 54 +++++---- .../com/c2kernel/lifecycle/instance/Workflow.java | 56 +++++---- .../com/c2kernel/lifecycle/instance/XOrSplit.java | 14 +-- .../instance/predefined/AddC2KObject.java | 24 ++-- .../instance/predefined/AddDomainPath.java | 23 ++-- .../instance/predefined/AddMemberToCollection.java | 48 ++++---- .../predefined/AddNewCollectionDescription.java | 109 ++++++++++++++++++ .../lifecycle/instance/predefined/AddNewSlot.java | 32 +++--- .../instance/predefined/AssignItemToSlot.java | 40 ++++--- .../lifecycle/instance/predefined/ClearSlot.java | 28 ++--- .../lifecycle/instance/predefined/Import.java | 13 +-- .../instance/predefined/PredefinedStep.java | 7 -- .../predefined/PredefinedStepContainer.java | 1 + .../instance/predefined/RemoveC2KObject.java | 15 ++- .../instance/predefined/RemoveDomainPath.java | 30 ++--- .../predefined/RemoveSlotFromCollection.java | 41 +++---- .../instance/predefined/ReplaceDomainWorkflow.java | 43 +++---- .../instance/predefined/WriteProperty.java | 19 ++-- .../instance/predefined/WriteViewpoint.java | 23 ++-- .../agent/CreateAgentFromDescription.java | 123 +++++++++++--------- .../instance/predefined/agent/RemoveAgent.java | 28 ++--- .../predefined/agent/SetAgentPassword.java | 33 ++---- .../instance/predefined/agent/SetAgentRoles.java | 16 +-- .../predefined/item/CreateItemFromDescription.java | 126 ++++++++++----------- .../lifecycle/instance/predefined/item/Erase.java | 40 +++---- .../predefined/server/AddDomainContext.java | 28 ++--- .../instance/predefined/server/CreateNewAgent.java | 34 ++++-- .../instance/predefined/server/CreateNewItem.java | 26 +++-- .../instance/predefined/server/CreateNewRole.java | 25 ++-- .../predefined/server/RemoveDomainContext.java | 37 +++--- .../instance/predefined/server/RemoveRole.java | 43 +++---- .../instance/stateMachine/StateMachine.java | 12 +- .../instance/stateMachine/Transition.java | 22 ++-- .../routingHelpers/ViewpointDataHelper.java | 4 +- src/main/java/com/c2kernel/lookup/AgentPath.java | 16 +-- src/main/java/com/c2kernel/lookup/DomainPath.java | 8 +- src/main/java/com/c2kernel/lookup/ItemPath.java | 4 +- src/main/java/com/c2kernel/lookup/Lookup.java | 30 ++--- .../java/com/c2kernel/lookup/LookupManager.java | 32 +++--- src/main/java/com/c2kernel/lookup/Path.java | 6 +- src/main/java/com/c2kernel/lookup/RolePath.java | 12 +- .../com/c2kernel/persistency/ClusterStorage.java | 27 ++--- .../persistency/ClusterStorageException.java | 47 -------- .../persistency/ClusterStorageManager.java | 43 +++---- .../persistency/MemoryOnlyClusterStorage.java | 13 ++- .../java/com/c2kernel/persistency/ProxyLoader.java | 31 ++--- .../java/com/c2kernel/persistency/RemoteMap.java | 13 ++- .../c2kernel/persistency/TransactionManager.java | 25 ++-- .../c2kernel/persistency/XMLClusterStorage.java | 23 ++-- .../com/c2kernel/persistency/outcome/Outcome.java | 32 +++--- .../persistency/outcome/OutcomeInitiator.java | 4 +- .../persistency/outcome/OutcomeValidator.java | 12 +- .../c2kernel/persistency/outcome/Viewpoint.java | 14 +-- src/main/java/com/c2kernel/process/Bootstrap.java | 16 +-- src/main/java/com/c2kernel/process/Gateway.java | 50 ++++---- .../java/com/c2kernel/process/UserCodeProcess.java | 4 +- .../com/c2kernel/process/auth/Authenticator.java | 20 ++-- .../java/com/c2kernel/process/module/Module.java | 6 +- .../com/c2kernel/process/module/ModuleImport.java | 11 +- .../com/c2kernel/process/module/ModuleManager.java | 8 +- .../c2kernel/process/module/ModuleResource.java | 12 +- .../com/c2kernel/process/resource/Resource.java | 20 ++-- .../c2kernel/process/resource/ResourceLoader.java | 8 +- .../c2kernel/property/PropertyDescriptionList.java | 6 +- .../com/c2kernel/property/PropertyUtility.java | 6 +- src/main/java/com/c2kernel/scripting/Script.java | 4 +- src/main/java/com/c2kernel/utils/ActDefCache.java | 14 +-- .../java/com/c2kernel/utils/CastorXMLUtility.java | 14 +-- .../com/c2kernel/utils/DescriptionObjectCache.java | 8 +- .../java/com/c2kernel/utils/LocalObjectLoader.java | 30 ++--- .../java/com/c2kernel/utils/StateMachineCache.java | 14 +-- src/test/java/MainTest.java | 4 +- 126 files changed, 1578 insertions(+), 1501 deletions(-) delete mode 100644 src/main/java/com/c2kernel/collection/MembershipException.java create mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java delete mode 100644 src/main/java/com/c2kernel/persistency/ClusterStorageException.java diff --git a/src/main/idl/CommonExceptions.idl b/src/main/idl/CommonExceptions.idl index 176b4a9..d5abb1d 100644 --- a/src/main/idl/CommonExceptions.idl +++ b/src/main/idl/CommonExceptions.idl @@ -34,12 +34,12 @@ module common { /************************************************************************** - * Thrown when the directory couldn't be modified during Entity creation, or - * Role management + * Thrown when the process isn't privileged enough to make the requested + * change, either because it is a client process, or its management objects + * are incorrect. **************************************************************************/ - exception CannotManageException + exception CannotManage { - string mDescription; }; @@ -49,18 +49,24 @@ module common * Most commonly occurs when the Activity is in a different state than the * caller has assumed. **************************************************************************/ - exception InvalidTransitionException + exception InvalidTransition + { + }; + + /************************************************************************** + * The modification to the collection could not be performed, due to rules + * within the collection itself. + **************************************************************************/ + exception InvalidCollectionModification { - string mDescription; }; /************************************************************************** * Either the supplied data, or the relevant description, was invalid. **************************************************************************/ - exception InvalidDataException + exception InvalidData { - string mDescription; }; @@ -69,16 +75,14 @@ module common **************************************************************************/ exception AccessRightsException { - string mDescription; }; /************************************************************************** * The requested object was not found **************************************************************************/ - exception ObjectNotFoundException + exception ObjectNotFound { - string mDescription; }; @@ -87,15 +91,13 @@ module common **************************************************************************/ exception PersistencyException { - string mDescription; }; /************************************************************************** * The object already exists. **************************************************************************/ - exception ObjectAlreadyExistsException + exception ObjectAlreadyExists { - string mDescription; }; @@ -104,7 +106,6 @@ module common **************************************************************************/ exception ObjectCannotBeUpdated { - string mDescription; }; }; //end of module common diff --git a/src/main/idl/Entity.idl b/src/main/idl/Entity.idl index 3348b41..ff0dad3 100644 --- a/src/main/idl/Entity.idl +++ b/src/main/idl/Entity.idl @@ -64,9 +64,10 @@ module entity in string workflow, in string collections ) raises( common::AccessRightsException, - common::InvalidDataException, + common::InvalidData, common::PersistencyException, - common::ObjectNotFoundException ); + common::ObjectNotFound, + common::InvalidCollectionModification ); /** * Returns a chunk of XML which may be a serialized C2KLocalObject, or in the case of Outcomes is merely a fragment of XML. @@ -90,7 +91,7 @@ module entity **/ string queryData( in string path ) raises( common::AccessRightsException, - common::ObjectNotFoundException, + common::ObjectNotFound, common::PersistencyException ); /** @@ -128,11 +129,12 @@ module entity in string requestData ) raises( common::AccessRightsException, - common::InvalidTransitionException, - common::ObjectNotFoundException, - common::InvalidDataException, + common::InvalidTransition, + common::ObjectNotFound, + common::InvalidData, common::PersistencyException, - common::ObjectAlreadyExistsException ); + common::ObjectAlreadyExists, + common::InvalidCollectionModification); /** @@ -150,7 +152,7 @@ module entity string queryLifeCycle( in common::SystemKey agentKey, in boolean filter ) raises( common::AccessRightsException, - common::ObjectNotFoundException, + common::ObjectNotFound, common::PersistencyException ); }; @@ -180,16 +182,16 @@ module entity * @throws CannotManageException when an error occurs writing the data to LDAP **/ void addRole( in string roleName ) - raises( common::ObjectNotFoundException, - common::CannotManageException ); + raises( common::ObjectNotFound, + common::CannotManage ); /** Remove this Agent from the given role * @param the role name to remove * @throws CannotManageException when an error occurs writing the data to LDAP **/ void removeRole( in string roleName ) - raises( common::ObjectNotFoundException, - common::CannotManageException ); + raises( common::ObjectNotFound, + common::CannotManage ); }; }; //end of module entity diff --git a/src/main/java/com/c2kernel/collection/Aggregation.java b/src/main/java/com/c2kernel/collection/Aggregation.java index 575cd39..b4d1b6b 100644 --- a/src/main/java/com/c2kernel/collection/Aggregation.java +++ b/src/main/java/com/c2kernel/collection/Aggregation.java @@ -20,7 +20,9 @@ */ package com.c2kernel.collection; -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.GraphModel; import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.graph.model.TypeNameAndConstructionInfo; @@ -33,8 +35,7 @@ import com.c2kernel.utils.Language; import com.c2kernel.utils.Logger; /** - * @version $Revision: 1.59 $ $Date: 2004/08/10 07:56:08 $ - * @author $Author: abranson $ + * A Collection with a graph layout */ abstract public class Aggregation extends Collection @@ -116,7 +117,7 @@ abstract public class Aggregation extends Collection } public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps, GraphPoint location, int w, int h) - throws MembershipException + throws InvalidCollectionModification, ObjectAlreadyExists { AggregationMember aggMem = addSlot(props, classProps, location, w, h); if (itemPath != null) { // some clients use this method when not setting a member @@ -129,24 +130,27 @@ abstract public class Aggregation extends Collection @Override - public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws MembershipException + public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws InvalidCollectionModification, ObjectAlreadyExists { return addMember(itemPath, props, classProps, null, -1, -1); } + + public AggregationMember addMember(CastorHashMap props, String classProps, GraphPoint location, int w, int h) throws InvalidCollectionModification { + try { + return addMember(null, props, classProps, location, w, h); + } catch (ObjectAlreadyExists e) { // not assigning an item so this won't happen + return null; + } + } + public AggregationMember addSlot(CastorHashMap props, String classProps) { return addSlot(props, classProps, null, -1, -1); } @Override - public AggregationMember addMember(ItemPath itemPath) throws MembershipException { - throw new MembershipException("Aggregations cannot accept arbitrary members without type info"); - - } - - @Override - public void removeMember(int memberId) throws MembershipException { + public void removeMember(int memberId) throws ObjectNotFound { for (AggregationMember element : mMembers.list) { if (element.getID() == memberId) { element.clearItem(); @@ -154,7 +158,7 @@ abstract public class Aggregation extends Collection return; } } - throw new MembershipException("Member "+memberId+" not found"); + throw new ObjectNotFound("Member "+memberId+" not found"); } static public boolean getIsComposite(ItemPath itemPath, String name) @@ -163,10 +167,9 @@ abstract public class Aggregation extends Collection try { for(String collName: Gateway.getProxyManager().getProxy(itemPath).getContents(ClusterStorage.COLLECTION) ) if (name == null || name.equals(collName)) return true; - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { return false; } return false; } - } diff --git a/src/main/java/com/c2kernel/collection/AggregationDescription.java b/src/main/java/com/c2kernel/collection/AggregationDescription.java index ec58cc1..400a91d 100644 --- a/src/main/java/com/c2kernel/collection/AggregationDescription.java +++ b/src/main/java/com/c2kernel/collection/AggregationDescription.java @@ -21,11 +21,14 @@ package com.c2kernel.collection; /** - * @version $Revision: 1.34 $ $Date: 2004/03/23 09:29:41 $ - * @author $Author: abranson $ + * The description of a Collection with a graph layout. Each slot is + * instantiated empty in the resulting Aggregation, with ClassProps taken from + * the PropertyDescription outcome of the description slot's referenced Item. */ -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.Vertex; import com.c2kernel.property.PropertyDescriptionList; import com.c2kernel.property.PropertyUtility; @@ -45,7 +48,7 @@ public class AggregationDescription extends Aggregation implements CollectionDes } @Override - public Aggregation newInstance() throws ObjectNotFoundException + public Aggregation newInstance() throws ObjectNotFound { AggregationInstance newInstance = new AggregationInstance(getName()); //for each desc member @@ -61,9 +64,8 @@ public class AggregationDescription extends Aggregation implements CollectionDes try { Vertex v = getLayout().getVertexById(mem.getID()); newInstance.addMember(null, PropertyUtility.createProperty(pdList), pdList.getClassProps(),v.getCentrePoint(),v.getWidth(),v.getHeight()); - } catch (MembershipException e) { - // won't happen as we're not assigning an entity - } + } catch (InvalidCollectionModification e) { + } catch (ObjectAlreadyExists e) { } } else { diff --git a/src/main/java/com/c2kernel/collection/AggregationInstance.java b/src/main/java/com/c2kernel/collection/AggregationInstance.java index e01fe12..2de6b7f 100644 --- a/src/main/java/com/c2kernel/collection/AggregationInstance.java +++ b/src/main/java/com/c2kernel/collection/AggregationInstance.java @@ -21,10 +21,12 @@ package com.c2kernel.collection; /** - * @version $Revision: 1.30 $ $Date: 2003/06/04 13:21:24 $ - * @author $Author: abranson $ + * Instance of an Aggregation. Unlike in the description, Items may only be + * assigned to one slot. */ +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectAlreadyExists; import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.lookup.ItemPath; import com.c2kernel.utils.CastorHashMap; @@ -45,20 +47,20 @@ public class AggregationInstance extends Aggregation @Override public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) - throws MembershipException + throws InvalidCollectionModification, ObjectAlreadyExists { if( itemPath != null && exists(itemPath)) - throw new MembershipException(itemPath+" already exists in this collection."); + throw new ObjectAlreadyExists(itemPath+" already exists in this collection."); else return super.addMember(itemPath, props, classProps); } - @Override + @Override public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps, GraphPoint location, int w, int h) - throws MembershipException + throws InvalidCollectionModification, ObjectAlreadyExists { if( itemPath != null && exists(itemPath)) - throw new MembershipException(itemPath+" already exists in this collection."); + throw new ObjectAlreadyExists(itemPath+" already exists in this collection."); else return super.addMember(itemPath, props, classProps, location, w, h); } diff --git a/src/main/java/com/c2kernel/collection/AggregationMember.java b/src/main/java/com/c2kernel/collection/AggregationMember.java index 067bb46..4a5b8db 100644 --- a/src/main/java/com/c2kernel/collection/AggregationMember.java +++ b/src/main/java/com/c2kernel/collection/AggregationMember.java @@ -22,7 +22,8 @@ package com.c2kernel.collection; import java.util.StringTokenizer; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.proxy.ItemProxy; import com.c2kernel.graph.model.GraphableVertex; import com.c2kernel.lookup.InvalidItemPathException; @@ -33,14 +34,12 @@ import com.c2kernel.property.Property; import com.c2kernel.utils.Logger; /** -* @version $Revision: 1.11 $ $Date: 2005/12/01 14:23:15 $ -* @author $Author: abranson $ +* A CollectionMember, or slot, of an Aggregation instance or description. +* Verifies type information of Items during assignment based on +* PropertyDescription information stored in slot properties and listed as +* ClassProps. */ - -//this extends Vertex for inherit the graph visualization -//this does not implement MemberObject anylonger. it is a java object. -//eventually the member object corba interface will be phased out. public class AggregationMember extends GraphableVertex implements CollectionMember { @@ -87,11 +86,11 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb } @Override - public void assignItem(ItemPath itemPath) throws MembershipException + public void assignItem(ItemPath itemPath) throws InvalidCollectionModification { if (itemPath != null) { if (mClassProps == null || getProperties() == null) - throw new MembershipException("ClassProps not yet set. Cannot check membership validity."); + throw new InvalidCollectionModification("ClassProps not yet set. Cannot check membership validity."); //for each mandatory prop check if its in the member property and has the matching value StringTokenizer sub = new StringTokenizer(mClassProps, ","); @@ -102,17 +101,17 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb String memberValue = (String)getProperties().get(aClassProp); Property ItemProperty = (Property)Gateway.getStorage().get(itemPath, ClusterStorage.PROPERTY+"/"+aClassProp, null); if (ItemProperty == null) - throw new MembershipException("Property "+aClassProp+ " does not exist for item " + itemPath ); + throw new InvalidCollectionModification("Property "+aClassProp+ " does not exist for item " + itemPath ); if (ItemProperty.getValue() == null || !ItemProperty.getValue().equalsIgnoreCase(memberValue)) - throw new MembershipException("Value of mandatory prop "+aClassProp+" does not match: " + ItemProperty.getValue()+"!="+memberValue); + throw new InvalidCollectionModification("Value of mandatory prop "+aClassProp+" does not match: " + ItemProperty.getValue()+"!="+memberValue); } - catch (MembershipException ex) { + catch (InvalidCollectionModification ex) { throw ex; } catch (Exception ex) { Logger.error(ex); - throw new MembershipException("Error checking properties"); + throw new InvalidCollectionModification("Error checking properties"); } } } @@ -130,7 +129,7 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb } @Override - public ItemProxy resolveItem() throws ObjectNotFoundException { + public ItemProxy resolveItem() throws ObjectNotFound { if (mItem == null && mItemPath != null) { mItem = Gateway.getProxyManager().getProxy(mItemPath); } @@ -143,7 +142,7 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb if (mItemPath != null) { try { mItemName = resolveItem().getName(); - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { Logger.error(ex); mItemName = "Error ("+mItemPath+")"; } @@ -155,7 +154,7 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb return mItemName; } - public void setChildUUID(String uuid) throws MembershipException, InvalidItemPathException { + public void setChildUUID(String uuid) throws InvalidCollectionModification, InvalidItemPathException { mItemPath = new ItemPath(uuid); mItemName = null; } diff --git a/src/main/java/com/c2kernel/collection/AggregationVertexFactory.java b/src/main/java/com/c2kernel/collection/AggregationVertexFactory.java index 242d0bb..6fa7014 100644 --- a/src/main/java/com/c2kernel/collection/AggregationVertexFactory.java +++ b/src/main/java/com/c2kernel/collection/AggregationVertexFactory.java @@ -26,7 +26,10 @@ import com.c2kernel.graph.model.TypeNameAndConstructionInfo; import com.c2kernel.graph.model.VertexFactory; import com.c2kernel.utils.CastorHashMap; - +/** + * GraphModel vertex factory for AggregationMembers + * + */ public class AggregationVertexFactory implements VertexFactory { private Aggregation mAggregation = null; diff --git a/src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java b/src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java index 4be48e0..fbd5434 100644 --- a/src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java +++ b/src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java @@ -24,7 +24,11 @@ import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.graph.model.Vertex; import com.c2kernel.graph.model.VertexOutlineCreator; - +/** + * AggregationMember vertex outline creator. Sets up the new dimensions and + * position on the GraphModel. + * + */ public class AggregationVertexOutlineCreator implements VertexOutlineCreator { @Override diff --git a/src/main/java/com/c2kernel/collection/Collection.java b/src/main/java/com/c2kernel/collection/Collection.java index 355fa1c..fa0230b 100644 --- a/src/main/java/com/c2kernel/collection/Collection.java +++ b/src/main/java/com/c2kernel/collection/Collection.java @@ -22,15 +22,39 @@ package com.c2kernel.collection; import java.util.Iterator; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.C2KLocalObject; +import com.c2kernel.graph.model.GraphModel; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.utils.CastorHashMap; /** - * @version $Revision: 1.23 $ $Date: 2004/05/14 15:39:39 $ - * @author $Author: abranson $ + * Collections are Item local objects that reference other Items. + * + *

In parallel with the OO meta-model, Items can be linked to other Items in + * different ways. These links are modelled with Collections, which are local + * objects stored in an Item which reference a number of other Items in the same + * server. The Collections holds a CollectionMember, sometimes known as a slot, + * to reference each Item and store additional information about the link. + * + *

Features: + *

    + *
  • Typing - Collections can restrict membership of based on type + * information derived from Item, Property and Collection descriptions. This + * restriction may be per-slot or apply to the whole Collection. + * + *
  • Fixed or flexible slots - The CollectionMember objects of a + * Collection may be empty, individually typed, or created and removed as + * required, simulating either array, structures or lists. + * + *
  • Layout - Collections can include a {@link GraphModel} to lay out + * its slots on a two-dimensional canvas, for modelling real world compositions. + *
+ * + *

Collections are managed through predefined steps. */ abstract public class Collection implements C2KLocalObject { @@ -131,12 +155,12 @@ abstract public class Collection implements C2KLocal return true; } - public E getMember(int memberId) throws ObjectNotFoundException { + public E getMember(int memberId) throws ObjectNotFound { for (E element : mMembers.list) { if (element.getID() == memberId) return element; } - throw new ObjectNotFoundException("Member "+memberId+" not found in "+mName, ""); + throw new ObjectNotFound("Member "+memberId+" not found in "+mName); } public CollectionMemberList getMembers() @@ -144,12 +168,10 @@ abstract public class Collection implements C2KLocal return mMembers; } - public abstract E addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws MembershipException; - - public abstract E addMember(ItemPath itemPath) throws MembershipException; - - public abstract void removeMember(int memberId) throws MembershipException; + public abstract E addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws InvalidCollectionModification, ObjectAlreadyExists; + public abstract void removeMember(int memberId) throws ObjectNotFound; + @Override public boolean equals(Object other) { if (!(other instanceof Collection)) return false; @@ -161,10 +183,12 @@ abstract public class Collection implements C2KLocal E thisMem = i.next(); CollectionMember otherMem = otherColl.getMember(thisMem.getID()); if (!thisMem.equals(otherMem)) return false; - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { return false; } } return true; } + + } diff --git a/src/main/java/com/c2kernel/collection/CollectionArrayList.java b/src/main/java/com/c2kernel/collection/CollectionArrayList.java index eb6ca1a..2c96170 100644 --- a/src/main/java/com/c2kernel/collection/CollectionArrayList.java +++ b/src/main/java/com/c2kernel/collection/CollectionArrayList.java @@ -24,6 +24,12 @@ import java.util.ArrayList; import com.c2kernel.utils.CastorArrayList; +/** + * A bundle of Collections. Used for storage and export/import using XML + * persistency via Castor, and to set up an Item's initial collections during + * initialization. + * + */ public class CollectionArrayList extends CastorArrayList> { public CollectionArrayList() { @@ -38,7 +44,9 @@ public class CollectionArrayList extends CastorArrayList c) { for (Collection thisColl : list) { if (thisColl.getName().equals(c.getName())) { diff --git a/src/main/java/com/c2kernel/collection/CollectionDescription.java b/src/main/java/com/c2kernel/collection/CollectionDescription.java index 4b49ccd..0c72b67 100644 --- a/src/main/java/com/c2kernel/collection/CollectionDescription.java +++ b/src/main/java/com/c2kernel/collection/CollectionDescription.java @@ -20,20 +20,21 @@ */ package com.c2kernel.collection; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.entity.C2KLocalObject; /** * A collection that can be instantiated. Collection descriptions link Item * descriptions together, which constrains membership of their instance. * */ -public interface CollectionDescription { +public interface CollectionDescription extends C2KLocalObject { /** * Create a new instance of this collection. * @return a new collection instance - * @throws ObjectNotFoundException When an essential piece of description + * @throws ObjectNotFound When an essential piece of description * data, such as a child Item PropertyDescription outcome, doesn't exist. */ - public Collection newInstance() throws ObjectNotFoundException; + public Collection newInstance() throws ObjectNotFound; } diff --git a/src/main/java/com/c2kernel/collection/CollectionMember.java b/src/main/java/com/c2kernel/collection/CollectionMember.java index 74d4671..b7b9f31 100644 --- a/src/main/java/com/c2kernel/collection/CollectionMember.java +++ b/src/main/java/com/c2kernel/collection/CollectionMember.java @@ -20,7 +20,8 @@ */ package com.c2kernel.collection; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.proxy.ItemProxy; import com.c2kernel.lookup.ItemPath; import com.c2kernel.utils.CastorHashMap; @@ -57,8 +58,9 @@ public interface CollectionMember { * @param itemPath The item to assign * @throws MembershipException When the Item Properties don't match the * typing specification in ClassProps and Properties + * @throws InvalidCollectionModification */ - public void assignItem(ItemPath itemPath) throws MembershipException; + public void assignItem(ItemPath itemPath) throws InvalidCollectionModification; /** * De-assign the slot, leaving it empty. @@ -68,9 +70,9 @@ public interface CollectionMember { /** * Resolve the Item currently assigned * @return the ItemProxy of the assigned Item - * @throws ObjectNotFoundException When empty + * @throws ObjectNotFound When empty */ - public ItemProxy resolveItem() throws ObjectNotFoundException; + public ItemProxy resolveItem() throws ObjectNotFound; /** * Get the integer slot ID, as generated by the parent Collection diff --git a/src/main/java/com/c2kernel/collection/Dependency.java b/src/main/java/com/c2kernel/collection/Dependency.java index 7b7904d..cfcb4f7 100644 --- a/src/main/java/com/c2kernel/collection/Dependency.java +++ b/src/main/java/com/c2kernel/collection/Dependency.java @@ -21,20 +21,27 @@ package com.c2kernel.collection; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.lookup.ItemPath; import com.c2kernel.utils.CastorHashMap; import com.c2kernel.utils.KeyValuePair; import com.c2kernel.utils.Logger; -/* -Dependency Object -Objectified link representing dependency between items. -e.g.: Used for ProductDesc::Item-dependency-dependencymember-WfDesc::Item -*/ - /** - * @version $Revision: 1.15 $ $Date: 2005/04/07 08:03:21 $ - * @author $Author: abranson $ + * A Collection implementation that contains a variable number of members of the + * same type, like a variable-length array. CollectionMembers are created and + * destroyed as needed. A Dependency never contains empty slots, nor duplicated + * members. + * + *

ClassProps are stored at the collection level and duplicated in each slot. + * Slots may still have their own individual properties annotating their link. + * + * Predefined steps managing Dependencies: + * + *

    + *
  • */ public class Dependency extends Collection { @@ -77,8 +84,8 @@ public class Dependency extends Collection return mClassProps; } - @Override - public DependencyMember addMember(ItemPath itemPath) throws MembershipException { + public DependencyMember addMember(ItemPath itemPath) throws InvalidCollectionModification, ObjectAlreadyExists { + if (contains(itemPath)) throw new ObjectAlreadyExists("Item "+itemPath+" already exists in Dependency "+getName()); // create member object DependencyMember depMember = new DependencyMember(); depMember.setID(getCounter()); @@ -94,10 +101,11 @@ public class Dependency extends Collection @Override public DependencyMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) - throws MembershipException + throws InvalidCollectionModification, ObjectAlreadyExists { + if (contains(itemPath)) throw new ObjectAlreadyExists("Item "+itemPath+" already exists in Dependency "+getName()); if (classProps != null && !classProps.equals(mClassProps)) - throw new MembershipException("Cannot change classProps in dependency member"); + throw new InvalidCollectionModification("Cannot change classProps in dependency member"); DependencyMember depMember = new DependencyMember(); depMember.setID(getCounter()); @@ -125,14 +133,14 @@ public class Dependency extends Collection } @Override - public void removeMember(int memberId) throws MembershipException { + public void removeMember(int memberId) throws ObjectNotFound { for (DependencyMember element : mMembers.list) { if (element.getID() == memberId) { mMembers.list.remove(element); return; } } - throw new MembershipException("Member "+memberId+" not found"); + throw new ObjectNotFound("Member "+memberId+" not found"); } } diff --git a/src/main/java/com/c2kernel/collection/DependencyDescription.java b/src/main/java/com/c2kernel/collection/DependencyDescription.java index 0e6bb91..aff2aca 100644 --- a/src/main/java/com/c2kernel/collection/DependencyDescription.java +++ b/src/main/java/com/c2kernel/collection/DependencyDescription.java @@ -20,7 +20,9 @@ */ package com.c2kernel.collection; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.lookup.ItemPath; import com.c2kernel.property.PropertyDescriptionList; import com.c2kernel.property.PropertyUtility; @@ -39,7 +41,7 @@ public class DependencyDescription extends Dependency implements CollectionDescr } @Override - public Collection newInstance() throws ObjectNotFoundException{ + public Collection newInstance() throws ObjectNotFound{ String depName = getName().replaceFirst("\'$", ""); // HACK: Knock the special 'prime' off the end for the case of descriptions of descriptions Dependency newDep = new Dependency(depName); if (mMembers.list.size() == 1) { // constrain the members based on the property description @@ -56,21 +58,21 @@ public class DependencyDescription extends Dependency implements CollectionDescr @Override - public DependencyMember addMember(ItemPath itemPath) throws MembershipException { + public DependencyMember addMember(ItemPath itemPath) throws InvalidCollectionModification, ObjectAlreadyExists { checkMembership(); return super.addMember(itemPath); } @Override public DependencyMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) - throws MembershipException { + throws InvalidCollectionModification, ObjectAlreadyExists { checkMembership(); return super.addMember(itemPath, props, classProps); } - public void checkMembership() throws MembershipException { + public void checkMembership() throws InvalidCollectionModification { if (mMembers.list.size() > 0) - throw new MembershipException("Dependency descriptions may not have more than one member."); + throw new InvalidCollectionModification("Dependency descriptions may not have more than one member."); } } diff --git a/src/main/java/com/c2kernel/collection/DependencyMember.java b/src/main/java/com/c2kernel/collection/DependencyMember.java index 6f86ecd..502894f 100644 --- a/src/main/java/com/c2kernel/collection/DependencyMember.java +++ b/src/main/java/com/c2kernel/collection/DependencyMember.java @@ -22,7 +22,8 @@ package com.c2kernel.collection; import java.util.StringTokenizer; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.proxy.ItemProxy; import com.c2kernel.lookup.InvalidItemPathException; import com.c2kernel.lookup.ItemPath; @@ -105,11 +106,11 @@ public class DependencyMember implements CollectionMember } @Override - public void assignItem(ItemPath itemPath) throws MembershipException + public void assignItem(ItemPath itemPath) throws InvalidCollectionModification { if (itemPath != null) { if (mClassProps == null || getProperties() == null) - throw new MembershipException("ClassProps not yet set. Cannot check membership validity."); + throw new InvalidCollectionModification("ClassProps not yet set. Cannot check membership validity."); //for each mandatory prop check if its in the member property and has the matching value StringTokenizer sub = new StringTokenizer(mClassProps, ","); @@ -120,14 +121,14 @@ public class DependencyMember implements CollectionMember String memberValue = (String)getProperties().get(aClassProp); Property ItemProperty = (Property)Gateway.getStorage().get(itemPath, ClusterStorage.PROPERTY+"/"+aClassProp, null); if (ItemProperty == null) - throw new MembershipException("Property "+aClassProp+ " does not exist for item " + itemPath ); + throw new InvalidCollectionModification("Property "+aClassProp+ " does not exist for item " + itemPath ); if (!ItemProperty.getValue().equalsIgnoreCase(memberValue)) - throw new MembershipException("DependencyMember::checkProperty() Values of mandatory prop "+aClassProp+" do not match " + ItemProperty.getValue()+"!="+memberValue); + throw new InvalidCollectionModification("DependencyMember::checkProperty() Values of mandatory prop "+aClassProp+" do not match " + ItemProperty.getValue()+"!="+memberValue); } catch (Exception ex) { Logger.error(ex); - throw new MembershipException("Error checking properties"); + throw new InvalidCollectionModification("Error checking properties"); } } } @@ -143,13 +144,13 @@ public class DependencyMember implements CollectionMember } @Override - public ItemProxy resolveItem() throws ObjectNotFoundException { + public ItemProxy resolveItem() throws ObjectNotFound { if (mItem == null && mItemPath != null) mItem = Gateway.getProxyManager().getProxy(mItemPath); return mItem; } - public void setChildUUID(String uuid) throws MembershipException, InvalidItemPathException { + public void setChildUUID(String uuid) throws InvalidCollectionModification, InvalidItemPathException { mItemPath = new ItemPath(uuid); } diff --git a/src/main/java/com/c2kernel/collection/MembershipException.java b/src/main/java/com/c2kernel/collection/MembershipException.java deleted file mode 100644 index 3e2ce8c..0000000 --- a/src/main/java/com/c2kernel/collection/MembershipException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.collection; - -/************************************************************************** - * - * $Revision: 1.1 $ - * $Date: 2003/05/09 14:23:01 $ - * - **************************************************************************/ - -public class MembershipException extends Exception { - - public MembershipException() { - super(); - } - - public MembershipException(String s) { - super(s); - } -} diff --git a/src/main/java/com/c2kernel/collection/package-info.java b/src/main/java/com/c2kernel/collection/package-info.java index 1c77816..96bd022 100644 --- a/src/main/java/com/c2kernel/collection/package-info.java +++ b/src/main/java/com/c2kernel/collection/package-info.java @@ -21,25 +21,7 @@ /** * Collections are Item local objects that reference other Items. * - *

    In parallel with the OO meta-model, Items can be linked to other Items in - * different ways. These links are modelled with Collections, which are local - * objects stored in an Item which reference a number of other Items in the same - * server. The Collections holds a CollectionMember, sometimes known as a slot, - * to reference each Item and store additional information about the link. - * - *

    Features: - *

      - *
    • Typing - Collections can restrict membership of based on type - * information derived from Item, Property and Collection descriptions. This - * restriction may be per-slot or apply to the whole Collection. - * - *
    • Fixed or flexible slots - The CollectionMember objects of a - * Collection may be empty, individually typed, or created and removed as - * required, simulating either array, structures or lists. - * - *
    • Layout - Collections can include a {@link GraphModel} to lay out - * its slots on a two-dimensional canvas, for modelling real world compositions. - *
    + * @see Collection */ package com.c2kernel.collection; \ No newline at end of file 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 } } diff --git a/src/main/java/com/c2kernel/events/Event.java b/src/main/java/com/c2kernel/events/Event.java index a6cc9bc..fd5bb33 100644 --- a/src/main/java/com/c2kernel/events/Event.java +++ b/src/main/java/com/c2kernel/events/Event.java @@ -23,7 +23,7 @@ package com.c2kernel.events; import java.util.Calendar; import com.c2kernel.common.GTimeStamp; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.InvalidItemPathException; @@ -289,7 +289,7 @@ public class Event implements C2KLocalObject return time.toString(); } - public void setTimeString(String time) throws InvalidDataException + public void setTimeString(String time) throws InvalidData { if (time.length() == 19) mTimeStamp = new GTimeStamp( @@ -310,7 +310,7 @@ public class Event implements C2KLocalObject Integer.parseInt(time.substring(12,14)), Calendar.getInstance().get(Calendar.ZONE_OFFSET)); else - throw new InvalidDataException("Unknown time format: "+time, ""); + throw new InvalidData("Unknown time format: "+time); } diff --git a/src/main/java/com/c2kernel/events/History.java b/src/main/java/com/c2kernel/events/History.java index a197f65..2010e81 100644 --- a/src/main/java/com/c2kernel/events/History.java +++ b/src/main/java/com/c2kernel/events/History.java @@ -21,7 +21,7 @@ package com.c2kernel.events; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.lifecycle.instance.stateMachine.Transition; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; @@ -93,7 +93,7 @@ public class History extends RemoteMap { String stateMachineName, Integer stateMachineVersion, Transition transition, - String timeString) throws InvalidDataException { + String timeString) throws InvalidData { return addEvent(agentPath, agentRole, stepName, stepPath, stepType, null, null, stateMachineName, stateMachineVersion, transition, null, timeString); } @@ -107,7 +107,7 @@ public class History extends RemoteMap { Integer stateMachineVersion, Transition transition, String viewName, - String timeString) throws InvalidDataException { + String timeString) throws InvalidData { Logger.msg(7, "History.addEvent() - creating new event for "+transition.getName()+" on "+stepName+" in "+mItemPath); Event newEvent = new Event(); newEvent.setItemPath(mItemPath); diff --git a/src/main/java/com/c2kernel/graph/model/GraphableVertex.java b/src/main/java/com/c2kernel/graph/model/GraphableVertex.java index 34b80cd..f8db540 100644 --- a/src/main/java/com/c2kernel/graph/model/GraphableVertex.java +++ b/src/main/java/com/c2kernel/graph/model/GraphableVertex.java @@ -25,7 +25,7 @@ package com.c2kernel.graph.model; */ -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.utils.CastorHashMap; import com.c2kernel.utils.KeyValuePair; public abstract class GraphableVertex extends Vertex @@ -46,13 +46,13 @@ public abstract class GraphableVertex extends Vertex { return mProperties; } - protected Integer getVersionNumberProperty(String propName) throws InvalidDataException { + protected Integer getVersionNumberProperty(String propName) throws InvalidData { Object val = getProperties().get(propName); if (val == null || val.equals("") || val.toString().equals("-1")) return null; try { return new Integer(val.toString()); } catch (NumberFormatException ex) { - throw new InvalidDataException("Invalid version number for property '"+propName+"': "+val.toString(), ""); + throw new InvalidData("Invalid version number for property '"+propName+"': "+val.toString()); } } public KeyValuePair[] getKeyValuePairs() diff --git a/src/main/java/com/c2kernel/lifecycle/ActivityDef.java b/src/main/java/com/c2kernel/lifecycle/ActivityDef.java index d783534..562c2b6 100644 --- a/src/main/java/com/c2kernel/lifecycle/ActivityDef.java +++ b/src/main/java/com/c2kernel/lifecycle/ActivityDef.java @@ -21,8 +21,8 @@ package com.c2kernel.lifecycle; import java.util.Vector; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.lifecycle.instance.Activity; import com.c2kernel.lifecycle.instance.WfVertex; @@ -148,10 +148,10 @@ public class ActivityDef extends WfVertexDef implements C2KLocalObject, Descript } @Override - public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException{ + public WfVertex instantiate() throws ObjectNotFound, InvalidData{ return instantiate(getName()); } - public WfVertex instantiate(String name) throws ObjectNotFoundException, InvalidDataException + public WfVertex instantiate(String name) throws ObjectNotFound, InvalidData { Activity act = new Activity(); configureInstance(act); diff --git a/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java b/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java index 2023122..5c8c90b 100644 --- a/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java +++ b/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java @@ -19,8 +19,8 @@ * http://www.fsf.org/licensing/licenses/lgpl.html */ package com.c2kernel.lifecycle; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.graph.model.Vertex; import com.c2kernel.graph.traversal.GraphTraversal; import com.c2kernel.lifecycle.instance.Activity; @@ -62,7 +62,7 @@ public class ActivitySlotDef extends WfVertexDef getProperties().put("Version", 0); } - public ActivityDef getTheActivityDef() throws ObjectNotFoundException, InvalidDataException + public ActivityDef getTheActivityDef() throws ObjectNotFound, InvalidData { ActivityDef actDef = LocalObjectLoader.getActDef(getActivityDef(), getVersionNumberProperty("Version")); if (actDef instanceof CompositeActivityDef) @@ -189,11 +189,11 @@ public class ActivitySlotDef extends WfVertexDef } @Override - public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException { + public WfVertex instantiate() throws ObjectNotFound, InvalidData { Activity newActivity = (Activity)getTheActivityDef().instantiate(); configureInstance(newActivity); if (newActivity.getProperties().getAbstract().size() > 0) { - throw new InvalidDataException("Abstract properties not overridden: "+newActivity.getProperties().getAbstract().toString(), ""); + throw new InvalidData("Abstract properties not overridden: "+newActivity.getProperties().getAbstract().toString()); } return newActivity; } diff --git a/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java b/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java index c48595f..e015404 100644 --- a/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java +++ b/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java @@ -19,8 +19,8 @@ * http://www.fsf.org/licensing/licenses/lgpl.html */ package com.c2kernel.lifecycle; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.graph.model.GraphModel; import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.graph.model.GraphableVertex; @@ -170,12 +170,12 @@ public class CompositeActivityDef extends ActivityDef * @return CompositeActivity */ @Override - public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException { + public WfVertex instantiate() throws ObjectNotFound, InvalidData { return instantiate(getName()); } @Override - public WfVertex instantiate(String name) throws ObjectNotFoundException, InvalidDataException + public WfVertex instantiate(String name) throws ObjectNotFound, InvalidData { CompositeActivity cAct = new CompositeActivity(); configureInstance(cAct); diff --git a/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java b/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java index 08e6451..27bf00a 100644 --- a/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java +++ b/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java @@ -22,8 +22,8 @@ package com.c2kernel.lifecycle; import java.util.Vector; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.graph.model.GraphableVertex; import com.c2kernel.lifecycle.instance.WfVertex; import com.c2kernel.utils.KeyValuePair; @@ -48,7 +48,7 @@ public abstract class WfVertexDef extends GraphableVertex setIsLayoutable(true); } - public abstract WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException; + public abstract WfVertex instantiate() throws ObjectNotFound, InvalidData; public void configureInstance(WfVertex newVertex) { KeyValuePair[] k = getProperties().getKeyValuePairs(); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java index a0fe6a0..70b991d 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java @@ -26,11 +26,14 @@ import java.util.Map; import java.util.Vector; import com.c2kernel.common.AccessRightsException; +import com.c2kernel.common.CannotManage; import com.c2kernel.common.GTimeStamp; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.InvalidTransitionException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.InvalidTransition; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.agent.Job; import com.c2kernel.events.Event; @@ -45,7 +48,6 @@ import com.c2kernel.lookup.InvalidAgentPathException; import com.c2kernel.lookup.ItemPath; import com.c2kernel.lookup.Path; import com.c2kernel.lookup.RolePath; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.persistency.outcome.Schema; import com.c2kernel.persistency.outcome.Viewpoint; @@ -101,13 +103,13 @@ public class Activity extends WfVertex return new Next(this, vertex); } - public StateMachine getStateMachine() throws InvalidDataException { + public StateMachine getStateMachine() throws InvalidData { if (machine == null) { String name = (String)getProperties().get("StateMachineName"); int version = getVersionNumberProperty("StateMachineVersion"); try { machine = LocalObjectLoader.getStateMachine(name, version); - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { if (name.equals(getDefaultSMName()) && version == 0) { // default state machine not imported yet. Fake it. try { String marshalledSM = Gateway.getResource().getTextResource(null, "boot/SM/"+getDefaultSMName()+".xml"); @@ -117,24 +119,24 @@ public class Activity extends WfVertex return bootstrap; } catch (Exception ex2) { Logger.error(ex2); - throw new InvalidDataException("Could not bootstrap default state machine from resources.", ""); + throw new InvalidData("Could not bootstrap default state machine from resources."); } } Logger.error(ex); - throw new InvalidDataException("Error loading state machine '"+name+"' v"+version, ""); + throw new InvalidData("Error loading state machine '"+name+"' v"+version); } } return machine; } /** return the current State of the State machine (Used in Serialisation) */ - public int getState() throws InvalidDataException + public int getState() throws InvalidData { if (state == -1) state = getStateMachine().getInitialStateCode(); return state; } - public String getStateName() throws InvalidDataException + public String getStateName() throws InvalidData { return getStateMachine().getState(getState()).getName(); } @@ -145,15 +147,19 @@ public class Activity extends WfVertex this.state = state; } - public boolean isFinished() throws InvalidDataException { + public boolean isFinished() throws InvalidData { return getStateMachine().getState(getState()).isFinished(); } /** cf Item request - * @throws ObjectNotFoundException - * @throws PersistencyException */ - public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException + * @throws ObjectNotFound + * @throws PersistencyException + * @throws ObjectAlreadyExists + * @throws ObjectCannotBeUpdated + * @throws CannotManage + * @throws InvalidCollectionModification */ + public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransition, InvalidData, ObjectNotFound, PersistencyException, ObjectAlreadyExists, ObjectCannotBeUpdated, CannotManage, InvalidCollectionModification { // Find requested transition @@ -172,7 +178,7 @@ public class Activity extends WfVertex if (requestData != null && requestData.length()>0) storeOutcome = true; else if (transition.getOutcome().isRequired()) - throw new InvalidDataException("Transition requires outcome data, but none was given", ""); + throw new InvalidData("Transition requires outcome data, but none was given"); } // Get new state @@ -212,10 +218,10 @@ public class Activity extends WfVertex Gateway.getStorage().put(itemPath, currentView, getWf()); } Gateway.getStorage().commit(getWf()); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); Gateway.getStorage().abort(getWf()); - throw new PersistencyException("Exception storing event data"); + throw ex; } if (newState.isFinished()) { @@ -231,7 +237,7 @@ public class Activity extends WfVertex try { RolePath myRole = Gateway.getLookup().getRolePath(agentRole); pushJobsToAgents(itemPath, myRole); - } catch (ObjectNotFoundException ex) { // non-existent role + } catch (ObjectNotFound ex) { // non-existent role Logger.msg(7, "Activity.pushJobsToAgents() - Activity role '"+agentRole+" not found."); } } @@ -241,7 +247,15 @@ public class Activity extends WfVertex } protected String runActivityLogic(AgentPath agent, ItemPath itemPath, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws + InvalidData, + InvalidCollectionModification, + ObjectAlreadyExists, + ObjectCannotBeUpdated, + ObjectNotFound, + PersistencyException, + CannotManage + { // Overriden in predefined steps return requestData; } @@ -309,13 +323,14 @@ public class Activity extends WfVertex return loop2; } /** sets the next activity available if possible - * @throws ObjectNotFoundException + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException + * @throws InvalidTransition * @throws PersistencyException - * @throws ObjectAlreadyExistsException */ + * @throws ObjectAlreadyExists + * @throws ObjectCannotBeUpdated */ @Override - public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidData { setActive(false); try @@ -353,7 +368,7 @@ public class Activity extends WfVertex } } } - catch (InvalidDataException s) + catch (InvalidData s) { setActive(true); throw s; @@ -368,10 +383,10 @@ public class Activity extends WfVertex return null; } /** reinitialises the Activity and propagate (for Loop) - * @throws InvalidDataException - * @throws ObjectNotFoundException */ + * @throws InvalidData + * @throws ObjectNotFound */ @Override - public void reinit(int idLoop) throws InvalidDataException + public void reinit(int idLoop) throws InvalidData { Vertex[] outVertices = getOutGraphables(); setState(getStateMachine().getInitialState().getId()); @@ -391,15 +406,16 @@ public class Activity extends WfVertex } /** * called by precedent Activity runNext() for setting the activity able to be executed - * @throws InvalidDataException - * @throws ObjectAlreadyExistsException + * @throws InvalidData + * @throws ObjectAlreadyExists * @throws AccessRightsException - * @throws InvalidTransitionException - * @throws ObjectNotFoundException + * @throws InvalidTransition + * @throws ObjectNotFound * @throws PersistencyException + * @throws ObjectCannotBeUpdated */ @Override - public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void run(AgentPath agent, ItemPath itemPath) throws InvalidData { Logger.debug(8, getPath() + " run " + getState()); @@ -417,15 +433,16 @@ public class Activity extends WfVertex } /** * sets the activity available to be executed on start of Workflow or composite activity (when it is the first one of the (sub)process - * @throws InvalidDataException - * @throws ObjectAlreadyExistsException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectAlreadyExists + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException + * @throws InvalidTransition * @throws PersistencyException + * @throws ObjectCannotBeUpdated */ @Override - public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidData { Logger.debug(8, getPath() + " runfirst"); run(agent, itemPath); @@ -458,17 +475,19 @@ public class Activity extends WfVertex /** * returns the lists of jobs for the activity and children (cf com.c2kernel.entity.Job) + * @throws InvalidData + * @throws ObjectNotFound * @throws InvalidAgentPathException */ - public ArrayList calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException + public ArrayList calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFound, InvalidData { return calculateJobsBase(agent, itemPath, false); } // - public ArrayList calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException + public ArrayList calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFound, InvalidData { return calculateJobsBase(agent, itemPath, true); } - private ArrayList calculateJobsBase(AgentPath agent, ItemPath itemPath, boolean includeInactive) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException + private ArrayList calculateJobsBase(AgentPath agent, ItemPath itemPath, boolean includeInactive) throws ObjectNotFound, InvalidData, InvalidAgentPathException { Logger.msg(7, "calculateJobs - " + getPath()); ArrayList jobs = new ArrayList(); @@ -491,7 +510,7 @@ public class Activity extends WfVertex try { RolePath myRole = Gateway.getLookup().getRolePath(agentRole); pushJobsToAgents(itemPath, myRole); - } catch (ObjectNotFoundException ex) { // non-existent role + } catch (ObjectNotFound ex) { // non-existent role Logger.msg(7, "Activity.pushJobsToAgents() - Activity role '"+agentRole+" not found."); } } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/AdvancementCalculator.java b/src/main/java/com/c2kernel/lifecycle/instance/AdvancementCalculator.java index 6f2c9ce..6f5da3a 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/AdvancementCalculator.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/AdvancementCalculator.java @@ -22,7 +22,7 @@ package com.c2kernel.lifecycle.instance; import java.util.Hashtable; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.graph.model.Vertex; //import com.c2kernel.utils.Logger; /** @author XSeb74 */ @@ -47,7 +47,7 @@ public class AdvancementCalculator HasNextMarked = new Hashtable(); hasprevActive = new Hashtable(); } - public void calculate(CompositeActivity act) throws InvalidDataException + public void calculate(CompositeActivity act) throws InvalidData { // Logger.debug(0, act.getName()+" >>>>>>>>>"); if (act instanceof Workflow) @@ -77,7 +77,7 @@ public class AdvancementCalculator j++; if (j != 0 && j==nexts.length) current.HasNextMarked.put(v, nexts[0]); } - private void calc(Vertex v, AdvancementCalculator current) throws InvalidDataException + private void calc(Vertex v, AdvancementCalculator current) throws InvalidData { if (current.isMarked.get(v) != null && !(v instanceof Join)) return; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java b/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java index 6503751..c888d7a 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java @@ -19,11 +19,7 @@ * http://www.fsf.org/licensing/licenses/lgpl.html */ package com.c2kernel.lifecycle.instance; -import com.c2kernel.common.AccessRightsException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.InvalidTransitionException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; +import com.c2kernel.common.InvalidData; import com.c2kernel.graph.model.Vertex; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; @@ -41,7 +37,7 @@ public class AndSplit extends Split super(); } @Override - public void runNext(AgentPath agent, ItemPath item) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void runNext(AgentPath agent, ItemPath item) throws InvalidData { AdvancementCalculator adv = new AdvancementCalculator(); adv.calculate((CompositeActivity) getParent()); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java b/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java index 6299633..8e08f99 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java @@ -23,9 +23,13 @@ package com.c2kernel.lifecycle.instance; import java.util.ArrayList; import com.c2kernel.common.AccessRightsException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.InvalidTransitionException; -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.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.agent.Job; import com.c2kernel.graph.model.GraphModel; @@ -302,15 +306,17 @@ public class CompositeActivity extends Activity } /** - * @throws InvalidDataException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException + * @throws InvalidTransition * @throws PersistencyException + * @throws ObjectAlreadyExists + * @throws ObjectCannotBeUpdated * @see com.c2kernel.lifecycle.instance.WfVertex#run() */ @Override - public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void run(AgentPath agent, ItemPath itemPath) throws InvalidData { super.run(agent, itemPath); if (getChildrenGraphModel().getStartVertex() != null && !getStateMachine().getState(state).isFinished()) @@ -321,22 +327,28 @@ public class CompositeActivity extends Activity } @Override - public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, AccessRightsException, InvalidTransitionException, ObjectNotFoundException, PersistencyException + public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidData { if (!getStateMachine().getState(state).isFinished()) - request(agent, itemPath, CompositeActivity.COMPLETE, null); + try { + request(agent, itemPath, CompositeActivity.COMPLETE, null); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + Logger.error(e); // current agent couldn't complete the composite, so leave it + } super.runNext(agent, itemPath); } /** - * @throws InvalidDataException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectNotFound * @throws InvalidAgentPathException * @see com.c2kernel.lifecycle.instance.Activity#calculateJobs() */ @Override - public ArrayList calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException + public ArrayList calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFound, InvalidData { ArrayList jobs = new ArrayList(); boolean childActive = false; @@ -354,7 +366,7 @@ public class CompositeActivity extends Activity } @Override - public ArrayList calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException + public ArrayList calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFound, InvalidData { ArrayList jobs = new ArrayList(); if (recurse) @@ -424,11 +436,11 @@ public class CompositeActivity extends Activity } /** - * @throws InvalidDataException + * @throws InvalidData * */ @Override - public void reinit(int idLoop) throws InvalidDataException + public void reinit(int idLoop) throws InvalidData { super.reinit(idLoop); if (getChildrenGraphModel().getStartVertex() != null && !getStateMachine().getState(state).isFinished()) @@ -436,7 +448,7 @@ public class CompositeActivity extends Activity } @Override - public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException + public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransition, InvalidData, ObjectNotFound, PersistencyException, ObjectAlreadyExists, ObjectCannotBeUpdated, CannotManage, InvalidCollectionModification { if (getChildrenGraphModel().getStartVertex() != null && !getStateMachine().getState(state).isFinished() && transitionID == CompositeActivity.START) ((WfVertex) getChildrenGraphModel().getStartVertex()).run(agent, itemPath); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Join.java b/src/main/java/com/c2kernel/lifecycle/instance/Join.java index 5151aba..2482f49 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Join.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Join.java @@ -22,9 +22,11 @@ package com.c2kernel.lifecycle.instance; import java.util.Vector; 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.ObjectAlreadyExists; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.graph.model.Vertex; import com.c2kernel.graph.traversal.GraphTraversal; @@ -49,15 +51,17 @@ public class Join extends WfVertex public int counter = 0; /** - * @throws InvalidDataException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException + * @throws InvalidTransition * @throws PersistencyException + * @throws ObjectAlreadyExists + * @throws ObjectCannotBeUpdated * @see com.c2kernel.lifecycle.instance.WfVertex#runNext() */ @Override - public void runNext(AgentPath agent, ItemPath item) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void runNext(AgentPath agent, ItemPath item) throws InvalidData { AdvancementCalculator adv = new AdvancementCalculator(); adv.calculate((CompositeActivity) getParent()); @@ -83,11 +87,11 @@ public class Join extends WfVertex new Next(this, (WfVertex) getParent().search(idNext)); } /** - * @throws InvalidDataException + * @throws InvalidData * @see com.c2kernel.lifecycle.instance.WfVertex#reinit(int) */ @Override - public void reinit(int idLoop) throws InvalidDataException + public void reinit(int idLoop) throws InvalidData { Vertex[] outVertices = getOutGraphables(); if (outVertices.length == 1) @@ -170,15 +174,17 @@ public class Join extends WfVertex return mErrors.elementAt(0); } /** - * @throws InvalidDataException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException + * @throws InvalidTransition * @throws PersistencyException + * @throws ObjectAlreadyExists + * @throws ObjectCannotBeUpdated * @see com.c2kernel.lifecycle.instance.WfVertex#run() */ @Override - public void run(AgentPath agent, ItemPath item) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void run(AgentPath agent, ItemPath item) throws InvalidData { runNext(agent, item); } @@ -209,7 +215,7 @@ public class Join extends WfVertex return loop2; } @Override - public void runFirst(AgentPath agent, ItemPath item) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void runFirst(AgentPath agent, ItemPath item) throws InvalidData { runNext(agent, item); } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Loop.java b/src/main/java/com/c2kernel/lifecycle/instance/Loop.java index 0ff1ec8..30e1bb7 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Loop.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Loop.java @@ -19,11 +19,7 @@ * http://www.fsf.org/licensing/licenses/lgpl.html */ package com.c2kernel.lifecycle.instance; -import com.c2kernel.common.AccessRightsException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.InvalidTransitionException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; +import com.c2kernel.common.InvalidData; import com.c2kernel.graph.model.Vertex; import com.c2kernel.graph.traversal.GraphTraversal; import com.c2kernel.lookup.AgentPath; @@ -51,7 +47,7 @@ public class Loop extends XOrSplit return true; } @Override - public void followNext(Next activeNext, AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void followNext(Next activeNext, AgentPath agent, ItemPath itemPath) throws InvalidData { WfVertex v = activeNext.getTerminusVertex(); if (!isInPrev(v)) @@ -63,11 +59,11 @@ public class Loop extends XOrSplit } } /** - * @throws InvalidDataException + * @throws InvalidData * @see com.c2kernel.lifecycle.instance.WfVertex#reinit(int) */ @Override - public void reinit(int idLoop) throws InvalidDataException + public void reinit(int idLoop) throws InvalidData { Logger.msg(8, "Loop.reinit"); if (idLoop == getID()) diff --git a/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java b/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java index cb4ec45..eabf46a 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java @@ -21,7 +21,7 @@ package com.c2kernel.lifecycle.instance; import java.util.StringTokenizer; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.graph.model.DirectedEdge; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; @@ -41,7 +41,7 @@ public class OrSplit extends Split super(); } @Override - public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException + public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidData { String nexts; String scriptName = (String) getProperties().get("RoutingScriptName"); @@ -50,7 +50,7 @@ public class OrSplit extends Split nexts = this.evaluateScript(scriptName, scriptVersion, itemPath).toString(); } catch (ScriptingEngineException e) { Logger.error(e); - throw new InvalidDataException("Error running routing script "+scriptName+" v"+scriptVersion, null); + throw new InvalidData("Error running routing script "+scriptName+" v"+scriptVersion); } StringTokenizer tok = new StringTokenizer(nexts, ","); Logger.msg(7, tok.countTokens() + " nexts to activate:" + nexts); @@ -82,7 +82,7 @@ public class OrSplit extends Split Logger.error(e); } if (active == 0) - throw new InvalidDataException("No nexts were activated!", null); + throw new InvalidData("No nexts were activated!"); } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Split.java b/src/main/java/com/c2kernel/lifecycle/instance/Split.java index 76fee48..e4bbb09 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Split.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Split.java @@ -23,9 +23,11 @@ package com.c2kernel.lifecycle.instance; import java.util.Vector; 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.ObjectAlreadyExists; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.graph.model.Vertex; import com.c2kernel.graph.traversal.GraphTraversal; @@ -53,15 +55,17 @@ public abstract class Split extends WfVertex private boolean loopTested; /** - * @throws InvalidDataException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException + * @throws InvalidTransition * @throws PersistencyException + * @throws ObjectAlreadyExists + * @throws ObjectCannotBeUpdated * @see com.c2kernel.lifecycle.instance.WfVertex#runNext() */ @Override - public abstract void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException; + public abstract void runNext(AgentPath agent, ItemPath itemPath) throws InvalidData; /** * Method addNext. @@ -93,7 +97,7 @@ public abstract class Split extends WfVertex } @Override - public void reinit(int idLoop) throws InvalidDataException + public void reinit(int idLoop) throws InvalidData { Vertex[] outVertices = getOutGraphables(); for (Vertex outVertice : outVertices) @@ -167,15 +171,17 @@ public abstract class Split extends WfVertex } /** - * @throws InvalidDataException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException + * @throws InvalidTransition * @throws PersistencyException + * @throws ObjectAlreadyExists + * @throws ObjectCannotBeUpdated * @see com.c2kernel.lifecycle.instance.WfVertex#run() */ @Override - public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void run(AgentPath agent, ItemPath itemPath) throws InvalidData { runNext(agent, itemPath); } @@ -224,7 +230,7 @@ public abstract class Split extends WfVertex } @Override - public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidData { runNext(agent, itemPath); } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java index 12cfa4e..7eb61a6 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java @@ -25,10 +25,11 @@ package com.c2kernel.lifecycle.instance; import java.util.HashMap; 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.InvalidData; +import com.c2kernel.common.InvalidTransition; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.graph.model.GraphableVertex; import com.c2kernel.lifecycle.routingHelpers.ViewpointDataHelper; @@ -49,13 +50,14 @@ public abstract class WfVertex extends GraphableVertex { /**sets the activity available to be executed on start of Workflow or composite activity (when it is the first one of the * (sub)process - * @throws InvalidDataException - * @throws ObjectAlreadyExistsException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectAlreadyExists + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException - * @throws PersistencyException */ - public abstract void runFirst(AgentPath agent, ItemPath itemPath) throws ScriptingEngineException, InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, ObjectAlreadyExistsException, PersistencyException; + * @throws InvalidTransition + * @throws PersistencyException + * @throws ObjectCannotBeUpdated */ + public abstract void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidData; /** * @see java.lang.Object#Object() @@ -69,14 +71,15 @@ public abstract class WfVertex extends GraphableVertex /** * Method runNext. - * @throws InvalidDataException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException + * @throws InvalidTransition * @throws PersistencyException - * @throws ObjectAlreadyExistsException + * @throws ObjectAlreadyExists + * @throws ObjectCannotBeUpdated */ - public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidData { try { @@ -92,10 +95,10 @@ public abstract class WfVertex extends GraphableVertex /** * Method reinit. * @param idLoop - * @throws InvalidDataException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectNotFound */ - public abstract void reinit( int idLoop ) throws InvalidDataException; + public abstract void reinit( int idLoop ) throws InvalidData; /** * Method verify. @@ -111,14 +114,15 @@ public abstract class WfVertex extends GraphableVertex /** * Method run. - * @throws InvalidDataException - * @throws ObjectAlreadyExistsException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectAlreadyExists + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException + * @throws InvalidTransition * @throws PersistencyException + * @throws ObjectCannotBeUpdated */ - public abstract void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException; + public abstract void run(AgentPath agent, ItemPath itemPath) throws InvalidData; /** * Method loop. @@ -155,7 +159,7 @@ public abstract class WfVertex extends GraphableVertex try { inputParam = ViewpointDataHelper.get(value)[0]; } catch (ArrayIndexOutOfBoundsException ex) { - throw new InvalidDataException("Could not retrieve data from viewpoint: "+value, ""); + throw new InvalidData("Could not retrieve data from viewpoint: "+value); } } if (value.startsWith("property//")) @@ -163,7 +167,7 @@ public abstract class WfVertex extends GraphableVertex value = value.substring(10); try { inputParam = Gateway.getStorage().get(itemPath, ClusterStorage.PROPERTY+"/"+value, null); - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { inputParam = null; } } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java b/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java index abb38cf..f1719f6 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java @@ -22,10 +22,13 @@ package com.c2kernel.lifecycle.instance; import java.util.ArrayList; 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.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.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.agent.Job; @@ -78,10 +81,10 @@ public class Workflow extends CompositeActivity implements C2KLocalObject addChild(predef, new GraphPoint(300, 100)); } - public History getHistory() throws InvalidDataException { + public History getHistory() throws InvalidData { if (history == null) { if (itemPath == null) - throw new InvalidDataException("Workflow not initialized.", ""); + throw new InvalidData("Workflow not initialized."); history = new History(itemPath, this); } return history; @@ -114,21 +117,24 @@ public class Workflow extends CompositeActivity implements C2KLocalObject * @param stepPath * @param transitionID * @param reguestData - * @throws ObjectNotFoundException + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException - * @throws InvalidDataException + * @throws InvalidTransition + * @throws InvalidData * @throws PersistencyException + * @throws ObjectCannotBeUpdated + * @throws CannotManage + * @throws InvalidCollectionModification */ //requestData is xmlstring public String requestAction(AgentPath agent, String stepPath, ItemPath itemPath, int transitionID, String requestData) - throws ObjectNotFoundException, AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException + throws ObjectNotFound, AccessRightsException, InvalidTransition, InvalidData, ObjectAlreadyExists, PersistencyException, ObjectCannotBeUpdated, CannotManage, InvalidCollectionModification { Logger.msg(3, "Action: " + transitionID + " " + stepPath + " by " + agent); if (search(stepPath) != null) return ((Activity) search(stepPath)).request(agent, itemPath, transitionID, requestData); else - throw new ObjectNotFoundException(stepPath + " not found", ""); + throw new ObjectNotFound(stepPath + " not found"); } /** @@ -190,25 +196,17 @@ public class Workflow extends CompositeActivity implements C2KLocalObject * Method initialise. * * @param systemKey - * @throws InvalidDataException - * @throws ObjectNotFoundException + * @throws InvalidData + * @throws ObjectNotFound * @throws AccessRightsException - * @throws InvalidTransitionException + * @throws InvalidTransition + * @throws ObjectAlreadyExists + * @throws ObjectCannotBeUpdated */ - public void initialise(ItemPath itemPath, AgentPath agent) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException + public void initialise(ItemPath itemPath, AgentPath agent) throws InvalidData { setItemPath(itemPath); - try - { - runFirst(agent, itemPath); - } - catch (InvalidDataException ex) - { - Logger.error(ex); - } catch (PersistencyException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + runFirst(agent, itemPath); } public ItemPath getItemPath() { @@ -234,11 +232,11 @@ public class Workflow extends CompositeActivity implements C2KLocalObject * @param itemSysKey * @param type * @return - * @throws ObjectNotFoundException - * @throws InvalidDataException + * @throws ObjectNotFound + * @throws InvalidData * @throws InvalidAgentPathException */ - public ArrayList calculateJobs(AgentPath agent, ItemPath itemPath, int type) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException + public ArrayList calculateJobs(AgentPath agent, ItemPath itemPath, int type) throws InvalidAgentPathException, ObjectNotFound, InvalidData { ArrayList jobs = new ArrayList(); if (type != 1) diff --git a/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java b/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java index 28896af..e5b91d3 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java @@ -23,11 +23,7 @@ package com.c2kernel.lifecycle.instance; import java.util.ArrayList; import java.util.StringTokenizer; -import com.c2kernel.common.AccessRightsException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.InvalidTransitionException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; +import com.c2kernel.common.InvalidData; import com.c2kernel.graph.model.DirectedEdge; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; @@ -49,7 +45,7 @@ public class XOrSplit extends Split } @Override - public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException + public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidData { ArrayList nextsToFollow = new ArrayList(); String nexts; @@ -59,7 +55,7 @@ public class XOrSplit extends Split nexts = this.evaluateScript(scriptName, scriptVersion, itemPath).toString(); } catch (ScriptingEngineException e) { Logger.error(e); - throw new InvalidDataException("Error running routing script "+scriptName+" v"+scriptVersion, ""); + throw new InvalidData("Error running routing script "+scriptName+" v"+scriptVersion); } StringTokenizer tok = new StringTokenizer(nexts,","); @@ -74,13 +70,13 @@ public class XOrSplit extends Split } // Logger.debug(0, getID()+" following "+nexts); if (nextsToFollow.size() != 1) - throw new InvalidDataException("not good number of active next", null); + throw new InvalidData("not good number of active next"); followNext((Next)nextsToFollow.get(0), agent, itemPath); } - public void followNext(Next activeNext, AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException { + public void followNext(Next activeNext, AgentPath agent, ItemPath itemPath) throws InvalidData { activeNext.getTerminusVertex().run(agent, itemPath); } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java index db1e85a..8c078aa 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java @@ -22,7 +22,8 @@ package com.c2kernel.lifecycle.instance.predefined; import java.util.Arrays; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; @@ -48,19 +49,18 @@ public class AddC2KObject extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, PersistencyException { String[] params = getDataList(requestData); if (Logger.doLog(3)) Logger.msg(3, "AddC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - try - { - C2KLocalObject obj = (C2KLocalObject)Gateway.getMarshaller().unmarshall(params[0]); - Gateway.getStorage().put(item, obj, null ); - return requestData; - } - catch( Exception ex ) - { - throw unknownException(ex); - } + if (params.length != 1) throw new InvalidData("AddC2KObject: Invalid parameters "+Arrays.toString(params)); + C2KLocalObject obj; + try { + obj = (C2KLocalObject)Gateway.getMarshaller().unmarshall(params[0]); + } catch (Exception e) { + throw new InvalidData("AddC2KObject: Could not unmarshall new object: "+params[0]); + } + Gateway.getStorage().put(item, obj, null ); + return requestData; } } \ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java index d838aa7..1067911 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java @@ -25,7 +25,10 @@ package com.c2kernel.lifecycle.instance.predefined; import java.util.Arrays; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.ItemPath; @@ -43,22 +46,16 @@ public class AddDomainPath extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectCannotBeUpdated, ObjectAlreadyExists, CannotManage { String[] params = getDataList(requestData); if (Logger.doLog(3)) Logger.msg(3, "AddDomainPath: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); + if (params.length != 1) throw new InvalidData("AddDomainPath: Invalid parameters "+Arrays.toString(params)); - try - { - LookupManager lookupManager = Gateway.getLookupManager(); - DomainPath domainPath = new DomainPath(params[0], item); - lookupManager.add(domainPath); - return requestData; - } - catch( Exception ex ) - { - throw unknownException(ex); - } + LookupManager lookupManager = Gateway.getLookupManager(); + DomainPath domainPath = new DomainPath(params[0], item); + lookupManager.add(domainPath); + return requestData; } } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java index cbe812e..43316b2 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java @@ -24,14 +24,15 @@ package com.c2kernel.lifecycle.instance.predefined; import java.util.Arrays; import com.c2kernel.collection.Dependency; -import com.c2kernel.collection.MembershipException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.process.Gateway; import com.c2kernel.utils.CastorHashMap; import com.c2kernel.utils.Logger; @@ -58,10 +59,14 @@ public class AddMemberToCollection extends PredefinedStep * Params: * 0 - collection name * 1 - target entity key + * @throws ObjectAlreadyExists + * @throws PersistencyException + * @throws ObjectNotFound + * @throws InvalidCollectionModification */ @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectAlreadyExists, PersistencyException, ObjectNotFound, InvalidCollectionModification { String collName; ItemPath newChild; @@ -78,37 +83,22 @@ public class AddMemberToCollection extends PredefinedStep props = (CastorHashMap)Gateway.getMarshaller().unmarshall(params[2]); } catch (Exception e) { - throw new InvalidDataException("AddMemberToCollection: Invalid parameters "+Arrays.toString(params), ""); + throw new InvalidData("AddMemberToCollection: Invalid parameters "+Arrays.toString(params)); } // load collection C2KLocalObject collObj; - try { - collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - } catch (ObjectNotFoundException ex) { - throw new InvalidDataException("AddMemberToCollection: Collection '"+collName+"' not found in this Item", ""); - } catch (ClusterStorageException ex) { - Logger.error(ex); - throw new InvalidDataException("AddMemberToCollection: Error loading collection '\"+collName+\"': "+ex.getMessage(), ""); - } - if (!(collObj instanceof Dependency)) throw new InvalidDataException("AddMemberToCollection: AddMemberToCollection operates on Dependency collections only.", ""); + collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); + if (!(collObj instanceof Dependency)) throw new InvalidData("AddMemberToCollection: AddMemberToCollection operates on Dependency collections only."); dep = (Dependency)collObj; - + // find member and assign entity - try { - if (props == null) - dep.addMember(newChild); - else - dep.addMember(newChild, props, null); - } catch (MembershipException e) { - throw new InvalidDataException("AddMemberToCollection: Item "+newChild+" is the wrong type for this collection", ""); - } + if (props == null) + dep.addMember(newChild); + else + dep.addMember(newChild, props, null); - try { - Gateway.getStorage().put(newChild, dep, null); - } catch (ClusterStorageException e) { - throw unknownException(e); - } + Gateway.getStorage().put(newChild, dep, null); return requestData; } } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java new file mode 100644 index 0000000..6eb69f3 --- /dev/null +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java @@ -0,0 +1,109 @@ +/** + * This file is part of the CRISTAL-iSE kernel. + * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * http://www.fsf.org/licensing/licenses/lgpl.html + */ +package com.c2kernel.lifecycle.instance.predefined; + + +import java.util.Arrays; + +import com.c2kernel.collection.AggregationDescription; +import com.c2kernel.collection.CollectionDescription; +import com.c2kernel.collection.DependencyDescription; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; +import com.c2kernel.lookup.AgentPath; +import com.c2kernel.lookup.ItemPath; +import com.c2kernel.persistency.ClusterStorage; +import com.c2kernel.process.Gateway; +import com.c2kernel.utils.Logger; + +/************************************************************************** + * + * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $ + * @version $Revision: 1.8 $ + **************************************************************************/ +public class AddNewCollectionDescription extends PredefinedStep +{ + /************************************************************************** + * Constructor for Castor + **************************************************************************/ + public AddNewCollectionDescription() + { + super(); + } + + + /** + * Generates a new empty collection description. Collection instances should + * be added by an Admin, who can do so using AddC2KObject. + * + * Params: + * 0 - collection name + * 1 - collection type (Aggregation, Dependency) + * @throws PersistencyException + */ + @Override + protected String runActivityLogic(AgentPath agent, ItemPath item, + int transitionID, String requestData) throws InvalidData, ObjectAlreadyExists, PersistencyException { + + String collName; + String collType; + + // extract parameters + String[] params = getDataList(requestData); + if (Logger.doLog(3)) Logger.msg(3, "AddNewCollectionDescription: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); + if (params.length != 2) + throw new InvalidData("AddNewCollectionDescription: Invalid parameters "+Arrays.toString(params)); + + collName = params[0]; + collType = params[1]; + + // check if collection already exists + try { + Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); + throw new ObjectAlreadyExists("Collection '"+collName+"' already exists"); + } catch (ObjectNotFound ex) { + // collection doesn't exist + } catch (PersistencyException ex) { + Logger.error(ex); + throw new PersistencyException("AddNewCollectionDescription: Error checking for collection '"+collName+"': "+ex.getMessage()); + } + + + CollectionDescription newCollDesc; + + if (collType.equals("Aggregation")) + newCollDesc = new AggregationDescription(collName); + if (collType.equals("Dependency")) + newCollDesc = new DependencyDescription(collName); + else + throw new InvalidData("AddNewCollectionDescription: Invalid collection type specified: '"+collType+"'. Must be Aggregation or Dependency."); + + // store it + try { + Gateway.getStorage().put(item, newCollDesc, null); + } catch (PersistencyException e) { + throw new PersistencyException("AddNewCollectionDescription: Error saving new collection '"+collName+"': "+e.getMessage()); + } + return requestData; + } +} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java index 87cbda0..19ef2ae 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java @@ -24,13 +24,13 @@ package com.c2kernel.lifecycle.instance.predefined; import java.util.Arrays; import com.c2kernel.collection.Aggregation; -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.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.process.Gateway; import com.c2kernel.property.PropertyDescription; import com.c2kernel.property.PropertyDescriptionList; @@ -62,10 +62,14 @@ public class AddNewSlot extends PredefinedStep *
  • Item Description key (optional)
  • *
  • Item Description version (optional)
  • * + * + * @throws InvalidData Then the parameters were incorrect + * @throws PersistencyException There was a problem loading or saving the collection from persistency + * @throws ObjectNotFound A required object, such as the collection or a PropertyDescription outcome, wasn't found */ @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, PersistencyException, ObjectNotFound { String collName; ItemPath descKey = null; @@ -82,20 +86,18 @@ public class AddNewSlot extends PredefinedStep if (params.length > 1 && params[1].length() > 0) descKey = new ItemPath(params[1]); if (params.length > 2 && params[2].length() > 0) descVer = params[2]; } catch (Exception e) { - throw new InvalidDataException("AddNewSlot: Invalid parameters "+Arrays.toString(params), ""); + throw new InvalidData("AddNewSlot: Invalid parameters "+Arrays.toString(params)); } // load collection C2KLocalObject collObj; try { collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - } catch (ObjectNotFoundException ex) { - throw new InvalidDataException("AddNewSlot: Collection '"+collName+"' not found in this Item", ""); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); - throw new InvalidDataException("AddNewSlot: Error loading collection '\"+collName+\"': "+ex.getMessage(), ""); + throw new PersistencyException("AddNewSlot: Error loading collection '\"+collName+\"': "+ex.getMessage()); } - if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AddNewSlot: AddNewSlot operates on Aggregation collections only.", ""); + if (!(collObj instanceof Aggregation)) throw new InvalidData("AddNewSlot: AddNewSlot operates on Aggregation collections only."); agg = (Aggregation)collObj; // get props @@ -103,11 +105,7 @@ public class AddNewSlot extends PredefinedStep StringBuffer classProps = new StringBuffer(); if (descKey != null) { PropertyDescriptionList propList; - try { - propList = PropertyUtility.getPropertyDescriptionOutcome(descKey, descVer); - } catch (ObjectNotFoundException e) { - throw new InvalidDataException("AddNewSlot: Item "+descKey+" does not contain a PropertyDescription outcome to define a slot", ""); - } + propList = PropertyUtility.getPropertyDescriptionOutcome(descKey, descVer); for (PropertyDescription pd : propList.list) { props.put(pd.getName(), pd.getDefaultValue()); if (pd.getIsClassIdentifier()) @@ -119,9 +117,9 @@ public class AddNewSlot extends PredefinedStep try { Gateway.getStorage().put(item, agg, null); - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error(e); - throw new InvalidDataException("AddNewSlot: Error storing collection", ""); + throw new PersistencyException("AddNewSlot: Error saving collection '"+collName+"': "+e.getMessage()); } return requestData; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java index 054b2da..fdf852f 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java @@ -25,14 +25,15 @@ import java.util.Arrays; import com.c2kernel.collection.Aggregation; import com.c2kernel.collection.AggregationMember; -import com.c2kernel.collection.MembershipException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -57,10 +58,14 @@ public class AssignItemToSlot extends PredefinedStep * 0 - collection name * 1 - slot number * 2 - target entity key + * @throws ObjectNotFound + * @throws PersistencyException + * @throws ObjectCannotBeUpdated + * @throws InvalidCollectionModification */ @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectNotFound, PersistencyException, ObjectCannotBeUpdated, InvalidCollectionModification { String collName; int slotNo; @@ -76,20 +81,18 @@ public class AssignItemToSlot extends PredefinedStep slotNo = Integer.parseInt(params[1]); childItem = new ItemPath(params[2]); } catch (Exception e) { - throw new InvalidDataException("AssignItemToSlot: Invalid parameters "+Arrays.toString(params), ""); + throw new InvalidData("AssignItemToSlot: Invalid parameters "+Arrays.toString(params)); } // load collection C2KLocalObject collObj; try { collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - } catch (ObjectNotFoundException ex) { - throw new InvalidDataException("AssignItemToSlot: Collection '"+collName+"' not found in this Item", ""); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); - throw new InvalidDataException("AssignItemToSlot: Error loading collection '\"+collName+\"': "+ex.getMessage(), ""); + throw new PersistencyException("AssignItemToSlot: Error loading collection '\"+collName+\"': "+ex.getMessage()); } - if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AssignItemToSlot: AssignItemToSlot operates on Aggregation collections only.", ""); + if (!(collObj instanceof Aggregation)) throw new InvalidData("AssignItemToSlot: AssignItemToSlot operates on Aggregation collections only."); agg = (Aggregation)collObj; // find member and assign entity @@ -97,25 +100,20 @@ public class AssignItemToSlot extends PredefinedStep for (AggregationMember member : agg.getMembers().list) { if (member.getID() == slotNo) { if (member.getItemPath() != null) - throw new InvalidDataException("AssignItemToSlot: Member slot "+slotNo+" not empty", ""); - try { - member.assignItem(childItem); - } catch (MembershipException e) { - throw new InvalidDataException("AssignItemToSlot: Item "+childItem+" does not fit in slot "+slotNo, ""); - } + throw new ObjectCannotBeUpdated("AssignItemToSlot: Member slot "+slotNo+" not empty"); + member.assignItem(childItem); stored = true; break; } } if (!stored) { - throw new InvalidDataException("AssignItemToSlot: Member slot "+slotNo+" not found.", ""); + throw new ObjectNotFound("AssignItemToSlot: Member slot "+slotNo+" not found."); } - try { Gateway.getStorage().put(item, agg, null); - } catch (ClusterStorageException e) { - unknownException(e); + } catch (PersistencyException e) { + throw new PersistencyException("AssignItemToSlot: Error saving collection '"+collName+"': "+e.getMessage()); } return requestData; } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java index acba2cb..a15b98f 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java @@ -25,12 +25,13 @@ import java.util.Arrays; import com.c2kernel.collection.Aggregation; import com.c2kernel.collection.AggregationMember; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -54,10 +55,13 @@ public class ClearSlot extends PredefinedStep * Params: * 0 - collection name * 1 - slot number + * @throws ObjectNotFound + * @throws PersistencyException + * @throws ObjectCannotBeUpdated */ @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectNotFound, PersistencyException, ObjectCannotBeUpdated { String collName; int slotNo; @@ -71,17 +75,15 @@ public class ClearSlot extends PredefinedStep collName = params[0]; slotNo = Integer.parseInt(params[1]); } catch (Exception e) { - throw new InvalidDataException("ClearSlot: Invalid parameters "+Arrays.toString(params), ""); + throw new InvalidData("ClearSlot: Invalid parameters "+Arrays.toString(params)); } // load collection try { agg = (Aggregation)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - } catch (ObjectNotFoundException ex) { - throw new InvalidDataException("ClearSlot: Collection '"+collName+"' not found in this Item", ""); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); - throw new InvalidDataException("ClearSlot: Error loading collection '"+collName+"': "+ex.getMessage(), ""); + throw new PersistencyException("ClearSlot: Error loading collection '"+collName+"': "+ex.getMessage()); } // find member and clear @@ -89,22 +91,22 @@ public class ClearSlot extends PredefinedStep for (AggregationMember member : agg.getMembers().list) { if (member.getID() == slotNo) { if (member.getItemPath() != null) - throw new InvalidDataException("ClearSlot: Member slot "+slotNo+" already empty", ""); + throw new ObjectCannotBeUpdated("ClearSlot: Member slot "+slotNo+" already empty"); member.clearItem(); stored = true; break; } } if (!stored) { - throw new InvalidDataException("Member slot "+slotNo+" not found.", ""); + throw new ObjectNotFound("ClearSlot: Member slot "+slotNo+" not found."); } try { Gateway.getStorage().put(item, agg, null); - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error(e); - throw new InvalidDataException("Error storing collection", ""); + throw new PersistencyException("ClearSlot: Error storing collection"); } return requestData; } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java index 0210fe3..e17919d 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java @@ -22,12 +22,12 @@ package com.c2kernel.lifecycle.instance.predefined; import java.util.Arrays; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.PersistencyException; import com.c2kernel.events.Event; import com.c2kernel.events.History; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.TransactionManager; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.persistency.outcome.Viewpoint; @@ -54,7 +54,7 @@ public class Import extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, PersistencyException { String[] params = getDataList(requestData); if (Logger.doLog(3)) Logger.msg(3, "Import: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); @@ -63,7 +63,7 @@ public class Import extends PredefinedStep int split2 = params[0].indexOf(':'); if (split1 == -1) - throw new InvalidDataException("Import: Invalid parameters "+Arrays.toString(params)); + throw new InvalidData("Import: Invalid parameters "+Arrays.toString(params)); requestData = params[1]; @@ -95,10 +95,9 @@ public class Import extends PredefinedStep storage.put(item, new Viewpoint(item, schemaName, viewpoint, schemaVersion, event.getID()), locker); if (!"last".equals(viewpoint)) storage.put(item, new Viewpoint(item, schemaName, "last", schemaVersion, event.getID()), locker); - } catch (ClusterStorageException e) { - Logger.error(e); + } catch (PersistencyException e) { storage.abort(locker); - throw new InvalidDataException("Import: Could not store imported outcome. Rolled back.", ""); + throw e; } storage.commit(locker); return requestData; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java index 1d4476f..9b6d6c4 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java @@ -32,7 +32,6 @@ import org.w3c.dom.NodeList; import org.w3c.dom.Text; import org.xml.sax.InputSource; -import com.c2kernel.common.InvalidDataException; import com.c2kernel.lifecycle.instance.Activity; import com.c2kernel.lifecycle.instance.predefined.agent.AgentPredefinedStepContainer; import com.c2kernel.lifecycle.instance.predefined.item.ItemPredefinedStepContainer; @@ -158,12 +157,6 @@ public abstract class PredefinedStep extends Activity return xmlData.toString(); } } - public InvalidDataException unknownException(Exception ex) { - String stepName = this.getClass().getSimpleName(); - Logger.error(stepName+": Exception:"); - Logger.error(ex); - return new InvalidDataException(stepName+": "+ex.getClass().getSimpleName()+". See log.", ""); - } // generic bundling of single parameter static public String bundleData(String data) diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java index 4e53f39..abf625c 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java @@ -41,6 +41,7 @@ public abstract class PredefinedStepContainer extends CompositeActivity predInit("RemoveC2KObject", "Removes the named C2Kernel object from this Item.", new RemoveC2KObject()); predInit("WriteProperty", "Writes a property to the Item", new WriteProperty()); predInit("WriteViewpoint", "Writes a viewpoint to the Item", new WriteViewpoint()); + predInit("AddNewCollectionDescription", "Creates a new collection description in this Item", new AddNewCollectionDescription()); predInit("AddNewSlot", "Creates a new slot in the given aggregation, that holds instances of the item description of the given key", new AddNewSlot()); predInit("AssignItemToSlot", "Assigns the referenced entity to a pre-existing slot in an aggregation", new AssignItemToSlot()); predInit("ClearSlot", "Clears an aggregation member slot, given a slot no or entity key", new ClearSlot()); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java index 1b9b6f7..a88e000 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java @@ -24,7 +24,8 @@ package com.c2kernel.lifecycle.instance.predefined; import java.util.Arrays; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.PersistencyException; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; import com.c2kernel.process.Gateway; @@ -47,19 +48,21 @@ public class RemoveC2KObject extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, PersistencyException { String[] params = getDataList(requestData); if (Logger.doLog(3)) Logger.msg(3, "RemoveC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - + if (params.length != 1) + throw new InvalidData("RemoveC2KObject: Invalid parameters "+Arrays.toString(params)); + String path = params[0]; + try { - String path = params[0]; Gateway.getStorage().remove( item, path, null ); } - catch( Exception ex ) + catch( PersistencyException ex ) { - throw unknownException(ex); + throw new PersistencyException("RemoveC2KObject: Error removing object '"+path+"': "+ex.getMessage()); } return requestData; } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java index 3181249..0248650 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java @@ -25,8 +25,10 @@ package com.c2kernel.lifecycle.instance.predefined; import java.util.Arrays; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.ItemPath; @@ -44,29 +46,27 @@ public class RemoveDomainPath extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectNotFound, ObjectCannotBeUpdated, CannotManage { String[] params = getDataList(requestData); if (Logger.doLog(3)) Logger.msg(3, "RemoveDomainPath: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - + if (params.length != 1) throw new InvalidData("RemoveDomainPath: Invalid parameters "+Arrays.toString(params)); + DomainPath domainPath = new DomainPath(params[0]); if (!domainPath.exists()) - throw new InvalidDataException("RemoveDomainPath: Domain path "+domainPath.toString()+" does not exist.", ""); + throw new ObjectNotFound("RemoveDomainPath: Domain path "+domainPath.toString()+" does not exist."); if (domainPath.getType()!=DomainPath.ENTITY) try { if (!domainPath.getItemPath().equals(item)) - throw new InvalidDataException("RemoveDomainPath: Domain path "+domainPath.toString()+" is not an alias of the current Item "+item, ""); - } catch (ObjectNotFoundException ex) { - throw new InvalidDataException("RemoveDomainPath: Domain path "+domainPath.toString()+" is a context.", ""); - } - try { - LookupManager lookupManager = Gateway.getLookupManager(); - lookupManager.delete(domainPath); - return requestData; - } catch (Exception ex) { - throw unknownException(ex); + throw new InvalidData("RemoveDomainPath: Domain path "+domainPath.toString()+" is not an alias of the current Item "+item); + } catch (ObjectNotFound ex) { + throw new InvalidData("RemoveDomainPath: Domain path "+domainPath.toString()+" is a context."); } + + LookupManager lookupManager = Gateway.getLookupManager(); + lookupManager.delete(domainPath); + return requestData; } } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java index e228688..061202d 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java @@ -25,13 +25,12 @@ import java.util.Arrays; import com.c2kernel.collection.Collection; import com.c2kernel.collection.CollectionMember; -import com.c2kernel.collection.MembershipException; -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.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -56,10 +55,12 @@ public class RemoveSlotFromCollection extends PredefinedStep * 0 - collection name * 1 - slot number OR if null: * 2 - target entity key + * @throws ObjectNotFound + * @throws PersistencyException */ @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectNotFound, PersistencyException { String collName; int slotNo = -1; @@ -75,35 +76,29 @@ public class RemoveSlotFromCollection extends PredefinedStep if (params.length>1 && params[1].length()>0) slotNo = Integer.parseInt(params[1]); if (params.length>2 && params[2].length()>0) currentChild = new ItemPath(params[2]); } catch (Exception e) { - throw new InvalidDataException("RemoveSlotFromCollection: Invalid parameters "+Arrays.toString(params), ""); + throw new InvalidData("RemoveSlotFromCollection: Invalid parameters "+Arrays.toString(params)); } if (slotNo == -1 && currentChild == null) - throw new InvalidDataException("RemoveSlotFromCollection: Must give either slot number or entity key", ""); + throw new InvalidData("RemoveSlotFromCollection: Must give either slot number or entity key"); // load collection try { coll = (Collection)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - } catch (ObjectNotFoundException ex) { - throw new InvalidDataException("RemoveSlotFromCollection: Collection '"+collName+"' not found in this Item", ""); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); - throw new InvalidDataException("RemoveSlotFromCollection: Error loading collection '\"+collName+\"': "+ex.getMessage(), ""); + throw new PersistencyException("RemoveSlotFromCollection: Error loading collection '\"+collName+\"': "+ex.getMessage()); } // check the slot is there if it's given by id CollectionMember slot = null; if (slotNo > -1) { - try { - slot = coll.getMember(slotNo); - } catch (ObjectNotFoundException e) { - throw new InvalidDataException("RemoveSlotFromCollection: Slot "+slotNo+" not found in this collection", ""); - } + slot = coll.getMember(slotNo); } // if both parameters are supplied, check the given item is actually in that slot if (slot != null && currentChild != null && !slot.getItemPath().equals(currentChild)) { - throw new InvalidDataException("RemoveSlotFromCollection: Item "+currentChild+" was not in slot "+slotNo, ""); + throw new ObjectNotFound("RemoveSlotFromCollection: Item "+currentChild+" was not in slot "+slotNo); } if (slotNo == -1) { // find slot from entity key @@ -115,22 +110,18 @@ public class RemoveSlotFromCollection extends PredefinedStep } } if (slotNo == -1) { - throw new InvalidDataException("No match", ""); + throw new ObjectNotFound("Could not find "+currentChild+" in collection "+coll.getName()); } // Remove the slot - try { - coll.removeMember(slotNo); - } catch (MembershipException e) { - throw new InvalidDataException(e.getMessage(), ""); - } + coll.removeMember(slotNo); // Store the collection try { Gateway.getStorage().put(item, coll, null); - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error(e); - throw new InvalidDataException("Error storing collection", ""); + throw new PersistencyException("Error storing collection"); } return requestData; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java index 14c6488..ddb89ba 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java @@ -23,7 +23,8 @@ package com.c2kernel.lifecycle.instance.predefined; //Java import java.util.Arrays; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.PersistencyException; import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.lifecycle.instance.CompositeActivity; import com.c2kernel.lifecycle.instance.Workflow; @@ -42,30 +43,34 @@ public class ReplaceDomainWorkflow extends PredefinedStep @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, PersistencyException { Workflow lifeCycle = getWf(); String[] params = getDataList(requestData); if (Logger.doLog(3)) Logger.msg(3, "AddC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - - try - { - lifeCycle.getChildGraphModel().removeVertex(lifeCycle.search("workflow/domain")); - CompositeActivity domain = (CompositeActivity) Gateway.getMarshaller().unmarshall(params[0]); - domain.setName("domain"); - lifeCycle.initChild(domain, true, new GraphPoint(150, 100)); - // if new workflow, activate it, otherwise refresh the jobs - if (!domain.active) lifeCycle.run(agent, item); - else lifeCycle.refreshJobs(item); - - // store new wf - Gateway.getStorage().put(item, lifeCycle, null); - return requestData; + if (params.length != 1) throw new InvalidData("AddC2KObject: Invalid parameters "+Arrays.toString(params)); + + lifeCycle.getChildGraphModel().removeVertex(lifeCycle.search("workflow/domain")); + CompositeActivity domain; + try { + domain = (CompositeActivity) Gateway.getMarshaller().unmarshall(params[0]); + } catch (Exception e) { + Logger.error(e); + throw new InvalidData("ReplaceDomainWorkflow: Could not unmarshall new workflow: "+e.getMessage()); } - catch (Exception ex) - { - throw unknownException(ex); + domain.setName("domain"); + lifeCycle.initChild(domain, true, new GraphPoint(150, 100)); + // if new workflow, activate it, otherwise refresh the jobs + if (!domain.active) lifeCycle.run(agent, item); + else lifeCycle.refreshJobs(item); + + // store new wf + try { + Gateway.getStorage().put(item, lifeCycle, null); + } catch (PersistencyException e) { + throw new PersistencyException("ReplaceDomainWorkflow: Could not write new workflow to storage: "+e.getMessage()); } + return requestData; } } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java index 6dd7e0a..e41411b 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java @@ -22,12 +22,13 @@ package com.c2kernel.lifecycle.instance.predefined; import java.util.Arrays; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.process.Gateway; import com.c2kernel.property.Property; import com.c2kernel.utils.Logger; @@ -50,13 +51,13 @@ public class WriteProperty extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectCannotBeUpdated, ObjectNotFound, PersistencyException { String[] params = getDataList(requestData); if (Logger.doLog(3)) Logger.msg(3, "WriteProperty: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); if (params.length != 2) - throw new InvalidDataException("WriteProperty: invalid parameters "+Arrays.toString(params), ""); + throw new InvalidData("WriteProperty: invalid parameters "+Arrays.toString(params)); String name = params[0]; String newValue = params[1]; @@ -66,13 +67,11 @@ public class WriteProperty extends PredefinedStep try { prop = (Property)Gateway.getStorage().get(item, ClusterStorage.PROPERTY+"/"+name, null); if (!prop.isMutable() && !newValue.equals(prop.getValue())) - throw new InvalidDataException("WriteProperty: Property '"+name+"' is not mutable.", ""); + throw new ObjectCannotBeUpdated("WriteProperty: Property '"+name+"' is not mutable."); prop.setValue(newValue); Gateway.getStorage().put(item, prop, null); - } catch (ObjectNotFoundException e) { - throw new InvalidDataException("WriteProperty: Property '"+name+"' not found.", ""); - } catch (ClusterStorageException e) { - throw unknownException(e); + } catch (ObjectNotFound e) { + throw new ObjectNotFound("WriteProperty: Property '"+name+"' not found."); } return requestData; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java index 349e34c..efe6a5f 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java @@ -22,13 +22,13 @@ package com.c2kernel.lifecycle.instance.predefined; import java.util.Arrays; -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.events.Event; 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.utils.Logger; @@ -41,7 +41,7 @@ public class WriteViewpoint extends PredefinedStep { @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectNotFound, PersistencyException { String schemaName; String viewName; @@ -52,7 +52,7 @@ public class WriteViewpoint extends PredefinedStep { // outcometype, name and evId. Event and Outcome should be checked so schema version should be discovered. if (params.length != 3) - throw new InvalidDataException("WriteViewpoint: Invalid parameters "+Arrays.toString(params), ""); + throw new InvalidData("WriteViewpoint: Invalid parameters "+Arrays.toString(params)); schemaName = params[0]; viewName = params[1]; @@ -60,7 +60,7 @@ public class WriteViewpoint extends PredefinedStep { try { evId = Integer.parseInt(params[2]); } catch (NumberFormatException ex) { - throw new InvalidDataException("WriteViewpoint: Parameter 3 (EventId) must be an integer", ""); + throw new InvalidData("WriteViewpoint: Parameter 3 (EventId) must be an integer"); } // Find event @@ -68,21 +68,18 @@ public class WriteViewpoint extends PredefinedStep { Event ev; try { ev = (Event)Gateway.getStorage().get(item, ClusterStorage.HISTORY+"/"+evId, null); - } catch (ObjectNotFoundException e) { + } catch (PersistencyException e) { Logger.error(e); - throw new InvalidDataException("WriteViewpoint: Event "+evId+" not found", ""); - } catch (ClusterStorageException e) { - Logger.error(e); - throw new InvalidDataException("WriteViewpoint: Exception loading event", ""); + throw new PersistencyException("WriteViewpoint: Could not load event "+evId); } // Write new viewpoint Viewpoint newView = new Viewpoint(item, schemaName, viewName, ev.getSchemaVersion(), evId); try { Gateway.getStorage().put(item, newView, null); - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error(e); - throw new InvalidDataException("WriteViewpoint: Could not store new viewpoint", ""); + throw new PersistencyException("WriteViewpoint: Could not store new viewpoint"); } return requestData; } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java index 0ce7c67..564c5db 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java @@ -20,10 +20,14 @@ */ package com.c2kernel.lifecycle.instance.predefined.agent; -import com.c2kernel.common.AccessRightsException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectNotFoundException; +import java.util.Arrays; + +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.CorbaServer; import com.c2kernel.entity.agent.ActiveEntity; import com.c2kernel.lifecycle.instance.predefined.item.CreateItemFromDescription; @@ -53,71 +57,80 @@ public class CreateAgentFromDescription extends CreateItemFromDescription *
  • Comma-delimited Role names to assign to the agent. Must already exist.
  • *
  • Initial properties to set in the new Agent
  • * + * @throws ObjectNotFound + * @throws InvalidData The input parameters were incorrect + * @throws ObjectAlreadyExists The Agent already exists + * @throws CannotManage The Agent could not be created + * @throws ObjectCannotBeUpdated The addition of the new entries into the LookupManager failed * @see com.c2kernel.lifecycle.instance.predefined.item.CreateItemFromDescription#runActivityLogic(com.c2kernel.lookup.AgentPath, int, int, java.lang.String) */ @Override - protected String runActivityLogic(AgentPath agent, ItemPath itemPath, - int transitionID, String requestData) throws InvalidDataException { + protected String runActivityLogic(AgentPath agent, ItemPath item, + int transitionID, String requestData) throws ObjectNotFound, InvalidData, ObjectAlreadyExists, CannotManage, ObjectCannotBeUpdated { + + String[] params = getDataList(requestData); + if (Logger.doLog(3)) Logger.msg(3, "CreateAgentFromDescription: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); + if (params.length < 3 || params.length > 4) + throw new InvalidData("CreateAgentFromDescription: Invalid parameters "+Arrays.toString(params)); - String[] input = getDataList(requestData); - String newName = input[0]; - String descVer = input[1]; - String roles = input[2]; + String newName = params[0]; + String descVer = params[1]; + String roles = params[2]; PropertyArrayList initProps = - input.length > 3 ? getInitProperties(input[3]):new PropertyArrayList(); + params.length > 3 ? getInitProperties(params[3]):new PropertyArrayList(); Logger.msg(1, "CreateAgentFromDescription::request() - Starting."); - try { - - // check if given roles exist - String[] roleArr = roles.split(","); - for(int i=0; i rolesToRemove = new ArrayList(); @@ -75,7 +75,7 @@ public class SetAgentRoles extends PredefinedStep { Gateway.getLookupManager().removeRole(targetAgent, roleToRemove); } catch (Exception e) { Logger.error(e); - throw new InvalidDataException("Error removing role "+roleToRemove.getName(), ""); + throw new InvalidData("Error removing role "+roleToRemove.getName()); } // add requested roles we don't already have @@ -84,7 +84,7 @@ public class SetAgentRoles extends PredefinedStep { Gateway.getLookupManager().addRole(targetAgent, roleToAdd); } catch (Exception e) { Logger.error(e); - throw new InvalidDataException("Error adding role "+roleToAdd.getName(), ""); + throw new InvalidData("Error adding role "+roleToAdd.getName()); } return requestData; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java index d2c48ff..02ea642 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java @@ -24,10 +24,12 @@ import com.c2kernel.collection.Collection; import com.c2kernel.collection.CollectionArrayList; import com.c2kernel.collection.CollectionDescription; import com.c2kernel.collection.CollectionMember; -import com.c2kernel.common.AccessRightsException; -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.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.CorbaServer; import com.c2kernel.entity.TraceableEntity; import com.c2kernel.lifecycle.CompositeActivityDef; @@ -37,7 +39,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.process.Gateway; import com.c2kernel.property.Property; import com.c2kernel.property.PropertyArrayList; @@ -61,7 +62,7 @@ public class CreateItemFromDescription extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath itemPath, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectNotFound, ObjectAlreadyExists, CannotManage, ObjectCannotBeUpdated, PersistencyException { String[] input = getDataList(requestData); String newName = input[0]; @@ -72,65 +73,64 @@ public class CreateItemFromDescription extends PredefinedStep Logger.msg(1, "CreateItemFromDescription - Starting."); - try { - // check if the path is already taken - DomainPath context = new DomainPath(new DomainPath(domPath), newName); - //Logger.debug(8,"context "+context.getItemPath()+" "+context.getPath()+" "+context.getString()); - if (context.exists()) - throw new ObjectAlreadyExistsException("The path " +context+ " exists already.", ""); - - // get init objects - - /* ITEM CREATION */ - - // generate new entity key - Logger.msg(6, "CreateItemFromDescription - Requesting new item path"); - ItemPath newItemPath = new ItemPath(); - - // resolve the item factory - Logger.msg(6, "CreateItemFromDescription - Resolving item factory"); - - // create the Item object - Logger.msg(3, "CreateItemFromDescription - Creating Item"); - CorbaServer factory = Gateway.getCorbaServer(); - if (factory == null) throw new AccessRightsException("This process cannot create new Items", ""); - TraceableEntity newItem = factory.createItem(newItemPath); - Gateway.getLookupManager().add(newItemPath); - - - // initialise it with its properties and workflow - - Logger.msg(3, "CreateItemFromDescription - Initializing Item"); - - newItem.initialise( - agent.getSystemKey(), - Gateway.getMarshaller().marshall(getNewProperties(itemPath, descVer, initProps, newName, agent)), - Gateway.getMarshaller().marshall(getNewWorkflow(itemPath, descVer)), - Gateway.getMarshaller().marshall(getNewCollections(itemPath, descVer)) - ); - - // add its domain path - Logger.msg(3, "CreateItemFromDescription - Creating "+context); - context.setItemPath(newItemPath); - Gateway.getLookupManager().add(context); - return requestData; - } catch (Exception e) { - Logger.error(e); - throw new InvalidDataException(e.getMessage(), ""); - } + // check if the path is already taken + DomainPath context = new DomainPath(new DomainPath(domPath), newName); + //Logger.debug(8,"context "+context.getItemPath()+" "+context.getPath()+" "+context.getString()); + if (context.exists()) + throw new ObjectAlreadyExists("The path " +context+ " exists already."); + + // get init objects + + /* ITEM CREATION */ + + // generate new entity key + Logger.msg(6, "CreateItemFromDescription - Requesting new item path"); + ItemPath newItemPath = new ItemPath(); + + // resolve the item factory + Logger.msg(6, "CreateItemFromDescription - Resolving item factory"); + + // create the Item object + Logger.msg(3, "CreateItemFromDescription - Creating Item"); + CorbaServer factory = Gateway.getCorbaServer(); + if (factory == null) throw new CannotManage("This process cannot create new Items"); + TraceableEntity newItem = factory.createItem(newItemPath); + Gateway.getLookupManager().add(newItemPath); + + // initialise it with its properties and workflow + + Logger.msg(3, "CreateItemFromDescription - Initializing Item"); + + try { + newItem.initialise( + agent.getSystemKey(), + Gateway.getMarshaller().marshall(getNewProperties(itemPath, descVer, initProps, newName, agent)), + Gateway.getMarshaller().marshall(getNewWorkflow(itemPath, descVer)), + Gateway.getMarshaller().marshall(getNewCollections(itemPath, descVer)) + ); + } catch (PersistencyException e) { + throw e; + } catch (Exception e) { + throw new InvalidData("CreateAgentFromDescription: Problem initializing new Agent. See log: "+e.getMessage()); + } + // add its domain path + Logger.msg(3, "CreateItemFromDescription - Creating "+context); + context.setItemPath(newItemPath); + Gateway.getLookupManager().add(context); + return requestData; } - protected PropertyArrayList getInitProperties(String input) throws InvalidDataException { + protected PropertyArrayList getInitProperties(String input) throws InvalidData { try { return (PropertyArrayList)Gateway.getMarshaller().unmarshall(input); } catch (Exception e) { Logger.error(e); - throw new InvalidDataException("Initial property parameter was not a marshalled PropertyArrayList: "+input, ""); + throw new InvalidData("Initial property parameter was not a marshalled PropertyArrayList: "+input); } } - protected PropertyArrayList getNewProperties(ItemPath itemPath, String descVer, PropertyArrayList initProps, String newName, AgentPath agent) throws ObjectNotFoundException, InvalidDataException { + protected PropertyArrayList getNewProperties(ItemPath itemPath, String descVer, PropertyArrayList initProps, String newName, AgentPath agent) throws ObjectNotFound, InvalidData { // copy properties -- intend to create from propdesc PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer); PropertyArrayList props = pdList.instantiate(initProps); @@ -147,7 +147,7 @@ public class CreateItemFromDescription extends PredefinedStep return props; } - protected CompositeActivity getNewWorkflow(ItemPath itemPath, String descVer) throws ClusterStorageException, ObjectNotFoundException, InvalidDataException { + protected CompositeActivity getNewWorkflow(ItemPath itemPath, String descVer) throws ObjectNotFound, InvalidData, PersistencyException { // find the workflow def for the given description version String wfDefName = null; Integer wfDefVer = null; @@ -159,26 +159,26 @@ public class CreateItemFromDescription extends PredefinedStep try { wfDefVer = Integer.parseInt(wfVerObj.toString()); } catch (NumberFormatException ex) { - throw new InvalidDataException("Invalid workflow version number: "+wfVerObj.toString(), ""); + throw new InvalidData("Invalid workflow version number: "+wfVerObj.toString()); } // load workflow def if (wfDefName == null) - throw new InvalidDataException("No workflow given or defined", ""); + throw new InvalidData("No workflow given or defined"); if (wfDefVer == null) - throw new InvalidDataException("No workflow def version given",""); + throw new InvalidData("No workflow def version given"); try { CompositeActivityDef wfDef = (CompositeActivityDef)LocalObjectLoader.getActDef(wfDefName, wfDefVer); return (CompositeActivity)wfDef.instantiate(); - } catch (ObjectNotFoundException ex) { - throw new InvalidDataException("Workflow def '"+wfDefName+"'v"+wfDefVer+" not found", ""); + } catch (ObjectNotFound ex) { + throw new InvalidData("Workflow def '"+wfDefName+"'v"+wfDefVer+" not found"); } catch (ClassCastException ex) { - throw new InvalidDataException("Activity def '"+wfDefName+"' was not Composite", ""); + throw new InvalidData("Activity def '"+wfDefName+"' was not Composite"); } } - protected CollectionArrayList getNewCollections(ItemPath itemPath, String descVer) throws ClusterStorageException, ObjectNotFoundException { + protected CollectionArrayList getNewCollections(ItemPath itemPath, String descVer) throws ObjectNotFound, PersistencyException { // loop through collections, collecting instantiated descriptions and finding the default workflow def CollectionArrayList colls = new CollectionArrayList(); String[] collNames = Gateway.getStorage().getClusterContents(itemPath, ClusterStorage.COLLECTION); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java index 8245c4a..f96bc08 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java @@ -24,7 +24,11 @@ package com.c2kernel.lifecycle.instance.predefined.item; import java.util.Iterator; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; @@ -50,33 +54,23 @@ public class Erase extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectNotFound, ObjectCannotBeUpdated, CannotManage, PersistencyException { Logger.msg(1, "Erase::request() - Starting."); - try - { - // get all domain paths - Iterator domPaths = Gateway.getLookup().searchAliases(item); - while (domPaths.hasNext()) { - DomainPath path = (DomainPath)domPaths.next(); - // delete them - if (path.getItemPath().equals(item)) - Gateway.getLookupManager().delete(path); - } - - //clear out all storages - Gateway.getStorage().removeCluster(item, "", null); - - //remove entity path - Gateway.getLookupManager().delete(item); + Iterator domPaths = Gateway.getLookup().searchAliases(item); + while (domPaths.hasNext()) { + DomainPath path = (DomainPath)domPaths.next(); + // delete them + if (path.getItemPath().equals(item)) + Gateway.getLookupManager().delete(path); } - catch( Exception ex ) - { - Logger.error(ex); - throw new InvalidDataException(ex.toString(), ""); - } + //clear out all storages + Gateway.getStorage().removeCluster(item, "", null); + + //remove entity path + Gateway.getLookupManager().delete(item); Logger.msg(1, "Erase::request() - DONE."); return requestData; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java index 3cb2182..57de2a1 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java @@ -20,11 +20,12 @@ */ package com.c2kernel.lifecycle.instance.predefined.server; +import java.util.Arrays; import java.util.Stack; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectAlreadyExists; import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; @@ -41,13 +42,15 @@ public class AddDomainContext extends PredefinedStep { @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectCannotBeUpdated, ObjectAlreadyExists, CannotManage { - Logger.msg(1, "AddDomainContext::request() - Starting."); + String[] params = getDataList(requestData); + if (Logger.doLog(3)) Logger.msg(3, "AddDomainContext: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); + if (params.length != 1) throw new InvalidData("AddDomainContext: Invalid parameters "+Arrays.toString(params)); - DomainPath pathToAdd = new DomainPath(getDataList(requestData)[0]); + DomainPath pathToAdd = new DomainPath(params); if (pathToAdd.exists()) - throw new InvalidDataException("Context "+pathToAdd+" already exists", ""); + throw new ObjectAlreadyExists("Context "+pathToAdd+" already exists"); // collect parent paths if they don't exist Stack pathsToAdd = new Stack(); while(pathToAdd!= null && !pathToAdd.exists()) { @@ -56,16 +59,7 @@ public class AddDomainContext extends PredefinedStep { } while(!pathsToAdd.empty()) { pathToAdd = pathsToAdd.pop(); - try { - Gateway.getLookupManager().add(pathToAdd); - } catch (ObjectAlreadyExistsException e) { - Logger.error("Context "+pathToAdd+" inconsistently exists."); - } catch (ObjectCannotBeUpdated e) { - Logger.error(e); - throw new InvalidDataException("Exception adding path "+pathToAdd+": "+e.getMessage(), ""); - } catch (CannotManageException e) { - throw new InvalidDataException("Cannot alter directory in a non-server process", ""); - } + Gateway.getLookupManager().add(pathToAdd); } return requestData; } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java index 6caf25e..ffe8950 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java @@ -20,7 +20,11 @@ */ package com.c2kernel.lifecycle.instance.predefined.server; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.imports.ImportAgent; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; @@ -39,19 +43,25 @@ public class CreateNewAgent extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectNotFound, ObjectCannotBeUpdated, CannotManage, ObjectAlreadyExists { String redactedRequestData; - try { - ImportAgent newAgent = (ImportAgent)Gateway.getMarshaller().unmarshall(requestData); - newAgent.create(agent, true); - newAgent.setPassword("REDACTED"); - redactedRequestData = Gateway.getMarshaller().marshall(newAgent); - return redactedRequestData; - } catch (Exception ex) { - Logger.error(ex); - throw new InvalidDataException("Error creating agent", ""); - } + ImportAgent newAgent; + try { + newAgent = (ImportAgent)Gateway.getMarshaller().unmarshall(requestData); + } catch (Exception e1) { + Logger.error(e1); + throw new InvalidData("CreateNewAgent: Couldn't unmarshall new Agent: "+requestData); + } + newAgent.create(agent, true); + newAgent.setPassword("REDACTED"); + try { + redactedRequestData = Gateway.getMarshaller().marshall(newAgent); + } catch (Exception e) { + Logger.error(e); + throw new InvalidData("CreateNewAgent: Couldn't marshall new Agent for outcome: "+newAgent); + } + return redactedRequestData; } } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java index 139bc55..5e0505e 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java @@ -23,7 +23,12 @@ package com.c2kernel.lifecycle.instance.predefined.server; -import com.c2kernel.common.InvalidDataException; +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.ObjectNotFound; import com.c2kernel.entity.imports.ImportItem; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; @@ -42,15 +47,16 @@ public class CreateNewItem extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectCannotBeUpdated, ObjectNotFound, CannotManage, ObjectAlreadyExists, InvalidCollectionModification { - try { - ImportItem newItem = (ImportItem)Gateway.getMarshaller().unmarshall(requestData); - newItem.create(agent, false); - return requestData; - } catch (Exception ex) { - Logger.error(ex); - throw new InvalidDataException("Error creating item", ""); - } + ImportItem newItem; + try { + newItem = (ImportItem)Gateway.getMarshaller().unmarshall(requestData); + } catch (Exception e) { + Logger.error(e); + throw new InvalidData("CreateNewAgent: Couldn't unmarshall new Agent: "+requestData); + } + newItem.create(agent, false); + return requestData; } } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java index 49231ea..de05dec 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java @@ -20,7 +20,11 @@ */ package com.c2kernel.lifecycle.instance.predefined.server; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.imports.ImportRole; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; @@ -39,16 +43,17 @@ public class CreateNewRole extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectAlreadyExists, ObjectCannotBeUpdated, CannotManage, ObjectNotFound { - try { - ImportRole newRole = (ImportRole)Gateway.getMarshaller().unmarshall(requestData); - newRole.create(agent, true); - return requestData; - } catch (Exception ex) { - Logger.error(ex); - throw new InvalidDataException("Error creating role", ""); - } + ImportRole newRole; + try { + newRole = (ImportRole)Gateway.getMarshaller().unmarshall(requestData); + } catch (Exception e) { + Logger.error(e); + throw new InvalidData("CreateNewAgent: Couldn't unmarshall new Agent: "+requestData); + } + newRole.create(agent, true); + return requestData; } } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java index d90f163..2d78e69 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java @@ -20,10 +20,12 @@ */ package com.c2kernel.lifecycle.instance.predefined.server; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; +import java.util.Arrays; + +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; @@ -38,28 +40,25 @@ public class RemoveDomainContext extends PredefinedStep { @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, ObjectNotFound, ObjectCannotBeUpdated, CannotManage { - Logger.msg(1, "RemoveDomainContext::request() - Starting."); - - DomainPath pathToDelete = new DomainPath(getDataList(requestData)[0]); + String[] params = getDataList(requestData); + if (Logger.doLog(3)) Logger.msg(3, "RemoveDomainContext: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); + if (params.length != 1) throw new InvalidData("RemoveDomainContext: Invalid parameters "+Arrays.toString(params)); + + DomainPath pathToDelete = new DomainPath(params[0]); if (!pathToDelete.exists()) - throw new InvalidDataException("Context "+pathToDelete+" does not exist", ""); + throw new ObjectNotFound("Context "+pathToDelete+" does not exist"); + try { pathToDelete.getItemPath(); - throw new InvalidDataException("Path "+pathToDelete+" is an Entity. Use its own Erase step instead, or RemoveAgent.", ""); - } catch (ObjectNotFoundException ex) { } + throw new InvalidData("Path "+pathToDelete+" is an Entity. Use its own Erase step instead, or RemoveAgent."); + } catch (ObjectNotFound ex) { } + if (Gateway.getLookup().getChildren(pathToDelete).hasNext()) - throw new InvalidDataException("Context "+pathToDelete+" is not empty. Cannot delete.", ""); + throw new ObjectCannotBeUpdated("Context "+pathToDelete+" is not empty. Cannot delete."); - try { - Gateway.getLookupManager().delete(pathToDelete); - } catch (ObjectCannotBeUpdated e) { - Logger.error(e); - throw new InvalidDataException("Exception deleting path"+pathToDelete+": "+e.getMessage(), ""); - } catch (CannotManageException e) { - throw new InvalidDataException("Cannot alter directory in a non-server process", ""); - } + Gateway.getLookupManager().delete(pathToDelete); return requestData; } } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java index a467ee0..7aeda55 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java @@ -22,10 +22,10 @@ package com.c2kernel.lifecycle.instance.predefined.server; import java.util.Arrays; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.ItemPath; @@ -44,33 +44,22 @@ public class RemoveRole extends PredefinedStep //requestdata is xmlstring @Override protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData, CannotManage, ObjectNotFound, ObjectCannotBeUpdated { - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "AddC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - LookupManager lookup; - try { - lookup = Gateway.getLookupManager(); - } catch (CannotManageException e) { - throw new InvalidDataException(e.getMessage(), ""); - } - - RolePath thisRole; AgentPath[] agents; - try { - thisRole = lookup.getRolePath(params[0]); - agents = Gateway.getLookup().getAgents(thisRole); - } catch (ObjectNotFoundException e) { - throw new InvalidDataException("Role "+params[0]+" not found.", ""); - } + String[] params = getDataList(requestData); + if (Logger.doLog(3)) Logger.msg(3, "RemoveRole: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); + if (params.length != 1) throw new InvalidData("RemoveRole: Invalid parameters "+Arrays.toString(params)); + + LookupManager lookup = Gateway.getLookupManager(); + + RolePath thisRole; AgentPath[] agents; + thisRole = lookup.getRolePath(params[0]); + agents = Gateway.getLookup().getAgents(thisRole); if (agents.length > 0) - throw new InvalidDataException("Cannot remove role. "+agents.length+" agents still hold it.", ""); - try { - lookup.delete(thisRole); - } catch (ObjectCannotBeUpdated e) { - Logger.error(e); - throw new InvalidDataException("Role "+params[0]+" could not be removed.", ""); - } + throw new ObjectCannotBeUpdated("Cannot remove role. "+agents.length+" agents still hold it."); + + lookup.delete(thisRole); return requestData; 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 getPossibleTransitions(Activity act, AgentPath agent) throws ObjectNotFoundException, InvalidDataException { + public Map getPossibleTransitions(Activity act, AgentPath agent) throws ObjectNotFound, InvalidData { HashMap returnList = new HashMap(); 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)+")"); } } diff --git a/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java b/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java index ae86c2a..db441da 100644 --- a/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java +++ b/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java @@ -20,7 +20,7 @@ */ package com.c2kernel.lifecycle.routingHelpers; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.proxy.ItemProxy; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; @@ -78,7 +78,7 @@ public class ViewpointDataHelper retArr = XmlElementParser.parse(outcome.getData(), xpath); return retArr; - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { return errArr; } } diff --git a/src/main/java/com/c2kernel/lookup/AgentPath.java b/src/main/java/com/c2kernel/lookup/AgentPath.java index d2a6c7f..06be6d4 100644 --- a/src/main/java/com/c2kernel/lookup/AgentPath.java +++ b/src/main/java/com/c2kernel/lookup/AgentPath.java @@ -26,7 +26,7 @@ import java.util.UUID; import org.apache.xerces.impl.dv.util.Base64; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.common.SystemKey; import com.c2kernel.process.Gateway; @@ -47,7 +47,7 @@ public class AgentPath extends ItemPath super(syskey); try { findAgentName(); - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { throw new InvalidAgentPathException(); } } @@ -55,7 +55,7 @@ public class AgentPath extends ItemPath super(uuid); try { findAgentName(); - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { throw new InvalidAgentPathException(); } } @@ -64,7 +64,7 @@ public class AgentPath extends ItemPath super(itemPath.mUUID); try { findAgentName(); - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { throw new InvalidAgentPathException(); } } @@ -78,7 +78,7 @@ public class AgentPath extends ItemPath super(path); try { findAgentName(); - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { throw new InvalidAgentPathException(); } } @@ -93,13 +93,13 @@ public class AgentPath extends ItemPath if (mAgentName==null) try { findAgentName(); - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { return null; } return mAgentName; } - private void findAgentName() throws ObjectNotFoundException { + private void findAgentName() throws ObjectNotFound { mAgentName = Gateway.getLookup().getAgentName(this); } @@ -115,7 +115,7 @@ public class AgentPath extends ItemPath public boolean hasRole(String role) { try { return hasRole(Gateway.getLookup().getRolePath(role)); - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { return false; } } diff --git a/src/main/java/com/c2kernel/lookup/DomainPath.java b/src/main/java/com/c2kernel/lookup/DomainPath.java index f1fad5a..1a86b57 100644 --- a/src/main/java/com/c2kernel/lookup/DomainPath.java +++ b/src/main/java/com/c2kernel/lookup/DomainPath.java @@ -20,7 +20,7 @@ */ package com.c2kernel.lookup; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.process.Gateway; @@ -95,13 +95,13 @@ public class DomainPath extends Path } @Override - public ItemPath getItemPath() throws ObjectNotFoundException { + public ItemPath getItemPath() throws ObjectNotFound { if (mType == UNKNOWN) { // must decide checkType(); } if (target == null) - throw new ObjectNotFoundException("Path "+toString()+" does not resolve to an Item", ""); + throw new ObjectNotFound("Path "+toString()+" does not resolve to an Item"); return target; } @@ -118,7 +118,7 @@ public class DomainPath extends Path setItemPath(Gateway.getLookup().resolvePath(this)); } catch (InvalidItemPathException ex) { mType = CONTEXT; - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { mType = CONTEXT; } diff --git a/src/main/java/com/c2kernel/lookup/ItemPath.java b/src/main/java/com/c2kernel/lookup/ItemPath.java index 855a5dd..ad13854 100644 --- a/src/main/java/com/c2kernel/lookup/ItemPath.java +++ b/src/main/java/com/c2kernel/lookup/ItemPath.java @@ -24,7 +24,7 @@ import java.nio.ByteBuffer; import java.util.Arrays; import java.util.UUID; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.common.SystemKey; @@ -86,7 +86,7 @@ public class ItemPath extends Path } @Override - public ItemPath getItemPath() throws ObjectNotFoundException { + public ItemPath getItemPath() throws ObjectNotFound { return this; } diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java index 924057a..f7e4f59 100644 --- a/src/main/java/com/c2kernel/lookup/Lookup.java +++ b/src/main/java/com/c2kernel/lookup/Lookup.java @@ -22,7 +22,7 @@ package com.c2kernel.lookup; import java.util.Iterator; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.process.auth.Authenticator; import com.c2kernel.property.Property; import com.c2kernel.property.PropertyDescriptionList; @@ -53,9 +53,9 @@ public interface Lookup { * @param sysKey The system key of the Item * @return an ItemPath or AgentPath * @throws InvalidItemPathException When the system key is invalid/out-of-range - * @throws ObjectNotFoundException When the Item does not exist in the directory. + * @throws ObjectNotFound When the Item does not exist in the directory. */ - public ItemPath getItemPath(String sysKey) throws InvalidItemPathException, ObjectNotFoundException; + public ItemPath getItemPath(String sysKey) throws InvalidItemPathException, ObjectNotFound; /** * Find the ItemPath for which a DomainPath is an alias. @@ -63,18 +63,18 @@ public interface Lookup { * @param domainPath The path to resolve * @return The ItemPath it points to (should be an AgentPath if the path references an Agent) * @throws InvalidItemPathException - * @throws ObjectNotFoundException + * @throws ObjectNotFound */ - public ItemPath resolvePath(DomainPath domainPath) throws InvalidItemPathException, ObjectNotFoundException; + public ItemPath resolvePath(DomainPath domainPath) throws InvalidItemPathException, ObjectNotFound; /** * Resolve a path to a CORBA Object Item or Agent * * @param path The path to be resolved * @return The CORBA Object - * @throws ObjectNotFoundException When the Path doesn't exist, or doesn't have an IOR associated with it + * @throws ObjectNotFound When the Path doesn't exist, or doesn't have an IOR associated with it */ - public org.omg.CORBA.Object resolve(Path path) throws ObjectNotFoundException; + public org.omg.CORBA.Object resolve(Path path) throws ObjectNotFound; // Path finding and searching @@ -131,23 +131,23 @@ public interface Lookup { /** * @param agentName * @return - * @throws ObjectNotFoundException + * @throws ObjectNotFound */ - public AgentPath getAgentPath(String agentName) throws ObjectNotFoundException; + public AgentPath getAgentPath(String agentName) throws ObjectNotFound; /** * @param roleName * @return - * @throws ObjectNotFoundException + * @throws ObjectNotFound */ - public RolePath getRolePath(String roleName) throws ObjectNotFoundException; + public RolePath getRolePath(String roleName) throws ObjectNotFound; /** * @param rolePath * @return - * @throws ObjectNotFoundException + * @throws ObjectNotFound */ - public AgentPath[] getAgents(RolePath rolePath) throws ObjectNotFoundException; + public AgentPath[] getAgents(RolePath rolePath) throws ObjectNotFound; /** * @param agentPath @@ -167,8 +167,8 @@ public interface Lookup { /** * @param agentPath * @return - * @throws ObjectNotFoundException + * @throws ObjectNotFound */ - public String getAgentName(AgentPath agentPath) throws ObjectNotFoundException; + public String getAgentName(AgentPath agentPath) throws ObjectNotFound; } diff --git a/src/main/java/com/c2kernel/lookup/LookupManager.java b/src/main/java/com/c2kernel/lookup/LookupManager.java index b05a4a4..620c522 100644 --- a/src/main/java/com/c2kernel/lookup/LookupManager.java +++ b/src/main/java/com/c2kernel/lookup/LookupManager.java @@ -22,9 +22,9 @@ package com.c2kernel.lookup; import java.security.NoSuchAlgorithmException; -import com.c2kernel.common.ObjectAlreadyExistsException; +import com.c2kernel.common.ObjectAlreadyExists; import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; /** * @author abranson @@ -35,9 +35,9 @@ public interface LookupManager extends Lookup { /** * Called when a server starts up. The Lookup implementation should ensure that the initial structure of its directory is valid, and create it on first boot. * - * @throws ObjectNotFoundException When initialization data is not found + * @throws ObjectNotFound When initialization data is not found */ - public void initializeDirectory() throws ObjectNotFoundException; + public void initializeDirectory() throws ObjectNotFound; // Path management @@ -46,9 +46,9 @@ public interface LookupManager extends Lookup { * * @param newPath The path to add * @throws ObjectCannotBeUpdated When there is an error writing to the directory - * @throws ObjectAlreadyExistsException When the Path has already been registered + * @throws ObjectAlreadyExists When the Path has already been registered */ - public void add(Path newPath) throws ObjectCannotBeUpdated, ObjectAlreadyExistsException; + public void add(Path newPath) throws ObjectCannotBeUpdated, ObjectAlreadyExists; /** * Remove a Path from the directory @@ -65,10 +65,10 @@ public interface LookupManager extends Lookup { * @param role * @param hasJobList * @return - * @throws ObjectAlreadyExistsException + * @throws ObjectAlreadyExists * @throws ObjectCannotBeUpdated */ - public RolePath createRole(RolePath role) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated; + public RolePath createRole(RolePath role) throws ObjectAlreadyExists, ObjectCannotBeUpdated; /** * Adds the given Agent to the given Role, if they both exist. @@ -76,9 +76,9 @@ public interface LookupManager extends Lookup { * @param agent - the * @param rolePath * @throws ObjectCannotBeUpdated - * @throws ObjectNotFoundException + * @throws ObjectNotFound */ - public void addRole(AgentPath agent, RolePath rolePath) throws ObjectCannotBeUpdated, ObjectNotFoundException; + public void addRole(AgentPath agent, RolePath rolePath) throws ObjectCannotBeUpdated, ObjectNotFound; /** * Removes the given Agent from the given Role. Does not delete the Role. @@ -86,26 +86,26 @@ public interface LookupManager extends Lookup { * @param agent * @param role * @throws ObjectCannotBeUpdated - * @throws ObjectNotFoundException + * @throws ObjectNotFound */ - public void removeRole(AgentPath agent, RolePath role) throws ObjectCannotBeUpdated, ObjectNotFoundException; + public void removeRole(AgentPath agent, RolePath role) throws ObjectCannotBeUpdated, ObjectNotFound; /** * @param agent * @param newPassword - * @throws ObjectNotFoundException + * @throws ObjectNotFound * @throws ObjectCannotBeUpdated * @throws NoSuchAlgorithmException */ - public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException; + public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFound, ObjectCannotBeUpdated, NoSuchAlgorithmException; /** * @param role * @param hasJobList - * @throws ObjectNotFoundException + * @throws ObjectNotFound * @throws ObjectCannotBeUpdated */ - public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated; + public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFound, ObjectCannotBeUpdated; } diff --git a/src/main/java/com/c2kernel/lookup/Path.java b/src/main/java/com/c2kernel/lookup/Path.java index 3ccdb35..7085a36 100644 --- a/src/main/java/com/c2kernel/lookup/Path.java +++ b/src/main/java/com/c2kernel/lookup/Path.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.StringTokenizer; import java.util.UUID; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.common.SystemKey; import com.c2kernel.process.Gateway; @@ -194,7 +194,7 @@ public abstract class Path Lookup myLookup = Gateway.getLookup(); try { newIOR = myLookup.resolve(this); - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { } setIOR(newIOR); } @@ -218,7 +218,7 @@ public abstract class Path return mUUID; } - public abstract ItemPath getItemPath() throws ObjectNotFoundException; + public abstract ItemPath getItemPath() throws ObjectNotFound; @Override public boolean equals( Object path ) diff --git a/src/main/java/com/c2kernel/lookup/RolePath.java b/src/main/java/com/c2kernel/lookup/RolePath.java index 7432171..97682ab 100644 --- a/src/main/java/com/c2kernel/lookup/RolePath.java +++ b/src/main/java/com/c2kernel/lookup/RolePath.java @@ -22,9 +22,9 @@ package com.c2kernel.lookup; import java.util.Iterator; -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.process.Gateway; @@ -50,7 +50,7 @@ public class RolePath extends DomainPath try { if (mPath.length > 2) return Gateway.getLookup().getRolePath(mPath[mPath.length-2]); - } catch (ObjectNotFoundException ex) { } + } catch (ObjectNotFound ex) { } return null; } @@ -77,10 +77,10 @@ public class RolePath extends DomainPath /** * @param hasJobList The hasJobList to set. * @throws ObjectCannotBeUpdated - * @throws ObjectNotFoundException - * @throws CannotManageException + * @throws ObjectNotFound + * @throws CannotManage */ - public void setHasJobList(boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException { + public void setHasJobList(boolean hasJobList) throws ObjectNotFound, ObjectCannotBeUpdated, CannotManage { this.hasJobList = hasJobList; } diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorage.java b/src/main/java/com/c2kernel/persistency/ClusterStorage.java index e4aa81c..a2a33fe 100644 --- a/src/main/java/com/c2kernel/persistency/ClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/ClusterStorage.java @@ -21,6 +21,7 @@ package com.c2kernel.persistency; import com.c2kernel.collection.Collection; +import com.c2kernel.common.PersistencyException; import com.c2kernel.common.SystemKey; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.lookup.ItemPath; @@ -48,7 +49,7 @@ import com.c2kernel.utils.Logger; * {@link #put(ItemPath, C2KLocalObject)} and {@link #delete(ItemPath, String)} * for clusters they return {@link #WRITE} and {@link #READWRITE} from * {@link #getClusterContents(ItemPath, String)}. Operations that have not been - * declared as not supported should throw a ClusterStorageException. If a + * declared as not supported should throw a PersistencyException. If a * cluster does not exist, get should return null, and delete should return with * no action. */ @@ -145,21 +146,21 @@ public abstract class ClusterStorage { * @param auth * The Authenticator instance that the user or server logged in * with. - * @throws ClusterStorageException + * @throws PersistencyException * If storage initialization failed */ public abstract void open(Authenticator auth) - throws ClusterStorageException; + throws PersistencyException; /** * Shuts down the storage. Data must be completely written to disk before * this method returns, so the process can exit. No further gets or puts * should follow. * - * @throws ClusterStorageException + * @throws PersistencyException * If closing failed */ - public abstract void close() throws ClusterStorageException; + public abstract void close() throws PersistencyException; /** * Declares whether or not this ClusterStorage can read or write a @@ -240,11 +241,11 @@ public abstract class ClusterStorage { * @param path * The path of the local object * @return The C2KLocalObject, or null if the object was not found - * @throws ClusterStorageException + * @throws PersistencyException * when retrieval failed */ public abstract C2KLocalObject get(ItemPath itemPath, String path) - throws ClusterStorageException; + throws PersistencyException; /** * Stores a CRISTAL local object. The path is automatically generated. @@ -253,11 +254,11 @@ public abstract class ClusterStorage { * The Item that the object will be stored under * @param obj * The C2KLocalObject to store - * @throws ClusterStorageException + * @throws PersistencyException * When storage fails */ public abstract void put(ItemPath itemPath, C2KLocalObject obj) - throws ClusterStorageException; + throws PersistencyException; /** * Remove a CRISTAL local object from storage. This should be used sparingly @@ -268,11 +269,11 @@ public abstract class ClusterStorage { * The containing Item * @param path * The path of the object to be removed - * @throws ClusterStorageException + * @throws PersistencyException * When deletion fails or is not allowed */ public abstract void delete(ItemPath itemPath, String path) - throws ClusterStorageException; + throws PersistencyException; // directory listing /** @@ -285,10 +286,10 @@ public abstract class ClusterStorage { * The path within that Item to query. May be ClusterStorage.ROOT * (empty String) * @return A String array of the possible next path elements - * @throws ClusterStorageException + * @throws PersistencyException * When an error occurred during the query */ public abstract String[] getClusterContents(ItemPath itemPath, String path) - throws ClusterStorageException; + throws PersistencyException; } diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorageException.java b/src/main/java/com/c2kernel/persistency/ClusterStorageException.java deleted file mode 100644 index dc83446..0000000 --- a/src/main/java/com/c2kernel/persistency/ClusterStorageException.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.persistency; - -/** - * - * @version $Revision: 1.2 $ $Date: 2003/07/14 07:57:06 $ - * @author $Author: abranson $ - */ - -public class ClusterStorageException extends Exception { - public ClusterStorageException() { - super(); - } - - public ClusterStorageException(String s) { - super(s); - } - - /** - * @param aMessage - * the detail message. - * @param aCause - * the cause - */ - public ClusterStorageException(String aMessage, Throwable aCause) { - super(aMessage, aCause); - } -} diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java index 61e04a7..baabb19 100644 --- a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java +++ b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java @@ -27,7 +27,8 @@ import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.agent.JobList; import com.c2kernel.entity.proxy.ProxyMessage; @@ -60,10 +61,10 @@ public class ClusterStorageManager { * Initialises all ClusterStorage handlers listed by class name in the property "ClusterStorages" * This property is usually process specific, and so should be in the server/client.conf and not the connect file. */ - public ClusterStorageManager(Authenticator auth) throws ClusterStorageException { + public ClusterStorageManager(Authenticator auth) throws PersistencyException { Object clusterStorageProp = Gateway.getProperties().getObject("ClusterStorage"); if (clusterStorageProp == null || clusterStorageProp.equals("")) { - throw new ClusterStorageException("ClusterStorageManager.init() - no ClusterStorages defined. No persistency!"); + throw new PersistencyException("ClusterStorageManager.init() - no ClusterStorages defined. No persistency!"); } ArrayList rootStores; @@ -77,20 +78,20 @@ public class ClusterStorageManager { if (thisStore instanceof ClusterStorage) rootStores.add((ClusterStorage)thisStore); else - throw new ClusterStorageException("Supplied ClusterStorage "+thisStore.toString()+" was not an instance of ClusterStorage"); + throw new PersistencyException("Supplied ClusterStorage "+thisStore.toString()+" was not an instance of ClusterStorage"); } } else { - throw new ClusterStorageException("Unknown class of ClusterStorage property: "+clusterStorageProp.getClass().getName()); + throw new PersistencyException("Unknown class of ClusterStorage property: "+clusterStorageProp.getClass().getName()); } int clusterNo = 0; for (ClusterStorage newStorage : rootStores) { try { newStorage.open(auth); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); - throw new ClusterStorageException("ClusterStorageManager.init() - Error initialising storage handler " + newStorage.getClass().getName() + + throw new PersistencyException("ClusterStorageManager.init() - Error initialising storage handler " + newStorage.getClass().getName() + ": " + ex.getMessage()); } Logger.msg(5, "ClusterStorageManager.init() - Cluster storage " + newStorage.getClass().getName() + @@ -102,7 +103,7 @@ public class ClusterStorageManager { } - public ArrayList instantiateStores(String allClusters) throws ClusterStorageException { + public ArrayList instantiateStores(String allClusters) throws PersistencyException { ArrayList rootStores = new ArrayList(); StringTokenizer tok = new StringTokenizer(allClusters, ","); clusterPriority = new String[tok.countTokens()]; @@ -117,13 +118,13 @@ public class ClusterStorageManager { newStorage = (ClusterStorage)(Class.forName("com.c2kernel.persistency."+newStorageClass).newInstance()); } } catch (ClassNotFoundException ex) { - throw new ClusterStorageException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass + + throw new PersistencyException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass + " could not be found."); } catch (InstantiationException ex) { - throw new ClusterStorageException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass + + throw new PersistencyException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass + " could not be instantiated."); } catch (IllegalAccessException ex) { - throw new ClusterStorageException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass + + throw new PersistencyException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass + " was not allowed to be instantiated."); } rootStores.add(newStorage); @@ -135,7 +136,7 @@ public class ClusterStorageManager { for (ClusterStorage thisStorage : allStores.values()) { try { thisStorage.close(); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); } } @@ -177,7 +178,7 @@ public class ClusterStorageManager { * Retrieves the ids of the next level of a cluster * Does not look in any currently open transactions. */ - public String[] getClusterContents(ItemPath itemPath, String path) throws ClusterStorageException { + public String[] getClusterContents(ItemPath itemPath, String path) throws PersistencyException { ArrayList contents = new ArrayList(); // get all readers @@ -194,7 +195,7 @@ public class ClusterStorageManager { contents.add(thisArr[j]); } } - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.msg(5, "ClusterStorageManager.getClusterContents() - reader " + thisReader.getName() + " could not retrieve contents of " + itemPath + "/" + path + ": " + e.getMessage()); } @@ -206,7 +207,7 @@ public class ClusterStorageManager { } /** Internal get method. Retrieves clusters from ClusterStorages & maintains the memory cache */ - public C2KLocalObject get(ItemPath itemPath, String path) throws ClusterStorageException, ObjectNotFoundException { + public C2KLocalObject get(ItemPath itemPath, String path) throws PersistencyException, ObjectNotFound { C2KLocalObject result = null; // check cache first Map sysKeyMemCache = null; @@ -271,23 +272,23 @@ public class ClusterStorageManager { // then return it return result; } - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.msg(7, "ClusterStorageManager.get() - reader " + thisReader.getName() + " could not retrieve " + itemPath + "/" + path + ": " + e.getMessage()); } } - throw new ObjectNotFoundException("ClusterStorageManager.get() - Path " + path + " not found in " + itemPath, ""); + throw new ObjectNotFound("ClusterStorageManager.get() - Path " + path + " not found in " + itemPath); } /** Internal put method. Creates or overwrites a cluster in all writers. Used when committing transactions. */ - public void put(ItemPath itemPath, C2KLocalObject obj) throws ClusterStorageException { + public void put(ItemPath itemPath, C2KLocalObject obj) throws PersistencyException { String path = ClusterStorage.getPath(obj); ArrayList writers = findStorages(ClusterStorage.getClusterType(path), true); for (ClusterStorage thisWriter : writers) { try { Logger.msg(7, "ClusterStorageManager.put() - writing "+path+" to "+thisWriter.getName()); thisWriter.put(itemPath, obj); - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error("ClusterStorageManager.put() - writer " + thisWriter.getName() + " could not store " + itemPath + "/" + path + ": " + e.getMessage()); throw e; @@ -317,13 +318,13 @@ public class ClusterStorageManager { } /** Deletes a cluster from all writers */ - public void remove(ItemPath itemPath, String path) throws ClusterStorageException { + public void remove(ItemPath itemPath, String path) throws PersistencyException { ArrayList writers = findStorages(ClusterStorage.getClusterType(path), true); for (ClusterStorage thisWriter : writers) { try { Logger.msg(7, "ClusterStorageManager.delete() - removing "+path+" from "+thisWriter.getName()); thisWriter.delete(itemPath, path); - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error("ClusterStorageManager.delete() - writer " + thisWriter.getName() + " could not delete " + itemPath + "/" + path + ": " + e.getMessage()); throw e; diff --git a/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java b/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java index 5717d85..7408da3 100644 --- a/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java @@ -25,6 +25,7 @@ import java.util.ConcurrentModificationException; import java.util.HashMap; import java.util.Map; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.lookup.ItemPath; import com.c2kernel.process.auth.Authenticator; @@ -41,12 +42,12 @@ public class MemoryOnlyClusterStorage extends ClusterStorage { } @Override - public void open(Authenticator auth) throws ClusterStorageException { + public void open(Authenticator auth) throws PersistencyException { } @Override - public void close() throws ClusterStorageException { + public void close() throws PersistencyException { } @Override @@ -66,7 +67,7 @@ public class MemoryOnlyClusterStorage extends ClusterStorage { @Override public C2KLocalObject get(ItemPath thisItem, String path) - throws ClusterStorageException { + throws PersistencyException { Map sysKeyMemCache = memoryCache.get(thisItem); if (sysKeyMemCache != null) return sysKeyMemCache.get(path); @@ -75,7 +76,7 @@ public class MemoryOnlyClusterStorage extends ClusterStorage { @Override public void put(ItemPath thisItem, C2KLocalObject obj) - throws ClusterStorageException { + throws PersistencyException { // create item cache if not present Map sysKeyMemCache; @@ -98,7 +99,7 @@ public class MemoryOnlyClusterStorage extends ClusterStorage { @Override public void delete(ItemPath thisItem, String path) - throws ClusterStorageException { + throws PersistencyException { Map sysKeyMemCache = memoryCache.get(thisItem); if (sysKeyMemCache != null) { synchronized (sysKeyMemCache) { @@ -116,7 +117,7 @@ public class MemoryOnlyClusterStorage extends ClusterStorage { @Override public String[] getClusterContents(ItemPath thisItem, String path) - throws ClusterStorageException { + throws PersistencyException { Map sysKeyMemCache = memoryCache.get(thisItem); ArrayList result = new ArrayList(); if (sysKeyMemCache != null) { diff --git a/src/main/java/com/c2kernel/persistency/ProxyLoader.java b/src/main/java/com/c2kernel/persistency/ProxyLoader.java index 26e43d7..f8704e3 100644 --- a/src/main/java/com/c2kernel/persistency/ProxyLoader.java +++ b/src/main/java/com/c2kernel/persistency/ProxyLoader.java @@ -22,7 +22,8 @@ package com.c2kernel.persistency; import java.util.HashMap; import java.util.StringTokenizer; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.AgentHelper; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.Item; @@ -43,12 +44,12 @@ public class ProxyLoader extends ClusterStorage { Lookup lookup; @Override - public void open(Authenticator auth) throws ClusterStorageException { + public void open(Authenticator auth) throws PersistencyException { lookup = Gateway.getLookup(); } @Override - public void close() throws ClusterStorageException { + public void close() throws PersistencyException { } // introspection @Override @@ -68,7 +69,7 @@ public class ProxyLoader extends ClusterStorage { // retrieve object by path @Override - public C2KLocalObject get(ItemPath thisItem, String path) throws ClusterStorageException { + public C2KLocalObject get(ItemPath thisItem, String path) throws PersistencyException { try { Item thisEntity = getIOR(thisItem); String type = getClusterType(path); @@ -83,33 +84,33 @@ public class ProxyLoader extends ClusterStorage { else return (C2KLocalObject)Gateway.getMarshaller().unmarshall(queryData); } - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { return null; } catch (Exception e) { Logger.error(e); - throw new ClusterStorageException(e.getMessage()); + throw new PersistencyException(e.getMessage()); } return null; } // store object by path @Override - public void put(ItemPath thisItem, C2KLocalObject obj) throws ClusterStorageException { + public void put(ItemPath thisItem, C2KLocalObject obj) throws PersistencyException { // not supported - throw new ClusterStorageException("Cannot write to items through the ProxyLoader"); + throw new PersistencyException("Cannot write to items through the ProxyLoader"); } // delete cluster @Override - public void delete(ItemPath thisItem, String path) throws ClusterStorageException { + public void delete(ItemPath thisItem, String path) throws PersistencyException { // not supported - throw new ClusterStorageException("Cannot write to items through the ProxyLoader"); + throw new PersistencyException("Cannot write to items through the ProxyLoader"); } /* navigation */ // directory listing @Override - public String[] getClusterContents(ItemPath thisItem, String path) throws ClusterStorageException { + public String[] getClusterContents(ItemPath thisItem, String path) throws PersistencyException { try { Item thisEntity = getIOR(thisItem); String contents = thisEntity.queryData(path+"/all"); @@ -121,11 +122,11 @@ public class ProxyLoader extends ClusterStorage { return result; } catch (Exception e) { Logger.error(e); - throw new ClusterStorageException(e.getMessage()); + throw new PersistencyException(e.getMessage()); } } - private Item getIOR(ItemPath thisPath) throws ClusterStorageException { + private Item getIOR(ItemPath thisPath) throws PersistencyException { if (entities.containsKey(thisPath)) { // check the cache Logger.msg(7, "ProxyLoader.getIOR() - "+thisPath+" cached."); @@ -143,7 +144,7 @@ public class ProxyLoader extends ClusterStorage { try { thisItem = AgentHelper.narrow(ior); } catch (org.omg.CORBA.BAD_PARAM ex2) { - throw new ClusterStorageException ("Could not narrow "+thisItem+" as a known Entity type"); + throw new PersistencyException ("Could not narrow "+thisItem+" as a known Entity type"); } } @@ -151,7 +152,7 @@ public class ProxyLoader extends ClusterStorage { entities.put(thisPath, thisItem); return thisItem; } catch (Exception e) { - throw new ClusterStorageException("Error narrowing "+thisPath+": "+e.getMessage()); + throw new PersistencyException("Error narrowing "+thisPath+": "+e.getMessage()); } } } diff --git a/src/main/java/com/c2kernel/persistency/RemoteMap.java b/src/main/java/com/c2kernel/persistency/RemoteMap.java index c11ceab..b1a1e51 100644 --- a/src/main/java/com/c2kernel/persistency/RemoteMap.java +++ b/src/main/java/com/c2kernel/persistency/RemoteMap.java @@ -27,7 +27,8 @@ import java.util.Iterator; import java.util.Set; import java.util.TreeMap; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.proxy.ItemProxy; import com.c2kernel.entity.proxy.MemberSubscription; @@ -125,7 +126,7 @@ public class RemoteMap extends TreeMap impl try { keys = storage.getClusterContents(mItemPath, mPath+mName); for (String key : keys) super.put(key, null); - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error(e); } @@ -222,9 +223,9 @@ public class RemoteMap extends TreeMap impl super.put(key, value); } return value; - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error(e); - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { Logger.error(e); } } @@ -261,7 +262,7 @@ public class RemoteMap extends TreeMap impl storage.put(mItemPath, value, mLocker); return putLocal(key, value); } - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error(e); return null; } @@ -282,7 +283,7 @@ public class RemoteMap extends TreeMap impl storage.remove(mItemPath, mPath+mName+"/"+key, mLocker); return super.remove(key); } - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error(e); } return null; diff --git a/src/main/java/com/c2kernel/persistency/TransactionManager.java b/src/main/java/com/c2kernel/persistency/TransactionManager.java index 9f2dac4..792709a 100644 --- a/src/main/java/com/c2kernel/persistency/TransactionManager.java +++ b/src/main/java/com/c2kernel/persistency/TransactionManager.java @@ -23,7 +23,8 @@ package com.c2kernel.persistency; import java.util.ArrayList; import java.util.HashMap; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.agent.JobList; import com.c2kernel.events.History; @@ -37,7 +38,7 @@ public class TransactionManager { HashMap> pendingTransactions; ClusterStorageManager storage; - public TransactionManager(Authenticator auth) throws ClusterStorageException { + public TransactionManager(Authenticator auth) throws PersistencyException { storage = new ClusterStorageManager(auth); locks = new HashMap(); pendingTransactions = new HashMap>(); @@ -61,7 +62,7 @@ public class TransactionManager { storage.close(); } - public String[] getClusterContents(ItemPath itemPath, String path) throws ClusterStorageException { + public String[] getClusterContents(ItemPath itemPath, String path) throws PersistencyException { if (path.startsWith("/") && path.length() > 1) path = path.substring(1); return storage.getClusterContents(itemPath, path); } @@ -71,8 +72,8 @@ public class TransactionManager { * Checks the transaction table first to see if the caller has uncommitted changes */ public C2KLocalObject get(ItemPath itemPath, String path, Object locker) - throws ClusterStorageException, - ObjectNotFoundException { + throws PersistencyException, + ObjectNotFound { if (path.startsWith("/") && path.length() > 1) path = path.substring(1); // deal out top level remote maps, if transactions aren't needed @@ -89,7 +90,7 @@ public class TransactionManager { for (TransactionEntry thisEntry : lockerTransaction) { if (itemPath.equals(thisEntry.itemPath) && path.equals(thisEntry.path)) { if (thisEntry.obj == null) - throw new ClusterStorageException("ClusterStorageManager.get() - Cluster " + path + " has been deleted in " + itemPath + + throw new PersistencyException("ClusterStorageManager.get() - Cluster " + path + " has been deleted in " + itemPath + " but not yet committed"); return thisEntry.obj; } @@ -102,7 +103,7 @@ public class TransactionManager { * Public put method. Manages the transaction table keyed by the object 'locker'. * If this object is null, transaction support is bypassed (so long as no lock exists on that object). */ - public void put(ItemPath itemPath, C2KLocalObject obj, Object locker) throws ClusterStorageException { + public void put(ItemPath itemPath, C2KLocalObject obj, Object locker) throws PersistencyException { Object tempLocker = null; ArrayList lockerTransaction; @@ -114,7 +115,7 @@ public class TransactionManager { if (thisLocker.equals(locker)) // retrieve the transaction list lockerTransaction = pendingTransactions.get(locker); else // locked by someone else - throw new ClusterStorageException("ClusterStorageManager.get() - Access denied: Object " + itemPath + + throw new PersistencyException("ClusterStorageManager.get() - Access denied: Object " + itemPath + " has been locked for writing by " + thisLocker); } else { // no locks for this item @@ -150,7 +151,7 @@ public class TransactionManager { /** Public delete method. Uses the put method, with null as the object value. */ - public void remove(ItemPath itemPath, String path, Object locker) throws ClusterStorageException { + public void remove(ItemPath itemPath, String path, Object locker) throws PersistencyException { ArrayList lockerTransaction; Object tempLocker = null; synchronized(locks) { @@ -161,7 +162,7 @@ public class TransactionManager { if (thisLocker.equals(locker)) // retrieve the transaction list lockerTransaction = pendingTransactions.get(locker); else // locked by someone else - throw new ClusterStorageException("ClusterStorageManager.get() - Access denied: Object " + itemPath + + throw new PersistencyException("ClusterStorageManager.get() - Access denied: Object " + itemPath + " has been locked for writing by " + thisLocker); } else { // either we are the locker, or there is no locker @@ -203,9 +204,9 @@ public class TransactionManager { * @param path - root path to delete * @param locker - locking object * - * @throws ClusterStorageException - when deleting fails + * @throws PersistencyException - when deleting fails */ - public void removeCluster(ItemPath itemPath, String path, Object locker) throws ClusterStorageException { + public void removeCluster(ItemPath itemPath, String path, Object locker) throws PersistencyException { String[] children = getClusterContents(itemPath, path); for (String element : children) diff --git a/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java b/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java index 8f1ed02..4a250e5 100644 --- a/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java @@ -22,6 +22,7 @@ package com.c2kernel.persistency; import java.io.File; import java.util.ArrayList; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.lookup.InvalidItemPathException; import com.c2kernel.lookup.ItemPath; @@ -38,17 +39,17 @@ public class XMLClusterStorage extends ClusterStorage { } @Override - public void open(Authenticator auth) throws ClusterStorageException { + public void open(Authenticator auth) throws PersistencyException { String rootProp = Gateway.getProperties().getString("XMLStorage.root"); if (rootProp == null) - throw new ClusterStorageException("XMLClusterStorage.open() - Root path not given in config file."); + throw new PersistencyException("XMLClusterStorage.open() - Root path not given in config file."); rootDir = new File(rootProp).getAbsolutePath(); if( !FileStringUtility.checkDir( rootDir ) ) { Logger.error("XMLClusterStorage.open() - Path " + rootDir + "' does not exist. Attempting to create."); boolean success = FileStringUtility.createNewDir(rootDir); - if (!success) throw new ClusterStorageException("XMLClusterStorage.open() - Could not create dir "+ rootDir +". Cannot continue."); + if (!success) throw new PersistencyException("XMLClusterStorage.open() - Could not create dir "+ rootDir +". Cannot continue."); } } @@ -77,7 +78,7 @@ public class XMLClusterStorage extends ClusterStorage { // retrieve object by path @Override - public C2KLocalObject get(ItemPath itemPath, String path) throws ClusterStorageException { + public C2KLocalObject get(ItemPath itemPath, String path) throws PersistencyException { try { String type = ClusterStorage.getClusterType(path); String filePath = getFilePath(itemPath, path)+".xml"; @@ -99,7 +100,7 @@ public class XMLClusterStorage extends ClusterStorage { // store object by path @Override - public void put(ItemPath itemPath, C2KLocalObject obj) throws ClusterStorageException { + public void put(ItemPath itemPath, C2KLocalObject obj) throws PersistencyException { try { String filePath = getFilePath(itemPath, getPath(obj)+".xml"); Logger.msg(7, "Writing "+filePath); @@ -108,18 +109,18 @@ public class XMLClusterStorage extends ClusterStorage { String dir = filePath.substring(0, filePath.lastIndexOf('/')); if( !FileStringUtility.checkDir( dir ) ) { boolean success = FileStringUtility.createNewDir(dir); - if (!success) throw new ClusterStorageException("XMLClusterStorage.put() - Could not create dir "+ dir +". Cannot continue."); + if (!success) throw new PersistencyException("XMLClusterStorage.put() - Could not create dir "+ dir +". Cannot continue."); } FileStringUtility.string2File(filePath, data); } catch (Exception e) { Logger.error(e); - throw new ClusterStorageException("XMLClusterStorage.put() - Could not write "+getPath(obj)+" to "+itemPath); + throw new PersistencyException("XMLClusterStorage.put() - Could not write "+getPath(obj)+" to "+itemPath); } } // delete cluster @Override - public void delete(ItemPath itemPath, String path) throws ClusterStorageException { + public void delete(ItemPath itemPath, String path) throws PersistencyException { try { String filePath = getFilePath(itemPath, path+".xml"); boolean success = FileStringUtility.deleteDir(filePath, true, true); @@ -128,14 +129,14 @@ public class XMLClusterStorage extends ClusterStorage { success = FileStringUtility.deleteDir(filePath, true, true); if (success) return; } catch(Exception e) { } - throw new ClusterStorageException("XMLClusterStorage.delete() - Failure deleting path "+path+" in "+itemPath); + throw new PersistencyException("XMLClusterStorage.delete() - Failure deleting path "+path+" in "+itemPath); } /* navigation */ // directory listing @Override - public String[] getClusterContents(ItemPath itemPath, String path) throws ClusterStorageException { + public String[] getClusterContents(ItemPath itemPath, String path) throws PersistencyException { String[] result = new String[0]; try { String filePath = getFilePath(itemPath, path); @@ -162,7 +163,7 @@ public class XMLClusterStorage extends ClusterStorage { return result; } catch (Exception e) { Logger.error(e); - throw new ClusterStorageException("XMLClusterStorage.getClusterContents() - Could not get contents of "+path+" from "+itemPath+": "+e.getMessage()); + throw new PersistencyException("XMLClusterStorage.getClusterContents() - Could not get contents of "+path+" from "+itemPath+": "+e.getMessage()); } } diff --git a/src/main/java/com/c2kernel/persistency/outcome/Outcome.java b/src/main/java/com/c2kernel/persistency/outcome/Outcome.java index 8dbe94e..ac2d970 100644 --- a/src/main/java/com/c2kernel/persistency/outcome/Outcome.java +++ b/src/main/java/com/c2kernel/persistency/outcome/Outcome.java @@ -40,8 +40,8 @@ import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSSerializer; import org.xml.sax.InputSource; -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.persistency.ClusterStorage; @@ -95,14 +95,14 @@ public class Outcome implements C2KLocalObject { // derive all the meta data from the path StringTokenizer tok = new StringTokenizer(path,"/"); if (tok.countTokens() != 3 && !(tok.nextToken().equals(ClusterStorage.OUTCOME))) - throw new PersistencyException("Outcome() - Outcome path must have three components: "+path, null); + throw new PersistencyException("Outcome() - Outcome path must have three components: "+path); mSchemaType = tok.nextToken(); String verstring = tok.nextToken(); String objId = tok.nextToken(); try { mSchemaVersion = Integer.parseInt(verstring); } catch (NumberFormatException ex) { - throw new PersistencyException("Outcome() - Outcome version was an invalid number: "+verstring, null); + throw new PersistencyException("Outcome() - Outcome version was an invalid number: "+verstring); } try { mID = new Integer(objId); @@ -144,10 +144,10 @@ public class Outcome implements C2KLocalObject { mData = null; } - public String getFieldByXPath(String xpath) throws XPathExpressionException, InvalidDataException { + public String getFieldByXPath(String xpath) throws XPathExpressionException, InvalidData { Node field = getNodeByXPath(xpath); if (field == null) - throw new InvalidDataException(xpath, ""); + throw new InvalidData(xpath); else if (field.getNodeType()==Node.TEXT_NODE || field.getNodeType()==Node.CDATA_SECTION_NODE) return field.getNodeValue(); @@ -155,28 +155,28 @@ public class Outcome implements C2KLocalObject { else if (field.getNodeType()==Node.ELEMENT_NODE) { NodeList fieldChildren = field.getChildNodes(); if (fieldChildren.getLength() == 0) - throw new InvalidDataException("No child node for element", ""); + throw new InvalidData("No child node for element"); else if (fieldChildren.getLength() == 1) { Node child = fieldChildren.item(0); if (child.getNodeType()==Node.TEXT_NODE || child.getNodeType()==Node.CDATA_SECTION_NODE) return child.getNodeValue(); else - throw new InvalidDataException("Can't get data from child node of type "+child.getNodeName(), ""); + throw new InvalidData("Can't get data from child node of type "+child.getNodeName()); } else - throw new InvalidDataException("Element "+xpath+" has too many children", ""); + throw new InvalidData("Element "+xpath+" has too many children"); } else if (field.getNodeType()==Node.ATTRIBUTE_NODE) return field.getNodeValue(); else - throw new InvalidDataException("Don't know what to do with node "+field.getNodeName(), ""); + throw new InvalidData("Don't know what to do with node "+field.getNodeName()); } - public void setFieldByXPath(String xpath, String data) throws XPathExpressionException, InvalidDataException { + public void setFieldByXPath(String xpath, String data) throws XPathExpressionException, InvalidData { Node field = getNodeByXPath(xpath); if (field == null) - throw new InvalidDataException(xpath, ""); + throw new InvalidData(xpath); else if (field.getNodeType()==Node.ELEMENT_NODE) { NodeList fieldChildren = field.getChildNodes(); @@ -191,16 +191,16 @@ public class Outcome implements C2KLocalObject { child.setNodeValue(data); break; default: - throw new InvalidDataException("Can't set child node of type "+child.getNodeName(), ""); + throw new InvalidData("Can't set child node of type "+child.getNodeName()); } } else - throw new InvalidDataException("Element "+xpath+" has too many children", ""); + throw new InvalidData("Element "+xpath+" has too many children"); } else if (field.getNodeType()==Node.ATTRIBUTE_NODE) field.setNodeValue(data); else - throw new InvalidDataException("Don't know what to do with node "+field.getNodeName(), ""); + throw new InvalidData("Don't know what to do with node "+field.getNodeName()); } @@ -211,7 +211,7 @@ public class Outcome implements C2KLocalObject { return mData; } - public Schema getSchema() throws ObjectNotFoundException { + public Schema getSchema() throws ObjectNotFound { return LocalObjectLoader.getSchema(mSchemaType, mSchemaVersion); } diff --git a/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java b/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java index e152df9..2c4427e 100644 --- a/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java +++ b/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java @@ -20,11 +20,11 @@ */ package com.c2kernel.persistency.outcome; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.entity.agent.Job; public interface OutcomeInitiator { - public String initOutcome(Job job) throws InvalidDataException; + public String initOutcome(Job job) throws InvalidData; } diff --git a/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java b/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java index defac3a..d89f7e7 100644 --- a/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java +++ b/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java @@ -38,7 +38,7 @@ import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.utils.Logger; /************************************************************************** @@ -69,7 +69,7 @@ public class OutcomeValidator implements ErrorHandler, XMLErrorHandler { XMLGrammarPoolImpl schemaGrammarPool = new XMLGrammarPoolImpl(1); SymbolTable sym = new SymbolTable(); - public static OutcomeValidator getValidator(Schema schema) throws InvalidDataException { + public static OutcomeValidator getValidator(Schema schema) throws InvalidData { if (schema.docType.equals("Schema") && schema.docVersion==0) @@ -82,11 +82,11 @@ public class OutcomeValidator implements ErrorHandler, XMLErrorHandler { errors = new StringBuffer(); } - public OutcomeValidator(Schema schema) throws InvalidDataException { + public OutcomeValidator(Schema schema) throws InvalidData { this.schema = schema; if (schema.docType.equals("Schema")) - throw new InvalidDataException("Use SchemaValidator to validate schema", ""); + throw new InvalidData("Use SchemaValidator to validate schema"); errors = new StringBuffer(); Logger.msg(5, "Parsing "+schema.docType+" version "+schema.docVersion+". "+schema.schema.length()+" chars"); @@ -103,11 +103,11 @@ public class OutcomeValidator implements ErrorHandler, XMLErrorHandler { try { preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, new XMLInputSource(null, null, null, new StringReader(schema.schema), null)); } catch (IOException ex) { - throw new InvalidDataException("Error parsing schema: "+ex.getMessage(), ""); + throw new InvalidData("Error parsing schema: "+ex.getMessage()); } if (errors.length() > 0) { - throw new InvalidDataException("Schema error: \n"+errors.toString(), ""); + throw new InvalidData("Schema error: \n"+errors.toString()); } } diff --git a/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java b/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java index 2a5118f..151bf65 100644 --- a/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java +++ b/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java @@ -20,14 +20,14 @@ */ package com.c2kernel.persistency.outcome; -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.events.Event; import com.c2kernel.lookup.InvalidItemPathException; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.process.Gateway; /** @@ -70,8 +70,8 @@ public class Viewpoint implements C2KLocalObject { this.eventId = eventId; } - public Outcome getOutcome() throws ObjectNotFoundException, ClusterStorageException { - if (eventId == NONE) throw new ObjectNotFoundException("No last eventId defined", ""); + public Outcome getOutcome() throws ObjectNotFound, PersistencyException { + if (eventId == NONE) throw new ObjectNotFound("No last eventId defined"); Outcome retVal = (Outcome)Gateway.getStorage().get(itemPath, ClusterStorage.OUTCOME+"/"+schemaName+"/"+schemaVersion+"/"+eventId, null); return retVal; } @@ -194,10 +194,10 @@ public class Viewpoint implements C2KLocalObject { * @return GDataRecord */ public Event getEvent() - throws InvalidDataException, ClusterStorageException, ObjectNotFoundException + throws InvalidData, PersistencyException, ObjectNotFound { if (eventId == NONE) - throw new InvalidDataException("No last eventId defined", ""); + throw new InvalidData("No last eventId defined"); return (Event)Gateway.getStorage().get(itemPath, ClusterStorage.HISTORY+"/"+eventId, null); } diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index 6f70867..eebdc47 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -30,8 +30,8 @@ import java.util.UUID; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.XMLUnit; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.proxy.AgentProxy; import com.c2kernel.entity.proxy.ItemProxy; import com.c2kernel.events.Event; @@ -176,7 +176,7 @@ public class Bootstrap Logger.error("Bootstrap.verifyResource() - Module clash! Resource '"+itemName+"' included in module "+moduleName+" but is assigned to '"+itemModule+"'. Not overwriting."); return path; } - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { itemModule = ""; } @@ -214,7 +214,7 @@ public class Bootstrap } } - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { Logger.msg("Bootstrap.verifyResource() - Item "+itemName+" exists but version "+version+" not found! Attempting to insert new."); } @@ -225,7 +225,7 @@ public class Bootstrap String error = validator.validate(newOutcome.getData()); if (error.length() > 0) { Logger.error("Outcome not valid: \n " + error); - throw new InvalidDataException(error, ""); + throw new InvalidData(error); } } @@ -287,7 +287,7 @@ public class Bootstrap if (ns!=null && Gateway.getProperties().getBoolean("Module.debug", false)) try { ca = (CompositeActivity) ((CompositeActivityDef)LocalObjectLoader.getActDef(impHandler.getWorkflowName(), 0)).instantiate(); - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { Logger.error("Module resource workflow "+impHandler.getWorkflowName()+" not found. Using empty."); } @@ -313,7 +313,7 @@ public class Bootstrap systemAgents.put(name, Gateway.getProxyManager().getAgentProxy(lookup.getAgentPath(name))); Logger.msg(3, "Bootstrap.checkAgent() - User '"+name+"' found."); return; - } catch (ObjectNotFoundException ex) { } + } catch (ObjectNotFound ex) { } Logger.msg("Bootstrap.checkAgent() - User '"+name+"' not found. Creating."); @@ -365,7 +365,7 @@ public class Bootstrap ItemPath serverEntity; try { serverEntity = thisServerPath.getItemPath(); - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { Logger.msg("Creating server item "+thisServerPath); serverEntity = new ItemPath(); Gateway.getCorbaServer().createItem(serverEntity); diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 50075c0..25f5d9a 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -29,9 +29,10 @@ import java.net.MalformedURLException; import java.util.Enumeration; import java.util.Properties; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.CorbaServer; import com.c2kernel.entity.proxy.AgentProxy; import com.c2kernel.entity.proxy.ProxyManager; @@ -39,7 +40,6 @@ import com.c2kernel.entity.proxy.ProxyServer; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.Lookup; import com.c2kernel.lookup.LookupManager; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.TransactionManager; import com.c2kernel.process.auth.Authenticator; import com.c2kernel.process.module.ModuleManager; @@ -97,9 +97,9 @@ public class Gateway * * @param props - java.util.Properties containing all application properties. * If null, the java system properties are used - * @throws InvalidDataException - invalid properties caused a failure in initialisation + * @throws InvalidData - invalid properties caused a failure in initialisation */ - static public void init(Properties props) throws InvalidDataException { + static public void init(Properties props) throws InvalidData { init(props, null); } @@ -111,9 +111,9 @@ public class Gateway * If null, the java system properties are used * @param res - ResourceLoader for the kernel to use to resolve all class resource requests * such as for bootstrap descriptions and version information - * @throws InvalidDataException - invalid properties caused a failure in initialisation + * @throws InvalidData - invalid properties caused a failure in initialisation */ - static public void init(Properties props, ResourceLoader res) throws InvalidDataException { + static public void init(Properties props, ResourceLoader res) throws InvalidData { // Init properties & resources mC2KProps.clear(); @@ -130,7 +130,7 @@ public class Gateway try { mMarshaller = new CastorXMLUtility(mResource, props, mResource.getKernelResourceURL("mapFiles/")); } catch (MalformedURLException e1) { - throw new InvalidDataException("Invalid Resource Location", ""); + throw new InvalidData("Invalid Resource Location"); } @@ -139,7 +139,7 @@ public class Gateway mModules = new ModuleManager(mResource.getModuleDefURLs(), AbstractMain.isServer); } catch (Exception e) { Logger.error(e); - throw new InvalidDataException("Could not load module definitions.", ""); + throw new InvalidData("Could not load module definitions."); } // merge in module props @@ -168,9 +168,9 @@ public class Gateway * bootstrap to create the root LDAP contexts, initialises the CORBA server and * time-out manager. * - * @throws InvalidDataException - error initialising + * @throws InvalidData - error initialising */ - static public void startServer(Authenticator auth) throws InvalidDataException, CannotManageException { + static public void startServer(Authenticator auth) throws InvalidData, CannotManage { try { // check top level directory contexts if (mLookup instanceof LookupManager) { @@ -178,7 +178,7 @@ public class Gateway mLookupManager.initializeDirectory(); } else { - throw new CannotManageException("Lookup implementation is not a LookupManager. Cannot write to directory"); + throw new CannotManage("Lookup implementation is not a LookupManager. Cannot write to directory"); } // start entity proxy server @@ -222,12 +222,12 @@ public class Gateway * Connects to the LDAP server in an administrative context - using the admin username and * password given in the LDAP.user and LDAP.password props of the kernel properties. * - * @throws InvalidDataException - bad params - * @throws ClusterStorageException - error starting storages + * @throws InvalidData - bad params + * @throws PersistencyException - error starting storages */ static public Authenticator connect() - throws InvalidDataException, - ClusterStorageException + throws InvalidData, + PersistencyException { try { Authenticator auth = (Authenticator)mC2KProps.getInstance("Authenticator"); @@ -242,7 +242,7 @@ public class Gateway return auth; } catch (Exception ex) { Logger.error(ex); - throw new InvalidDataException("Cannot connect server process. Please check config.", ""); + throw new InvalidData("Cannot connect server process. Please check config."); } @@ -254,18 +254,18 @@ public class Gateway * @param agentName - username * @param agentPassword - password * @return an AgentProxy on the requested user - * @throws InvalidDataException - * @throws ClusterStorageException + * @throws InvalidData + * @throws PersistencyException * @throws ClassNotFoundException * @throws IllegalAccessException * @throws InstantiationException */ static public AgentProxy connect(String agentName, String agentPassword, String resource) - throws InvalidDataException, ObjectNotFoundException, ClusterStorageException, InstantiationException, IllegalAccessException, ClassNotFoundException + throws InvalidData, ObjectNotFound, PersistencyException, InstantiationException, IllegalAccessException, ClassNotFoundException { Authenticator auth = (Authenticator)mC2KProps.getInstance("Authenticator"); if (!auth.authenticate(agentName, agentPassword, resource)) - throw new InvalidDataException("Login failed", ""); + throw new InvalidData("Login failed"); mLookup = (Lookup)mC2KProps.getInstance("Lookup"); mLookup.open(auth); @@ -286,7 +286,7 @@ public class Gateway } static public AgentProxy connect(String agentName, String agentPassword) - throws InvalidDataException, ObjectNotFoundException, ClusterStorageException, InstantiationException, IllegalAccessException, ClassNotFoundException + throws InvalidData, ObjectNotFound, PersistencyException, InstantiationException, IllegalAccessException, ClassNotFoundException { return connect(agentName, agentPassword, null); } @@ -358,10 +358,10 @@ public class Gateway return mLookup; } - static public LookupManager getLookupManager() throws CannotManageException + static public LookupManager getLookupManager() throws CannotManage { if (mLookupManager == null) - throw new CannotManageException("No Lookup Manager created. Not a server process.", ""); + throw new CannotManage("No Lookup Manager created. Not a server process."); else return mLookupManager; } diff --git a/src/main/java/com/c2kernel/process/UserCodeProcess.java b/src/main/java/com/c2kernel/process/UserCodeProcess.java index bc7e23e..4a4d7f4 100644 --- a/src/main/java/com/c2kernel/process/UserCodeProcess.java +++ b/src/main/java/com/c2kernel/process/UserCodeProcess.java @@ -25,7 +25,7 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.HashMap; -import com.c2kernel.common.InvalidTransitionException; +import com.c2kernel.common.InvalidTransition; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.agent.Job; import com.c2kernel.entity.proxy.AgentProxy; @@ -139,7 +139,7 @@ public class UserCodeProcess extends StandardClient implements ProxyObserver moduleBaseURLs = new HashMap(); private final HashMap allBaseURLs = new HashMap(); - public Resource() throws InvalidDataException { + public Resource() throws InvalidData { baseURL = getURLorResURL("com/c2kernel/utils/resources/"); allBaseURLs.put(null, baseURL); } @@ -89,7 +89,7 @@ public class Resource implements ResourceLoader { * @see com.c2kernel.utils.ResourceLoader#addModuleBaseURL(java.lang.String, java.lang.String) */ @Override - public void addModuleBaseURL(String ns, String newBaseURL) throws InvalidDataException { + public void addModuleBaseURL(String ns, String newBaseURL) throws InvalidData { addModuleBaseURL(ns, getURLorResURL(newBaseURL)); } @@ -113,7 +113,7 @@ public class Resource implements ResourceLoader { return new URL(moduleBaseURLs.get(ns), resName); } - static private URL getURLorResURL(String newURL) throws InvalidDataException { + static private URL getURLorResURL(String newURL) throws InvalidData { URL result; try { result = new URL(newURL); @@ -124,7 +124,7 @@ public class Resource implements ResourceLoader { } if (result == null) { Logger.error("URL "+newURL+" could not be found"); - throw new InvalidDataException(); + throw new InvalidData(); } return result; } @@ -137,7 +137,7 @@ public class Resource implements ResourceLoader { for (String ns : getAllBaseURLs().keySet()) { try { return getTextResource(ns, resName); - } catch (ObjectNotFoundException ex) { } + } catch (ObjectNotFound ex) { } } Logger.warning("Text resource '"+resName+"' not found."); return null; @@ -152,7 +152,7 @@ public class Resource implements ResourceLoader { for (String ns : getAllBaseURLs().keySet()) { try { results.put(ns, getTextResource(ns, resName)); - } catch (ObjectNotFoundException ex) { } + } catch (ObjectNotFound ex) { } } return results; } @@ -161,7 +161,7 @@ public class Resource implements ResourceLoader { * @see com.c2kernel.utils.ResourceLoader#getTextResource(java.lang.String, java.lang.String) */ @Override - public String getTextResource(String ns, String resName) throws ObjectNotFoundException + public String getTextResource(String ns, String resName) throws ObjectNotFound // throws IOException { Logger.msg(8, "Resource::getTextResource() - Getting resource from "+ns+": " + resName); @@ -184,7 +184,7 @@ public class Resource implements ResourceLoader { txtCache.put(ns+'/'+resName, newRes); return newRes; } catch (Exception e) { - throw new ObjectNotFoundException(e.getMessage(),null); + throw new ObjectNotFound(e.getMessage()); } } diff --git a/src/main/java/com/c2kernel/process/resource/ResourceLoader.java b/src/main/java/com/c2kernel/process/resource/ResourceLoader.java index d05831a..ff5b489 100644 --- a/src/main/java/com/c2kernel/process/resource/ResourceLoader.java +++ b/src/main/java/com/c2kernel/process/resource/ResourceLoader.java @@ -25,8 +25,8 @@ import java.net.URL; import java.util.Enumeration; import java.util.HashMap; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; public interface ResourceLoader { @@ -38,7 +38,7 @@ public interface ResourceLoader { public void addModuleBaseURL(String ns, URL newBaseURL); public void addModuleBaseURL(String ns, String newBaseURL) - throws InvalidDataException; + throws InvalidData; public HashMap getModuleBaseURLs(); @@ -54,7 +54,7 @@ public interface ResourceLoader { public HashMap getAllTextResources(String resName); public String getTextResource(String ns, String resName) - throws ObjectNotFoundException; + throws ObjectNotFound; public Class getClassForName(String name) throws ClassNotFoundException; diff --git a/src/main/java/com/c2kernel/property/PropertyDescriptionList.java b/src/main/java/com/c2kernel/property/PropertyDescriptionList.java index a5c6d57..a4e226d 100644 --- a/src/main/java/com/c2kernel/property/PropertyDescriptionList.java +++ b/src/main/java/com/c2kernel/property/PropertyDescriptionList.java @@ -23,7 +23,7 @@ package com.c2kernel.property; import java.util.ArrayList; import java.util.HashMap; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.utils.CastorArrayList; public class PropertyDescriptionList extends CastorArrayList @@ -68,12 +68,12 @@ public class PropertyDescriptionList extends CastorArrayList validatedInitProps = new HashMap(); for (Property initProp : initProps.list) { if (!definesProperty(initProp.getName())) - throw new InvalidDataException("Property "+initProp.getName()+" has not been declared in the property descriptions", ""); + throw new InvalidData("Property "+initProp.getName()+" has not been declared in the property descriptions"); else validatedInitProps.put(initProp.getName(), initProp.getValue()); } diff --git a/src/main/java/com/c2kernel/property/PropertyUtility.java b/src/main/java/com/c2kernel/property/PropertyUtility.java index 02daf47..b345962 100644 --- a/src/main/java/com/c2kernel/property/PropertyUtility.java +++ b/src/main/java/com/c2kernel/property/PropertyUtility.java @@ -23,7 +23,7 @@ package com.c2kernel.property; import java.util.ArrayList; import java.util.Iterator; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.persistency.outcome.Outcome; @@ -66,7 +66,7 @@ public class PropertyUtility } - static public PropertyDescriptionList getPropertyDescriptionOutcome(ItemPath itemPath, String descVer) throws ObjectNotFoundException + static public PropertyDescriptionList getPropertyDescriptionOutcome(ItemPath itemPath, String descVer) throws ObjectNotFound { try { @@ -76,7 +76,7 @@ public class PropertyUtility catch (Exception ex) { Logger.error(ex); - throw new ObjectNotFoundException("Problem getting PropertyDescription from "+itemPath, ""); + throw new ObjectNotFound("Could not fetch PropertyDescription from "+itemPath); } } diff --git a/src/main/java/com/c2kernel/scripting/Script.java b/src/main/java/com/c2kernel/scripting/Script.java index 6ca1b9c..f9acd55 100644 --- a/src/main/java/com/c2kernel/scripting/Script.java +++ b/src/main/java/com/c2kernel/scripting/Script.java @@ -44,7 +44,7 @@ import org.w3c.dom.NodeList; import org.w3c.dom.Text; import org.xml.sax.InputSource; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.agent.Job; import com.c2kernel.entity.proxy.AgentProxy; import com.c2kernel.entity.proxy.ItemProxy; @@ -222,7 +222,7 @@ public class Script mVersion = scriptVersion; parseScriptXML(LocalObjectLoader.getScript(scriptName, scriptVersion)); } - catch (ObjectNotFoundException e) + catch (ObjectNotFound e) { throw new ScriptingEngineException("Script '"+scriptName+"' not found"); } diff --git a/src/main/java/com/c2kernel/utils/ActDefCache.java b/src/main/java/com/c2kernel/utils/ActDefCache.java index ec98c93..da171da 100644 --- a/src/main/java/com/c2kernel/utils/ActDefCache.java +++ b/src/main/java/com/c2kernel/utils/ActDefCache.java @@ -23,12 +23,12 @@ */ package com.c2kernel.utils; -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.proxy.ItemProxy; import com.c2kernel.lifecycle.ActivityDef; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.outcome.Viewpoint; import com.c2kernel.process.Gateway; @@ -41,23 +41,23 @@ public class ActDefCache extends DescriptionObjectCache { } @Override - public ActivityDef loadObject(String name, int version, ItemProxy proxy) throws ObjectNotFoundException, InvalidDataException { + public ActivityDef loadObject(String name, int version, ItemProxy proxy) throws ObjectNotFound, InvalidData { ActivityDef thisActDef; String actType = proxy.getProperty("Complexity"); Viewpoint actView = (Viewpoint)proxy.getObject(ClusterStorage.VIEWPOINT + "/" + actType + "ActivityDef/" + version); String marshalledAct; try { marshalledAct = actView.getOutcome().getData(); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); - throw new ObjectNotFoundException("Problem loading "+name+" v"+version+": "+ex.getMessage(), ""); + throw new ObjectNotFound("Problem loading "+name+" v"+version+": "+ex.getMessage()); } try { thisActDef = (ActivityDef)Gateway.getMarshaller().unmarshall(marshalledAct); thisActDef.getProperties().put("Version", version); } catch (Exception ex) { Logger.error(ex); - throw new InvalidDataException("Could not unmarshall '"+name+"' v"+version+": "+ex.getMessage(), ""); + throw new InvalidData("Could not unmarshall '"+name+"' v"+version+": "+ex.getMessage()); } thisActDef.setName(name); thisActDef.setVersion(version); diff --git a/src/main/java/com/c2kernel/utils/CastorXMLUtility.java b/src/main/java/com/c2kernel/utils/CastorXMLUtility.java index 1596a63..81a8e64 100644 --- a/src/main/java/com/c2kernel/utils/CastorXMLUtility.java +++ b/src/main/java/com/c2kernel/utils/CastorXMLUtility.java @@ -38,7 +38,7 @@ import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; import org.exolab.castor.xml.XMLContext; -import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.InvalidData; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.process.resource.ResourceLoader; @@ -66,11 +66,11 @@ public class CastorXMLUtility * configuration * @param mapURL * the root URL for the mapfiles - * @throws InvalidDataException + * @throws InvalidData */ public CastorXMLUtility(final ResourceLoader aResourceLoader, final Properties aAppProperties, final URL mapURL) - throws InvalidDataException { + throws InvalidData { // load index @@ -79,7 +79,7 @@ public class CastorXMLUtility try { index = FileStringUtility.url2String( new URL(mapURL, "index") ); } catch (Exception e) { - throw new InvalidDataException(String.format("Could not load map index from [%s]",mapURL)); + throw new InvalidData(String.format("Could not load map index from [%s]",mapURL)); } // retrieve the class loader of the class "CastorXMLUtility" @@ -135,13 +135,13 @@ public class CastorXMLUtility mappingContext.addMapping(thisMapping); } catch (MappingException ex) { Logger.error(ex); - throw new InvalidDataException("XML Mapping files are not valid: "+ex.getMessage(), ""); + throw new InvalidData("XML Mapping files are not valid: "+ex.getMessage()); } catch (MalformedURLException ex) { Logger.error(ex); - throw new InvalidDataException("Mapping file location invalid: "+ex.getMessage(), ""); + throw new InvalidData("Mapping file location invalid: "+ex.getMessage()); } catch (IOException ex) { Logger.error(ex); - throw new InvalidDataException("Could not read XML mapping files: "+ex.getMessage(), ""); + throw new InvalidData("Could not read XML mapping files: "+ex.getMessage()); } Logger.msg(1, String.format("Loaded [%d] maps from [%s]", loadedMapURLs.size(), mapURL)); diff --git a/src/main/java/com/c2kernel/utils/DescriptionObjectCache.java b/src/main/java/com/c2kernel/utils/DescriptionObjectCache.java index d3eb5ec..88a060d 100644 --- a/src/main/java/com/c2kernel/utils/DescriptionObjectCache.java +++ b/src/main/java/com/c2kernel/utils/DescriptionObjectCache.java @@ -23,8 +23,8 @@ */ package com.c2kernel.utils; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.proxy.ProxyObserver; import com.c2kernel.entity.proxy.ItemProxy; import com.c2kernel.entity.proxy.MemberSubscription; @@ -35,7 +35,7 @@ public abstract class DescriptionObjectCache { SoftCache> cache = new SoftCache>(); - public D get(String name, int version) throws ObjectNotFoundException, InvalidDataException { + public D get(String name, int version) throws ObjectNotFound, InvalidData { D thisDef; synchronized(cache) { CacheEntry thisDefEntry = cache.get(name+"_"+version); @@ -55,7 +55,7 @@ public abstract class DescriptionObjectCache { public abstract String getDefRoot(); - public abstract D loadObject(String name, int version, ItemProxy proxy) throws ObjectNotFoundException, InvalidDataException; + public abstract D loadObject(String name, int version, ItemProxy proxy) throws ObjectNotFound, InvalidData; public void removeObject(String id) { synchronized(cache) { diff --git a/src/main/java/com/c2kernel/utils/LocalObjectLoader.java b/src/main/java/com/c2kernel/utils/LocalObjectLoader.java index 445f5cd..434c24d 100644 --- a/src/main/java/com/c2kernel/utils/LocalObjectLoader.java +++ b/src/main/java/com/c2kernel/utils/LocalObjectLoader.java @@ -22,15 +22,15 @@ package com.c2kernel.utils; 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.common.PersistencyException; import com.c2kernel.entity.proxy.ItemProxy; import com.c2kernel.lifecycle.ActivityDef; import com.c2kernel.lifecycle.instance.stateMachine.StateMachine; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.Path; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.outcome.Schema; import com.c2kernel.persistency.outcome.Viewpoint; import com.c2kernel.process.Gateway; @@ -40,35 +40,35 @@ public class LocalObjectLoader { private static StateMachineCache smCache = new StateMachineCache(); static public ItemProxy loadLocalObjectDef(String root, String name) - throws ObjectNotFoundException + throws ObjectNotFound { DomainPath defRoot = new DomainPath(root); Iterator e = Gateway.getLookup().search(defRoot, name); if (e.hasNext()) { DomainPath defPath = (DomainPath)e.next(); - if (e.hasNext()) throw new ObjectNotFoundException("Too many matches for "+name+" in "+root, ""); + if (e.hasNext()) throw new ObjectNotFound("Too many matches for "+name+" in "+root); return Gateway.getProxyManager().getProxy(defPath); } else { - throw new ObjectNotFoundException("No match for "+name+" in "+root, ""); + throw new ObjectNotFound("No match for "+name+" in "+root); } } - static public String getScript(String scriptName, int scriptVersion) throws ObjectNotFoundException { + static public String getScript(String scriptName, int scriptVersion) throws ObjectNotFound { Logger.msg(5, "Loading script "+scriptName+" v"+scriptVersion); try { ItemProxy script = loadLocalObjectDef("/desc/Script/", scriptName); Viewpoint scriptView = (Viewpoint)script.getObject(ClusterStorage.VIEWPOINT + "/Script/" + scriptVersion); return scriptView.getOutcome().getData(); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); - throw new ObjectNotFoundException("Error loading script " + scriptName + " version " + scriptVersion, ""); + throw new ObjectNotFound("Error loading script " + scriptName + " version " + scriptVersion); } } - static public Schema getSchema(String schemaName, int schemaVersion) throws ObjectNotFoundException { + static public Schema getSchema(String schemaName, int schemaVersion) throws ObjectNotFound { Logger.msg(5, "Loading schema "+schemaName+" v"+schemaVersion); String docType = schemaName; @@ -83,9 +83,9 @@ public class LocalObjectLoader { Viewpoint schemaView = (Viewpoint)schema.getObject(ClusterStorage.VIEWPOINT + "/Schema/" + schemaVersion); try { schemaData = schemaView.getOutcome().getData(); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); - throw new ObjectNotFoundException("Problem loading schema "+schemaName+" v"+schemaVersion+": "+ex.getMessage(), ""); + throw new ObjectNotFound("Problem loading schema "+schemaName+" v"+schemaVersion+": "+ex.getMessage()); } return new Schema(docType, docVersion, schemaData); } @@ -96,14 +96,14 @@ public class LocalObjectLoader { * @param actName - activity name * @param version - named version (String) * @return ActivityDef - * @throws ObjectNotFoundException - When activity or version does not exist + * @throws ObjectNotFound - When activity or version does not exist */ - static public ActivityDef getActDef(String actName, int actVersion) throws ObjectNotFoundException, InvalidDataException { + static public ActivityDef getActDef(String actName, int actVersion) throws ObjectNotFound, InvalidData { Logger.msg(5, "Loading activity def "+actName+" v"+actVersion); return actCache.get(actName, actVersion); } - static public StateMachine getStateMachine(String smName, int smVersion) throws ObjectNotFoundException, InvalidDataException { + static public StateMachine getStateMachine(String smName, int smVersion) throws ObjectNotFound, InvalidData { Logger.msg(5, "Loading activity def "+smName+" v"+smVersion); return smCache.get(smName, smVersion); } diff --git a/src/main/java/com/c2kernel/utils/StateMachineCache.java b/src/main/java/com/c2kernel/utils/StateMachineCache.java index b11ac8b..9b9e464 100644 --- a/src/main/java/com/c2kernel/utils/StateMachineCache.java +++ b/src/main/java/com/c2kernel/utils/StateMachineCache.java @@ -23,12 +23,12 @@ */ package com.c2kernel.utils; -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.proxy.ItemProxy; import com.c2kernel.lifecycle.instance.stateMachine.StateMachine; import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.outcome.Viewpoint; import com.c2kernel.process.Gateway; @@ -41,22 +41,22 @@ public class StateMachineCache extends DescriptionObjectCache { } @Override - public StateMachine loadObject(String name, int version, ItemProxy proxy) throws ObjectNotFoundException, InvalidDataException { + public StateMachine loadObject(String name, int version, ItemProxy proxy) throws ObjectNotFound, InvalidData { StateMachine thisStateMachine; Viewpoint smView = (Viewpoint)proxy.getObject(ClusterStorage.VIEWPOINT + "/StateMachine/" + version); String marshalledSM; try { marshalledSM = smView.getOutcome().getData(); - } catch (ClusterStorageException ex) { + } catch (PersistencyException ex) { Logger.error(ex); - throw new ObjectNotFoundException("Problem loading State Machine "+name+" v"+version+": "+ex.getMessage(), ""); + throw new ObjectNotFound("Problem loading State Machine "+name+" v"+version+": "+ex.getMessage()); } try { thisStateMachine = (StateMachine)Gateway.getMarshaller().unmarshall(marshalledSM); thisStateMachine.validate(); } catch (Exception ex) { Logger.error(ex); - throw new InvalidDataException("Could not unmarshall State Machine '"+name+"' v"+version+": "+ex.getMessage(), ""); + throw new InvalidData("Could not unmarshall State Machine '"+name+"' v"+version+": "+ex.getMessage()); } thisStateMachine.setName(name); thisStateMachine.setVersion(version); diff --git a/src/test/java/MainTest.java b/src/test/java/MainTest.java index 9154dca..8d25a0e 100644 --- a/src/test/java/MainTest.java +++ b/src/test/java/MainTest.java @@ -24,7 +24,7 @@ import java.util.StringTokenizer; import org.custommonkey.xmlunit.XMLUnit; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.lifecycle.instance.stateMachine.StateMachine; import com.c2kernel.persistency.outcome.OutcomeValidator; import com.c2kernel.persistency.outcome.Schema; @@ -109,7 +109,7 @@ public class MainTest { } } - private static Schema getSchema(String name, int version, String resPath) throws ObjectNotFoundException { + private static Schema getSchema(String name, int version, String resPath) throws ObjectNotFound { return new Schema(name, version, Gateway.getResource().getTextResource(null, resPath)); } -- cgit v1.2.3