package com.itstherules.mediacentre.controller;
import java.io.IOException;
import java.io.Writer;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.itstherules.mediacentre.model.HostScalar;
public class ConfigurationController extends BaseController {
@Override
public void edit(Map<String, Object> parameters, HttpServletResponse response) throws IOException {
Writer writer = response.getWriter();
setIfNotSet(parameters, "updated", "false");
merge("configuration/edit.freemarker", parameters, writer);
}
private void setIfNotSet(Map<String, Object> parameters, String key, String value) {
if(!parameters.containsKey(key)){parameters.put(key, value);}
}
@Override
public void update(Map<String, Object> parameters, HttpServletResponse response) throws IOException {
String hostName = (String) parameters.get("dynDnsHostName");
new HostScalar().persist(hostName);
response.sendRedirect("../edit/index.html?updated=true");
}
}