Resolve "Force formatting"

This commit is contained in:
Andreas Penski 2020-09-03 06:02:42 +00:00
parent bc9acc3a0a
commit 69d6e55f14
45 changed files with 535 additions and 538 deletions

View file

@ -15,7 +15,6 @@ abstract class BaseHandler implements HttpHandler {
protected static final String APPLICATION_XML = "application/xml";
protected static void write(final HttpExchange exchange, final byte[] content, final String contentType) throws IOException {
write(exchange, content, contentType, HttpStatus.SC_OK);
}

View file

@ -37,8 +37,8 @@ class CheckHandler extends BaseHandler {
/**
* Methode, die eine gegebene Anforderung verarbeitet und eine entsprechende Antwort generiert
*
* @param httpExchange kapselt eine empfangene HTTP-Anforderung und eine Antwort, die in einem Exchange generiert werden
* soll.
* @param httpExchange kapselt eine empfangene HTTP-Anforderung und eine Antwort, die in einem Exchange generiert
* werden soll.
*/
@Override
public void handle(final HttpExchange httpExchange) throws IOException {

View file

@ -26,7 +26,7 @@ import de.kosit.validationtool.model.scenarios.Scenarios;
*/
@Slf4j
@RequiredArgsConstructor
class ConfigHandler extends BaseHandler {
class ConfigHandler extends BaseHandler {
private final Configuration configuration;

View file

@ -55,7 +55,6 @@ public class Daemon {
this.threadCount = threadCount;
}
/**
* Methode zum Starten des Servers
*

View file

@ -28,28 +28,27 @@ public class GuiHandler extends BaseHandler {
final String path = exchange.getRequestURI().toASCIIString();
if (path.equals("/")) {
write(exchange, IOUtils.toString(INDEX_HTML, Charset.defaultCharset()).getBytes(), "text/html");
} else{
} 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());
}else {
error(exchange,404,"not found");
} else {
error(exchange, 404, "not found");
}
}
}
@RequiredArgsConstructor
@Getter
protected enum Mediatype {
JS("application/javascript"),
MD("text/markdown"),
CSS("text/css");
JS("application/javascript"), MD("text/markdown"), CSS("text/css");
private final String mimeType;
static Mediatype resolveBySuffix(final String path) {
return Arrays.stream(values()).filter(e->path.toUpperCase().endsWith("."+e.name())).findFirst().orElse(Mediatype.MD);
return Arrays.stream(values()).filter(e -> path.toUpperCase().endsWith("." + e.name())).findFirst().orElse(Mediatype.MD);
}
}
}