}
private void prepareContentForUserSetList(ActionForm form, HttpServletRequest req, Session session,String filter) {
UserSetAssignmentListForm userSetAssignmentListForm = (UserSetAssignmentListForm) form;
UserSetManager userSetManager = new UserSetManager(locale, session);
UserSet userSet = userSetManager.getUserSet(userSetAssignmentListForm.getUserSetId());
if (userSet == null) {
String msg = getResources(req).getMessage("um.userSetNotFound", req.getParameter("id"));
LOGGER.error(msg);
throw new InputException(msg);
}
if (!userSet.getGroup().equals(getCurrentGroup(req))) {
// due to global group selection, userset should be in current group
throw new InputException(getResources(req).getMessage("um.userSetNotInCurrentGroup"));
}
checkAccessRights(req, userSet.getGroup());
Group currentGroup = getCurrentGroup(req);
// fetch the list of users
int pageNumber = 1; // default page size
if(req.getParameter("page") != null){
pageNumber = Integer.parseInt(req.getParameter("page"));
}
String sortCriterion = "username"; // default sort criterion
if(req.getParameter("sort") != null){
sortCriterion = req.getParameter("sort");
}
SortOrderEnum sortOrderDisplayTag = SortOrderEnum.ASCENDING; // default
evolaris.framework.database.util.SortOrderEnum sortOrderDb = evolaris.framework.database.util.SortOrderEnum.asc;
if(req.getParameter("dir") != null){
String order = req.getParameter("dir");
if("asc".equals(order)){
sortOrderDisplayTag = SortOrderEnum.ASCENDING;
sortOrderDb = evolaris.framework.database.util.SortOrderEnum.asc;
} else {
sortOrderDisplayTag = SortOrderEnum.DESCENDING;
sortOrderDb = evolaris.framework.database.util.SortOrderEnum.desc;
}
}
User[] users = null;
int listFullSize = 0; // the size of the complete result list used for paging
Hibernate.initialize(userSet); // used to fetch the data from db
userSetAssignmentListForm.setUserSetName(userSet.getName());
userSetAssignmentListForm.setUserSetId(userSet.getId());
String[] choosenUsers = null;
if(userSetAssignmentListForm.getDisplayAll() != null && userSetAssignmentListForm.getDisplayAll()){
GroupManager groupMgm = new GroupManager(locale,session);
users = groupMgm.getUsers(currentGroup, pageNumber, PAGE_SIZE, sortCriterion, sortOrderDb,true,filter);
listFullSize = groupMgm.getUsers(currentGroup,true,filter).length;
// create a list containing all users for which the check box should be selected
choosenUsers = new String[users.length];
for(int i=0;i<users.length;i++){
if(userSetManager.isUserInUserset(userSet, users[i])){
choosenUsers[i]= String.valueOf(users[i].getId());
}
}
} else {
users = userSetManager.getUsers(userSet, pageNumber, PAGE_SIZE, sortCriterion, sortOrderDb,filter);
listFullSize = userSetManager.getUsers(userSet,filter).length;
// create a list containing all users for which the check box should be selected
choosenUsers = new String[users.length];
for(int i=0;i<users.length;i++){
choosenUsers[i]= String.valueOf(users[i].getId());
}