class TicketClientOperationsImpl extends AbstractTicketService implements TicketClientOperations {

	@Override
	public void redeemTicketAndStreamToIRODSCollection(final String ticketString,
			final String irodsCollectionAbsolutePath, final String fileName, final InputStream inputStreamForFileData,
			final File temporaryCacheDirectoryLocation)
			throws DataNotFoundException, OverwriteException, JargonException {

		log.info("redeemTicketAndStreamToIRODSCollection()");

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

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

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

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

		if (!temporaryCacheDirectoryLocation.exists()) {
			throw new JargonException("temporaryCacheDirectoryLocation does not exist");
		}

		if (!temporaryCacheDirectoryLocation.isDirectory()) {
			throw new JargonException("temporaryCacheDirectoryLocation is not a directory");
		}

		/*
		 * Everything is in order I need to stream the input stream data to a temporary
		 * file first
		 */

		StringBuffer sb = new StringBuffer();
		sb.append("redeemTicketAndStreamToIRODSCollection_");
		sb.append(System.currentTimeMillis());
		sb.append("_");
		sb.append(fileName);
		String tempFileName = sb.toString();
		log.info("temp file name:{}", tempFileName);
		File tempFile = new File(temporaryCacheDirectoryLocation, tempFileName);

		try {
			FileUtils.copyInputStreamToFile(inputStreamForFileData, tempFile);
		} catch (IOException e) {
			log.error("io exception copying input stream to temp file", e);
			throw new JargonException("error copying provided input stream to temporary cache");
		}

		IRODSFile targetIrodsFile = getIrodsAccessObjectFactory().getIRODSFileFactory(getIrodsAccount())
				.instanceIRODSFile(irodsCollectionAbsolutePath, fileName);
		log.info("target iRODS file:{}", targetIrodsFile);

		log.info("data has been copied to temp file, now put to iRODS via ticket");
		/*
		 * Put file, try and clean up no matter what happens
		 */
		try {
			putFileToIRODSUsingTicket(ticketString, tempFile, targetIrodsFile, null, null);
		} finally {
			log.info("delete the temp file");
			tempFile.delete();
			log.info("close input stream");
			try {
				inputStreamForFileData.close();
			} catch (IOException e) {
			}
		}

		log.info("transfer complete");

	}

	  TicketClientOperationsImpl(final IRODSAccessObjectFactory irodsAccessObjectFactory, final IRODSAccount irodsAccount);

}