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:cz.muni.fi.pa165.rentalofconstructionmachinery.restclient.MachineRestController.java

public static void deleteMachine(Long id) throws URISyntaxException {
    String url = MACHINE_URL + id;
    rt.exchange(new URI(url), HttpMethod.DELETE, new HttpEntity<>(httpHeaders), Object.class);
}

From source file:com.pablinchapin.tiendaliz.configuration.SecurityConfiguration.java

@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {

    httpSecurity.csrf().disable().authorizeRequests().antMatchers(HttpMethod.POST, "/api/**").authenticated()
            .antMatchers(HttpMethod.PUT, "/api/**").authenticated().antMatchers(HttpMethod.DELETE, "/api/**")
            .authenticated()//  w  w w  .j a v a  2s. c o m

            .anyRequest().permitAll().and().httpBasic().and().sessionManagement()
            .sessionCreationPolicy(SessionCreationPolicy.STATELESS);

}

From source file:com.netflix.genie.web.security.SecurityUtils.java

/**
 * Build the common API HTTP security./*from  ww w .  j  a  v a 2s .  c  om*/
 *
 * @param http                   The http security object to use
 * @param x509UserDetailsService The x509 authentication user details service to use
 * @param actuatorEndpoint       The endpoint where the Spring Actuator sits
 * @throws Exception when there is a problem configuring HTTP errors
 */
public static void buildAPIHttpSecurity(@NotNull final HttpSecurity http,
        @NotNull final X509UserDetailsService x509UserDetailsService, @NotBlank final String actuatorEndpoint)
        throws Exception {
    // @formatter:off
    http
            //            .regexMatcher("(/api/.*)|(" + actuatorEndpoint + ")/(?!health).*")
            .regexMatcher("(/api/.*)").authorizeRequests()
            .regexMatchers(HttpMethod.DELETE, APPLICATIONS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.PATCH, APPLICATIONS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.POST, APPLICATIONS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.PUT, APPLICATIONS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.DELETE, CLUSTERS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.PATCH, CLUSTERS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.POST, CLUSTERS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.PUT, CLUSTERS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.DELETE, COMMANDS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.PATCH, COMMANDS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.POST, COMMANDS_API_REGEX).hasRole(ADMIN_ROLE)
            .regexMatchers(HttpMethod.PUT, COMMANDS_API_REGEX).hasRole(ADMIN_ROLE).anyRequest()
            .hasRole(USER_ROLE).and().x509().authenticationUserDetailsService(x509UserDetailsService).and()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
            //            .and()
            //                .requiresChannel().anyRequest().requiresSecure()
            .and().requestCache().requestCache(new NullRequestCache()).and().csrf().disable();
    // @formatter:on
}

From source file:com.opensearchserver.hadse.index.IndexTest.java

@Test
public void t01_deleteIndex() {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));

    RestTemplate template = new RestTemplate();

    ResponseEntity<String> entity = template.exchange("http://localhost:8080/my_index", HttpMethod.DELETE, null,
            String.class);
    assertNotNull(entity);// www.j a  v  a  2s.  c  o  m
    HttpStatus res = entity.getStatusCode();
    assertNotNull(res);
    switch (res) {
    case OK:
        assertEquals(HttpStatus.OK, res);
        break;
    case NOT_FOUND:
        assertEquals(HttpStatus.NOT_FOUND, res);
        break;
    default:
        fail("Unexpected result: " + res);
        break;
    }
}

From source file:org.androidannotations.test15.rest.HttpMethodServiceTest.java

@Test
public void useDeleteHttpMethod() {
    HttpMethodsService_ service = new HttpMethodsService_(null);

    RestTemplate restTemplate = mock(RestTemplate.class);
    service.setRestTemplate(restTemplate);

    service.delete();//w  w w .  j a  v a2s. c om

    verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod>eq(HttpMethod.DELETE),
            Matchers.<HttpEntity<?>>any(), Matchers.<Class<Object>>any());
}

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

@Test
public void badRequest() {
    mockServer.expect(requestTo("http://localhost/appglu/v1/tables/user/2"))
            .andExpect(method(HttpMethod.DELETE)).andRespond(
                    withBadRequest().body(compactedJson("data/error_bad_request")).headers(responseHeaders));

    try {/*from  ww  w .  ja v a2s  .  c  o  m*/
        crudOperations.delete("user", 2);
        Assert.fail("Should had caused a exception");
    } catch (AppGluHttpClientException e) {
        Error error = e.getError();

        Assert.assertEquals(ErrorCode.EMPTY_REQUEST_BODY, error.getCode());
        Assert.assertEquals("The request body is empty.", error.getMessage());
        Assert.assertNull(error.getDetail());
    }

    mockServer.verify();
}

