Search in sources :

Example 11 with DataGridException

use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.

the class MetadataController method getMetadata.

@RequestMapping(value = "/getMetadata/", method = RequestMethod.POST)
public String getMetadata(final Model model, final String path) throws DataGridConnectionRefusedException, FileNotFoundException {
    logger.info("MetadataController getMetadata() starts !!");
    List<DataGridMetadata> metadataList = metadataService.findMetadataValuesByPath(path);
    DataGridCollectionAndDataObject dgColObj = null;
    try {
        dgColObj = collectionService.findByName(path);
        permissionsService.resolveMostPermissiveAccessForUser(dgColObj, loggedUserUtils.getLoggedDataGridUser());
    } catch (DataGridException e) {
        logger.error("Could not retrieve collection/dataobject from path: {}", path);
    }
    model.addAttribute("permissionOnCurrentPath", collectionService.getPermissionsForPath(path));
    model.addAttribute("dataGridMetadataList", metadataList);
    model.addAttribute("currentPath", path);
    model.addAttribute("collectionAndDataObject", dgColObj);
    model.addAttribute("metadataFlag", true);
    logger.info("MetadataController getMetadata() ends !!");
    return "metadata/metadataTable :: metadataTable";
}
Also used : DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataGridMetadata(com.emc.metalnx.core.domain.entity.DataGridMetadata) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with DataGridException

use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.

the class BrowseController method setBreadcrumbToModel.

/*
	 * **************************************************************************
	 * **************************** PRIVATE METHODS *****************************
	 * **************************************************************************
	 */
/**
 * Creates the breadcrumb based on a given path.
 *
 * @param model
 *            Model attribute to set variables to be used in the view
 * @param path
 *            path that will be displayed in the breadcrumb
 * @throws DataGridException
 */
private void setBreadcrumbToModel(final Model model, final String path) throws DataGridException {
    DataGridCollectionAndDataObject obj;
    try {
        obj = cs.findByName(path);
    } catch (FileNotFoundException e) {
        obj = new DataGridCollectionAndDataObject();
        obj.setPath(path);
        obj.setCollection(false);
        obj.setParentPath(path.substring(0, path.lastIndexOf("/") + 1));
        obj.setName(path.substring(path.lastIndexOf("/") + 1, path.length()));
        logger.error("Could not find DataGridCollectionAndDataObject by path: {}", e.getMessage());
    } catch (DataGridException e) {
        logger.error("unable to find path for breadcrumb", e);
        throw e;
    }
    setBreadcrumbToModel(model, obj);
}
Also used : DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) FileNotFoundException(org.irods.jargon.core.exception.FileNotFoundException)

Example 13 with DataGridException

use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.

the class BrowseController method addCollection.

/**
 * Performs the action of actually creating a collection in iRODS
 *
 * @param model
 * @param collection
 * @return if the creation of collection was successful, it returns the
 *         collection management template, and returns the add collection
 *         template, otherwise.
 * @throws DataGridConnectionRefusedException
 */
@RequestMapping(value = "add/action", method = RequestMethod.POST)
public String addCollection(final Model model, @ModelAttribute final CollectionOrDataObjectForm collection, final RedirectAttributes redirectAttributes) throws DataGridConnectionRefusedException {
    logger.info("addCollection()");
    logger.info("collection:{}", collection);
    logger.info("redirectAttributes:{}", redirectAttributes);
    DataGridCollectionAndDataObject newCollection = new DataGridCollectionAndDataObject(currentPath + '/' + collection.getCollectionName(), collection.getCollectionName(), currentPath, true);
    logger.info("newCollection:{}", newCollection);
    newCollection.setParentPath(currentPath);
    newCollection.setCreatedAt(new Date());
    newCollection.setModifiedAt(newCollection.getCreatedAt());
    newCollection.setInheritanceOption(collection.getInheritOption());
    boolean creationSucessful;
    try {
        creationSucessful = cs.createCollection(newCollection);
        logger.info("creationSuccessful?:{}", creationSucessful);
        if (creationSucessful) {
            redirectAttributes.addFlashAttribute("collectionAddedSuccessfully", collection.getCollectionName());
        }
    } catch (DataGridConnectionRefusedException e) {
        throw e;
    } catch (DataGridException e) {
        logger.error("Could not create collection/data object (lack of permission): ", e.getMessage());
        redirectAttributes.addFlashAttribute("missingPermissionError", true);
    }
    return "redirect:/collections?path=" + URLEncoder.encode(currentPath);
}
Also used : DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with DataGridException

