View Javadoc
1   /*
2    * This file is part of ***  M y C o R e  ***
3    * See http://www.mycore.de/ for details.
4    *
5    * MyCoRe is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * MyCoRe 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 General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with MyCoRe.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package org.mycore.sword.servlets;
20  
21  import java.io.IOException;
22  
23  import org.mycore.sword.MCRSwordConfigurationDefault;
24  import org.mycore.sword.manager.MCRSwordContainerManager;
25  import org.mycore.sword.manager.MCRSwordStatementManager;
26  import org.swordapp.server.ContainerAPI;
27  
28  import jakarta.servlet.ServletException;
29  import jakarta.servlet.http.HttpServletRequest;
30  import jakarta.servlet.http.HttpServletResponse;
31  
32  /**
33   * @author Sebastian Hofmann (mcrshofm)
34   */
35  public class MCRSwordContainerServlet extends MCRSwordServlet {
36  
37      private ContainerAPI api;
38  
39      public void init() {
40          MCRSwordConfigurationDefault swordConfiguration = new MCRSwordConfigurationDefault();
41          MCRSwordContainerManager containerManager = new MCRSwordContainerManager();
42          MCRSwordStatementManager statementManager = new MCRSwordStatementManager();
43          api = new ContainerAPI(containerManager, statementManager, swordConfiguration);
44      }
45  
46      public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
47          prepareRequest(req, resp);
48          api.get(req, resp);
49          afterRequest(req, resp);
50      }
51  
52      public void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
53          prepareRequest(req, resp);
54          api.head(req, resp);
55          afterRequest(req, resp);
56      }
57  
58      public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
59          prepareRequest(req, resp);
60          api.post(req, resp);
61          afterRequest(req, resp);
62      }
63  
64      public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
65          prepareRequest(req, resp);
66          api.put(req, resp);
67          afterRequest(req, resp);
68      }
69  
70      public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
71          prepareRequest(req, resp);
72          api.delete(req, resp);
73          afterRequest(req, resp);
74      }
75  }