Search in sources :

Example 1 with IbisManager

use of nl.nn.adapterframework.configuration.IbisManager in project iaf by ibissource.

the class ConfigurationBase method doGet.

/**
 * When extending this class, copy and extend the doGet method in the new
 * child class.
 */
protected String doGet(IPipeLineSession session) throws PipeRunException {
    IbisManager ibisManager = RestListenerUtils.retrieveIbisManager(session);
    String configurationName = null;
    if (configurationName == null) {
        configurationName = retrieveConfigurationName(session);
    }
    Configuration configuration = null;
    boolean configAll;
    if (configurationName == null || configurationName.equalsIgnoreCase(CONFIG_ALL)) {
        configAll = true;
    } else {
        configuration = ibisManager.getConfiguration(configurationName);
        if (configuration == null) {
            configAll = true;
        } else {
            configAll = false;
        }
    }
    List<Configuration> allConfigurations = ibisManager.getConfigurations();
    XmlBuilder configurationsXml = toConfigurationsXml(allConfigurations);
    storeConfiguration(session, configAll, configuration);
    XmlBuilder root = new XmlBuilder("root");
    root.addSubElement(configurationsXml);
    return root.toXML();
}
Also used : IbisManager(nl.nn.adapterframework.configuration.IbisManager) Configuration(nl.nn.adapterframework.configuration.Configuration) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 2 with IbisManager

use of nl.nn.adapterframework.configuration.IbisManager in project iaf by ibissource.

the class ShowConfigurationStatus method doGet.

@Override
protected String doGet(IPipeLineSession session) throws PipeRunException {
    IbisManager ibisManager = retrieveIbisManager();
    String configurationName = null;
    ShowConfigurationStatusManager showConfigurationStatusManager = new ShowConfigurationStatusManager();
    String countStr = (String) session.get("count");
    showConfigurationStatusManager.count = Boolean.parseBoolean(countStr);
    String alertStr = (String) session.get("alert");
    if (alertStr != null) {
        showConfigurationStatusManager.alert = Boolean.parseBoolean(alertStr);
        configurationName = CONFIG_ALL;
    }
    if (configurationName == null) {
        configurationName = retrieveConfigurationName(session);
    }
    Configuration configuration = null;
    boolean configAll;
    if (configurationName == null || configurationName.equalsIgnoreCase(CONFIG_ALL)) {
        configAll = true;
    } else {
        configuration = ibisManager.getConfiguration(configurationName);
        if (configuration == null) {
            configAll = true;
        } else {
            configAll = false;
        }
    }
    List<Configuration> allConfigurations = ibisManager.getConfigurations();
    XmlBuilder configurationsXml = toConfigurationsXml(allConfigurations);
    List<IAdapter> registeredAdapters = retrieveRegisteredAdapters(ibisManager, configAll, configuration);
    storeConfiguration(session, configAll, configuration);
    XmlBuilder adapters = toAdaptersXml(ibisManager, allConfigurations, configuration, registeredAdapters, showConfigurationStatusManager);
    XmlBuilder root = new XmlBuilder("root");
    root.addSubElement(configurationsXml);
    root.addSubElement(adapters);
    return root.toXML();
}
Also used : IbisManager(nl.nn.adapterframework.configuration.IbisManager) Configuration(nl.nn.adapterframework.configuration.Configuration) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) IAdapter(nl.nn.adapterframework.core.IAdapter)

Example 3 with IbisManager

use of nl.nn.adapterframework.configuration.IbisManager in project iaf by ibissource.

the class RestListenerUtils method doRestartShowConfigurationStatus.

