Search in sources :

Example 61 with JargonException

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

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

the class CollectionServiceImpl method getChecksum.

@Override
public String getChecksum(String path) throws DataGridConnectionRefusedException {
    logger.info("getChecksum()");
    logger.debug("Getting checksum of " + path);
    DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
    DataObject dataObject = null;
    try {
        dataObject = dataObjectAO.findByAbsolutePath(path);
    } catch (JargonException e) {
        logger.error("Could not find a data object matching " + path, e);
    }
    if (dataObject != null) {
        return dataObject.getChecksum();
    }
    return new String();
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) JargonException(org.irods.jargon.core.exception.JargonException) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

Example 63 with JargonException

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

the class CollectionServiceImpl method listReplicasByResource.

@Override
public Map<DataGridCollectionAndDataObject, DataGridResource> listReplicasByResource(String path) throws DataGridConnectionRefusedException {
    logger.info("listReplicasByResource()");
    logger.info("Listing all replicas of " + path);
    Map<DataGridCollectionAndDataObject, DataGridResource> map = new HashMap<DataGridCollectionAndDataObject, DataGridResource>();
    String collectionAbsPath = null;
    String fileName = null;
    DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
    try {
        collectionAbsPath = path.substring(0, path.lastIndexOf(IRODS_PATH_SEPARATOR));
        fileName = path.substring(path.lastIndexOf(IRODS_PATH_SEPARATOR) + 1, path.length());
        List<DataObject> replicas = dataObjectAO.listReplicationsForFile(collectionAbsPath, fileName);
        for (DataObject replica : replicas) {
            DataGridCollectionAndDataObject dataGridCollectionAndDataObject = DataGridUtils.getDataGridCollectionAndDataObject(replica);
            DataGridResource dataGridResource = resourceService.find(replica.getResourceName());
            map.put(dataGridCollectionAndDataObject, dataGridResource);
        }
    } catch (JargonException e) {
        logger.error("Could not list replicas by resource for " + path);
    }
    return DataGridUtils.sortReplicaResourceMap(map);
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) HashMap(java.util.HashMap) JargonException(org.irods.jargon.core.exception.JargonException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

Example 64 with JargonException

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

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

the class CollectionServiceImpl method searchCollectionAndDataObjectsByName.

@Override
public List<DataGridCollectionAndDataObject> searchCollectionAndDataObjectsByName(String collectionName) throws DataGridConnectionRefusedException {
    logger.info("searchCollectionAndDataObjectsByName()");
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    List<CollectionAndDataObjectListingEntry> collectionAndDataObjects = null;
    List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = null;
    try {
        collectionAndDataObjects = collectionAndDataObjectListAndSearchAO.searchCollectionsAndDataObjectsBasedOnName(collectionName);
        dataGridCollectionAndDataObjects = this.mapListingEntryToDataGridCollectionAndDataObject(collectionAndDataObjects);
        return dataGridCollectionAndDataObjects;
    } catch (JargonException e) {
        logger.error("Could not search collections: {}", e.getMessage());
    }
    return null;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) JargonException(org.irods.jargon.core.exception.JargonException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) CollectionAndDataObjectListingEntry(org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)

Aggregations

JargonException (org.irods.jargon.core.exception.JargonException)86 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)20 CollectionAO (org.irods.jargon.core.pub.CollectionAO)20 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)18 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)18 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)17 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)15 ArrayList (java.util.ArrayList)12 SpecificQueryAO (org.irods.jargon.core.pub.SpecificQueryAO)12 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)11 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)10 SpecificQueryDefinition (org.irods.jargon.core.pub.domain.SpecificQueryDefinition)10 SpecificQueryResultSet (org.irods.jargon.core.query.SpecificQueryResultSet)9 UnsupportedDataGridFeatureException (com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException)8 SpecificQueryProvider (com.emc.metalnx.services.irods.utils.SpecificQueryProvider)8 ClientHints (org.irods.jargon.core.pub.domain.ClientHints)8 DataObject (org.irods.jargon.core.pub.domain.DataObject)8 CollectionAndDataObjectListingEntry (org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)8 SpecificQuery (org.irods.jargon.core.query.SpecificQuery)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8