/** * Delete a single ticket instance from the store. * * @param ticketId the ticket id * @return the boolean */ public boolean deleteSingleTicket(final Ticket ticketId) { return deleteSingleTicket(ticketId.getId()); }
/** * Delete TGT's service tickets. * * @param ticket the ticket * @return the count of tickets that were removed including child tickets and zero if the ticket was not deleted */ public int deleteChildren(final TicketGrantingTicket ticket) { int count = 0; // delete service tickets final Map<String, Service> services = ticket.getServices(); if (services != null && !services.isEmpty()) { final Iterator<String> it = services.keySet().iterator(); while (it.hasNext()) { final String ticketId = it.next(); if (deleteSingleTicket(ticketId)) { logger.debug("Removed ticket [{}]", ticketId); count++; } else { logger.debug("Unable to remove ticket [{}]", ticketId); } } } return count; }
@Override public int deleteTicket(final String ticketId) { int count = 0; if (ticketId == null) { return count; } final Ticket ticket = getTicket(ticketId); if (ticket == null) { return count; } if (ticket instanceof TicketGrantingTicket) { if (ticket instanceof ProxyGrantingTicket) { logger.debug("Removing proxy-granting ticket [{}]", ticketId); } logger.debug("Removing children of ticket [{}] from the registry.", ticket.getId()); final TicketGrantingTicket tgt = (TicketGrantingTicket) ticket; count += deleteChildren(tgt); final Collection<ProxyGrantingTicket> proxyGrantingTickets = tgt.getProxyGrantingTickets(); final Iterator<ProxyGrantingTicket> it = proxyGrantingTickets.iterator(); while(it.hasNext()) { final ProxyGrantingTicket pgt = it.next(); count += deleteTicket(pgt.getId()); } } logger.debug("Removing ticket [{}] from the registry.", ticket); if (deleteSingleTicket(ticketId)) { count++; } return count; }