List of usage examples for javax.servlet.http HttpServletRequest getParameterMap
public Map<String, String[]> getParameterMap();
From source file:com.openmeap.services.ServiceManagementServlet.java
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { Result result = null;/* w w w . j av a2 s . c o m*/ PrintWriter os = new PrintWriter(response.getOutputStream()); logger.debug("Request uri: {}", request.getRequestURI()); logger.debug("Request url: {}", request.getRequestURL()); logger.debug("Query string: {}", request.getQueryString()); if (logger.isDebugEnabled()) { logger.debug("Parameter map: {}", ParameterMapUtils.toString(request.getParameterMap())); } String action = request.getParameter(UrlParamConstants.ACTION); if (action == null) { action = ""; } if (!authenticates(request)) { logger.error("Request failed to authenticate ", request); result = new Result(Result.Status.FAILURE, "Authentication failed"); sendResult(response, os, result); return; } if (action.equals(ModelEntityEventAction.MODEL_REFRESH.getActionName())) { logger.trace("Processing refresh"); result = refresh(request, response); sendResult(response, os, result); return; } else if (action.equals(ClusterNodeRequest.HEALTH_CHECK)) { logger.trace("Cluster node health check"); result = healthCheck(request, response); sendResult(response, os, result); return; } GlobalSettings settings = modelManager.getGlobalSettings(); ClusterNode clusterNode = modelManager.getClusterNode(); if (clusterNode == null) { throw new RuntimeException( "openmeap-services-web needs to be configured as a cluster node in the settings of the admin interface."); } Map<Method, String> validationErrors = clusterNode.validate(); if (validationErrors != null) { throw new RuntimeException(new InvalidPropertiesException(clusterNode, validationErrors)); } if (request.getParameter("clearPersistenceContext") != null && context instanceof AbstractApplicationContext) { logger.trace("Clearing persistence context"); clearPersistenceContext(); } else if (action.equals(ModelEntityEventAction.ARCHIVE_UPLOAD.getActionName())) { logger.trace("Processing archive upload - max file size: {}, storage path prefix: {}", settings.getMaxFileUploadSize(), clusterNode.getFileSystemStoragePathPrefix()); archiveUploadHandler.setFileSystemStoragePathPrefix(clusterNode.getFileSystemStoragePathPrefix()); Map<Object, Object> paramMap = ServletUtils.cloneParameterMap(settings.getMaxFileUploadSize(), clusterNode.getFileSystemStoragePathPrefix(), request); result = handleArchiveEvent(archiveUploadHandler, new MapPayloadEvent(paramMap), paramMap); } else if (action.equals(ModelEntityEventAction.ARCHIVE_DELETE.getActionName())) { logger.trace("Processing archive delete - max file size: {}, storage path prefix: {}", settings.getMaxFileUploadSize(), clusterNode.getFileSystemStoragePathPrefix()); archiveDeleteHandler.setFileSystemStoragePathPrefix(clusterNode.getFileSystemStoragePathPrefix()); Map<Object, Object> paramMap = ServletUtils.cloneParameterMap(settings.getMaxFileUploadSize(), clusterNode.getFileSystemStoragePathPrefix(), request); result = handleArchiveEvent(archiveDeleteHandler, new MapPayloadEvent(paramMap), paramMap); } sendResult(response, os, result); }
From source file:org.zilverline.web.ExtractorMappingsController.java
/** Method updates an existing IndexService's ExtractorFactory. */ /*// w w w. ja v a 2 s.c o m * (non-Javadoc) * * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException) */ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws ServletException { // reconstruct the extractor map, it contains pairs of (extension, // extractor) // in the request they are related by the fact that the extension is in // a parameter with an integer value // and the extractor contains 'prefix' and corresponding integer value // first get the prefix (posted as hidden field) String prefix = request.getParameter("prefix"); if (!StringUtils.hasLength(prefix)) { log.warn("no prefix set"); prefix = "select_"; } // get keys and values Map reqMap = request.getParameterMap(); Iterator iter = reqMap.entrySet().iterator(); String[] keys = new String[reqMap.size()]; String[] values = new String[reqMap.size()]; while (iter.hasNext()) { Map.Entry element = (Map.Entry) iter.next(); String key = (String) element.getKey(); String value = ((String[]) element.getValue())[0]; log.debug("Parsing request for: " + key + ", " + value); try { if (key.startsWith(prefix)) { String indexStr = key.substring(prefix.length()); int index = Integer.parseInt(indexStr); log.debug("Adding " + value + " to values[" + index + "]"); values[index] = value; } else { int index = Integer.parseInt(key); log.debug("Adding " + value + " to keys[" + index + "]"); keys[index] = value; } } catch (NumberFormatException e) { // not an extractor related requestParameter log.debug("Skipping " + key + ", " + value); } } // add the key value pairs to Map, if value contains value Map props = new Properties(); for (int i = 0; i < values.length; i++) { if (StringUtils.hasLength(values[i])) { log.debug("Adding " + keys[i] + "," + values[i] + " to map"); props.put(keys[i], values[i]); } else { log.debug("Skipping (remove) " + keys[i] + "," + values[i] + " to map"); } } collectionManager.getFactory() .setCaseSensitive(RequestUtils.getBooleanParameter(request, "casesensitive", false)); collectionManager.getFactory() .setDefaultFileinfo(RequestUtils.getBooleanParameter(request, "defaultfileinfo", false)); collectionManager.getFactory().setMappings(props); try { collectionManager.store(); } catch (IndexException e) { throw new ServletException("Error storing new CollectionManager Defaults", e); } return new ModelAndView(getSuccessView()); }
From source file:mx.edu.um.mateo.inventario.web.SalidaController.java
@SuppressWarnings("unchecked") @RequestMapping/*from w w w. ja v a2s . com*/ public String lista(HttpServletRequest request, HttpServletResponse response, Usuario usuario, Errors errors, Model modelo) throws ParseException { log.debug("Mostrando lista de salidas"); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Map<String, Object> params = this.convierteParams(request.getParameterMap()); Long almacenId = (Long) request.getSession().getAttribute("almacenId"); params.put("almacen", almacenId); if (params.containsKey("fechaIniciado")) { log.debug("FechaIniciado: {}", params.get("fechaIniciado")); params.put("fechaIniciado", sdf.parse((String) params.get("fechaIniciado"))); } if (params.containsKey("fechaTerminado")) { params.put("fechaTerminado", sdf.parse((String) params.get("fechaTerminado"))); } if (params.containsKey("tipo") && StringUtils.isNotBlank((String) params.get("tipo"))) { params.put("reporte", true); params = salidaDao.lista(params); try { generaReporte((String) params.get("tipo"), (List<Salida>) params.get("salidas"), response, "salidas", Constantes.ALM, almacenId); return null; } catch (ReporteException e) { log.error("No se pudo generar el reporte", e); params.remove("reporte"); errors.reject("error.generar.reporte"); } } if (params.containsKey("correo") && StringUtils.isNotBlank((String) params.get("correo"))) { params.put("reporte", true); params = salidaDao.lista(params); params.remove("reporte"); try { enviaCorreo((String) params.get("correo"), (List<Salida>) params.get("salidas"), request, "salidas", Constantes.ALM, almacenId); modelo.addAttribute("message", "lista.enviada.message"); modelo.addAttribute("messageAttrs", new String[] { messageSource.getMessage("salida.lista.label", null, request.getLocale()), ambiente.obtieneUsuario().getUsername() }); } catch (ReporteException e) { log.error("No se pudo enviar el reporte por correo", e); } } params = salidaDao.lista(params); modelo.addAttribute("salidas", params.get("salidas")); Long pagina = 1l; if (params.containsKey("pagina")) { pagina = (Long) params.get("pagina"); } this.pagina(params, modelo, "salidas", pagina); if (params.containsKey(Constantes.ABIERTA) || params.containsKey(Constantes.CERRADA) || params.containsKey(Constantes.PENDIENTE) || params.containsKey(Constantes.FACTURADA) || params.containsKey(Constantes.CANCELADA)) { modelo.addAttribute("estatus", Boolean.TRUE); } else { modelo.addAttribute("estatus", Boolean.FALSE); } return "inventario/salida/lista"; }
From source file:org.broadleafcommerce.vendor.authorizenet.web.controller.BroadleafAuthorizeNetController.java
@RequestMapping(value = "/process", method = RequestMethod.POST, produces = "text/html") public @ResponseBody String relay(HttpServletRequest request, HttpServletResponse response, Model model) throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException, BroadleafAuthorizeNetException { LOG.debug("Authorize URL request - " + request.getRequestURL().toString()); LOG.debug("Authorize Request Parameter Map (params: [" + requestParamToString(request) + "])"); PaymentResponseDTO responseDTO = new PaymentResponseDTO(PaymentType.CREDIT_CARD, AuthorizeNetGatewayType.AUTHORIZENET).rawResponse(webResponsePrintService.printRequest(request)); Result result = Result.createResult(configuration.getLoginId(), configuration.getMd5Key(), request.getParameterMap()); boolean approved = false; if (result.getResponseCode().toString().equals("APPROVED")) { approved = true;//from w w w. j a va 2s . co m } String tps = authorizeNetCheckoutService.createTamperProofSeal( result.getResponseMap().get(MessageConstants.BLC_CID), result.getResponseMap().get(MessageConstants.BLC_OID)); responseDTO.valid(tps.equals(result.getResponseMap().get(MessageConstants.BLC_TPS))); System.out.println("requestmap: " + webResponsePrintService.printRequest(request)); if (approved && responseDTO.isValid()) { if (LOG.isDebugEnabled()) { LOG.debug("Transaction success for order " + result.getResponseMap().get(AuthNetField.X_TRANS_ID.getFieldName())); LOG.debug("Response for Authorize.net to relay to client: "); LOG.debug(authorizeNetCheckoutService.buildRelayResponse(configuration.getConfirmUrl(), result)); } return authorizeNetCheckoutService.buildRelayResponse(configuration.getConfirmUrl(), result); } return authorizeNetCheckoutService.buildRelayResponse(configuration.getErrorUrl(), result); }
From source file:net.fenyo.mail4hotspot.web.WebController.java
@RequestMapping(value = "/navigation") public ModelAndView nav(@RequestParam(value = "url", required = false) String target_url, HttpServletRequest request) throws IOException { log.info("TRACE: navigation;get;" + target_url + ";"); @SuppressWarnings("unchecked") final Map<String, String[]> parameters = request.getParameterMap(); boolean first_param = true; if (target_url == null || target_url.isEmpty()) target_url = "http://www.bing.com/"; else if (!parameters.keySet().isEmpty()) { for (final String key : parameters.keySet()) if (!key.equals("url")) for (final String val : parameters.get(key)) { if (first_param == false) target_url += "&"; if (first_param == true) { target_url += "?"; first_param = false; }//from w ww . j av a2s . c o m target_url += URLEncoder.encode(key, "UTF-8") + "=" + URLEncoder.encode(val, "UTF-8"); } } log.info("TRACE: navigation;target url;" + target_url + ";"); ModelAndView mav = new ModelAndView(); mav.setViewName("navigation"); String simple_html; try { simple_html = Browser.getSimpleHtml(target_url, request.getCookies()); } catch (final IOException ex) { log.info("TRACE: navigation;exception;" + target_url + ";"); simple_html = "<BODY><center><a href='#en'>english</a> - <a href='#fr'>franais</a></center><p/><hr/>" + "<a name='en'/><table><tr><td bgcolor='#A00000'><font color='white'>An error occured while downloading the page your requested from this server</font></td></tr></table>" + "<P/><font size='-1'><b>Cause</b>: the internal browser shipped with <i>VPN-over-DNS</i> is optimized to be very efficient on low-bandwith networks. For this purpose, it may disable some features needed by this targeted web site: JavaScript, Cascading Style Sheets, Cookies or SSL/TLS (https) transport protocol support." + "<P/>" + "<b>Solution</b>: you can browse this site with your prefered full-featured browser installed on this device, simply by using one of those two <b>proxy</b> configurations:<br/>" + "<UL>" + " <LI><b>fast browsing proxy</b>" + " <UL>" + " <LI>remote host : <b>localhost</b></LI>" + " <LI>remote port : <b>8080</b></LI>" + " <LI>supported features: JavaScript, CSS & Cookies</LI>" + " </UL>" + " </LI><BR/>" + " <LI><b>full-featured browsing proxy</b>" + " <UL>" + " <LI>remote host : <b>localhost</b></LI>" + " <LI>remote port : <b>8081</b></LI>" + " <LI>supported features: pictures, SSL/TLS (https), JavaScript, CSS & Cookies</LI>" + " </UL>" + " </LI>" + "</UL>" + "<b>Note</b>: you need to let <i>VPN-over-DNS</i> running in the background while using your browser with one of those two proxy configurations, since the implementation of those proxies is made through <i>VPN-over-DNS</i>." + "<p/>Support available on www.vpnoverdns.com" + "<HR/>" + "<BODY><a name='fr'/><table><tr><td bgcolor='#A00000'><font color='white'>Une erreur s'est produite lors du tlchargement de la page</font></td></tr></table>" + "<P/><font size='-1'><b>Raison</b>: le navigateur intgr <i>VPN-over-DNS</i> est optimis pour tre particulirement efficace sur les rseaux bas dbit. Pour cela, il n'implmente pas certaines fonctions ventuellement ncessaires au site que vous avez slectionn : JavaScript, Cascading Style Sheets, Cookies ou encore le protocole de transport SSL/TLS (https)." + "<P/>" + "<b>Solution</b>: vous pouvez naviguer sur ce site web avec n'importe quel navigateur install sur ce priphrique et proposant ces fonctionnalits avances, simplement en configurant votre <b>proxy</b> suivant l'une ou l'autre de ces deux alternatives :<br/>" + "<UL>" + " <LI><b>navigation rapide</b>" + " <UL>" + " <LI>hte distant : <b>localhost</b></LI>" + " <LI>port distant : <b>8080</b></LI>" + " <LI>fonctionnalits disponibles : JavaScript, CSS & Cookies</LI>" + " </UL>" + " </LI><BR/>" + " <LI><b>navigation avec fonctions tendues</b>" + " <UL>" + " <LI>hte distant : <b>localhost</b></LI>" + " <LI>port distant : <b>8081</b></LI>" + " <LI>fonctionnalits disponibles : images, SSL/TLS (https), JavaScript, CSS & Cookies</LI>" + " </UL>" + " </LI>" + "</UL>" + "<b> noter</b> : vous devez laisser <i>VPN-over-DNS</i> fonctionner en tche de fond lors de l'utilisation de votre navigateur via l'un ou l'autre de ces proxies, ils sont en effet implments travers <i>VPN-over-DNS</i>." + "<p/>Support disponible sur www.vpnoverdns.com" + "</BODY>"; } mav.addObject("htmlContent", simple_html); log.info("TRACE: navigation;done;" + target_url + ";" + simple_html.length() + ";"); return mav; }
From source file:com.zjzcn.web.LogInterceptor.java
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { Map<String, LogNode> logConfigs = ConfigHelper.getLogConfigs(); String username = userService.getUsername(); if (logConfigs != null && StringUtils.isNotBlank(username)) { HttpServletRequest req = (HttpServletRequest) request; String uri = req.getRequestURI().split("[?]")[0]; String[] strs = uri.split("[\\/\\.]"); if (strs.length < 2) { return; }/*from w ww.j a v a2s . co m*/ String perm = strs[strs.length - 2]; if (logConfigs.containsKey(perm)) { StringBuffer param = new StringBuffer(); Map<String, String[]> parameterMap = request.getParameterMap(); if (parameterMap != null) { for (Entry<String, String[]> entry : parameterMap.entrySet()) { String parameterName = entry.getKey(); if (!ArrayUtils.contains(ignoreParameters, parameterName)) { String[] parameterValues = entry.getValue(); if (parameterValues != null) { for (String parameterValue : parameterValues) { param.append(parameterName + " = " + parameterValue + "\n"); } } } } } LogNode logConfig = logConfigs.get(perm); Log log = new Log(); log.setLogType(0); log.setName(logConfig.getName()); log.setUsername(username); log.setCreateTime(DateUtils.getCurrentTime(null)); log.setContent(param.toString()); log.setIp(request.getRemoteAddr()); //logService.save(log); } } }
From source file:net.shopxx.plugin.paypalPayment.PaypalPaymentPlugin.java
@Override public boolean verifyNotify(PaymentPlugin.NotifyMethod notifyMethod, HttpServletRequest request) { PluginConfig pluginConfig = getPluginConfig(); PaymentLog paymentLog = getPaymentLog(request.getParameter("invoice")); if (paymentLog != null && pluginConfig.getAttribute("partner").equals(request.getParameter("receiver_email")) && pluginConfig.getAttribute("currency").equals(request.getParameter("mc_currency")) && "Completed".equals(request.getParameter("payment_status")) && paymentLog.getAmount().compareTo(new BigDecimal(request.getParameter("mc_gross"))) == 0) { Map<String, Object> parameterMap = new LinkedHashMap<String, Object>(); parameterMap.put("cmd", "_notify-validate"); parameterMap.putAll(request.getParameterMap()); if ("VERIFIED".equals(WebUtils.post("https://www.paypal.com/cgi-bin/webscr", parameterMap))) { return true; }// w w w. j a v a2 s. c o m } return false; }
From source file:org.busko.routemanager.web.admin.community.RouteOutlineController.java
/** * Needs to process all the data submitted to create, at present, the associated Route object. *//*from w ww. j a va 2 s .c o m*/ @Transactional @RequestMapping(method = RequestMethod.PUT, produces = "text/html") public String update(@Valid RouteOutline routeOutline, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { if (bindingResult.hasErrors()) { populateEditForm(uiModel, routeOutline); return "admin/community/routeoutlines/update"; } // Sort the request data HashMap<String, String> latMap = new HashMap<String, String>(); HashMap<String, String> lonMap = new HashMap<String, String>(); HashMap<String, String> descMap = new HashMap<String, String>(); HashMap<String, HashMap<String, String>> tripStoptimeMap = new HashMap<String, HashMap<String, String>>(); HashMap<String, String> frequencyMap = new HashMap<String, String>(); for (Object o : httpServletRequest.getParameterMap().keySet()) { String key = o.toString(); if (key.startsWith("LAT")) { latMap.put(key.substring(3), httpServletRequest.getParameter(key)); } else if (key.startsWith("LON")) { lonMap.put(key.substring(3), httpServletRequest.getParameter(key)); } else if (key.startsWith("DESC")) { descMap.put(key.substring(4), httpServletRequest.getParameter(key)); } else if (key.endsWith("FREQUENCY")) { frequencyMap.put(key.substring(4, key.indexOf("-")), httpServletRequest.getParameter(key)); } else if (key.startsWith("TRIP")) { String index = key.substring(4, key.indexOf("-")); HashMap<String, String> stoptimeMap = tripStoptimeMap.get(index); if (stoptimeMap == null) { stoptimeMap = new HashMap<String, String>(); tripStoptimeMap.put(index, stoptimeMap); } stoptimeMap.put(key.substring(key.indexOf("-") + 1), httpServletRequest.getParameter(key)); } } RouteOutline theRouteOutline = RouteOutline.findRouteOutline(routeOutline.getId()); theRouteOutline.setUsername(routeOutline.getUsername()); theRouteOutline.setRouteName(routeOutline.getRouteName()); theRouteOutline.setRouteDescription(routeOutline.getRouteDescription()); theRouteOutline.setSubmittedDateTime(routeOutline.getSubmittedDateTime()); Route route = theRouteOutline.createAndAssociateNewRoute(); route.persist(); theRouteOutline.merge(); // Stops should be prefixed with 'STOPx_' where the x is the stop number. If this format is used then set the stopId accordingly. HashMap<String, Stop> stopMap = new HashMap<String, Stop>(); for (int i = 0; i < latMap.size(); i++) { String index = Integer.toString(i); String stopName = descMap.get(index); String stopId = null; if (stopName.toLowerCase().startsWith("stop")) { int pos = stopName.indexOf("_"); if (pos > 4) { stopId = stopName.substring(4, pos); stopName = stopName.substring(pos + 1); } } Stop stop = new Stop(stopId != null ? stopId : "XX", stopName, null, latMap.get(index), lonMap.get(index)); // todo Here we may need to set Agency if stop is being reused route.addStop(stop); stopMap.put(index, stop); stop.persist(); } // Create the shape from the GPS data // TODO Do we want to do this from the GUI to allow points to be added/moved on the interface? GpxToShapeParser gpxToShapeParser = new GpxToShapeParser(); gpxToShapeParser.parse(theRouteOutline); gpxToShapeParser.getShapeCollection().persist(); for (String tripNumber : tripStoptimeMap.keySet()) { Trip trip = new Trip(frequencyMap.get(tripNumber), null, routeOutline.getRouteName(), 0); trip.setCalendar(Calendar.findCalendarsByServiceIdEquals(trip.getServiceId()).getSingleResult()); trip.setShapeCollection(gpxToShapeParser.getShapeCollection()); route.addTrip(trip); trip.persist(); HashMap<String, String> stoptimeMap = tripStoptimeMap.get(tripNumber); for (int i = 0; i < latMap.size(); i++) { String index = Integer.toString(i); StopTime stopTime = new StopTime(stoptimeMap.get(index), stoptimeMap.get(index), i); trip.addStopTime(stopTime); Stop stop = stopMap.get(index); stop.addStopTime(stopTime); stopTime.persist(); } } uiModel.asMap().clear(); return "redirect:/admin/community/routeoutlines/" + encodeUrlPathSegment(routeOutline.getId().toString(), httpServletRequest); }
From source file:net.groupbuy.plugin.paypal.PaypalPlugin.java
@SuppressWarnings("unchecked") @Override/*w w w . j a va 2 s . c om*/ public boolean verifyNotify(String sn, NotifyMethod notifyMethod, HttpServletRequest request) { PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn); if (pluginConfig.getAttribute("partner").equals(request.getParameter("receiver_email")) && sn.equals(request.getParameter("invoice")) && pluginConfig.getAttribute("currency").equals(request.getParameter("mc_currency")) && "Completed".equals(request.getParameter("payment_status")) && payment.getAmount().compareTo(new BigDecimal(request.getParameter("mc_gross"))) == 0) { Map<String, Object> parameterMap = new LinkedHashMap<String, Object>(); parameterMap.put("cmd", "_notify-validate"); parameterMap.putAll(request.getParameterMap()); if ("VERIFIED".equals(post("https://www.paypal.com/cgi-bin/webscr", parameterMap))) { return true; } } return false; }