Search in sources :

Example 6 with DataGridUser

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

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

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

the class UserController method listUsersByPageAndQuery.

/**
 * List users by page number
 *
 * @param model
 * @return
 */
@RequestMapping(value = "/find/{query}/")
public String listUsersByPageAndQuery(Model model, @PathVariable String query) {
    List<DataGridUser> users = userService.findByQueryString(query);
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    String usernameLogged = (String) auth.getPrincipal();
    model.addAttribute("usernameLogged", usernameLogged);
    model.addAttribute("users", users);
    model.addAttribute("queryString", query);
    return "users/userList :: userList";
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) Authentication(org.springframework.security.core.Authentication) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with DataGridUser

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

the class UserBookmarkController method bookmarksPaginated.

@RequestMapping(value = "/bookmarksPaginated")
@ResponseBody
public String bookmarksPaginated(final HttpServletRequest request) {
    int draw = Integer.parseInt(request.getParameter("draw"));
    int start = Integer.parseInt(request.getParameter("start"));
    int length = Integer.parseInt(request.getParameter("length"));
    String searchString = request.getParameter("search[value]");
    int orderColumn = Integer.parseInt(request.getParameter("order[0][column]"));
    String orderDir = request.getParameter("order[0][dir]");
    boolean onlyCollections = Boolean.parseBoolean(request.getParameter("onlyCollections"));
    String loggedUsername = irodsServices.getCurrentUser();
    String loggedUserZoneName = irodsServices.getCurrentUserZone();
    DataGridUser user = userService.findByUsernameAndAdditionalInfo(loggedUsername, loggedUserZoneName);
    String[] orderBy = { "name", "path", "created_at", "is_collection" };
    // checking if there is another column to order by
    boolean has2ndColumnToOrderBy = request.getParameter("order[1][column]") != null;
    List<DataGridUserBookmark> userBookmarks = null;
    if (has2ndColumnToOrderBy) {
        List<String> orderByList = new ArrayList<String>();
        List<String> orderDirList = new ArrayList<String>();
        int firstCol = Integer.parseInt(request.getParameter("order[0][column]"));
        int secondCol = Integer.parseInt(request.getParameter("order[1][column]"));
        orderByList.add(orderBy[firstCol]);
        orderDirList.add(request.getParameter("order[0][dir]"));
        orderByList.add(orderBy[secondCol]);
        orderDirList.add(request.getParameter("order[1][dir]"));
        userBookmarks = userBookmarkService.findBookmarksPaginated(user, start, length, searchString, orderByList, orderDirList, onlyCollections);
    } else {
        userBookmarks = userBookmarkService.findBookmarksPaginated(user, start, length, searchString, orderBy[orderColumn], orderDir, onlyCollections);
    }
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> jsonResponse = new HashMap<String, Object>();
    String jsonString = "";
    if ("".equals(searchString)) {
        totalUserBookmarks = user.getBookmarks().size();
        totalUserBookmarksFiltered = user.getBookmarks().size();
    } else {
        totalUserBookmarksFiltered = userBookmarks.size();
    }
    jsonResponse.put("draw", String.valueOf(draw));
    jsonResponse.put("recordsTotal", String.valueOf(totalUserBookmarks));
    jsonResponse.put("recordsFiltered", String.valueOf(totalUserBookmarksFiltered));
    jsonResponse.put("data", userBookmarks);
    try {
        jsonString = mapper.writeValueAsString(jsonResponse);
    } catch (JsonProcessingException e) {
        logger.error("Could not parse user bookmarks to json: {}", e.getMessage());
    }
    return jsonString;
}
Also used : HashMap(java.util.HashMap) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) ArrayList(java.util.ArrayList) DataGridUserBookmark(com.emc.metalnx.core.domain.entity.DataGridUserBookmark) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 10 with DataGridUser

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

the class UserBookmarkController method removeBookmarkFromGroup.

@RequestMapping(value = "/removeBookmarkFromUser/")
@ResponseBody
public String removeBookmarkFromGroup(@RequestParam("username") final String username, @RequestParam("path") final String path) {
    logger.info("removeBookmarkFromGroup()");
    logger.info("Request for removing a {} bookmark from {}", path, username);
    String zoneName = irodsServices.getCurrentUserZone();
    DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, zoneName);
    if (user == null) {
        return REQUEST_ERROR;
    }
    Set<String> toRemove = new HashSet<String>();
    toRemove.add(path);
    return userBookmarkService.updateBookmarks(user, null, toRemove) ? REQUEST_OK : REQUEST_ERROR;
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) HashSet(java.util.HashSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

DataGridUser (com.emc.metalnx.core.domain.entity.DataGridUser)48 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)28 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)8 JargonException (org.irods.jargon.core.exception.JargonException)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 DataGridGroup (com.emc.metalnx.core.domain.entity.DataGridGroup)5 User (org.irods.jargon.core.pub.domain.User)5 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)4 HashMap (java.util.HashMap)4 Query (org.hibernate.Query)4 UserAO (org.irods.jargon.core.pub.UserAO)4 Authentication (org.springframework.security.core.Authentication)4 UserProfile (com.emc.metalnx.core.domain.entity.UserProfile)3 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 DataGridUserBookmark (com.emc.metalnx.core.domain.entity.DataGridUserBookmark)2 DataGridUserFavorite (com.emc.metalnx.core.domain.entity.DataGridUserFavorite)2 URLMap (com.emc.metalnx.modelattribute.enums.URLMap)2 GroupForm (com.emc.metalnx.modelattribute.group.GroupForm)2