Example usage for javax.servlet.http HttpServletRequest getParameterMap

List of usage examples for javax.servlet.http HttpServletRequest getParameterMap

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getParameterMap.

Prototype

public Map<String, String[]> getParameterMap();

Source Link

Document

Returns a java.util.Map of the parameters of this request.

Usage

From source file:fr.paris.lutece.plugins.workflow.modules.appointment.service.TaskManualAppointmentNotification.java

/**
 * {@inheritDoc}//from ww w .j  a  va  2 s  . com
 */
@Override
public void processTask(int nIdResourceHistory, HttpServletRequest request, Locale locale) {
    ResourceHistory resourceHistory = _resourceHistoryService.findByPrimaryKey(nIdResourceHistory);
    Appointment appointment = AppointmentHome.findByPrimaryKey(resourceHistory.getIdResource());

    Map<String, String[]> parameters = request.getParameterMap();
    String strCancelMotif = null;
    for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
        if (entry.getKey().startsWith("comment_value_")) {
            String[] tabAllParamsStartedWithCommentValue = entry.getValue();
            strCancelMotif = tabAllParamsStartedWithCommentValue[0];
            break;
        }
    }

    String strSenderName = request.getParameter(PARAMETER_SENDER_NAME);
    String strSenderEmail = request.getParameter(PARAMETER_SENDER_EMAIL);
    String strCc = request.getParameter(PARAMETER_CC);
    String strBcc = request.getParameter(PARAMETER_BCC);
    String strMessage = request.getParameter(PARAMETER_MESSAGE);
    String strSubject = request.getParameter(PARAMETER_SUBJECT);
    boolean bSendICalNotif = Boolean.valueOf(request.getParameter(PARAMETER_SEND_ICAL_NOTIF));

    if (StringUtils.isBlank(strSenderName)) {
        strSenderName = MailService.getNoReplyEmail();
    }

    NotifyAppointmentDTO notifyAppointmentDTO = new NotifyAppointmentDTO();
    notifyAppointmentDTO.setMessage(strMessage);
    notifyAppointmentDTO.setRecipientsCc(strCc);
    notifyAppointmentDTO.setRecipientsBcc(strBcc);
    notifyAppointmentDTO.setSubject(strSubject);
    notifyAppointmentDTO.setSenderName(strSenderName);
    notifyAppointmentDTO.setCancelMotif(strCancelMotif);
    // We do not check the email nor the sender name since it's done by the sendEmail( ... ) method.
    notifyAppointmentDTO.setSenderEmail(strSenderEmail);
    notifyAppointmentDTO.setSendICalNotif(bSendICalNotif);

    if (bSendICalNotif) {
        String strLocation = request.getParameter(PARAMETER_LOCATION);
        notifyAppointmentDTO.setLocation(strLocation);
        notifyAppointmentDTO.setCreateNotif(Boolean.parseBoolean(request.getParameter(PARAMETER_CREATE_NOTIF)));
    }

    String strEmail = null;

    if (notifyAppointmentDTO.getIsSms()) {
        strEmail = getEmailForSmsFromAppointment(appointment);
    } else {
        strEmail = appointment.getEmail();
    }

    if (StringUtils.isNotBlank(strEmail)) {
        EmailDTO emailDTO = this.sendEmail(appointment, resourceHistory, request, locale, notifyAppointmentDTO,
                strEmail);

        if (emailDTO != null) {
            ManualAppointmentNotificationHistory history = new ManualAppointmentNotificationHistory();
            history.setIdHistory(resourceHistory.getId());
            history.setIdAppointment(resourceHistory.getIdResource());
            history.setEmailTo(appointment.getEmail());
            history.setEmailSubject(emailDTO.getSubject());
            history.setEmailMessage(emailDTO.getContent());
            ManualAppointmentNotificationHistoryHome.create(history);
        }
    }
}

From source file:com.mmj.app.common.pipeline.value.BaseWebUserBuilderValve.java

protected PipelineResult getToLogin(HttpServletRequest request, HttpServletResponse response, String uri)
        throws Exception {
    String url = loginUrl;/*from   w w  w  . j  a va 2s . c  o m*/
    // ????returnurl
    if (request.getParameterMap().isEmpty() && !StringUtils.contains("/login", uri)) {
        url = loginUrl + "?returnurl=" + uri;
    }
    return PipelineResult.gotoAfterCompletion("gotoLogin", url);
}

