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. --- .../instance/predefined/ReplaceDomainWorkflow.java | 43 ++++++++++++---------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java') 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; } } -- cgit v1.2.3