summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-03-06 16:32:29 +0100
committerAndrew Branson <andrew.branson@cern.ch>2014-03-06 16:32:29 +0100
commit7c341c90d5d45ddf4b868f7ccec91d9cdd23792f (patch)
treef0c0804e686854f9788ce649c97f962e5416e266
parent53040641471c131f759c932167bed79040c806c5 (diff)
Module resources get a 'Module' property set when they belong to a
particular module. If they belong to a particular module, they are moved into the correct sub-context for that module. If the resource is already set to a different module, and error occurs.
-rw-r--r--src/main/java/com/c2kernel/process/Bootstrap.java36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java
index 4f64adf..d472978 100644
--- a/src/main/java/com/c2kernel/process/Bootstrap.java
+++ b/src/main/java/com/c2kernel/process/Bootstrap.java
@@ -125,6 +125,33 @@ public class Bootstrap
else {
DomainPath path = (DomainPath)en.nextElement();
thisProxy = (ItemProxy)Gateway.getProxyManager().getProxy(path);
+
+ DomainPath modDomPath = getResourceDomPath(itemType, ns, itemName);
+ String moduleName = (ns==null?"kernel":ns);
+ String itemModule;
+ try{
+ itemModule = thisProxy.getProperty("Module");
+ if (!itemModule.equals("") && !itemModule.equals("null") && !moduleName.equals(itemModule)) {
+ Logger.error("Bootstrap.verifyResource() - Resource '"+itemName+"' included in module "+moduleName+" but is assigned to '"+itemModule+"'. Not overwriting.");
+ return;
+ }
+ } catch (ObjectNotFoundException ex) {
+ itemModule = "";
+ }
+
+ if (!moduleName.equals(itemModule)) { // write module property
+ Gateway.getStorage().put(thisProxy.getSystemKey(), new Property("Module", moduleName, false), null);
+ }
+
+ 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 EntityPath(thisProxy.getSystemKey()));
+ if (!modDomPath.exists())
+ Gateway.getLDAPLookup().add(modDomPath);
+ Gateway.getLDAPLookup().delete(path);
+ }
+
+
try {
Viewpoint currentData = (Viewpoint)thisProxy.getObject(ClusterStorage.VIEWPOINT+"/"+getDataType(itemType)+"/"+version);
Outcome oldData = currentData.getOutcome();
@@ -161,7 +188,12 @@ public class Bootstrap
Gateway.getStorage().commit(thisProxy);
}
- /**
+ private static DomainPath getResourceDomPath(String itemType, String ns,
+ String itemName) throws Exception {
+ return new DomainPath(getTypeRoot(itemType).toString()+"/system/"+(ns==null?"kernel":ns)+"/"+itemName);
+ }
+
+ /**
* @param itemType
* @param itemName
* @param data
@@ -195,7 +227,7 @@ public class Bootstrap
1,
Gateway.getMarshaller().marshall(props),
Gateway.getMarshaller().marshall(ca));
- DomainPath newDomPath = new DomainPath(getTypeRoot(itemType).toString()+"/system/"+(ns==null?"kernel":ns)+"/"+itemName);
+ DomainPath newDomPath = getResourceDomPath(itemType, ns, itemName);
newDomPath.setEntity(entityPath);
Gateway.getLDAPLookup().add(newDomPath);
return (ItemProxy)Gateway.getProxyManager().getProxy(entityPath);