Search in sources :

Example 86 with CoreException

use of com.adaptris.core.CoreException in project interlok by adaptris.

the class IgnoreOriginalXmlDocumentAggregator method aggregate.

@Override
public void aggregate(AdaptrisMessage original, Iterable<AdaptrisMessage> messages) throws CoreException {
    try {
        if (isEmpty(getTemplate())) {
            throw new CoreException("Template is null / empty, cannot continue");
        }
        Document resultDoc = XmlHelper.createDocument(getTemplate(), documentFactoryBuilder());
        for (AdaptrisMessage m : messages) {
            if (filter(m)) {
                Document mergeDoc = XmlHelper.createDocument(m, documentFactoryBuilder());
                overwriteMetadata(m, original);
                resultDoc = getMergeImplementation().merge(resultDoc, mergeDoc);
            }
        }
        XmlHelper.writeXmlDocument(resultDoc, original, getDocumentEncoding());
    } catch (Exception e) {
        throw ExceptionHelper.wrapCoreException(e);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Document(org.w3c.dom.Document) CoreException(com.adaptris.core.CoreException)

Example 87 with CoreException

use of com.adaptris.core.CoreException in project interlok by adaptris.

the class ScriptingService method initService.

@Override
protected void initService() throws CoreException {
    try {
        Args.notBlank(getScriptFilename(), "scriptFilename");
        File f = new File(getScriptFilename());
        FsWorker.isFile(FsWorker.checkReadable(f));
        super.initService();
    } catch (Exception e) {
        throw ExceptionHelper.wrapCoreException(e);
    }
}
Also used : File(java.io.File) IOException(java.io.IOException) CoreException(com.adaptris.core.CoreException)

Example 88 with CoreException

use of com.adaptris.core.CoreException in project interlok by adaptris.

the class CoreSecurityService method initService.

@Override
protected final void initService() throws CoreException {
    try {
        pkPassword = getPrivateKeyPasswordProvider().retrievePrivateKeyPassword();
    } catch (PasswordException e) {
        throw new CoreException("Could not get password using " + getPrivateKeyPasswordProvider().getClass().getCanonicalName(), e);
    }
    try {
        if (isEmpty(localPartner)) {
            throw new CoreException("No Local Partner configured");
        }
        localPartnerAlias = new Alias(localPartner, pkPassword);
        if (isEmpty(remotePartner)) {
            log.warn("Remote partner not configured,  " + "must be set individually as message metadata");
        } else {
            remotePartnerAlias = new Alias(remotePartner);
        }
        SecurityServiceFactory factory = securityFactory;
        if (factory == null) {
            factory = SecurityServiceFactory.defaultInstance();
        }
        service = factory.createService();
        for (Iterator i = keystoreUrls.iterator(); i.hasNext(); ) {
            ConfiguredKeystore url = (ConfiguredKeystore) i.next();
            service.registerKeystore(url);
        }
        service.setEncryptionAlgorithm(encryptionAlgorithm);
        if (successId != null && failId != null) {
            branchingEnabled = true;
        } else {
            log.debug("No Success Id or Fail Id, branching disabled");
        }
    } catch (AdaptrisSecurityException e) {
        throw new CoreException(e);
    }
}
Also used : PasswordException(com.adaptris.security.exc.PasswordException) CoreException(com.adaptris.core.CoreException) Alias(com.adaptris.security.keystore.Alias) Iterator(java.util.Iterator) AdaptrisSecurityException(com.adaptris.security.exc.AdaptrisSecurityException) ConfiguredKeystore(com.adaptris.security.keystore.ConfiguredKeystore) SecurityServiceFactory(com.adaptris.security.SecurityServiceFactory)

Example 89 with CoreException

use of com.adaptris.core.CoreException in project interlok by adaptris.

the class ComponentManagerImpl method registerSelf.

/**
 * Convenience method to handle {@link BaseComponentMBean#registerMBean()}
 */
protected void registerSelf() throws CoreException {
    try {
        ObjectName objName = createObjectName();
        log.trace("Registering {} against {}", this.getClass().getName(), objName);
        JmxHelper.register(objName, this);
    } catch (Exception e) {
        throw new CoreException(e);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) TimeoutException(java.util.concurrent.TimeoutException) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) MalformedObjectNameException(javax.management.MalformedObjectNameException) CoreException(com.adaptris.core.CoreException) ObjectName(javax.management.ObjectName)

Example 90 with CoreException

use of com.adaptris.core.CoreException in project interlok by adaptris.

the class ComponentManagerImpl method requestStop.

public void requestStop(final long timeout) throws CoreException, TimeoutException {
    checkTransitionTo(StoppedState.getInstance());
    final CyclicBarrier barrier = new CyclicBarrier(2);
    executeAndWait(timeout, barrier, new Runnable() {

        @Override
        public void run() {
            Thread current = Thread.currentThread();
            current.setName(THREAD_NAME_PREFIX + requestNumber.getAndIncrement());
            LifecycleHelper.stop(getWrappedComponent());
            try {
                barrier.await(timeout, TimeUnit.MILLISECONDS);
            } catch (Exception e) {
                current.getUncaughtExceptionHandler().uncaughtException(current, e);
            }
        }
    });
    sendLifecycleNotification(NOTIF_MSG_STOPPED, getComponentState());
}
Also used : TimeoutException(java.util.concurrent.TimeoutException) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) MalformedObjectNameException(javax.management.MalformedObjectNameException) CoreException(com.adaptris.core.CoreException) CyclicBarrier(java.util.concurrent.CyclicBarrier)

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