Search in sources :

Example 6 with DataGridGroup

use of com.emc.metalnx.core.domain.entity.DataGridGroup in project metalnx-web by irods-contrib.

the class UserController method getGroupInfo.

/**
 * Finds all users existing in a group
 *
 * @param groupname
 * @param additionalInfo
 * @param model
 * @return
 * @throws DataGridConnectionRefusedException
 */
@RequestMapping(value = "getUsersInAGroup/{groupname}/{additionalInfo}", method = RequestMethod.GET)
public String getGroupInfo(@PathVariable String groupname, @PathVariable String additionalInfo, Model model) throws DataGridConnectionRefusedException {
    DataGridGroup dataGridGroup = groupService.findByGroupnameAndZone(groupname, additionalInfo);
    if (dataGridGroup == null) {
        model.addAttribute("users", new ArrayList<DataGridUser>());
        model.addAttribute("foundUsers", false);
        model.addAttribute("resultSize", 0);
        model.addAttribute("queryString", "");
    } else {
        List<DataGridUser> usersListOfAGroup = userService.findByDataGridIds(groupService.getMemberList(dataGridGroup));
        model.addAttribute("users", usersListOfAGroup);
        model.addAttribute("foundUsers", usersListOfAGroup.size() > 0);
        model.addAttribute("resultSize", usersListOfAGroup.size());
        model.addAttribute("queryString", "findAll");
    }
    return "users/userListOfAGroup :: userList";
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with DataGridGroup

use of com.emc.metalnx.core.domain.entity.DataGridGroup 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 8 with DataGridGroup

use of com.emc.metalnx.core.domain.entity.DataGridGroup in project metalnx-web by irods-contrib.

the class UserProfileController method showCreateForm.

@RequestMapping(value = "/create/")
public String showCreateForm(Model model) {
    UserProfileForm userProfileForm = new UserProfileForm();
    List<DataGridGroup> groups = groupService.findAll();
    groupIdsList = new ArrayList<String>();
    model.addAttribute("userProfileForm", userProfileForm);
    model.addAttribute("groups", groups);
    model.addAttribute("groupsOnProfileList", new String[0]);
    model.addAttribute("resultSize", groups.size());
    model.addAttribute("foundGroups", groups.size() > 0);
    model.addAttribute("requestMapping", "/users/profile/create/action/");
    return "userProfile/userProfileForm";
}
Also used : UserProfileForm(com.emc.metalnx.modelattribute.user.profile.UserProfileForm) DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup)

Example 9 with DataGridGroup

use of com.emc.metalnx.core.domain.entity.DataGridGroup in project metalnx-web by irods-contrib.

the class GroupController method groupsToCSVFile.

@RequestMapping(value = "/groupsToCSVFile/")
public void groupsToCSVFile(HttpServletResponse response) {
    String loggedUser = loggedUserUtils.getLoggedDataGridUser().getUsername();
    String date = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String filename = String.format("groups_%s_%s.csv", loggedUser, date);
    // Setting CSV Mime type
    response.setContentType("text/csv");
    response.setHeader("Content-disposition", "attachment;filename=" + filename);
    List<DataGridGroup> groups = groupService.findAll();
    List<String> rows = new ArrayList<String>();
    rows.add("Group name;Zone\n");
    for (DataGridGroup group : groups) {
        rows.add(group.getGroupname() + ";");
        rows.add(group.getAdditionalInfo());
        rows.add("\n");
    }
    try {
        ServletOutputStream outputStream = response.getOutputStream();
        // Writing CSV file
        Iterator<String> fileIterator = rows.iterator();
        while (fileIterator.hasNext()) {
            outputStream.print(fileIterator.next());
        }
        outputStream.flush();
    } catch (IOException e) {
        logger.error("Could not generate CSV file for groups", e);
    }
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) IOException(java.io.IOException) DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup) SimpleDateFormat(java.text.SimpleDateFormat)

Example 10 with DataGridGroup

use of com.emc.metalnx.core.domain.entity.DataGridGroup in project metalnx-web by irods-contrib.

the class GroupController method addGroup.

/**
 * Controller method that executes action 'create group'
 *
 * @param user
 * @return the name of the template to render
 * @throws DataGridConnectionRefusedException
 */
@RequestMapping(value = "add/action/", method = RequestMethod.POST)
public String addGroup(@ModelAttribute GroupForm groupForm, HttpServletRequest httpServletRequest, RedirectAttributes redirectAttributes) throws DataGridConnectionRefusedException {
    DataGridGroup newGroup = new DataGridGroup();
    newGroup.setGroupname(groupForm.getGroupname());
    newGroup.setAdditionalInfo(groupForm.getAdditionalInfo());
    // Get the list of users to be attached to the group
    String[] idsList = usersToBeAdded.toArray(new String[usersToBeAdded.size()]);
    List<DataGridUser> usersToBeAttached = new ArrayList<DataGridUser>();
    if (idsList != null && idsList.length != 0) {
        usersToBeAttached = userService.findByDataGridIds(idsList);
    }
    if (groupService.createGroup(newGroup, usersToBeAttached) == false) {
        return "redirect:/groups/add/";
    }
    // Updating permissions on collections
    // boolean recursive = false;
    groupService.updateReadPermissions(newGroup, addReadPermissionsOnDirs, removeReadPermissionsOnDirs);
    groupService.updateWritePermissions(newGroup, addWritePermissionsOnDirs, removeWritePermissionsOnDirs);
    groupService.updateOwnership(newGroup, addOwnerOnDirs, removeOwnerOnDirs);
    // Setting the Group's home collection as a bookmark by default
    bookmarkController.addPathAsGroupBookmark(groupService.getGroupCollectionPath(newGroup.getGroupname()));
    // Updating bookmarks
    updateBookmarksList(newGroup.getGroupname());
    redirectAttributes.addFlashAttribute("groupAddedSuccessfully", groupForm.getGroupname());
    collectionService.updateInheritanceOptions(addInheritanceOnDirs, removeInheritanceOnDirs, newGroup.getAdditionalInfo());
    cleanModificationSets();
    currentGroup = null;
    return "redirect:/groups/";
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup)

Aggregations

DataGridGroup (com.emc.metalnx.core.domain.entity.DataGridGroup)23 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 DataGridUser (com.emc.metalnx.core.domain.entity.DataGridUser)6 UserProfile (com.emc.metalnx.core.domain.entity.UserProfile)5 ArrayList (java.util.ArrayList)4 JargonException (org.irods.jargon.core.exception.JargonException)4 HashSet (java.util.HashSet)3 Query (org.hibernate.Query)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)2 UserForm (com.emc.metalnx.modelattribute.user.UserForm)2 UserProfileForm (com.emc.metalnx.modelattribute.user.profile.UserProfileForm)2 HashMap (java.util.HashMap)2 DuplicateDataException (org.irods.jargon.core.exception.DuplicateDataException)2 UserGroupAO (org.irods.jargon.core.pub.UserGroupAO)2 User (org.irods.jargon.core.pub.domain.User)2 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)1 DataGridZone (com.emc.metalnx.core.domain.entity.DataGridZone)1 DataGridPermType (com.emc.metalnx.core.domain.entity.enums.DataGridPermType)1 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)1