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.MCRSwordMediaManager;
25  import org.swordapp.server.MediaResourceAPI;
26  
27  import jakarta.servlet.ServletException;
28  import jakarta.servlet.http.HttpServletRequest;
29  import jakarta.servlet.http.HttpServletResponse;
30  
31  public class MCRSwordMediaResourceServlet extends MCRSwordServlet {
32  
33      private MCRSwordMediaManager mrm;
34  
35      private MediaResourceAPI api;
36  
37      public void init() throws ServletException {
38          MCRSwordConfigurationDefault swordConfiguration = new MCRSwordConfigurationDefault();
39          mrm = new MCRSwordMediaManager();
40          api = new MediaResourceAPI(mrm, swordConfiguration);
41      }
42  
43      public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
44          prepareRequest(req, resp);
45          api.get(req, resp);
46          afterRequest(req, resp);
47      }
48  
49      public void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
50          prepareRequest(req, resp);
51          api.head(req, resp);
52          afterRequest(req, resp);
53      }
54  
55      public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
56          prepareRequest(req, resp);
57          api.post(req, resp);
58          afterRequest(req, resp);
59      }
60  
61      public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
62          prepareRequest(req, resp);
63          api.put(req, resp);
64          afterRequest(req, resp);
65      }
66  
67      public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
68          prepareRequest(req, resp);
69          api.delete(req, resp);
70          afterRequest(req, resp);
71      }
72  }