| | |
| | | * PUT /mz/api/alist/[pl-name] den Titel im Body anfuegen an die Liste [pl-name] |
| | | * PUT /mz/api/alist/[pl-name]/[nr] an der Position nr der Liste [pl-name] den Titel im Body einfuegen |
| | | * DELETE /mz/api/alist/[pl-name]/[nr] den Titel an der Position [nr] aus der Liste [pl-name] entfernen |
| | | * DELETE /mz/api/alist/[pl-name]/alle alle Titel aus der Liste [pl-name] entfernen |
| | | * |
| | | * @author Ulrich Hilger |
| | | * @version 1, 8.4.2021 |
| | |
| | | public class ListHandler extends AbstractHandler { |
| | | |
| | | private static final Logger logger = Logger.getLogger(ListHandler.class.getName()); |
| | | |
| | | public static final String ALLE_TITEL = "alle"; |
| | | |
| | | |
| | | @Override |
| | |
| | | protected boolean delete(HttpExchange e) { |
| | | String path = e.getRequestURI().toString(); |
| | | String[] elems = path.split(Server.SLASH); |
| | | String plname = elems[elems.length - 2]; |
| | | String listName = elems[elems.length - 3]; |
| | | |
| | | 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])); |
| | | String titelStr = elems[elems.length-1]; |
| | | if(titelStr.equalsIgnoreCase(ALLE_TITEL)) { |
| | | liste.getTitel().clear(); |
| | | } else { |
| | | liste.getTitel().remove(Integer.parseInt(elems[elems.length-1])); |
| | | } |
| | | fs.write(liste, true); |
| | | return true; |
| | | } else { |