return createWithOrWithoutUsers(mapping, form, req, resp, true);
}
// Creates duplicated user set with or without users
private ActionForward createWithOrWithoutUsers(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp, boolean includeUserAssignments) {
UserSetEnterOrEditForm userSetEnterOrEditForm = (UserSetEnterOrEditForm) form;
long originalUserSetId = userSetEnterOrEditForm.getOriginalId();
UserSetManager userSetManager = new UserSetManager(locale,session);
UserSet originalUserSet = userSetManager.getUserSet(originalUserSetId);
if (originalUserSet == null){
throw new InputException(getResources(req).getMessage(locale, "um.userSetNotFound", originalUserSetId));
}
checkAccessRights(req, originalUserSet.getGroup());
Group group = new GroupManager(locale,session).getGroup(userSetEnterOrEditForm.getGroupId());
boolean differentGroup = group != originalUserSet.getGroup();
if (includeUserAssignments && differentGroup && !userSetEnterOrEditForm.isConfirmationPending() && originalUserSet.getUsers().size() >= 1){
userSetEnterOrEditForm.setConfirmationPending(true);
String reallyDuplicate1 = getResources(req).getMessage(locale,"um.reallyDuplicate1");
String reallyDuplicate2 = getResources(req).getMessage(locale,"um.reallyDuplicate2");
req.setAttribute("generalError",reallyDuplicate1 + " " + originalUserSet.getUsers().size() + " " + reallyDuplicate2);
return mapping.findForward("confirm");
}
userSetEnterOrEditForm.setConfirmationPending(false);
UserSet newUserSet = userSetManager.duplicate(originalUserSet,group,userSetEnterOrEditForm.getUserSetName(),includeUserAssignments);
checkAccessRights(req, newUserSet.getGroup());
newUserSet.setDescription(userSetEnterOrEditForm.getDescription());
newUserSet.setHidden(userSetEnterOrEditForm.getHidden()==true?1:0);
userSetManager.modifyUserSet(newUserSet);
setCurrentGroup(req, resp, group); // switch group in global group selection
return mapping.findForward("created");
}