class TicketAdminServiceImpl extends AbstractTicketService implements TicketAdminService {

	@Override
	public Ticket createTicketFromTicketObject(final Ticket ticket)
			throws DuplicateDataException, DataNotFoundException, JargonException {

		log.info("createTicketFromTicketObjectAndSetAnyGivenLimits");
		if (ticket == null) {
			throw new IllegalArgumentException("null ticket");
		}

		log.info("ticket to update:{}", ticket);

		if (ticket.getType() == null) {
			throw new IllegalArgumentException("null type in ticket");
		}

		if (ticket.getIrodsAbsolutePath() == null || ticket.getIrodsAbsolutePath().isEmpty()) {
			throw new IllegalArgumentException("null or empty irodsAbsolutePath");
		}

		IRODSFile ticketFile = irodsAccessObjectFactory.getIRODSFileFactory(getIrodsAccount())
				.instanceIRODSFile(ticket.getIrodsAbsolutePath());
		if (!ticketFile.exists()) {
			log.error("file for ticket does not exist");
		}

		if (ticketFile.isDirectory()) {
			ticket.setObjectType(TicketObjectType.COLLECTION);
		} else {
			ticket.setObjectType(TicketObjectType.DATA_OBJECT);
		}

		ticket.setOwnerName(getIrodsAccount().getUserName());
		ticket.setOwnerZone(getIrodsAccount().getZone());

		log.info("creating base ticket");
		ticket.setTicketString(createTicket(ticket.getType(), ticketFile, ticket.getTicketString()));
		log.info("adding count values and limits");

		if (ticket.getExpireTime() != null) {
			setTicketExpiration(ticket.getTicketString(), ticket.getExpireTime());
		}

		if (ticket.getUsesLimit() > 0) {
			setTicketUsesLimit(ticket.getTicketString(), ticket.getUsesLimit());
		}

		if (ticket.getWriteByteLimit() > 0) {
			setTicketByteWriteLimit(ticket.getTicketString(), ticket.getWriteByteLimit());
		}

		if (ticket.getWriteFileLimit() > 0) {
			setTicketFileWriteLimit(ticket.getTicketString(), ticket.getWriteFileLimit());
		}

		return ticket;

	}

	  TicketAdminServiceImpl(final IRODSAccessObjectFactory irodsAccessObjectFactory, final IRODSAccount irodsAccount);

}