use of com.adaptris.core.CoreException in project interlok by adaptris.
the class FtpConsumerCase method testInit_UnknownFileFilter.
@Test
public void testInit_UnknownFileFilter() throws Exception {
FtpConsumer ftpConsumer = new FtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationString());
ftpConsumer.setFileFilterImp(".*");
ftpConsumer.setFileFilterImp("BlahDeBlahDeBlah");
ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
try {
ftpConsumer.init();
ftpConsumer.close();
fail();
} catch (CoreException expected) {
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class HttpProducer method init.
@Override
public void init() throws CoreException {
try {
if (getUserName() != null && getPassword() != null) {
authString = buildBasicRfc2617(getUserName(), Password.decode(ExternalResolver.resolve(getPassword())));
passwordAuth = new PasswordAuthentication(userName, Password.decode(ExternalResolver.resolve(getPassword())).toCharArray());
}
if (sendMetadataAsHeaders()) {
if (getSendMetadataRegexp() == null && getMetadataFilter() instanceof RemoveAllMetadataFilter) {
log.warn("No Metadata Regular expression configured, ignoring sendMetadataAsHeaders=true");
setSendMetadataAsHeaders(Boolean.FALSE);
} else {
if (getSendMetadataRegexp() != null && getMetadataFilter() instanceof RemoveAllMetadataFilter) {
log.trace("Overriding metadata-filter with filter based on {}", getSendMetadataRegexp());
RegexMetadataFilter filter = new RegexMetadataFilter();
filter.addIncludePattern(getSendMetadataRegexp());
setMetadataFilter(filter);
}
}
}
} catch (Exception e) {
throw new CoreException(e);
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class BranchingHttpRequestService method doService.
@Override
public void doService(AdaptrisMessage msg) throws ServiceException {
StandardHttpProducer p = buildProducer(msg);
p.setIgnoreServerResponseCode(true);
try {
LifecycleHelper.initAndStart(p, false).request(msg);
Optional.ofNullable(getDefaultServiceId()).ifPresent((s) -> msg.setNextServiceId(s));
int responseCode = ((Integer) msg.getObjectHeaders().get(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE)).intValue();
for (StatusEvaluator rp : getStatusMatches()) {
if (rp.matches(responseCode)) {
msg.setNextServiceId(rp.serviceId());
break;
}
}
} catch (CoreException e) {
throw ExceptionHelper.wrapServiceException(e);
} finally {
LifecycleHelper.stopAndClose(p, false);
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class BasicJettyConsumer method ensureIsPath.
// Ensure that if someone types in http://localhost:8080/fred/blah/blah then
// we make sure that we return /fred/blah/blah
protected String ensureIsPath(String s) throws CoreException {
String result = s;
try {
URI uri = new URI(s);
result = uri.getPath();
} catch (URISyntaxException e) {
throw new CoreException(e);
}
return result;
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class EmbeddedConnection method addServlet.
@Override
public void addServlet(ServletWrapper wrapper) throws CoreException {
try {
JettyServerManager serverManager = JettyServerManager.getInstance();
HashMap<String, Object> additionalProperties = new HashMap<String, Object>();
additionalProperties.put(JettyServerManager.CONTEXT_PATH, wrapper.getUrl());
additionalProperties.put(JettyServerManager.SECURITY_CONSTRAINTS, getSecurityHandler());
serverManager.addServlet(SERVER_ID, wrapper.getServletHolder(), additionalProperties);
serverManager.startDeployment(SERVER_ID, wrapper.getUrl());
log.trace("Added " + wrapper.getServletHolder() + " against " + wrapper.getUrl());
} catch (Exception ex) {
throw ExceptionHelper.wrapCoreException(ex);
}
}
Aggregations