Example usage for org.springframework.http HttpMethod DELETE

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

Introduction

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

Prototype

HttpMethod DELETE

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

Click Source Link

Usage

From source file:org.cloudfoundry.identity.uaa.login.UaaApprovalsService.java

@Override
public void deleteApprovalsForClient(String clientId) {
    ResponseEntity<String> response = restTemplate.exchange(approvalsUrl + "?clientId=" + clientId,
            HttpMethod.DELETE, null, String.class);
    logger.debug("Delete approvals request for client " + clientId + " resulted in " + response);
}

From source file:com.expedia.seiso.SeisoWebSecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    // @formatter:off
    http/*w w  w.j av  a  2s . co m*/
            // TODO Would prefer to do this without sessions if possible. But see
            // https://spring.io/guides/tutorials/spring-security-and-angular-js/
            // http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/elb-sticky-sessions.html
            //         .sessionManagement()
            //            .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            //            .and()
            .authorizeRequests().antMatchers(HttpMethod.GET, "/internal/**").permitAll()
            .antMatchers(HttpMethod.GET, "/api/**").permitAll().antMatchers(HttpMethod.POST, "/api/**")
            .hasAnyRole(Roles.USER, Roles.ADMIN).antMatchers(HttpMethod.PUT, "/api/**")
            .hasAnyRole(Roles.USER, Roles.ADMIN).antMatchers(HttpMethod.DELETE, "/api/**")
            .hasAnyRole(Roles.USER, Roles.ADMIN).antMatchers(HttpMethod.PATCH, "/api/**")
            .hasAnyRole(Roles.USER, Roles.ADMIN)

            // Admin console
            .antMatchers(HttpMethod.GET, "/admin").hasRole(Roles.ADMIN).antMatchers(HttpMethod.GET, "/admin/**")
            .hasRole(Roles.ADMIN)

            // Blacklist
            .anyRequest().denyAll()
            //            .anyRequest().hasRole(Roles.USER)
            .and().httpBasic().authenticationEntryPoint(entryPoint()).and().exceptionHandling()
            .authenticationEntryPoint(entryPoint()).and()
            // FIXME Enable. See https://spring.io/guides/tutorials/spring-security-and-angular-js/
            .csrf().disable();
    // @formatter:on
}

From source file:com.orange.ngsi.client.NgsiRestClient.java

/**
 * Delete a context element/*from   ww w.  j av a 2  s .c om*/
 * @param url the URL of the broker
 * @param httpHeaders the HTTP header to use, or null for default
 * @param entityID the ID of the entity
 * @return a future for a StatusCode
 */
public ListenableFuture<StatusCode> deleteContextElement(String url, HttpHeaders httpHeaders, String entityID) {
    return request(HttpMethod.DELETE, url + entitiesPath + entityID, httpHeaders, null, StatusCode.class);
}

From source file:com.appglu.impl.PushTemplateTest.java

@Test
public void removeDevice() {
    mockServer.expect(requestTo("http://localhost/appglu/v1/push/device/f3f71c5a-0a98-48f7-9acd-d38d714d76ad"))
            .andExpect(method(HttpMethod.DELETE)).andRespond(withSuccess().headers(responseHeaders));

    boolean success = pushOperations.removeDevice("f3f71c5a-0a98-48f7-9acd-d38d714d76ad");
    Assert.assertTrue(success);//from   w  ww  . j a  va 2  s.  c  om

    mockServer.verify();
}

From source file:org.cloudfoundry.identity.uaa.scim.remote.RemoteScimUserProvisioning.java

@Override
public ScimUser delete(String id, int version) throws ScimResourceNotFoundException {
    HttpHeaders headers = new HttpHeaders();
    headers.set("If-Match", String.format("%d", version));
    return restTemplate.exchange(baseUrl + "/User/{id}", HttpMethod.DELETE, new HttpEntity<Void>(headers),
            ScimUser.class, id).getBody();
}

From source file:org.zalando.github.spring.MembersTemplateTest.java

