From dd91089106edeb9bf1cdfe415c98a051585797c2 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Wed, 2 Apr 2014 15:27:08 +0200 Subject: Default StateMachine workflow --- src/main/resources/boot/CA/ManageStateMachine.xml | 214 ++++++++++++++++++++++ src/main/resources/boot/EA/EditStateMachine.xml | 19 ++ src/main/resources/boot/allbootitems.txt | 2 + 3 files changed, 235 insertions(+) create mode 100644 src/main/resources/boot/CA/ManageStateMachine.xml create mode 100644 src/main/resources/boot/EA/EditStateMachine.xml (limited to 'src/main/resources/boot') diff --git a/src/main/resources/boot/CA/ManageStateMachine.xml b/src/main/resources/boot/CA/ManageStateMachine.xml new file mode 100644 index 0000000..47d769b --- /dev/null +++ b/src/main/resources/boot/CA/ManageStateMachine.xml @@ -0,0 +1,214 @@ + + + + + + + + + + 19 + 20 + 21 + + + + + + + + + + + + + 17 + 20 + 18 + + + + + + + + + + + 16 + 17 + + + + + + + + + + + + 8 + 21 + + + + + + + + + + + 6 + 7 + 8 + + + + + + + + + + + + + 18 + 19 + + + + + AssignNewVersionFromLast + + + + + + + + 7 + 16 + 5 + + + + + + + + + + + 5 + 6 + + + + + + EditStateMachine + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/boot/EA/EditStateMachine.xml b/src/main/resources/boot/EA/EditStateMachine.xml new file mode 100644 index 0000000..a1060b7 --- /dev/null +++ b/src/main/resources/boot/EA/EditStateMachine.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/boot/allbootitems.txt b/src/main/resources/boot/allbootitems.txt index 194eb61..9bbea75 100644 --- a/src/main/resources/boot/allbootitems.txt +++ b/src/main/resources/boot/allbootitems.txt @@ -16,6 +16,7 @@ EA/AssignNewVersionFromLast EA/EditActivityDef EA/EditSchema EA/EditScriptDefinition +EA/EditStateMachine EA/CreateNewItem EA/CreateNewAgent EA/EditModuleDefinition @@ -26,5 +27,6 @@ CA/ManageCompositeActDef CA/ManageElementaryActDef CA/ManageSchema CA/ManageScript +CA/ManageStateMachine SC/CreateNewNumberedVersionFromLast SC/ServerNewEntity -- cgit v1.2.3 From 4466bfb51367afefec57bae9ca8f571eef17cfd9 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 4 Apr 2014 12:54:29 +0200 Subject: Removed resource type enumeration, because we allow domain-defined types now. Refs #178 --- src/main/resources/boot/OD/Module.xsd | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src/main/resources/boot') diff --git a/src/main/resources/boot/OD/Module.xsd b/src/main/resources/boot/OD/Module.xsd index 2b8fefd..882b374 100644 --- a/src/main/resources/boot/OD/Module.xsd +++ b/src/main/resources/boot/OD/Module.xsd @@ -56,16 +56,7 @@ - - - - - - - - - - + -- cgit v1.2.3 From 11e7a9aaed7c22ec93a791ea752e159b4b120e4e Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 4 Apr 2014 17:26:10 +0200 Subject: Module XML now supports a workflowVer attribute for the Item element. If not given, it assumed version 0, as per the previous behaviour. Fixes #180 --- .../predefined/entitycreation/NewItem.java | 23 +++++++++++++++++----- src/main/java/com/c2kernel/process/Bootstrap.java | 2 +- .../java/com/c2kernel/process/module/Module.java | 2 +- src/main/resources/boot/OD/Module.xsd | 4 +++- src/main/resources/mapFiles/NewEntityMap.xml | 3 +++ 5 files changed, 26 insertions(+), 8 deletions(-) (limited to 'src/main/resources/boot') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java index 5f8cf12..07b8462 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java @@ -39,6 +39,7 @@ public class NewItem extends ModuleImport { public String initialPath; public String workflow; + public Integer workflowVer; public ArrayList properties = new ArrayList(); public ArrayList aggregationList = new ArrayList(); public ArrayList dependencyList = new ArrayList(); @@ -48,11 +49,12 @@ public class NewItem extends ModuleImport { public NewItem() { } - public NewItem(String name, String initialPath, String wf) { + public NewItem(String name, String initialPath, String wf, int wfVer) { this(); this.name = name; this.initialPath = initialPath; this.workflow = wf; + this.workflowVer = wfVer; } public void setNamespace(String ns) { @@ -82,11 +84,22 @@ public class NewItem extends ModuleImport { // set the name property properties.add(new Property("Name", name, true)); - // init the new item + // find workflow def + CompositeActivityDef compact; + // default workflow version is 0 if not given + int usedWfVer; + if (workflowVer == null) usedWfVer = 0; + else usedWfVer = workflowVer.intValue(); try { - - // find workflow def - CompositeActivityDef compact = (CompositeActivityDef)LocalObjectLoader.getActDef(workflow, 0); + 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", ""); + } + + try { + // initialise the new item with workflow and properties newItem.initialise( agentId, Gateway.getMarshaller().marshall(new PropertyArrayList(properties)), diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index df8ced7..a750b3f 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -183,7 +183,7 @@ public class Bootstrap } // data was missing or doesn't match - Logger.msg("Bootstrap.verifyResource() - Writing new "+newOutcome.getSchemaType()+"version "+version+" to "+typeImpHandler.getName()+" "+itemName); + Logger.msg("Bootstrap.verifyResource() - Writing new "+newOutcome.getSchemaType()+" v"+version+" to "+typeImpHandler.getName()+" "+itemName); History hist = new History(thisProxy.getSystemKey(), thisProxy); Transition predefDone = new Transition(0, "Done", 0, 0); Event newEvent = hist.addEvent("system", "Admin", "Bootstrap", "Bootstrap", "Bootstrap", newOutcome.getSchemaType(), 0, "PredefinedStep", 0, predefDone, String.valueOf(version)); diff --git a/src/main/java/com/c2kernel/process/module/Module.java b/src/main/java/com/c2kernel/process/module/Module.java index a7c707e..3e8ab2a 100644 --- a/src/main/java/com/c2kernel/process/module/Module.java +++ b/src/main/java/com/c2kernel/process/module/Module.java @@ -51,7 +51,7 @@ public class Module { } public void addModuleItem(String moduleXML) { - NewItem moduleItem = new NewItem(name, "/desc/modules/", "ModuleWorkflow"); + NewItem moduleItem = new NewItem(name, "/desc/modules/", "ModuleWorkflow", 0); // Module properties moduleItem.properties.add(new com.c2kernel.property.Property("Namespace", ns, false)); moduleItem.properties.add(new com.c2kernel.property.Property("Name", name, false)); diff --git a/src/main/resources/boot/OD/Module.xsd b/src/main/resources/boot/OD/Module.xsd index 882b374..d25352e 100644 --- a/src/main/resources/boot/OD/Module.xsd +++ b/src/main/resources/boot/OD/Module.xsd @@ -150,7 +150,9 @@ + use="required" /> + diff --git a/src/main/resources/mapFiles/NewEntityMap.xml b/src/main/resources/mapFiles/NewEntityMap.xml index 239fa21..84c4ce7 100644 --- a/src/main/resources/mapFiles/NewEntityMap.xml +++ b/src/main/resources/mapFiles/NewEntityMap.xml @@ -11,6 +11,9 @@ + + + -- cgit v1.2.3 From 410dc5af0fec0e29635cc049351076712f2d4727 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 11 Apr 2014 17:00:47 +0200 Subject: Remove description editing workflows from the kernel - they have been moved to cristal-dev. Requires future post-processing for previous Module.debug functionality --- src/main/java/com/c2kernel/process/Bootstrap.java | 11 +- .../java/com/c2kernel/process/module/Module.java | 2 +- .../resources/boot/CA/ManageCompositeActDef.xml | 208 -------------------- .../resources/boot/CA/ManageElementaryActDef.xml | 212 -------------------- src/main/resources/boot/CA/ManageSchema.xml | 216 -------------------- src/main/resources/boot/CA/ManageScript.xml | 217 --------------------- src/main/resources/boot/CA/ManageStateMachine.xml | 214 -------------------- src/main/resources/boot/CA/ModuleWorkflow.xml | 100 ---------- .../resources/boot/EA/AssignNewVersionFromLast.xml | 20 -- src/main/resources/boot/EA/EditActivityDef.xml | 19 -- .../resources/boot/EA/EditModuleDefinition.xml | 1 - src/main/resources/boot/EA/EditSchema.xml | 19 -- .../resources/boot/EA/EditScriptDefinition.xml | 19 -- src/main/resources/boot/EA/EditStateMachine.xml | 19 -- .../boot/SC/CreateNewNumberedVersionFromLast.xml | 31 --- src/main/resources/boot/allbootitems.txt | 13 -- 16 files changed, 8 insertions(+), 1313 deletions(-) delete mode 100644 src/main/resources/boot/CA/ManageCompositeActDef.xml delete mode 100644 src/main/resources/boot/CA/ManageElementaryActDef.xml delete mode 100644 src/main/resources/boot/CA/ManageSchema.xml delete mode 100644 src/main/resources/boot/CA/ManageScript.xml delete mode 100644 src/main/resources/boot/CA/ManageStateMachine.xml delete mode 100644 src/main/resources/boot/CA/ModuleWorkflow.xml delete mode 100644 src/main/resources/boot/EA/AssignNewVersionFromLast.xml delete mode 100644 src/main/resources/boot/EA/EditActivityDef.xml delete mode 100644 src/main/resources/boot/EA/EditModuleDefinition.xml delete mode 100644 src/main/resources/boot/EA/EditSchema.xml delete mode 100644 src/main/resources/boot/EA/EditScriptDefinition.xml delete mode 100644 src/main/resources/boot/EA/EditStateMachine.xml delete mode 100644 src/main/resources/boot/SC/CreateNewNumberedVersionFromLast.xml (limited to 'src/main/resources/boot') diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index a750b3f..601db31 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -238,11 +238,14 @@ public class Bootstrap props.list.add(new Property(propName, propVal, pd.getIsMutable())); } - CompositeActivity ca; + CompositeActivity ca = new CompositeActivity(); if (ns!=null && Gateway.getProperties().getBoolean("Module.debug", false)) - ca = (CompositeActivity) ((CompositeActivityDef)LocalObjectLoader.getActDef(impHandler.getWorkflowName(), 0)).instantiate(); - else - ca = new CompositeActivity(); + try { + ca = (CompositeActivity) ((CompositeActivityDef)LocalObjectLoader.getActDef(impHandler.getWorkflowName(), 0)).instantiate(); + } catch (ObjectNotFoundException ex) { + Logger.error("Module resource workflow "+impHandler.getWorkflowName()+" not found. Using empty."); + } + EntityPath entityPath = Gateway.getLDAPLookup().getNextKeyManager().generateNextEntityKey(); TraceableEntity newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entityPath); diff --git a/src/main/java/com/c2kernel/process/module/Module.java b/src/main/java/com/c2kernel/process/module/Module.java index 3e8ab2a..32a5997 100644 --- a/src/main/java/com/c2kernel/process/module/Module.java +++ b/src/main/java/com/c2kernel/process/module/Module.java @@ -51,7 +51,7 @@ public class Module { } public void addModuleItem(String moduleXML) { - NewItem moduleItem = new NewItem(name, "/desc/modules/", "ModuleWorkflow", 0); + NewItem moduleItem = new NewItem(name, "/desc/modules/", "NoWorkflow", 0); // Module properties moduleItem.properties.add(new com.c2kernel.property.Property("Namespace", ns, false)); moduleItem.properties.add(new com.c2kernel.property.Property("Name", name, false)); diff --git a/src/main/resources/boot/CA/ManageCompositeActDef.xml b/src/main/resources/boot/CA/ManageCompositeActDef.xml deleted file mode 100644 index f1def44..0000000 --- a/src/main/resources/boot/CA/ManageCompositeActDef.xml +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - 19 - 20 - 21 - - - - - - - - - - - - 17 - 20 - 18 - - - - - - - - - - - 16 - 17 - - - - - - - - - 8 - 21 - - - - - - - - - - - 25 - 7 - 8 - - - - - - - - - - - - 18 - 19 - - - - - AssignNewVersionFromLast - - - - - - - - 7 - 16 - 24 - - - - - - - - - - - 24 - 25 - - - - - EditActivityDef - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/boot/CA/ManageElementaryActDef.xml b/src/main/resources/boot/CA/ManageElementaryActDef.xml deleted file mode 100644 index 756fb8a..0000000 --- a/src/main/resources/boot/CA/ManageElementaryActDef.xml +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - 19 - 20 - 21 - - - - - - - - - - - - 17 - 20 - 18 - - - - - - - - - - - 8 - 21 - - - - - - - - - - - 16 - 17 - - - - - - - - - 25 - 7 - 8 - - - - - - - - - - - - 7 - 16 - 24 - - - - - - - - - - - 18 - 19 - - - - - - - AssignNewVersionFromLast - - - - - - - - 24 - 25 - - - - - - - EditActivityDef - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/boot/CA/ManageSchema.xml b/src/main/resources/boot/CA/ManageSchema.xml deleted file mode 100644 index 69580fe..0000000 --- a/src/main/resources/boot/CA/ManageSchema.xml +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - - - - - 19 - 20 - 21 - - - - - - - - - - - - - 17 - 20 - 18 - - - - - - - - - - - 16 - 17 - - - - - - - - - - - - 8 - 21 - - - - - - - - - - - 6 - 7 - 8 - - - - - - - - - - - - - 18 - 19 - - - - - - - AssignNewVersionFromLast - - - - - - - - 7 - 16 - 5 - - - - - - - - - - - 5 - 6 - - - - - - EditSchema - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/boot/CA/ManageScript.xml b/src/main/resources/boot/CA/ManageScript.xml deleted file mode 100644 index 9dff06f..0000000 --- a/src/main/resources/boot/CA/ManageScript.xml +++ /dev/null @@ -1,217 +0,0 @@ - - - - - - - - - - 24 - 25 - 26 - - - - - - - - - - - - - 21 - 22 - 23 - - - - - - - - - - - - - 18 - 25 - 20 - - - - - - - - - - - 17 - 23 - 19 - - - - - - - - - - - 17 - 18 - - - - - - - - - - - - 19 - 21 - - - - - - EditScriptDefinition - - - - - - - - 20 - 24 - - - - - - - AssignNewVersionFromLast - - - - - - - - 22 - 26 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/boot/CA/ManageStateMachine.xml b/src/main/resources/boot/CA/ManageStateMachine.xml deleted file mode 100644 index 47d769b..0000000 --- a/src/main/resources/boot/CA/ManageStateMachine.xml +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - - - 19 - 20 - 21 - - - - - - - - - - - - - 17 - 20 - 18 - - - - - - - - - - - 16 - 17 - - - - - - - - - - - - 8 - 21 - - - - - - - - - - - 6 - 7 - 8 - - - - - - - - - - - - - 18 - 19 - - - - - AssignNewVersionFromLast - - - - - - - - 7 - 16 - 5 - - - - - - - - - - - 5 - 6 - - - - - - EditStateMachine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/boot/CA/ModuleWorkflow.xml b/src/main/resources/boot/CA/ModuleWorkflow.xml deleted file mode 100644 index 1eb3ee4..0000000 --- a/src/main/resources/boot/CA/ModuleWorkflow.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - 7 - - - - - - - - - - - 4 - 5 - 7 - - - - - - - - - - - - - 5 - 3 - - - - - - - - - - - 3 - 4 - - - - - EditModuleDefinition - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/boot/EA/AssignNewVersionFromLast.xml b/src/main/resources/boot/EA/AssignNewVersionFromLast.xml deleted file mode 100644 index 248dfee..0000000 --- a/src/main/resources/boot/EA/AssignNewVersionFromLast.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/boot/EA/EditActivityDef.xml b/src/main/resources/boot/EA/EditActivityDef.xml deleted file mode 100644 index e90c225..0000000 --- a/src/main/resources/boot/EA/EditActivityDef.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/boot/EA/EditModuleDefinition.xml b/src/main/resources/boot/EA/EditModuleDefinition.xml deleted file mode 100644 index 04afe4d..0000000 --- a/src/main/resources/boot/EA/EditModuleDefinition.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/main/resources/boot/EA/EditSchema.xml b/src/main/resources/boot/EA/EditSchema.xml deleted file mode 100644 index 3b01fdc..0000000 --- a/src/main/resources/boot/EA/EditSchema.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/boot/EA/EditScriptDefinition.xml b/src/main/resources/boot/EA/EditScriptDefinition.xml deleted file mode 100644 index 11c14ec..0000000 --- a/src/main/resources/boot/EA/EditScriptDefinition.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/boot/EA/EditStateMachine.xml b/src/main/resources/boot/EA/EditStateMachine.xml deleted file mode 100644 index a1060b7..0000000 --- a/src/main/resources/boot/EA/EditStateMachine.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/boot/SC/CreateNewNumberedVersionFromLast.xml b/src/main/resources/boot/SC/CreateNewNumberedVersionFromLast.xml deleted file mode 100644 index 7a63b76..0000000 --- a/src/main/resources/boot/SC/CreateNewNumberedVersionFromLast.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - diff --git a/src/main/resources/boot/allbootitems.txt b/src/main/resources/boot/allbootitems.txt index 9bbea75..7a3cd03 100644 --- a/src/main/resources/boot/allbootitems.txt +++ b/src/main/resources/boot/allbootitems.txt @@ -12,21 +12,8 @@ OD/Schema OD/Script OD/Errors OD/StateMachine -EA/AssignNewVersionFromLast -EA/EditActivityDef -EA/EditSchema -EA/EditScriptDefinition -EA/EditStateMachine EA/CreateNewItem EA/CreateNewAgent -EA/EditModuleDefinition CA/NoWorkflow CA/ServerItemWorkflow -CA/ModuleWorkflow -CA/ManageCompositeActDef -CA/ManageElementaryActDef -CA/ManageSchema -CA/ManageScript -CA/ManageStateMachine -SC/CreateNewNumberedVersionFromLast SC/ServerNewEntity -- cgit v1.2.3 From 8e8185210f5bd87cb5dcda3a458fe059f811aafc Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 15 May 2014 15:10:13 +0200 Subject: Introduced 'Layer' attribute to allow overriding of descriptions. Desc with the same name in the same description tree will be ranked by LocalObjectLoader according to this number, and the highest one chosen for instantiation. Fixes #188 --- src/main/java/com/c2kernel/process/Bootstrap.java | 25 +++++++++++++++---- .../java/com/c2kernel/process/module/Module.java | 3 ++- .../com/c2kernel/process/module/ModuleInfo.java | 1 + .../java/com/c2kernel/utils/LocalObjectLoader.java | 28 ++++++++++++++++++++-- src/main/resources/boot/OD/Module.xsd | 1 + src/main/resources/boot/property/CAProp.xml | 1 + src/main/resources/boot/property/EAProp.xml | 1 + src/main/resources/boot/property/ODProp.xml | 1 + src/main/resources/boot/property/SCProp.xml | 1 + src/main/resources/boot/property/SMProp.xml | 1 + src/main/resources/mapFiles/ModuleMap.xml | 3 +++ 11 files changed, 58 insertions(+), 8 deletions(-) (limited to 'src/main/resources/boot') diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index e2ad24e..f273c5d 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -103,7 +103,7 @@ public class Bootstrap String itemName = thisItem.substring(delim+1); try { String location = "boot/"+thisItem+(itemType.equals("OD")?".xsd":".xml"); - verifyResource(ns, itemName, 0, itemType, location, reset); + verifyResource(ns, itemName, 0, itemType, location, 0, reset); } catch (Exception e) { Logger.error(e); Logger.die("Error importing bootstrap items. Unsafe to continue."); @@ -112,7 +112,7 @@ public class Bootstrap } - public static DomainPath verifyResource(String ns, String itemName, Integer version, String itemType, String dataLocation, boolean reset) throws Exception { + public static DomainPath verifyResource(String ns, String itemName, Integer version, String itemType, String dataLocation, int layer, boolean reset) throws Exception { if (version == null) version = 0; ResourceImportHandler typeImpHandler = getHandler(itemType); Logger.msg(1, "Bootstrap.verifyResource() - Verifying version "+version+" of "+typeImpHandler.getName()+" "+itemName); @@ -123,7 +123,7 @@ public class Bootstrap Enumeration en = Gateway.getLDAPLookup().search(typeImpHandler.getTypeRoot(), itemName); if (!en.hasMoreElements()) { Logger.msg("Bootstrap.verifyResource() - "+typeImpHandler.getName()+" "+itemName+" not found. Creating new."); - thisProxy = createResourceItem(typeImpHandler, itemName, ns); + thisProxy = createResourceItem(typeImpHandler, itemName, layer, ns); } else { DomainPath path = (DomainPath)en.nextElement(); @@ -147,6 +147,15 @@ public class Bootstrap Gateway.getStorage().put(thisProxy.getSystemKey(), new Property("Module", moduleName, false), thisProxy); } + // overwrite layer if different + int currentLayer = -1; + try { + String layerProp = thisProxy.getProperty("Layer"); + currentLayer = Integer.parseInt(layerProp); + } catch (Exception e) { } + if (currentLayer != layer) + Gateway.getStorage().put(thisProxy.getSystemKey(), new Property("Layer", String.valueOf(layer), false), thisProxy); + if (!modDomPath.equals(path)) { // move item to module subtree Logger.msg("Module item "+itemName+" found with path "+path.toString()+". Moving to "+modDomPath.toString()); modDomPath.setEntity(new ItemPath(thisProxy.getSystemKey())); @@ -224,16 +233,22 @@ public class Bootstrap /** * @param itemType * @param itemName + * @param layer * @param data */ - private static ItemProxy createResourceItem(ResourceImportHandler impHandler, String itemName, String ns) throws Exception { + private static ItemProxy createResourceItem(ResourceImportHandler impHandler, String itemName, int layer, String ns) throws Exception { // create props PropertyDescriptionList pdList = impHandler.getPropDesc(); PropertyArrayList props = new PropertyArrayList(); for (int i = 0; i < pdList.list.size(); i++) { PropertyDescription pd = pdList.list.get(i); String propName = pd.getName(); - String propVal = propName.equals("Name")?itemName:pd.getDefaultValue(); + String propVal; + if (propName.equals("Name")) + propVal = itemName; + else if (propName.equals("Layer")) + propVal = String.valueOf(layer); + else propVal = pd.getDefaultValue(); props.list.add(new Property(propName, propVal, pd.getIsMutable())); } diff --git a/src/main/java/com/c2kernel/process/module/Module.java b/src/main/java/com/c2kernel/process/module/Module.java index 32a5997..2c182ea 100644 --- a/src/main/java/com/c2kernel/process/module/Module.java +++ b/src/main/java/com/c2kernel/process/module/Module.java @@ -56,6 +56,7 @@ public class Module { moduleItem.properties.add(new com.c2kernel.property.Property("Namespace", ns, false)); moduleItem.properties.add(new com.c2kernel.property.Property("Name", name, false)); moduleItem.properties.add(new com.c2kernel.property.Property("Type", "Module", false)); + moduleItem.properties.add(new com.c2kernel.property.Property("Layer", String.valueOf(info.layer), true)); moduleItem.properties.add(new com.c2kernel.property.Property("Version", info.version, true)); // Add dependency for all children Dependency children = new Dependency("Contents"); @@ -79,7 +80,7 @@ public class Module { for (ModuleResource thisRes : imports.getResources()) { try { thisRes.path = Bootstrap.verifyResource(ns, thisRes.name, thisRes.version, - thisRes.resourceType, thisRes.resourceLocation, reset); + thisRes.resourceType, thisRes.resourceLocation, info.layer, reset); } catch (Exception ex) { Logger.error(ex); } diff --git a/src/main/java/com/c2kernel/process/module/ModuleInfo.java b/src/main/java/com/c2kernel/process/module/ModuleInfo.java index 55e02c9..646a915 100644 --- a/src/main/java/com/c2kernel/process/module/ModuleInfo.java +++ b/src/main/java/com/c2kernel/process/module/ModuleInfo.java @@ -6,6 +6,7 @@ public class ModuleInfo { public String desc; public String version; + public int layer = 0; public ArrayList dependency = new ArrayList(); public ModuleInfo() { diff --git a/src/main/java/com/c2kernel/utils/LocalObjectLoader.java b/src/main/java/com/c2kernel/utils/LocalObjectLoader.java index 05f8aba..307cd97 100644 --- a/src/main/java/com/c2kernel/utils/LocalObjectLoader.java +++ b/src/main/java/com/c2kernel/utils/LocalObjectLoader.java @@ -1,11 +1,14 @@ package com.c2kernel.utils; +import java.util.Enumeration; + import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.ObjectNotFoundException; 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; @@ -20,8 +23,29 @@ public class LocalObjectLoader { throws ObjectNotFoundException { DomainPath defRoot = new DomainPath(root); - DomainPath defPath = (DomainPath)defRoot.find(name); - return Gateway.getProxyManager().getProxy(defPath); + Enumeration e = Gateway.getLDAPLookup().search(defRoot, name); + ItemProxy defProxy = null; int currentLayer = -1; + while (e.hasMoreElements()) { + DomainPath defPath = (DomainPath)e.nextElement(); + ItemProxy thisProxy = Gateway.getProxyManager().getProxy(defPath); + int thisLayer; + try { + String thisLayerProp = thisProxy.getProperty("Layer"); + thisLayer = Integer.parseInt(thisLayerProp); + } catch (Exception ex) { + thisLayer = 0; + } + if (thisLayer > currentLayer) { + currentLayer = thisLayer; + defProxy = thisProxy; + } + else if (thisLayer == currentLayer) { + throw new ObjectNotFoundException("Duplicate definition for "+name+" in "+root+" found in Layer "+thisLayer, ""); + } + } + if (defProxy == null) + throw new ObjectNotFoundException("No match for "+name+" in "+root, ""); + return defProxy; } static public String getScript(String scriptName, int scriptVersion) throws ObjectNotFoundException { diff --git a/src/main/resources/boot/OD/Module.xsd b/src/main/resources/boot/OD/Module.xsd index d25352e..c768e3f 100644 --- a/src/main/resources/boot/OD/Module.xsd +++ b/src/main/resources/boot/OD/Module.xsd @@ -9,6 +9,7 @@ + diff --git a/src/main/resources/boot/property/CAProp.xml b/src/main/resources/boot/property/CAProp.xml index ac37ae7..b29884a 100644 --- a/src/main/resources/boot/property/CAProp.xml +++ b/src/main/resources/boot/property/CAProp.xml @@ -2,5 +2,6 @@ + diff --git a/src/main/resources/boot/property/EAProp.xml b/src/main/resources/boot/property/EAProp.xml index a345695..2477c93 100644 --- a/src/main/resources/boot/property/EAProp.xml +++ b/src/main/resources/boot/property/EAProp.xml @@ -2,5 +2,6 @@ + diff --git a/src/main/resources/boot/property/ODProp.xml b/src/main/resources/boot/property/ODProp.xml index 894a6ee..f4d7b15 100644 --- a/src/main/resources/boot/property/ODProp.xml +++ b/src/main/resources/boot/property/ODProp.xml @@ -1,5 +1,6 @@ + diff --git a/src/main/resources/boot/property/SCProp.xml b/src/main/resources/boot/property/SCProp.xml index f5de23c..9ff0366 100644 --- a/src/main/resources/boot/property/SCProp.xml +++ b/src/main/resources/boot/property/SCProp.xml @@ -1,5 +1,6 @@ + diff --git a/src/main/resources/boot/property/SMProp.xml b/src/main/resources/boot/property/SMProp.xml index 8581e74..f43d0b5 100644 --- a/src/main/resources/boot/property/SMProp.xml +++ b/src/main/resources/boot/property/SMProp.xml @@ -1,5 +1,6 @@ + diff --git a/src/main/resources/mapFiles/ModuleMap.xml b/src/main/resources/mapFiles/ModuleMap.xml index 45f6cbe..440b852 100644 --- a/src/main/resources/mapFiles/ModuleMap.xml +++ b/src/main/resources/mapFiles/ModuleMap.xml @@ -38,6 +38,9 @@ + + + -- cgit v1.2.3