use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ZipAggregator method aggregate.
@Override
public void aggregate(AdaptrisMessage original, Iterable<AdaptrisMessage> messages) throws CoreException {
try (ZipOutputStream zipOutputStream = new ZipOutputStream(original.getOutputStream())) {
for (AdaptrisMessage m : messages) {
if (BooleanUtils.and(new boolean[] { filter(m), m.headersContainsKey(filenameMetadata()) })) {
zipOutputStream.putNextEntry(new ZipEntry(m.getMetadataValue(filenameMetadata())));
try (InputStream in = m.getInputStream()) {
IOUtils.copy(in, zipOutputStream);
}
zipOutputStream.closeEntry();
}
}
} catch (Exception e) {
throw ExceptionHelper.wrapCoreException(e);
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ConditionFunction method init.
@Override
public void init() throws CoreException {
try {
ScriptEngineManager manager = new ScriptEngineManager(this.getClass().getClassLoader());
engine = Args.notNull(manager.getEngineByName("nashorn"), "nashorn engine");
engine.eval(definition);
Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
bindings.put("log", log);
} catch (Exception e) {
throw ExceptionHelper.wrapCoreException(e);
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ExceptionAsXml method serialize.
@Override
public void serialize(Exception exception, AdaptrisMessage msg) throws CoreException {
try {
Document newDoc = exceptionGenerator().create(exception, msg.getMetadataValue(Workflow.WORKFLOW_ID_KEY), (String) msg.getObjectHeaders().get(CoreConstants.OBJ_METADATA_EXCEPTION_CAUSE));
Document result = documentMerge().merge(XmlHelper.createDocument(msg, documentFactoryBuilder(), ignoreXmlParseExceptions()), newDoc);
String encoding = XmlHelper.getXmlEncoding(msg, getXmlEncoding());
XmlHelper.writeXmlDocument(result, msg, encoding);
} catch (Exception e) {
throw ExceptionHelper.wrapServiceException(e);
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class XpathCacheValueTranslator method getValueFromMessage.
/**
* @return the result of applying the configured xpath against the payload of this {@link AdaptrisMessage}
*/
@Override
public String getValueFromMessage(AdaptrisMessage msg) throws CoreException {
NamespaceContext ctx = SimpleNamespaceContext.create(getNamespaceContext(), msg);
DocumentBuilderFactoryBuilder builder = documentFactoryBuilder(ctx);
String result = null;
try {
XPath xp = XPath.newXPathInstance(builder, ctx);
Document d = XmlHelper.createDocument(msg, builder);
result = xp.selectSingleTextItem(d, msg.resolve(getXpath()));
} catch (Exception e) {
throw ExceptionHelper.wrapCoreException(e);
}
return result;
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class XmlPayloadTranslatorImpl method createXmlUtils.
protected static XmlUtils createXmlUtils(AdaptrisMessage msg) {
XmlUtils xu = null;
try {
NamespaceContext ctx = (NamespaceContext) msg.getObjectHeaders().get(JdbcDataQueryService.KEY_NAMESPACE_CTX);
DocumentBuilderFactoryBuilder builder = (DocumentBuilderFactoryBuilder) msg.getObjectHeaders().get(JdbcDataQueryService.KEY_DOCBUILDER_FAC);
xu = XmlHelper.createXmlUtils(msg, ctx, builder);
} catch (CoreException e) {
xu = new XmlUtils();
}
return xu;
}
Aggregations