Package com.itstherules.mediacentre.controller

Source Code of com.itstherules.mediacentre.controller.ConfigurationController

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");
  }

}
TOP

Related Classes of com.itstherules.mediacentre.controller.ConfigurationController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.