001/** 002 * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ 003 * 004 * This file is part of Dicoogle/dicoogle. 005 * 006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Dicoogle/dicoogle is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package pt.ua.dicoogle.server.web.servlets.management; 020 021import java.io.IOException; 022import java.util.ArrayList; 023import java.util.List; 024 025import javax.servlet.ServletException; 026import javax.servlet.http.HttpServlet; 027import javax.servlet.http.HttpServletRequest; 028import javax.servlet.http.HttpServletResponse; 029 030import org.apache.commons.lang3.StringUtils; 031 032import pt.ua.dicoogle.core.ServerSettings; 033import pt.ua.dicoogle.server.web.utils.ResponseUtil; 034import pt.ua.dicoogle.server.web.utils.ResponseUtil.Pair; 035 036/** 037 * 038 * @author Frederico Silva <fredericosilva@ua.pt> 039 */ 040public class AETitleServlet extends HttpServlet{ 041 042 @Override 043 protected void doGet(HttpServletRequest req, HttpServletResponse resp) 044 throws ServletException, IOException { 045 List<Pair> mpairs = new ArrayList<>(); 046 mpairs.add(new ResponseUtil.Pair("aetitle", ServerSettings.getInstance().getAE())); 047 048 ResponseUtil.objectResponse(resp, mpairs); 049 } 050 051 @Override 052 protected void doPut(HttpServletRequest req, HttpServletResponse resp) 053 throws ServletException, IOException { 054 String aetitle = req.getParameter("aetitle"); 055 056 if(StringUtils.isEmpty(aetitle)) 057 { 058 resp.sendError(402, "aetitle param not found"); 059 return; 060 } 061 062 ServerSettings.getInstance().setAE(aetitle); 063 064 ResponseUtil.simpleResponse(resp, "success", true); 065 066 } 067 068}