| | |
| | | package de.uhilger.avdirektor.handler; |
| | | |
| | | import com.sun.net.httpserver.HttpExchange; |
| | | import de.uhilger.avdirektor.App; |
| | | import de.uhilger.avdirektor.MeldeThread; |
| | | import de.uhilger.avdirektor.ProzessLauscher; |
| | |
| | | import java.io.Writer; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | |
| | | * @param token |
| | | * @return Antwort des Servers |
| | | */ |
| | | /* |
| | | public String abspielen(String urlStr, String token) { |
| | | return abspielenMitParametern(urlStr, null, token); |
| | | } |
| | | */ |
| | | |
| | | /* |
| | | public String abspielenMitRueckmeldung(String urlStr, String meldeUrlStr, String token) { |
| | | return abspielenMitParameternUndRueckmeldung(urlStr, null, meldeUrlStr, token); |
| | | } |
| | | */ |
| | | |
| | | /** |
| | | * Einen Prozess zum Abspielen mit dem omxplayer starten |
| | |
| | | * @param token |
| | | * @return Antwort des Servers |
| | | */ |
| | | /* |
| | | public String abspielenMitParametern(String urlStr, String parameter, String token) { |
| | | return abspielenMitParameternUndRueckmeldung(urlStr, parameter, null, token); |
| | | } |
| | | */ |
| | | |
| | | public String abspielenMitParameternUndRueckmeldung(String urlStr, String parameter, String meldeUrlStr, String token) { |
| | | public String abspielen(String urlStr, String parameter, String meldeUrlStr, String token) { |
| | | String antwort;// = null; |
| | | try { |
| | | //Object o = t.getAttribute(App.PI_PLAYER); |
| | |
| | | return antwort; |
| | | } |
| | | |
| | | /* --- --- */ |
| | | |
| | | protected String getParam(Map map, String key) { |
| | | Object o = map.get(key); |
| | | if(o != null) { |
| | | return o.toString(); |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /* |
| | | Den Query-Teil einer URL in die Parameter zerlegen |
| | | */ |
| | | protected Map getQueryMap(HttpExchange t) { |
| | | HashMap map = new HashMap(); |
| | | String query = t.getRequestURI().getQuery(); |
| | | if(query != null && query.length() > 0) { |
| | | String qParts[] = query.split("&"); |
| | | for(String qPart : qParts) { |
| | | logger.finer("qPart: " + qPart); |
| | | String pParts[] = qPart.split("="); |
| | | map.put(pParts[0], pParts[1]); |
| | | logger.finer("pParts[0]: " + pParts[0] + ", pParts[1]: " + pParts[1]); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | protected String getResponseString(Map map, String cmd, String antwort) { |
| | | Set keys = map.keySet(); |
| | | StringBuilder buf = new StringBuilder(); |
| | | buf.append(cmd); |
| | | buf.append(System.lineSeparator()); |
| | | keys.forEach((Object key) -> { |
| | | buf.append("key: "); |
| | | buf.append(key); |
| | | buf.append(System.lineSeparator()); |
| | | buf.append("value: "); |
| | | buf.append(map.get(key)); |
| | | buf.append(System.lineSeparator()); |
| | | //logger.log(Level.FINE, "key {0} value {1}", new Object[]{key, map.get(key)}); |
| | | }); |
| | | buf.append(antwort); |
| | | return buf.toString(); |
| | | } |
| | | |
| | | /* ------ Implementierung ProzessLauscher ----------------- */ |
| | | |
| | | @Override |