1 /* ==============================================================================
2 * JDBCAdmin, data management software.
3 * Copyright (C) 2005 Norsys S.A
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * ==============================================================================
19 */
20 package jdbcadmin.web.util;
21
22 import java.util.Enumeration;
23
24 import javax.servlet.http.HttpServletRequest;
25
26 import jdbcadmin.core.data.Line;
27 import jdbcadmin.core.exceptions.TechnicalException;
28 import jdbcadmin.web.actions.Constants;
29
30 /***
31 * Non trivial mappings between the http request and the objects
32 */
33 public class HttpWrapper {
34
35 /*** Constructor */
36 protected HttpWrapper() {
37 }
38
39 /***
40 * Fill the specified line with the http request parameters.
41 * @param aRequest the http request
42 * @param aLine the line to fill
43 * @throws TechnicalException Technical error
44 */
45 public static void wrapLine (HttpServletRequest aRequest, Line aLine) throws TechnicalException {
46 Enumeration paramNames = aRequest.getParameterNames();
47 while (paramNames.hasMoreElements()) {
48 String paramName = (String) paramNames.nextElement();
49 if (!paramName.equals("typeAction")) {
50 if (!paramName.endsWith(Constants.NULL_PARAM_SUFFIX)) {
51 String valNull = aRequest.getParameter(paramName + Constants.NULL_PARAM_SUFFIX);
52 if (valNull == null || !valNull.equals(Constants.NULL_PARAM_VALUE)) {
53 String value = aRequest.getParameter(paramName);
54 aLine.addValue(paramName, value);
55 }
56 }
57 }
58 }
59 }
60 }