Search in sources :

Example 1 with DataGridUser

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

the class UserServiceImpl method deleteUserByUsername.

@Override
public boolean deleteUserByUsername(String username) throws DataGridConnectionRefusedException {
    UserAO userAO = irodsServices.getUserAO();
    try {
        DataGridUser user = findByUsername(username).get(0);
        String userHomeFolder = String.format("/%s/home/%s", configService.getIrodsZone(), username);
        // Removing user
        userAO.deleteUser(username);
        userDao.deleteByUsername(username);
        // Removing favorites and user bookmarks before removing user
        userBookmarkService.removeBookmarkBasedOnUser(user);
        userBookmarkService.removeBookmarkBasedOnPath(userHomeFolder);
        favoritesService.removeFavoriteBasedOnUser(user);
        favoritesService.removeFavoriteBasedOnPath(userHomeFolder);
        return true;
    } catch (Exception e) {
        logger.error("Could not delete user with username [" + username + "]");
    }
    return false;
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) UserAO(org.irods.jargon.core.pub.UserAO) DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) JargonException(org.irods.jargon.core.exception.JargonException)

Example 2 with DataGridUser

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

the class UserDaoImpl method findByDataGridIdList.

@Override
public List<DataGridUser> findByDataGridIdList(String[] ids) {
    List<DataGridUser> result = new ArrayList<DataGridUser>();
    if (ids != null) {
        int i = 0;
        Integer[] ids_int = new Integer[ids.length];
        for (String id_str : ids) {
            ids_int[i++] = Integer.parseInt(id_str);
        }
        // Checking if the input ID list is empty
        if (ids_int != null) {
            Query q = sessionFactory.getCurrentSession().createQuery("from DataGridUser where data_grid_id in (:ids)");
            q.setParameterList("ids", ids_int);
            result = q.list();
        }
    }
    // If the input list is null, the method returns null
    return result;
}
Also used : Query(org.hibernate.Query) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) ArrayList(java.util.ArrayList)

Example 3 with DataGridUser

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

the class UserDaoImpl method findByUsernameAndZone.

@Override
public DataGridUser findByUsernameAndZone(String username, String zone) {
    List<DataGridUser> users = null;
    Query q = sessionFactory.getCurrentSession().createQuery("from DataGridUser where username = :username and additional_info = :zone");
    q.setString("username", username);
    q.setString("zone", zone);
    users = q.list();
    return users.size() > 0 ? users.get(0) : null;
}
Also used : Query(org.hibernate.Query) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser)

Example 4 with DataGridUser

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

the class TicketClientExceptionController method handleTicketFileNotFound.

@ExceptionHandler({ DataGridTicketDownloadException.class })
public ModelAndView handleTicketFileNotFound(DataGridTicketDownloadException e) {
    ticketClientService.deleteTempTicketDir();
    String path = e.getPath();
    String objName = path.substring(path.lastIndexOf(IRODS_PATH_SEPARATOR) + 1, path.length());
    ModelAndView mav = new ModelAndView();
    mav.addObject("error", e.getMessage());
    mav.addObject("objName", objName);
    mav.addObject("path", path);
    mav.addObject("ticketString", e.getTicketString());
    String viewName = "tickets/ticketclient";
    DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
    if (loggedUser != null) {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        UserTokenDetails userTokenDetails = (UserTokenDetails) auth.getDetails();
        mav.addObject("userDetails", userTokenDetails.getUser());
        viewName = "tickets/ticketAuthAccess";
    }
    mav.setViewName(viewName);
    return mav;
}
Also used : UserTokenDetails(com.emc.metalnx.services.auth.UserTokenDetails) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) Authentication(org.springframework.security.core.Authentication) ModelAndView(org.springframework.web.servlet.ModelAndView) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Example 5 with DataGridUser

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

the class UserController method modifyUser.

/**
 * Updates the user on the current DB.
 *
 * @param userForm
 * @return the users views template name
 * @throws DataGridConnectionRefusedException
 */
@RequestMapping(value = "modify/action/", method = RequestMethod.POST)
public String modifyUser(@ModelAttribute UserForm userForm, HttpServletRequest request, RedirectAttributes redirectAttributes) throws DataGridConnectionRefusedException {
    String[] groupList = groupsToBeAdded.toArray(new String[groupsToBeAdded.size()]);
    List<DataGridGroup> groups = new ArrayList<DataGridGroup>();
    if (groupList != null && groupList.length != 0) {
        groups = groupService.findByDataGridIdList(groupList);
    }
    DataGridUser user = userService.findByUsernameAndAdditionalInfo(userForm.getUsername(), userForm.getAdditionalInfo());
    boolean modificationSucessful = false;
    boolean updateGroupsSuccessful = false;
    if (user != null) {
        user.setAdditionalInfo(userForm.getAdditionalInfo());
        user.setUsername(userForm.getUsername());
        user.setPassword(userForm.getPassword());
        user.setFirstName(userForm.getFirstName());
        user.setLastName(userForm.getLastName());
        user.setEmail(userForm.getEmail());
        user.setOrganizationalRole(userForm.getOrganizationalRole() != null ? userForm.getOrganizationalRole() : "");
        user.setUserType(userForm.getUserType());
        user.setCompany(userForm.getCompany() != null ? userForm.getCompany() : "");
        user.setDepartment(userForm.getDepartment() != null ? userForm.getDepartment() : "");
        // User bookmarks
        updateBookmarksList(user.getUsername(), user.getAdditionalInfo());
        modificationSucessful = userService.modifyUser(user);
        updateGroupsSuccessful = userService.updateGroupList(user, groups);
        if (modificationSucessful && updateGroupsSuccessful) {
            redirectAttributes.addFlashAttribute("userModifiedSuccessfully", userForm.getUsername());
            // Updating permissions on collections
            userService.updateOwnership(user, addOwnerOnDirs, removeOwnerOnDirs);
            userService.updateWritePermissions(user, addWritePermissionsOnDirs, removeWritePermissionsOnDirs);
            userService.updateReadPermissions(user, addReadPermissionsOnDirs, removeReadPermissionsOnDirs);
        }
    }
    // Applying selected profile to the user
    String selectedProfile = request.getParameter("selectedProfile");
    if (selectedProfile != null && selectedProfile != "") {
        UserProfile userProfile = userProfileService.findById(Long.valueOf(selectedProfile));
        userService.applyProfileToUser(userProfile, user);
        user.setUserProfile(userProfile);
    } else {
        user.setUserProfile(null);
    }
    userService.modifyUser(user);
    cleanPermissionsSets();
    return modificationSucessful && updateGroupsSuccessful ? "redirect:/users/" : "redirect:/users/modify/" + user.getUsername() + "/" + user.getAdditionalInfo() + "/";
}
Also used : UserProfile(com.emc.metalnx.core.domain.entity.UserProfile) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) ArrayList(java.util.ArrayList) DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup) 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