commit | author | age
|
63b711
|
1 |
package de.uhilger.avdirektor.handler; |
U |
2 |
|
|
3 |
import com.sun.net.httpserver.HttpExchange; |
|
4 |
import com.sun.net.httpserver.HttpHandler; |
|
5 |
import java.io.IOException; |
|
6 |
import java.io.OutputStream; |
|
7 |
import java.util.Map; |
|
8 |
import java.util.logging.Level; |
|
9 |
import java.util.logging.Logger; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author ulrich |
|
14 |
*/ |
|
15 |
public class SeekHandler extends PlayHandler { |
|
16 |
|
|
17 |
private static final Logger logger = Logger.getLogger(SeekHandler.class.getName()); |
|
18 |
|
|
19 |
public SeekHandler(String cmd) { |
|
20 |
super(cmd); |
|
21 |
} |
|
22 |
|
|
23 |
@Override |
|
24 |
public void handle(HttpExchange t) throws IOException { |
|
25 |
logger.log(Level.FINE, "RequestURI: {0}", t.getRequestURI().toString()); |
|
26 |
|
|
27 |
StringBuilder params = super.buildParams(t); |
|
28 |
params.append(" --pos "); |
|
29 |
params.append(getParam(map, "p")); |
|
30 |
|
|
31 |
String antwort = abspielenMitParameternUndRueckmeldung( |
|
32 |
getParam(map, "titel"), params.toString(), getParam(map, "r"), "1"); |
|
33 |
|
|
34 |
String response = getResponseString(map, "play", antwort); |
|
35 |
t.sendResponseHeaders(200, response.length()); |
|
36 |
OutputStream os = t.getResponseBody(); |
|
37 |
os.write(response.getBytes()); |
|
38 |
os.close(); |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
protected String process(HttpExchange t, String params) { |
|
43 |
String antwort = abspielenMitParameternUndRueckmeldung( |
|
44 |
getParam(map, "titel"), params, getParam(map, "r"), "1"); |
|
45 |
logger.log(Level.FINE, antwort); |
|
46 |
return antwort; |
|
47 |
} |
|
48 |
|
|
49 |
protected StringBuilder buildParams(HttpExchange t) { |
|
50 |
StringBuilder params = super.buildParams(t); |
|
51 |
params.append(" --pos "); |
|
52 |
params.append(getParam(map, "p")); |
|
53 |
return params; |
|
54 |
} |
|
55 |
|
|
56 |
} |