Search in sources :

Example 96 with CoreException

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) {
    }
}
Also used : QuartzCronPoller(com.adaptris.core.QuartzCronPoller) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 97 with CoreException

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);
    }
}
Also used : RegexMetadataFilter(com.adaptris.core.metadata.RegexMetadataFilter) CoreException(com.adaptris.core.CoreException) RemoveAllMetadataFilter(com.adaptris.core.metadata.RemoveAllMetadataFilter) ProduceException(com.adaptris.core.ProduceException) IOException(java.io.IOException) CoreException(com.adaptris.core.CoreException) PasswordAuthentication(java.net.PasswordAuthentication)

Example 98 with CoreException

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);
    }
}
Also used : StatusEvaluator(com.adaptris.core.http.client.StatusEvaluator) CoreException(com.adaptris.core.CoreException) InputFieldHint(com.adaptris.annotation.InputFieldHint)

Example 99 with CoreException

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;
}
Also used : CoreException(com.adaptris.core.CoreException) URISyntaxException(java.net.URISyntaxException) JETTY_URI(com.adaptris.core.http.jetty.JettyConstants.JETTY_URI) URI(java.net.URI)

Example 100 with CoreException

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);
    }
}
Also used : HashMap(java.util.HashMap) CoreException(com.adaptris.core.CoreException) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager)

Aggregations

CoreException (com.adaptris.core.CoreException)186 Test (org.junit.Test)110 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)44 Adapter (com.adaptris.core.Adapter)32 ObjectName (javax.management.ObjectName)29 Channel (com.adaptris.core.Channel)27 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)20 File (java.io.File)19 ServiceException (com.adaptris.core.ServiceException)14 TimeInterval (com.adaptris.util.TimeInterval)13 Document (org.w3c.dom.Document)12 MalformedObjectNameException (javax.management.MalformedObjectNameException)11 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)10 StandardWorkflow (com.adaptris.core.StandardWorkflow)9 URLString (com.adaptris.util.URLString)9 TimeoutException (java.util.concurrent.TimeoutException)9 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)8 Workflow (com.adaptris.core.Workflow)8 XPath (com.adaptris.util.text.xml.XPath)8