use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.

the class CollectionController method index.

/**
 * Legacy index method used in other controllers, eventually factor out TODO:
 * factor this out and make explicit via urls etc - mcc
 *
 * @param model
 * @param request
 * @return
 */
public String index(final Model model, final HttpServletRequest request) {
    logger.info("index()");
    try {
        sourcePaths.clear();
        if (!cs.isPathValid(currentPath)) {
            currentPath = cs.getHomeDirectyForCurrentUser();
            parentPath = currentPath;
        } else if (cs.isDataObject(currentPath)) {
            parentPath = currentPath.substring(0, currentPath.lastIndexOf("/") + 1);
        }
        DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
        String uiMode = (String) request.getSession().getAttribute("uiMode");
        if (uiMode == null || uiMode.isEmpty()) {
            boolean isUserAdmin = loggedUser != null && loggedUser.isAdmin();
            uiMode = isUserAdmin ? UI_ADMIN_MODE : UI_USER_MODE;
        }
        if (uiMode.equals(UI_USER_MODE)) {
            model.addAttribute("homePath", cs.getHomeDirectyForCurrentUser());
            model.addAttribute("publicPath", cs.getHomeDirectyForPublic());
        }
        model.addAttribute("cameFromFilePropertiesSearch", cameFromFilePropertiesSearch);
        model.addAttribute("cameFromMetadataSearch", cameFromMetadataSearch);
        model.addAttribute("cameFromBookmarks", cameFromBookmarks);
        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());
        cameFromMetadataSearch = false;
        cameFromFilePropertiesSearch = false;
        cameFromBookmarks = false;
    } catch (DataGridException | JargonException e) {
        logger.error("Could not respond to request for collections: {}", e);
        model.addAttribute("unexpectedError", true);
    }
    logger.info("returning to 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)

Example 15 with DataGridException

use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.

the class CollectionServiceImpl method findByName.

@Override
public DataGridCollectionAndDataObject findByName(String path) throws FileNotFoundException, DataGridException {
    logger.info("findByName()");
    if (path == null || path.isEmpty()) {
        logger.info("Could not find collection or data object by name: path is null");
        return null;
    }
    logger.info("Find collection or data object by name: {}", path);
    CollectionAndDataObjectListAndSearchAO objectsAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    DataGridCollectionAndDataObject dataGridCollectionAndDataObject;
    try {
        CollectionAndDataObjectListingEntry entry = objectsAO.getCollectionAndDataObjectListingEntryAtGivenAbsolutePathWithHeuristicPathGuessing(path);
        dataGridCollectionAndDataObject = this.mapListingEntryToDataGridCollectionAndDataObject(entry);
    } catch (FileNotFoundException fnf) {
        logger.warn("file not found for path:{}", path);
        throw fnf;
    } catch (JargonException e) {
        logger.debug("error finding collection/data object by name: {}", path);
        throw new DataGridException("Could not find path " + path);
    }
    return dataGridCollectionAndDataObject;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) JargonException(org.irods.jargon.core.exception.JargonException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) FileNotFoundException(org.irods.jargon.core.exception.FileNotFoundException) CollectionAndDataObjectListingEntry(org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)

Aggregations

DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)19 JargonException (org.irods.jargon.core.exception.JargonException)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)5 CollectionAO (org.irods.jargon.core.pub.CollectionAO)4 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)4 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)3 IOException (java.io.IOException)3 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)3 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)3 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)3 DataGridUser (com.emc.metalnx.core.domain.entity.DataGridUser)2 InputStream (java.io.InputStream)2 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)2 Stream2StreamAO (org.irods.jargon.core.pub.Stream2StreamAO)2 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 MultipartHttpServletRequest (org.springframework.web.multipart.MultipartHttpServletRequest)2 DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)1 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)1