use of org.irods.jargon.ticket.Ticket 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 org.irods.jargon.ticket.Ticket in project metalnx-web by irods-contrib.
the class TicketServiceImpl method convertDataGridTicketToTicket.
private Ticket convertDataGridTicketToTicket(DataGridTicket dgTicket) {
Ticket ticket = new Ticket();
ticket.setTicketString(dgTicket.getTicketString());
ticket.setOwnerName(dgTicket.getOwner());
ticket.setIrodsAbsolutePath(dgTicket.getPath());
ticket.setTicketString(dgTicket.getTicketString());
ticket.setExpireTime(dgTicket.getExpirationDate());
ticket.setUsesLimit(dgTicket.getUsesLimit());
ticket.setUsesCount(dgTicket.getUsesCount());
ticket.setWriteByteLimit(dgTicket.getWriteByteLimit());
ticket.setWriteByteCount(dgTicket.getWriteByteCount());
ticket.setWriteFileLimit(dgTicket.getWriteFileLimit());
ticket.setWriteFileCount(dgTicket.getWriteFileCount());
TicketCreateModeEnum ticketMode;
if (dgTicket.getType() == DataGridTicket.TicketType.READ)
ticketMode = TicketCreateModeEnum.READ;
else if (dgTicket.getType() == DataGridTicket.TicketType.WRITE)
ticketMode = TicketCreateModeEnum.WRITE;
else
ticketMode = TicketCreateModeEnum.UNKNOWN;
ticket.setType(ticketMode);
if (dgTicket.isCollection())
ticket.setObjectType(Ticket.TicketObjectType.COLLECTION);
return ticket;
}
use of org.irods.jargon.ticket.Ticket in project metalnx-web by irods-contrib.
the class TestCreateTicketWithFilesLimit method testCreateTicketWithWriteFileLimit.
@Test
public void testCreateTicketWithWriteFileLimit() throws DataGridConnectionRefusedException, DataGridTicketException, JargonException {
ticketString = ticketService.create(dgt);
Ticket ticketWithFileLimit = ticketUtils.findTicket(ticketString);
assertEquals(WRITE_FILE_LIMIT, ticketWithFileLimit.getWriteFileLimit());
assertFalse(ticketWithFileLimit.getTicketString().isEmpty());
assertTrue(ticketWithFileLimit.getIrodsAbsolutePath().equals(targetPath));
assertTrue(ticketWithFileLimit.getOwnerName().equals(username));
}
use of org.irods.jargon.ticket.Ticket in project metalnx-web by irods-contrib.
the class TestCreateTicketWithUsesLimit method testCreateTicketWithExpirationDate.
@Test
public void testCreateTicketWithExpirationDate() throws DataGridConnectionRefusedException, DataGridTicketException, JargonException {
ticketString = ticketService.create(dgt);
Ticket ticketWithUses = ticketUtils.findTicket(ticketString);
assertEquals(USES_LIMIT, ticketWithUses.getUsesLimit());
assertFalse(ticketWithUses.getTicketString().isEmpty());
assertTrue(ticketWithUses.getIrodsAbsolutePath().equals(targetPath));
assertTrue(ticketWithUses.getOwnerName().equals(username));
}
use of org.irods.jargon.ticket.Ticket in project metalnx-web by irods-contrib.
the class TestCreateTicketWithByteLimit method testCreateTicketWithWriteByteLimit.
@Test
public void testCreateTicketWithWriteByteLimit() throws DataGridConnectionRefusedException, DataGridTicketException, JargonException {
ticketString = ticketService.create(dgt);
Ticket ticketWithByteLimit = ticketUtils.findTicket(ticketString);
assertEquals(WRITE_BYTE_LIMIT, ticketWithByteLimit.getWriteByteLimit());
assertFalse(ticketWithByteLimit.getTicketString().isEmpty());
assertTrue(ticketWithByteLimit.getIrodsAbsolutePath().equals(targetPath));
assertTrue(ticketWithByteLimit.getOwnerName().equals(username));
}
Aggregations