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