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;
}
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;
}
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";
}
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;
}
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);
}
Aggregations