List of usage examples for org.springframework.http MediaType APPLICATION_FORM_URLENCODED_VALUE
String APPLICATION_FORM_URLENCODED_VALUE
To view the source code for org.springframework.http MediaType APPLICATION_FORM_URLENCODED_VALUE.
Click Source Link
From source file:de.otto.mongodb.profiler.web.OpProfileController.java
@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=startProfiling", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public View startProfiling(@PathVariable("connectionId") final String connectionId, @PathVariable("databaseName") final String databaseName, final UriComponentsBuilder uriComponentsBuilder) throws ResourceNotFoundException { getProfilerService().getOpProfiler(requireDatabase(connectionId, databaseName)).continueProfiling(); return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}") .fragment("OpProfiles").buildAndExpand(connectionId, databaseName).toUriString()); }
From source file:test.phoenixnap.oss.plugin.naming.SpringMvcResourceParserTest.java
@Test public void test_simpleGetAndPostWithOneParameter() { Resource testResource = baseResourceTestController.getResource("/base").getResource("/oneParameter"); assertEquals("Assert resources size", 2, testResource.getActions().size()); Action getAction = testResource.getActions().get(ActionType.GET); Action postAction = testResource.getActions().get(ActionType.POST); assertNotNull(getAction);//from ww w. j a va 2 s . c o m assertNotNull(postAction); validateSimpleAjaxResponse(getAction); validateSimpleAjaxResponse(postAction); assertEquals("Assert Javadoc", COMMENT_JAVADOC, getAction.getDescription()); assertEquals("Assert Javadoc", COMMENT_JAVADOC, postAction.getDescription()); // validate Get String paramName = "param1"; assertEquals("Check that parameter was placed in query", 1, getAction.getQueryParameters().size()); QueryParameter queryParameter = getAction.getQueryParameters().get(paramName); assertEquals("Check that parameter was placed in query", ParamType.STRING, queryParameter.getType()); assertEquals("Assert Javadoc", combineConstantAndName(PARAM_JAVADOC, paramName), queryParameter.getDescription()); assertEquals("Assert Javadoc", COMMENT_JAVADOC, getAction.getDescription()); // validate Post Map<String, List<FormParameter>> formParameters = postAction.getBody() .get(MediaType.APPLICATION_FORM_URLENCODED_VALUE).getFormParameters(); assertEquals("Check that parameter was placed in form", 1, formParameters.size()); FormParameter formParameter = formParameters.get(paramName).get(0); assertEquals("Assert Javadoc", combineConstantAndName(PARAM_JAVADOC, paramName), formParameter.getDescription()); assertEquals("Check that parameter type is correct", ParamType.STRING, formParameter.getType()); }
From source file:com.phoenixnap.oss.ramlapisync.data.ApiActionMetadata.java
public String getConsumes() { if (action.hasBody()) { String out = null;//from w ww . j a v a 2s. co m boolean first = true; // Special Case - ignore application/x-www-form-urlencoded in POST // since we will be treating them as request params for (String key : action.getBody().keySet()) { if (MediaType.APPLICATION_FORM_URLENCODED_VALUE.equals(key)) { continue; } if (first) { first = false; out = ""; } else { out += ","; } out += key; } return out; } return null; }
From source file:de.otto.mongodb.profiler.web.CollectionProfileController.java
@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=reset", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public View resetProfiles(@PathVariable("connectionId") final String connectionId, @PathVariable("databaseName") final String databaseName, final UriComponentsBuilder uriComponentsBuilder) throws Exception { requireProfiler(connectionId, databaseName).reset(); return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}") .fragment("Collections").buildAndExpand(connectionId, databaseName).toUriString()); }
From source file:de.otto.mongodb.profiler.web.OpProfileController.java
@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=stopProfiling", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public View stopProfiling(@PathVariable("connectionId") final String connectionId, @PathVariable("databaseName") final String databaseName, final UriComponentsBuilder uriComponentsBuilder) throws ResourceNotFoundException { getProfilerService().getOpProfiler(requireDatabase(connectionId, databaseName)).stopProfiling(); return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}") .fragment("OpProfiles").buildAndExpand(connectionId, databaseName).toUriString()); }
From source file:de.otto.mongodb.profiler.web.CollectionProfileController.java
@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=newSample", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public View takeSample(@PathVariable("connectionId") final String connectionId, @PathVariable("databaseName") final String databaseName, final UriComponentsBuilder uriComponentsBuilder) throws Exception { requireProfiler(connectionId, databaseName).newSample(); return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}") .fragment("Collections").buildAndExpand(connectionId, databaseName).toUriString()); }
From source file:org.jutge.joc.porra.controller.desktop.DesktopSignupController.java
@ReCaptchaConsumer @EntityStashManaged//from w w w . j av a 2 s. c o m @RequestMapping(value = "/nova-clau", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE) public String resetPassPost(@RequestBody final MultiValueMap<String, String> dataMap, final Model model, final HttpServletRequest request, final Locale locale) { this.logger.info("DesktopSignupController.resetPassPost"); // validation first final String name = dataMap.getFirst("usr"); final String email = dataMap.getFirst("mil"); request.setAttribute("usr", name); request.setAttribute("mil", email); final Boolean recaptchaIsValid = (Boolean) request.getAttribute(ReCaptchaUtils.RECAPTCHA_IS_VALID); final Account account = validateResetPassParams(name, email, recaptchaIsValid, locale); // Do actual reset this.accountService.resetAccount(account); this.emailService.sendPasswordResetMail(account); return "/desktop/signup/reset-done"; }
From source file:de.otto.mongodb.profiler.web.OpProfileController.java
@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=reset", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public View resetProfiles(@PathVariable("connectionId") final String connectionId, @PathVariable("databaseName") final String databaseName, final UriComponentsBuilder uriComponentsBuilder) throws ResourceNotFoundException { getProfilerService().getOpProfiler(requireDatabase(connectionId, databaseName)).reset(); return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}") .fragment("OpProfiles").buildAndExpand(connectionId, databaseName).toUriString()); }
From source file:de.otto.mongodb.profiler.web.OpProfileController.java
@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=changeProfilingLevel", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public View changeProfilingLevel(@PathVariable("connectionId") final String connectionId, @PathVariable("databaseName") final String databaseName, @RequestParam(value = "level") final Integer levelValue, final UriComponentsBuilder uriComponentsBuilder) throws ResourceNotFoundException { final OpProfiler.ProfilingLevel level = OpProfiler.ProfilingLevel.forValue(levelValue); if (level != null) { getProfilerService().getOpProfiler(requireDatabase(connectionId, databaseName)) .setProfilingLevel(level); }/* w ww. j a va 2 s.c o m*/ return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}") .fragment("OpProfiles").buildAndExpand(connectionId, databaseName).toUriString()); }
From source file:test.phoenixnap.oss.plugin.naming.SpringMvcResourceParserTest.java
@Test public void test_simpleGetAndPostWithTwoParameters() { String paramName;//w w w. j a v a 2 s.c o m Resource testResource = baseResourceTestController.getResource("/base").getResource("/twoParameter"); assertEquals("Assert resources size", 2, testResource.getActions().size()); Action getAction = testResource.getActions().get(ActionType.GET); Action postAction = testResource.getActions().get(ActionType.POST); assertNotNull(getAction); assertNotNull(postAction); validateSimpleAjaxResponse(getAction); validateSimpleAjaxResponse(postAction); // validate Get paramName = "param1"; assertEquals("Check that parameters were placed in query", 2, getAction.getQueryParameters().size()); QueryParameter queryParameter = getAction.getQueryParameters().get(paramName); assertEquals("Check that parameter was placed in query", ParamType.INTEGER, queryParameter.getType()); assertEquals("Assert Javadoc", combineConstantAndName(PARAM_JAVADOC, paramName), queryParameter.getDescription()); paramName = "nameOverride"; QueryParameter queryParameter2 = getAction.getQueryParameters().get(paramName); assertEquals("Check that parameter was placed in query", ParamType.STRING, queryParameter2.getType()); assertEquals("Check that parameter is required", true, queryParameter2.isRequired()); assertEquals("Assert Javadoc", combineConstantAndName(PARAM_JAVADOC, "param2"), queryParameter2.getDescription()); // validate Post paramName = "param1"; Map<String, List<FormParameter>> formParameters = postAction.getBody() .get(MediaType.APPLICATION_FORM_URLENCODED_VALUE).getFormParameters(); assertEquals("Check that parameter was placed in form", 2, formParameters.size()); FormParameter formParameter = formParameters.get(paramName).get(0); assertEquals("Check that parameter type is correct", ParamType.INTEGER, formParameter.getType()); assertEquals("Assert Javadoc", combineConstantAndName(PARAM_JAVADOC, paramName), formParameter.getDescription()); paramName = "nameOverride"; FormParameter formParameter2 = formParameters.get(paramName).get(0); assertEquals("Check that parameter type is correct", ParamType.STRING, formParameter2.getType()); assertEquals("Check that parameter is required", true, formParameter2.isRequired()); assertEquals("Assert Javadoc", combineConstantAndName(PARAM_JAVADOC, "param2"), formParameter2.getDescription()); }