List of usage examples for javax.servlet.http HttpServletRequest getParameterMap
public Map<String, String[]> getParameterMap();
From source file:org.broadleafcommerce.payment.service.gateway.AuthorizeNetWebResponseServiceImpl.java
@Override public PaymentResponseDTO translateWebResponse(HttpServletRequest request) throws PaymentException { PaymentResponseDTO responseDTO = new PaymentResponseDTO(PaymentType.CREDIT_CARD, AuthorizeNetGatewayType.AUTHORIZENET).rawResponse(webResponsePrintService.printRequest(request)); Map<String, String[]> paramMap = request.getParameterMap(); for (String key : paramMap.keySet()) { responseDTO.responseMap(key, paramMap.get(key)[0]); }/*from w ww . j a v a2 s .c om*/ Map<String, String> params = responseDTO.getResponseMap(); Money amount = Money.ZERO; if (responseDTO.getResponseMap().containsKey(AuthNetField.X_AMOUNT.getFieldName())) { String amt = responseDTO.getResponseMap().get(AuthNetField.X_AMOUNT.getFieldName()); amount = new Money(amt); } boolean approved = false; if (params.get(AuthNetField.X_RESPONSE_CODE.getFieldName()).equals("1")) { approved = true; } PaymentTransactionType type = PaymentTransactionType.AUTHORIZE_AND_CAPTURE; if (!configuration.isPerformAuthorizeAndCapture()) { type = PaymentTransactionType.AUTHORIZE; } responseDTO.successful(approved).amount(amount).paymentTransactionType(type) .orderId(params.get(MessageConstants.BLC_OID)).customer() .firstName(params.get(AuthNetField.X_FIRST_NAME.getFieldName())) .lastName(params.get(AuthNetField.X_LAST_NAME.getFieldName())) .customerId(params.get(AuthNetField.X_CUST_ID.getFieldName())).done().billTo() .addressFirstName(params.get(AuthNetField.X_FIRST_NAME.getFieldName())) .addressLastName(params.get(AuthNetField.X_LAST_NAME.getFieldName())) .addressLine1(params.get(AuthNetField.X_ADDRESS.getFieldName())) .addressCityLocality(params.get(AuthNetField.X_CITY.getFieldName())) .addressStateRegion(params.get(AuthNetField.X_STATE.getFieldName())) .addressPostalCode(params.get(AuthNetField.X_ZIP.getFieldName())) .addressCountryCode(params.get(AuthNetField.X_COUNTRY.getFieldName())) .addressPhone(params.get(AuthNetField.X_PHONE.getFieldName())).done().creditCard() .creditCardLastFour(params.get(AuthNetField.X_ACCOUNT_NUMBER.getFieldName())) .creditCardType(params.get(AuthNetField.X_CARD_TYPE.getFieldName())); return responseDTO; }
From source file:org.zilverline.web.SearchDefaultsController.java
/** * Method updates an existing SearchService. * /*from ww w.ja v a 2s. c o m*/ * @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 { // get keys and values for BoostFactors Map reqMap = request.getParameterMap(); Iterator iter = reqMap.entrySet().iterator(); String[] values = new String[reqMap.size()]; String[] fields = new String[reqMap.size()]; String prefix = "field_"; // find corresponding field, value pairs, they have matching numbers as // parameter names (field_#,#) (# is a number) 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)) { // this is a field named field_# String indexStr = key.substring(prefix.length()); int index = Integer.parseInt(indexStr); log.debug("Adding " + value + " to fields[" + index + "]"); fields[index] = value; } else { // this could be a value named # int index = Integer.parseInt(key); log.debug("Adding " + value + " to values[" + index + "]"); values[index] = value; } } catch (NumberFormatException e) { // not an extractor related requestParameter log.debug("Skipping " + key + ", " + value); } } // add the key value pairs to Map, if field and value contains value Map props = new Properties(); for (int i = 0; i < fields.length; i++) { if (StringUtils.hasLength(fields[i]) && StringUtils.hasLength(values[i])) { log.debug("Adding " + fields[i] + "=" + values[i] + " to map"); props.put(fields[i], values[i]); // validate the value try { float f = Float.parseFloat(values[i]); } catch (NumberFormatException e) { log.debug("value must be a float: " + values[i]); errors.rejectValue("factors", "error.notapositivenumber", null, "must be a float."); // TODO this is not great, and it does not show error. // OnBindAndValidate? return new ModelAndView(getSuccessView()); } } else { log.debug("Skipping (remove) " + fields[i] + "=" + values[i] + " from map"); } } if (service.getFactors() != null) { service.getFactors().setFactors(props); } else { // TODO: this is funny,and should not occur, prevent this from happening somewhere else log.warn("SearchService should have Boostfactors, creating new"); service.setFactors(new BoostFactor()); service.getFactors().setFactors(props); } try { service.store(); } catch (SearchException e) { throw new ServletException("Error storing new Search Defaults", e); } return new ModelAndView(getSuccessView()); }
From source file:de.hybris.platform.chinesepspalipaymockaddon.controllers.pages.AlipayMockController.java
@SuppressWarnings("boxing") @RequestMapping(value = "", method = RequestMethod.GET) public String doGetGateWay(final Model model, final HttpServletRequest request) { final Map<String, String[]> requestParamMap = request.getParameterMap(); if (requestParamMap == null) { return AlipayMockControllerConstants.Pages.AlipayMockPage; }//w ww. j a v a2 s . c o m final String baseGateWay = request.getRequestURL().toString(); model.addAttribute("baseGateWay", baseGateWay); final Map<String, String> clearParams = removeUselessValue(requestParamMap); this.setCSRFToken(clearParams, request); final String service = request.getParameter("service"); if (service == null) { return AlipayMockControllerConstants.Pages.AlipayMockPage; } XSSFilterUtil.filter(service); final boolean signIsValid = isSignValid(clearParams); model.addAttribute("signIsValid", Boolean.valueOf(signIsValid)); model.addAttribute("params", clearParams); model.addAttribute("out_trade_no", clearParams.get("out_trade_no")); model.addAttribute("total_fee", clearParams.get("total_fee")); model.addAttribute("storefront", (StringUtils.substringBetween(request.getContextPath(), "/"))); if ("refund_fastpay_by_platform_pwd".equals(service)) { return AlipayMockControllerConstants.Pages.AlipayRefundPage; } return AlipayMockControllerConstants.Pages.AlipayMockPage; }
From source file:org.ldp4j.apps.ldp4ro.servlets.Form2RDFServlet.java
/** * Upon receiving data from the RO creation form, * 1. parses the request to extract the form data * 2. converts them to RDF to generate a RO * 3. submit that RO to an LDP server that manages the RO *//*from w w w.j a v a2 s. co m*/ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String requestURL = request.getRequestURL().toString(); logger.debug("Received a POST request on '{}'", requestURL); Map<String, String[]> parameterMap = request.getParameterMap(); RoRDFModel ro = new RoRDFModel(parameterMap); Model model = ro.process(); ByteArrayOutputStream os = new ByteArrayOutputStream(); model.write(os, "TURTLE"); String roString = os.toString(); logger.debug("Form data is converted to RDF ... \n{}", roString); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost post = new HttpPost("http://localhost:8080/ldp4j/ldp-bc/"); //HttpPost post = new HttpPost("http://linkeddata4.dia.fi.upm.es:8088/ldp4j/ldp-bc/"); StringEntity body = new StringEntity(roString); body.setContentType("text/turtle"); post.setEntity(body); HttpResponse ldpResponse = httpclient.execute(post); try { int statusCode = ldpResponse.getStatusLine().getStatusCode(); logger.debug("LDP server responded with {} {}", statusCode, ldpResponse.getStatusLine().getReasonPhrase()); if (statusCode == 201 && ldpResponse.getFirstHeader("Location") != null) { String location = ldpResponse.getFirstHeader("Location").getValue(); logger.debug("URI of the newly created LDPR - {}", location); request.setAttribute("newURI", location); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/roCreated.jsp"); dispatcher.forward(request, response); } else { logger.error("An error occurred while creating the RO. {} {}", statusCode, ldpResponse.getStatusLine().getReasonPhrase()); } } finally { post.releaseConnection(); } }
From source file:com.igeekinc.indelible.indeliblefs.iscsi.IndelibleiSCSIMgmtServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Map<String, String[]> paramMap = req.getParameterMap(); String[] keys = paramMap.get("cmd"); if (keys.length != 1) { resp.sendError(200);/*from ww w . j a v a 2 s . com*/ } else { try { String command = keys[0].toLowerCase().trim(); JSONObject resultObject = null; if (command.equals("export")) resultObject = export(req, resp, paramMap); if (command.equals("unexport")) resultObject = unexport(req, resp, paramMap); if (command.equals("listexports")) resultObject = listExports(); if (command.equals("serverinfo")) resultObject = serverInfo(); if (resultObject != null) { resp.getWriter().print(resultObject.toString(5)); } else { throw new InternalError("No result object created"); } } catch (IndelibleMgmtException e) { Logger.getLogger(getClass()).error(new ErrorLogMessage("Caught exception"), e); doError(resp, e); } catch (Throwable t) { doError(resp, new IndelibleMgmtException(IndelibleMgmtException.kInternalError, t)); } } }
From source file:mx.edu.um.mateo.general.web.EmpresaController.java
@RequestMapping(value = "/centrosDeCosto", params = "term", produces = "application/json") public @ResponseBody List<Map<String, String>> centrosDeCosto(HttpServletRequest request, @RequestParam("term") String filtro) { log.debug("Buscando Centros de Costo por {}", filtro); for (String nombre : request.getParameterMap().keySet()) { log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre)); }//from ww w .j av a 2 s .c o m List<CentroCosto> centrosDeCosto = centroCostoDao.buscaPorOrganizacion(filtro, ambiente.obtieneUsuario()); List<Map<String, String>> resultados = new ArrayList<>(); for (CentroCosto centroCosto : centrosDeCosto) { Map<String, String> map = new HashMap<>(); map.put("id", centroCosto.getId().getIdCosto()); map.put("value", centroCosto.getNombreCompleto()); resultados.add(map); } return resultados; }
From source file:org.easysoa.registry.dbb.rest.ServiceFinderRest.java
@POST public Object findServices(@Context HttpContext httpContext, @Context HttpServletRequest request) throws Exception { // Retrieve params @SuppressWarnings("unchecked") Map<String, String> formValues = getFirstValues(request.getParameterMap()); // Find WSDLs BrowsingContext browsingContext = new BrowsingContext(new URL(formValues.get("url")), formValues.get("data")); return findServices(browsingContext); }
From source file:com.sandboxnine.controller.catalog.CategoryController.java
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView model = super.handleRequest(request, response); //? ? category . //TODO ./*from w w w . j a va2s . co m*/ if (false == request.getParameterMap().containsKey("facetField")) { List<SortOption> sortOptions = ((ExCategoryImpl) model.getModelMap().get(CATEGORY_ATTRIBUTE_NAME)) .getSortOptions(); for (SortOption sortOption : sortOptions) { String sortCondition = sortOption.getSortCondition(); sortOption.setLink(addSortLink(sortOption)); } } return model; }
From source file:com.medallia.spider.api.DynamicInputImpl.java
/** * Creates a new {@link DynamicInputImpl} * @param request from which to read the request parameters *//*from w w w.java 2 s. com*/ public DynamicInputImpl(HttpServletRequest request) { @SuppressWarnings("unchecked") Map<String, String[]> reqParams = Maps.newHashMap(request.getParameterMap()); this.inputParams = reqParams; if (ServletFileUpload.isMultipartContent(request)) { this.fileUploads = Maps.newHashMap(); Multimap<String, String> inputParamsWithList = ArrayListMultimap.create(); ServletFileUpload upload = new ServletFileUpload(); try { FileItemIterator iter = upload.getItemIterator(request); while (iter.hasNext()) { FileItemStream item = iter.next(); String fieldName = item.getFieldName(); InputStream stream = item.openStream(); if (item.isFormField()) { inputParamsWithList.put(fieldName, Streams.asString(stream, Charsets.UTF_8.name())); } else { final String filename = item.getName(); final byte[] bytes = ByteStreams.toByteArray(stream); fileUploads.put(fieldName, new UploadedFile() { @Override public String getFilename() { return filename; } @Override public byte[] getBytes() { return bytes; } @Override public int getSize() { return bytes.length; } }); } } for (Entry<String, Collection<String>> entry : inputParamsWithList.asMap().entrySet()) { inputParams.put(entry.getKey(), entry.getValue().toArray(new String[0])); } } catch (IOException | FileUploadException e) { throw new IllegalArgumentException("Failed to parse multipart", e); } } else { this.fileUploads = Collections.emptyMap(); } }
From source file:gov.nih.nci.security.upt.forms.SystemConfigurationForm.java
public List<String> validate(HttpServletRequest request) { List<String> errors = new ArrayList<String>(); Iterator entries = request.getParameterMap().entrySet().iterator(); while (entries.hasNext()) { Entry thisEntry = (Entry) entries.next(); Object key = thisEntry.getKey(); String keyString = (String) thisEntry.getKey(); if (keyString != null && keyString.equalsIgnoreCase("PASSWORD_EXPIRY_DAYS")) { String[] keyValue = (String[]) thisEntry.getValue(); if (keyValue != null) { int intValue = new Integer(keyValue[0]).intValue(); if (intValue <= 0) { errors.add("Invalid Password expiry days. Value should be more than 0."); }//from www. jav a 2s . com } else errors.add("Password expiry days value is missing. Value should be more than 0."); } else if (keyString != null && keyString.equalsIgnoreCase("ALLOWED_ATTEMPTS")) { String[] keyValue = (String[]) thisEntry.getValue(); if (keyValue != null) { try { int intValue = Integer.parseInt(keyValue[0]); if (intValue <= 0) { errors.add("Invalid Allowed attempts. Value should be more than 0."); } } catch (NumberFormatException e) { errors.add("Invalid Allowed attempts. Value should be more than 0."); } } else errors.add("Allowed attempts value is missing. Value should be more than 0."); } else if (keyString != null && keyString.equalsIgnoreCase("ALLOWED_LOGIN_TIME")) { String[] keyValue = (String[]) thisEntry.getValue(); if (keyValue != null) { try { int intValue = Integer.parseInt(keyValue[0]); if (intValue <= 0) { errors.add("Invalid Allowed login time. Value should be more than 0."); } } catch (NumberFormatException e) { errors.add("Invalid Allowed login time. Value should be more than 0."); } } else errors.add("Allowed login time value is missing. Value should be more than 0."); } else if (keyString != null && keyString.equalsIgnoreCase("PASSWORD_LOCKOUT_TIME")) { String[] keyValue = (String[]) thisEntry.getValue(); if (keyValue != null) { try { int intValue = Integer.parseInt(keyValue[0]); if (intValue <= 0) { errors.add("Invalid Password lockout time. Value should be more than 0."); } } catch (NumberFormatException e) { errors.add("Invalid Password lockout time. Value should be more than 0."); } } else errors.add("Password lockout time value is missing. Value should be more than 0."); } else if (keyString != null && keyString.equalsIgnoreCase("PASSWORD_MATCH_NUM")) { String[] keyValue = (String[]) thisEntry.getValue(); if (keyValue != null) { try { int intValue = Integer.parseInt(keyValue[0]); if (intValue <= 0) { errors.add("Invalid Password matching number. Value should be more than 0."); } } catch (NumberFormatException e) { errors.add("Invalid Password matching number. Value should be more than 0."); } } else errors.add("Password matching number is missing. Value should be more than 0."); } } return errors; }