use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.
the class TestModifyTicket method testModifyTicketUsesLimit.
@Test
public void testModifyTicketUsesLimit() throws DataGridConnectionRefusedException, DataGridTicketException {
int newUsesLimit = USES_LIMIT + 1;
DataGridTicket dgt = new DataGridTicket(targetPath);
dgt.setTicketString(ticketString);
dgt.setUsesLimit(newUsesLimit);
DataGridTicket ticketModified = ticketService.modify(dgt);
assertEquals(newUsesLimit, ticketModified.getUsesLimit());
assertFalse(ticketModified.getTicketString().isEmpty());
assertTrue(ticketModified.getPath().equals(targetPath));
assertTrue(ticketModified.getOwner().equals(username));
}
use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.
the class TestModifyTicket method testModifyTicketHosts.
@Test
public void testModifyTicketHosts() throws DataGridConnectionRefusedException, DataGridTicketException {
DataGridTicket dgt = new DataGridTicket(targetPath);
dgt.setTicketString(ticketString);
dgt.addHost(host);
DataGridTicket ticketModified = ticketService.modify(dgt);
assertEquals(1, ticketModified.getHosts().size());
assertFalse(ticketModified.getTicketString().isEmpty());
assertTrue(ticketModified.getPath().equals(targetPath));
assertTrue(ticketModified.getOwner().equals(username));
}
use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.
the class TestModifyTicket method testModifyTicketExpireDate.
@Test
public void testModifyTicketExpireDate() throws DataGridConnectionRefusedException, DataGridTicketException {
Date date = new Date();
DataGridTicket dgt = new DataGridTicket(targetPath);
dgt.setTicketString(ticketString);
dgt.setExpirationDate(date);
DataGridTicket dgtModified = ticketService.modify(dgt);
String currDate = dateFormat.format(date);
String ticketModifiedDate = dateFormat.format(dgtModified.getExpirationDate());
assertEquals(currDate, ticketModifiedDate);
assertFalse(dgtModified.getTicketString().isEmpty());
assertTrue(dgtModified.getPath().equals(targetPath));
assertTrue(dgtModified.getOwner().equals(username));
}
use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.
the class HostInfo method createTicketForm.
@RequestMapping(value = "/ticketForm", method = RequestMethod.GET)
public String createTicketForm(final Model model, @RequestParam(value = "ticketstring", required = false) final String ticketString) throws DataGridConnectionRefusedException, DataGridTicketNotFoundException, UnsupportedDataGridFeatureException {
if (!configService.getGlobalConfig().isTicketsEnabled()) {
logger.error("tickets are not enabled");
throw new UnsupportedDataGridFeatureException("tickets disabled");
}
DataGridTicket ticket;
if (ticketString != null && !ticketString.isEmpty()) {
ticket = ticketService.find(ticketString);
} else {
ticket = new DataGridTicket();
}
model.addAttribute("ticket", ticket);
model.addAttribute("requestMapping", "tickets/");
return "tickets/ticketForm";
}
use of com.emc.metalnx.core.domain.entity.DataGridTicket 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;
}
Aggregations