use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.
the class UserBookmarkController method listBookmarks.
@RequestMapping(value = "/")
public String listBookmarks(final Model model) {
String loggedUsername = irodsServices.getCurrentUser();
String loggedUserZoneName = irodsServices.getCurrentUserZone();
DataGridUser user = userService.findByUsernameAndAdditionalInfo(loggedUsername, loggedUserZoneName);
List<DataGridUserBookmark> userBookmakrs = user.getBookmarksSorted();
logger.info("userBookmarks found....");
logger.info(userBookmakrs.toString());
model.addAttribute("userBookmarks", userBookmakrs);
model.addAttribute("foundUserBookmarks", !userBookmakrs.isEmpty());
model.addAttribute("topnavHeader", headerService.getheader("shared"));
return "bookmarks/userBookmarks";
}
use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.
the class HttpResponseHandlerInterceptor method postHandle.
@Override
public void postHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler, final ModelAndView modelAndView) throws Exception {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (modelAndView != null && auth != null) {
if (urlMap == null) {
urlMap = new URLMap();
}
if (emcmetalnxVersion == null) {
emcmetalnxVersion = new EmcMetalnxVersion();
}
modelAndView.getModelMap().addAttribute("urlMap", urlMap);
modelAndView.getModelMap().addAttribute("emcmetalnxVersion", emcmetalnxVersion);
modelAndView.getModelMap().addAttribute("jargonVersion", new JargonVersion());
modelAndView.getModelMap().addAttribute("globalConfig", configService.getGlobalConfig());
DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
logger.debug("added user prefs to model as 'dataGridUser':{}", loggedUser);
modelAndView.getModelMap().addAttribute("dataGridUser", loggedUser);
if (auth instanceof UsernamePasswordAuthenticationToken) {
userTokenDetails = (UserTokenDetails) auth.getDetails();
modelAndView.getModelMap().addAttribute("userDetails", userTokenDetails.getUser());
}
}
// closing sessions to avoid idle agents
irodsAccessObjectFactory.closeSessionAndEatExceptions();
}
use of com.emc.metalnx.core.domain.entity.DataGridUser 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;
}
use of com.emc.metalnx.core.domain.entity.DataGridUser 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;
}
use of com.emc.metalnx.core.domain.entity.DataGridUser 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;
}
Aggregations