use of nl.nn.adapterframework.configuration.BaseConfigurationWarnings 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.BaseConfigurationWarnings in project iaf by ibissource.
the class ServerStatistics method getServerConfiguration.
@GET
@PermitAll
@Path("/server/warnings")
@Produces(MediaType.APPLICATION_JSON)
public Response getServerConfiguration() throws ApiException {
initBase(servletConfig);
ConfigurationWarnings globalConfigWarnings = ConfigurationWarnings.getInstance();
// (globalConfigWarnings.size() + 1); //Add 1 for ESR
List<Object> warnings = new ArrayList<Object>();
boolean showCountErrorStore = AppConstants.getInstance().getBoolean("errorStore.count.show", true);
List<IAdapter> registeredAdapters = ibisManager.getRegisteredAdapters();
long esr = 0;
if (showCountErrorStore) {
for (Iterator<IAdapter> adapterIt = registeredAdapters.iterator(); adapterIt.hasNext(); ) {
Adapter adapter = (Adapter) adapterIt.next();
for (Iterator<?> receiverIt = adapter.getReceiverIterator(); receiverIt.hasNext(); ) {
ReceiverBase receiver = (ReceiverBase) receiverIt.next();
ITransactionalStorage errorStorage = receiver.getErrorStorage();
if (errorStorage != null) {
try {
esr += errorStorage.getMessageCount();
} catch (Exception e) {
// error("error occured on getting number of errorlog records for adapter ["+adapter.getName()+"]",e);
log.warn("Assuming there are no errorlog records for adapter [" + adapter.getName() + "]");
}
}
}
}
} else {
esr = -1;
}
if (esr != 0) {
Map<String, Object> messageObj = new HashMap<String, Object>(2);
String message;
if (esr == -1) {
message = "Errorlog might contain records. This is unknown because errorStore.count.show is not set to true";
} else if (esr == 1) {
message = "Errorlog contains 1 record. Service management should check whether this record has to be resent or deleted";
} else {
message = "Errorlog contains " + esr + " records. Service Management should check whether these records have to be resent or deleted";
}
messageObj.put("message", message);
messageObj.put("type", "severe");
warnings.add(messageObj);
}
for (Configuration config : ibisManager.getConfigurations()) {
if (config.getConfigurationException() != null) {
Map<String, Object> messageObj = new HashMap<String, Object>(2);
String message = config.getConfigurationException().getMessage();
messageObj.put("message", message);
messageObj.put("type", "exception");
warnings.add(messageObj);
}
}
// Configuration specific warnings
for (Configuration configuration : ibisManager.getConfigurations()) {
BaseConfigurationWarnings configWarns = configuration.getConfigurationWarnings();
for (int j = 0; j < configWarns.size(); j++) {
Map<String, Object> messageObj = new HashMap<String, Object>(1);
messageObj.put("message", configWarns.get(j));
messageObj.put("configuration", configuration.getName());
warnings.add(messageObj);
}
}
// Global warnings
if (globalConfigWarnings.size() > 0) {
for (int j = 0; j < globalConfigWarnings.size(); j++) {
Map<String, Object> messageObj = new HashMap<String, Object>(1);
messageObj.put("message", globalConfigWarnings.get(j));
warnings.add(messageObj);
}
}
return Response.status(Response.Status.CREATED).entity(warnings).build();
}
Aggregations