Search in sources :

Example 26 with DataGridUser

use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.

the class TemplateController method index.

@RequestMapping(value = "/")
public String index(final Model model, final HttpServletRequest request) throws DataGridConnectionRefusedException, DataGridException {
    addTemplateFields = new ArrayList<TemplateFieldForm>();
    removeTemplateFields = new ArrayList<TemplateFieldForm>();
    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);
    model.addAttribute("topnavHeader", headerService.getheader("template"));
    return "template/templateManagement";
}
Also used : TemplateFieldForm(com.emc.metalnx.modelattribute.template.field.TemplateFieldForm) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with DataGridUser

use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.

the class CollectionController method indexViaUrl.

/**
 * Responds the collections/ request
 *
 * @param model
 * @return the collection management template
 * @throws JargonException
 * @throws DataGridException
 */
@RequestMapping(method = RequestMethod.GET)
public String indexViaUrl(final Model model, final HttpServletRequest request, @RequestParam("path") final Optional<String> path, @ModelAttribute("requestHeader") String requestHeader) {
    logger.info("indexViaUrl()");
    String myPath = path.orElse("");
    logger.info("dp Header requestHeader is :: " + requestHeader);
    try {
        if (myPath.isEmpty()) {
            model.addAttribute("topnavHeader", headerService.getheader("collections"));
            logger.info("no path, go to home dir");
            myPath = cs.getHomeDirectyForCurrentUser();
        } else {
            logger.info("path provided...go to:{}", path);
            // TODO: do I need to worry about decoding, versus configure
            myPath = URLDecoder.decode(myPath);
        // in filter? - MCC
        // see
        // https://stackoverflow.com/questions/25944964/where-and-how-to-decode-pathvariable
        }
        logger.info("myPath:{}" + myPath);
        DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
        String uiMode = (String) request.getSession().getAttribute("uiMode");
        sourcePaths = MiscIRODSUtils.breakIRODSPathIntoComponents(myPath);
        CollectionAndPath collectionAndPath = MiscIRODSUtils.separateCollectionAndPathFromGivenAbsolutePath(myPath);
        this.parentPath = collectionAndPath.getCollectionParent();
        this.currentPath = myPath;
        if (uiMode == null || uiMode.isEmpty()) {
            boolean isUserAdmin = loggedUser != null && loggedUser.isAdmin();
            uiMode = isUserAdmin ? UI_ADMIN_MODE : UI_USER_MODE;
        }
        if (cs.isDataObject(myPath)) {
            logger.info("redirect to info page");
            StringBuilder sb = new StringBuilder();
            sb.append("redirect:/collectionInfo?path=");
            sb.append(URLEncoder.encode(myPath));
            return sb.toString();
        }
        logger.info("is collection...continue to collection management");
        if (uiMode.equals(UI_USER_MODE)) {
            model.addAttribute("homePath", cs.getHomeDirectyForCurrentUser());
            model.addAttribute("publicPath", cs.getHomeDirectyForPublic());
        }
        model.addAttribute("uiMode", uiMode);
        model.addAttribute("currentPath", currentPath);
        model.addAttribute("encodedCurrentPath", URLEncoder.encode(currentPath));
        model.addAttribute("parentPath", parentPath);
        model.addAttribute("resources", resourceService.findAll());
        model.addAttribute("overwriteFileOption", loggedUser != null && loggedUser.isForceFileOverwriting());
    } catch (JargonException | DataGridException e) {
        logger.error("error establishing collection location", e);
        model.addAttribute("unexpectedError", true);
    }
    logger.info("displaying collections/collectionManagement");
    return "collections/collectionManagement";
}
Also used : DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) JargonException(org.irods.jargon.core.exception.JargonException) CollectionAndPath(org.irods.jargon.core.utils.CollectionAndPath) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with DataGridUser

use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.

the class FileOperationsController method emptyTrash.

@RequestMapping(value = "emptyTrash/", method = RequestMethod.POST)
public ResponseEntity<String> emptyTrash() throws DataGridConnectionRefusedException, JargonException {
    String trashForCurrentPath = collectionService.getTrashForPath(browseController.getCurrentPath());
    DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
    if (fileOperationService.emptyTrash(loggedUser, trashForCurrentPath)) {
        return new ResponseEntity<>(HttpStatus.OK);
    }
    return new ResponseEntity<>(HttpStatus.METHOD_NOT_ALLOWED);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with DataGridUser

use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.

the class MetadataController method index.

@RequestMapping(value = "/")
public String index(final Model model, final HttpServletRequest request, @RequestParam(value = "backFromCollections", required = false) final boolean backFromCollections) throws DataGridException {
    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());
        }
    }
    if (backFromCollections) {
        model.addAttribute("jsonMetadataSearch", jsonMetadataSearch);
    }
    model.addAttribute("uiMode", uiMode);
    model.addAttribute("topnavHeader", headerService.getheader("search"));
    return "metadata/metadataDisplay";
}
Also used : DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 30 with DataGridUser

use of com.emc.metalnx.core.domain.entity.DataGridUser in project metalnx-web by irods-contrib.

the class PreferencesController method index.

@RequestMapping(value = "/")
public String index(final Model model, final HttpServletRequest request) {
    logger.info("index()");
    DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
    String locale = loggedUser.getLocale();
    String uiMode = (String) request.getSession().getAttribute("uiMode");
    if (uiMode == null || uiMode.isEmpty()) {
        if (loggedUser.isAdmin()) {
            uiMode = UI_ADMIN_MODE;
        } else {
            uiMode = UI_USER_MODE;
        }
    }
    UserPreferences userPreferences = new UserPreferences();
    userPreferences.setLocaleLanguage(locale);
    userPreferences.setForceFileOverwriting(loggedUser.isForceFileOverwriting());
    userPreferences.setAdvancedView(loggedUser.isAdvancedView());
    model.addAttribute("preferences", userPreferences);
    model.addAttribute("uiMode", uiMode);
    model.addAttribute("topnavHeader", headerService.getheader("prefrences"));
    return "preferences/index";
}
Also used : UserPreferences(com.emc.metalnx.modelattribute.preferences.UserPreferences) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DataGridUser (com.emc.metalnx.core.domain.entity.DataGridUser)48 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)28 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)8 JargonException (org.irods.jargon.core.exception.JargonException)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 DataGridGroup (com.emc.metalnx.core.domain.entity.DataGridGroup)5 User (org.irods.jargon.core.pub.domain.User)5 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)4 HashMap (java.util.HashMap)4 Query (org.hibernate.Query)4 UserAO (org.irods.jargon.core.pub.UserAO)4 Authentication (org.springframework.security.core.Authentication)4 UserProfile (com.emc.metalnx.core.domain.entity.UserProfile)3 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 DataGridUserBookmark (com.emc.metalnx.core.domain.entity.DataGridUserBookmark)2 DataGridUserFavorite (com.emc.metalnx.core.domain.entity.DataGridUserFavorite)2 URLMap (com.emc.metalnx.modelattribute.enums.URLMap)2 GroupForm (com.emc.metalnx.modelattribute.group.GroupForm)2