| | |
| | | import com.sun.net.httpserver.Headers; |
| | | import com.sun.net.httpserver.HttpExchange; |
| | | import com.sun.net.httpserver.HttpHandler; |
| | | import de.uhilger.tango.App; |
| | | import de.uhilger.tango.entity.Einstellung; |
| | | import de.uhilger.tango.entity.Entity; |
| | | import de.uhilger.tango.store.Storage; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.io.OutputStream; |
| | | import java.util.ResourceBundle; |
| | | import java.util.logging.Logger; |
| | | |
| | | |
| | |
| | | public static final int RTC_NOT_FOUND = 404; |
| | | |
| | | protected int returnCode; |
| | | |
| | | private ResourceBundle rb; |
| | | |
| | | public AbstractHandler() { |
| | | this.returnCode = RTC_OK; |
| | |
| | | return "nicht unterstuetzt"; |
| | | } |
| | | |
| | | protected String post(HttpExchange e) { |
| | | protected String post(HttpExchange e) throws IOException { |
| | | setReturnCode(RTC_NOT_FOUND); |
| | | return "nicht unterstuetzt"; |
| | | } |
| | |
| | | protected abstract boolean delete(HttpExchange e); |
| | | */ |
| | | |
| | | protected String getResString(String key) { |
| | | if(rb == null) { |
| | | rb = ResourceBundle.getBundle(App.RB_NAME); |
| | | } |
| | | return rb.getString(key); |
| | | } |
| | | |
| | | protected String getEinstellung(Storage s, String key, String standardWert) { |
| | | Entity entity = s.read(Einstellung.class.getSimpleName(), key); |
| | | if (entity instanceof Einstellung) { |
| | | Einstellung einstellung = (Einstellung) entity; |
| | | Object o = einstellung.getValue(); |
| | | if(o instanceof String) { |
| | | return o.toString(); |
| | | } else { |
| | | return standardWert; |
| | | } |
| | | } else { |
| | | return standardWert; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |