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. --- .../com/c2kernel/lifecycle/instance/Workflow.java | 56 +++++++++++----------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'src/main/java/com/c2kernel/lifecycle/instance/Workflow.java') 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) -- cgit v1.2.3