use of org.milyn.container.ExecutionContext in project coprhd-controller by CoprHD.
the class SmooksUtil method getParsedXMLJavaResult.
/**
* This initializes the Smooks & parse the given inputStream and returns the javaResult.
*
* @param inputStream : Response in inputStream received from server.
* @param configFile : Smooks configuration file.
* @return
*/
public static JavaResult getParsedXMLJavaResult(InputStream inputStream, String configFile) {
Smooks smooks = null;
JavaResult javaResult = null;
try {
smooks = new Smooks(configFile);
log.debug("initialized smooks");
ExecutionContext executionContext = smooks.createExecutionContext();
// The result of this transform is a set of Java objects...
javaResult = new JavaResult();
// Filter the input message to extract, using the execution context...
smooks.filterSource(executionContext, new StreamSource(inputStream), javaResult);
log.debug("Parsing completed");
} catch (Exception e) {
log.error("Unable to parse the response received from server.", e);
throw HDSException.exceptions.unableToParseResponse();
} finally {
if (null != smooks) {
smooks.close();
}
}
return javaResult;
}
Aggregations