List of usage examples for javax.servlet.http HttpServletRequest getParameterNames
public Enumeration<String> getParameterNames();
Enumeration
of String
objects containing the names of the parameters contained in this request. From source file:net.nan21.dnet.core.web.controller.workflow.WorkflowProcessInstanceController.java
/** * Start a new instance of the specified process definition * //from ww w. j a v a 2 s . c o m * @param processDefinitionId * @param processDefinitionKey * @param businessKey * @param request * @param response * @return * @throws Exception */ @SuppressWarnings("unchecked") @RequestMapping(value = "/start") @ResponseBody public String startInstance( @RequestParam(required = false, value = "processDefinitionId") String processDefinitionId, @RequestParam(required = false, value = "processDefinitionKey") String processDefinitionKey, @RequestParam(required = false, value = "businessKey") String businessKey, HttpServletRequest request, HttpServletResponse response) throws Exception { try { this.prepareRequest(request, response); ProcessInstance processInstance = null; Map<String, Object> variables = new HashMap<String, Object>(); Enumeration<String> it = request.getParameterNames(); while (it.hasMoreElements()) { String k = it.nextElement(); variables.put(k, request.getParameter(k)); } if (businessKey == null || businessKey.equals("")) { businessKey = UUID.randomUUID().toString().toUpperCase(); } variables.remove("processDefinitionId"); variables.remove("processDefinitionKey"); variables.remove("businessKey"); if (processDefinitionKey != null && !processDefinitionKey.equals("")) { processInstance = getWorkflowRuntimeService().startProcessInstanceByKey(processDefinitionKey, businessKey, variables); } else { processInstance = getWorkflowRuntimeService().startProcessInstanceById(processDefinitionId, businessKey, variables); } return "{\"success\":true, \"id\": \"" + processInstance.getId() + "\", \"processDefinitionId\": \"" + processInstance.getProcessDefinitionId() + "\",\"activityNames\": [],\"ended\": true }"; } catch (Exception e) { return this.handleException(e, response); } finally { this.finishRequest(); } }
From source file:edu.harvard.i2b2.fhir.oauth2.ws.OAuth2TokenEndpoint.java
@POST @Consumes("application/x-www-form-urlencoded") @Produces("application/json") public Response authorize(@Context HttpServletRequest request) throws OAuthSystemException, IOException, URISyntaxException { try {/* w ww.j ava2 s . c o m*/ logger.info("got url:" + request.getRequestURL()); Enumeration<String> kl = request.getParameterNames(); while (kl.hasMoreElements()) { String k = kl.nextElement(); logger.debug(k + "->" + request.getParameter(k)); } OAuthTokenRequest oauthRequest = new OAuthTokenRequest(request); OAuthIssuer oauthIssuerImpl = new OAuthIssuerImpl(new MD5Generator()); // find if AuthToken was issued, from db String authCode = oauthRequest.getCode(); AuthToken authToken = authTokenBean.find(authCode); if (authToken == null) { logger.debug("authToken is not found"); return buildBadAuthCodeResponse(); } logger.debug("authToken is " + authToken.toString()); // check if clientid is valid if (!checkClientId(oauthRequest.getClientId(), authToken)) { return buildInvalidClientIdResponse(); } // check if client_secret is valid if (!checkClientSecret(oauthRequest.getClientSecret())) { return buildInvalidClientSecretResponse(); } // do checking for different grant types if (oauthRequest.getParam(OAuth.OAUTH_GRANT_TYPE).equals(GrantType.AUTHORIZATION_CODE.toString())) { if (!checkAuthCode(authToken, oauthRequest.getParam(OAuth.OAUTH_CODE))) { return buildBadAuthCodeResponse(); } } else if (oauthRequest.getParam(OAuth.OAUTH_GRANT_TYPE).equals(GrantType.PASSWORD.toString())) { if (!checkUserPass(oauthRequest.getUsername(), oauthRequest.getPassword(), authToken)) { return buildInvalidUserPassResponse(); } } else if (oauthRequest.getParam(OAuth.OAUTH_GRANT_TYPE).equals(GrantType.REFRESH_TOKEN.toString())) { // refresh token is not supported in this implementation // buildInvalidUserPassResponse(); //buildAccessTokenNotSupportedResponse(); } logger.trace("authToken:" + authToken); String state = authToken.getState(); String patientId = authToken.getPatient(); AccessToken accessToken = accessTokenBean.createAccessTokenAndDeleteAuthToken(authToken); URI fhirBase = HttpHelper.getBasePath(request, serverConfigs); OAuthResponse response = OAuthASResponse.tokenResponse(HttpServletResponse.SC_OK) .setAccessToken(accessToken.getTokenString()).setExpiresIn("3600") .setScope(accessToken.getScope()).setParam("token_type", "Bearer").setParam("state", state) .setParam("patient", patientId)//"1000000005")//authToken.getPatient()) .setParam("need_patient_banner", "true") .setParam("smart_style_url", fhirBase.toString() + "smartstyleuri").buildJSONMessage(); logger.trace("pat:" + authToken.getPatient()); logger.info("returning res:" + response.getBody()); return Response.status(response.getResponseStatus()).entity(response.getBody()).build(); } catch (OAuthProblemException e) { logger.error(e.getMessage(), e); OAuthResponse res = OAuthASResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST).error(e) .buildJSONMessage(); return Response.status(res.getResponseStatus()).entity(res.getBody()).build(); } }
From source file:com.npower.dl.OMADownloadServlet.java
/** * @param request/*from ww w. ja va 2 s. com*/ */ private void logRequest(HttpServletRequest request) { Enumeration<String> names = request.getHeaderNames(); while (names.hasMoreElements()) { String name = names.nextElement(); String value = request.getHeader(name); log.info("Http header: " + name + "=" + value); } names = request.getParameterNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); String value = request.getHeader(name); log.info("Http param: " + name + "=" + value); } }
From source file:org.addsimplicity.anicetus.web.TelemetryServletFilter.java
@SuppressWarnings("unchecked") private void setRequestOnSession(TelemetryHttpSession session, HttpServletRequest request) { session.setMethod(request.getMethod()); session.setProtocol(request.getProtocol()); if (request.getContentType() != null) { session.setContentType(request.getContentType(), HeaderType.Request); }//from w w w. j a va 2 s. co m session.setRequestURL(request.getRequestURI()); Enumeration<String> pnames = request.getParameterNames(); while (pnames.hasMoreElements()) { String name = pnames.nextElement(); session.setParameter(name, request.getParameter(name)); } Enumeration<String> hnames = request.getHeaderNames(); while (hnames.hasMoreElements()) { String name = hnames.nextElement(); String value = request.getHeader(name); if (value != null) { session.setHeader(name, request.getHeader(name), HeaderType.Request); } } String parent = request.getHeader(s_PARENT_NAME); if (parent == null) { parent = request.getParameter(s_PARENT_NAME); } if (parent != null) { try { UUID parentId = UUID.fromString(parent); session.setParentId(parentId); } catch (IllegalArgumentException iae) { // TODO - Exception handler } } }
From source file:psiprobe.controllers.jsp.RecompileJspController.java
@Override protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(false); Summary summary = (Summary) session.getAttribute(DisplayJspController.SUMMARY_ATTRIBUTE); if (request.getMethod().equalsIgnoreCase("post") && summary != null) { List<String> names = new ArrayList<>(); for (String name : Collections.list(request.getParameterNames())) { if ("on".equals(request.getParameter(name))) { names.add(name);/* www. j a va2 s.com*/ } } getContainerWrapper().getTomcatContainer().recompileJsps(context, summary, names); session.setAttribute(DisplayJspController.SUMMARY_ATTRIBUTE, summary); } else if (summary != null && contextName.equals(summary.getName())) { String name = ServletRequestUtils.getStringParameter(request, "source", null); if (name != null) { List<String> names = new ArrayList<>(); names.add(name); getContainerWrapper().getTomcatContainer().recompileJsps(context, summary, names); session.setAttribute(DisplayJspController.SUMMARY_ATTRIBUTE, summary); } else { logger.error("source is not passed, nothing to do"); } } return new ModelAndView(new RedirectView( request.getContextPath() + ServletRequestUtils.getStringParameter(request, "view", getViewName()) + "?" + request.getQueryString())); }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.search.AbstractSearchController.java
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command) throws Exception { logger.debug("Search scenario controller"); ModelAndView mav = new ModelAndView(getSuccessView()); List<String> source = new ArrayList<String>(); List<String> condition = new ArrayList<String>(); List<String> andOr = new ArrayList<String>(); Enumeration enumer = request.getParameterNames(); while (enumer.hasMoreElements()) { String param = (String) enumer.nextElement(); if (param.startsWith("source")) { source.add(param);/* w w w .j a va2 s. co m*/ } else if (param.startsWith("condition")) { condition.add(param); } else { andOr.add(param); } } Collections.sort(andOr); Collections.sort(source); Collections.sort(condition); requests = new ArrayList<SearchRequest>(); requests.add(new SearchRequest(request.getParameter(condition.get(0)), (request.getParameter(source.get(0))), "")); for (int i = 1; i < condition.size(); i++) { requests.add(new SearchRequest(request.getParameter(condition.get(i)), (request.getParameter(source.get(i))), (request.getParameter(andOr.get(i - 1))))); } return mav; }
From source file:com.googlecode.psiprobe.controllers.jsp.RecompileJspController.java
protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); Summary summary = session != null ? (Summary) session.getAttribute(DisplayJspController.SUMMARY_ATTRIBUTE) : null;//from w w w . java 2 s . c om if (request.getMethod().equalsIgnoreCase("post") && summary != null) { List names = new ArrayList(); for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); if ("on".equals(request.getParameter(name))) { names.add(name); } } getContainerWrapper().getTomcatContainer().recompileJsps(context, summary, names); session.setAttribute(DisplayJspController.SUMMARY_ATTRIBUTE, summary); } else if (summary != null && contextName.equals(summary.getName())) { String name = ServletRequestUtils.getStringParameter(request, "source", null); if (name != null) { List names = new ArrayList(); names.add(name); getContainerWrapper().getTomcatContainer().recompileJsps(context, summary, names); session.setAttribute(DisplayJspController.SUMMARY_ATTRIBUTE, summary); } else { logger.error("source is not passed, nothing to do"); } } return new ModelAndView(new RedirectView( request.getContextPath() + ServletRequestUtils.getStringParameter(request, "view", getViewName()) + "?" + request.getQueryString())); }
From source file:org.dhara.portal.web.controllers.WorkflowMonitorController.java
@RequestMapping(value = { "/admin/monitoring", "/admin/monitoring/" }, method = RequestMethod.GET) protected String handleRequestInternal(@RequestParam(required = false) final String action, @RequestParam(required = false) String referringPageId, Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { addNavigationMenusToModel(SELECTED_ITEM, model, referringPageId); String workflowName = request.getParameter("workflowId"); List<InputHelper> inputHelperList = new ArrayList<InputHelper>(); //Get user specified inputs from the form Enumeration enumeration = request.getParameterNames(); while (enumeration.hasMoreElements()) { String temp = (String) enumeration.nextElement(); if (temp.equalsIgnoreCase("workflowId")) ;/*from w ww .j ava2 s .co m*/ else { InputHelper inputHelper = new InputHelper(); inputHelper.setRawName(temp); inputHelper.setName(temp.split("/")[0]); inputHelper.setType(temp.split("/")[1]); inputHelper.setValues(request.getParameterValues(temp)); inputHelperList.add(inputHelper); } } List<UserInputHelper> inputs = new ArrayList<UserInputHelper>(); for (InputHelper in : inputHelperList) { UserInputHelper userInputHelper = new UserInputHelper(); userInputHelper.setName(in.getName()); for (int i = 0; i < in.getValues().length; i++) { userInputHelper.setValue(in.getValues()[i]); } inputs.add(userInputHelper); } Object[] ints = inputs.toArray(); //Start workflow monitoring Runnable monitorThread = new MonitorThread(airavataClientAPIService, workflowName, ints); String id = ((MonitorThread) monitorThread).getExperimentId(); PortalConfiguration.executor.execute(monitorThread); model.addAttribute("id", id); model.addAttribute("workflowId", workflowName); return "templates.admin.monitoring"; }
From source file:at.gv.egovernment.moa.id.auth.servlet.AuthServlet.java
/** * Logs all servlet parameters for debugging purposes. */// w w w .j a v a2 s .c om protected void logParameters(HttpServletRequest req) { for (Enumeration params = req.getParameterNames(); params.hasMoreElements();) { String parname = (String) params.nextElement(); Logger.debug("Parameter " + parname + req.getParameter(parname)); } }
From source file:com.mockey.ui.ServiceMergeServlet.java
/** * //from ww w . j ava2 s .co m * * @param req * basic request * @param resp * basic resp * @throws ServletException * basic * @throws IOException * basic */ @SuppressWarnings("unchecked") public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Boolean originalMode = store.getReadOnlyMode(); store.setReadOnlyMode(true); String[] serviceMergeIdList = req.getParameterValues("serviceIdMergeSource[]"); Enumeration<String> names = (Enumeration<String>) req.getParameterNames(); while (names.hasMoreElements()) { log.debug(names.nextElement()); } Long serviceIdMergeSource = null; Long serviceIdMergeDestination = null; ServiceMergeResults mergeResults = null; Map<String, String> responseMap = new HashMap<String, String>(); try { for (int i = 0; i < serviceMergeIdList.length; i++) { serviceIdMergeSource = new Long(serviceMergeIdList[i]); serviceIdMergeDestination = new Long(req.getParameter("serviceIdMergeDestination")); if (!serviceIdMergeSource.equals(serviceIdMergeDestination)) { Service serviceMergeSource = store.getServiceById(serviceIdMergeSource); Service serviceMergeDestination = store.getServiceById(serviceIdMergeDestination); MockeyXmlFileManager configurationReader = new MockeyXmlFileManager(); mergeResults = configurationReader.mergeServices(serviceMergeSource, serviceMergeDestination, mergeResults, null); } responseMap.put("additions", mergeResults.getAdditionMsg()); responseMap.put("conflicts", mergeResults.getConflictMsg()); } } catch (Exception e) { // Do nothing log.error("Something wrong with merging services.", e); responseMap.put("conflicts", "Unable to merge services. The services selected may be missing or contain bad data. Sorry about this."); } // IF NO CONFLICTS, THEN DELETE OLD SOURCE SERVICES if (mergeResults != null && (mergeResults.getConflictMsgs() == null || mergeResults.getConflictMsgs().isEmpty())) { for (int i = 0; i < serviceMergeIdList.length; i++) { serviceIdMergeSource = new Long(serviceMergeIdList[i]); Service service = store.getServiceById(serviceIdMergeSource); store.deleteService(service); } } resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); String resultingJSON = Util.getJSON(responseMap); out.println(resultingJSON); out.flush(); out.close(); store.setReadOnlyMode(originalMode); return; // AJAX thing. Return nothing at this time. }