diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2013-05-17 16:48:52 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2013-05-17 16:48:52 +0200 |
| commit | c78449fd2dee42ed340e5be702a42279b1856fc3 (patch) | |
| tree | 1de4a39749aa7a4fac5d2ca76357c36c163c0c36 /src/main/java/com/c2kernel/process/module/Module.java | |
| parent | be9aa9c636204051381f4efe4b895dff968f0c4d (diff) | |
Force order of imports to make sure roles and agents are in before
items, so init push jobs will function.
Diffstat (limited to 'src/main/java/com/c2kernel/process/module/Module.java')
| -rw-r--r-- | src/main/java/com/c2kernel/process/module/Module.java | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/src/main/java/com/c2kernel/process/module/Module.java b/src/main/java/com/c2kernel/process/module/Module.java index 33180ae..16f2c29 100644 --- a/src/main/java/com/c2kernel/process/module/Module.java +++ b/src/main/java/com/c2kernel/process/module/Module.java @@ -77,52 +77,50 @@ public class Module { public void importAll(ItemProxy serverEntity, String moduleXML) throws Exception {
addModuleItem(moduleXML);
int systemAgentId = Gateway.getLDAPLookup().getRoleManager().getAgentPath("system").getSysKey();
- for (ModuleImport thisImp : imports.list) {
- Logger.msg(1, "Checking for "+thisImp.name+" "+thisImp.getClass().getSimpleName());
- if (thisImp instanceof ModuleResource) {
- ModuleResource thisRes = (ModuleResource)thisImp;
- try {
- Bootstrap.verifyResource(ns, thisRes.name, thisRes.resourceType, Resource.getTextResource(ns, thisRes.resourceLocation));
- } catch (Exception ex) {
- Logger.error(ex);
- }
- }
- else if (thisImp instanceof NewItem) {
- NewItem thisItem = (NewItem)thisImp;
- thisItem.setNamespace(ns);
- try {
- new DomainPath(new DomainPath(thisItem.initialPath), thisItem.name).getEntity();
- Logger.msg(3, "Module.importAll() - Item '"+thisItem.name+"' found.");
- continue;
- } catch (ObjectNotFoundException ex) { }
- Logger.msg("Module.importAll() - Item '"+thisItem.name+"' not found. Creating.");
- thisItem.create(systemAgentId);
+
+ for (ModuleResource thisRes : imports.getResources()) {
+ try {
+ Bootstrap.verifyResource(ns, thisRes.name, thisRes.resourceType, Resource.getTextResource(ns, thisRes.resourceLocation));
+ } catch (Exception ex) {
+ Logger.error(ex);
}
- else if (thisImp instanceof NewRole) {
- NewRole thisRole = (NewRole)thisImp;
- RolePath rolePath;
- try {
- rolePath = Gateway.getLDAPLookup().getRoleManager().getRolePath(thisRole.name);
- if (rolePath.hasJobList() != thisRole.jobList) {
- Logger.msg("Module.importAll() - Role '"+thisRole.name+"' has incorrect joblist settings. Correcting.");
- rolePath.setHasJobList(thisRole.jobList);
- }
- } catch (ObjectNotFoundException ex) {
- Logger.msg("Module.importAll() - Role '"+thisRole.name+"' not found. Creating.");
- thisRole.create(systemAgentId);
+ }
+
+ for (NewRole thisRole : imports.getRoles()) {
+ RolePath rolePath;
+ try {
+ rolePath = Gateway.getLDAPLookup().getRoleManager().getRolePath(thisRole.name);
+ if (rolePath.hasJobList() != thisRole.jobList) {
+ Logger.msg("Module.importAll() - Role '"+thisRole.name+"' has incorrect joblist settings. Correcting.");
+ rolePath.setHasJobList(thisRole.jobList);
}
+ } catch (ObjectNotFoundException ex) {
+ Logger.msg("Module.importAll() - Role '"+thisRole.name+"' not found. Creating.");
+ thisRole.create(systemAgentId);
}
- else if (thisImp instanceof NewAgent) {
- NewAgent thisAgent = (NewAgent)thisImp;
- try {
- Gateway.getLDAPLookup().getRoleManager().getAgentPath(thisAgent.name);
- Logger.msg(3, "Module.importAll() - User '"+thisAgent.name+"' found.");
- continue;
- } catch (ObjectNotFoundException ex) { }
- Logger.msg("Module.importAll() - User '"+thisAgent.name+"' not found. Creating.");
- thisAgent.create(systemAgentId);
- }
}
+
+ for (NewAgent thisAgent : imports.getAgents()) {
+ try {
+ Gateway.getLDAPLookup().getRoleManager().getAgentPath(thisAgent.name);
+ Logger.msg(3, "Module.importAll() - User '"+thisAgent.name+"' found.");
+ continue;
+ } catch (ObjectNotFoundException ex) { }
+ Logger.msg("Module.importAll() - User '"+thisAgent.name+"' not found. Creating.");
+ thisAgent.create(systemAgentId);
+ }
+
+ for (NewItem thisItem : imports.getItems()) {
+ thisItem.setNamespace(ns);
+ try {
+ new DomainPath(new DomainPath(thisItem.initialPath), thisItem.name).getEntity();
+ Logger.msg(3, "Module.importAll() - Item '"+thisItem.name+"' found.");
+ continue;
+ } catch (ObjectNotFoundException ex) { }
+ Logger.msg("Module.importAll() - Item '"+thisItem.name+"' not found. Creating.");
+ thisItem.create(systemAgentId);
+ }
+
}
public Properties getProperties(boolean isServer) {
|
