List of usage examples for javax.servlet.http HttpServletRequest getParameterMap
public Map<String, String[]> getParameterMap();
From source file:mx.edu.um.mateo.general.web.ProveedorController.java
@RequestMapping(value = "/crea", method = RequestMethod.POST) public String crea(HttpServletRequest request, HttpServletResponse response, @Valid Proveedor proveedor, 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 . j a va2s .c o m if (bindingResult.hasErrors()) { log.debug("Hubo algun error en la forma, regresando"); return "admin/proveedor/nuevo"; } try { Usuario usuario = ambiente.obtieneUsuario(); proveedor = proveedorDao.crea(proveedor, usuario); } catch (ConstraintViolationException e) { log.error("No se pudo crear al proveedor", e); errors.rejectValue("nombre", "campo.duplicado.message", new String[] { "nombre" }, null); return "admin/proveedor/nuevo"; } redirectAttributes.addFlashAttribute("message", "proveedor.creado.message"); redirectAttributes.addFlashAttribute("messageAttrs", new String[] { proveedor.getNombre() }); return "redirect:/admin/proveedor/ver/" + proveedor.getId(); }
From source file:com.nexmo.security.RequestSigningTest.java
private HttpServletRequest constructDummyRequest(final Map<String, String[]> nullableParams) { Map<String, String[]> params; if (nullableParams == null) { params = constructDummyParams(); } else {// ww w . j av a 2 s . c om params = nullableParams; } HttpServletRequest request = mock(HttpServletRequest.class); for (Map.Entry<String, String[]> pair : params.entrySet()) { when(request.getParameter(pair.getKey())) .thenReturn(pair.getValue() == null ? null : pair.getValue()[0]); } when(request.getParameterMap()).thenReturn(params); return request; }
From source file:jp.mathes.databaseWiki.web.DbwServlet.java
@SuppressWarnings("unchecked") private void edit(final String db, final String table, final String name, final String user, final String password, final Configuration cfg, final HttpServletResponse resp, final HttpServletRequest req, final Backend backend) throws IOException, TemplateException, BackendException { Map<String, String[]> parameterMap = req.getParameterMap(); Document document = backend.getDocument(user, password, db, table, name, true, parameterMap); Template template = cfg.getTemplate("edit.ftl"); HashMap<String, Object> data = new HashMap<String, Object>(); data.put("fields", document.getAllFields()); this.addCommonData(data, req, db, table, name); template.process(data, resp.getWriter()); }
From source file:mx.edu.um.mateo.contabilidad.web.CuentaMayorController.java
@Transactional @RequestMapping(value = "/crea", method = RequestMethod.POST) public String crea(HttpServletRequest request, HttpServletResponse response, @Valid CuentaMayor mayor, BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) { for (String nombre : request.getParameterMap().keySet()) { log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre)); }/*from w w w . j a v a2 s . c o m*/ if (bindingResult.hasErrors()) { log.debug("Hubo algun error en la forma, regresando"); return Constantes.PATH_CUENTA_MAYOR_NUEVA; } try { mayor = cuentaMayorDao.crea(mayor, ambiente.obtieneUsuario()); } catch (ConstraintViolationException e) { log.error("No se pudo crear la cuenta de mayor", e); return Constantes.PATH_CUENTA_MAYOR_NUEVA; } redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE, "mayores.creada.message"); redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE_ATTRS, new String[] { mayor.getNombre() }); return "redirect:" + Constantes.PATH_CUENTA_MAYOR_VER + "/" + mayor.getId(); }
From source file:mx.edu.um.mateo.general.web.UnionController.java
@RequestMapping(value = "/crea", method = RequestMethod.POST) public String crea(HttpServletRequest request, HttpServletResponse response, @Valid Union union, BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) { for (String nombre : request.getParameterMap().keySet()) { log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre)); }//w w w.j av a 2 s . co m if (bindingResult.hasErrors()) { log.debug("Hubo algun error en la forma, regresando"); return Constantes.PATH_UNION_NUEVA; } try { Usuario usuario = null; if (ambiente.obtieneUsuario() != null) { usuario = ambiente.obtieneUsuario(); } union = unionDao.crea(union, usuario); ambiente.actualizaSesion(request, usuario); } catch (ConstraintViolationException e) { log.error("No se pudo crear al union", e); errors.rejectValue("nombre", "campo.duplicado.message", new String[] { "nombre" }, null); return Constantes.PATH_UNION_NUEVA; } redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE, "union.creada.message"); redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE_ATTRS, new String[] { union.getNombre() }); return "redirect:" + Constantes.PATH_UNION_VER + "/" + union.getId(); }
From source file:org.openmrs.module.iqchartimport.web.controller.MappingsController.java
/** * Handles a save request on the drugs form * @param request/*from w ww.ja v a 2s . c o m*/ */ @SuppressWarnings("unchecked") private void handleDrugMappingsSave(HttpServletRequest request) { DrugMapping.clear(); HttpSession httpSession = request.getSession(); List<String> iqDrugs = (List<String>) httpSession.getAttribute("iqDrugs"); for (String param : (Set<String>) request.getParameterMap().keySet()) { if (param.startsWith("drugs-")) { // Get index and lookup up IQChart drug list to get drug name int iqDrugID = Integer.parseInt(param.substring(6)); String iqDrug = iqDrugs.get(iqDrugID); // Get OpenMRS drug concept ids String[] conceptStrIds = request.getParameterValues(param); List<Integer> conceptIds = new ArrayList<Integer>(0); for (String conceptStrId : conceptStrIds) { int drugConceptId = Integer.parseInt(conceptStrId); conceptIds.add(drugConceptId); } DrugMapping.setConcepts(iqDrug, conceptIds); } } DrugMapping.save(); request.getSession().setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Drug mappings saved"); }
From source file:mx.edu.um.mateo.colportor.web.UnionController.java
@RequestMapping(value = "/crea", method = RequestMethod.POST) public String crea(HttpServletRequest request, HttpServletResponse response, @Valid Union union, BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) { for (String nombre : request.getParameterMap().keySet()) { log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre)); }// w ww . jav a 2 s . c om if (bindingResult.hasErrors()) { log.debug("Hubo algun error en la forma, regresando"); return Constantes.PATH_UNION_NUEVA; } try { Usuario usuario = null; if (ambiente.obtieneUsuario() != null) { usuario = ambiente.obtieneUsuario(); } union = unionDao.crea(union, usuario); ambiente.actualizaSesion(request.getSession(), usuario); } catch (ConstraintViolationException e) { log.error("No se pudo crear al union", e); errors.rejectValue("nombre", "campo.duplicado.message", new String[] { "nombre" }, null); return Constantes.PATH_UNION_NUEVA; } redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE, "union.creada.message"); redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE_ATTRS, new String[] { union.getNombre() }); return "redirect:" + Constantes.PATH_UNION_VER + "/" + union.getId(); }
From source file:de.digiway.rapidbreeze.client.infrastructure.cnl.ClickAndLoadHandler.java
private boolean addLinks(HttpServletRequest request) throws IOException { String passwords = null;/* www .ja v a 2 s . c om*/ String source = null; String jk = null; String crypted = null; for (Map.Entry<String, String[]> entry : request.getParameterMap().entrySet()) { String value = entry.getValue()[0]; switch (entry.getKey().toLowerCase()) { case "passwords": passwords = value; break; case "source": source = value; break; case "jk": jk = value; break; case "crypted": crypted = value; break; } } if (jk != null) { Context cx = null; try { cx = ContextFactory.getGlobal().enterContext(); Scriptable scope = cx.initStandardObjects(); String fun = jk + " f()"; Object result = cx.evaluateString(scope, fun, "<cmd>", 1, null); byte[] key = hexStringToByteArray(Context.toString(result)); byte[] decoded = Base64.decode(crypted); String decryptedUrls = decrypt(decoded, key); String[] split = StringUtils.split(decryptedUrls, "\n"); if (split.length > 0) { List<URL> urls = new ArrayList<>(); for (String url : split) { String trimmed = url.trim(); if (!trimmed.isEmpty()) { urls.add(new URL(url)); } } LinkBundle lb = new LinkBundle(urls); RRB.get().send(BusEvents.ADD_LINK_BUNDLE, lb); Platform.runLater(new Runnable() { @Override public void run() { RRB.get().send(BusEvents.OPEN_DOWNLOAD_COLLECTOR_WINDOW); } }); return true; } } finally { if (cx != null) { Context.exit(); } } } return false; }
From source file:net.e2.bw.idreg.client.keycloak.KeycloakClient.java
/** {@inheritDoc} */ public AccessTokenData handleAuthServerCallback(HttpServletRequest request, String callbackUrl) throws AuthErrorException { Map<String, String[]> reqParams = request.getParameterMap(); if (reqParams.containsKey("error")) { // Handle errors received from the Keycloak server String errorMessage = reqParams.get("error")[0]; throw new AuthErrorException("Failed Keycloak authentication: " + errorMessage); } else if (reqParams.containsKey("code")) { String code = request.getParameter("code"); // Check the state parameter against the state cookie checkStateParam(request);//from ww w.j a va 2 s . com return executeAuthServerTokenRequest(code, callbackUrl, false); } else { // Invalid request throw new AuthErrorException("Invalid Keycloak callback request"); } }
From source file:mx.edu.um.mateo.contabilidad.web.EjercicioController.java
@RequestMapping(value = "/crea", method = RequestMethod.POST) public String crea(HttpServletRequest request, HttpServletResponse response, @Valid Ejercicio ejercicio, BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) { 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*/ if (bindingResult.hasErrors()) { log.debug("Hubo algun error en la forma, regresando"); for (ObjectError error : bindingResult.getAllErrors()) { log.debug("Error: {}", error); } return "admin/ejercicio/nueva"; } try { Usuario usuario = ambiente.obtieneUsuario(); ejercicio = ejercicioDao.crea(ejercicio, usuario); } catch (ConstraintViolationException e) { log.error("No se pudo crear al ejercicio", e); errors.rejectValue("id", "campo.duplicado.message", new String[] { "id" }, null); errors.rejectValue("nombre", "campo.duplicado.message", new String[] { "nombre" }, null); return "contabilidad/ejercicio/nuevo"; } redirectAttributes.addFlashAttribute("message", "ejercicio.creado.message"); redirectAttributes.addFlashAttribute("messageAttrs", new String[] { ejercicio.getNombre() }); return "redirect:/contabilidad/ejercicio/ver/" + ejercicio.getId().getIdEjercicio(); }