summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/process
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/process')
-rw-r--r--src/main/java/com/c2kernel/process/Bootstrap.java32
-rw-r--r--src/main/java/com/c2kernel/process/module/Module.java5
2 files changed, 20 insertions, 17 deletions
diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java
index 0f06616..e269e09 100644
--- a/src/main/java/com/c2kernel/process/Bootstrap.java
+++ b/src/main/java/com/c2kernel/process/Bootstrap.java
@@ -281,7 +281,7 @@ public class Bootstrap
/**************************************************************************
* Checks for the existence of the admin users so you can use Cristal
**************************************************************************/
- private static void checkAgent(String name, String pass, String role, UUID uuid, boolean joblist) throws Exception {
+ private static void checkAgent(String name, String pass, RolePath rolePath, UUID uuid) throws Exception {
Logger.msg(1, "Bootstrap.checkAgent() - Checking for existence of '"+name+"' user.");
LookupManager lookup = Gateway.getLookupManager();
@@ -293,13 +293,6 @@ public class Bootstrap
Logger.msg("Bootstrap.checkAgent() - User '"+name+"' not found. Creating.");
- RolePath rolePath;
- try {
- rolePath = lookup.getRolePath(role);
- } catch (ObjectNotFoundException ex) {
- rolePath = lookup.createRole(role, joblist);
- }
-
try {
AgentPath agentPath = new AgentPath(new ItemPath(uuid), name);
agentPath.setPassword(pass);
@@ -307,8 +300,8 @@ public class Bootstrap
lookup.add(agentPath);
// assign admin role
- Logger.msg("Bootstrap.checkAgent() - Assigning role '"+role+"'");
- rolePath.addAgent(agentPath);
+ Logger.msg("Bootstrap.checkAgent() - Assigning role '"+rolePath.getName()+"'");
+ Gateway.getLookupManager().addRole(agentPath, rolePath);
Gateway.getStorage().put(agentPath, new Property("Name", name, true), null);
Gateway.getStorage().put(agentPath, new Property("Type", "Agent", false), null);
systemAgents.put(name, Gateway.getProxyManager().getAgentProxy(agentPath));
@@ -322,16 +315,23 @@ public class Bootstrap
*
*/
public static void checkAdminAgents() throws Exception {
- // check for administrative user
+
+ // check for administrative user & admin role
String adminPassword = Gateway.getProperties().getString("AdminPassword", "admin12345");
-
+ RolePath rootRole = new RolePath();
+ if (!rootRole.exists()) Gateway.getLookupManager().createRole(rootRole);
+ RolePath adminRole = new RolePath(rootRole, "Admin", false);
+ if (!adminRole.exists()) Gateway.getLookupManager().createRole(adminRole);
+
// check for import user
- checkAgent("system", adminPassword, "Admin", new UUID(0, 0), false);
+ checkAgent("system", adminPassword, adminRole, new UUID(0, 0));
- checkAgent("admin", adminPassword, "Admin", new UUID(0, 1), false);
+ checkAgent("admin", adminPassword, adminRole, new UUID(0, 1));
- // check for local usercode user
- checkAgent(InetAddress.getLocalHost().getHostName(), "uc", "UserCode", UUID.randomUUID(), true);
+ // check for local usercode user & role
+ RolePath usercodeRole = new RolePath(rootRole, "UserCode", true);
+ if (!usercodeRole.exists()) Gateway.getLookupManager().createRole(usercodeRole);
+ checkAgent(InetAddress.getLocalHost().getHostName(), "uc", usercodeRole, UUID.randomUUID());
}
public static void createServerItem() throws Exception {
diff --git a/src/main/java/com/c2kernel/process/module/Module.java b/src/main/java/com/c2kernel/process/module/Module.java
index 2f4592f..9a54944 100644
--- a/src/main/java/com/c2kernel/process/module/Module.java
+++ b/src/main/java/com/c2kernel/process/module/Module.java
@@ -99,10 +99,13 @@ public class Module extends ImportItem {
for (ImportRole thisRole : imports.getRoles()) {
RolePath rolePath;
try {
- rolePath = Gateway.getLookup().getRolePath(thisRole.name);
+ String roleName = thisRole.name;
+ if (roleName.indexOf('/') > -1) roleName = roleName.substring(roleName.indexOf('/')+1);
+ rolePath = Gateway.getLookup().getRolePath(roleName);
if (rolePath.hasJobList() != thisRole.hasJobList()) {
Logger.msg("Module.importAll() - Role '"+thisRole.name+"' has incorrect joblist settings. Correcting.");
rolePath.setHasJobList(thisRole.hasJobList());
+ Gateway.getLookupManager().createRole(rolePath);
}
} catch (ObjectNotFoundException ex) {
Logger.msg("Module.importAll() - Role '"+thisRole.name+"' not found. Creating.");