From 20c81748688547c1b13686f15c65fbb1d60d81a0 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 12 Jul 2012 14:52:36 +0200 Subject: Suspend transition now can carry an optional 'Errors' outcome where client processes can record the reason for the suspension. Errors XML is marshalled ErrorInfo. UserCodeProcess automatically sends fatal ErrorInfos through suspend jobs. Job API added to to support all this. fixes #23 --- .../com/c2kernel/lifecycle/instance/Activity.java | 41 ++++++++++++---------- 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/main/java/com/c2kernel/lifecycle/instance/Activity.java') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java index 8d92522..8dc6b9d 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java @@ -543,26 +543,28 @@ public class Activity extends WfVertex } /** * Stores the request data as an outcome of the Item It does a great deal of storing outcomes in different configuration */ //requestdata is xmlstring - private String storeOutcome(int eventID, String requestData) + private String storeOutcome(int eventID, String requestData, boolean isError) throws InvalidDataException { EntityPath entityPath = getItemEntityPath(); if (entityPath != null) { - String schemaType = (String) getProperties().get("SchemaType"); - if (schemaType == null || schemaType.length() == 0) // no - // outcome - // required - return null; - int schemaVersion = 0; - String versionString = (String) getProperties().get("SchemaVersion"); - try - { - schemaVersion = Integer.parseInt(versionString); + String schemaType; int schemaVersion; + if (isError) { + schemaType="Errors"; + schemaVersion=0; } - catch (Exception e) - { - Logger.error("Activity.storeOutcome() - invalid schemaVersion " + versionString); + else { + schemaType = (String) getProperties().get("SchemaType"); + if (schemaType == null || schemaType.length() == 0) return null; + String versionString = (String) getProperties().get("SchemaVersion"); + try + { + schemaVersion = Integer.parseInt(versionString); + } catch (Exception e) { + throw new InvalidDataException("Activity.storeOutcome() - invalid schemaVersion " + versionString, ""); + } } + Logger.msg(5, "Activity::storeOutcome() - type:" + schemaType + " version:" + schemaVersion); try { @@ -588,16 +590,19 @@ public class Activity extends WfVertex } else return null; - } /** the method to be called by the requestAction() method */ - public void sendEventStoreOutcome(int transitionID, String requestData, AgentPath agent) + } + + /** the method to be called by the requestAction() method + * @throws InvalidDataException */ + public void sendEventStoreOutcome(int transitionID, String requestData, AgentPath agent) throws InvalidDataException { int eventID = -1; Event event = null; event = auditEvent(transitionID, agent); if (event != null) eventID = event.getID(); - if (transitionID == Transitions.DONE || transitionID == Transitions.COMPLETE) - storeOutcome(eventID, requestData); + if ((transitionID == Transitions.DONE || transitionID == Transitions.COMPLETE || transitionID == Transitions.SUSPEND) && requestData != null && requestData.length() > 0) + storeOutcome(eventID, requestData, transitionID == Transitions.SUSPEND); EntityPath entityPath = getItemEntityPath(); TransactionManager storage = Gateway.getStorage(); if (entityPath != null) -- cgit v1.2.3