diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/BrowseController.java b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/BrowseController.java index 4a109b2c1..4a1b44dc5 100644 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/BrowseController.java +++ b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/BrowseController.java @@ -25,7 +25,6 @@ import org.irods.jargon.core.exception.JargonException; import org.irods.jargon.core.utils.MiscIRODSUtils; import org.irods.jargon.extensions.dataprofiler.DataProfile; -import org.irodsext.dataprofiler.favorites.FavoritesService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -64,7 +63,6 @@ import com.emc.metalnx.services.interfaces.PermissionsService; import com.emc.metalnx.services.interfaces.ResourceService; import com.emc.metalnx.services.interfaces.RuleDeploymentService; -import com.emc.metalnx.services.interfaces.UserBookmarkService; import com.emc.metalnx.services.interfaces.UserService; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -95,9 +93,6 @@ public class BrowseController { @Autowired GroupService groupService; - @Autowired - UserBookmarkService userBookmarkService; - @Autowired MetadataService metadataService; @@ -107,9 +102,6 @@ public class BrowseController { @Autowired IRODSServices irodsServices; - @Autowired - FavoritesService favoritesService; - @Autowired LoggedUserUtils loggedUserUtils; @@ -439,7 +431,6 @@ public String getDirectoriesAndFilesForUser(final Model model, @RequestParam("pa Set writePermissions = new HashSet(); Set ownershipPermissions = new HashSet(); Set inheritPermissions = new HashSet(); - List userBookmarks = new ArrayList(); // If a string is null, empty or contains only white spaces, StringUtils // returns true @@ -463,11 +454,6 @@ public String getDirectoriesAndFilesForUser(final Model model, @RequestParam("pa // may not find based on permissions..it's ok } } - - List users = userService.findByUsername(username); - if (users != null && !users.isEmpty()) { - userBookmarks = userBookmarkService.findBookmarksForUserAsString(users.get(0)); - } } } @@ -479,9 +465,6 @@ public String getDirectoriesAndFilesForUser(final Model model, @RequestParam("pa model.addAttribute("writePermissions", writePermissions); model.addAttribute("ownershipPermissions", ownershipPermissions); model.addAttribute("inheritPermissions", inheritPermissions); - model.addAttribute("addBookmark", new ArrayList()); - model.addAttribute("removeBookmark", new ArrayList()); - model.addAttribute("userBookmarks", userBookmarks); logger.info("model:{}", model); logger.info("done with processing:{}", model); @@ -575,28 +558,8 @@ public String modifyAction(@ModelAttribute final CollectionOrDataObjectForm coll boolean modificationSuccessful = cs.modifyCollectionAndDataObject(previousPath, newPath, collForm.getInheritOption()); - // checking if the previousPath collection/dataobject was marked as favorite: - String username = irodsServices.getCurrentUser(); - String zoneName = irodsServices.getCurrentUserZone(); - DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, zoneName); - boolean isMarkedFavorite = favoritesService.isPathFavoriteForUser(user, previousPath); - logger.info("Favorite status for previousPath: " + previousPath + " is: " + String.valueOf(isMarkedFavorite)); - if (modificationSuccessful) { logger.debug("Collection/Data Object {} modified to {}", previousPath, newPath); - - if (isMarkedFavorite) { - Set toAdd = new HashSet(); - Set toRemove = new HashSet(); - toAdd.add(newPath); - toRemove.add(previousPath); - boolean operationResult = favoritesService.updateFavorites(user, toAdd, toRemove); - if (operationResult) { - logger.info("Favorite re-added successfully for: " + newPath); - } else { - logger.info("Error re-adding favorite to: " + newPath); - } - } redirectAttributes.addFlashAttribute("collectionModifiedSuccessfully", collForm.getCollectionName()); } diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/CollectionController.java b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/CollectionController.java index 2f74dd0d3..d58faeadc 100755 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/CollectionController.java +++ b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/CollectionController.java @@ -12,7 +12,6 @@ import org.irods.jargon.core.exception.JargonException; import org.irods.jargon.core.utils.CollectionAndPath; import org.irods.jargon.core.utils.MiscIRODSUtils; -import org.irodsext.dataprofiler.favorites.FavoritesService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -38,7 +37,6 @@ import com.emc.metalnx.services.interfaces.PermissionsService; import com.emc.metalnx.services.interfaces.ResourceService; import com.emc.metalnx.services.interfaces.RuleDeploymentService; -import com.emc.metalnx.services.interfaces.UserBookmarkService; import com.emc.metalnx.services.interfaces.UserService; import com.emc.metalnx.services.interfaces.mail.MailService; @@ -60,9 +58,6 @@ public class CollectionController { @Autowired GroupService groupService; - @Autowired - UserBookmarkService userBookmarkService; - @Autowired MetadataService metadataService; @@ -72,9 +67,6 @@ public class CollectionController { @Autowired IRODSServices irodsServices; - @Autowired - FavoritesService favoritesService; - @Autowired LoggedUserUtils loggedUserUtils; @@ -281,14 +273,6 @@ public void setGroupService(GroupService groupService) { this.groupService = groupService; } - public UserBookmarkService getUserBookmarkService() { - return userBookmarkService; - } - - public void setUserBookmarkService(UserBookmarkService userBookmarkService) { - this.userBookmarkService = userBookmarkService; - } - public MetadataService getMetadataService() { return metadataService; } @@ -313,14 +297,6 @@ public void setIrodsServices(IRODSServices irodsServices) { this.irodsServices = irodsServices; } - public FavoritesService getFavoritesService() { - return favoritesService; - } - - public void setFavoritesService(FavoritesService favoritesService) { - this.favoritesService = favoritesService; - } - public LoggedUserUtils getLoggedUserUtils() { return loggedUserUtils; } diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/FavoritesController.java b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/FavoritesController.java deleted file mode 100755 index 60909cb84..000000000 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/FavoritesController.java +++ /dev/null @@ -1,168 +0,0 @@ - /* Copyright (c) 2018, University of North Carolina at Chapel Hill */ - /* Copyright (c) 2015-2017, Dell EMC */ - - - -package com.emc.metalnx.controller; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; - -import org.irodsext.dataprofiler.favorites.FavoritesService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.SessionAttributes; -import org.springframework.web.context.WebApplicationContext; - -import com.emc.metalnx.core.domain.entity.DataGridUser; -import com.emc.metalnx.core.domain.entity.DataGridUserFavorite; -import com.emc.metalnx.services.interfaces.HeaderService; -import com.emc.metalnx.services.interfaces.IRODSServices; -import com.emc.metalnx.services.interfaces.UserService; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@Scope(WebApplicationContext.SCOPE_SESSION) -@RequestMapping(value = "/favorites") -public class FavoritesController { - @Autowired - FavoritesService favoritesService; - - @Autowired - UserService userService; - - @Autowired - IRODSServices irodsServices; - - @Autowired - HeaderService headerService; - - private static final String REQUEST_OK = "OK"; - private static final String REQUEST_ERROR = "ERROR"; - - private int totalFavorites; - private int totalFavoritesFiltered; - - private static final Logger logger = LoggerFactory.getLogger(FavoritesController.class); - - /** - * Responds to the list favorites request - * - * @param model - * @return the template with a list of favorite items - */ - @RequestMapping(value = "/") - public String listfavorites(final Model model) { - String loggedUsername = irodsServices.getCurrentUser(); - String loggedUserZoneName = irodsServices.getCurrentUserZone(); - DataGridUser user = userService.findByUsernameAndAdditionalInfo(loggedUsername, loggedUserZoneName); - - List userFavorites = user.getFavoritesSorted(); - - model.addAttribute("userFavorites", userFavorites); - - - return "favorites/favorites"; - } - - /** - * Add a path to the favorites list - * - * @param path - * path to be added to the favorites - */ - @RequestMapping(value = "/addFavoriteToUser/") - @ResponseBody - public String addFavoriteToUser(@RequestParam("path") final String path) { - String zoneName = irodsServices.getCurrentUserZone(); - String username = irodsServices.getCurrentUser(); - - logger.info("Request for adding a {} favorite from {}", path, username); - DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, zoneName); - - Set toAdd = new HashSet(); - toAdd.add(path); - - boolean operationResult = favoritesService.updateFavorites(user, toAdd, null); - - return operationResult ? REQUEST_OK : REQUEST_ERROR; - } - - /** - * Remove a path to the favorites list - * - * @param model - * @param path - * path to be removed from the favorites - */ - @RequestMapping(value = "/removeFavoriteFromUser/") - @ResponseBody - public String removeFavoriteFromUser(@RequestParam("path") final String path) { - String username = irodsServices.getCurrentUser(); - logger.info("Request for removing a {} favorite from {}", path, username); - - String zoneName = irodsServices.getCurrentUserZone(); - DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, zoneName); - - Set toRemove = new HashSet(); - toRemove.add(path); - - boolean operationResult = favoritesService.updateFavorites(user, null, toRemove); - - return operationResult ? REQUEST_OK : REQUEST_ERROR; - } - - @RequestMapping(value = "/favoritesPaginated") - @ResponseBody - public String favoritesPaginated(final HttpServletRequest request) { - - int draw = Integer.parseInt(request.getParameter("draw")); - int start = Integer.parseInt(request.getParameter("start")); - int length = Integer.parseInt(request.getParameter("length")); - String searchString = request.getParameter("search[value]"); - int orderColumn = Integer.parseInt(request.getParameter("order[0][column]")); - String orderDir = request.getParameter("order[0][dir]"); - boolean onlyCollections = Boolean.parseBoolean(request.getParameter("onlyCollections")); - String loggedUsername = irodsServices.getCurrentUser(); - String loggedUserZoneName = irodsServices.getCurrentUserZone(); - DataGridUser user = userService.findByUsernameAndAdditionalInfo(loggedUsername, loggedUserZoneName); - String[] orderBy = { "name", "path", "created_at", "is_collection" }; - - List userFavorites = favoritesService.findFavoritesPaginated(user, start, length, - searchString, orderBy[orderColumn], orderDir, onlyCollections); - - ObjectMapper mapper = new ObjectMapper(); - Map jsonResponse = new HashMap(); - String jsonString = ""; - if ("".equals(searchString)) { - totalFavorites = user.getFavorites().size(); - totalFavoritesFiltered = user.getFavorites().size(); - } else { - totalFavoritesFiltered = userFavorites.size(); - } - - jsonResponse.put("draw", String.valueOf(draw)); - jsonResponse.put("recordsTotal", String.valueOf(totalFavorites)); - jsonResponse.put("recordsFiltered", String.valueOf(totalFavoritesFiltered)); - jsonResponse.put("data", userFavorites); - - try { - jsonString = mapper.writeValueAsString(jsonResponse); - } catch (Exception e) { - logger.error("Could not parse hashmap in favorites to json", e.getMessage()); - } - return jsonString; - } -} diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/PermissionsController.java b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/PermissionsController.java index 1e9612a76..5f0085c5a 100755 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/PermissionsController.java +++ b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/PermissionsController.java @@ -27,7 +27,6 @@ import com.emc.metalnx.core.domain.entity.DataGridFilePermission; import com.emc.metalnx.core.domain.entity.DataGridGroupPermission; import com.emc.metalnx.core.domain.entity.DataGridUser; -import com.emc.metalnx.core.domain.entity.DataGridUserBookmark; import com.emc.metalnx.core.domain.entity.DataGridUserPermission; import com.emc.metalnx.core.domain.entity.enums.DataGridPermType; import com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException; @@ -35,7 +34,6 @@ import com.emc.metalnx.services.interfaces.CollectionService; import com.emc.metalnx.services.interfaces.GroupService; import com.emc.metalnx.services.interfaces.PermissionsService; -import com.emc.metalnx.services.interfaces.UserBookmarkService; import com.emc.metalnx.services.interfaces.UserService; @Controller @@ -49,9 +47,6 @@ public class PermissionsController { @Autowired private GroupService gs; - @Autowired - private UserBookmarkService uBMS; - @Autowired private PermissionsService ps; @@ -120,9 +115,6 @@ public String getPermissionDetails(final Model model, @RequestParam("path") fina List permissions; List groupPermissions; List userPermissions; - List userBookmarks; - Set groupsWithBookmarks; - Set usersWithBookmarks; boolean userCanModify = false; boolean isCollection = false; @@ -133,16 +125,8 @@ public String getPermissionDetails(final Model model, @RequestParam("path") fina groupPermissions = ps.getGroupsWithPermissions(permissions); userPermissions = ps.getUsersWithPermissions(permissions); - userBookmarks = uBMS.findBookmarksOnPath(path); userCanModify = loggedUser.isAdmin() || ps.canLoggedUserModifyPermissionOnPath(path); - groupsWithBookmarks = new HashSet<>(); - - usersWithBookmarks = new HashSet<>(); - for (DataGridUserBookmark userBookmark : userBookmarks) { - usersWithBookmarks.add(userBookmark.getUser().getUsername()); - } - obj = cs.findByName(path); obj.setMostPermissiveAccessForCurrentUser( ps.resolveMostPermissiveAccessForUser(obj.getPath(), loggedUser.getUsername())); @@ -151,8 +135,6 @@ public String getPermissionDetails(final Model model, @RequestParam("path") fina throw new DataGridException("error getting permissions", e); } - model.addAttribute("usersWithBookmarks", usersWithBookmarks); - model.addAttribute("groupsWithBookmark", groupsWithBookmarks); model.addAttribute("groupPermissions", groupPermissions); model.addAttribute("userPermissions", userPermissions); model.addAttribute("userCanModify", userCanModify); @@ -240,12 +222,6 @@ public String addGroupToCreationList(@RequestParam("permission") final String pe operationResult &= ps.setPermissionOnPath(permType, group, recursive, loggedUser.isAdmin(), path); } - // Updating bookmarks for the recently-created permissions - if (bookmark) { - Set bookmarks = new HashSet(); - bookmarks.add(path); - } - return operationResult ? REQUEST_OK : REQUEST_ERROR; } @@ -270,18 +246,6 @@ public String addUserToCreationList(@RequestParam("permission") final String per for (String username : usernames) { operationResult &= ps.setPermissionOnPath(permType, username, recursive, loggedUser.isAdmin(), path); - - // Updating bookmarks for the recently-created permissions - if (bookmark) { - Set bookmarks = new HashSet(); - bookmarks.add(path); - - // Getting list of users and updating bookmarks - List dataGridUsers = us.findByUsername(username); - if (dataGridUsers != null && !dataGridUsers.isEmpty()) { - uBMS.updateBookmarks(dataGridUsers.get(0), bookmarks, null); - } - } } return operationResult ? REQUEST_OK : REQUEST_ERROR; diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/TemplateController.java b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/TemplateController.java deleted file mode 100755 index e5112f283..000000000 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/TemplateController.java +++ /dev/null @@ -1,810 +0,0 @@ -/* Copyright (c) 2018, University of North Carolina at Chapel Hill */ -/* Copyright (c) 2015-2017, Dell EMC */ - -package com.emc.metalnx.controller; - -import java.io.IOException; -import java.io.InputStream; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.Arrays; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Scope; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.SessionAttributes; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.multipart.MultipartHttpServletRequest; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.emc.metalnx.controller.utils.LoggedUserUtils; -import com.emc.metalnx.core.domain.entity.DataGridTemplate; -import com.emc.metalnx.core.domain.entity.DataGridTemplateField; -import com.emc.metalnx.core.domain.entity.DataGridUser; -import com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException; -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.core.domain.exceptions.DataGridTemplateAttrException; -import com.emc.metalnx.core.domain.exceptions.DataGridTemplateUnitException; -import com.emc.metalnx.core.domain.exceptions.DataGridTemplateValueException; -import com.emc.metalnx.core.domain.exceptions.DataGridTooLongTemplateNameException; -import com.emc.metalnx.modelattribute.enums.MetadataTemplateAccessType; -import com.emc.metalnx.modelattribute.metadatatemplate.MetadataTemplateForm; -import com.emc.metalnx.modelattribute.template.field.TemplateFieldForm; -import com.emc.metalnx.services.interfaces.CollectionService; -import com.emc.metalnx.services.interfaces.HeaderService; -import com.emc.metalnx.services.interfaces.MetadataTemplateException; -import com.emc.metalnx.services.interfaces.TemplateFieldService; -import com.emc.metalnx.services.interfaces.TemplateService; -import com.emc.metalnx.services.interfaces.UserService; -import com.emc.metalnx.services.interfaces.IRODSServices; - -@Controller -@Scope(WebApplicationContext.SCOPE_SESSION) -@SessionAttributes({ "selectedTemplates" }) -@RequestMapping(value = "/templates") -public class TemplateController { - - @Autowired - TemplateService templateService; - - @Autowired - TemplateFieldService templateFieldService; - - @Autowired - CollectionService collectionService; - - @Autowired - UserService userService; - - @Autowired - IRODSServices irodsServices; - - @Autowired - LoggedUserUtils loggedUserUtils; - - @Autowired - HeaderService headerService; - - @Value("${irods.zoneName}") - private String zoneName; - - // contains the template fields to be added to a brand new template - private List addTemplateFields; - - // contains the template fields to be removed from a brand new template - private List removeTemplateFields; - - // Auxiliary structure to handle template selection - private Set selectedTemplates = new HashSet(); - - // UI mode that will be shown when the rods user switches mode from admin to - // user and vice-versa - public static final String UI_USER_MODE = "user"; - public static final String UI_ADMIN_MODE = "admin"; - - private static final Logger logger = LoggerFactory.getLogger(TemplateController.class); - - @RequestMapping(value = "/") - public String index(final Model model, final HttpServletRequest request) - throws DataGridConnectionRefusedException, DataGridException { - - addTemplateFields = new ArrayList(); - removeTemplateFields = new ArrayList(); - - DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser(); - String uiMode = (String) request.getSession().getAttribute("uiMode"); - - if (uiMode == null || uiMode.isEmpty()) { - if (loggedUser.isAdmin()) { - uiMode = UI_ADMIN_MODE; - } else { - uiMode = UI_USER_MODE; - model.addAttribute("homePath", collectionService.getHomeDirectyForCurrentUser()); - model.addAttribute("publicPath", collectionService.getHomeDirectyForPublic()); - } - } - selectedTemplates.clear(); - model.addAttribute("uiMode", uiMode); - return "template/templateManagement"; - } - - @RequestMapping(value = "/listTemplateFields", method = RequestMethod.POST) - public String listTemplateFields(final Model model, @RequestParam("template") final String template) { - updateAddTemplateFieldsList(); - - List dataGridTemplateFields = templateService.listTemplateFields(template); - List templateFields = this.mapDataGridTempToFieldForm(dataGridTemplateFields); - DataGridTemplate metadataTemplate = templateService.findByName(template); - - if (addTemplateFields != null) { - templateFields.addAll(addTemplateFields); - } - if (removeTemplateFields != null) { - templateFields.removeAll(removeTemplateFields); - } - - model.addAttribute("metadataTemplate", metadataTemplate); - model.addAttribute("templateFields", templateFields); - model.addAttribute("resultSize", templateFields.size()); - model.addAttribute("foundTemplateFields", templateFields.size() > 0); - - return "template/templateFieldList"; - } - - @RequestMapping(value = "/listTemplateFieldsForCollections", method = RequestMethod.POST) - public String listTemplateFieldsForCollections(final Model model, - @RequestParam("templateIDsList") final long[] templateIDsList) { - MetadataTemplateForm templateForm = new MetadataTemplateForm(); - List templateFields = new ArrayList(); - List dataGridTemplateFields = new ArrayList(); - - if (templateIDsList.length > 0) { - for (long id : templateIDsList) { - dataGridTemplateFields.addAll(templateService.listTemplateFields(id)); - } - templateFields = this.mapDataGridTempToFieldForm(dataGridTemplateFields); - } - - model.addAttribute("templateForm", templateForm); - model.addAttribute("requestMapping", "/browse/applyTemplatesToCollections/"); - model.addAttribute("templateFields", templateFields); - model.addAttribute("resultSize", templateFields.size()); - model.addAttribute("foundTemplateFields", templateFields.size() > 0); - - return "collections/templateFieldListForCollections"; - } - - @RequestMapping(value = "/listTemplatesForCollections", method = RequestMethod.POST) - public String listTemplatesForCollections(final Model model) { - findAllTemplates(model); - return "collections/templateListForCollections :: templateList"; - } - - @RequestMapping(value = "/findAll/") - public String findAll(final Model model) { - findAllTemplates(model); - return "template/templateList :: templateList"; - } - - @RequestMapping(value = "/find/{templateName}") - public String findTemplate(final Model model, @PathVariable final String templateName) { - List templates = templateService.findByQueryString(templateName); - - model.addAttribute("templates", templates); - model.addAttribute("foundTemplates", templates.size() >= 0); - model.addAttribute("resultSize", templates.size()); - model.addAttribute("queryString", templateName); - - return "template/templateList :: templateList"; - } - - @RequestMapping(value = "add/") - public String newTemplate(final Model model, final HttpServletRequest request) { - MetadataTemplateForm templateForm = new MetadataTemplateForm(); - TemplateFieldForm templateFieldForm = new TemplateFieldForm(); - - if (addTemplateFields == null) { - addTemplateFields = new ArrayList(); - } - - templateForm.setOwner(loggedUserUtils.getLoggedDataGridUser().getUsername()); - - model.addAttribute("uiMode", request.getSession().getAttribute("uiMode")); - model.addAttribute("accessTypes", MetadataTemplateAccessType.values()); - model.addAttribute("metadataTemplateForm", templateForm); - model.addAttribute("templateFieldForm", templateFieldForm); - model.addAttribute("requestMapping", "/templates/add/action/"); - model.addAttribute("requestMappingForTemplateField", "/templates/addFieldToCurrentTemplate"); - - return "template/templateForm"; - } - - @RequestMapping(value = "add/action/") - public String addNewTemplate(final Model model, @ModelAttribute final MetadataTemplateForm templateForm, - final RedirectAttributes redirectAttributes) { - DataGridTemplate newTemplate = null; - - try { - newTemplate = new DataGridTemplate(); - newTemplate.setTemplateName(templateForm.getTemplateName()); - newTemplate.setDescription(templateForm.getDescription()); - newTemplate.setUsageInformation(templateForm.getUsageInformation()); - newTemplate.setOwner(loggedUserUtils.getLoggedDataGridUser().getUsername()); - newTemplate.setAccessType(templateForm.getAccessType().toString()); - - long templateID = templateService.createTemplate(newTemplate); - - if (templateID > 0) { - redirectAttributes.addFlashAttribute("templateAddedSuccessfully", newTemplate.getTemplateName()); - newTemplate.setId(templateID); - - // adding all fields to the template - for (TemplateFieldForm tempFieldForm : addTemplateFields) { - DataGridTemplateField dataGridTempField = mapTempFieldFormToDataGridTemp(tempFieldForm); - dataGridTempField.setTemplate(newTemplate); - templateFieldService.createTemplateField(dataGridTempField); - } - - // reseting the temporary fields to be added and removed from a - // template - addTemplateFields = new ArrayList(); - removeTemplateFields = new ArrayList(); - - return "redirect:/templates/"; - } - } catch (DataGridTooLongTemplateNameException e) { - redirectAttributes.addFlashAttribute("templateNotAddedSuccessfully", true); - redirectAttributes.addFlashAttribute("tooLongTemplateName", true); - } catch (Exception e) { - redirectAttributes.addFlashAttribute("templateNotAddedSuccessfully", true); - } - - return "redirect:/templates/add/"; - } - - @RequestMapping(value = "modify/") - public String showModifyTemplate(final Model model, final HttpServletRequest request) { - // DataGridTemplate template = - // templateService.findById(selectedTemplates.iterator().next()); - DataGridTemplate template = templateService.findById(Long.parseLong(request.getParameter("templateId"))); - - if (template == null) { - return "redirect:/templates/"; - } - - MetadataTemplateForm templateForm = new MetadataTemplateForm(); - templateForm.setId(template.getId()); - templateForm.setTemplateName(template.getTemplateName()); - templateForm.setDescription(template.getDescription()); - templateForm.setUsageInformation(template.getUsageInformation()); - templateForm.setOwner(template.getOwner()); - templateForm.setAccessType(template.getAccessType()); - templateForm.setVersion(template.getVersion()); - - TemplateFieldForm templateFieldForm = new TemplateFieldForm(); - - model.addAttribute("uiMode", request.getSession().getAttribute("uiMode")); - model.addAttribute("accessTypes", MetadataTemplateAccessType.values()); - model.addAttribute("metadataTemplateForm", templateForm); - model.addAttribute("templateFieldForm", templateFieldForm); - model.addAttribute("requestMapping", "/templates/modify/action/"); - - return "template/templateForm"; - } - - @RequestMapping(value = "modify/action/") - public String modifyTemplate(final Model model, @ModelAttribute final MetadataTemplateForm templateForm, - final RedirectAttributes redirectAttributes) { - - DataGridTemplate template = null; - - try { - template = templateService.findById(templateForm.getId()); - - if (template == null) { - throw new Exception("Cannot modify a non-existent template"); - } - DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser(); - - // throw error if user is not the template owner, rodsadmin or groupadmin - if (!(template.getOwner().equalsIgnoreCase(loggedUser.getUsername())) && loggedUser.isAdmin() == false && loggedUser.isGroupAdmin() == false) { - throw new Exception("Cannot modify a template belonging to another user"); - } - // throw error if logged user is not the groupadmin of the template owner's group - if (loggedUser.isGroupAdmin()){ - boolean groupAdminEditPermission = false; - String[] templateOwnerGroupList = userService.getGroupIdsForUser(template.getOwner(), irodsServices.getCurrentUserZone()); - Set groupAdminGroupList = new HashSet<>(Arrays.asList(userService.getGroupIdsForUser(loggedUser.getUsername(), irodsServices.getCurrentUserZone()))); - for(int i = 0; i< templateOwnerGroupList.length && !groupAdminEditPermission; i++){ - if (groupAdminGroupList.contains(templateOwnerGroupList[i])) { - groupAdminEditPermission = true; - } - } - if (!groupAdminEditPermission) { - throw new Exception("Cannot modify a template belonging to a user of other group"); - } - } - - template.setTemplateName(templateForm.getTemplateName()); - template.setDescription(templateForm.getDescription()); - template.setUsageInformation(templateForm.getUsageInformation()); - template.setAccessType(templateForm.getAccessType().toString()); - - List positions = templateForm.getAvuPositions(); - List attributes = templateForm.getAvuAttributes(); - List values = templateForm.getAvuValues(); - List units = templateForm.getAvuUnits(); - - if (attributes != null) { - for (int i = 0; i < attributes.size(); i++) { - for (int j = i + 1; j < attributes.size(); j++) { - if (attributes.get(i).equals(attributes.get(j)) && !values.get(i).isEmpty() - && values.get(i).equals(values.get(j)) && units.get(i).equals(units.get(j))) { - redirectAttributes.addFlashAttribute("repeatedAVU", true); - return "redirect:/templates/modify/"; - } - } - } - } - - if (positions != null) { - for (int i = 0; i < positions.size(); i++) { - String position = positions.get(i); - if (position.contains("mod_pos_")) { - addTemplateFields.get(Integer.parseInt(position.replace("mod_pos_", ""))) - .setAttribute(attributes.get(i)); - addTemplateFields.get(Integer.parseInt(position.replace("mod_pos_", ""))) - .setValue(values.get(i)); - addTemplateFields.get(Integer.parseInt(position.replace("mod_pos_", ""))).setUnit(units.get(i)); - } else if (position.contains("mod_id_")) { - templateFieldService.modifyTemplateField(Long.parseLong(position.replace("mod_id_", "")), - attributes.get(i), values.get(i), units.isEmpty() ? "" : units.get(i)); - template.setModified(true); - } - } - } - - // adding all fields to the template - for (TemplateFieldForm tempFieldForm : addTemplateFields) { - DataGridTemplateField dataGridTempField = mapTempFieldFormToDataGridTemp(tempFieldForm); - dataGridTempField.setTemplate(template); - templateFieldService.createTemplateField(dataGridTempField); - template.setModified(true); - } - - Set currentTempFields = template.getFields(); - - // removing fields from the template - for (TemplateFieldForm tempFieldForm : removeTemplateFields) { - DataGridTemplateField dataGridTempField = mapTempFieldFormToDataGridTemp(tempFieldForm); - dataGridTempField.setTemplate(template); - template.setModified(true); - - // removing template fields from template - if (currentTempFields.remove(dataGridTempField)) { - templateFieldService.deleteTemplateField(dataGridTempField); - logger.debug("Template removed from memory and database"); - } - // template field wasn't removed - else { - throw new Exception("Could not removed template field from memory."); - } - } - - template.setFields(currentTempFields); - templateService.modifyTemplate(template); - - // reseting the temporary fields to be added and removed from a template - addTemplateFields = new ArrayList(); - removeTemplateFields = new ArrayList(); - - redirectAttributes.addFlashAttribute("templateModifiedSuccessfully", template.getTemplateName()); - - selectedTemplates.clear(); - } catch (Exception e) { - logger.error("Could not modify template {}.", templateForm.getTemplateName()); - redirectAttributes.addFlashAttribute("templateNotModifiedSuccessfully", templateForm.getTemplateName()); - } - - return "redirect:/templates/"; - - } - - @RequestMapping(value = "delete/") - public String deleteTemplate(final RedirectAttributes redirectAttributes) { - - boolean deletionSuccessful = true; - - for (Long templateId : selectedTemplates) { - logger.debug("Deleting template [{}]", templateId); - DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser(); - if (templateService.findById(templateId).getOwner().equalsIgnoreCase(loggedUser.getUsername())) { - deletionSuccessful &= templateService.deleteTemplate(templateId); - } - } - - redirectAttributes.addFlashAttribute("templateRemovedSuccessfully", deletionSuccessful); - selectedTemplates.clear(); - - return "redirect:/templates/"; - } - - @RequestMapping(value = "/addFieldToCurrentTemplate") - public String addFieldToCurrentTemplate(final Model model, - @ModelAttribute final TemplateFieldForm templateFieldForm) { - updateAddTemplateFieldsList(); - - boolean isAddFieldsEmpty = false; - - try { - List existingTemplateFields = templateService - .listTemplateFields(templateFieldForm.getTemplateName()); - - DataGridTemplateField newDataGridField = mapTempFieldFormToDataGridTemp(templateFieldForm); - - List templateFields = new ArrayList(); - TemplateFieldForm newField = this.mapDataGridTempToFieldForm(newDataGridField, addTemplateFields.size()); - templateFields.add(newField); - - if (addTemplateFields.isEmpty()) { - isAddFieldsEmpty = true; - } - - // prevent an AVU from being added twice to a template - if (!addTemplateFields.contains(newField) - || addTemplateFields.contains(newField) && newField.getValue().equals("")) { - addTemplateFields.add(newField.getFormListPosition(), newField); - } - - model.addAttribute("templateFields", templateFields); - model.addAttribute("resultSize", templateFields.size()); - model.addAttribute("foundTemplateFields", templateFields.size() > 0); - - if (isAddFieldsEmpty && existingTemplateFields.isEmpty()) { - return "template/templateFieldList"; - } - } catch (DataGridTemplateAttrException e) { - logger.error(e.getMessage()); - } catch (DataGridTemplateValueException e) { - logger.error(e.getMessage()); - } catch (DataGridTemplateUnitException e) { - logger.error(e.getMessage()); - } - - return "template/templateFieldList :: avuRow"; - } - - @RequestMapping(value = "/removeFieldFromDB") - @ResponseStatus(value = HttpStatus.OK) - public void removeFieldFromDB(@RequestParam("templateFieldsIDList") final long[] templateFieldsIDList) { - for (long templateFieldID : templateFieldsIDList) { - DataGridTemplateField dataGridField = templateFieldService.findById(templateFieldID); - TemplateFieldForm field = this.mapDataGridTempToFieldForm(dataGridField); - - if (addTemplateFields.contains(field)) { - addTemplateFields.remove(field); - } - - // adding the field to the list that is needed to be removed from a template - if (!removeTemplateFields.contains(field)) { - removeTemplateFields.add(field); - } - } - } - - @RequestMapping(value = "/removeFieldFromTemplate") - @ResponseStatus(value = HttpStatus.OK) - public void removeFieldFromTemplate(@RequestParam("templateFieldsPosList") final int[] templateFieldsPosList) { - int addTemplateFieldsSize = addTemplateFields.size(); - - for (int templateFieldPos : templateFieldsPosList) { - if (templateFieldPos >= 0 && templateFieldPos < addTemplateFieldsSize) { - addTemplateFields.remove(templateFieldPos); - } - } - } - - @RequestMapping(value = "/exportTemplates/") - public void exportTemplates(final HttpServletResponse response) throws DataGridException { - try { - setReponseHeaderForJsonExport(response); - String jsonString; - - response.getOutputStream().write("{\"templates\":[".getBytes()); - int ctr = 0; - - for (Long templateId : selectedTemplates) { - jsonString = templateService.exportMetadataTemplateAsJsonString(Long.valueOf(templateId)); - - logger.debug("exporting template:{}", jsonString); - response.getOutputStream().write(jsonString.getBytes()); - if (ctr + 1 < selectedTemplates.size()) { - response.getOutputStream().write(",".getBytes()); - ctr++; - } - - } - - response.getOutputStream().write("]}".getBytes()); - - response.getOutputStream().flush(); - selectedTemplates.clear(); - - } catch (Exception e) { - logger.error("Could not export templates using metadata", e); - throw new DataGridException("unable to export template", e); - } - } - - @RequestMapping(value = "/import/", method = RequestMethod.POST) - @ResponseStatus(value = HttpStatus.OK) - @ResponseBody - public String importJsonFile(final Model model, final HttpServletRequest request, final RedirectAttributes redirect) - throws MetadataTemplateException, DataGridException { - - logger.info("importJsonFile()"); - - String responseString = "ok"; - - if (request instanceof MultipartHttpServletRequest) { - - MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; - List multipartFiles = multipartRequest.getFiles("file"); - String prefix = multipartRequest.getParameter("prefix"); - String suffix = multipartRequest.getParameter("suffix"); - InputStream jsonStream; - try { - jsonStream = multipartFiles.get(0).getInputStream(); - } catch (IOException e) { - logger.error("Io excepion getting JSON data for template", e); - throw new MetadataTemplateException("error getting JSON stream", e); - } - if (jsonStream == null) { - logger.error("no json input stream found"); - throw new MetadataTemplateException("error importing input stream, no json multipart file found"); - } - - // try { - String username = loggedUserUtils.getLoggedDataGridUser().getUsername(); - this.templateService.importMetadataTemplate(jsonStream, username, prefix, suffix); - - } - return responseString; - } - - /* - * ************************************************************************ - * ******************** HANDLING SESSION VARIABLES ************************ - * ************************************************************************ - */ - - @RequestMapping(value = "/selectTemplate/", method = RequestMethod.POST) - @ResponseBody - public boolean selectTemplate(@RequestParam("id") final String id) { - Long idLong = Long.valueOf(id); - if (!selectedTemplates.contains(idLong)) { - selectedTemplates.add(idLong); - } - - return canCurrentUserRemoveSelectedTemplates(); - } - - @RequestMapping(value = "/unselectTemplate/", method = RequestMethod.POST) - @ResponseBody - public boolean unselectTemplate(@RequestParam("id") final String id) { - Long idLong = Long.valueOf(id); - if (selectedTemplates.contains(idLong)) { - selectedTemplates.remove(idLong); - } - - return canCurrentUserRemoveSelectedTemplates(); - } - - /* - * ***************************************************************************** - * *************** ******************************** VALIDATION - * *************************************** - * ***************************************************************************** - * *************** - */ - - /** - * Validates a template name - * - * @param templateName - * @return True, if the template name can be used. False, otherwise. - */ - @ResponseBody - @RequestMapping(value = "isValidTemplateName/{templateName}/", method = RequestMethod.GET) - public String isValidUsername(@PathVariable final String templateName) { - - if (templateName.compareTo("") != 0) { - // if no users are found with this username, it means this username can be used - DataGridTemplate template = templateService.findByName(templateName); - return template == null ? "true" : "false"; - } - - return "false"; - } - - /* - * ************************************************************************* - * ***************************** PRIVATE METHODS *************************** - * ************************************************************************* - */ - - private void setReponseHeaderForJsonExport(final HttpServletResponse response) { - String loggedUser = loggedUserUtils.getLoggedDataGridUser().getUsername(); - String date = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); - - String filename = String.format("template_%s_%s.json", loggedUser, date); - - // Setting CSV Mime type - response.setContentType("application/json"); - response.setHeader("Content-disposition", "attachment;filename=" + filename); - } - - private void findAllTemplates(final Model model) { - - List templates = new ArrayList(); - String loggedUser = loggedUserUtils.getLoggedDataGridUser().getUsername(); - - templates = templateService.listPublicTemplates(); - templates.addAll(templateService.listPrivateTemplatesByUser(loggedUser)); - - Collections.sort(templates); - - model.addAttribute("templates", templates); - model.addAttribute("resultSize", templates.size()); - model.addAttribute("foundTemplates", templates.size() >= 0); - } - - /** - * Updates the form list position of each element of the addTemplateFields array - * list. - */ - private void updateAddTemplateFieldsList() { - if (addTemplateFields != null) { - // updating form list position once an element was removed from the - // array - int i = 0; - for (TemplateFieldForm templateFieldForm : addTemplateFields) { - templateFieldForm.setFormListPosition(i); - i++; - } - } - } - - /** - * Maps a single instance of DataGridTemplateField into a TemplateFieldForm - * object - * - * @param dataGridTempField DataGridTemplateField object - * @return TemplateFieldForm object - */ - private TemplateFieldForm mapDataGridTempToFieldForm(final DataGridTemplateField dataGridTempField) { - if (dataGridTempField == null) { - return null; - } - - TemplateFieldForm tempField = new TemplateFieldForm(); - tempField.setAttribute(dataGridTempField.getAttribute()); - tempField.setValue(dataGridTempField.getValue()); - tempField.setUnit(dataGridTempField.getUnit()); - tempField.setStartRange(dataGridTempField.getStartRange()); - tempField.setEndRange(dataGridTempField.getEndRange()); - tempField.setOrder(dataGridTempField.getOrder()); - tempField.setId(dataGridTempField.getId()); - - if (dataGridTempField.getTemplate() != null) { - tempField.setTemplateName(dataGridTempField.getTemplate().getTemplateName()); - } - - return tempField; - } - - /** - * Maps a single instance of DataGridTemplateField into a TemplateFieldForm - * object - * - * @param dataGridTempField DataGridTemplateField object - * @param position DataGridTemplateField object position into the - * memory array list of fields to be added to a - * template - * @return TemplateFieldForm object - */ - private TemplateFieldForm mapDataGridTempToFieldForm(final DataGridTemplateField dataGridTempField, - final int position) { - if (dataGridTempField == null) { - return null; - } - - TemplateFieldForm tempField = new TemplateFieldForm(); - tempField.setAttribute(dataGridTempField.getAttribute()); - tempField.setValue(dataGridTempField.getValue()); - tempField.setUnit(dataGridTempField.getUnit()); - tempField.setStartRange(dataGridTempField.getStartRange()); - tempField.setEndRange(dataGridTempField.getEndRange()); - tempField.setOrder(dataGridTempField.getOrder()); - tempField.setFormListPosition(position); - tempField.setId(dataGridTempField.getId()); - - if (dataGridTempField.getTemplate() != null) { - tempField.setTemplateName(dataGridTempField.getTemplate().getTemplateName()); - } - - return tempField; - } - - /** - * Maps a list of DataGridTemplateField objects into a list of TemplateFieldForm - * objects - * - * @param tempFields list of data grid template objects - * @return list of TemplateFieldForm objects - */ - private List mapDataGridTempToFieldForm(final List tempFields) { - List tempFieldFormList = new ArrayList(); - - if (tempFields == null || tempFields.isEmpty()) { - return tempFieldFormList; - } - - TemplateFieldForm tempField = null; - - int position = 0; - for (DataGridTemplateField dataGridTemplateField : tempFields) { - tempField = this.mapDataGridTempToFieldForm(dataGridTemplateField, position); - tempFieldFormList.add(tempField); - } - - return tempFieldFormList; - } - - /** - * Map a Template Field form object into a DataGridTemplateField object - * - * @param tempFieldForm template field form object to be mapped - * @return DataGridTemplateField object - * @throws DataGridTemplateAttrException - * @throws DataGridTemplateValueException - * @throws DataGridTemplateUnitException - */ - private DataGridTemplateField mapTempFieldFormToDataGridTemp(final TemplateFieldForm tempFieldForm) - throws DataGridTemplateAttrException, DataGridTemplateValueException, DataGridTemplateUnitException { - - if (tempFieldForm == null) { - return null; - } - - DataGridTemplateField templateField = new DataGridTemplateField(); - templateField.setAttribute(tempFieldForm.getAttribute()); - templateField.setValue(tempFieldForm.getValue()); - templateField.setUnit(tempFieldForm.getUnit()); - templateField.setStartRange(tempFieldForm.getStartRange()); - templateField.setEndRange(tempFieldForm.getEndRange()); - templateField.setOrder(tempFieldForm.getOrder()); - - if (tempFieldForm.getId() != null) { - templateField.setId(tempFieldForm.getId()); - } - - return templateField; - } - - /** - * Checks if the currently logged user can delete the list of selected templates - * - * @return true it is possible to delete selected templates, false otherwise - */ - private boolean canCurrentUserRemoveSelectedTemplates() { - DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser(); - for (Long templateId : selectedTemplates) { - if (!templateService.findById(templateId).getOwner().equalsIgnoreCase(loggedUser.getUsername())) { - return false; - } - } - return true; - } -} diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UserBookmarkController.java b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UserBookmarkController.java deleted file mode 100755 index 9c1260f64..000000000 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UserBookmarkController.java +++ /dev/null @@ -1,230 +0,0 @@ - /* Copyright (c) 2018, University of North Carolina at Chapel Hill */ - /* Copyright (c) 2015-2017, Dell EMC */ - - - -package com.emc.metalnx.controller; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.SessionAttributes; - -import com.emc.metalnx.core.domain.entity.DataGridUser; -import com.emc.metalnx.core.domain.entity.DataGridUserBookmark; -import com.emc.metalnx.services.interfaces.AdminServices; -import com.emc.metalnx.services.interfaces.GroupService; -import com.emc.metalnx.services.interfaces.HeaderService; -import com.emc.metalnx.services.interfaces.IRODSServices; -import com.emc.metalnx.services.interfaces.UserBookmarkService; -import com.emc.metalnx.services.interfaces.UserService; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@SessionAttributes({ "addBookmarks", "removeBookmarks"}) -@RequestMapping(value = "/userBookmarks") -public class UserBookmarkController { - @Autowired - UserBookmarkService userBookmarkService; - - @Autowired - UserService userService; - - @Autowired - GroupService groupService; - - @Autowired - IRODSServices irodsServices; - - @Autowired - AdminServices adminServices; - - @Autowired - HeaderService headerService; - - private Set addBookmark = new HashSet(); - private Set removeBookmark = new HashSet(); - - private int totalUserBookmarks; - private int totalUserBookmarksFiltered; - - private static final String REQUEST_OK = "OK"; - private static final String REQUEST_ERROR = "ERROR"; - - public final static Logger logger = LoggerFactory.getLogger(UserBookmarkController.class); - - @RequestMapping(value = "/") - public String listBookmarks(final Model model) { - String loggedUsername = irodsServices.getCurrentUser(); - String loggedUserZoneName = irodsServices.getCurrentUserZone(); - DataGridUser user = userService.findByUsernameAndAdditionalInfo(loggedUsername, loggedUserZoneName); - - List userBookmakrs = user.getBookmarksSorted(); - logger.info("userBookmarks found...."); - logger.info(userBookmakrs.toString()); - model.addAttribute("userBookmarks", userBookmakrs); - model.addAttribute("foundUserBookmarks", !userBookmakrs.isEmpty()); - return "bookmarks/userBookmarks"; - } - - @RequestMapping(value = "/addBookmark/") - @ResponseStatus(value = HttpStatus.OK) - public void addBookmark(@RequestParam("path") final String path, final Model model) { - logger.info("addBookmark()"); - // Remove from the in-memory list before checking database - if (removeBookmark.contains(path)) { - removeBookmark.remove(path); - } else { - addBookmark.add(path); - model.addAttribute("addBookmark", addBookmark); - } - } - - @RequestMapping(value = "/removeBookmark/") - @ResponseStatus(value = HttpStatus.OK) - public void removeBookmark(@RequestParam("path") final String path) { - logger.info("removeBookmark()"); - // Removing from the in-memory bookmarks list before checking database - if (addBookmark.contains(path)) { - addBookmark.remove(path); - } else { - removeBookmark.add(path); - } - } - - @RequestMapping(value = "/addBookmarkToUser/") - @ResponseBody - public String addBookmarkToGroup(@RequestParam("username") final String username, - @RequestParam("path") final String path) { - logger.info("addBookmarkToGroup()"); - String zoneName = irodsServices.getCurrentUserZone(); - DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, zoneName); - - if (user == null) { - return REQUEST_ERROR; - } - - Set toAdd = new HashSet(); - toAdd.add(path); - - return userBookmarkService.updateBookmarks(user, toAdd, null) ? REQUEST_OK : REQUEST_ERROR; - } - - @RequestMapping(value = "/removeBookmarkFromUser/") - @ResponseBody - public String removeBookmarkFromGroup(@RequestParam("username") final String username, - @RequestParam("path") final String path) { - logger.info("removeBookmarkFromGroup()"); - logger.info("Request for removing a {} bookmark from {}", path, username); - - String zoneName = irodsServices.getCurrentUserZone(); - DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, zoneName); - - if (user == null) { - return REQUEST_ERROR; - } - - Set toRemove = new HashSet(); - toRemove.add(path); - - return userBookmarkService.updateBookmarks(user, null, toRemove) ? REQUEST_OK : REQUEST_ERROR; - } - - @RequestMapping(value = "/bookmarksPaginated") - @ResponseBody - public String bookmarksPaginated(final HttpServletRequest request) { - int draw = Integer.parseInt(request.getParameter("draw")); - int start = Integer.parseInt(request.getParameter("start")); - int length = Integer.parseInt(request.getParameter("length")); - String searchString = request.getParameter("search[value]"); - int orderColumn = Integer.parseInt(request.getParameter("order[0][column]")); - String orderDir = request.getParameter("order[0][dir]"); - boolean onlyCollections = Boolean.parseBoolean(request.getParameter("onlyCollections")); - String loggedUsername = irodsServices.getCurrentUser(); - String loggedUserZoneName = irodsServices.getCurrentUserZone(); - DataGridUser user = userService.findByUsernameAndAdditionalInfo(loggedUsername, loggedUserZoneName); - String[] orderBy = { "name", "path", "created_at", "is_collection" }; - - // checking if there is another column to order by - boolean has2ndColumnToOrderBy = request.getParameter("order[1][column]") != null; - - List userBookmarks = null; - if (has2ndColumnToOrderBy) { - List orderByList = new ArrayList(); - List orderDirList = new ArrayList(); - - int firstCol = Integer.parseInt(request.getParameter("order[0][column]")); - int secondCol = Integer.parseInt(request.getParameter("order[1][column]")); - - orderByList.add(orderBy[firstCol]); - orderDirList.add(request.getParameter("order[0][dir]")); - orderByList.add(orderBy[secondCol]); - orderDirList.add(request.getParameter("order[1][dir]")); - - userBookmarks = userBookmarkService.findBookmarksPaginated(user, start, length, searchString, orderByList, - orderDirList, onlyCollections); - } else { - userBookmarks = userBookmarkService.findBookmarksPaginated(user, start, length, searchString, - orderBy[orderColumn], orderDir, onlyCollections); - } - - ObjectMapper mapper = new ObjectMapper(); - Map jsonResponse = new HashMap(); - String jsonString = ""; - if ("".equals(searchString)) { - totalUserBookmarks = user.getBookmarks().size(); - totalUserBookmarksFiltered = user.getBookmarks().size(); - } else { - totalUserBookmarksFiltered = userBookmarks.size(); - } - - jsonResponse.put("draw", String.valueOf(draw)); - jsonResponse.put("recordsTotal", String.valueOf(totalUserBookmarks)); - jsonResponse.put("recordsFiltered", String.valueOf(totalUserBookmarksFiltered)); - jsonResponse.put("data", userBookmarks); - - try { - jsonString = mapper.writeValueAsString(jsonResponse); - } catch (JsonProcessingException e) { - logger.error("Could not parse user bookmarks to json: {}", e.getMessage()); - } - return jsonString; - } - - public void clearBookmarksLists() { - addBookmark.clear(); - removeBookmark.clear(); - } - - /** - * @return the addBookmark - */ - public Set getAddBookmark() { - return addBookmark; - } - - /** - * @return the removeBookmark - */ - public Set getRemoveBookmark() { - return removeBookmark; - } - -} diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UserController.java b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UserController.java index b5af3f680..19d7a6ec8 100755 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UserController.java +++ b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UserController.java @@ -52,7 +52,6 @@ import com.emc.metalnx.services.interfaces.GroupService; import com.emc.metalnx.services.interfaces.HeaderService; import com.emc.metalnx.services.interfaces.IRODSServices; -import com.emc.metalnx.services.interfaces.UserBookmarkService; import com.emc.metalnx.services.interfaces.UserService; import com.emc.metalnx.services.interfaces.ZoneService; import com.fasterxml.jackson.core.JsonProcessingException; @@ -80,12 +79,6 @@ public class UserController { @Autowired ZoneService zoneService; - @Autowired - UserBookmarkService userBookmarkService; - - @Autowired - UserBookmarkController userBookmarkController; - @Autowired LoggedUserUtils loggedUserUtils; @@ -129,7 +122,7 @@ public String listUsers(Model model) { */ @RequestMapping(value = "/find/{query}/") public String listUsersByPageAndQuery(Model model, @PathVariable String query) { - List users = userService.findByQueryString(query); + List users = userService.findByUsername(query); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String usernameLogged = (String) auth.getPrincipal(); @@ -150,15 +143,13 @@ public String listUsersByPageAndQuery(Model model, @PathVariable String query) { @ResponseBody public String findUserByQueryy(Model model, @PathVariable String query) { ObjectMapper mapper = new ObjectMapper(); - List users = userService.findByQueryString(query); + List users = userService.findByUsername(query); List> userList = new ArrayList>(); for (DataGridUser user : users) { Map userMap = new LinkedHashMap(); userMap.put("username", user.getUsername()); - userMap.put("first_name", user.getFirstName()); - userMap.put("last_name", user.getLastName()); userList.add(userMap); } @@ -284,13 +275,7 @@ public String addUser(@ModelAttribute UserForm user, HttpServletRequest request, DataGridUser newUser = new DataGridUser(); newUser.setAdditionalInfo(user.getAdditionalInfo()); newUser.setUsername(user.getUsername()); - newUser.setFirstName(user.getFirstName()); - newUser.setLastName(user.getLastName()); - newUser.setEmail(user.getEmail()); newUser.setUserType(user.getUserType()); - newUser.setOrganizationalRole(user.getOrganizationalRole() != null ? user.getOrganizationalRole() : ""); - newUser.setCompany(user.getCompany() != null ? user.getCompany() : ""); - newUser.setDepartment(user.getDepartment() != null ? user.getDepartment() : ""); logger.info("adding user:{}", newUser); String[] groupList = groupsToBeAdded.toArray(new String[groupsToBeAdded.size()]); @@ -328,8 +313,6 @@ public String addUser(@ModelAttribute UserForm user, HttpServletRequest request, DataGridUser userForGroups = userService.findByUsernameAndAdditionalInfo(newUser.getUsername(), newUser.getAdditionalInfo()); - // User bookmarks - updateBookmarksList(newUser.getUsername(), newUser.getAdditionalInfo()); userService.modifyUser(userForGroups); redirectAttributes.addFlashAttribute("userAddedSuccessfully", user.getUsername()); @@ -390,30 +373,8 @@ public String showModifyUserForm(@PathVariable String username, @PathVariable St 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); @@ -479,17 +440,7 @@ public String modifyUser(@ModelAttribute UserForm userForm, HttpServletRequest r 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()); userService.modifyUser(user); userService.updateGroupList(user, groups); @@ -701,20 +652,12 @@ public void usersToCSVFile(HttpServletResponse response) { List users = userService.findAll(); List rows = new ArrayList(); rows.add( - "Username;Zone;FirstName;LastName;Email;UserType;UserProfile;Title;Company;Department;OrganizationalRole\n"); + "Username;Zone;UserType\n"); for (DataGridUser user : users) { rows.add(user.getUsername() + ";"); rows.add(user.getAdditionalInfo() + ";"); - rows.add((user.getFirstName() == null ? "" : user.getFirstName()) + ";"); - rows.add((user.getLastName() == null ? "" : user.getLastName()) + ";"); - rows.add((user.getEmail() == null ? "" : user.getEmail()) + ";"); rows.add(user.getUserType() + ";"); - rows.add((user.getUserProfile() == null ? "" : user.getUserProfile()) + ";"); - rows.add((user.getTitle() == null ? "" : user.getTitle()) + ";"); - rows.add((user.getCompany() == null ? "" : user.getCompany()) + ";"); - rows.add((user.getDepartment() == null ? "" : user.getDepartment()) + ";"); - rows.add(user.getOrganizationalRole() == null ? "" : user.getOrganizationalRole()); rows.add("\n"); } @@ -767,34 +710,4 @@ public String isValidUsername(@PathVariable String username) { return "false"; } - - /* - * ***************************************************************************** - * *************** ******************************** PRIVATE - * *************************************** - * ***************************************************************************** - * *************** - */ - - /** - * Persists the changes on the bookmarks lists for the given group on the - * database - * - * @param groupName - */ - private void updateBookmarksList(String username, String additionalInfo) { - if (username == null || username.isEmpty() || additionalInfo == null || additionalInfo.isEmpty()) { - return; - } - - DataGridUser user = userService.findByUsernameAndAdditionalInfo(username, additionalInfo); - - if (user != null) { - Set bookmarksToAdd = userBookmarkController.getAddBookmark(); - Set bookmarksToRemove = userBookmarkController.getRemoveBookmark(); - userBookmarkService.updateBookmarks(user, bookmarksToAdd, bookmarksToRemove); - } - - userBookmarkController.clearBookmarksLists(); - } } diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/jobs/SyncJobs.java b/src/metalnx-web/src/main/java/com/emc/metalnx/jobs/SyncJobs.java deleted file mode 100755 index 338aeaf3e..000000000 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/jobs/SyncJobs.java +++ /dev/null @@ -1,246 +0,0 @@ -/* Copyright (c) 2018, University of North Carolina at Chapel Hill */ -/* Copyright (c) 2015-2017, Dell EMC */ - -package com.emc.metalnx.jobs; - -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -import org.irods.jargon.core.connection.AuthScheme; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.connection.auth.AuthResponse; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.protovalues.UserTypeEnum; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.pub.UserAO; -import org.irods.jargon.core.pub.domain.User; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; - -import com.emc.metalnx.core.domain.dao.UserDao; -import com.emc.metalnx.core.domain.entity.DataGridUser; - -@EnableScheduling -public class SyncJobs { - - @Autowired - UserDao userDao; - - @Autowired - IRODSAccessObjectFactory irodsAccessObjectFactory; - - private IRODSAccount irodsAccount; - - private String irodsHost; - private String irodsPort; - private String irodsZone; - private String irodsJobUser; - private String irodsJobPassword; - - @Value("${runSyncJobs}") - private String runSyncJobs; - - @Value("${jobs.irods.auth.scheme}") - private String irodsAuthScheme; - - private static final Logger logger = LoggerFactory.getLogger(SyncJobs.class); - - @Scheduled(fixedDelay = 1500000) - public void sync() throws JargonException { - if (runSyncJobs.trim().compareTo("true") == 0) { - logger.debug("Starting synchronization job..."); - - if (this.irodsAccount == null) { - authenticateIRODSAccount(); - } - - this.executeUsersSync(); - } else { - logger.debug("Ignoring synchronization jobs..."); - } - } - - private void executeUsersSync() { - - try { - // Gets all users existing in iRODS - List irodsUsers = this.findAllIRODSUsers(); - - HashMap hashMapIRodsUsers = new HashMap(); - for (User user : irodsUsers) { - if (user.getUserType() != UserTypeEnum.RODS_GROUP) { - hashMapIRodsUsers.put(Long.valueOf(user.getId()), user); - } - } - - // Gets all users existing in our database - List dbUsers = userDao.findAll(DataGridUser.class); - - HashMap hashMapDBUsers = new HashMap(); - for (DataGridUser dataGridUser : dbUsers) { - hashMapDBUsers.put(dataGridUser.getDataGridId(), dataGridUser); - } - - Set irodsUserIDs = hashMapIRodsUsers.keySet(); - Set dbDataGridUserIDs = hashMapDBUsers.keySet(); - - // case 1: a user exists in our database but doesn't exist in iRODS - // action: remove this user from our database - for (Long id : dbDataGridUserIDs) { - if (!irodsUserIDs.contains(id)) { - String usernameDeleted = hashMapDBUsers.get(id).getUsername(); - long userID = hashMapDBUsers.get(id).getId(); - long dataGridID = hashMapDBUsers.get(id).getDataGridId(); - - userDao.deleteByDataGridId(id); - - // logger.info("[DELETE] User " + usernameDeleted + " (iRODS id: " + userID + ") - // " + " (DataGrid id: " - // + dataGridID + ") " + " was deleted from database."); - } - } - - // case 2: a user exists in iRODS but doesn't exist in our database - // action: add this user to our database - for (Long id : irodsUserIDs) { - if (!dbDataGridUserIDs.contains(id)) { - User irodsUserMissingInDB = hashMapIRodsUsers.get(id); - - DataGridUser userMissingInDB = new DataGridUser(); - userMissingInDB.setDataGridId(Long.valueOf(irodsUserMissingInDB.getId())); - userMissingInDB.setUsername(irodsUserMissingInDB.getName()); - userMissingInDB.setAdditionalInfo(irodsUserMissingInDB.getZone()); - userMissingInDB.setUserType(irodsUserMissingInDB.getUserType().getTextValue()); - userMissingInDB.setEnabled(true); - - userDao.save(userMissingInDB); - - // logger.info("[INSERT] User " + userMissingInDB.getUsername() + " (iRODS id: " - // + userMissingInDB.getDataGridId() + ") " + " was added to database."); - } - } - - } catch (Exception e) { - logger.error("Could not synchronize database and iRODS (users): ", e); - } - - } - - private void authenticateIRODSAccount() throws JargonException { - AuthResponse authResponse = null; - - if (this.irodsAccount == null) { - // Getting iRODS protocol set - IRODSAccount tempAccount = IRODSAccount.instance(irodsHost, Integer.parseInt(irodsPort), irodsJobUser, - irodsJobPassword, "", irodsZone, "demoResc"); - - tempAccount.setAuthenticationScheme(AuthScheme.findTypeByString(irodsAuthScheme)); - authResponse = irodsAccessObjectFactory.authenticateIRODSAccount(tempAccount); - - if (authResponse.isSuccessful()) { - this.irodsAccount = authResponse.getAuthenticatedIRODSAccount(); - } - } - } - - private List findAllIRODSUsers() throws JargonException { - - // Retrieving logging user - UserAO userAO = irodsAccessObjectFactory.getUserAO(this.irodsAccount); - - // returns all users existing in iRODS - return userAO.findAll(); - - } - - /** - * @return the irodsHost - */ - public String getIrodsHost() { - return irodsHost; - } - - /** - * @param irodsHost the irodsHost to set - */ - public void setIrodsHost(String irodsHost) { - this.irodsHost = irodsHost; - } - - /** - * @return the irodsPort - */ - public String getIrodsPort() { - return irodsPort; - } - - /** - * @param irodsPort the irodsPort to set - */ - public void setIrodsPort(String irodsPort) { - this.irodsPort = irodsPort; - } - - /** - * @return the irodsZone - */ - public String getIrodsZone() { - return irodsZone; - } - - /** - * @param irodsZone the irodsZone to set - */ - public void setIrodsZone(String irodsZone) { - this.irodsZone = irodsZone; - } - - /** - * @return the irodsJobUser - */ - public String getIrodsJobUser() { - return irodsJobUser; - } - - /** - * @param irodsJobUser the irodsJobUser to set - */ - public void setIrodsJobUser(String irodsJobUser) { - this.irodsJobUser = irodsJobUser; - } - - /** - * @return the irodsJobPassword - */ - public String getIrodsJobPassword() { - return irodsJobPassword; - } - - /** - * @param irodsJobPassword the irodsJobPassword to set - */ - public void setIrodsJobPassword(String irodsJobPassword) { - this.irodsJobPassword = irodsJobPassword; - } - - public UserDao getUserDao() { - return userDao; - } - - public void setUserDao(UserDao userDao) { - this.userDao = userDao; - } - - public IRODSAccessObjectFactory getIrodsAccessObjectFactory() { - return irodsAccessObjectFactory; - } - - public void setIrodsAccessObjectFactory(IRODSAccessObjectFactory irodsAccessObjectFactory) { - this.irodsAccessObjectFactory = irodsAccessObjectFactory; - } -} diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/enums/URLMap.java b/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/enums/URLMap.java index 16a12639a..a4c1c7d56 100755 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/enums/URLMap.java +++ b/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/enums/URLMap.java @@ -16,16 +16,7 @@ public class URLMap { public static final String URL_FIND_USER = "/users/find/"; public static final String URL_FIND_ALL_USER = "/users/findAll/"; public static final String URL_USERS_CSV_REPORT = "/users/usersToCSVFile/"; - public static final String URL_USER_BOOKMARKS = "/userBookmarks/"; - public static final String URL_STARRED_ITEMS = "/favorites/"; - public static final String URL_USER_PROFILE_MANAGEMENT = "/users/profile/"; - public static final String URL_ADD_USER_PROFILE = "/users/profile/create/"; - public static final String URL_USER_PROFILE_VALIDATE_PROFILE_NAME = "/metalnx/users/profile/isValidProfileName/"; - public static final String URL_USER_PROFILES_CSV_REPORT = "/users/profile/profilesToCSVFile/"; - - public static final String URL_REMOVE_USER_PROFILE = "/metalnx/users/profile/remove/"; - public static final String URL_MODIFY_USER_PROFILE = "/metalnx/users/profile/modify/"; public static final String URL_USER_VALIDATE_USERNAME = "/metalnx/users/isValidUsername/"; public static final String URL_GROUPS_MANAGEMENT = "/groups/"; @@ -45,15 +36,6 @@ public class URLMap { public static final String URL_METADATA_SEARCH = "/metadata/"; public static final String URL_GLOBAL_SEARCH = "/search/"; - public static final String URL_TEMPLATE_MANAGEMENT = "/templates/"; - public static final String URL_ADD_TEMPLATE = "add/"; - public static final String URL_MODIFY_TEMPLATE = "modify/"; - public static final String URL_DELETE_TEMPLATE = "delete/"; - public static final String URL_DELETE_TEMPLATE_FIELD_FROM_DB = "/metalnx/templates/removeFieldFromDB"; - public static final String URL_DELETE_TEMPLATE_FIELD = "/metalnx/templates/removeFieldFromTemplate"; - public static final String URL_TEMPLATE_VALIDATE_NAME = "/metalnx/templates/isValidTemplateName/"; - public static final String URL_EXPORT_TEMPLATE_XML = "exportTemplatesToXMLFile/"; - public static final String URL_RESOURCES_MANAGEMENT = "/resources/"; public static final String URL_ADD_RESOURCE = "/resources/add/"; public static final String URL_ADD_RESOURCE_ACTION = "/resources/add/action/"; diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/user/UserForm.java b/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/user/UserForm.java index 48c32d0f2..37bd0f1d5 100755 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/user/UserForm.java +++ b/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/user/UserForm.java @@ -5,8 +5,6 @@ package com.emc.metalnx.modelattribute.user; -import com.emc.metalnx.core.domain.entity.UserProfile; - public class UserForm { private String username; @@ -21,8 +19,6 @@ public class UserForm { private String company; private String department; - private UserProfile userProfile; - /** * @return the username */ @@ -107,18 +103,6 @@ public long getDataGridId() { public void setDataGridId(long dataGridId) { this.dataGridId = dataGridId; } - /** - * @return the userProfile - */ - public UserProfile getUserProfile() { - return userProfile; - } - /** - * @param userProfile the userProfile to set - */ - public void setUserProfile(UserProfile userProfile) { - this.userProfile = userProfile; - } /** * @return the userType */ diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/user/profile/UserProfileForm.java b/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/user/profile/UserProfileForm.java deleted file mode 100755 index 9b046fb5a..000000000 --- a/src/metalnx-web/src/main/java/com/emc/metalnx/modelattribute/user/profile/UserProfileForm.java +++ /dev/null @@ -1,52 +0,0 @@ - /* Copyright (c) 2018, University of North Carolina at Chapel Hill */ - /* Copyright (c) 2015-2017, Dell EMC */ - - - -package com.emc.metalnx.modelattribute.user.profile; - -public class UserProfileForm { - - private String profileId; - private String profileName; - private String description; - - /** - * @return the profileName - */ - public String getProfileName() { - return profileName; - } - /** - * @param profileName the profileName to set - */ - public void setProfileName(String profileName) { - this.profileName = profileName; - } - /** - * @return the description - */ - public String getDescription() { - return description; - } - /** - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - /** - * @return the profileId - */ - public String getProfileId() { - return profileId; - } - /** - * @param profileId the profileId to set - */ - public void setProfileId(String profileId) { - this.profileId = profileId; - } - - -} diff --git a/src/metalnx-web/src/main/resources/emc-metalnx-jobs-context.xml b/src/metalnx-web/src/main/resources/emc-metalnx-jobs-context.xml index 206a579c5..96cb41d5f 100755 --- a/src/metalnx-web/src/main/resources/emc-metalnx-jobs-context.xml +++ b/src/metalnx-web/src/main/resources/emc-metalnx-jobs-context.xml @@ -18,12 +18,4 @@ - - - - - - - - - \ No newline at end of file + diff --git a/src/metalnx-web/src/main/resources/i18n/messages_en.properties b/src/metalnx-web/src/main/resources/i18n/messages_en.properties index ffb1e6b61..518a53f47 100644 --- a/src/metalnx-web/src/main/resources/i18n/messages_en.properties +++ b/src/metalnx-web/src/main/resources/i18n/messages_en.properties @@ -54,10 +54,8 @@ dashboard.summary.table.files.label=Files dashboard.panel.summary.label=Summary dashboard.panel.total.storage.error.title=Please, check if Metalnx remote monitor is running on all servers. -dashboard.card.add.template=Add template dashboard.card.add.user=Add user dashboard.card.add.group=Add group -dashboard.card.add.profile=Add profile dashboard.panel.mlx.msi.title=Metalnx Microservices dashboard.card.msi.version.not.supported=Unsupported version found. dashboard.card.msi.not.installed=Metalnx MSI package not installed. @@ -119,8 +117,6 @@ trash.deletion.confirmation=Are you sure you want to permanently delete all item empty.trash.label=Empty Trash card.users.title=Users card.groups.title=Groups -card.profiles.title=Profiles -card.templates.title=Templates msi.package.installed=Installed msi.package.not.installed=Not Installed msi.package.mlx.accordion=Metalnx @@ -161,32 +157,11 @@ users.add.form.password.label=Password users.add.form.password.confirm.label=Password Confirmation users.add.form.zone.label=Zone users.add.form.role.label=iRODS System Role -users.add.form.organizational.role.label=Organizational Role -users.add.form.profile.label=Profile -users.add.form.first.name.label=First Name -users.add.form.last.name.label=Last Name -users.add.form.email.label=Email address -users.add.form.user.field1.label=Company -users.add.form.user.field2.label=Department -users.add.form.user.field3.label=Title users.add.form.username.placeholder=Enter username users.add.form.password.placeholder=Enter password users.add.form.password.confirm.placeholder=Re-enter password users.add.form.zone.placeholder=Enter zone name -users.add.form.first.name.placeholder=Enter first name -users.add.form.last.name.placeholder=Enter last name -users.add.form.email.placeholder=Enter email -users.add.form.user.field1.placeholder=Enter company -users.add.form.user.field2.placeholder=Enter department -users.add.form.user.field3.placeholder=Enter title -users.add.form.organizational.role.researcher=Researcher -users.add.form.organizational.role.admin=System Administrator -users.add.form.organizational.role.curator=Data Curator -users.add.form.organizational.role.chief.researcher=Chief Researcher -users.add.form.organizational.role.manager=Manager -users.add.form.organizational.role.director=Director - users.add.available.groups.label=Available Groups users.add.attach.action.label=Attach @@ -200,9 +175,6 @@ users.add.group.table.details.label=Details users.add.additional.permissions.label=Additional Permissions users.add.view.users.in.group.button=View Users -users.add.form.profile.select.label=Select the profile -users.add.form.profile.select.notavailable.label=No profiles available - users.add.error.duplicate.user=Duplicate user, cannot add users.add.error=Error adding user @@ -226,36 +198,6 @@ users.validation.passwords.not.match=Passwords do not match users.validation.password.min.length=The password must have at least 5 characters users.validation.additionalinfo.blank=The zone is required and cannot be blank -profiles.validation.name.duplicated=Another profile already has that name -profiles.validation.name.blank=The profile name is required and cannot be blank - -## Profile management -users.profile.management.page.title=Profiles -users.profile.management.page.title.popover=A profile is a list of groups that can be associated to users. Profiles are very handy when different users must be associated to a common set of groups. -users.profile.management.menu.title=Profiles -users.profile.management.menu.title.tooltip=Manage Profiles -users.profile.management.add.button=Add Profile - -users.profiles.add.group.table.results.found.label=user profile(s) found - -users.profile.table.header.name=Profile Name -users.profile.table.header.description=Profile Description -users.profile.table.header.action=Action -users.profile.add.form.settings.label=User Profile Form -users.profile.add.form.name=Profile Name -users.profile.add.form.description=Description -users.profile.add.form.attach.to.group.label=Groups -users.profile.management.result.number.found=group(s) found -users.profile.management.add.form.table.attach.label=Attach - -users.profile.add.form.placeholder.name=Enter the profile name -users.profile.add.form.placeholder.description=Enter the description of the profile - -users.profile.removal.confirmation.label=Are you sure you want to remove the user profile - -users.profile.management.delete.button=Delete -users.profile.management.edit.button=Edit - # Groups groups.menu.title=Groups groups.not.removed.successfully=could not be deleted. Please, check if the group home directory is empty. @@ -391,12 +333,9 @@ icat.menu.title=iCAT private.menu.title=Private Library # Template labels -user.profile.label=User Profile user.preferences.label=Preferences user.logout.label=Logout -template.add.attribute=Add Attribute prferences.title.popover=User Preferences -templates.metadata.import=Import JSON template # Preferences Page preferences.page.title=Preferences @@ -444,7 +383,6 @@ collections.management.table.collection.path.label=Path collections.management.table.matches.label=Matches collections.management.checksum.label=Checksum collections.management.replicas.label=Replicas -collections.management.table.bookmark.label=Shared Link collections.management.table.recursive.label=Recursive collections.management.table.apply.recursion.label=Apply to subcollections and files collections.management.shared.links.list.by.user=Shared by users @@ -468,7 +406,6 @@ collections.management.table.resource.label=Resource collections.management.add.metadata.modal.empty.attribute=The attribute field is required and cannot be blank collections.management.add.metadata.modal.empty.value=The value field is required and cannot be blank -collections.management.progress.label.apply.template=Applying templates... collections.management.progress.label.download=Preparing files for download... collections.management.progress.label.permissions=Retrieving permissions... collections.management.btn.action.add.collection=Add Collection @@ -549,13 +486,6 @@ metadata.search.page.title.popover=Search for files and collections by AVU metad metadata.search.prompt=Search for data objects and collections that match all conditions below (Logical AND): metadata.search.menu.title=Search metadata.pluggable.search.menu.title=Global Search -metadata.template.management.menu.title=Templates -metadata.template.management.page.title=Templates -metadata.template.management.page.title.popover=A Template is a list of metadata that can be associated to one or more objects (collections of files). It can be set as public to allow other users or private to keep it visible only to its owner. -metadata.template.table.name.title=Name -metadata.template.table.description.title=Description -metadata.template.management.result.number.found=template(s) found -metadata.template.avu.result.number.found=attribute(s) found metadata.search.add.criteria=Criteria no.metadata.available=No metadata available metadata.modal.add.title=Add Metadata @@ -586,46 +516,6 @@ metadata.table.header.actions=Actions metadata.table.button.label.save=Save metadata.table.button.label.cancel=Cancel - -# Template -templates.management.table.title=Metadata -templates.management.table.name.label=Template -templates.management.table.owner.label=Owner -templates.management.table.version.label=Version -templates.management.table.description.label=Description -templates.management.table.usageInformation.label=Usage Information -templates.management.table.accessType.label=Visibility -templates.management.table.createTs.label=Created -templates.management.table.modifyTs.label=Modified -templates.management.table.action.label=Action -template.metadata.access_type.SYSTEM=Public -template.metadata.access_type.PRIVATE=Private -template.metadata.new.form.add.metadata=Metadata -template.metadata.new.form.delete.metadata=Delete -template.metadata.new.form.edit.metadata=Edit - -#Template Fields -template.fields.management.table.attribute.label=Attribute -templates.fields.management.table.value.label=Value -templates.fields.management.table.unit.label=Unit -templates.fields.management.table.startRange.label=Start Range -templates.fields.management.table.endRange.label=End Range -templates.fields.management.table.order.label=Order -templates.fields.management.table.required.label=(required) -template.fields.management.result.number.found=metadata field(s) -templates.fields.management.table.template.label=Template - -templates.metadata.access_type.private.label=Only {0} will view/edit/apply this template. -templates.metadata.access_type.system.label=All users will be able to view/apply this template. - -templates.validation.name.duplicated=Another template already has that name -templates.validation.name.blank=Template name is required and cannot be blank -templates.not.added.successfully=Template could not be added. -templates.name.too.long=Template name cannot exceed 100 characters. -templates.duplicated.avus=Duplicated AVUs are not permitted to be saved. -templates.confirmation.removal.label=Do you want to remove the selected templates? -templates.edit.button=Edit - # Permissions permissions.page.title=Permissions permissions.page.add.button=Permissions @@ -654,8 +544,6 @@ permission.validation.group.nonexistent=Group does not exist # Confirmation messages confirmation.user.removal.title=User Remove confirmation.user.removal.label=Do you really want to remove the user -confirmation.profile.removal.title=Profile Remove -confirmation.profile.removal.label=Do you really want to remove these templates confirmation.removal.label=Do you really want to remove confirmation.removal.title=Confirmation @@ -671,77 +559,35 @@ confirmation.cancel.title=Cancel Operation confirmation.cancel.label=If you choose to cancel this form, you will lose any unsaved data. Do you want to continue confirmation.message.ok=Ok -# Success messages -templates.metadata.success.import.label=Ok. -templates.metadata.success.import.message=All the templates have been correctly imported. - -# Warnings on metadata templates -templates.metadata.partial.import.label=Attention! -templates.metadata.partial.import.message=Some of the metadata templates have not been imported due to their duplicate names. - # Error Messages messages.error.1=Jargon Exception messages.error.2=Data Duplicate Exception -templates.metadata.error.import.label=Error! -templates.metadata.error.import.message=The templates could not be imported. - tab.title.dashboard=Metalnx - Dashboard tab.title.groups=Metalnx - Groups tab.title.users= Metalnx - Users tab.title.resources=Metalnx - Resources tab.title.collections=Metalnx - Collections tab.title.search=Metalnx - Search -tab.title.templates=Metalnx - Templates tab.title.shared=Metalnx - Shared Links -tab.title.favorites=Metalnx - Favorites -tab.title.profile=Metalnx - Profile tab.title.nitifications=NIEHS - Notifications # Side bar user menu sidebar.user.mycollections=My Collections sidebar.user.public=Public sidebar.user.zone=Zone -sidebar.user.bookmarks=Shared Links -sidebar.user.favorites=Favorites sidebar.user.recents=Recents sidebar.user.shared.items=Shared Items sidebar.user.trash=Trash sidebar.user.groups=My Groups sidebar.tickets=Tickets -# Bookmarks -bookmarks.table.file.name.label=Name -bookmarks.table.file.path.label=Path -bookmarks.table.created.at.label=Created -bookmarks.table.type.label=Type -bookmarks.table.group.label=Group -bookmarks.result.number.found=shared link(s) found -bookmarks.page.subtitle=(by users) -bookmarks.page.title=Shared -bookmarks.page.title.popover=List of Collections and Files shared by or with other users. -bookmarks.for.group.your.groups.label=The item(s) below are shared with you: - # Shared Items shareditems.empty.table=There are no shared items # My Groups mygroups.empty.table=You are not listed in any group -# Favorites -favorites.page.title=Favorites -favorites.page.title.popover=Bookmark a collection or data object as a favorite to make it easy to find -favorites.result.number.found=favorite item(s) found -favorites.table.name.label=Name -favorites.table.path.label=Path -favorites.table.owner.label=Owner -favorites.table.created.at.label=Marked on -favorites.table.type.label=Type -favorites.table.permission.label=Permission -favorites.table.unfav.label=Remove -favorites.items.marked.as.favorites=The following item(s) were marked as favorite: -favorites.empty.table=There are no favorites yet - # Tickets tab.title.tickets=Tickets ticket.page.title=Tickets @@ -846,12 +692,6 @@ collection.browser.item.not.copied=The following items failed to be copied: collection.browser.files.deleted.success=The selected files were successfully deleted. collection.browser.files.deleted.fail=The following items failed to be deleted: -#listTemplateFieldsForCollections -template.field.list.not.found=No attributes found. - -#favorites -favorite.page.content.path.not.remove=Could not remove path from favorites. - #httperrors httperror.403.message=You do not have permissions to access that page. Your session is no longer valid. httperror.404.message=We could not process your request. @@ -871,10 +711,6 @@ login.title=Metalnx #permissions #It has title and text - test and update if needed - -#template -template.management.not.modified=The template could not be modified. - #ticket in service & template in admin about.modal= This software contains the intellectual property of the University of North Carolina at Chapel Hill and EMC diff --git a/src/metalnx-web/src/main/resources/static/js/formValidator.js b/src/metalnx-web/src/main/resources/static/js/formValidator.js index 3fe362782..b73f71a05 100644 --- a/src/metalnx-web/src/main/resources/static/js/formValidator.js +++ b/src/metalnx-web/src/main/resources/static/js/formValidator.js @@ -391,15 +391,6 @@ function groupFormCanBeSubmitted(urlValidateGroupname, isAddAction){ } -/* - * Validates add/modify user profile form - */ -function userProfileFormValidator(urlValidateProfileName) { - $("#inputProfileName").focusout(function() { - validateProfileNameAjax(urlValidateProfileName); - }); -} - /* * Function that goes to the server and checks if the profile name entered is valid or not */ @@ -449,19 +440,6 @@ function validateProfileDescription(){ return true; } -/* - * Validates the user profile form before submit it - */ -function userProfileFormCanBeSubmitted(urlValidateProfileName){ - var isValidProfileName = validateProfileNameAjax(urlValidateProfileName); - var isValidProfileDescription = validateProfileDescription(); - - if(isValidProfileName && isValidProfileDescription) - return true - - return false; -} - /* * Validates a username using AJAX */ diff --git a/src/metalnx-web/src/main/resources/views/bookmarks/userBookmarks.html b/src/metalnx-web/src/main/resources/views/bookmarks/userBookmarks.html deleted file mode 100755 index 618ec1a1d..000000000 --- a/src/metalnx-web/src/main/resources/views/bookmarks/userBookmarks.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - Metalnx - Shared Links - - - - - -
-
-
- -
- - -
- - - - - - - - - -
-
- - -
- - - -
- - - - diff --git a/src/metalnx-web/src/main/resources/views/collections/collectionManagement.html b/src/metalnx-web/src/main/resources/views/collections/collectionManagement.html index 55d9160de..f9dd8334f 100755 --- a/src/metalnx-web/src/main/resources/views/collections/collectionManagement.html +++ b/src/metalnx-web/src/main/resources/views/collections/collectionManagement.html @@ -226,27 +226,7 @@

-
- - - - - - - -
-
-
- - - - - - - -
-
@@ -326,27 +306,6 @@

-
- - - - - - - -
-
- -
- - - - - - - -
-
diff --git a/src/metalnx-web/src/main/resources/views/dashboard/dashboard.html b/src/metalnx-web/src/main/resources/views/dashboard/dashboard.html index 785dab54c..b31722e57 100755 --- a/src/metalnx-web/src/main/resources/views/dashboard/dashboard.html +++ b/src/metalnx-web/src/main/resources/views/dashboard/dashboard.html @@ -176,34 +176,6 @@
- -
-
-
-
- - - - - -
-
-
diff --git a/src/metalnx-web/src/main/resources/views/defaultTemplate.html b/src/metalnx-web/src/main/resources/views/defaultTemplate.html index 1ce58110b..c11280fe4 100644 --- a/src/metalnx-web/src/main/resources/views/defaultTemplate.html +++ b/src/metalnx-web/src/main/resources/views/defaultTemplate.html @@ -150,10 +150,6 @@

Title here

}else if(current_url.indexOf([[@{ ${urlMap.URL_PUBLIC_COLLECTION_USER} }]]) >= 0){ $("#side-menu a[href='"+[[@{${urlMap.URL_PUBLIC_COLLECTION_USER}}]]+"']").addClass("active"); set_active_class = true; - // making only profile side-menu active - }else if(current_url.indexOf([[@{ ${urlMap.URL_USER_PROFILE_MANAGEMENT} }]]) >= 0){ - $("#side-menu a[href='"+[[@{${urlMap.URL_USER_PROFILE_MANAGEMENT}}]]+"']").addClass("active"); - set_active_class = true; //making trash side-menu option active }else if(current_url.indexOf([[@{ ${urlMap.URL_TRASH_COLLECTION_USER} }]]) >= 0){ console.log("issue 145 trash block passed") @@ -167,4 +163,4 @@

Title here

/*]]>*/ - \ No newline at end of file + diff --git a/src/metalnx-web/src/main/resources/views/defaultTemplatev.html b/src/metalnx-web/src/main/resources/views/defaultTemplatev.html index b7df603f3..a43f1ebe8 100644 --- a/src/metalnx-web/src/main/resources/views/defaultTemplatev.html +++ b/src/metalnx-web/src/main/resources/views/defaultTemplatev.html @@ -164,10 +164,6 @@

Title here

}else if(current_url.indexOf([[@{ ${urlMap.URL_PUBLIC_COLLECTION_USER} }]]) >= 0){ $("#side-menu a[href='"+[[@{${urlMap.URL_PUBLIC_COLLECTION_USER}}]]+"']").addClass("active"); set_active_class = true; - // making only profile side-menu active - }else if(current_url.indexOf([[@{ ${urlMap.URL_USER_PROFILE_MANAGEMENT} }]]) >= 0){ - $("#side-menu a[href='"+[[@{${urlMap.URL_USER_PROFILE_MANAGEMENT}}]]+"']").addClass("active"); - set_active_class = true; //making shared links side-menu option active if user is in group bookmarks page }else if(current_url.indexOf([[@{ ${urlMap.URL_TRASH_COLLECTION_USER} }]]) >= 0){ console.log("issue 145 trash block passed") diff --git a/src/metalnx-web/src/main/resources/views/favorites/favorites.html b/src/metalnx-web/src/main/resources/views/favorites/favorites.html deleted file mode 100755 index 3a7768021..000000000 --- a/src/metalnx-web/src/main/resources/views/favorites/favorites.html +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - Metalnx - Favorites - - - - -
-
- - -
- -
-
- - - - - - - - - -
-
- -
- - - -
- - - - diff --git a/src/metalnx-web/src/main/resources/views/groups/groupForm.html b/src/metalnx-web/src/main/resources/views/groups/groupForm.html index 187ad4fc0..14c4ba6be 100755 --- a/src/metalnx-web/src/main/resources/views/groups/groupForm.html +++ b/src/metalnx-web/src/main/resources/views/groups/groupForm.html @@ -170,8 +170,6 @@ - - @@ -182,8 +180,6 @@ th:value="${user.dataGridId}" th:checked="${#arrays.contains(membersList, '' + user.dataGridId)}" /> - - @@ -217,8 +213,6 @@ - - @@ -227,8 +221,6 @@ - - diff --git a/src/metalnx-web/src/main/resources/views/permissions/permissionDetails.html b/src/metalnx-web/src/main/resources/views/permissions/permissionDetails.html index ab9d9b3a9..b325324dc 100755 --- a/src/metalnx-web/src/main/resources/views/permissions/permissionDetails.html +++ b/src/metalnx-web/src/main/resources/views/permissions/permissionDetails.html @@ -40,7 +40,6 @@

- @@ -98,13 +97,6 @@

- -