use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.
the class FavoritesController method listfavorites.
/**
* Responds to the list favorites request
*
* @param model
* @return the template with a list of favorite items
*/
@RequestMapping(value = "/")
public String listfavorites(final Model model) {
String loggedUsername = irodsServices.getCurrentUser();
String loggedUserZoneName = irodsServices.getCurrentUserZone();
DataGridUser user = userService.findByUsernameAndAdditionalInfo(loggedUsername, loggedUserZoneName);
List<DataGridUserFavorite> userFavorites = user.getFavoritesSorted();
model.addAttribute("userFavorites", userFavorites);
model.addAttribute("topnavHeader", headerService.getheader("favorite"));
return "favorites/favorites";
}
use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.
the class FavoritesController method addFavoriteToUser.
/**
* Add a path to the favorites list
*
* @param path
* path to be added to the favorites
*/
@RequestMapping(value = "/addFavoriteToUser/")
@ResponseBody
public String addFavoriteToUser(@RequestParam("path") final String path) {
String zoneName = irodsServices.getCurrentUserZone();
String username = irodsServices.getCurrentUser();
logger.info("Request for adding a {} favorite from {}", path, username);
DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, zoneName);
Set<String> toAdd = new HashSet<String>();
toAdd.add(path);
boolean operationResult = favoritesService.updateFavorites(user, toAdd, null);
return operationResult ? REQUEST_OK : REQUEST_ERROR;
}
use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.
the class CollectionController method index.
/**
* Legacy index method used in other controllers, eventually factor out TODO:
* factor this out and make explicit via urls etc - mcc
*
* @param model
* @param request
* @return
*/
public String index(final Model model, final HttpServletRequest request) {
logger.info("index()");
try {
sourcePaths.clear();
if (!cs.isPathValid(currentPath)) {
currentPath = cs.getHomeDirectyForCurrentUser();
parentPath = currentPath;
} else if (cs.isDataObject(currentPath)) {
parentPath = currentPath.substring(0, currentPath.lastIndexOf("/") + 1);
}
DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
String uiMode = (String) request.getSession().getAttribute("uiMode");
if (uiMode == null || uiMode.isEmpty()) {
boolean isUserAdmin = loggedUser != null && loggedUser.isAdmin();
uiMode = isUserAdmin ? UI_ADMIN_MODE : UI_USER_MODE;
}
if (uiMode.equals(UI_USER_MODE)) {
model.addAttribute("homePath", cs.getHomeDirectyForCurrentUser());
model.addAttribute("publicPath", cs.getHomeDirectyForPublic());
}
model.addAttribute("cameFromFilePropertiesSearch", cameFromFilePropertiesSearch);
model.addAttribute("cameFromMetadataSearch", cameFromMetadataSearch);
model.addAttribute("cameFromBookmarks", cameFromBookmarks);
model.addAttribute("uiMode", uiMode);
model.addAttribute("currentPath", currentPath);
model.addAttribute("encodedCurrentPath", URLEncoder.encode(currentPath));
model.addAttribute("parentPath", parentPath);
model.addAttribute("resources", resourceService.findAll());
model.addAttribute("overwriteFileOption", loggedUser != null && loggedUser.isForceFileOverwriting());
cameFromMetadataSearch = false;
cameFromFilePropertiesSearch = false;
cameFromBookmarks = false;
} catch (DataGridException | JargonException e) {
logger.error("Could not respond to request for collections: {}", e);
model.addAttribute("unexpectedError", true);
}
logger.info("returning to collections/collectionManagement");
return "collections/collectionManagement";
}
use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.
the class UserController method updateBookmarksList.
/*
* *****************************************************************************
* *************** ******************************** PRIVATE
* ***************************************
* *****************************************************************************
* ***************
*/
/**
* Persists the changes on the bookmarks lists for the given group on the
* database
*
* @param groupName
*/
private void updateBookmarksList(String username, String additionalInfo) {
if (username == null || username.isEmpty() || additionalInfo == null || additionalInfo.isEmpty()) {
return;
}
DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, additionalInfo);
if (user != null) {
Set<String> bookmarksToAdd = userBookmarkController.getAddBookmark();
Set<String> bookmarksToRemove = userBookmarkController.getRemoveBookmark();
userBookmarkService.updateBookmarks(user, bookmarksToAdd, bookmarksToRemove);
}
userBookmarkController.clearBookmarksLists();
}
use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.
the class UserController method listAllUsers.
/**
* List users by page number
*
* @param model
* @return
*/
@RequestMapping(value = "/findAll/")
public String listAllUsers(Model model) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String usernameLogged = (String) auth.getPrincipal();
List<DataGridUser> users = userService.findAll();
Collections.sort(users);
model.addAttribute("usernameLogged", usernameLogged);
model.addAttribute("users", users);
return "users/userList :: userList";
}
Aggregations