class RuleCompositionServiceImpl extends AbstractJargonService implements RuleCompositionService {

	@Override
	public Rule storeRuleFromParts(final String ruleAbsolutePath, final String ruleBody,
			final List<String> inputParameters, final List<String> outputParameters) throws JargonException {
		log.info("storeRuleFromParts()");

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

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

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

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

		log.info("ruleAbsolutePath:{}", ruleAbsolutePath);
		log.info("inputParameters:{}", inputParameters);
		log.info("outputParameters:{}", outputParameters);

		String ruleAsString = buildRuleStringFromParts(ruleBody, inputParameters, outputParameters);
		IRODSFile irodsFile = getIrodsAccessObjectFactory().getIRODSFileFactory(getIrodsAccount())
				.instanceIRODSFile(ruleAbsolutePath);

		Stream2StreamAO stream2StreamAO = getIrodsAccessObjectFactory().getStream2StreamAO(getIrodsAccount());
		try {
			stream2StreamAO.streamBytesToIRODSFile(
					ruleAsString.getBytes(getIrodsAccessObjectFactory().getJargonProperties().getEncoding()),
					irodsFile);
		} catch (UnsupportedEncodingException e) {
			log.error("unsupported encoding streaming to file", e);
			throw new JargonException("error writing rule file", e);
		}

		log.info("rule stored:{}", ruleAsString);

		return parseStringIntoRule(ruleAsString);

	}

	public  RuleCompositionServiceImpl();
	public  RuleCompositionServiceImpl(final IRODSAccessObjectFactory irodsAccessObjectFactory,
			final IRODSAccount irodsAccount);

}