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:com.restfiddle.handler.http.builder.RfRequestBuilder.java
private void setRequestEntity(RfRequestDTO requestDTO, RequestBuilder requestBuilder) { List<FormDataDTO> formParams = requestDTO.getFormParams(); if (requestDTO.getApiBody() != null && !requestDTO.getApiBody().isEmpty()) { try {/*from w ww.j a v a 2 s .c o m*/ requestBuilder.setEntity(new StringEntity(requestDTO.getApiBody())); } catch (UnsupportedEncodingException e) { logger.error(e.getMessage(), e); } } else if (formParams != null && !formParams.isEmpty()) { // NOTE : http://stackoverflow.com/questions/12745710/apache-httpclient-4-2-1-post-request-to-fill-form-after-successful-login requestBuilder.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); List<NameValuePair> nvps2 = new ArrayList<NameValuePair>(); for (FormDataDTO formDataDTO : formParams) { nvps2.add(new BasicNameValuePair(formDataDTO.getKey(), formDataDTO.getValue())); } try { requestBuilder.setEntity(new UrlEncodedFormEntity(nvps2)); } catch (UnsupportedEncodingException e) { } } }
From source file:com.phoenixnap.oss.ramlapisync.data.ApiActionMetadata.java
private void collectBodyParams(Entry<String, RamlMimeType> mime) { if (mime.getKey().equals(MediaType.MULTIPART_FORM_DATA_VALUE) && ResourceParser.doesActionTypeSupportMultipartMime(actionType)) { collectRequestParamsForMime(action.getBody().get(MediaType.MULTIPART_FORM_DATA_VALUE)); } else if (mime.getKey().equals(MediaType.APPLICATION_FORM_URLENCODED_VALUE) && ResourceParser.doesActionTypeSupportMultipartMime(actionType)) { collectRequestParamsForMime(action.getBody().get(MediaType.APPLICATION_FORM_URLENCODED_VALUE)); }//from ww w . j a va 2 s . c om if (ResourceParser.doesActionTypeSupportRequestBody(actionType) && mime.getKey().toLowerCase().contains("json")) { // Continue here! String schema = mime.getValue().getSchema(); if (StringUtils.hasText(schema)) { ApiBodyMetadata requestBody = SchemaHelper.mapSchemaToPojo(parent.getDocument(), schema, parent.getBasePackage() + NamingHelper.getDefaultModelPackage(), StringUtils.capitalize(getName()) + "Request", null); if (requestBody != null) { setRequestBody(requestBody, mime.getKey()); } } } }
From source file:org.mitreid.multiparty.web.ResourceController.java
@RequestMapping(value = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @PreAuthorize("hasRole('ROLE_USER')") public String createResource(@RequestParam("label") String label, @RequestParam("value") String value, Principal p) {//from www . j a va 2 s.c om if (!Strings.isNullOrEmpty(label) && !Strings.isNullOrEmpty(value)) { // create a unique resource for the current user (use principal name?) Resource res = new Resource(); res.label = label; res.value = value; // give it a random ID res.id = new RandomValueStringGenerator().generate(); // save it into the store resourceService.addResource(res, p); // redirect back to the home page } return "redirect:"; }
From source file:de.otto.mongodb.profiler.web.CollectionProfileController.java
@Page(mainNavigation = MainNavigation.DATABASES) @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public ModelAndView addCollectionProfile( @Valid @ModelAttribute("collection") AddCollectionProfileFormModel model, final BindingResult bindingResult, @PathVariable("connectionId") final String connectionId, @PathVariable("databaseName") final String databaseName, final UriComponentsBuilder uriComponentsBuilder) throws ResourceNotFoundException { final ProfiledDatabase database = requireDatabase(connectionId, databaseName); if (bindingResult.hasErrors()) { return showDatabasePageWith(model, database); }// w w w .j a v a 2s . com final CollectionProfiler collectionProfiler = getProfilerService().getCollectionProfiler(database); final String uri; if (Boolean.TRUE.equals(model.getAddAll())) { final Set<String> collections = collectionProfiler.getAvailableCollections(); for (String collection : collections) { try { collectionProfiler.addProfile(collection); } catch (CollectionDoesNotExistException e) { logger.debug(e, "Failed to add collection [%s]", collection); } } uri = uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}/collections") .buildAndExpand(connectionId, databaseName).toUriString(); } else { final CollectionProfile collectionProfile; try { collectionProfile = collectionProfiler.addProfile(model.getName()); } catch (CollectionDoesNotExistException e) { logger.debug(e, "Failed to add collection [%s]", model.getName()); bindingResult.rejectValue("name", "collectionDoesNotExist"); return showDatabasePageWith(model, database); } uri = uriComponentsBuilder .path("/connections/{connectionId}/databases/{databaseName}/collections/{collectionName}") .buildAndExpand(connectionId, databaseName, collectionProfile.getCollectionName()) .toUriString(); } return new ModelAndView(new RedirectView(uri)); }
From source file:de.otto.mongodb.profiler.web.DatabaseController.java
@RequestMapping(value = "/{name:.+}/control", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, params = "action=remove") public View removeDatabase(@PathVariable("connectionId") final String connectionId, @PathVariable("name") final String databaseName, final UriComponentsBuilder uriComponentsBuilder) throws ResourceNotFoundException { final ProfiledDatabase database = requireDatabase(connectionId, databaseName); getProfilerService().removeDatabase(database); final String uri = uriComponentsBuilder.path("/connections/{id}").buildAndExpand(connectionId) .toUriString();/*from w w w .j ava 2s. c om*/ return new RedirectView(uri); }
From source file:org.mitreid.multiparty.web.ResourceController.java
@RequestMapping(value = "/share", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @PreAuthorize("hasRole('ROLE_USER')") public String shareResource(@RequestParam("issuer") String issuer, Principal p, HttpSession session) { // load the resource SharedResourceSet oldSharedResourceSet = resourceService.getSharedResourceSetForUser(p); // discover/load the auth server configuration MultipartyServerConfiguration server = serverConfig.getServerConfiguration(issuer); // load client configuration (register if needed) RegisteredClient client = clientConfig.getClientConfiguration(server); // get an access token (this might redirect) String accessTokenValue = acccessTokenService.getAccessToken(server, client); if (Strings.isNullOrEmpty(accessTokenValue)) { // we don't have an access token yet, let's go get one // first save what we're working on so we can come back to it session.setAttribute("SHARE_ISSUER", issuer); return redirectForPAT(server, client, session); } else {/*from w w w. ja v a 2s.c om*/ // unregister the old set if (oldSharedResourceSet != null) { unregisterOldResourceSet(oldSharedResourceSet, accessTokenValue, p); } // register the resource set registerResourceSet(p, issuer, server, accessTokenValue); // redirect back to home page return "redirect:"; } }
From source file:com.phoenixnap.oss.ramlapisync.data.ApiMappingMetadata.java
public Set<ApiParameterMetadata> getResponse() { if (requestParameters != null) { return requestParameters; }// w ww . j a v a 2s .c o m requestParameters = new LinkedHashSet<>(); for (Entry<String, QueryParameter> param : action.getQueryParameters().entrySet()) { requestParameters.add(new ApiParameterMetadata(param.getKey(), param.getValue())); } if (ActionType.POST.equals(actionType) && action.getBody() != null && action.getBody().containsKey(MediaType.APPLICATION_FORM_URLENCODED_VALUE)) { MimeType requestBody = action.getBody().get(MediaType.APPLICATION_FORM_URLENCODED_VALUE); for (Entry<String, List<FormParameter>> params : requestBody.getFormParameters().entrySet()) { for (FormParameter param : params.getValue()) { requestParameters.add(new ApiParameterMetadata(params.getKey(), param)); } } } if (ResourceParser.doesActionTypeSupportRequestBody(actionType) && action.getBody() != null && !action.getBody().isEmpty()) { for (Entry<String, MimeType> body : action.getBody().entrySet()) { if (body.getKey().toLowerCase().contains("json")) { // Continue here! String schema = body.getValue().getSchema(); if (StringUtils.hasText(schema)) { ApiBodyMetadata requestBody = SchemaHelper.mapSchemaToPojo(parent.getDocument(), schema, parent.getBasePackage() + ".requestObjects", getName() + "Request"); if (requestBody != null) { setRequestBody(requestBody); } } } } } return requestParameters; }
From source file:de.otto.mongodb.profiler.web.CollectionProfileController.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 Exception { requireProfiler(connectionId, databaseName).continueProfiling(); return new RedirectView(uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}") .fragment("Collections").buildAndExpand(connectionId, databaseName).toUriString()); }
From source file:de.otto.mongodb.profiler.web.CollectionProfileController.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 Exception { requireProfiler(connectionId, databaseName).stopProfiling(); 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
@EntityStashManaged @RequestMapping(value = "/apuntar-se/activar/{activationToken}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE) public String activatePost(@PathVariable final String activationToken, @RequestBody final MultiValueMap<String, String> dataMap, final HttpServletRequest request, final Locale locale) { this.logger.info("DesktopSignupController.activatePost"); final Account account = this.validateAccountToken(activationToken, locale); request.setAttribute("userName", account.getName()); request.setAttribute("activationToken", activationToken); // validate params final String password = dataMap.getFirst("pwd"); final String passwordConfirm = dataMap.getFirst("pwd-con"); account.setHashedPass(password);// w w w .j ava2s .c o m this.validatePassword(account, passwordConfirm, locale); this.accountService.approveAccount(account); return "/desktop/signup/activate-done"; }