Search in sources :

Example 1 with DataNotFoundException

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

the class TicketServiceImpl method find.

@Override
public DataGridTicket find(String ticketId) throws DataGridConnectionRefusedException, DataGridTicketNotFoundException {
    logger.info("Find ticket {}", ticketId);
    DataGridTicket dgTicket = null;
    TicketAdminService tas = irodsServices.getTicketAdminService();
    try {
        Ticket t = tas.getTicketForSpecifiedTicketString(ticketId);
        dgTicket = convertTicketToDataGridTicket(t);
        dgTicket.setHosts(tas.listAllHostRestrictionsForSpecifiedTicket(ticketId, OFFSET));
        dgTicket.setUsers(tas.listAllUserRestrictionsForSpecifiedTicket(ticketId, OFFSET));
        dgTicket.setGroups(tas.listAllGroupRestrictionsForSpecifiedTicket(ticketId, OFFSET));
    } catch (DataNotFoundException e) {
        throw new DataGridTicketNotFoundException("Ticket does not exist");
    } catch (JargonException e) {
        logger.error("Could not find ticket with string: {}", ticketId);
    }
    return dgTicket;
}
Also used : DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) Ticket(org.irods.jargon.ticket.Ticket) DataNotFoundException(org.irods.jargon.core.exception.DataNotFoundException) JargonException(org.irods.jargon.core.exception.JargonException) DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) DataGridTicketNotFoundException(com.emc.metalnx.core.domain.exceptions.DataGridTicketNotFoundException) TicketAdminService(org.irods.jargon.ticket.TicketAdminService)

Example 2 with DataNotFoundException

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

Aggregations

DataNotFoundException (org.irods.jargon.core.exception.DataNotFoundException)2 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)1 DataGridTicket (com.emc.metalnx.core.domain.entity.DataGridTicket)1 DataGridDataNotFoundException (com.emc.metalnx.core.domain.exceptions.DataGridDataNotFoundException)1 DataGridQueryException (com.emc.metalnx.core.domain.exceptions.DataGridQueryException)1 DataGridTicketNotFoundException (com.emc.metalnx.core.domain.exceptions.DataGridTicketNotFoundException)1 ArrayList (java.util.ArrayList)1 JargonException (org.irods.jargon.core.exception.JargonException)1 JargonQueryException (org.irods.jargon.core.query.JargonQueryException)1 Ticket (org.irods.jargon.ticket.Ticket)1 TicketAdminService (org.irods.jargon.ticket.TicketAdminService)1