Search in sources :

Example 6 with FileNotFoundException

use of org.irods.jargon.core.exception.FileNotFoundException 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 7 with FileNotFoundException

use of org.irods.jargon.core.exception.FileNotFoundException in project metalnx-web by irods-contrib.

the class CollectionServiceImpl method getSubCollectionsUnderPath.

@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsUnderPath(String parent) throws DataGridConnectionRefusedException {
    logger.info("getSubCollectionsUnderPath()");
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = null;
    try {
        List<CollectionAndDataObjectListingEntry> collectionAndDataObjects = collectionAndDataObjectListAndSearchAO.listCollectionsUnderPath(parent, 0);
        dataGridCollectionAndDataObjects = this.mapListingEntryToDataGridCollectionAndDataObject(collectionAndDataObjects);
        return dataGridCollectionAndDataObjects;
    } catch (FileNotFoundException e) {
        logger.error("Could not locate file: ", e);
    } catch (JargonException e) {
        logger.error("Error: ", e);
    }
    return dataGridCollectionAndDataObjects;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) 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)

Example 8 with FileNotFoundException

use of org.irods.jargon.core.exception.FileNotFoundException in project metalnx-web by irods-contrib.

the class CollectionServiceImpl method getSubCollectionsAndDataObjectsUnderPath.

@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsAndDataObjectsUnderPath(String parent) throws DataGridConnectionRefusedException, JargonException {
    logger.info("getSubCollectionsAndDataObjectsUnderPath()");
    if (parent == null || parent.isEmpty()) {
        throw new IllegalArgumentException("null or empty parent");
    }
    logger.info("parent:{}", parent);
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = null;
    try {
        List<CollectionAndDataObjectListingEntry> collectionAndDataObjects = collectionAndDataObjectListAndSearchAO.listDataObjectsAndCollectionsUnderPath(parent);
        dataGridCollectionAndDataObjects = new ArrayList<DataGridCollectionAndDataObject>();
        dataGridCollectionAndDataObjects = this.mapListingEntryToDataGridCollectionAndDataObject(collectionAndDataObjects);
        return dataGridCollectionAndDataObjects;
    } catch (FileNotFoundException e) {
        logger.error("Could not locate file: ", e);
        throw e;
    } catch (JargonException e) {
        logger.error("Error: ", e);
        throw e;
    }
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) 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)

Example 9 with FileNotFoundException

use of org.irods.jargon.core.exception.FileNotFoundException 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)

Example 10 with FileNotFoundException

use of org.irods.jargon.core.exception.FileNotFoundException in project metalnx-web by irods-contrib.

the class ZipServiceImpl method writeZipFile.

private File writeZipFile(File directoryToPlaceZip, File directoryToZip, List<File> fileList) {
    String zipFileName = String.format("%s/%s%s", directoryToPlaceZip.getName(), directoryToZip.getName(), ZIP_EXTENSION);
    FileOutputStream fos = null;
    ZipOutputStream zos = null;
    try {
        fos = new FileOutputStream(zipFileName);
        zos = new ZipOutputStream(fos);
        for (File file : fileList) {
            if (!file.isDirectory()) {
                // we only zip files, not directories
                addToZip(directoryToZip, file, zos);
            }
        }
    } catch (FileNotFoundException | IOException e) {
        logger.error("Could not create zip file");
    } finally {
        try {
            if (zos != null)
                zos.close();
            if (fos != null)
                fos.close();
        } catch (IOException e) {
            logger.error("Could not close zip streams: {}", e);
        }
    }
    return new File(zipFileName);
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(org.irods.jargon.core.exception.FileNotFoundException) IOException(java.io.IOException) File(java.io.File)

Aggregations

FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)10 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)8 JargonException (org.irods.jargon.core.exception.JargonException)6 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)3 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)3 CollectionAndDataObjectListingEntry (org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)3 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)2 CollectionAO (org.irods.jargon.core.pub.CollectionAO)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DataGridFilePermission (com.emc.metalnx.core.domain.entity.DataGridFilePermission)1 DataGridGroupBookmark (com.emc.metalnx.core.domain.entity.DataGridGroupBookmark)1 DataGridGroupPermission (com.emc.metalnx.core.domain.entity.DataGridGroupPermission)1 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)1 DataGridUser (com.emc.metalnx.core.domain.entity.DataGridUser)1 DataGridUserBookmark (com.emc.metalnx.core.domain.entity.DataGridUserBookmark)1 DataGridUserPermission (com.emc.metalnx.core.domain.entity.DataGridUserPermission)1 IconObject (com.emc.metalnx.core.domain.entity.IconObject)1 CollectionOrDataObjectForm (com.emc.metalnx.modelattribute.collection.CollectionOrDataObjectForm)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1