From 66b9f0bd1415a17a3db8801f5231248414712be5 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 9 Oct 2014 22:35:09 +0200 Subject: Predefined step testing and tweaking --- .../lifecycle/instance/predefined/AddMemberToCollection.java | 8 +++++++- .../instance/predefined/AddNewCollectionDescription.java | 4 ++-- .../kernel/lifecycle/instance/predefined/AddNewSlot.java | 10 +++++++++- .../kernel/lifecycle/instance/predefined/AssignItemToSlot.java | 9 ++++++++- .../kernel/lifecycle/instance/predefined/ClearSlot.java | 2 +- .../instance/predefined/RemoveSlotFromCollection.java | 10 +++++++++- .../lifecycle/instance/predefined/agent/SetAgentRoles.java | 4 ++-- 7 files changed, 38 insertions(+), 9 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddMemberToCollection.java b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddMemberToCollection.java index a065b1d..00b16ef 100644 --- a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddMemberToCollection.java +++ b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddMemberToCollection.java @@ -31,6 +31,8 @@ import org.cristalise.kernel.common.ObjectNotFoundException; import org.cristalise.kernel.common.PersistencyException; import org.cristalise.kernel.entity.C2KLocalObject; import org.cristalise.kernel.lookup.AgentPath; +import org.cristalise.kernel.lookup.DomainPath; +import org.cristalise.kernel.lookup.InvalidItemPathException; import org.cristalise.kernel.lookup.ItemPath; import org.cristalise.kernel.persistency.ClusterStorage; import org.cristalise.kernel.process.Gateway; @@ -80,7 +82,11 @@ public class AddMemberToCollection extends PredefinedStep if (Logger.doLog(3)) Logger.msg(3, "AddMemberToCollection: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); try { collName = params[0]; - newChild = new ItemPath(params[1]); + try { + newChild = new ItemPath(params[1]); + } catch (InvalidItemPathException e) { + newChild = new DomainPath(params[1]).getItemPath(); + } if (params.length > 2) props = (CastorHashMap)Gateway.getMarshaller().unmarshall(params[2]); diff --git a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java index b230284..eabf07a 100644 --- a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java +++ b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java @@ -92,9 +92,9 @@ public class AddNewCollectionDescription extends PredefinedStep CollectionDescription newCollDesc; - if (collType.equals("Aggregation")) + if (collType.equalsIgnoreCase("Aggregation")) newCollDesc = new AggregationDescription(collName); - if (collType.equals("Dependency")) + else if (collType.equalsIgnoreCase("Dependency")) newCollDesc = new DependencyDescription(collName); else throw new InvalidDataException("AddNewCollectionDescription: Invalid collection type specified: '"+collType+"'. Must be Aggregation or Dependency."); diff --git a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddNewSlot.java b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddNewSlot.java index f3acdf3..0088091 100644 --- a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddNewSlot.java +++ b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AddNewSlot.java @@ -29,6 +29,8 @@ import org.cristalise.kernel.common.ObjectNotFoundException; import org.cristalise.kernel.common.PersistencyException; import org.cristalise.kernel.entity.C2KLocalObject; import org.cristalise.kernel.lookup.AgentPath; +import org.cristalise.kernel.lookup.DomainPath; +import org.cristalise.kernel.lookup.InvalidItemPathException; import org.cristalise.kernel.lookup.ItemPath; import org.cristalise.kernel.persistency.ClusterStorage; import org.cristalise.kernel.process.Gateway; @@ -84,7 +86,13 @@ public class AddNewSlot extends PredefinedStep // resolve desc item path and version try { collName = params[0]; - if (params.length > 1 && params[1].length() > 0) descKey = new ItemPath(params[1]); + if (params.length > 1 && params[1].length() > 0) { + try { + descKey = new ItemPath(params[1]); + } catch (InvalidItemPathException e) { + descKey = new DomainPath(params[1]).getItemPath(); + } + } if (params.length > 2 && params[2].length() > 0) descVer = params[2]; } catch (Exception e) { throw new InvalidDataException("AddNewSlot: Invalid parameters "+Arrays.toString(params)); diff --git a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AssignItemToSlot.java b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AssignItemToSlot.java index c242500..416d85d 100644 --- a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AssignItemToSlot.java +++ b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/AssignItemToSlot.java @@ -32,6 +32,8 @@ import org.cristalise.kernel.common.ObjectNotFoundException; import org.cristalise.kernel.common.PersistencyException; import org.cristalise.kernel.entity.C2KLocalObject; import org.cristalise.kernel.lookup.AgentPath; +import org.cristalise.kernel.lookup.DomainPath; +import org.cristalise.kernel.lookup.InvalidItemPathException; import org.cristalise.kernel.lookup.ItemPath; import org.cristalise.kernel.persistency.ClusterStorage; import org.cristalise.kernel.process.Gateway; @@ -80,8 +82,13 @@ public class AssignItemToSlot extends PredefinedStep try { collName = params[0]; slotNo = Integer.parseInt(params[1]); - childItem = new ItemPath(params[2]); + try { + childItem = new ItemPath(params[2]); + } catch (InvalidItemPathException e) { + childItem = new DomainPath(params[2]).getItemPath(); + } } catch (Exception e) { + Logger.error(e); throw new InvalidDataException("AssignItemToSlot: Invalid parameters "+Arrays.toString(params)); } diff --git a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/ClearSlot.java b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/ClearSlot.java index bd0fa19..7e9831a 100644 --- a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/ClearSlot.java +++ b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/ClearSlot.java @@ -91,7 +91,7 @@ public class ClearSlot extends PredefinedStep boolean stored = false; for (AggregationMember member : agg.getMembers().list) { if (member.getID() == slotNo) { - if (member.getItemPath() != null) + if (member.getItemPath() == null) throw new ObjectCannotBeUpdated("ClearSlot: Member slot "+slotNo+" already empty"); member.clearItem(); stored = true; diff --git a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java index 6522384..8bca2ca 100644 --- a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java +++ b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java @@ -29,6 +29,8 @@ import org.cristalise.kernel.common.InvalidDataException; import org.cristalise.kernel.common.ObjectNotFoundException; import org.cristalise.kernel.common.PersistencyException; import org.cristalise.kernel.lookup.AgentPath; +import org.cristalise.kernel.lookup.DomainPath; +import org.cristalise.kernel.lookup.InvalidItemPathException; import org.cristalise.kernel.lookup.ItemPath; import org.cristalise.kernel.persistency.ClusterStorage; import org.cristalise.kernel.process.Gateway; @@ -75,7 +77,13 @@ public class RemoveSlotFromCollection extends PredefinedStep try { collName = params[0]; 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]); + if (params.length>2 && params[2].length()>0) { + try { + currentChild = new ItemPath(params[2]); + } catch (InvalidItemPathException e) { + currentChild = new DomainPath(params[2]).getItemPath(); + } + } } catch (Exception e) { throw new InvalidDataException("RemoveSlotFromCollection: Invalid parameters "+Arrays.toString(params)); } diff --git a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java index e267034..831997a 100644 --- a/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java +++ b/src/main/java/org/cristalise/kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java @@ -21,6 +21,7 @@ package org.cristalise.kernel.lifecycle.instance.predefined.agent; import java.util.ArrayList; +import java.util.Arrays; import org.cristalise.kernel.common.InvalidDataException; import org.cristalise.kernel.common.ObjectNotFoundException; @@ -43,9 +44,8 @@ public class SetAgentRoles extends PredefinedStep { protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData) throws InvalidDataException { - Logger.msg(1, "SetAgentRoles::request() - Starting."); - String[] params = getDataList(requestData); + if (Logger.doLog(3)) Logger.msg(3, "AddC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); AgentPath targetAgent; try { targetAgent = new AgentPath(item); -- cgit v1.2.3