Example usage for org.springframework.http HttpMethod POST

List of usage examples for org.springframework.http HttpMethod POST

Introduction

In this page you can find the example usage for org.springframework.http HttpMethod POST.

Prototype

HttpMethod POST

To view the source code for org.springframework.http HttpMethod POST.

Click Source Link

Usage

From source file:org.n52.restfulwpsproxy.wps.SimplePostClient.java

public String performPostRequest(Object xmlRequest)
        throws TransformerFactoryConfigurationError, TransformerException {
    HttpEntity<String> requestEntity = new HttpEntity<String>(XMLBeansHelper.nodeToString((Node) xmlRequest),
            headers);// w  ww.ja  v  a 2 s  .  co  m
    ResponseEntity<String> exchange = restTemplate.exchange(baseUrl, HttpMethod.POST, requestEntity,
            String.class);
    return exchange.getBody();
}

From source file:org.openbaton.nfvo.security.authentication.ResourceServer.java

@Override
public void configure(HttpSecurity http) throws Exception {
    http.headers().frameOptions().disable();

    boolean enabled = Boolean.parseBoolean(enabledSt);

    // API calls/*from   w w  w.ja  v  a2s .c  o  m*/
    if (true) {
        log.info("Security is enabled");
        http.authorizeRequests().regexMatchers(HttpMethod.POST, "/api/v1/").access("#oauth2.hasScope('write')")
                .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER).and()
                .exceptionHandling();

        http.authorizeRequests().antMatchers(HttpMethod.POST, "/api/**").access("#oauth2.hasScope('write')")
                .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER).and()
                .exceptionHandling();
        http.authorizeRequests().regexMatchers(HttpMethod.GET, "/api/v1/vnf-packages/*/download-with-link")
                .permitAll();
    } else {
        log.warn("Security is not enabled!");
        http.authorizeRequests().anyRequest().permitAll();
    }
}

From source file:it.reply.orchestrator.service.CloudProviderRankerServiceImpl.java

@Override
public List<RankedCloudProvider> getProviderRanking(CloudProviderRankerRequest cloudProviderRankerRequest) {

    HttpEntity<CloudProviderRankerRequest> entity = new HttpEntity<CloudProviderRankerRequest>(
            cloudProviderRankerRequest);

    ResponseEntity<List<RankedCloudProvider>> response = restTemplate.exchange(url, HttpMethod.POST, entity,
            new ParameterizedTypeReference<List<RankedCloudProvider>>() {
            });/*from   www  .  j a  va  2  s.c o  m*/
    if (response.getStatusCode().is2xxSuccessful()) {
        return response.getBody();
    }

    throw new DeploymentException(
            "Error retrieving cloud provider ranking data for request <" + cloudProviderRankerRequest + ">");
}

From source file:com.peertopark.spring.commons.CsrfRequestMatcher.java

public CsrfRequestMatcher andMatchPost(String pattern) {
    return andMatch(pattern, HttpMethod.POST);
}

From source file:org.openbaton.nfvo.vnfm_reg.impl.sender.RestVnfmSender.java

private String post(String json, String url) {
    HttpEntity<String> requestEntity = new HttpEntity<>(json, headers);
    ResponseEntity<String> responseEntity = rest.exchange(url, HttpMethod.POST, requestEntity, String.class);
    this.setStatus(responseEntity.getStatusCode());
    return responseEntity.getBody();
}

From source file:com.ecsteam.cloudlaunch.services.jenkins.JenkinsService.java

