Search in sources :

Example 1 with UserForm

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";
}
Also used : DataGridZone(com.emc.metalnx.core.domain.entity.DataGridZone) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup) UserForm(com.emc.metalnx.modelattribute.user.UserForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with 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";
}
Also used : DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup) UserForm(com.emc.metalnx.modelattribute.user.UserForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DataGridGroup (com.emc.metalnx.core.domain.entity.DataGridGroup)2 UserForm (com.emc.metalnx.modelattribute.user.UserForm)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DataGridUser (com.emc.metalnx.core.domain.entity.DataGridUser)1 DataGridZone (com.emc.metalnx.core.domain.entity.DataGridZone)1