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);
}
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;
}
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;
}
}
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;
}
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);
}
Aggregations