Example usage for org.springframework.http HttpMethod PUT

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

Introduction

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

Prototype

HttpMethod PUT

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

Click Source Link

Usage

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()//from  w  ww  . j  av  a2 s.co m

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

}

From source file:nl.iwelcome.connector.google.RestInvoker.java

public static RestInvoker preparePutTo(String uri) {
    return new RestInvoker(HttpMethod.PUT, uri);
}

From source file:com.pablinchapin.planz.dailytaskmanager.client.service.TaskServiceBean.java

public TaskServiceDTO update(Long id, TaskServiceDTO task) {
    return restTemplate.exchange(idResource, HttpMethod.PUT, new HttpEntity<>(task), TaskServiceDTO.class, id)
            .getBody();/*ww  w.  j a  v  a2  s .  c o  m*/
}

From source file:com.flipkart.poseidon.filters.RequestGzipFilter.java

@Override
public void doFilter(final ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest servletRequest = (HttpServletRequest) request;
    HttpServletResponse servletResponse = (HttpServletResponse) response;
    boolean isGzipped = servletRequest.getHeader(HttpHeaders.CONTENT_ENCODING) != null
            && servletRequest.getHeader(HttpHeaders.CONTENT_ENCODING).contains("gzip");
    boolean requestTypeSupported = HttpMethod.POST.toString().equals(servletRequest.getMethod())
            || HttpMethod.PUT.toString().equals(servletRequest.getMethod())
            || HttpMethod.PATCH.toString().equals(servletRequest.getMethod());
    if (isGzipped && !requestTypeSupported) {
        throw new IllegalStateException(new StringBuilder().append(servletRequest.getMethod())
                .append(" is not supports gzipped body of parameters.")
                .append(" Only POST requests are currently supported.").toString());
    }//from  www  . jav  a  2 s .  c  o m
    if (isGzipped) {
        servletRequest = new GzippedInputStreamWrapper(servletRequest);
    }
    chain.doFilter(servletRequest, servletResponse);
}

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

/**
 * Build the common API HTTP security.//from w w w .  j  ava  2  s  .c o  m
 *
 * @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:net.paslavsky.springrest.SpringAnnotationPreprocessorTest.java

private Object[] rowData(Class<?> clientClass, String methodName) {
    MetadataBuilder builder = new MetadataBuilder();
    if ("test1".equals(methodName)) {
        builder.setAdditionalPath("/test1").setHttpMethod(HttpMethod.PUT).setRequestParameter(0);
    } else if ("test7".equals(methodName)) {
        builder.setAdditionalPath("/test7/{path}").setHttpMethod(HttpMethod.GET).addUriVarParameter("path", 0)
                .addQueryParameter("size", 1).setMethodReturnType(Map.class).setResponseClass(Map.class);
    } else if ("test2".equals(methodName)) {
        builder.setAdditionalPath("/test2").setHttpMethod(HttpMethod.GET).addRequestHeaderParameter("OAuth", 0)
                .setMethodReturnType(ResponseEntity.class).setResponseClass(Map.class);
    } else if ("test3".equals(methodName)) {
        builder.setAdditionalPath("/test3").setHttpMethod(HttpMethod.GET)
                .setMethodReturnType(ResponseEntity.class).setResponseClass(Map.class);
    } else if ("test4".equals(methodName)) {
        builder.setAdditionalPath("/test4").setHttpMethod(HttpMethod.GET)
                .setMethodReturnType(ResponseEntity.class).setResponseClass(byte[].class);
    } else if ("test5".equals(methodName)) {
        builder.setAdditionalPath("/test5").setHttpMethod(HttpMethod.GET)
                .setMethodReturnType(ResponseEntity.class).setResponseClass(byte[].class);
    } else if ("test6".equals(methodName)) {
        builder.setAdditionalPath("/test6").setHttpMethod(HttpMethod.GET).setMethodReturnType(Object.class)
                .setResponseClass(byte[].class);
    } else if ("test8".equals(methodName)) {
        builder.setCommonPath("/common").setAdditionalPath("/test8").setHttpMethod(HttpMethod.PUT);
    } else if ("test9".equals(methodName)) {
        builder.setCommonPath("/common").setAdditionalPath("/test9").setHttpMethod(HttpMethod.GET)
                .setMethodReturnType(String.class).setResponseClass(String.class);
    } else if ("test10".equals(methodName)) {
        builder.setCommonPath("/common").setHttpMethod(HttpMethod.GET).setMethodReturnType(String.class)
                .setResponseClass(String.class);
    } else if ("test11".equals(methodName)) {
        builder.setCommonPath("/common").setHttpMethod(HttpMethod.GET).setMethodReturnType(String.class)
                .setResponseClass(String.class);
    }/*from   w  ww  . j  a v a  2 s .  co  m*/
    return new Object[] { clientClass, getMethod(clientClass, methodName), builder.build() };
}

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:org.jasig.portlet.notice.service.ssp.MarkTaskCompletedAction.java

@Override
public void invoke(ActionRequest req, ActionResponse res) throws IOException {
    ResponseEntity<String> updateResponse = null;

    @SuppressWarnings("unchecked")
    SSPApiRequest<String> updateReq = new SSPApiRequest<String>(MARK_TASK_COMPLETE_FRAGMENT, String.class)
            .setMethod(HttpMethod.PUT).addUriParameter("taskId", taskId).addUriParameter("completed", true);

    try {/*from www  . j  ava 2s. com*/
        // since these may be serialized and cached, need to actually look up the
        // service vs. injecting it or passing it in.
        ISSPApi sspApi = SSPApiLocator.getSSPApi();
        updateResponse = sspApi.doRequest(updateReq);
    } catch (Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    }

    if (updateResponse != null && updateResponse.getStatusCode().series() != HttpStatus.Series.SUCCESSFUL) {
        throw new RuntimeException("Error updating task: " + updateResponse.getBody());
    }
}

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();
}