Search in sources :

Example 51 with JargonException

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

the class ResourceServiceImpl method getImmediateChildren.

@Override
public List<String> getImmediateChildren(String resourceName) throws DataGridConnectionRefusedException {
    try {
        ResourceAO resourceAO = irodsServices.getResourceAO();
        Resource irodsResource = resourceAO.findByName(resourceName);
        return irodsResource.getImmediateChildren();
    } catch (JargonException e) {
        logger.error("Could not get immediate children of resource " + resourceName + ": ", e);
    }
    return new ArrayList<String>();
}
Also used : ResourceAO(org.irods.jargon.core.pub.ResourceAO) JargonException(org.irods.jargon.core.exception.JargonException) Resource(org.irods.jargon.core.pub.domain.Resource) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) ArrayList(java.util.ArrayList)

Example 52 with JargonException

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

the class ResourceServiceImpl method createResource.

@Override
public boolean createResource(DataGridResource newDataGridResource) throws DataGridConnectionRefusedException {
    try {
        ResourceAO resourceAO = irodsServices.getResourceAO();
        ZoneAO zoneAO = irodsServices.getZoneAO();
        // mapping data grid resource to iRODS Resource
        Resource irodsResource = new Resource();
        irodsResource.setName(newDataGridResource.getName());
        irodsResource.setType(newDataGridResource.getType());
        irodsResource.setZone(zoneAO.getZoneByName(newDataGridResource.getZone()));
        irodsResource.setCreateTime(newDataGridResource.getCreateTime());
        irodsResource.setModifyTime(newDataGridResource.getModifyTime());
        irodsResource.setStatus(newDataGridResource.getStatus());
        irodsResource.setInfo(newDataGridResource.getInfo());
        irodsResource.setParentName(newDataGridResource.getParent());
        irodsResource.setVaultPath(newDataGridResource.getPath());
        irodsResource.setLocation(newDataGridResource.getHost());
        // context string is not always set
        if (newDataGridResource.getContextString() != null) {
            irodsResource.setContextString(newDataGridResource.getContextString());
        }
        // adding the new resource to iRODS
        resourceAO.addResource(irodsResource);
        return true;
    } catch (JargonException e) {
        logger.error("Could not create resource: ", e);
    }
    return false;
}
Also used : ResourceAO(org.irods.jargon.core.pub.ResourceAO) JargonException(org.irods.jargon.core.exception.JargonException) Resource(org.irods.jargon.core.pub.domain.Resource) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) ZoneAO(org.irods.jargon.core.pub.ZoneAO)

Example 53 with JargonException

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

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

the class TicketServiceImpl method create.

@Override
public String create(DataGridTicket dgTicket) throws DataGridConnectionRefusedException, DataGridTicketException {
    logger.info("Create ticket");
    if (dgTicket == null) {
        logger.info("Could not create ticket: Null ticket provided.");
        throw new DataGridTicketException("Could not create ticket: null ticket provided.");
    }
    if (dgTicket.getPath().isEmpty()) {
        logger.info("Could not create ticket: Ticket with no path.");
        throw new DataGridTicketException("Could not create ticket: path is empty");
    }
    TicketCreateModeEnum ticketType = TicketCreateModeEnum.UNKNOWN;
    if (dgTicket.getType() == DataGridTicket.TicketType.READ)
        ticketType = TicketCreateModeEnum.READ;
    if (dgTicket.getType() == DataGridTicket.TicketType.WRITE)
        ticketType = TicketCreateModeEnum.WRITE;
    String path = dgTicket.getPath();
    int idxOfSeparator = path.lastIndexOf(GRID_FILE_SEPARATOR);
    String parentPath = path.substring(0, idxOfSeparator);
    String item = path.substring(idxOfSeparator + 1, path.length());
    String ticketString = "";
    try {
        IRODSFile irodsFile = irodsServices.getIRODSFileFactory().instanceIRODSFile(parentPath, item);
        TicketAdminService tas = irodsServices.getTicketAdminService();
        ticketString = tas.createTicket(ticketType, irodsFile, dgTicket.getTicketString());
        // set ticket string created by the grid
        dgTicket.setTicketString(ticketString);
        modify(dgTicket);
    } catch (JargonException e) {
        logger.error("Could not create a ticket: {}", e);
        throw new DataGridTicketException(e.getMessage());
    }
    return ticketString;
}
Also used : TicketCreateModeEnum(org.irods.jargon.ticket.packinstr.TicketCreateModeEnum) JargonException(org.irods.jargon.core.exception.JargonException) DataGridTicketException(com.emc.metalnx.core.domain.exceptions.DataGridTicketException) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile) TicketAdminService(org.irods.jargon.ticket.TicketAdminService)

Example 55 with JargonException

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

the class TicketServiceImpl method delete.

@Override
public boolean delete(String ticketString) throws DataGridConnectionRefusedException {
    if (ticketString == null || ticketString.isEmpty()) {
        logger.error("Could not delete ticket: Ticket ID null or emtpy");
        return false;
    }
    logger.info("Deleting ticket {}", ticketString);
    boolean ticketDeleted = false;
    TicketAdminService tas = irodsServices.getTicketAdminService();
    try {
        ticketDeleted = tas.deleteTicket(ticketString);
    } catch (JargonException e) {
        logger.info("Could not delete ticket {}: {}.", ticketString, e.getMessage());
    }
    return ticketDeleted;
}
Also used : JargonException(org.irods.jargon.core.exception.JargonException) TicketAdminService(org.irods.jargon.ticket.TicketAdminService)

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