@Test
public void removeMember() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/orgs/zalando-stups/members/klaus"))
            .andExpect(method(HttpMethod.DELETE))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(withNoContent());

    membersTemplate.removeFromOrganization("zalando-stups", "klaus");
}

From source file:org.cloudfoundry.caldecott.client.HttpTunnel.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public void close() {
    if (logger.isDebugEnabled()) {
        logger.debug("Deleting tunnel " + this.tunnelInfo.get("path"));
    }// www. j  a va2  s. com
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("Auth-Token", auth);
    HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
    try {
        restOperations.exchange(url + this.tunnelInfo.get("path"), HttpMethod.DELETE, requestEntity, null);
    } catch (HttpClientErrorException e) {
        if (e.getStatusCode().value() == 404) {
            if (logger.isDebugEnabled()) {
                logger.debug("Tunnel not found [" + e.getStatusCode() + "] " + e.getStatusText());
            }
        } else {
            logger.warn("Error while deleting tunnel [" + e.getStatusCode() + "] " + e.getStatusText());
        }
    }
}

From source file:org.cloudfoundry.identity.uaa.integration.TokenAdminEndpointsIntegrationTests.java

@Test
@OAuth2ContextConfiguration(resource = TokenResourceOwnerPassword.class)
public void testRevokeBogusToken() throws Exception {

    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    HttpEntity<?> request = new HttpEntity<String>(context.getAccessToken().getValue(), headers);
    ResponseEntity<Void> response = serverRunning.getRestTemplate().exchange(
            serverRunning.getUrl("/oauth/users/{user}/tokens/{token}"), HttpMethod.DELETE, request, Void.class,
            testAccounts.getUserName(), "FOO");
    assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());

}

From source file:org.cloudfoundry.identity.uaa.integration.VmcScimUserEndpointIntegrationTests.java

@SuppressWarnings("rawtypes")
private ResponseEntity<Map> deleteUser(RestOperations client, String id, int version) {
    HttpHeaders headers = new HttpHeaders();
    headers.add("If-Match", "\"" + version + "\"");
    return client.exchange(serverRunning.getUrl(usersEndpoint + "/{id}"), HttpMethod.DELETE,
            new HttpEntity<Void>(headers), Map.class, id);
}

From source file:cz.zcu.kiv.eeg.mobile.base.ws.asynctask.RemoveReservation.java

/**
 * Method, where reservation information is pushed to server in order to remove it.
 * All heavy lifting is made here./*from   w ww. j a  v  a2s  .  com*/
 *
 * @param params only one Reservation object is accepted
 * @return true if reservation is removed
 */
@Override
protected Boolean doInBackground(Reservation... params) {

    Reservation data = params[0];

    //nothing to remove
    if (data == null)
        return false;

    try {

        setState(RUNNING, R.string.working_ws_remove);

        SharedPreferences credentials = getCredentials();
        String username = credentials.getString("username", null);
        String password = credentials.getString("password", null);
        String url = credentials.getString("url", null) + Values.SERVICE_RESERVATION + data.getReservationId();

        HttpAuthentication authHeader = new HttpBasicAuthentication(username, password);
        HttpHeaders requestHeaders = new HttpHeaders();
        requestHeaders.setAuthorization(authHeader);
        HttpEntity<Reservation> entity = new HttpEntity<Reservation>(requestHeaders);

        SSLSimpleClientHttpRequestFactory factory = new SSLSimpleClientHttpRequestFactory();
        // Create a new RestTemplate instance
        RestTemplate restTemplate = new RestTemplate(factory);
        restTemplate.getMessageConverters().add(new StringHttpMessageConverter());

        Log.d(TAG, url + "\n" + entity);
        restTemplate.exchange(url, HttpMethod.DELETE, entity, String.class);
        return true;
    } catch (Exception e) {
        Log.e(TAG, e.getLocalizedMessage());
        setState(ERROR, e);
    } finally {
        setState(DONE);
    }
    return false;
}