Search in sources :

Example 6 with User

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

use of org.irods.jargon.core.pub.domain.User 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 8 with User

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

the class GroupServiceImpl method updateMemberList.

@Override
public boolean updateMemberList(DataGridGroup group, List<DataGridUser> users) throws DataGridConnectionRefusedException {
    try {
        UserGroupAO groupAO = irodsServices.getGroupAO();
        // Users that are currently on this group
        List<User> usersFromIrods = groupAO.listUserGroupMembers(group.getGroupname());
        // Building set with iRODS IDs already on this group
        HashMap<Long, User> idsFromIrods = new HashMap<Long, User>();
        for (User userFromIrods : usersFromIrods) {
            idsFromIrods.put(Long.valueOf(userFromIrods.getId()), userFromIrods);
        }
        // Building set with iRODS IDs coming from UI
        HashMap<Long, DataGridUser> idsFromUi = new HashMap<Long, DataGridUser>();
        for (DataGridUser userFromUi : users) {
            idsFromUi.put(userFromUi.getDataGridId(), userFromUi);
        }
        // Resolving differences from UI to iRODS
        Set<Long> keysFromUi = idsFromUi.keySet();
        Set<Long> keysFromIrods = idsFromIrods.keySet();
        for (Long dataGridId : keysFromUi) {
            if (!keysFromIrods.contains(dataGridId)) {
                attachUserToGroup(idsFromUi.get(dataGridId), group);
            }
        }
        for (Long dataGridId : keysFromIrods) {
            if (!keysFromUi.contains(dataGridId)) {
                DataGridUser user = new DataGridUser();
                user.setUsername(idsFromIrods.get(dataGridId).getName());
                removeUserFromGroup(user, group);
            }
        }
        return true;
    } catch (Exception e) {
        logger.info("Could not update [" + group.getGroupname() + "]: ", e);
    }
    return false;
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) User(org.irods.jargon.core.pub.domain.User) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) UserGroupAO(org.irods.jargon.core.pub.UserGroupAO) DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) DuplicateDataException(org.irods.jargon.core.exception.DuplicateDataException) DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) JargonException(org.irods.jargon.core.exception.JargonException)

Example 9 with User

use of org.irods.jargon.core.pub.domain.User 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)

Example 10 with User

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

the class UserServiceImpl method modifyUser.

@Override
public boolean modifyUser(DataGridUser modifyUser) throws DataGridConnectionRefusedException {
    UserAO userAO = irodsServices.getUserAO();
    try {
        User iRodsUser = userAO.findById(String.valueOf(modifyUser.getDataGridId()));
        boolean iRodsFieldsModified = false;
        // check which fields were modified (iRODS)
        if (iRodsUser.getZone().compareTo(modifyUser.getAdditionalInfo()) != 0) {
            iRodsUser.setZone(modifyUser.getAdditionalInfo());
            iRodsFieldsModified = true;
        }
        if (!iRodsUser.getUserType().getTextValue().equals(modifyUser.getUserType())) {
            if (modifyUser.getUserType().compareTo(UserTypeEnum.RODS_ADMIN.getTextValue()) == 0) {
                iRodsUser.setUserType(UserTypeEnum.RODS_ADMIN);
            } else {
                iRodsUser.setUserType(UserTypeEnum.RODS_USER);
            }
            iRodsFieldsModified = true;
        }
        // updating user in iRODS if any field was modified
        if (iRodsFieldsModified) {
            userAO.updateUser(iRodsUser);
        }
        DataGridUser applicationUser = userDao.findByUsernameAndZone(modifyUser.getUsername(), modifyUser.getAdditionalInfo());
        // check which fields were modified (our database)
        if (applicationUser.getAdditionalInfo() == null || applicationUser.getAdditionalInfo().compareTo(modifyUser.getAdditionalInfo()) != 0) {
            applicationUser.setAdditionalInfo(modifyUser.getAdditionalInfo());
        }
        if (applicationUser.getFirstName() == null || applicationUser.getFirstName().compareTo(modifyUser.getFirstName()) != 0) {
            applicationUser.setFirstName(modifyUser.getFirstName());
        }
        if (applicationUser.getLastName() == null || applicationUser.getLastName().compareTo(modifyUser.getLastName()) != 0) {
            applicationUser.setLastName(modifyUser.getLastName());
        }
        if (applicationUser.getEmail() == null || applicationUser.getEmail().compareTo(modifyUser.getEmail()) != 0) {
            applicationUser.setEmail(modifyUser.getEmail());
        }
        if (applicationUser.getCompany() == null || applicationUser.getCompany().compareTo(modifyUser.getCompany()) != 0) {
            applicationUser.setCompany(modifyUser.getCompany());
        }
        if (applicationUser.getDepartment() == null || applicationUser.getDepartment().compareTo(modifyUser.getDepartment()) != 0) {
            applicationUser.setDepartment(modifyUser.getDepartment());
        }
        applicationUser.setUserProfile(modifyUser.getUserProfile());
        applicationUser.setLocale(modifyUser.getLocale());
        applicationUser.setOrganizationalRole(modifyUser.getOrganizationalRole());
        applicationUser.setUserType(modifyUser.getUserType());
        applicationUser.setForceFileOverwriting(modifyUser.isForceFileOverwriting());
        applicationUser.setAdvanceView(modifyUser.isAdvancedView());
        userDao.merge(applicationUser);
        // Changing password if a new password is set
        String newPassword = modifyUser.getPassword();
        if (newPassword != null && !newPassword.isEmpty()) {
            userAO.changeAUserPasswordByAnAdmin(modifyUser.getUsername(), newPassword);
        }
        return true;
    } catch (JargonException e) {
        e.printStackTrace();
    }
    return false;
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) User(org.irods.jargon.core.pub.domain.User) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) JargonException(org.irods.jargon.core.exception.JargonException) UserAO(org.irods.jargon.core.pub.UserAO)

Aggregations

User (org.irods.jargon.core.pub.domain.User)11 DataGridUser (com.emc.metalnx.core.domain.entity.DataGridUser)8 JargonException (org.irods.jargon.core.exception.JargonException)6 UserAO (org.irods.jargon.core.pub.UserAO)6 ArrayList (java.util.ArrayList)3 DataGridGroup (com.emc.metalnx.core.domain.entity.DataGridGroup)2 DataGridAuthenticationException (com.emc.metalnx.core.domain.exceptions.DataGridAuthenticationException)2 HashMap (java.util.HashMap)2 AuthResponse (org.irods.jargon.core.connection.auth.AuthResponse)2 UserGroupAO (org.irods.jargon.core.pub.UserGroupAO)2 DataGridGroupBookmark (com.emc.metalnx.core.domain.entity.DataGridGroupBookmark)1 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)1 DataGridDatabaseException (com.emc.metalnx.core.domain.exceptions.DataGridDatabaseException)1 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)1 DataGridServerException (com.emc.metalnx.core.domain.exceptions.DataGridServerException)1 DuplicateDataException (org.irods.jargon.core.exception.DuplicateDataException)1 InvalidUserException (org.irods.jargon.core.exception.InvalidUserException)1 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)1 AuthenticationException (org.springframework.security.core.AuthenticationException)1 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1