use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class XQueryPipe method configure.
public void configure() throws ConfigurationException {
super.configure();
URL url;
if (StringUtils.isNotEmpty(getXqueryName())) {
url = ClassUtils.getResourceURL(classLoader, getXqueryName());
if (url == null) {
throw new ConfigurationException(getLogPrefix(null) + "could not find XQuery '" + getXqueryName() + "'");
}
} else if (StringUtils.isNotEmpty(getXqueryFile())) {
File file = new File(getXqueryFile());
try {
url = file.toURI().toURL();
} catch (MalformedURLException e) {
throw new ConfigurationException(getLogPrefix(null) + "could not create url for XQuery file", e);
}
} else {
throw new ConfigurationException(getLogPrefix(null) + "no XQuery name or file specified");
}
try {
xquery = Misc.resourceToString(url);
} catch (IOException e) {
throw new ConfigurationException(getLogPrefix(null) + "could not read XQuery", e);
}
SaxonXQDataSource dataSource = new SaxonXQDataSource();
XQConnection connection;
try {
connection = dataSource.getConnection();
preparedExpression = connection.prepareExpression(xquery);
} catch (XQException e) {
throw new ConfigurationException(getLogPrefix(null) + "could not create prepared expression", e);
}
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class XmlValidator method getSchemas.
@Override
public List<Schema> getSchemas(IPipeLineSession session) throws PipeRunException {
List<Schema> xsds = new ArrayList<Schema>();
String schemaLocation = getSchemasId(session);
if (schemaSessionKey != null) {
final URL url = ClassUtils.getResourceURL(classLoader, schemaLocation);
if (url == null) {
throw new PipeRunException(this, getLogPrefix(session) + "could not find schema at [" + schemaLocation + "]");
}
XSD xsd = new XSD();
xsd.setClassLoader(classLoader);
xsd.setNoNamespaceSchemaLocation(schemaLocation);
try {
xsd.init();
} catch (ConfigurationException e) {
throw new PipeRunException(this, "Could not init xsd", e);
}
xsds.add(xsd);
return xsds;
}
return null;
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class XmlValidator method configure.
/**
* Configure the XmlValidator
* @throws ConfigurationException when:
* <ul><li>the schema cannot be found</li>
* <ul><li><{@link #isThrowException()} is false and there is no forward defined
* for "failure"</li>
* <li>when the parser does not accept setting the properties for validating</li>
* </ul>
*/
@Override
public void configure() throws ConfigurationException {
try {
super.configure();
if ((StringUtils.isNotEmpty(getNoNamespaceSchemaLocation()) || StringUtils.isNotEmpty(getSchemaLocation())) && StringUtils.isNotEmpty(getSchemaSessionKey())) {
throw new ConfigurationException(getLogPrefix(null) + "cannot have schemaSessionKey together with schemaLocation or noNamespaceSchemaLocation");
}
checkSchemaSpecified();
if (StringUtils.isNotEmpty(getSoapNamespace())) {
// Don't use this warning yet as it is used for the IFSA to Tibco
// migration where an adapter with Tibco listener (with SOAP
// Envelope and an adapter with IFSA listener (without SOAP Envelop)
// call an adapter with XmlValidator which should validate both.
// ConfigurationWarnings.getInstance().add(log, "Using XmlValidator with soapNamespace for Soap validation is deprecated. Please use " + SoapValidator.class.getName());
String extractNamespaceDefs = "soapenv=" + getSoapNamespace();
String extractBodyXPath = "/soapenv:Envelope/soapenv:Body/*";
try {
transformerPoolExtractSoapBody = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(extractNamespaceDefs, extractBodyXPath, "xml"));
} catch (TransformerConfigurationException te) {
throw new ConfigurationException(getLogPrefix(null) + "got error creating transformer from getSoapBody", te);
}
String getRootNamespace_xslt = XmlUtils.makeGetRootNamespaceXslt();
try {
transformerPoolGetRootNamespace = TransformerPool.getInstance(getRootNamespace_xslt, true);
} catch (TransformerConfigurationException te) {
throw new ConfigurationException(getLogPrefix(null) + "got error creating transformer from getRootNamespace", te);
}
String removeNamespaces_xslt = XmlUtils.makeRemoveNamespacesXslt(true, false);
try {
transformerPoolRemoveNamespaces = TransformerPool.getInstance(removeNamespaces_xslt);
} catch (TransformerConfigurationException te) {
throw new ConfigurationException(getLogPrefix(null) + "got error creating transformer from removeNamespaces", te);
}
}
if (!isForwardFailureToSuccess() && !isThrowException()) {
if (findForward("failure") == null) {
throw new ConfigurationException(getLogPrefix(null) + "must either set throwException true, forwardFailureToSuccess true or have a forward with name [failure]");
}
}
// noNamespaceSchemaLocation.
if (validator.getIgnoreUnknownNamespaces() == null) {
if (StringUtils.isNotEmpty(getNoNamespaceSchemaLocation())) {
validator.setIgnoreUnknownNamespaces(true);
} else {
validator.setIgnoreUnknownNamespaces(false);
}
}
validator.setSchemasProvider(this);
// do initial schema check
if (getSchemasId() != null) {
getSchemas(true);
}
if (isRecoverAdapter()) {
validator.reset();
}
validator.configure(getLogPrefix(null));
registerEvent(AbstractXmlValidator.XML_VALIDATOR_PARSER_ERROR_MONITOR_EVENT);
registerEvent(AbstractXmlValidator.XML_VALIDATOR_NOT_VALID_MONITOR_EVENT);
registerEvent(AbstractXmlValidator.XML_VALIDATOR_VALID_MONITOR_EVENT);
} catch (ConfigurationException e) {
configurationException = e;
throw e;
}
if (getRoot() == null) {
ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
String msg = getLogPrefix(null) + "Root not specified";
configWarnings.add(log, msg);
}
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class MessageSendingPipe method configure.
/**
* Checks whether a sender is defined for this pipe.
*/
@Override
public void configure() throws ConfigurationException {
super.configure();
if (StringUtils.isNotEmpty(getStubFileName())) {
URL stubUrl;
try {
stubUrl = ClassUtils.getResourceURL(classLoader, getStubFileName());
} catch (Throwable e) {
throw new ConfigurationException(getLogPrefix(null) + "got exception finding resource for stubfile [" + getStubFileName() + "]", e);
}
if (stubUrl == null) {
throw new ConfigurationException(getLogPrefix(null) + "could not find resource for stubfile [" + getStubFileName() + "]");
}
try {
returnString = Misc.resourceToString(stubUrl, SystemUtils.LINE_SEPARATOR);
} catch (Throwable e) {
throw new ConfigurationException(getLogPrefix(null) + "got exception loading stubfile [" + getStubFileName() + "] from resource [" + stubUrl.toExternalForm() + "]", e);
}
} else {
propagateName();
if (getSender() == null) {
throw new ConfigurationException(getLogPrefix(null) + "no sender defined ");
}
try {
if (getSender() instanceof PipeAware) {
((PipeAware) getSender()).setPipe(this);
}
getSender().configure();
} catch (ConfigurationException e) {
throw new ConfigurationException(getLogPrefix(null) + "while configuring sender", e);
}
if (getSender() instanceof HasPhysicalDestination) {
log.info(getLogPrefix(null) + "has sender on " + ((HasPhysicalDestination) getSender()).getPhysicalDestinationName());
}
if (getListener() != null) {
if (getSender().isSynchronous()) {
throw new ConfigurationException(getLogPrefix(null) + "cannot have listener with synchronous sender");
}
try {
getListener().configure();
} catch (ConfigurationException e) {
throw new ConfigurationException(getLogPrefix(null) + "while configuring listener", e);
}
if (getListener() instanceof HasPhysicalDestination) {
log.info(getLogPrefix(null) + "has listener on " + ((HasPhysicalDestination) getListener()).getPhysicalDestinationName());
}
}
if (!(getLinkMethod().equalsIgnoreCase("MESSAGEID")) && (!(getLinkMethod().equalsIgnoreCase("CORRELATIONID")))) {
throw new ConfigurationException(getLogPrefix(null) + "Invalid argument for property LinkMethod [" + getLinkMethod() + "]. it should be either MESSAGEID or CORRELATIONID");
}
if (!(getHideMethod().equalsIgnoreCase("all")) && (!(getHideMethod().equalsIgnoreCase("firstHalf")))) {
throw new ConfigurationException(getLogPrefix(null) + "invalid value for hideMethod [" + getHideMethod() + "], must be 'all' or 'firstHalf'");
}
if (isCheckXmlWellFormed() || StringUtils.isNotEmpty(getCheckRootTag())) {
if (findForward(ILLEGAL_RESULT_FORWARD) == null)
throw new ConfigurationException(getLogPrefix(null) + "has no forward with name [illegalResult]");
}
if (!ConfigurationUtils.stubConfiguration()) {
if (StringUtils.isNotEmpty(getTimeOutOnResult())) {
throw new ConfigurationException(getLogPrefix(null) + "timeOutOnResult only allowed in stub mode");
}
if (StringUtils.isNotEmpty(getExceptionOnResult())) {
throw new ConfigurationException(getLogPrefix(null) + "exceptionOnResult only allowed in stub mode");
}
}
if (getMaxRetries() > 0) {
ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
if (getRetryMinInterval() < MIN_RETRY_INTERVAL) {
String msg = "retryMinInterval [" + getRetryMinInterval() + "] should be greater than or equal to [" + MIN_RETRY_INTERVAL + "], assuming the lower limit";
configWarnings.add(log, msg);
setRetryMinInterval(MIN_RETRY_INTERVAL);
}
if (getRetryMaxInterval() > MAX_RETRY_INTERVAL) {
String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be less than or equal to [" + MAX_RETRY_INTERVAL + "], assuming the upper limit";
configWarnings.add(log, msg);
setRetryMaxInterval(MAX_RETRY_INTERVAL);
}
if (getRetryMaxInterval() < getRetryMinInterval()) {
String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be greater than or equal to [" + getRetryMinInterval() + "], assuming the lower limit";
configWarnings.add(log, msg);
setRetryMaxInterval(getRetryMinInterval());
}
}
}
ITransactionalStorage messageLog = getMessageLog();
if (checkMessageLog) {
if (!getSender().isSynchronous() && getListener() == null && !(getSender() instanceof nl.nn.adapterframework.senders.IbisLocalSender)) {
if (messageLog == null) {
ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
String msg = "asynchronous sender [" + getSender().getName() + "] without sibling listener has no messageLog. Integrity check not possible";
configWarnings.add(log, msg);
}
}
}
if (messageLog != null) {
messageLog.configure();
if (messageLog instanceof HasPhysicalDestination) {
String msg = getLogPrefix(null) + "has messageLog in " + ((HasPhysicalDestination) messageLog).getPhysicalDestinationName();
log.info(msg);
if (getAdapter() != null)
getAdapter().getMessageKeeper().add(msg);
}
if (StringUtils.isNotEmpty(getAuditTrailXPath())) {
auditTrailTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getAuditTrailNamespaceDefs(), getAuditTrailXPath(), null, "text", false, null);
}
if (StringUtils.isNotEmpty(getCorrelationIDXPath()) || StringUtils.isNotEmpty(getCorrelationIDStyleSheet())) {
correlationIDTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getCorrelationIDNamespaceDefs(), getCorrelationIDXPath(), getCorrelationIDStyleSheet(), "text", false, null);
}
if (StringUtils.isNotEmpty(getLabelXPath()) || StringUtils.isNotEmpty(getLabelStyleSheet())) {
labelTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getLabelNamespaceDefs(), getLabelXPath(), getLabelStyleSheet(), "text", false, null);
}
}
if (StringUtils.isNotEmpty(getRetryXPath())) {
retryTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getRetryNamespaceDefs(), getRetryXPath(), null, "text", false, null);
}
IPipe inputValidator = getInputValidator();
IPipe outputValidator = getOutputValidator();
if (inputValidator != null && outputValidator == null && inputValidator instanceof IDualModeValidator) {
outputValidator = ((IDualModeValidator) inputValidator).getResponseValidator();
setOutputValidator(outputValidator);
}
if (inputValidator != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
inputValidator.registerForward(pf);
// inputValidator.configure(); // configure is handled in PipeLine.configure()
}
if (outputValidator != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
outputValidator.registerForward(pf);
// outputValidator.configure(); // configure is handled in PipeLine.configure()
}
if (getInputWrapper() != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
getInputWrapper().registerForward(pf);
if (getInputWrapper() instanceof EsbSoapWrapperPipe) {
EsbSoapWrapperPipe eswPipe = (EsbSoapWrapperPipe) getInputWrapper();
ISender sender = getSender();
eswPipe.retrievePhysicalDestinationFromSender(sender);
}
}
if (getOutputWrapper() != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
getOutputWrapper().registerForward(pf);
}
registerEvent(PIPE_TIMEOUT_MONITOR_EVENT);
registerEvent(PIPE_CLEAR_TIMEOUT_MONITOR_EVENT);
registerEvent(PIPE_EXCEPTION_MONITOR_EVENT);
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class PutSystemDateInSession method configure.
/**
* checks wether the proper forward is defined, a dateformat is specified and the dateformat is valid.
* @throws ConfigurationException
*/
public void configure() throws ConfigurationException {
super.configure();
// check the presence of a sessionKey
if (getSessionKey() == null) {
throw new ConfigurationException(getLogPrefix(null) + "has a null value for sessionKey");
}
// check the presence of a dateformat
if (getDateFormat() == null) {
throw new ConfigurationException(getLogPrefix(null) + "has a null value for dateFormat");
}
if (isReturnFixedDate()) {
if (!ConfigurationUtils.stubConfiguration()) {
throw new ConfigurationException(getLogPrefix(null) + "returnFixedDate only allowed in stub mode");
}
}
// check the dateformat
try {
Date currentDate = new Date();
SimpleDateFormat formatter = new SimpleDateFormat(getDateFormat());
} catch (IllegalArgumentException ex) {
throw new ConfigurationException(getLogPrefix(null) + "has an illegal value for dateFormat", ex);
}
formatter = new SimpleDateFormat(getDateFormat());
if (timeZone != null) {
formatter.setTimeZone(timeZone);
}
}
Aggregations