| | |
| | | import de.uhilger.mediaz.api.AblageTestHandler; |
| | | import de.uhilger.mediaz.api.FileHandler; |
| | | import de.uhilger.mediaz.api.StopServerHandler; |
| | | import de.uhilger.mediaz.api.StoreHandler; |
| | | import de.uhilger.mediaz.api.StorageHandler; |
| | | import de.uhilger.mediaz.api.StoreTestHandler; |
| | | import de.uhilger.mediaz.conf.Store; |
| | | import de.uhilger.mediaz.store.FileStorage; |
| | | import de.uhilger.mediaz.entity.Ablageort; |
| | | import de.uhilger.mediaz.entity.ConfigurationElement; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.logging.Logger; |
| | | import java.net.InetSocketAddress; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.logging.Level; |
| | | import de.uhilger.mediaz.entity.Entity; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Die Klasse Server stellt Methoden zur Ausführung eines HTTP-Servers |
| | |
| | | server.createContext(ctx + App.getRs(RB_WEBROOT), |
| | | new FileHandler(wwwDir.getAbsolutePath())); |
| | | ablageorteEinklinken(server); |
| | | server.createContext(ctx + App.getRs(RB_STORE), new StoreHandler()); |
| | | server.createContext(ctx + App.getRs(RB_STORE), new StorageHandler()); |
| | | //server.createContext(ctx + App.getRs(RB_UI_ROOT), new FileHandler(uiDir.getAbsolutePath())); |
| | | server.createContext(ctx + App.getRs(RB_STOP_SERVER), new StopServerHandler()); |
| | | server.createContext(ctx + App.getRs(RB_ABLAGE_TEST), new AblageTestHandler()); |
| | |
| | | } |
| | | |
| | | private void ablageorteEinklinken(HttpServer server) throws ClassNotFoundException, IOException { |
| | | Store store = new Store(); |
| | | String typ = Ablageort.class.getSimpleName(); |
| | | FileStorage store = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF))); |
| | | List<String> orte = store.list(typ); |
| | | Iterator<String> i = orte.iterator(); |
| | | while(i.hasNext()) { |
| | | String ortName = i.next(); |
| | | Entity e = store.read(typ, ortName); |
| | | if(e instanceof Ablageort) { |
| | | Ablageort ort = (Ablageort) e; |
| | | Ablageort ablageort = (Ablageort) e; |
| | | server.createContext(ctx + ablageort.getUrl(), |
| | | new FileHandler(new File(ablageort.getOrt()).getAbsolutePath())); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | String conf = App.getInitParameter(App.getRs(App.RB_AP_CONF)); |
| | | File ablageortDir = new File(conf, Ablageort.class.getSimpleName()); |
| | | File[] orte = ablageortDir.listFiles(); |
| | | if (orte != null) { |
| | | for (File ort : orte) { |
| | | ConfigurationElement elem = store.readFromFile(ort); |
| | | Entity elem = store.readFromFile(ort); |
| | | if (elem instanceof Ablageort) { |
| | | Ablageort ablageort = (Ablageort) elem; |
| | | server.createContext(ctx + ablageort.getUrl(), |
| | |
| | | } |
| | | } |
| | | } |
| | | */ |
| | | } |
| | | |
| | | } |