Search in sources :

Example 41 with DataGridCollectionAndDataObject

use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject 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 42 with DataGridCollectionAndDataObject

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

the class CollectionServiceImpl method getSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated.

@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated(String parentPath, String searchText, int pageNum, int pageSize, int orderColumn, String orderDir, DataGridPageContext pageContext) throws DataGridDataNotFoundException, DataGridQueryException, DataGridException {
    logger.info("getSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated()");
    List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = new ArrayList<>();
    List<DataGridCollectionAndDataObject> dataGridCollections = null;
    List<DataGridCollectionAndDataObject> dataGridObjects = null;
    int totalCollections = 0;
    int totalDataObjects = 0;
    int startIndex = (pageNum - 1) * pageSize;
    int endIndex = pageNum * pageSize - 1;
    int endIndexForDataObjs;
    int endIndexForCollections;
    try {
        totalCollections = getTotalCollectionsUnderPathThatMatchSearchText(parentPath, searchText);
        totalDataObjects = getTotalDataObjectsUnderPathThatMatchSearchText(parentPath, searchText);
        pageContext.setStartItemNumber(startIndex + 1);
        pageContext.setTotalNumberOfItems(totalCollections + totalDataObjects);
        if (endIndex + 1 <= totalCollections) {
            dataGridCollections = listCollectionsUnderPathThatMatchSearchText(parentPath, searchText, startIndex, pageSize, orderColumn, orderDir);
            int collectionEntriesSize = dataGridCollections.size();
            endIndexForCollections = collectionEntriesSize;
            dataGridCollectionAndDataObjects = dataGridCollections.subList(0, endIndexForCollections);
            pageContext.setEndItemNumber(pageContext.getStartItemNumber() + endIndexForCollections - 1);
        } else if (startIndex + 1 > totalCollections) {
            dataGridObjects = listDataObjectsUnderPathThatMatchSearchText(parentPath, searchText, startIndex - totalCollections, pageSize, orderColumn, orderDir);
            pageContext.setEndItemNumber(pageContext.getStartItemNumber() + dataGridObjects.size() - 1);
            dataGridCollectionAndDataObjects.addAll(dataGridObjects);
        } else {
            dataGridCollections = listCollectionsUnderPathThatMatchSearchText(parentPath, searchText, startIndex, pageSize, orderColumn, orderDir);
            endIndexForDataObjs = pageSize - totalCollections % pageSize;
            dataGridObjects = listDataObjectsUnderPathThatMatchSearchText(parentPath, searchText, 0, endIndexForDataObjs, orderColumn, orderDir);
            endIndexForDataObjs = endIndexForDataObjs > dataGridObjects.size() ? dataGridObjects.size() : endIndexForDataObjs;
            dataGridCollectionAndDataObjects.addAll(dataGridCollections);
            dataGridCollectionAndDataObjects.addAll(dataGridObjects);
            pageContext.setEndItemNumber(pageContext.getStartItemNumber() + endIndexForDataObjs + dataGridCollections.size() - 1);
        }
    } catch (DataNotFoundException e) {
        logger.error("Could not find items under path: {}", e.getMessage());
        throw new DataGridDataNotFoundException(e.getMessage());
    } catch (JargonQueryException e) {
        logger.error("Could not query catalog for items under path: {}", e.getMessage());
        throw new DataGridQueryException(e.getMessage());
    }
    return dataGridCollectionAndDataObjects;
}
Also used : DataGridQueryException(com.emc.metalnx.core.domain.exceptions.DataGridQueryException) DataNotFoundException(org.irods.jargon.core.exception.DataNotFoundException) DataGridDataNotFoundException(com.emc.metalnx.core.domain.exceptions.DataGridDataNotFoundException) DataGridDataNotFoundException(com.emc.metalnx.core.domain.exceptions.DataGridDataNotFoundException) JargonQueryException(org.irods.jargon.core.query.JargonQueryException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) ArrayList(java.util.ArrayList)

Example 43 with DataGridCollectionAndDataObject

use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject 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 44 with DataGridCollectionAndDataObject

use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject 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)

Example 45 with DataGridCollectionAndDataObject

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

the class CollectionServiceImpl method mapListingEntryToDataGridCollectionAndDataObject.

@Override
public List<DataGridCollectionAndDataObject> mapListingEntryToDataGridCollectionAndDataObject(List<CollectionAndDataObjectListingEntry> entries) {
    logger.info("mapListingEntryToDataGridCollectionAndDataObject()");
    logger.debug("Mapping a CollectionAndDataObjectListingEntry list into a DataGridCollectionAndDataObject list");
    List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = new ArrayList<DataGridCollectionAndDataObject>();
    for (CollectionAndDataObjectListingEntry entry : entries) {
        dataGridCollectionAndDataObjects.add(mapListingEntryToDataGridCollectionAndDataObject(entry));
    }
    return dataGridCollectionAndDataObjects;
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) ArrayList(java.util.ArrayList) CollectionAndDataObjectListingEntry(org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)

Aggregations

DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)55 JargonException (org.irods.jargon.core.exception.JargonException)15 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 Before (org.junit.Before)11 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)9 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)9 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)7 ArrayList (java.util.ArrayList)7 CollectionAndDataObjectListingEntry (org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)7 DataGridPageContext (com.emc.metalnx.core.domain.entity.DataGridPageContext)6 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)6 DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)5 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)5 Date (java.util.Date)4 HashMap (java.util.HashMap)4 JargonQueryException (org.irods.jargon.core.query.JargonQueryException)4 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)3 UnsupportedDataGridFeatureException (com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3