use of com.emc.metalnx.modelattribute.user.UserForm in project metalnx-web by irods-contrib.
the class UserController method showModifyUserForm.
/**
* Controller that shows the modification of user view.
*
* @param username
* @param additionalInfo
* @param model
* @return the template name to render the modify user form
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "modify/{username}/{additionalInfo}/", method = RequestMethod.GET)
public String showModifyUserForm(@PathVariable String username, @PathVariable String additionalInfo, Model model) throws DataGridConnectionRefusedException {
DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, additionalInfo);
List<DataGridGroup> groups = groupService.findAll();
List<DataGridZone> zones = zoneService.findAll();
if (user != null) {
UserForm userForm = new UserForm();
// iRODS data
userForm.setDataGridId(user.getDataGridId());
userForm.setUsername(user.getUsername());
userForm.setAdditionalInfo(user.getAdditionalInfo());
userForm.setUserProfile(user.getUserProfile());
userForm.setOrganizationalRole(user.getOrganizationalRole());
userForm.setUserType(user.getUserType());
// our data
if (user.getEmail() != null) {
userForm.setEmail(user.getEmail());
}
if (user.getFirstName() != null) {
userForm.setFirstName(user.getFirstName());
}
if (user.getLastName() != null) {
userForm.setLastName(user.getLastName());
}
if (user.getCompany() != null) {
userForm.setCompany(user.getCompany());
}
if (user.getDepartment() != null) {
userForm.setDepartment(user.getDepartment());
}
// Getting the list of groups the user belongs to
String[] groupList = userService.getGroupIdsForUser(user);
groupsToBeAdded = new ArrayList<String>(Arrays.asList(groupList));
model.addAttribute("user", userForm);
model.addAttribute("groupList", groupList);
model.addAttribute("requestMapping", "/users/modify/action/");
model.addAttribute("addReadPermissionsOnDirs", addReadPermissionsOnDirs);
model.addAttribute("addWritePermissionsOnDirs", addWritePermissionsOnDirs);
model.addAttribute("addOwnerOnDirs", addOwnerOnDirs);
}
model.addAttribute("profiles", userProfileService.findAll());
model.addAttribute("groups", groups);
model.addAttribute("zones", zones);
model.addAttribute("userZone", additionalInfo);
model.addAttribute("userTypes", userService.listUserTypes());
return "users/userForm";
}
use of com.emc.metalnx.modelattribute.user.UserForm in project metalnx-web by irods-contrib.
the class UserController method showAddUserForm.
/**
* Responds the request for the url "add/". It adds a new UserForm to the Model
* and sets the form's action to "add".
*
* @param model
* @return the userForm template
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "add/", method = RequestMethod.GET)
public String showAddUserForm(Model model) throws DataGridConnectionRefusedException {
String[] groupsList = new String[1];
groupsToBeAdded = new ArrayList<String>();
String currentZone = irodsServices.getCurrentUserZone();
DataGridGroup publicGroup = groupService.findByGroupnameAndZone("public", currentZone);
groupsList[0] = String.valueOf(publicGroup.getDataGridId());
model.addAttribute("addReadPermissionsOnDirs", addReadPermissionsOnDirs);
model.addAttribute("addWritePermissionsOnDirs", addWritePermissionsOnDirs);
model.addAttribute("addOwnerOnDirs", addOwnerOnDirs);
model.addAttribute("user", new UserForm());
model.addAttribute("groups", groupService.findAll());
model.addAttribute("zones", zoneService.findAll());
model.addAttribute("userZone", "");
model.addAttribute("groupList", groupsList);
model.addAttribute("requestMapping", "/users/add/action/");
model.addAttribute("profiles", userProfileService.findAll());
model.addAttribute("userTypes", userService.listUserTypes());
return "users/userForm";
}
Aggregations