From source file:com.revze.crudspring.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers(HttpMethod.GET, "/api/catatan/**").hasRole("CATATAN_VIEW")
            .antMatchers(HttpMethod.POST, "/api/catatan/**").hasRole("CATATAN_CREATE")
            .antMatchers(HttpMethod.DELETE, "/api/catatan/**").hasRole("CATATAN_DELETE")
            .antMatchers(HttpMethod.PUT, "/api/catatan/**").hasRole("CATATAN_UPDATE").antMatchers("/lib/**")
            .permitAll().antMatchers("/scripts/**").permitAll().anyRequest().authenticated().and().formLogin()
            .loginPage("/login.html").defaultSuccessUrl("/").loginProcessingUrl("/login").permitAll().and()
            .logout().permitAll().and().csrf().disable();
}

From source file:customer.springboot.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers(HttpMethod.GET, "/api/customer/**").hasRole("CUSTOMER_VIEW")
            .antMatchers(HttpMethod.POST, "/api/customer/**").hasRole("CUSTOMER_CREATE")
            .antMatchers(HttpMethod.DELETE, "/api/customer/**").hasRole("CUSTOMER_DELETE")
            .antMatchers(HttpMethod.PUT, "/api/customer/**").hasRole("CUSTOMER_UPDATE")
            .antMatchers(HttpMethod.GET, "/api/user/**").hasRole("USER_VIEW").antMatchers("/lib/**").permitAll()
            .antMatchers("/scripts/**").permitAll().anyRequest().authenticated().and().formLogin()
            .loginPage("/login.html").defaultSuccessUrl("/").loginProcessingUrl("/login").permitAll().and()
            .logout().permitAll().and().csrf().disable();
}

From source file:mynotesrzd.springboot.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers(HttpMethod.GET, "/api/mynotes/**").hasRole("MYNOTES_VIEW")
            .antMatchers(HttpMethod.POST, "/api/mynotes/**").hasRole("MYNOTES_CREATE")
            .antMatchers(HttpMethod.DELETE, "/api/mynotes/**").hasRole("MYNOTES_DELETE")
            .antMatchers(HttpMethod.PUT, "/api/mynotes/**").hasRole("MYNOTES_UPDATE")
            .antMatchers(HttpMethod.GET, "/api/user/**").hasRole("USER_VIEW").antMatchers("/lib/**").permitAll()
            .antMatchers("/scripts/**").permitAll().anyRequest().authenticated().and().formLogin()
            .loginPage("/login.html").defaultSuccessUrl("/").loginProcessingUrl("/login").permitAll().and()
            .logout().permitAll().and().csrf().disable();
}

From source file:library.SecurityConfiguration.java

@Override
protected void configure(HttpSecurity http) throws Exception {

    http.httpBasic().and().authorizeRequests().antMatchers(HttpMethod.DELETE, "/user/delete").hasRole("ADMIN")
            .antMatchers(HttpMethod.DELETE, "/user/passBook").hasRole("ADMIN")
            .antMatchers(HttpMethod.DELETE, "/books/delete").hasRole("ADMIN")
            .antMatchers(HttpMethod.GET, "/users/all").hasRole("ADMIN")
            .antMatchers(HttpMethod.GET, "/users/user/**").hasAnyRole("USER", "ADMIN")
            .antMatchers(HttpMethod.GET, "/books/user/**").hasAnyRole("USER", "ADMIN")
            .antMatchers(HttpMethod.GET, "/books/book/**").hasAnyRole("USER", "ADMIN")
            .antMatchers(HttpMethod.POST, "/books/book/search").hasAnyRole("USER", "ADMIN")
            .antMatchers(HttpMethod.GET, "/book/status/*").hasAnyRole("USER", "ADMIN")
            .antMatchers(HttpMethod.GET, "/books/all").hasAnyRole("USER", "ADMIN")
            .antMatchers(HttpMethod.POST, "/users/user/search").hasRole("ADMIN")
            .antMatchers(HttpMethod.POST, "/user/takeBook").hasAnyRole("USER", "ADMIN")
            .antMatchers(HttpMethod.POST, "/books/add").hasRole("ADMIN")
            .antMatchers(HttpMethod.POST, "/books/update").hasRole("ADMIN").and().csrf().disable();
}