summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/utils/LocalObjectLoader.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-05-15 15:10:13 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-05-15 15:10:13 +0200
commit8e8185210f5bd87cb5dcda3a458fe059f811aafc (patch)
tree6c6e8783c20800df261d7e0e79aa276ead84d368 /src/main/java/com/c2kernel/utils/LocalObjectLoader.java
parent2ee6d3c6e816214892fdd541a9aae535686be788 (diff)
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
Diffstat (limited to 'src/main/java/com/c2kernel/utils/LocalObjectLoader.java')
-rw-r--r--src/main/java/com/c2kernel/utils/LocalObjectLoader.java28
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 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<Path> 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 {