}
public void removeRoles(EntityReference ref, Map<String, Object> inputVar, Context context) {
try {
Integer id = Integer.parseInt(ref.getId());
Collection collection = Collection.find(context, id);
if (collection != null) {
int act = Utils.getActionRole((String) inputVar.get("eid"));
switch (act) {
case 1: {
Group group = collection.getAdministrators();
if (group != null) {
collection.removeAdministrators();
collection.update();
group.delete();
}
break;
}
case 2: {
Group group = collection.getSubmitters();
if (group != null) {
collection.removeSubmitters();
collection.update();
group.delete();
}
break;
}
case 4:
case 5:
case 6: {
Group group = collection.getWorkflowGroup(act - 3);
if (group != null) {
AuthorizeUtil.authorizeManageWorkflowsGroup(context, collection);
collection.setWorkflowGroup(act - 3,null);
collection.update();
group.delete();
}
break;
}
}
} else {
throw new EntityException("Not found", "Entity not found", 404);
}
} catch (SQLException ex) {
throw new EntityException("Internal server error", "SQL error", 500);
} catch (AuthorizeException ae) {
throw new EntityException("Forbidden", "Forbidden", 403);
} catch (NumberFormatException ex) {
throw new EntityException("Bad request", "Could not parse input", 400);
}
try {
Integer elid = Integer.parseInt((String) inputVar.get("id"));
Collection col = Collection.find(context, elid);
if ((col != null)) {
col.removeAdministrators();
}
} catch (SQLException ex) {
throw new EntityException("Internal server error", "SQL error", 500);
} catch (AuthorizeException ae) {
throw new EntityException("Forbidden", "Forbidden", 403);