Persoenliche Mediazentrale
ulrich
2021-04-10 5898509f4ca658690c4d4bc0e1784a8ecbff4178
src/de/uhilger/mediaz/api/ListHandler.java
@@ -47,17 +47,17 @@
  @Override
  protected String get(HttpExchange e) {
    String path = e.getRequestURI().toString();
    String[] elems = path.split(App.getRs(Server.RB_SLASH));
    String[] elems = path.split(Server.SLASH);
    String plname = elems[elems.length - 1];
    FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF)));
    String json = fs.readJson(FileStorage.ST_ABSPIELLISTE, plname);
    return json;
    return embedInCustomType(json, FileStorage.ST_ABSPIELLISTE);
  }
  @Override
  protected String put(HttpExchange e) throws IOException {
    String path = e.getRequestURI().toString();
    String[] elems = path.split(App.getRs(Server.RB_SLASH));
    String[] elems = path.split(Server.SLASH);
    String response = "ListHandler.put: ungueltiger URL";
    switch(elems.length) {
      case 5: // ohne nr am Ende
@@ -95,9 +95,23 @@
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  }
  // DELETE /mz/api/alist/[pl-name]/[nr]  den Titel an der Position [nr] aus der Liste [pl-name] entfernen
  @Override
  protected boolean delete(HttpExchange e) {
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    String path = e.getRequestURI().toString();
    String[] elems = path.split(Server.SLASH);
    String listName = elems[elems.length - 2];
    FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF)));
    Entity entity = fs.read(Abspielliste.class.getSimpleName(), listName);
    if(entity instanceof Abspielliste) {
      Abspielliste liste = (Abspielliste) entity;
      liste.getTitel().remove(Integer.parseInt(elems[elems.length-1]));
      fs.write(liste, true);
      return true;
    } else {
      return false;
    }
  }
  
}