diff options
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java')
| -rw-r--r-- | src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java index 44000c6..ec3071b 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java @@ -42,22 +42,21 @@ public class RemoveRole extends PredefinedStep throw new InvalidDataException(e.getMessage(), "");
}
- RolePath thisRole;
+ RolePath thisRole; AgentPath[] agents;
try {
thisRole = lookup.getRolePath(params[0]);
+ agents = Gateway.getLookup().getAgents(thisRole);
} catch (ObjectNotFoundException e) {
throw new InvalidDataException("Role "+params[0]+" not found.", "");
}
- AgentPath[] agents = thisRole.getAgentsWithRole();
+
if (agents.length > 0)
throw new InvalidDataException("Cannot remove role. "+agents.length+" agents still hold it.", "");
try {
- lookup.removeRole(agent, thisRole);
+ lookup.delete(thisRole);
} catch (ObjectCannotBeUpdated e) {
Logger.error(e);
throw new InvalidDataException("Role "+params[0]+" could not be removed.", "");
- } catch (ObjectNotFoundException e) {
- throw new InvalidDataException("Role "+params[0]+" not found.", "");
}
return requestData;
|
