From 94a2d9eb867cb7b74c41e8eff9157c518e18408f Mon Sep 17 00:00:00 2001
From: ulrich <not disclosed>
Date: Thu, 28 Dec 2017 11:06:35 +0000
Subject: [PATCH] Erste Version des MarkdownServlets fertig zum Test

---
 src/de/uhilger/wbx/web/MarkdownServlet.java |   38 +++++++++-----------------------------
 1 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/src/de/uhilger/wbx/web/MarkdownServlet.java b/src/de/uhilger/wbx/web/MarkdownServlet.java
index 58bfbc3..46082d8 100644
--- a/src/de/uhilger/wbx/web/MarkdownServlet.java
+++ b/src/de/uhilger/wbx/web/MarkdownServlet.java
@@ -19,8 +19,10 @@
 
 import java.io.IOException;
 import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import org.markdownj.MarkdownProcessor;
 
 /**
  *
@@ -29,37 +31,15 @@
 public class MarkdownServlet extends WbxServlet {
   
   
-  /**
-   * Handles the HTTP <code>GET</code> method.
-   *
-   * @param request servlet request
-   * @param response servlet response
-   * @throws ServletException if a servlet-specific error occurs
-   * @throws IOException if an I/O error occurs
-   */
   @Override
-  protected void doGet(HttpServletRequest request, HttpServletResponse response)
-          throws ServletException, IOException {
-    String contextPath = request.getContextPath();
-    if(HOME_CTX.equals(contextPath)) {
-      String userName = getUserName(request);
-      if (userName != null) {
-        String urlUser = getUrlUser(request, userName);
-        if(userName.equals(urlUser)) {
-          seiteAusgeben(request, response);
-        } else {
-          logger.fine("Wrong user.");
-        }
-      } else {
-        logger.fine("Missing login.");
-      }
-    } else {
-      seiteAusgeben(request, response);
-    }
-  }
-  
-  private void seiteAusgeben(HttpServletRequest request, HttpServletResponse response) {
+  protected void seiteAusgeben(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
     
+    CustomResponseWrapper wrapper = new CustomResponseWrapper(response);
+    super.doGet(request, wrapper);
+    String responseContent = wrapper.getResponseContent();
+    ServletOutputStream out = response.getOutputStream();
+    MarkdownProcessor p = new MarkdownProcessor();
+    out.print(p.markdown(responseContent));
   }
   
 }

--
Gitblit v1.9.3