gt:         Exporter exporter = getICalDBExporter();
context: /** 
   * software for projectmanagement and documentation
   * 
   * @FeatureDomain                Collaboration 
   * @author                       Michael Schreiner <michael.schreiner@your-it-fellow.de>
   * @category                     collaboration
   * @copyright                    Copyright (c) 2014, Michael Schreiner
   * @license                      http://mozilla.org/MPL/2.0/ Mozilla Public License 2.0
   *
   * This Source Code Form is subject to the terms of the Mozilla Public
   * License, v. 2.0. If a copy of the MPL was not distributed with this
   * file, You can obtain one at http://mozilla.org/MPL/2.0/.
   */
  package de.yaio.app.server.controller;
  
  import de.yaio.app.config.ContextHelper;
  import de.yaio.app.config.YaioConfiguration;
  import de.yaio.app.core.dbservice.BaseNodeRepository;
  import de.yaio.app.core.node.BaseNode;
  import de.yaio.app.datatransfer.common.ConverterException;
  import de.yaio.app.datatransfer.exporter.EmptyOutputOptionsImpl;
  import de.yaio.app.datatransfer.exporter.Exporter;
  import de.yaio.app.datatransfer.exporter.OutputOptions;
  import de.yaio.app.datatransfer.exporter.OutputOptionsImpl;
  import de.yaio.app.datatransfer.json.JSONFullExporter;
  import de.yaio.app.extension.datatransfer.csv.CSVExporter;
  import de.yaio.app.extension.datatransfer.excel.ExcelExporter;
  import de.yaio.app.extension.datatransfer.excel.ExcelOutputOptions;
  import de.yaio.app.extension.datatransfer.ical.ICalDBExporter;
  import de.yaio.app.extension.datatransfer.mindmap.MindMapExporter;
  import de.yaio.app.extension.datatransfer.ppl.PPLExporter;
  import de.yaio.app.extension.datatransfer.wiki.WikiExporter;
  import org.apache.log4j.Logger;
  import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.ApplicationContext;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.*;
  
  import javax.servlet.ServletOutputStream;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import java.io.IOException;
  import java.util.Map;
  
  import static org.apache.http.HttpStatus.SC_BAD_REQUEST;
  import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR;
  
  /** 
   * controller with Download-Services to export BaseNodes in different 
   * formats (wiki, excel..)
   *  
   * @author                       Michael Schreiner <michael.schreiner@your-it-fellow.de>
   */
  @Controller
  @RequestMapping("/exports")
  public class ExportController {
      
      /** API-Version **/
      public static final String API_VERSION = "1.0.0";
  
      @Autowired
      protected ConverterUtils converterUtils;
  
      @Autowired
      protected BaseNodeRepository baseNodeDBService;
  
      @Autowired
      private ApplicationContext appContext;
  
      // Logger
      private static final Logger LOGGER = Logger.getLogger(ExportController.class);
  
      /** 
       * Request to read the node for sysUID and return it in wiki-format with all children<br>
       * use the settings of the default-output-options
       * @param sysUID                 sysUID to export
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - wiki-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = RequestMethod.GET, 
                      value = "/wiki/{sysUID}", 
                      produces = "application/wiki")
      public String exportNodeAsWiki(@PathVariable(value = "sysUID") final String sysUID, 
                                     final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = new WikiExporter();
          OutputOptions oOptions = new OutputOptionsImpl();
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".wiki", response);
      }
  
      /** 
       * Request to read the node for sysUID and return it in wiki-format with all children<br>
       * use the setting of the output-options from request<br>
       * requires an post-form application/x-www-form-urlencoded
       * @param sysUID                 sysUID to export
       * @param oOptions               the outputOptions 
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - wiki-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = {RequestMethod.POST}, 
                      value = "/wikiuseoptions/{sysUID}", 
                      produces = "application/wiki",
                      consumes = "application/x-www-form-urlencoded")
      public String exportNodeAsWiki(@PathVariable(value = "sysUID") final String sysUID,
                                     @ModelAttribute final EmptyOutputOptionsImpl oOptions,
                                     final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = new WikiExporter();
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".wiki", response);
      }
  
      /** 
       * Request to read the node for sysUID and return it in mindmap-format with all children
       * @param sysUID                 sysUID to export
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - mindmap-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = RequestMethod.GET, 
                      value = "/mindmap/{sysUID}", 
                      produces = "application/mindmap")
      public String exportNodeAsMindMap(@PathVariable(value = "sysUID") final String sysUID, 
                                        final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = new MindMapExporter();
          OutputOptions oOptions = new OutputOptionsImpl();
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".mm", response);
      }
      /** 
       * Request to read the node for sysUID and return it in mindmap-format with all children<br>
       * use the setting of the output-options from request<br>
       * requires an post-form application/x-www-form-urlencoded
       * @param sysUID                 sysUID to export
       * @param oOptions               the outputOptions 
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - mindmap-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = {RequestMethod.POST}, 
                      value = "/mindmapuseoptions/{sysUID}", 
                      produces = "application/mindmap",
                      consumes = "application/x-www-form-urlencoded")
      public String exportNodeAsMindMap(@PathVariable(value = "sysUID") final String sysUID,
                                        @ModelAttribute final EmptyOutputOptionsImpl oOptions,
                                        final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = new MindMapExporter();
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".mm", response);
      }
  
      /** 
       * Request to read the node for sysUID and return it in csv-format with all children
       * @param sysUID                 sysUID to export
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - csv-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = RequestMethod.GET, 
                      value = "/csv/{sysUID}", 
                      produces = "application/csv")
      public String exportNodeAsCsv(@PathVariable(value = "sysUID") final String sysUID, 
                                    final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = new CSVExporter();
          OutputOptions oOptions = new OutputOptionsImpl();
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".csv", response);
      }
      
      /** 
       * Request to read the node for sysUID and return it in csv-format with all children<br>
       * use the setting of the output-options from request<br>
       * requires an post-form application/x-www-form-urlencoded
       * @param sysUID                 sysUID to export
       * @param oOptions               the outputOptions 
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - csv-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = {RequestMethod.POST}, 
                      value = "/csvuseoptions/{sysUID}", 
                      produces = "application/csv",
                      consumes = "application/x-www-form-urlencoded")
      public String exportNodeAsCsv(@PathVariable(value = "sysUID") final String sysUID,
                                    @ModelAttribute final EmptyOutputOptionsImpl oOptions,
                                    final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = new CSVExporter();
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".csv", response);
      }
  
      /** 
       * Request to read the node for sysUID and return it in json-format with all children
       * @param sysUID                 sysUID to export
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - csv-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = RequestMethod.GET, 
                      value = "/json/{sysUID}", 
                      produces = "application/json")
      public String exportNodeAsJson(@PathVariable(value = "sysUID") final String sysUID, 
                                    final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = new JSONFullExporter();
          OutputOptions oOptions = new OutputOptionsImpl();
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".json", response);
      }
      
      /** 
       * Request to read the node for sysUID and return it in ppl-format with all children
       * @param sysUID                 sysUID to export
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - ppl-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = RequestMethod.GET, 
                      value = "/ppl/{sysUID}", 
                      produces = "application/ppl")
      public String exportNodeAsPpl(@PathVariable(value = "sysUID") final String sysUID, 
                                    final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = new PPLExporter();
          OutputOptions oOptions = new OutputOptionsImpl();
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".ppl", response);
      }
  
      /** 
       * Request to read the node for sysUID and return it in ppl-format with all children<br>
       * use the setting of the output-options from request<br>
       * requires an post-form application/x-www-form-urlencoded
       * @param sysUID                 sysUID to export
       * @param oOptions               the outputOptions 
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - ppl-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = {RequestMethod.POST}, 
                      value = "/ppluseoptions/{sysUID}", 
                      produces = "application/ppl",
                      consumes = "application/x-www-form-urlencoded")
      public String exportNodeAsPpl(@PathVariable(value = "sysUID") final String sysUID,
                                    @ModelAttribute final EmptyOutputOptionsImpl oOptions,
                                    final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = new PPLExporter();
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".ppl", response);
      }
  
      /** 
       * Request to read the node for sysUID and return it in ICal-format with all children
       * @param sysUID                 sysUID to export
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - ical-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = RequestMethod.GET, 
                      value = "/ical/{sysUID}", 
                      produces = "application/ical")
      public String exportNodeAsICal(@PathVariable(value = "sysUID") final String sysUID, 
                                     final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = getICalDBExporter();
          OutputOptions oOptions = new OutputOptionsImpl();
          
          // exclude system-nodes
          oOptions.setStrNotNodePraefix(System.getProperty("yaio.exportcontroller.excludenodepraefix", ""));
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".ics", response);
      }
  
      /** 
       * Request to read all Events after node=sysUID and return it and all 
       * children that matches className=EventNode in ICal-format 
       * @param sysUID                 sysUID to export
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - ical-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = RequestMethod.GET, 
                      value = "/icalevents/{sysUID}", 
                      produces = "application/ical")
      public String exportNodeAsICalOnlyEvents(@PathVariable(value = "sysUID") final String sysUID, 
                                               final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = getICalDBExporter();
          OutputOptions oOptions = new OutputOptionsImpl();
          
          // exclude system-nodes
          oOptions.setStrNotNodePraefix(System.getProperty("yaio.exportcontroller.excludenodepraefix", ""));
          oOptions.setStrClassFilter("EventNode");
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".ics", response);
      }
  
      /** 
       * Request to read all Tasks after node=sysUID and return it and all 
       * children that matches className=TaskNode in ICal-format 
       * @param sysUID                 sysUID to export
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - ical-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = RequestMethod.GET, 
                      value = "/icaltasks/{sysUID}", 
                      produces = "application/ical")
      public String exportNodeAsICalOnlyTasks(@PathVariable(value = "sysUID") final String sysUID, 
                                              final HttpServletResponse response) throws ConverterException {
          // configure
          Exporter exporter = getICalDBExporter();
          OutputOptions oOptions = new OutputOptionsImpl();
          
          // exclude system-nodes
          oOptions.setStrNotNodePraefix(System.getProperty("yaio.exportcontroller.excludenodepraefix", ""));
          oOptions.setStrClassFilter("TaskNode");
          
          // run
          return converterUtils.exportNode(sysUID, exporter, oOptions, ".ics", response);
      }
  
      /** 
       * Request to read all Open Tasks after node=sysUID and return it and 
       * all children that matches className=TaskNode and 
       * type=OFFEN,RUNNING,LATE,WARNING in ICal-format 
       * @param sysUID                 sysUID to export
       * @param response               the response-Obj to set contenttype and headers
       * @return                       String - ical-format of the node
       * @throws ConverterException    if something went wrong
       */
      @ResponseBody
      @RequestMapping(method = RequestMethod.GET, 
                      value = "/icaltaskstodo/{sysUID}", 
                      produces = "application/ical")
      public String exportNodeAsICalOnlyTasksTodo(@PathVariable(value = "sysUID") final String sysUID, 
                                                  final HttpServletResponse response) throws ConverterException {
          // configure
  