From source file:com.microsoft.aad.adal4jsample.BasicFilter.java

private void processAuthenticationData(HttpServletRequest httpRequest, String currentUri, String fullUrl)
        throws Throwable {
    Map<String, String> params = new HashMap();
    for (String key : httpRequest.getParameterMap().keySet()) {
        params.put(key, httpRequest.getParameterMap().get(key)[0]);
    }/*from   w w  w .  j  av a2 s. co  m*/
    // validate that state in response equals to state in request
    StateData stateData = validateState(httpRequest.getSession(), params.get(STATE));

    AuthenticationResponse authResponse = AuthenticationResponseParser.parse(new URI(fullUrl), params);
    if (AuthHelper.isAuthenticationSuccessful(authResponse)) {
        AuthenticationSuccessResponse oidcResponse = (AuthenticationSuccessResponse) authResponse;
        // validate that OIDC Auth Response matches Code Flow (contains only requested artifacts)
        validateAuthRespMatchesCodeFlow(oidcResponse);

        AuthenticationResult authData = getAccessToken(oidcResponse.getAuthorizationCode(), currentUri);
        // validate nonce to prevent reply attacks (code maybe substituted to one with broader access)
        validateNonce(stateData, getClaimValueFromIdToken(authData.getIdToken(), "nonce"));

        setSessionPrincipal(httpRequest, authData);
    } else {
        AuthenticationErrorResponse oidcResponse = (AuthenticationErrorResponse) authResponse;
        throw new Exception(String.format("Request for auth code failed: %s - %s",
                oidcResponse.getErrorObject().getCode(), oidcResponse.getErrorObject().getDescription()));
    }
}

From source file:com.tc.admin.UpdateCheckRequestTest.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    response.setContentType("text/html");
    response.setStatus(HttpServletResponse.SC_OK);

    String[] expectedParams = { "kitID", "pageID", "id", "os-name", "jvm-name", "jvm-version", "platform",
            "tc-version", "tc-product", "source" };
    Map paramMap = request.getParameterMap();
    for (String expectedParam : expectedParams) {
        if (paramMap.get(expectedParam) == null) {
            response.getWriter().println("Missing parameter '" + expectedParam + "'");
            return;
        }/*from www  .ja v  a2 s.c o m*/
    }
    if (paramMap.size() != expectedParams.length) {
        response.getWriter()
                .println("Parameter count doesn't match expected count='" + expectedParams.length + "'");
        return;
    }
    response.getWriter().println("OK");
}

From source file:mx.edu.um.mateo.general.web.ClienteController.java

@RequestMapping(value = "/crea", method = RequestMethod.POST)
public String crea(HttpServletRequest request, HttpServletResponse response, @Valid Cliente cliente,
        BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }//from  www  . j a  va2  s  . c o  m
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");

        Map<String, Object> params = new HashMap<>();
        params.put("empresa", request.getSession().getAttribute("empresaId"));
        params.put("reporte", true);
        params = tipoClienteDao.lista(params);
        modelo.addAttribute("tiposDeCliente", params.get("tiposDeCliente"));

        return "admin/cliente/nuevo";
    }

    try {
        Usuario usuario = ambiente.obtieneUsuario();
        log.debug("TipoCliente: {}", cliente.getTipoCliente().getId());
        cliente = clienteDao.crea(cliente, usuario);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo crear al cliente", e);
        errors.rejectValue("nombre", "campo.duplicado.message", new String[] { "nombre" }, null);

        Map<String, Object> params = new HashMap<>();
        params.put("empresa", request.getSession().getAttribute("empresaId"));
        params.put("reporte", true);
        params = tipoClienteDao.lista(params);
        modelo.addAttribute("tiposDeCliente", params.get("tiposDeCliente"));

        return "admin/cliente/nuevo";
    }

    redirectAttributes.addFlashAttribute("message", "cliente.creado.message");
    redirectAttributes.addFlashAttribute("messageAttrs", new String[] { cliente.getNombre() });

    return "redirect:/admin/cliente/ver/" + cliente.getId();
}

From source file:net.shibboleth.idp.oidc.flow.BuildAuthorizationRequestContextAction.java

