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