Search in sources :

Example 1 with DataGridGroupBookmark

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

the class GroupBookmarkServiceImpl method findBookmarksForGroupAsString.

@Override
public List<String> findBookmarksForGroupAsString(DataGridGroup group) {
    List<DataGridGroupBookmark> bookmarks = groupBookmarkDao.findByGroup(group);
    List<String> strings = new ArrayList<String>();
    for (DataGridGroupBookmark bookmark : bookmarks) {
        strings.add(bookmark.getPath());
    }
    Collections.sort(strings);
    return strings;
}
Also used : DataGridGroupBookmark(com.emc.metalnx.core.domain.entity.DataGridGroupBookmark) ArrayList(java.util.ArrayList)

Example 2 with DataGridGroupBookmark

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

the class GroupBookmarkController method listGroupsByQueryPaginatedModel.

@RequestMapping(value = "/groupsBookmarksPaginated")
@ResponseBody
public String listGroupsByQueryPaginatedModel(final HttpServletRequest request) throws DataGridConnectionRefusedException {
    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 currentUser = irodsServices.getCurrentUser();
    String currentZone = irodsServices.getCurrentUserZone();
    String[] orderBy = { "Dggb.name", "Dggb.path", "Dgg.groupname", "Dggb.createTs" };
    List<DataGridGroupBookmark> groupBookmarks = null;
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> jsonResponse = new HashMap<String, Object>();
    String jsonString = "";
    try {
        groupBookmarks = groupBookmarkService.getGroupsBookmarksPaginated(currentUser, currentZone, start, length, searchString, orderBy[orderColumn], orderDir, onlyCollections);
        if ("".equals(searchString)) {
            totalGroupBookmarks = groupBookmarkService.countTotalGroupBookmarks(currentUser, currentZone);
            totalGroupBookmarksFiltered = totalGroupBookmarks;
        } else {
            totalGroupBookmarksFiltered = groupBookmarks.size();
        }
    } catch (JargonException e) {
        logger.error("Could not get groups bookmarks for {}", currentUser);
        groupBookmarks = new ArrayList<DataGridGroupBookmark>();
    }
    jsonResponse.put("draw", String.valueOf(draw));
    jsonResponse.put("recordsTotal", String.valueOf(totalGroupBookmarks));
    jsonResponse.put("recordsFiltered", String.valueOf(totalGroupBookmarksFiltered));
    jsonResponse.put("data", groupBookmarks);
    try {
        jsonString = mapper.writeValueAsString(jsonResponse);
    } catch (Exception e) {
        logger.error("Could not parse hashmap in favorites to json", e.getMessage());
    }
    return jsonString;
}
Also used : DataGridGroupBookmark(com.emc.metalnx.core.domain.entity.DataGridGroupBookmark) HashMap(java.util.HashMap) JargonException(org.irods.jargon.core.exception.JargonException) ArrayList(java.util.ArrayList) DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) JargonException(org.irods.jargon.core.exception.JargonException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with DataGridGroupBookmark

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

the class PermissionsController method getPermissionDetails.

/**
 * Gives permission details related to a collection or file that is passed as a
 * parameter
 *
 * @param model
 * @param path
 * @return
 * @throws DataGridConnectionRefusedException
 * @throws JargonException
 * @throws FileNotFoundException
 */
@RequestMapping(value = "/getPermissionDetails/", method = RequestMethod.POST)
public String getPermissionDetails(final Model model, @RequestParam("path") final String path) throws DataGridConnectionRefusedException {
    logger.debug("Getting permission info for {}", path);
    DataGridCollectionAndDataObject obj = null;
    List<DataGridFilePermission> permissions;
    List<DataGridGroupPermission> groupPermissions;
    List<DataGridUserPermission> userPermissions;
    List<DataGridGroupBookmark> bookmarks;
    List<DataGridUserBookmark> userBookmarks;
    Set<String> groupsWithBookmarks;
    Set<String> usersWithBookmarks;
    boolean userCanModify = false;
    boolean isCollection = false;
    try {
        loggedUser = luu.getLoggedDataGridUser();
        permissions = ps.getPathPermissionDetails(path);
        groupPermissions = ps.getGroupsWithPermissions(permissions);
        userPermissions = ps.getUsersWithPermissions(permissions);
        bookmarks = gBMS.findBookmarksOnPath(path);
        userBookmarks = uBMS.findBookmarksOnPath(path);
        userCanModify = loggedUser.isAdmin() || ps.canLoggedUserModifyPermissionOnPath(path);
        groupsWithBookmarks = new HashSet<>();
        for (DataGridGroupBookmark bookmark : bookmarks) {
            groupsWithBookmarks.add(bookmark.getGroup().getGroupname());
        }
        usersWithBookmarks = new HashSet<>();
        for (DataGridUserBookmark userBookmark : userBookmarks) {
            usersWithBookmarks.add(userBookmark.getUser().getUsername());
        }
        obj = cs.findByName(path);
        ps.resolveMostPermissiveAccessForUser(obj, loggedUser);
    } catch (Exception e) {
        logger.error("Could not get permission details {}: {}", path, e.getMessage());
        groupPermissions = new ArrayList<>();
        userPermissions = new ArrayList<>();
        groupsWithBookmarks = new HashSet<>();
        usersWithBookmarks = new HashSet<>();
    }
    model.addAttribute("usersWithBookmarks", usersWithBookmarks);
    model.addAttribute("groupsWithBookmark", groupsWithBookmarks);
    model.addAttribute("groupPermissions", groupPermissions);
    model.addAttribute("userPermissions", userPermissions);
    model.addAttribute("userCanModify", userCanModify);
    model.addAttribute("permissions", PERMISSIONS);
    model.addAttribute("permissionsWithoutNone", PERMISSIONS_WITHOUT_NONE);
    model.addAttribute("collectionAndDataObject", obj);
    model.addAttribute("isCollection", isCollection);
    model.addAttribute("permissionOnCurrentPath", cs.getPermissionsForPath(path));
    model.addAttribute("permissionFlag", true);
    System.out.println("permissionOnCurrentPath =======" + cs.getPermissionsForPath(path));
    System.out.println("------Permission Conroller - /getPermissionDetail/ ends------");
    return "permissions/permissionDetails :: permissionDetails";
}
Also used : DataGridGroupPermission(com.emc.metalnx.core.domain.entity.DataGridGroupPermission) DataGridUserPermission(com.emc.metalnx.core.domain.entity.DataGridUserPermission) DataGridGroupBookmark(com.emc.metalnx.core.domain.entity.DataGridGroupBookmark) ArrayList(java.util.ArrayList) DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) FileNotFoundException(org.irods.jargon.core.exception.FileNotFoundException) JargonException(org.irods.jargon.core.exception.JargonException) DataGridUserBookmark(com.emc.metalnx.core.domain.entity.DataGridUserBookmark) DataGridFilePermission(com.emc.metalnx.core.domain.entity.DataGridFilePermission) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) HashSet(java.util.HashSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with DataGridGroupBookmark

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

the class GroupBookmarkServiceImpl method getGroupsBookmarksPaginated.

@Override
public List<DataGridGroupBookmark> getGroupsBookmarksPaginated(String user, String additionalInfo, int offset, int limit, String searchString, String orderBy, String orderDir, boolean onlyCollections) throws DataGridConnectionRefusedException, DataNotFoundException, JargonException {
    List<DataGridGroupBookmark> groupBookmarks = new ArrayList<DataGridGroupBookmark>();
    if (user == null || additionalInfo == null || user.isEmpty() || additionalInfo.isEmpty()) {
        logger.error("Could not get groups bookmarks. Username or zone empty");
        return groupBookmarks;
    }
    logger.info("Get groups bookmarks for {}", user);
    UserAO userAO = adminServices.getUserAO();
    User iRodsUser = userAO.findByName(user);
    if (iRodsUser != null) {
        String[] groupIds = userService.getGroupIdsForUser(user, additionalInfo);
        groupBookmarks = groupBookmarkDao.findGroupBookmarksByGroupsIds(groupIds, offset, limit, searchString, orderBy, orderDir, onlyCollections);
    }
    return groupBookmarks;
}
Also used : User(org.irods.jargon.core.pub.domain.User) DataGridGroupBookmark(com.emc.metalnx.core.domain.entity.DataGridGroupBookmark) ArrayList(java.util.ArrayList) UserAO(org.irods.jargon.core.pub.UserAO)

Example 5 with DataGridGroupBookmark

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

the class GroupBookmarkDaoImpl method addByGroupAndPath.

@Override
public Long addByGroupAndPath(DataGridGroup group, String path, boolean isCollection) {
    String parentPath = path.substring(0, path.lastIndexOf("/"));
    if (parentPath.isEmpty()) {
        parentPath = "/";
    }
    DataGridGroupBookmark bookmark = new DataGridGroupBookmark();
    bookmark.setGroup(group);
    bookmark.setPath(path);
    bookmark.setIsCollection(isCollection);
    bookmark.setCreateTs(new Date());
    bookmark.setIsNotified(false);
    return save(bookmark);
}
Also used : DataGridGroupBookmark(com.emc.metalnx.core.domain.entity.DataGridGroupBookmark) Date(java.util.Date)

Aggregations

DataGridGroupBookmark (com.emc.metalnx.core.domain.entity.DataGridGroupBookmark)8 ArrayList (java.util.ArrayList)4 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)2 JargonException (org.irods.jargon.core.exception.JargonException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)1 DataGridFilePermission (com.emc.metalnx.core.domain.entity.DataGridFilePermission)1 DataGridGroupPermission (com.emc.metalnx.core.domain.entity.DataGridGroupPermission)1 DataGridUserBookmark (com.emc.metalnx.core.domain.entity.DataGridUserBookmark)1 DataGridUserPermission (com.emc.metalnx.core.domain.entity.DataGridUserPermission)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Query (org.hibernate.Query)1 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)1 UserAO (org.irods.jargon.core.pub.UserAO)1 User (org.irods.jargon.core.pub.domain.User)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1