diff options
Diffstat (limited to 'src/main/java/com/c2kernel/utils/LocalObjectLoader.java')
| -rw-r--r-- | src/main/java/com/c2kernel/utils/LocalObjectLoader.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/main/java/com/c2kernel/utils/LocalObjectLoader.java b/src/main/java/com/c2kernel/utils/LocalObjectLoader.java index aef7b96..f0d8928 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.Iterator;
+
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 (ItemProxy)Gateway.getProxyManager().getProxy(defPath);
+ Iterator<Path> e = Gateway.getLookup().search(defRoot, name);
+ ItemProxy defProxy = null; int currentLayer = -1;
+ while (e.hasNext()) {
+ DomainPath defPath = (DomainPath)e.next();
+ 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 {
|