/**
 * Create authorization request authorization request.
 *
 * @param request the request/*from  w ww. j ava 2  s  .c om*/
 * @return the authorization request
 */
private AuthorizationRequest createAuthorizationRequest(final HttpServletRequest request) {
    log.debug("Constructing authorization request");
    final Map<String, String> requestParameters = createRequestMap(request.getParameterMap());
    return authRequestFactory.createAuthorizationRequest(requestParameters);
}

From source file:com.alibaba.citrus.service.requestcontext.parser.impl.ParameterParserImpl.java

/** servlet engine??? */
private void parseByServletEngine(HttpServletRequest wrappedRequest) {
    @SuppressWarnings("unchecked")
    Map<String, String[]> parameters = wrappedRequest.getParameterMap();

    if (parameters != null && parameters.size() > 0) {
        for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
            String key = entry.getKey();
            String[] values = entry.getValue();

            for (String value : values) {
                add(key, value);//  w ww . j a  va2s. c  om
            }
        }
    }
}

From source file:com.trsvax.jacquard.services.EMultipartDecoderImpl.java

protected HttpServletRequest processFileItems(HttpServletRequest request, List<FileItem> fileItems) {
    if (uploadException == null && fileItems.isEmpty()) {
        return request;
    }/*from   ww w  .  j  av a 2s  .c om*/

    ParametersServletRequestWrapper wrapper = new ParametersServletRequestWrapper(request);

    // First add parameters from the request
    for (Object e : request.getParameterMap().entrySet()) {
        Map.Entry<String, String[]> ee = (Map.Entry<String, String[]>) e;
        for (String s : ee.getValue())
            wrapper.addParameter(ee.getKey(), s);
    }

    for (FileItem item : fileItems) {
        if (item.isFormField()) {
            String fieldValue;

            try {

                fieldValue = item.getString(requestEncoding);
            } catch (UnsupportedEncodingException ex) {
                throw new RuntimeException(ex);
            }

            wrapper.addParameter(item.getFieldName(), fieldValue);
        } else {
            wrapper.addParameter(item.getFieldName(), item.getName());
            addUploadedFile(item.getFieldName(), new UploadedFileItem(item));
        }
    }

    return wrapper;
}

From source file:fr.paris.lutece.plugins.extend.modules.comment.web.component.CommentResourceExtenderComponent.java

/**
 * {@inheritDoc}/*from w  ww . j ava2  s.c  o  m*/
 */
@Override
public String getPostBackUrl(HttpServletRequest request) {
    UrlItem urlItem = new UrlItem(request.getRequestURI());
    Map<String, String[]> mapParameters = new HashMap<String, String[]>(request.getParameterMap());
    // We ignore some parameters : those parameter will be set regardlessly of the post pack URL
    mapParameters.remove(CommentConstants.MARK_ID_EXTENDABLE_RESOURCE);
    mapParameters.remove(CommentConstants.MARK_EXTENDABLE_RESOURCE_TYPE);
    mapParameters.remove(CommentConstants.PARAMETER_EXTENDER_TYPE);
    mapParameters.remove(CommentConstants.PARAMETER_FROM_URL);
    mapParameters.remove(CommentConstants.PARAMETER_ID_COMMENT);
    mapParameters.remove(Paginator.PARAMETER_PAGE_INDEX);
    mapParameters.remove(Paginator.PARAMETER_ITEMS_PER_PAGE);
    mapParameters.remove(Parameters.SORTED_ATTRIBUTE_NAME);
    mapParameters.remove(Parameters.SORTED_ASC);
    for (Entry<String, String[]> entry : mapParameters.entrySet()) {
        urlItem.addParameter(entry.getKey(), entry.getValue()[0]);
    }
    return urlItem.getUrl();
}

From source file:com.intouch.processor.RequestProcessor.java

public JSONObject processRequest(HttpServletRequest request) throws Exception {
    InputStream inputStream = request.getServletContext()
            .getResourceAsStream("/WEB-INF/resourse/properties/prop.properties");
    Properties properties = new Properties();
    properties.load(inputStream);/*from  w ww  . j  a v  a2  s .  c o  m*/
    Class cls = Class.forName(properties.getProperty(request.getParameter("method")));
    Processor processor = (Processor) cls.newInstance();
    inputStream.close();
    return processor.processRequest(request.getParameterMap());
}