use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ShowConfigurationStatus method toConfigurationWarningsXml.
private XmlBuilder toConfigurationWarningsXml(List<Configuration> configurations, Configuration configurationSelected) {
ConfigurationWarnings globalConfigurationWarnings = ConfigurationWarnings.getInstance();
List<ErrorStoreCounter> errorStoreCounters = retrieveErrorStoreCounters(configurations, configurationSelected);
List<String[]> selectedConfigurationWarnings = new ArrayList<String[]>();
if (configurationSelected != null) {
BaseConfigurationWarnings configWarns = configurationSelected.getConfigurationWarnings();
for (int j = 0; j < configWarns.size(); j++) {
String[] item = new String[2];
item[0] = configurationSelected.getName();
item[1] = (String) configWarns.get(j);
selectedConfigurationWarnings.add(item);
}
} else {
for (Configuration configuration : configurations) {
BaseConfigurationWarnings configWarns = configuration.getConfigurationWarnings();
for (int j = 0; j < configWarns.size(); j++) {
String[] item = new String[2];
item[0] = configuration.getName();
item[1] = (String) configWarns.get(j);
selectedConfigurationWarnings.add(item);
}
}
}
if (!globalConfigurationWarnings.isEmpty() || !errorStoreCounters.isEmpty() || !SHOW_COUNT_ERRORSTORE || !selectedConfigurationWarnings.isEmpty()) {
XmlBuilder warningsXML = new XmlBuilder("warnings");
if (!SHOW_COUNT_ERRORSTORE) {
XmlBuilder warningXML = new XmlBuilder("warning");
warningXML.setValue("Errorlog might contain records. This is unknown because errorStore.count.show is not set to true");
warningXML.addAttribute("severe", true);
warningsXML.addSubElement(warningXML);
}
for (int j = 0; j < errorStoreCounters.size(); j++) {
ErrorStoreCounter esr = errorStoreCounters.get(j);
XmlBuilder warningXML = new XmlBuilder("warning");
warningXML.addAttribute("config", esr.config);
if (esr.counter == 1) {
warningXML.setValue("Errorlog contains 1 record. Service management should check whether this record has to be resent or deleted");
} else {
warningXML.setValue("Errorlog contains " + esr.counter + " records. Service Management should check whether these records have to be resent or deleted");
}
warningXML.addAttribute("severe", true);
warningsXML.addSubElement(warningXML);
}
for (int j = 0; j < globalConfigurationWarnings.size(); j++) {
XmlBuilder warningXML = new XmlBuilder("warning");
warningXML.setValue((String) globalConfigurationWarnings.get(j));
warningsXML.addSubElement(warningXML);
}
for (int j = 0; j < selectedConfigurationWarnings.size(); j++) {
XmlBuilder warningXML = new XmlBuilder("warning");
warningXML.addAttribute("config", selectedConfigurationWarnings.get(j)[0]);
warningXML.setValue((String) selectedConfigurationWarnings.get(j)[1]);
warningsXML.addSubElement(warningXML);
}
return warningsXML;
}
return null;
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ServerStatistics method getServerInformation.
@GET
@PermitAll
@Path("/server/info")
@Produces(MediaType.APPLICATION_JSON)
public Response getServerInformation() throws ApiException {
Map<String, Object> returnMap = new HashMap<String, Object>();
List<Object> configurations = new ArrayList<Object>();
initBase(servletConfig);
for (Configuration configuration : ibisManager.getConfigurations()) {
Map<String, Object> cfg = new HashMap<String, Object>();
cfg.put("name", configuration.getName());
cfg.put("version", configuration.getVersion());
cfg.put("type", configuration.getClassLoaderType());
ClassLoader classLoader = configuration.getClassLoader().getParent();
if (classLoader instanceof DatabaseClassLoader) {
cfg.put("filename", ((DatabaseClassLoader) classLoader).getFileName());
cfg.put("created", ((DatabaseClassLoader) classLoader).getCreationDate());
cfg.put("user", ((DatabaseClassLoader) classLoader).getUser());
}
configurations.add(cfg);
}
returnMap.put("configurations", configurations);
returnMap.put("version", ibisContext.getFrameworkVersion());
returnMap.put("name", ibisContext.getApplicationName());
returnMap.put("applicationServer", servletConfig.getServletContext().getServerInfo());
returnMap.put("javaVersion", System.getProperty("java.runtime.name") + " (" + System.getProperty("java.runtime.version") + ")");
Map<String, Object> fileSystem = new HashMap<String, Object>(2);
fileSystem.put("totalSpace", Misc.getFileSystemTotalSpace());
fileSystem.put("freeSpace", Misc.getFileSystemFreeSpace());
returnMap.put("fileSystem", fileSystem);
returnMap.put("processMetrics", ProcessMetrics.toMap());
Date date = new Date();
returnMap.put("serverTime", date.getTime());
returnMap.put("machineName", Misc.getHostname());
returnMap.put("uptime", ibisContext.getUptimeDate());
return Response.status(Response.Status.CREATED).entity(returnMap).build();
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ShowEnvironmentVariables method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Initialize action
initAction(request);
if (ibisManager == null)
return (mapping.findForward("noIbisContext"));
DynaActionForm configurationPropertiesForm = getPersistentForm(mapping, form, request);
Logger rl = LogUtil.getRootLogger();
configurationPropertiesForm.set("logLevel", rl.getLevel().toString());
configurationPropertiesForm.set("logIntermediaryResults", new Boolean(false));
if (AppConstants.getInstance().getResolvedProperty("log.logIntermediaryResults") != null) {
if (AppConstants.getInstance().getResolvedProperty("log.logIntermediaryResults").equalsIgnoreCase("true")) {
configurationPropertiesForm.set("logIntermediaryResults", new Boolean(true));
}
}
Appender appender = rl.getAppender("appwrap");
if (appender != null && appender instanceof IbisAppenderWrapper) {
IbisAppenderWrapper iaw = (IbisAppenderWrapper) appender;
configurationPropertiesForm.set("lengthLogRecords", iaw.getMaxMessageLength());
} else {
configurationPropertiesForm.set("lengthLogRecords", -1);
}
// Retrieve environment variables for browsing
XmlBuilder configurationsXml = new XmlBuilder("configurations");
List<Configuration> configurations = ibisManager.getConfigurations();
for (Configuration configuration : configurations) {
XmlBuilder configurationXml = new XmlBuilder("configuration");
configurationXml.setValue(configuration.getConfigurationName());
configurationXml.addAttribute("nameUC", Misc.toSortName(configuration.getConfigurationName()));
configurationsXml.addSubElement(configurationXml);
}
request.setAttribute("configurations", configurationsXml.toXML());
Configuration configuration;
String configurationName = request.getParameter("configuration");
if (configurationName == null) {
configurationName = (String) request.getSession().getAttribute("configurationName");
}
if (configurationName == null || configurationName.equalsIgnoreCase(CONFIG_ALL) || ibisManager.getConfiguration(configurationName) == null) {
configuration = configurations.get(0);
request.getSession().setAttribute("configurationName", configuration.getName());
} else {
configuration = ibisManager.getConfiguration(configurationName);
request.getSession().setAttribute("configurationName", configuration.getName());
}
List<String> propsToHide = new ArrayList<String>();
String propertiesHideString = AppConstants.getInstance(configuration.getClassLoader()).getString("properties.hide", null);
if (propertiesHideString != null) {
propsToHide.addAll(Arrays.asList(propertiesHideString.split("[,\\s]+")));
}
XmlBuilder envVars = new XmlBuilder("environmentVariables");
addPropertiesToXmlBuilder(envVars, AppConstants.getInstance(configuration.getClassLoader()), "Application Constants", propsToHide, true);
addPropertiesToXmlBuilder(envVars, System.getProperties(), "System Properties", propsToHide);
try {
addPropertiesToXmlBuilder(envVars, Misc.getEnvironmentVariables(), "Environment Variables");
} catch (Throwable t) {
log.warn("caught Throwable while getting EnvironmentVariables", t);
}
addPropertiesToXmlBuilder(envVars, JdbcUtil.retrieveJdbcPropertiesFromDatabase(), "Jdbc Properties", propsToHide);
request.setAttribute("envVars", envVars.toXML());
// Forward control to the specified success URI
log.debug("forward to success");
return (mapping.findForward("success"));
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class WsdlTest method mockPipeLine.
protected PipeLine mockPipeLine(IPipe inputValidator, IPipe outputValidator, String targetNamespace, String adapterName) {
PipeLine simple = mock(PipeLine.class);
when(simple.getInputValidator()).thenReturn(inputValidator);
when(simple.getOutputValidator()).thenReturn(outputValidator);
Adapter adp = mock(Adapter.class);
when(simple.getAdapter()).thenReturn(adp);
Configuration cfg = mock(Configuration.class);
when(simple.getAdapter().getConfiguration()).thenReturn(cfg);
final ReceiverBase receiverBase = mock(ReceiverBase.class);
WebServiceListener listener = new WebServiceListener();
listener.setServiceNamespaceURI(targetNamespace);
when(receiverBase.getListener()).thenReturn(listener);
when(adp.getReceiverIterator()).thenAnswer(new Answer<Iterator>() {
public Iterator answer(InvocationOnMock invocation) throws Throwable {
return Arrays.asList(receiverBase).iterator();
}
});
when(adp.getName()).thenReturn(adapterName);
return simple;
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class WsdlGeneratorPipe method doPipe.
@Override
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
InputStream inputStream = (InputStream) session.get("file");
if (inputStream == null) {
throw new PipeRunException(this, getLogPrefix(session) + "got null value from session under key [" + getSessionKey() + "]");
}
File tempDir;
String fileName;
try {
tempDir = FileUtils.createTempDir(null, "WEB-INF" + File.separator + "classes");
fileName = (String) session.get("fileName");
if (FileUtils.extensionEqualsIgnoreCase(fileName, "zip")) {
FileUtils.unzipStream(inputStream, tempDir);
} else {
File file = new File(tempDir, fileName);
Misc.streamToFile(inputStream, file);
file.deleteOnExit();
}
} catch (IOException e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on uploading and unzipping/writing file", e);
}
File propertiesFile = new File(tempDir, getPropertiesFileName());
PipeLine pipeLine;
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
DirectoryClassLoader directoryClassLoader = new DirectoryClassLoader(tempDir.getPath());
Thread.currentThread().setContextClassLoader(directoryClassLoader);
if (propertiesFile.exists()) {
pipeLine = createPipeLineFromPropertiesFile(propertiesFile);
} else {
File xsdFile = FileUtils.getFirstFile(tempDir);
pipeLine = createPipeLineFromXsdFile(xsdFile);
}
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on generating wsdl", e);
} finally {
if (originalClassLoader != null) {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
}
Object result = null;
OutputStream zipOut = null;
OutputStream fullWsdlOut = null;
try {
Adapter adapter = new Adapter();
adapter.setConfiguration(new Configuration(null));
String fileBaseName = FileUtils.getBaseName(fileName).replaceAll(" ", "_");
adapter.setName(fileBaseName);
GenericReceiver genericReceiver = new GenericReceiver();
EsbJmsListener esbJmsListener = new EsbJmsListener();
esbJmsListener.setQueueConnectionFactoryName("jms/qcf_" + fileBaseName);
esbJmsListener.setDestinationName("jms/dest_" + fileBaseName);
genericReceiver.setListener(esbJmsListener);
adapter.registerReceiver(genericReceiver);
pipeLine.setAdapter(adapter);
Wsdl wsdl = null;
wsdl = new Wsdl(pipeLine);
wsdl.setIndent(true);
wsdl.setDocumentation(getWsdlDocumentation(wsdl.getFilename()));
wsdl.init();
File wsdlDir = FileUtils.createTempDir(tempDir);
// zip (with includes)
File zipOutFile = new File(wsdlDir, wsdl.getFilename() + ".zip");
zipOutFile.deleteOnExit();
zipOut = new FileOutputStream(zipOutFile);
wsdl.setUseIncludes(true);
wsdl.zip(zipOut, null);
// full wsdl (without includes)
File fullWsdlOutFile = new File(wsdlDir, wsdl.getFilename() + ".wsdl");
fullWsdlOutFile.deleteOnExit();
fullWsdlOut = new FileOutputStream(fullWsdlOutFile);
wsdl.setUseIncludes(false);
wsdl.wsdl(fullWsdlOut, null);
Dir2Xml dx = new Dir2Xml();
dx.setPath(wsdlDir.getPath());
result = dx.getDirList();
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on generating wsdl", e);
} finally {
try {
if (zipOut != null) {
zipOut.close();
}
if (fullWsdlOut != null) {
fullWsdlOut.close();
}
} catch (IOException e1) {
log.warn("exception closing outputstream", e1);
}
}
return new PipeRunResult(getForward(), result);
}
Aggregations