List of usage examples for org.springframework.http HttpMethod POST
HttpMethod POST
To view the source code for org.springframework.http HttpMethod POST.
Click Source Link
From source file:com.orange.ngsi.client.NgsiRestClient.java
/** * Append attributes to a context element * @param url the URL of the broker//w w w. j a v a2s. c o m * @param httpHeaders the HTTP header to use, or null for default * @param entityID the ID of the entity * @param appendContextElement attributes to append * @return a future for an AppendContextElementResponse */ public ListenableFuture<AppendContextElementResponse> appendContextElement(String url, HttpHeaders httpHeaders, String entityID, AppendContextElement appendContextElement) { return request(HttpMethod.POST, url + entitiesPath + entityID, httpHeaders, appendContextElement, AppendContextElementResponse.class); }
From source file:io.github.restdocsext.jersey.operation.preprocess.BinaryPartPlaceholderOperationPreprocessorTest.java
@Test public void replace_binary_multipart_content_with_placeholder() { OperationRequestPart part1 = this.partFactory.create("field1", "file1.png", "BinaryContent".getBytes(), new HttpHeaders()); OperationRequestPart part2 = this.partFactory.create("field2", null, "TextContent".getBytes(), new HttpHeaders()); final OperationRequest request = this.requestFactory.create(URI.create("http://localhost"), HttpMethod.POST, null, new HttpHeaders(), new Parameters(), Arrays.asList(part1, part2)); this.preprocessor.field("field1", "<<placeholder>>"); final OperationRequest preprocessed = this.preprocessor.preprocess(request); final Collection<OperationRequestPart> parts = preprocessed.getParts(); assertThat(hasPart(parts, "field1", "<<placeholder>>"), is(true)); assertThat(hasPart(parts, "field2", "TextContent"), is(true)); }
From source file:com.marklogic.mgmt.admin.AdminManager.java
public void init(String licenseKey, String licensee) { final URI uri = adminConfig.buildUri("/admin/v1/init"); String json = null;/* w w w . j a va2 s . c o m*/ if (licenseKey != null && licensee != null) { json = format("{\"license-key\":\"%s\", \"licensee\":\"%s\"}", licenseKey, licensee); } else { json = "{}"; } final String payload = json; logger.info("Initializing MarkLogic at: " + uri); invokeActionRequiringRestart(new ActionRequiringRestart() { @Override public boolean execute() { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<String> entity = new HttpEntity<String>(payload, headers); try { ResponseEntity<String> response = restTemplate.exchange(uri, HttpMethod.POST, entity, String.class); logger.info("Initialization response: " + response); // According to http://docs.marklogic.com/REST/POST/admin/v1/init, a 202 is sent back in the event a // restart is needed. A 400 or 401 will be thrown as an error by RestTemplate. return HttpStatus.ACCEPTED.equals(response.getStatusCode()); } catch (HttpClientErrorException hcee) { String body = hcee.getResponseBodyAsString(); if (logger.isTraceEnabled()) { logger.trace("Response body: " + body); } if (body != null && body.contains("MANAGE-ALREADYINIT")) { logger.info("MarkLogic has already been initialized"); return false; } else { logger.error("Caught error, response body: " + body); throw hcee; } } } }); }
From source file:rest.json.Application.java
@Bean public HttpRequestHandlingMessagingGateway httpGate() { HttpRequestHandlingMessagingGateway gateway = new HttpRequestHandlingMessagingGateway(true); RequestMapping mapping = new RequestMapping(); mapping.setMethods(HttpMethod.POST); mapping.setPathPatterns("/foo"); gateway.setRequestMapping(mapping);/*from www. j a v a 2 s.c o m*/ gateway.setRequestChannel(requestChannel()); gateway.setRequestPayloadType(String.class); return gateway; }
From source file:fragment.web.AccessDecisionTest.java
@Test public void testAnonymousUrls() throws Exception { Authentication auth = createAnonymousToken(); Object[][] anonymousAccessValid = { { HttpMethod.GET, "/portal/portal/" }, { HttpMethod.GET, "/portal/portal" }, { HttpMethod.GET, "/portal/portal/login" }, { HttpMethod.POST, "/portal/portal/login" }, { HttpMethod.GET, "/portal/portal/getGoogleAnalytics" }, { HttpMethod.GET, "/portal/portal/register" }, { HttpMethod.POST, "/portal/portal/register" }, { HttpMethod.GET, "/portal/portal/validate_username" }, { HttpMethod.GET, "/portal/portal/loggedout" }, { HttpMethod.GET, "/portal/portal/reset_password" }, { HttpMethod.POST, "/portal/portal/reset_password" }, { HttpMethod.GET, "/portal/portal/verify_email" }, { HttpMethod.GET, "/portal/portal/verify_user" } }; Object[][] anonymousAccessInvalid = { { HttpMethod.GET, "/portal/portal/home" }, { HttpMethod.GET, "/portal/portal/profile" }, { HttpMethod.GET, "/portal/portal/profile/edit" }, { HttpMethod.POST, "/portal/portal/profile" }, { HttpMethod.GET, "/portal/portal/users" }, { HttpMethod.POST, "/portal/portal/users" }, { HttpMethod.GET, "/portal/portal/users/new" }, { HttpMethod.GET, "/portal/portal/users/1" }, { HttpMethod.PUT, "/portal/portal/users/1" }, { HttpMethod.GET, "/portal/portal/tenants" }, { HttpMethod.POST, "/portal/portal/tenants" }, { HttpMethod.GET, "/portal/portal/tenants/new" }, { HttpMethod.GET, "/portal/portal/tenants/1" }, { HttpMethod.GET, "/portal/portal/tenants/1/edit" }, { HttpMethod.PUT, "/portal/portal/tenants/1" }, { HttpMethod.GET, "/portal/portal/tasks/" }, { HttpMethod.GET, "/portal/portal/tasks/1/" }, { HttpMethod.GET, "/portal/portal/tasks/approval-task/1" }, { HttpMethod.POST, "/portal/portal/tasks/approval-task" }, { HttpMethod.POST, "/portal/portal/acceptCookies" } }; verify(auth, anonymousAccessValid, anonymousAccessInvalid); }
From source file:org.n52.restfulwpsproxy.wps.ExecuteClient.java
public ResultDocument syncExecute(String processId, ExecuteDocument executeDocument) throws URISyntaxException { HttpEntity<ExecuteDocument> requestEntity = new HttpEntity<ExecuteDocument>(executeDocument, headers); return restTemplate.exchange(baseUrl, HttpMethod.POST, requestEntity, ResultDocument.class).getBody(); }
From source file:com.joseph.california.test.restapi.ClubRestControllerTest.java
@Test public void tesClubUpdate() { // LEFT AS AN EXERCISE FOR YOU // GET THE CLUB and THEN CHANGE AND MAKE A COPY //THEN SEND TO THE SERVER USING A PUT OR POST // THEN READ BACK TO SEE IF YOUR CHANGE HAS HAPPENED Club club = new Club.Builder("Hackers").build(); HttpEntity<Club> requestEntity = new HttpEntity<>(club, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/club/create", HttpMethod.POST, requestEntity, String.class); System.out.println(" THE RESPONSE BODY " + responseEntity.getBody()); System.out.println(" THE RESPONSE STATUS CODE " + responseEntity.getStatusCode()); System.out.println(" THE RESPONSE IS HEADERS " + responseEntity.getHeaders()); Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK); }
From source file:net.orpiske.tcs.service.config.SecurityConfig.java
@Override protected void configure(HttpSecurity http) throws Exception { /**// w w w . j av a 2 s . co m * Disabling CSRF because ... well ... because ... f**** you. I know it's good * but I need to research more about it. For now, I just want to get this site * up an running. * * Ref.: * http://spring.io/blog/2013/08/21/spring-security-3-2-0-rc1-highlights-csrf-protection/ */ http.csrf().disable(); http.authorizeRequests().antMatchers(HttpMethod.POST, "/domain/**").hasRole("USER").and().httpBasic(); http.authorizeRequests().antMatchers(HttpMethod.GET, "/domain/**").permitAll(); http.authorizeRequests().antMatchers(HttpMethod.POST, "/references/**").hasRole("USER").and().httpBasic(); http.authorizeRequests().antMatchers("/tagcloud/**", "/tagcloud/domain/**").permitAll(); }
From source file:com.cemeterylistingswebtest.test.rest.PublishedListingController.java
@Test(enabled = false) public void testCreate() { Long subID = new Long(17); List<PersonOtherNames> names = null; PublishedDeceasedListing newListing = new PublishedDeceasedListing.Builder().setFirstName("Hendrika") .setSurname("Fourie").setMaidenName("Gerber").setGender("Female").setDateOfBirth("08/06/1969") .setDateOfDeath("14/02/2005").setGraveInscription("Hippiest person eva").setGraveNumber("2456") .setImageOfBurialSite("/images/001.jpg").setLastKnownContactName("Berry") .setLastKnownContactNumber("0725576482").setSubscriberSubmitID(subID).setNames(names).build(); HttpEntity<PublishedDeceasedListing> requestEntity = new HttpEntity<>(newListing, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/publishedListings/create", HttpMethod.POST, requestEntity, String.class); System.out.println(" THE RESPONSE BODY " + responseEntity.getBody()); System.out.println(" THE RESPONSE STATUS CODE " + responseEntity.getStatusCode()); System.out.println(" THE RESPONSE IS HEADERS " + responseEntity.getHeaders()); Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK); id = newListing.getPublishedListingID(); }
From source file:org.trustedanalytics.h2oscoringengine.publisher.steps.AppRecordCreatingStepTest.java
@Before public void setUp() { this.restTemplateMock = mock(RestTemplate.class); this.responseMock = mock(ResponseEntity.class); when(restTemplateMock.exchange(eq(cfAppsEndpoint), same(HttpMethod.POST), any(), same(String.class))) .thenReturn(responseMock);//from ww w . jav a 2 s.c o m }