Search in sources :

Example 1 with UserAO

use of org.irods.jargon.core.pub.UserAO in project metalnx-web by irods-contrib.

the class GroupBookmarkServiceImpl method countTotalGroupBookmarks.

@Override
public Integer countTotalGroupBookmarks(String user, String additionalInfo) throws DataGridConnectionRefusedException, DataNotFoundException, JargonException {
    Integer totalGroupBookmarks = 0;
    if (user == null || additionalInfo == null || user.isEmpty() || additionalInfo.isEmpty()) {
        logger.error("Could not get groups bookmarks. Username or zone empty");
        return 0;
    }
    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);
        totalGroupBookmarks = groupBookmarkDao.countGroupBookmarksByGroupsIds(groupIds).intValue();
    }
    return totalGroupBookmarks;
}
Also used : User(org.irods.jargon.core.pub.domain.User) UserAO(org.irods.jargon.core.pub.UserAO)

Example 2 with UserAO

use of org.irods.jargon.core.pub.UserAO 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 3 with UserAO

use of org.irods.jargon.core.pub.UserAO 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;
}
Also used : User(org.irods.jargon.core.pub.domain.User) DataGridGroupBookmark(com.emc.metalnx.core.domain.entity.DataGridGroupBookmark) ArrayList(java.util.ArrayList) UserAO(org.irods.jargon.core.pub.UserAO)

Example 4 with UserAO

use of org.irods.jargon.core.pub.UserAO in project metalnx-web by irods-contrib.

the class GroupBookmarkServiceImpl method getGroupsBookmarks.

@Override
public List<DataGridGroup> getGroupsBookmarks(String user, String additionalInfo) throws DataGridConnectionRefusedException, DataNotFoundException, JargonException {
    List<DataGridGroup> groups = new ArrayList<DataGridGroup>();
    if (user == null || additionalInfo == null || user.isEmpty() || additionalInfo.isEmpty()) {
        logger.error("Could not get groups bookmarks. Username or zone empty");
        return groups;
    }
    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);
        groups = groupService.findByDataGridIdList(groupIds);
    }
    return groups;
}
Also used : User(org.irods.jargon.core.pub.domain.User) ArrayList(java.util.ArrayList) UserAO(org.irods.jargon.core.pub.UserAO) DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup)

Example 5 with UserAO

use of org.irods.jargon.core.pub.UserAO in project metalnx-web by irods-contrib.

the class UserServiceImpl method createUser.

@Override
public boolean createUser(DataGridUser user, String password) throws JargonException, DataGridConnectionRefusedException {
    logger.info("createUser()");
    UserAO userAO = irodsServices.getUserAO();
    // Translating to iRODS model format
    User irodsUser = new User();
    irodsUser.setName(user.getUsername());
    irodsUser.setZone(user.getAdditionalInfo());
    if (user.getUserType().compareTo(UserTypeEnum.RODS_ADMIN.getTextValue()) == 0) {
        irodsUser.setUserType(UserTypeEnum.RODS_ADMIN);
    } else {
        irodsUser.setUserType(UserTypeEnum.RODS_USER);
    }
    logger.debug("adding...");
    // Creating user
    irodsUser = userAO.addUser(irodsUser);
    logger.debug("...added");
    user.setDataGridId(Long.parseLong(irodsUser.getId()));
    user.setEnabled(true);
    userDao.save(user);
    logger.info("setting password if provided (may be a PAM user!)");
    if (password == null || password.isEmpty()) {
        logger.info("no password, assume is not standard auth");
    } else {
        logger.info("password was provided, set in irods");
        // Setting password
        userAO.changeAUserPasswordByAnAdmin(user.getUsername(), password);
    }
    return true;
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) User(org.irods.jargon.core.pub.domain.User) UserAO(org.irods.jargon.core.pub.UserAO)

Aggregations

UserAO (org.irods.jargon.core.pub.UserAO)7 User (org.irods.jargon.core.pub.domain.User)6 DataGridUser (com.emc.metalnx.core.domain.entity.DataGridUser)4 ArrayList (java.util.ArrayList)2 JargonException (org.irods.jargon.core.exception.JargonException)2 DataGridGroup (com.emc.metalnx.core.domain.entity.DataGridGroup)1 DataGridGroupBookmark (com.emc.metalnx.core.domain.entity.DataGridGroupBookmark)1 DataGridAuthenticationException (com.emc.metalnx.core.domain.exceptions.DataGridAuthenticationException)1 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)1 AuthResponse (org.irods.jargon.core.connection.auth.AuthResponse)1