class TicketAdminServiceImpl extends AbstractTicketService implements TicketAdminService {

	@Override
	public String createTicket(final TicketCreateModeEnum mode, final IRODSFile file, final String ticketId)
			throws JargonException, DuplicateDataException {

		if (file == null) {
			throw new IllegalArgumentException("cannot create ticket with null IRODS file/collection");
		}

		log.info("creating at ticket for :{}", file.getPath());

		if (mode == null) {
			throw new IllegalArgumentException("cannot create ticket with null create mode - read or write access");
		}

		String myTicketId = ticketId;

		if (myTicketId == null || myTicketId.isEmpty()) {
			// create a new ticket string 15 chars in length
			myTicketId = new TicketRandomString(15).nextString();
		}
		log.info("ticket creation mode is:{}", mode);

		/*
		 * If a ticket is created on a collection, then inheritance is set. Otherwise,
		 * others can add files to the colletion and the collection owner may not be
		 * able to manage the files.
		 */
		if (file.isDirectory()) {
			log.info("ticket is for a collection, set inherit to true on collection:{}", file.getAbsolutePath());
			CollectionAO collectionAO = getIrodsAccessObjectFactory().getCollectionAO(getIrodsAccount());
			collectionAO.setAccessPermissionInherit(irodsAccount.getZone(), file.getAbsolutePath(), true);
			log.info("collection inheritance set");

		}

		TicketAdminInp ticketPI = TicketAdminInp.instanceForCreate(mode, file.getAbsolutePath(), myTicketId);
		log.info(EXECUTING_TICKET_PI);

		ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
		Tag ticketOperationResponse = pep.irodsFunction(ticketPI);

		log.info("received response from ticket operation:{}", ticketOperationResponse);

		return myTicketId;
	}

	  TicketAdminServiceImpl(final IRODSAccessObjectFactory irodsAccessObjectFactory, final IRODSAccount irodsAccount);

}