@OptionAnnotation(value = "-du", min = 2, extra = MAX_ARG_VALUE)
public void deleteUserSet(final OptionInfo oi) throws JGDIException {
List<JGDIAnswer> answer = new LinkedList<JGDIAnswer>();
final List<String> setList = oi.getLastOriginalArgList();
final List<String> userList = oi.getArgs();
UserSet obj;
//This is the only call we want to make
oi.optionDone();
if (userList.size() == 0) {
//We are missing the set list and used usernames as sets
String msg = getErrorMessage("LessArguments", oi.getOd().getOption(), new ArrayList(setList));
throw new JGDIException(msg, getCustomExitCode("LessArguments", oi.getOd().getOption()));
}
//We delete form all the sets
for (String set : setList) {
obj = jgdi.getUserSetWithAnswer(set, answer);
printAnswers(answer);
answer.clear();
if (obj == null) {
err.println(getErrorMessage("InvalidObjectArgument", oi.getOd().getOption(), set));
setExitCode(getCustomExitCode("InvalidObjectArgument", oi.getOd().getOption()));
//TODO LP: Missing message about invalid name
continue;
}
for (String user: userList) {
//TODO LP: CR XXXXXX addEntries curently add already existing elements
//Also messages are coming from the client!
//user "user3" is not in access list "set1"
//deleted user "user3" from access list "set2"
obj.removeEntries(user);
}
jgdi.updateUserSetWithAnswer(obj, answer);
printAnswers(answer);
answer.clear();
}