src/de/uhilger/mediaz/api/AbstractHandler.java | ●●●●● patch | view | raw | blame | history | |
src/de/uhilger/mediaz/api/ListHandler.java | ●●●●● patch | view | raw | blame | history | |
www/ui/js/app.js | ●●●●● patch | view | raw | blame | history |
src/de/uhilger/mediaz/api/AbstractHandler.java
@@ -5,7 +5,6 @@ */ package de.uhilger.mediaz.api; import com.google.gson.Gson; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import java.io.BufferedReader; @@ -13,7 +12,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.logging.Level; import java.util.logging.Logger; @@ -71,7 +69,6 @@ } break; } logger.fine(response); e.sendResponseHeaders(code, response.length()); OutputStream os = e.getResponseBody(); os.write(response.getBytes()); @@ -89,7 +86,6 @@ } r.close(); String json = sb.toString(); logger.log(Level.FINE, "json: {0}", json); return json; } src/de/uhilger/mediaz/api/ListHandler.java
@@ -49,10 +49,8 @@ String path = e.getRequestURI().toString(); String[] elems = path.split(App.getRs(Server.RB_SLASH)); String plname = elems[elems.length - 1]; logger.finer("GET plname: " + plname); FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF))); String json = fs.readJson(FileStorage.ST_ABSPIELLISTE, plname); logger.finer("PL json: " + json); return json; } @@ -61,12 +59,8 @@ String path = e.getRequestURI().toString(); String[] elems = path.split(App.getRs(Server.RB_SLASH)); String response = "ListHandler.put: ungueltiger URL"; logger.finer("elems.length: " + elems.length); for(String elem : elems) { logger.finer("elem: " + elem); } switch(elems.length) { case 5: case 5: // ohne nr am Ende response = addTitel(e, elems[4]); break; @@ -78,16 +72,12 @@ } private String addTitel(HttpExchange e, String plname) throws IOException { //String plname = elems[elems.length - 1]; logger.finer("plname: " + plname); FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF))); Entity entity = fs.read(FileStorage.ST_ABSPIELLISTE, plname); String response = "Titel konnte nicht hinzugefuegt werden."; if(entity instanceof Abspielliste) { Abspielliste aliste = (Abspielliste) entity; logger.finer("aliste: " + aliste.getName()); String titelJson = bodyLesen(e); logger.finer("titelJson: " + titelJson); Gson gson = new Gson(); Object o = gson.fromJson(titelJson, fs.typeFromName(Titel.class.getSimpleName()).getType()); if(o instanceof Titel) { www/ui/js/app.js
@@ -168,7 +168,7 @@ var titel = new Titel(self.mediaPfad + titelName, self.ortPfad); var plname = document.querySelector('#playlist').value; self.http_put('../api/alist/' + plname, JSON.stringify(titel), function(responseText) { console.log(responseText); self.meldung_mit_timeout(responseText, 1500); }); };