private static boolean doRestartShowConfigurationStatus(ServletContext servletContext) {
    String attributeKey = AppConstants.getInstance().getProperty(ConfigurationServlet.KEY_CONTEXT);
    IbisContext ibisContext = (IbisContext) servletContext.getAttribute(attributeKey);
    IAdapter adapter = null;
    IReceiver receiver = null;
    if (ibisContext != null) {
        IbisManager ibisManager = ibisContext.getIbisManager();
        if (ibisManager != null) {
            Configuration configuration = ibisManager.getConfiguration(SHOW_CONFIG_STATUS_CONFIGURATION);
            if (configuration != null) {
                adapter = configuration.getRegisteredAdapter(SHOW_CONFIG_STATUS_ADAPTER);
                if (adapter instanceof Adapter) {
                    receiver = ((Adapter) adapter).getReceiverByNameAndListener(SHOW_CONFIG_STATUS_RECEIVER, RestListener.class);
                }
            }
        }
    }
    if (adapter == null) {
        log.info("could not restart ShowConfigurationStatus, adapter [" + SHOW_CONFIG_STATUS_ADAPTER + "] not found");
        return false;
    }
    if (receiver == null) {
        log.info("could not restart ShowConfigurationStatus, receiver [" + SHOW_CONFIG_STATUS_RECEIVER + "] not found");
        return false;
    }
    RunStateEnum adapterStatus = adapter.getRunState();
    RunStateEnum receiverStatus = receiver.getRunState();
    if (RunStateEnum.STARTED.equals(adapterStatus) && RunStateEnum.STARTED.equals(receiverStatus)) {
        log.info("ShowConfigurationStatus is already running, will restart it");
        ibisContext.getIbisManager().handleAdapter("stopadapter", SHOW_CONFIG_STATUS_CONFIGURATION, SHOW_CONFIG_STATUS_ADAPTER, SHOW_CONFIG_STATUS_RECEIVER, "system", true);
    }
    if (RunStateEnum.STOPPED.equals(adapterStatus)) {
        log.info("starting adapter of ShowConfigurationStatus");
        ibisContext.getIbisManager().handleAdapter("startadapter", SHOW_CONFIG_STATUS_CONFIGURATION, SHOW_CONFIG_STATUS_ADAPTER, SHOW_CONFIG_STATUS_RECEIVER, "system", true);
        return true;
    } else {
        if (RunStateEnum.STARTED.equals(adapterStatus) && RunStateEnum.STOPPED.equals(receiverStatus)) {
            log.info("starting receiver of ShowConfigurationStatus");
            ibisContext.getIbisManager().handleAdapter("startreceiver", SHOW_CONFIG_STATUS_CONFIGURATION, SHOW_CONFIG_STATUS_ADAPTER, SHOW_CONFIG_STATUS_RECEIVER, "system", true);
            return true;
        }
    }
    log.info("could not restart ShowConfigurationStatus with adapter status [" + adapterStatus + "] and receiver status [" + receiverStatus + "]");
    return false;
}
Also used : IbisContext(nl.nn.adapterframework.configuration.IbisContext) IReceiver(nl.nn.adapterframework.core.IReceiver) IbisManager(nl.nn.adapterframework.configuration.IbisManager) Configuration(nl.nn.adapterframework.configuration.Configuration) RunStateEnum(nl.nn.adapterframework.util.RunStateEnum) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) IAdapter(nl.nn.adapterframework.core.IAdapter)

Example 4 with IbisManager

use of nl.nn.adapterframework.configuration.IbisManager in project iaf by ibissource.

the class ConfiguredJob method execute.

public void execute(JobExecutionContext context) throws JobExecutionException {
    String ctName = Thread.currentThread().getName();
    try {
        JobDataMap dataMap = context.getJobDetail().getJobDataMap();
        IbisManager ibisManager = (IbisManager) dataMap.get("manager");
        JobDef jobDef = (JobDef) dataMap.get("jobdef");
        Thread.currentThread().setName(jobDef.getName() + "[" + ctName + "]");
        log.info(getLogPrefix(jobDef) + "executing");
        jobDef.executeJob(ibisManager);
        log.debug(getLogPrefix(jobDef) + "completed");
    } catch (Exception e) {
        log.error(e);
        throw new JobExecutionException(e, false);
    } finally {
        Thread.currentThread().setName(ctName);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) JobExecutionException(org.quartz.JobExecutionException) IbisManager(nl.nn.adapterframework.configuration.IbisManager) JobExecutionException(org.quartz.JobExecutionException)

Example 5 with IbisManager

use of nl.nn.adapterframework.configuration.IbisManager in project iaf by ibissource.

the class TestPipeline method getIbisManager.

private IbisManager getIbisManager() {
    String attributeKey = AppConstants.getInstance().getProperty(ConfigurationServlet.KEY_CONTEXT);
    IbisContext ibisContext = (IbisContext) servletConfig.getServletContext().getAttribute(attributeKey);
    if (ibisContext != null) {
        IbisManager ibisManager = ibisContext.getIbisManager();
        if (ibisManager == null) {
            log.warn("Could not retrieve ibisManager from context");
        } else {
            log.trace("retrieved ibisManager [" + ClassUtils.nameOf(ibisManager) + "][" + ibisManager + "] from servlet context attribute [" + attributeKey + "]");
            return ibisManager;
        }
    }
    return null;
}
Also used : IbisContext(nl.nn.adapterframework.configuration.IbisContext) IbisManager(nl.nn.adapterframework.configuration.IbisManager)

Aggregations

IbisManager (nl.nn.adapterframework.configuration.IbisManager)8 Configuration (nl.nn.adapterframework.configuration.Configuration)4 IAdapter (nl.nn.adapterframework.core.IAdapter)4 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)3 IOException (java.io.IOException)2 IbisContext (nl.nn.adapterframework.configuration.IbisContext)2 PipeRunException (nl.nn.adapterframework.core.PipeRunException)2 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ZipInputStream (java.util.zip.ZipInputStream)1 RolesAllowed (javax.annotation.security.RolesAllowed)1 NamingException (javax.naming.NamingException)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 Adapter (nl.nn.adapterframework.core.Adapter)1