use of com.emc.metalnx.core.domain.entity.DataGridGroup in project metalnx-web by irods-contrib.
the class UserController method getGroupInfo.
/**
* Finds all users existing in a group
*
* @param groupname
* @param additionalInfo
* @param model
* @return
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "getUsersInAGroup/{groupname}/{additionalInfo}", method = RequestMethod.GET)
public String getGroupInfo(@PathVariable String groupname, @PathVariable String additionalInfo, Model model) throws DataGridConnectionRefusedException {
DataGridGroup dataGridGroup = groupService.findByGroupnameAndZone(groupname, additionalInfo);
if (dataGridGroup == null) {
model.addAttribute("users", new ArrayList<DataGridUser>());
model.addAttribute("foundUsers", false);
model.addAttribute("resultSize", 0);
model.addAttribute("queryString", "");
} else {
List<DataGridUser> usersListOfAGroup = userService.findByDataGridIds(groupService.getMemberList(dataGridGroup));
model.addAttribute("users", usersListOfAGroup);
model.addAttribute("foundUsers", usersListOfAGroup.size() > 0);
model.addAttribute("resultSize", usersListOfAGroup.size());
model.addAttribute("queryString", "findAll");
}
return "users/userListOfAGroup :: userList";
}
use of com.emc.metalnx.core.domain.entity.DataGridGroup in project metalnx-web by irods-contrib.
the class UserController method showModifyUserForm.
/**
* Controller that shows the modification of user view.
*
* @param username
* @param additionalInfo
* @param model
* @return the template name to render the modify user form
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "modify/{username}/{additionalInfo}/", method = RequestMethod.GET)
public String showModifyUserForm(@PathVariable String username, @PathVariable String additionalInfo, Model model) throws DataGridConnectionRefusedException {
DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, additionalInfo);
List<DataGridGroup> groups = groupService.findAll();
List<DataGridZone> zones = zoneService.findAll();
if (user != null) {
UserForm userForm = new UserForm();
// iRODS data
userForm.setDataGridId(user.getDataGridId());
userForm.setUsername(user.getUsername());
userForm.setAdditionalInfo(user.getAdditionalInfo());
userForm.setUserProfile(user.getUserProfile());
userForm.setOrganizationalRole(user.getOrganizationalRole());
userForm.setUserType(user.getUserType());
// our data
if (user.getEmail() != null) {
userForm.setEmail(user.getEmail());
}
if (user.getFirstName() != null) {
userForm.setFirstName(user.getFirstName());
}
if (user.getLastName() != null) {
userForm.setLastName(user.getLastName());
}
if (user.getCompany() != null) {
userForm.setCompany(user.getCompany());
}
if (user.getDepartment() != null) {
userForm.setDepartment(user.getDepartment());
}
// Getting the list of groups the user belongs to
String[] groupList = userService.getGroupIdsForUser(user);
groupsToBeAdded = new ArrayList<String>(Arrays.asList(groupList));
model.addAttribute("user", userForm);
model.addAttribute("groupList", groupList);
model.addAttribute("requestMapping", "/users/modify/action/");
model.addAttribute("addReadPermissionsOnDirs", addReadPermissionsOnDirs);
model.addAttribute("addWritePermissionsOnDirs", addWritePermissionsOnDirs);
model.addAttribute("addOwnerOnDirs", addOwnerOnDirs);
}
model.addAttribute("profiles", userProfileService.findAll());
model.addAttribute("groups", groups);
model.addAttribute("zones", zones);
model.addAttribute("userZone", additionalInfo);
model.addAttribute("userTypes", userService.listUserTypes());
return "users/userForm";
}
use of com.emc.metalnx.core.domain.entity.DataGridGroup in project metalnx-web by irods-contrib.
the class UserProfileController method showCreateForm.
@RequestMapping(value = "/create/")
public String showCreateForm(Model model) {
UserProfileForm userProfileForm = new UserProfileForm();
List<DataGridGroup> groups = groupService.findAll();
groupIdsList = new ArrayList<String>();
model.addAttribute("userProfileForm", userProfileForm);
model.addAttribute("groups", groups);
model.addAttribute("groupsOnProfileList", new String[0]);
model.addAttribute("resultSize", groups.size());
model.addAttribute("foundGroups", groups.size() > 0);
model.addAttribute("requestMapping", "/users/profile/create/action/");
return "userProfile/userProfileForm";
}
use of com.emc.metalnx.core.domain.entity.DataGridGroup in project metalnx-web by irods-contrib.
the class GroupController method groupsToCSVFile.
@RequestMapping(value = "/groupsToCSVFile/")
public void groupsToCSVFile(HttpServletResponse response) {
String loggedUser = loggedUserUtils.getLoggedDataGridUser().getUsername();
String date = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String filename = String.format("groups_%s_%s.csv", loggedUser, date);
// Setting CSV Mime type
response.setContentType("text/csv");
response.setHeader("Content-disposition", "attachment;filename=" + filename);
List<DataGridGroup> groups = groupService.findAll();
List<String> rows = new ArrayList<String>();
rows.add("Group name;Zone\n");
for (DataGridGroup group : groups) {
rows.add(group.getGroupname() + ";");
rows.add(group.getAdditionalInfo());
rows.add("\n");
}
try {
ServletOutputStream outputStream = response.getOutputStream();
// Writing CSV file
Iterator<String> fileIterator = rows.iterator();
while (fileIterator.hasNext()) {
outputStream.print(fileIterator.next());
}
outputStream.flush();
} catch (IOException e) {
logger.error("Could not generate CSV file for groups", e);
}
}
use of com.emc.metalnx.core.domain.entity.DataGridGroup in project metalnx-web by irods-contrib.
the class GroupController method addGroup.
/**
* Controller method that executes action 'create group'
*
* @param user
* @return the name of the template to render
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "add/action/", method = RequestMethod.POST)
public String addGroup(@ModelAttribute GroupForm groupForm, HttpServletRequest httpServletRequest, RedirectAttributes redirectAttributes) throws DataGridConnectionRefusedException {
DataGridGroup newGroup = new DataGridGroup();
newGroup.setGroupname(groupForm.getGroupname());
newGroup.setAdditionalInfo(groupForm.getAdditionalInfo());
// Get the list of users to be attached to the group
String[] idsList = usersToBeAdded.toArray(new String[usersToBeAdded.size()]);
List<DataGridUser> usersToBeAttached = new ArrayList<DataGridUser>();
if (idsList != null && idsList.length != 0) {
usersToBeAttached = userService.findByDataGridIds(idsList);
}
if (groupService.createGroup(newGroup, usersToBeAttached) == false) {
return "redirect:/groups/add/";
}
// Updating permissions on collections
// boolean recursive = false;
groupService.updateReadPermissions(newGroup, addReadPermissionsOnDirs, removeReadPermissionsOnDirs);
groupService.updateWritePermissions(newGroup, addWritePermissionsOnDirs, removeWritePermissionsOnDirs);
groupService.updateOwnership(newGroup, addOwnerOnDirs, removeOwnerOnDirs);
// Setting the Group's home collection as a bookmark by default
bookmarkController.addPathAsGroupBookmark(groupService.getGroupCollectionPath(newGroup.getGroupname()));
// Updating bookmarks
updateBookmarksList(newGroup.getGroupname());
redirectAttributes.addFlashAttribute("groupAddedSuccessfully", groupForm.getGroupname());
collectionService.updateInheritanceOptions(addInheritanceOnDirs, removeInheritanceOnDirs, newGroup.getAdditionalInfo());
cleanModificationSets();
currentGroup = null;
return "redirect:/groups/";
}
Aggregations