Search in sources :

Example 1 with Configuration

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

the class ShowConfiguration method getConfigurationByName.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/configurations/{configuration}")
@Produces(MediaType.APPLICATION_XML)
public Response getConfigurationByName(@PathParam("configuration") String configurationName, @QueryParam("loadedConfiguration") boolean loadedConfiguration) throws ApiException {
    initBase(servletConfig);
    String result = "";
    Configuration configuration = ibisManager.getConfiguration(configurationName);
    if (configuration == null) {
        throw new ApiException("Configuration not found!");
    }
    if (loadedConfiguration) {
        result = configuration.getOriginalConfiguration();
    } else {
        result = configuration.getLoadedConfiguration();
    }
    return Response.status(Response.Status.CREATED).entity(result).build();
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with Configuration

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

the class ShowConfiguration method makeConfigurationActive.

@GET
@RolesAllowed({ "IbisTester" })
@Path("/configurations/manage/{configuration}/activate/{version}")
@Produces(MediaType.APPLICATION_JSON)
public Response makeConfigurationActive(@PathParam("configuration") String configurationName, @PathParam("version") String version, @QueryParam("realm") String jmsRealm) throws ApiException {
    initBase(servletConfig);
    Configuration configuration = ibisManager.getConfiguration(configurationName);
    if (configuration == null) {
        throw new ApiException("Configuration not found!");
    }
    if (version == null || version.isEmpty()) {
        throw new ApiException("No version supplied!");
    }
    if (StringUtils.isEmpty(version))
        version = null;
    if (StringUtils.isEmpty(jmsRealm))
        jmsRealm = null;
    try {
        if (ConfigurationUtils.makeConfigActive(ibisContext, configurationName, version, jmsRealm))
            return Response.status(Response.Status.ACCEPTED).entity("{\"status\":\"ok\"}").build();
        else
            return Response.status(Response.Status.BAD_REQUEST).build();
    } catch (ConfigurationException e) {
        return Response.status(Response.Status.BAD_REQUEST).build();
    }
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with Configuration

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

the class ShowConfiguration method getXMLConfiguration.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/configurations")
@Produces(MediaType.APPLICATION_XML)
public Response getXMLConfiguration(@QueryParam("loadedConfiguration") boolean loadedConfiguration) throws ApiException {
    initBase(servletConfig);
    String result = "";
    for (Configuration configuration : ibisManager.getConfigurations()) {
        if (loadedConfiguration) {
            result = result + configuration.getOriginalConfiguration();
        } else {
            result = result + configuration.getLoadedConfiguration();
        }
    }
    return Response.status(Response.Status.CREATED).entity(result).build();
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with Configuration

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

the class ShowConfigurationStatus method mapAdapter.

private Map<String, Object> mapAdapter(Adapter adapter) {
    Map<String, Object> adapterInfo = new HashMap<String, Object>();
    Configuration config = adapter.getConfiguration();
    String adapterName = adapter.getName();
    adapterInfo.put("name", adapterName);
    adapterInfo.put("description", adapter.getDescription());
    adapterInfo.put("configuration", config.getName());
    // replace low line (x'5f') by asterisk (x'2a) so it's sorted before any digit and letter
    String nameUC = StringUtils.upperCase(StringUtils.replace(adapterName, "_", "*"));
    adapterInfo.put("nameUC", nameUC);
    RunStateEnum adapterRunState = adapter.getRunState();
    adapterInfo.put("started", adapterRunState.equals(RunStateEnum.STARTED));
    String state = adapterRunState.toString().toLowerCase().replace("*", "");
    adapterInfo.put("state", state);
    adapterInfo.put("configured", adapter.configurationSucceeded());
    adapterInfo.put("upSince", adapter.getStatsUpSinceDate().getTime());
    Date lastMessage = adapter.getLastMessageDateDate();
    adapterInfo.put("lastMessage", (lastMessage == null) ? null : lastMessage.getTime());
    adapterInfo.put("messagesInProcess", adapter.getNumOfMessagesInProcess());
    adapterInfo.put("messagesProcessed", adapter.getNumOfMessagesProcessed());
    adapterInfo.put("messagesInError", adapter.getNumOfMessagesInError());
    return adapterInfo;
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) RunStateEnum(nl.nn.adapterframework.util.RunStateEnum) Date(java.util.Date)

Example 5 with Configuration

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

the class ShowScheduler method getJobGroupNamesWithJobs.

private Map<String, Object> getJobGroupNamesWithJobs(Scheduler scheduler) throws ApiException {
    Map<String, Object> jobGroups = new HashMap<String, Object>();
    try {
        String[] jobGroupNames = scheduler.getJobGroupNames();
        for (int i = 0; i < jobGroupNames.length; i++) {
            Map<String, Object> jobsInGroup = new HashMap<String, Object>();
            String jobGroupName = jobGroupNames[i];
            String[] jobNames = scheduler.getJobNames(jobGroupName);
            for (int j = 0; j < jobNames.length; j++) {
                String jobName = jobNames[j];
                Map<String, Object> jobData = new HashMap<String, Object>();
                JobDef jobDef = null;
                for (Configuration configuration : ibisManager.getConfigurations()) {
                    jobDef = configuration.getScheduledJob(jobName);
                    if (jobDef != null) {
                        break;
                    }
                }
                JobDetail job = scheduler.getJobDetail(jobName, jobGroupName);
                jobData.put("fullName", job.getFullName());
                jobData.put("name", job.getName());
                String description = "-";
                if (StringUtils.isNotEmpty(job.getDescription()))
                    description = job.getDescription();
                jobData.put("description", description);
                jobData.put("stateful", job.isStateful());
                jobData.put("durable", job.isDurable());
                jobData.put("volatile", job.isVolatile());
                jobData.put("jobClass", job.getJobClass().getName());
                jobData.put("triggers", getJobTriggers(scheduler, jobName, jobGroupName));
                jobData.put("messages", getJobMessages(jobDef));
                JobDataMap jobMap = job.getJobDataMap();
                jobData.put("containsTransientData", jobMap.containsTransientData());
                jobData.put("allowsTransientData", jobMap.getAllowsTransientData());
                jobData.put("properties", getJobData(jobMap));
                jobsInGroup.put(jobName, jobData);
            }
            jobGroups.put(jobGroupName, jobsInGroup);
        }
    } catch (Exception e) {
        log.error(e);
    }
    return jobGroups;
}
Also used : JobDetail(org.quartz.JobDetail) JobDataMap(org.quartz.JobDataMap) Configuration(nl.nn.adapterframework.configuration.Configuration) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) JobDef(nl.nn.adapterframework.scheduler.JobDef) SchedulerException(org.quartz.SchedulerException)

Aggregations

Configuration (nl.nn.adapterframework.configuration.Configuration)31 ArrayList (java.util.ArrayList)12 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)9 IAdapter (nl.nn.adapterframework.core.IAdapter)8 Path (javax.ws.rs.Path)7 Produces (javax.ws.rs.Produces)7 Adapter (nl.nn.adapterframework.core.Adapter)7 HashMap (java.util.HashMap)6 GET (javax.ws.rs.GET)6 Iterator (java.util.Iterator)5 LinkedHashMap (java.util.LinkedHashMap)5 RolesAllowed (javax.annotation.security.RolesAllowed)5 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)4 IbisManager (nl.nn.adapterframework.configuration.IbisManager)4 ReceiverBase (nl.nn.adapterframework.receivers.ReceiverBase)4 IOException (java.io.IOException)3 URL (java.net.URL)3 Date (java.util.Date)3 Transformer (javax.xml.transform.Transformer)3 IReceiver (nl.nn.adapterframework.core.IReceiver)3