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;
}
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;
}
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;
}
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;
}
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() + "/";
}
Aggregations