use of com.emc.metalnx.core.domain.exceptions.DataGridTicketException in project metalnx-web by irods-contrib.
the class TicketServiceImpl method modify.
@Override
public DataGridTicket modify(DataGridTicket t) throws DataGridConnectionRefusedException, DataGridTicketException {
logger.info("Modify ticket");
if (t == null) {
logger.error("Null ticket provided.");
throw new DataGridTicketException("Null ticket instance");
}
if (t.getTicketString().isEmpty()) {
logger.error("Ticket with empty string provided.");
throw new DataGridTicketException("Ticket string missing");
}
String ticketString = t.getTicketString();
DataGridTicket dgTicket;
try {
updateHostRestrictions(t);
updateUserRestrictions(t);
updateGroupRestrictions(t);
TicketAdminService tas = irodsServices.getTicketAdminService();
Ticket ticketUpdated = tas.compareGivenTicketToActualAndUpdateAsNeeded(convertDataGridTicketToTicket(t));
dgTicket = convertTicketToDataGridTicket(ticketUpdated);
dgTicket.setHosts(tas.listAllHostRestrictionsForSpecifiedTicket(ticketString, OFFSET));
dgTicket.setUsers(tas.listAllUserRestrictionsForSpecifiedTicket(ticketString, OFFSET));
dgTicket.setGroups(tas.listAllGroupRestrictionsForSpecifiedTicket(ticketString, OFFSET));
} catch (JargonException e) {
logger.error("Could not modify ticket");
throw new DataGridTicketException(e.getMessage());
}
return dgTicket;
}
use of com.emc.metalnx.core.domain.exceptions.DataGridTicketException 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;
}
Aggregations