List of usage examples for javax.servlet.http HttpServletRequest getParameterMap
public Map<String, String[]> getParameterMap();
From source file:mx.edu.um.mateo.activos.web.ActivoController.java
@SuppressWarnings("unchecked") @RequestMapping(value = "/proveedores", params = "term", produces = "application/json") public @ResponseBody List<LabelValueBean> proveedores(HttpServletRequest request, @RequestParam("term") String filtro) { for (String nombre : request.getParameterMap().keySet()) { log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre)); }// w w w. j av a 2 s. c o m Map<String, Object> params = new HashMap<>(); params.put("empresa", request.getSession().getAttribute("empresaId")); params.put("filtro", filtro); params = proveedorDao.lista(params); List<LabelValueBean> valores = new ArrayList<>(); List<Proveedor> proveedores = (List<Proveedor>) params.get("proveedores"); for (Proveedor proveedor : proveedores) { StringBuilder sb = new StringBuilder(); sb.append(proveedor.getNombre()); sb.append(" | "); sb.append(proveedor.getRfc()); sb.append(" | "); sb.append(proveedor.getNombreCompleto()); valores.add(new LabelValueBean(proveedor.getId(), sb.toString(), proveedor.getNombre())); } return valores; }
From source file:de.adorsys.oauth.authdispatcher.FixedServletUtils.java
/** * Creates a new HTTP request from the specified HTTP servlet request. * * @param sr The servlet request. Must not be * {@code null}.//from ww w .ja va2s .c o m * @param maxEntityLength The maximum entity length to accept, -1 for * no limit. * * @return The HTTP request. * * @throws IllegalArgumentException The the servlet request method is * not GET, POST, PUT or DELETE or the * content type header value couldn't * be parsed. * @throws IOException For a POST or PUT body that * couldn't be read due to an I/O * exception. */ public static HTTPRequest createHTTPRequest(final HttpServletRequest sr, final long maxEntityLength) throws IOException { HTTPRequest.Method method = HTTPRequest.Method.valueOf(sr.getMethod().toUpperCase()); String urlString = reconstructRequestURLString(sr); URL url; try { url = new URL(urlString); } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid request URL: " + e.getMessage() + ": " + urlString, e); } HTTPRequest request = new HTTPRequest(method, url); try { request.setContentType(sr.getContentType()); } catch (ParseException e) { throw new IllegalArgumentException("Invalid Content-Type header value: " + e.getMessage(), e); } Enumeration<String> headerNames = sr.getHeaderNames(); while (headerNames.hasMoreElements()) { final String headerName = headerNames.nextElement(); request.setHeader(headerName, sr.getHeader(headerName)); } if (method.equals(HTTPRequest.Method.GET) || method.equals(HTTPRequest.Method.DELETE)) { request.setQuery(sr.getQueryString()); } else if (method.equals(HTTPRequest.Method.POST) || method.equals(HTTPRequest.Method.PUT)) { if (maxEntityLength > 0 && sr.getContentLength() > maxEntityLength) { throw new IOException("Request entity body is too large, limit is " + maxEntityLength + " chars"); } Map<String, String[]> parameterMap = sr.getParameterMap(); StringBuilder builder = new StringBuilder(); if (!parameterMap.isEmpty()) { for (Entry<String, String[]> entry : parameterMap.entrySet()) { String key = entry.getKey(); String[] value = entry.getValue(); if (value.length > 0 && value[0] != null) { String encoded = URLEncoder.encode(value[0], "UTF-8"); builder = builder.append(key).append('=').append(encoded).append('&'); } } String queryString = StringUtils.substringBeforeLast(builder.toString(), "&"); request.setQuery(queryString); } else { // read body StringBuilder body = new StringBuilder(256); BufferedReader reader = sr.getReader(); char[] cbuf = new char[256]; int readChars; while ((readChars = reader.read(cbuf)) != -1) { body.append(cbuf, 0, readChars); if (maxEntityLength > 0 && body.length() > maxEntityLength) { throw new IOException( "Request entity body is too large, limit is " + maxEntityLength + " chars"); } } reader.close(); request.setQuery(body.toString()); } } return request; }
From source file:mx.edu.um.mateo.rh.web.ClaveEmpleadoController.java
@RequestMapping("/cambiarClave") public String cambiarClave(HttpServletRequest request, @Valid ClaveEmpleado claveEmpleado, Model modelo) { log.debug("Cambiar clave de empleado"); Empleado empleado = (Empleado) request.getSession().getAttribute(Constantes.EMPLEADO_KEY); ClaveEmpleado claveantigua = manager.obtieneClaveActiva(empleado.getId()); claveantigua.setStatus(Constantes.STATUS_INACTIVO); String t = request.getParameter("tipoEmpleado.id"); for (String nombre : request.getParameterMap().keySet()) { log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre)); }/* w w w. j a v a 2s.com*/ TipoEmpleado tipoEmpleado = tipoEmpleadoManager.obtiene(Long.valueOf(t)); Usuario usuario = ambiente.obtieneUsuario(); String prefijo = tipoEmpleado.getPrefijo(); ClaveEmpleado clavenueva = manager.nuevaClave(usuario, prefijo); clavenueva.setEmpleado(empleado); clavenueva.setObservaciones(claveEmpleado.getObservaciones()); clavenueva.setFecha(claveEmpleado.getFecha()); manager.graba(clavenueva, usuario); return "redirect:" + Constantes.PATH_EMPLEADO; }
From source file:com.nkapps.billing.controllers.BankStatementController.java
@RequestMapping(value = "/list", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> list(HttpServletRequest request, HttpServletResponse response) { HashMap<String, Object> resMap = new LinkedHashMap<String, Object>(); try {//from w w w .j a v a 2 s. c o m // for saving search parameters searchService.execSearchBy(request, response); searchService.execSearchWithinDate(request, response); searchService.execSearchByDate(request, response); Map<String, String[]> map = request.getParameterMap(); HashMap<String, String> parameters = new HashMap<>(); for (String key : map.keySet()) { String[] mapValue = map.get(key); parameters.put(key, mapValue[0]); } resMap.put("success", true); resMap.put("draw", request.getParameter("draw")); resMap.put("data", bankStatementService.getList(parameters)); } catch (Exception e) { logger.error(e.getMessage()); resMap.put("success", false); resMap.put("reason", e.getMessage()); } return resMap; }
From source file:edu.mayo.trilliumbridge.webapp.TransformerController.java
@RequestMapping(value = "/epsos2ccda", method = RequestMethod.POST) @ResponseBody/*from w w w. j av a2 s. com*/ public void epsos2ccda(final HttpServletRequest request, HttpServletResponse response, @RequestHeader(value = "Accept", defaultValue = MediaType.APPLICATION_XML_VALUE) String accept, @RequestParam(value = "formatOverride", required = false) String formatOverride) throws IOException { this.doTransform(request, response, accept, formatOverride, new Transformer() { @Override public void transform(InputStream in, OutputStream out, TrilliumBridgeTransformer.Format outputFormat) { transformer.epsosToCcda(in, out, outputFormat, getParams(request.getParameterMap(), transformer.getTransformerParams())); } }); }
From source file:edu.mayo.trilliumbridge.webapp.TransformerController.java
@RequestMapping(value = "/ccda2epsos", method = RequestMethod.POST) @ResponseBody// w ww . jav a 2 s . co m public void ccda2epsos(final HttpServletRequest request, HttpServletResponse response, @RequestHeader(value = "Accept", defaultValue = MediaType.APPLICATION_XML_VALUE) String accept, @RequestParam(value = "formatOverride", required = false) String formatOverride) throws IOException { this.doTransform(request, response, accept, formatOverride, new Transformer() { @Override public void transform(InputStream in, OutputStream out, TrilliumBridgeTransformer.Format outputFormat) { transformer.ccdaToEpsos(in, out, outputFormat, getParams(request.getParameterMap(), transformer.getCcdaToEpsosOptions())); } }); }
From source file:mx.edu.um.mateo.inventario.web.EntradaController.java
@Transactional @RequestMapping(value = "/crea", method = RequestMethod.POST) public String crea(HttpServletRequest request, HttpServletResponse response, @Valid Entrada entrada, BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) { for (String nombre : request.getParameterMap().keySet()) { log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre)); }/*from w ww. java 2s.co m*/ if (bindingResult.hasErrors()) { log.debug("Hubo algun error en la forma, regresando"); return "inventario/entrada/nueva"; } if (entrada.getProveedor() == null || entrada.getProveedor().getId() == null) { log.warn("No introdujo un proveedor correcto, regresando"); errors.rejectValue("proveedor", "entrada.no.eligio.proveedor.message", null, null); return "inventario/entrada/nueva"; } try { Usuario usuario = ambiente.obtieneUsuario(); if (request.getParameter("proveedor.id") == null) { log.warn("No se puede crear la entrada si no ha seleccionado un proveedor"); errors.rejectValue("proveedor", "entrada.sin.proveedor.message"); return "inventario/entrada/nueva"; } Proveedor proveedor = proveedorDao.obtiene(new Long(request.getParameter("proveedor.id"))); entrada.setProveedor(proveedor); entrada = entradaDao.crea(entrada, usuario); } catch (ConstraintViolationException e) { log.error("No se pudo crear la entrada", e); errors.rejectValue("factura", "campo.duplicado.message", new String[] { "factura" }, null); return "inventario/entrada/nueva"; } redirectAttributes.addFlashAttribute("message", "entrada.creada.message"); redirectAttributes.addFlashAttribute("messageAttrs", new String[] { entrada.getFolio() }); return "redirect:/inventario/entrada/ver/" + entrada.getId(); }
From source file:net.ontopia.topicmaps.nav2.utils.TreeWidget.java
/** * PUBLIC: Runs the widget, producing the output. * /* w ww . j a v a 2s . co m*/ * @since 2.2.1 */ public void run(HttpServletRequest request, Writer writer) throws IOException, InvalidQueryException, NavigatorRuntimeException { initializeContext(request); Map parameters = request.getParameterMap(); parseQueries(); // get current node TopicIF current = null; if (parameters.containsKey("current")) current = getTopic(get(parameters, "current")); int action = getAction(parameters); if (action == EXPAND_ALL) openNodes = new UniversalSet(); else if (action == CLOSE_ALL) openNodes = new CompactHashSet(); else { openNodes = getOpenNodes(request); if (action == OPEN) openNodes.add(current); else if (action == CLOSE) openNodes.remove(current); } int topline = 0; if (parameters.containsKey("topline")) { try { topline = Integer.parseInt(get(parameters, "topline")); } catch (NumberFormatException e) { } } try { doQuery(topline, writer); } catch (InvalidQueryException e) { throw new net.ontopia.utils.OntopiaRuntimeException(e); } setOpenNodes(request, openNodes); }
From source file:mx.edu.um.mateo.general.web.UsuarioController.java
@SuppressWarnings("unchecked") @RequestMapping//from www. j a va 2 s .c om public String lista(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String filtro, @RequestParam(required = false) Long pagina, @RequestParam(required = false) String tipo, @RequestParam(required = false) String correo, @RequestParam(required = false) String order, @RequestParam(required = false) String sort, Model modelo) { log.debug("Mostrando lista de usuarios"); Map<String, Object> params = this.convierteParams(request.getParameterMap()); Long empresaId = (Long) request.getSession().getAttribute("empresaId"); params.put("empresa", empresaId); if (StringUtils.isNotBlank(tipo)) { params.put("reporte", true); params = usuarioDao.lista(params); try { generaReporte(tipo, (List<Usuario>) params.get("usuarios"), response, "usuarios", Constantes.EMP, empresaId); return null; } catch (ReporteException e) { log.error("No se pudo generar el reporte", e); } } if (StringUtils.isNotBlank(correo)) { params.put("reporte", true); params = usuarioDao.lista(params); params.remove("reporte"); try { enviaCorreo(correo, (List<Usuario>) params.get("usuarios"), request, "usuarios", Constantes.EMP, empresaId); modelo.addAttribute("message", "lista.enviada.message"); modelo.addAttribute("messageAttrs", new String[] { messageSource.getMessage("usuario.lista.label", null, request.getLocale()), ambiente.obtieneUsuario().getUsername() }); } catch (ReporteException e) { log.error("No se pudo enviar el reporte por correo", e); } } params = usuarioDao.lista(params); modelo.addAttribute("usuarios", params.get("usuarios")); this.pagina(params, modelo, "usuarios", pagina); return "admin/usuario/lista"; }
From source file:it.geosdi.era.server.servlet.HTTPProxy.java
/** * Performs an HTTP GET request//from w ww.j a v a 2 s . com * @param httpServletRequest The {@link HttpServletRequest} object passed * in by the servlet engine representing the * client request to be proxied * @param httpServletResponse The {@link HttpServletResponse} object by which * we can send a proxied response to the client */ public void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException { URL url = null; String user = null, password = null, method = "GET", post = null; int timeout = 0; Set entrySet = httpServletRequest.getParameterMap().entrySet(); Map headers = new HashMap(); for (Object anEntrySet : entrySet) { Map.Entry header = (Map.Entry) anEntrySet; String key = (String) header.getKey(); String value = ((String[]) header.getValue())[0]; if ("user".equals(key)) { user = value; } else if ("password".equals(key)) { password = value; } else if ("timeout".equals(key)) { timeout = Integer.parseInt(value); } else if ("method".equals(key)) { method = value; } else if ("post".equals(key)) { post = value; } else if ("url".equals(key)) { url = new URL(value); } else { headers.put(key, value); } } if (url != null) { // String digest=null; // if (user != null && password!=null) { // digest = "Basic " + new String(Base64.encodeBase64((user+":"+password).getBytes())); // } // Create a GET request GetMethod getMethodProxyRequest = new GetMethod( /*this.getProxyURL(httpServletRequest)*/ url.toExternalForm()); // Forward the request headers setProxyRequestHeaders(url, httpServletRequest, getMethodProxyRequest); // Execute the proxy request this.executeProxyRequest(getMethodProxyRequest, httpServletRequest, httpServletResponse, user, password); } }