Resolve "Validator new feature: Pruefbericht Gesamtuebersicht bei Batch Verarbeitung"

This commit is contained in:
Andreas Penski 2020-08-10 06:38:20 +00:00
parent c781316509
commit e265667f25
31 changed files with 791 additions and 110 deletions

View file

@ -44,6 +44,7 @@ class CheckHandler extends BaseHandler {
try {
log.debug("Incoming request");
final String requestMethod = httpExchange.getRequestMethod();
// check neccessary, since gui can be disabled
if (requestMethod.equals("POST")) {
final InputStream inputStream = httpExchange.getRequestBody();
if (inputStream.available() > 0) {

View file

@ -1,15 +1,17 @@
package de.kosit.validationtool.daemon;
import com.sun.net.httpserver.HttpExchange;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Arrays;
import org.apache.commons.io.IOUtils;
import com.sun.net.httpserver.HttpExchange;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
public class GuiHandler extends BaseHandler {
private static final URL INDEX_HTML = GuiHandler.class.getClassLoader().getResource("gui/index.html");
@ -21,7 +23,7 @@ public class GuiHandler extends BaseHandler {
}
@Override
public void handle(HttpExchange exchange) throws IOException {
public void handle(final HttpExchange exchange) throws IOException {
assert INDEX_HTML != null;
final String path = exchange.getRequestURI().toASCIIString();
if (path.equals("/")) {
@ -29,7 +31,8 @@ public class GuiHandler extends BaseHandler {
} else{
final URL resource = GuiHandler.class.getClassLoader().getResource("gui" + path);
if (resource != null) {
write(exchange,IOUtils.toString(resource, Charset.defaultCharset()).getBytes(), Mediatype.resolveBySuffix(resource.getPath()).getMimeType());;
write(exchange, IOUtils.toString(resource, Charset.defaultCharset()).getBytes(),
Mediatype.resolveBySuffix(resource.getPath()).getMimeType());
}else {
error(exchange,404,"not found");
}
@ -45,7 +48,7 @@ public class GuiHandler extends BaseHandler {
CSS("text/css");
private final String mimeType;
static Mediatype resolveBySuffix(String path){
static Mediatype resolveBySuffix(final String path) {
return Arrays.stream(values()).filter(e->path.toUpperCase().endsWith("."+e.name())).findFirst().orElse(Mediatype.MD);
}
}

View file

@ -4,13 +4,13 @@ import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
import de.kosit.validationtool.impl.EngineInformation;
import de.kosit.validationtool.model.daemon.ApplicationType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import de.kosit.validationtool.api.Configuration;
import de.kosit.validationtool.impl.ConversionService;
import de.kosit.validationtool.impl.EngineInformation;
import de.kosit.validationtool.model.daemon.ApplicationType;
import de.kosit.validationtool.model.daemon.HealthType;
import de.kosit.validationtool.model.daemon.MemoryType;
@ -39,7 +39,7 @@ class HealthHandler extends BaseHandler {
final HealthType h = new HealthType();
h.setMemory(createMemory());
h.setApplication(createApplication());
h.setStatus(scenarios.getScenarios().size() > 0 ? "UP" : "DOWN");
h.setStatus(!this.scenarios.getScenarios().isEmpty() ? "UP" : "DOWN");
return h;
}
@ -53,7 +53,7 @@ class HealthHandler extends BaseHandler {
}
private static ApplicationType createApplication() {
ApplicationType a = new ApplicationType();
final ApplicationType a = new ApplicationType();
a.setBuild(EngineInformation.getBuild());
a.setName(EngineInformation.getName());
a.setVersion(EngineInformation.getVersion());

View file

@ -1,11 +1,11 @@
package de.kosit.validationtool.daemon;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import lombok.RequiredArgsConstructor;
import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
import lombok.RequiredArgsConstructor;
/**
* A simple handler which routes between the {@link CheckHandler} and the {@link GuiHandler} depending on the request.
*/
@ -17,12 +17,12 @@ class RoutingHandler extends BaseHandler {
private final GuiHandler guiHandler;
@Override
public void handle(HttpExchange exchange) throws IOException {
public void handle(final HttpExchange exchange) throws IOException {
final String requestMethod = exchange.getRequestMethod();
if (requestMethod.equals("POST")) {
checkHandler.handle(exchange);
this.checkHandler.handle(exchange);
} else if (requestMethod.equals("GET")) {
guiHandler.handle(exchange);
this.guiHandler.handle(exchange);
} else {
error(exchange, 405, String.format("Method % not supported", requestMethod));
}