public QueuedBuildResponse triggerBuild() {
    String urlTemplate = "{baseUrl}/job/{jobName}/build";

    RestTemplate template = new RestTemplate();
    ResponseEntity<Object> response = template.exchange(urlTemplate, HttpMethod.POST, getAuthorizationEntity(),
            Object.class, baseUrl, jobName);

    if (HttpStatus.CREATED.equals(response.getStatusCode())) {
        HttpHeaders headers = response.getHeaders();
        URI queueUri = headers.getLocation();

        String last = null;/*from   w  w  w.ja  va2 s.com*/
        String current = null;
        String next = null;

        String[] parts = queueUri.getPath().split("/");

        QueuedBuildResponse responseObject = new QueuedBuildResponse();
        for (int i = parts.length - 1; i >= 0; --i) {
            last = parts[i];
            current = parts[i - 1];
            next = parts[i - 2];

            if ("queue".equals(next) && "item".equals(current)) {
                responseObject = new QueuedBuildResponse();
                responseObject.setMonitorUri(String.format("/services/builds/queue/%s", last));

                return responseObject;
            }
        }
    }
    return null;
}

From source file:com.cemeterylistingswebtest.test.rest.CemeteryControllerTest.java

@Test(enabled = false)
public void testCreate() {
    System.out.println("Cemetery Testing");

    Location local = new Location.Builder().setCemeteryName("Palm Springs").setCountry("America")
            .setDistrict_state("Washington").setLocationOfCemetery("12.06.12:45.63.89")
            .setProvince_State("New Jersey").setTown("Marlboro").build();

    Cemetery newCemetery = new Cemetery.Builder().setContactName("Palm Springs").setContactNumber("0215698412")
            .setLocation(local).build();

    HttpEntity<Cemetery> requestEntity = new HttpEntity<>(newCemetery, getContentType());
    //        Make the HTTP POST request, marshaling the request to JSON, and the response to a String
    ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/cemetery/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 = newCemetery.getId();/*www  .j  a va 2s.  c om*/
}

From source file:org.openschedule.api.impl.SessionTemplate.java

public void addBlockComment(String shortName, Integer dayId, Integer scheduleId, Integer blockId,
        Comment comment) {/*from  w  ww. j  a  v a 2s .  c  o m*/
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.setContentType(new MediaType("application", "json"));

    HttpEntity<Comment> requestEntity = new HttpEntity<Comment>(comment, requestHeaders);

    restTemplate.exchange(
            "public/" + shortName + "/days/" + dayId + "/schedules/" + scheduleId + "/blocks/" + blockId
                    + "/comments",
            HttpMethod.POST, requestEntity, String.class, shortName, dayId, scheduleId, blockId).getBody();
}

From source file:io.pivotal.xd.chaoslemur.reporter.DataDogReporterTest.java

@Test
public void badSendEvent() {
    mockServer.expect(requestTo(URI)).andExpect(method(HttpMethod.POST)).andRespond(withBadRequest());

    dataDog.sendEvent("Title", "Message");

    this.mockServer.verify();
}

From source file:com.mc.printer.model.StartTask.java

@Override
public Object doBackgrounp() {

    //        File file = new File(ClientConstants.GUIDE_DOWNLOAD_DIR);
    //        if (file.exists() && file.isDirectory()) {
    //            try {
    //                logger.debug("clean download directory.");
    //                FileUtils.deleteDirectory(file);
    //            } catch (IOException ex) {
    //                logger.error("ex");
    //            }
    //        }/*w  w  w  .j a v a  2  s  .  c om*/
    try {

        TbBranch branch = new TbBranch();
        branch.setAddress(IPHelper.getCurrentIP());
        branch.setName(ClientConstants.LOCAL_NAME);
        branch.setStatus(1);
        ComResponse<TbBranch> response = restTemplate.exchange(
                ClientConstants.WS_HTTP + ClientConstants.WS_ISREGISTER, HttpMethod.POST,
                new HttpEntity<TbBranch>(branch), new ParameterizedTypeReference<ComResponse<TbBranch>>() {
                }).getBody();

        if (response.getResponseStatus() == ComResponse.STATUS_OK) {
            logger.info("checked successfully. client is existing.");
            AutoPrinterApp.isRegister = true;
        } else {
            logger.error(response.getErrorMessage());
        }

    } catch (Exception e) {
        logger.error(e.getMessage());
    }

    return null;
}