Search in sources :

Example 31 with DataGridUser

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";
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) DataGridUserFavorite(com.emc.metalnx.core.domain.entity.DataGridUserFavorite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 32 with DataGridUser

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

Example 33 with DataGridUser

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";
}
Also used : DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) JargonException(org.irods.jargon.core.exception.JargonException)

Example 34 with DataGridUser

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();
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser)

Example 35 with DataGridUser

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";
}
Also used : Authentication(org.springframework.security.core.Authentication) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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