/*
|
* To change this license header, choose License Headers in Project Properties.
|
* To change this template file, choose Tools | Templates
|
* and open the template in the editor.
|
*/
|
package de.uhilger.mediaz.api;
|
|
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpHandler;
|
import de.uhilger.mediaz.conf.Store;
|
import de.uhilger.mediaz.entity.Ablageort;
|
import de.uhilger.mediaz.entity.ConfigurationElement;
|
import java.io.File;
|
import java.io.IOException;
|
import java.io.OutputStream;
|
import java.util.logging.Level;
|
import java.util.logging.Logger;
|
|
/**
|
*
|
* @author ulrich
|
*/
|
public class StoreTestHandler implements HttpHandler {
|
|
private static final Logger logger = Logger.getLogger(StoreTestHandler.class.getName());
|
|
|
@Override
|
public void handle(HttpExchange e) throws IOException {
|
Ablageort ort = new Ablageort();
|
ort.setName("Katalog");
|
ort.setOrt("/home/ulrich/Videos");
|
Store store = new Store();
|
File file = store.writeToFile(ort);
|
try {
|
ConfigurationElement elem = store.readFromFile(file);
|
logger.log(Level.INFO, "Typ: {0}, Name: {1}",
|
new Object[]{elem.getClass().getSimpleName(), elem.getName()});
|
} catch (ClassNotFoundException ex) {
|
logger.log(Level.SEVERE, null, ex);
|
}
|
|
String response = "OK";
|
e.sendResponseHeaders(200, response.length());
|
OutputStream os = e.getResponseBody();
|
os.write(response.getBytes());
|
os.close();
|
|
}
|
|
}
|