use of nl.nn.adapterframework.configuration.ApplicationWarnings in project iaf by ibissource.
the class ServerStatistics method getServerConfiguration.
@GET
@PermitAll
@Path("/server/warnings")
@Produces(MediaType.APPLICATION_JSON)
public Response getServerConfiguration() throws ApiException {
Map<String, Object> returnMap = new HashMap<String, Object>();
ApplicationWarnings globalConfigWarnings = getIbisContext().getBean("applicationWarnings", ApplicationWarnings.class);
MessageEventListener eventListener = getIbisContext().getBean("MessageEventListener", MessageEventListener.class);
long totalErrorStoreCount = 0;
boolean showCountErrorStore = AppConstants.getInstance().getBoolean("errorStore.count.show", true);
if (!showCountErrorStore)
totalErrorStoreCount = -1;
for (Configuration configuration : getIbisManager().getConfigurations()) {
Map<String, Object> configurationsMap = new HashMap<String, Object>();
// Configuration specific exceptions
if (configuration.getConfigurationException() != null) {
String message = configuration.getConfigurationException().getMessage();
configurationsMap.put("exception", message);
}
if (configuration.isActive()) {
// ErrorStore count
if (showCountErrorStore) {
long esr = 0;
for (Adapter adapter : configuration.getRegisteredAdapters()) {
for (Receiver<?> receiver : adapter.getReceivers()) {
IMessageBrowser<?> errorStorage = receiver.getMessageBrowser(ProcessState.ERROR);
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() + "]");
}
}
}
}
totalErrorStoreCount += esr;
configurationsMap.put("errorStoreCount", esr);
}
// Configuration specific warnings
ConfigurationWarnings configWarns = configuration.getConfigurationWarnings();
if (configWarns != null && configWarns.size() > 0) {
configurationsMap.put("warnings", configWarns.getWarnings());
}
// Configuration specific messages
MessageKeeper messageKeeper = eventListener.getMessageKeeper(configuration.getName());
if (messageKeeper != null) {
List<Object> messages = mapMessageKeeperMessages(messageKeeper);
if (!messages.isEmpty()) {
configurationsMap.put("messages", messages);
}
}
}
returnMap.put(configuration.getName(), configurationsMap);
}
// Total ErrorStore Count
returnMap.put("totalErrorStoreCount", totalErrorStoreCount);
// Global warnings
if (globalConfigWarnings.size() > 0) {
List<Object> warnings = new ArrayList<>();
for (int j = 0; j < globalConfigWarnings.size(); j++) {
warnings.add(globalConfigWarnings.get(j));
}
returnMap.put("warnings", warnings);
}
// Global messages
MessageKeeper messageKeeper = eventListener.getMessageKeeper();
List<Object> messages = mapMessageKeeperMessages(messageKeeper);
if (!messages.isEmpty()) {
returnMap.put("messages", messages);
}
Response.ResponseBuilder response = null;
// Calculate the ETag on last modified date of user resource
EntityTag etag = new EntityTag(returnMap.hashCode() + "");
// Verify if it matched with etag available in http request
response = rsRequest.evaluatePreconditions(etag);
// If ETag matches the response will be non-null;
if (response != null) {
return response.tag(etag).build();
}
response = Response.status(Response.Status.OK).entity(returnMap).tag(etag);
return response.build();
}
Aggregations