class TicketClientOperationsImpl extends AbstractTicketService implements TicketClientOperations {

	@Override
	public FileStreamAndInfo redeemTicketGetDataObjectAndStreamBack(final String ticketString,
			final IRODSFile irodsSourceFile, final File intermediateCacheRootDirectory)
			throws DataNotFoundException, JargonException {

		log.info("redeemTicketGetDataObjectAndStreamBack()");

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

		if (intermediateCacheRootDirectory == null) {
			throw new IllegalArgumentException("null intermediateCacheRootDirectory");
		}

		log.info("intermediate cache root dir:{}", intermediateCacheRootDirectory.getAbsolutePath());

		if (!intermediateCacheRootDirectory.exists()) {
			throw new JargonException("cannot create intermediate cache, root dir does not exist");
		}

		// compute file name under cache dir as current time +
		// irodsSourceFileName
		StringBuilder sb = new StringBuilder();
		sb.append(".tempTicketFileCache_");
		sb.append(System.currentTimeMillis());
		sb.append("_");
		sb.append(irodsSourceFile.getName());
		String tempFileName = sb.toString();

		log.info("temp file name: {}", tempFileName);

		File intermediateCacheFile = new File(intermediateCacheRootDirectory, tempFileName);

		// other param checks done in delegated methods

		log.info("initializing session with ticket:{}", ticketString);
		ticketClientSupport.initializeSessionWithTicket(ticketString);

		log.info("session initialized, doing get operation");
		dataTransferOperations.getOperation(irodsSourceFile, intermediateCacheFile, null, null);
		log.info("file obtained and in cache, now returning an input stream");
		InputStream inputStream;
		try {
			inputStream = new BufferedInputStream(new CleanUpWhenClosedInputStream(intermediateCacheFile));
			return new FileStreamAndInfo(inputStream, intermediateCacheFile.length());
		} catch (FileNotFoundException e) {
			log.error("cannot find temp cache file to stream back", e);
			throw new JargonException("cannot find the temporary cache stream I had created");
		}

	}

	  TicketClientOperationsImpl(final IRODSAccessObjectFactory irodsAccessObjectFactory, final IRODSAccount irodsAccount);

}