From c78449fd2dee42ed340e5be702a42279b1856fc3 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 17 May 2013 16:48:52 +0200 Subject: Force order of imports to make sure roles and agents are in before items, so init push jobs will function. --- .../java/com/c2kernel/process/module/Module.java | 82 +++++++++++----------- 1 file changed, 40 insertions(+), 42 deletions(-) (limited to 'src/main/java/com/c2kernel/process/module/Module.java') 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) { -- cgit v1.2.3