WebBox Klassenbibliothek
ulrich
2017-03-10 7bcebfd6fa76b55a6682f1dad45e51f025c831b8
commit | author | age
7bcebf 1 /*
U 2     WebBox - Dein Server.
3     Copyright (C) 2017 Ulrich Hilger, http://uhilger.de
4
5     This program is free software: you can redistribute it and/or modify
6     it under the terms of the GNU Affero General Public License as
7     published by the Free Software Foundation, either version 3 of the
8     License, or (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU Affero General Public License for more details.
14
15     You should have received a copy of the GNU Affero General Public License
16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package de.uhilger.wbx.web;
19
20 import java.io.IOException;
21 import javax.servlet.ServletException;
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
24 import org.apache.catalina.servlets.DefaultServlet;
25
26 /**
27  * Mit dem TNServlet kann f&uuml;r eine Bilddatei eine 
28  * Miniaturansicht erzeugt werden, wie sie im Dateimanager 
29  * der WebBox verwendet wird.
30  * 
31  */
32 public class TNServlet extends DefaultServlet {
33   
34   /**
35    * Diese String-Konstanten noetigenfalls in eine 
36    * Konfigurationsdatei auslagern
37    */
38   public static final String TN = "_tn";
39   public static final String JPG = ".jpg";
40   public static final String JPEG = ".jpeg";
41   public static final String PNG = ".png";
42   
43   /**
44    * Handles the HTTP <code>GET</code> method.
45    *
46    * @param request servlet request
47    * @param response servlet response
48    * @throws ServletException if a servlet-specific error occurs
49    * @throws IOException if an I/O error occurs
50    */
51   @Override
52   protected void doGet(HttpServletRequest request, HttpServletResponse response)
53           throws ServletException, IOException {
54     
55     String urlStr = request.getRequestURI();
56     if(urlStr.contains(TN) && (urlStr.endsWith(JPG) || urlStr.endsWith(JPEG) || urlStr.endsWith(PNG))) {
57       /*
58       TODO: hier mit Hilfe der Klasse Bild eine Miniaturansicht erzeugen  
59       und in die Antwort schreiben
60       */      
61     } else {
62       super.doGet(request, response);
63     }
64             
65     
66   }
67   
68 }