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