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.netflix.genie.web.security.SecurityUtils.java
/** * Build the common API HTTP security./*from ww w.j ava2 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:client.RestConnector.java
public Response send(Request request) { HttpEntity<Request> requestEntity = new HttpEntity<>(request); ResponseEntity<Response> response1 = restTemplate.exchange("http://" + host + ":" + port + "/graphdb", HttpMethod.POST, requestEntity, Response.class); return response1.getBody(); }
From source file:com.tenforce.lodms.extractors.views.CkanExtractFieldFactory.java
@Override public Field createField(Item item, Object propertyId, Component uiContext) { if ("baseUri".equals(propertyId)) { TextField uriField = new TextField("CKAN Url"); uriField.setRequired(true);/*from w w w . j a v a 2 s.c o m*/ uriField.setRequiredError("CKAN Url is required!"); uriField.setWidth(350, VerticalLayout.UNITS_PIXELS); uriField.setDescription("Base url of the ckan portal."); uriField.setImmediate(true); uriField.addValidator(new AbstractStringValidator(null) { @Override protected boolean isValidString(String value) { try { new URIImpl(value); return true; } catch (Exception ex) { setErrorMessage("Invalid CKAN Url: " + ex.getMessage()); return false; } } }); return uriField; } else if ("httpMethod".equals(propertyId)) { Select selector = new Select("Http Method"); selector.addItem(HttpMethod.GET); selector.addItem(HttpMethod.POST); return selector; } else if ("publisher".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("The foaf:agent responsible for this catalog."); field.setRequired(true); return field; } else if ("title".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("Title for this catalog."); field.setRequired(true); return field; } else if ("license".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("license for this catalog."); field.setRequired(true); return field; } else if ("description".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("Description for this catalog."); field.setWidth(350, VerticalLayout.UNITS_PIXELS); field.setRequired(true); return field; } else if ("ignoredKeys".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription( "A comma seperated list of attributes in the metadata that should be ignored by the extractor."); return field; } else if ("subjectPrefix".equals(propertyId)) { TextField subjectField = new TextField("Subject Prefix"); subjectField.setRequired(true); subjectField.setDescription("This prefix will be used to generate the subject url."); subjectField.setRequiredError("Subject Prefix is required!"); subjectField.setWidth(350, VerticalLayout.UNITS_PIXELS); return subjectField; } else if ("predicatePrefix".equals(propertyId)) { TextField predicateField = new TextField("Predicate Prefix"); predicateField.setRequired(true); predicateField.setDescription( "All json attributes will be prefixed with this string to generate a predicate."); predicateField.setRequiredError("Predicate Prefix is required!"); predicateField.setWidth(350, VerticalLayout.UNITS_PIXELS); return predicateField; } else if ("packageIds".equals(propertyId)) { TwinColSelect select = new TwinColSelect("Select catalog records to harvest"); select.setLeftColumnCaption("Available records"); select.setRightColumnCaption("Selected records"); select.setRows(20); select.setWidth(500, VerticalLayout.UNITS_PIXELS); return select; } else if ("allDatasets".equals(propertyId)) { CheckBox box = new CheckBox("harvest all datasets"); box.setImmediate(true); return box; } return super.createField(item, propertyId, uiContext); }
From source file:org.openwms.common.comm.sysu.HttpSystemUpdateMessageHandler.java
@Override public Void apply(SystemUpdateMessage msg) { restTemplate.exchange("http://routing-service/v1/sysu", HttpMethod.POST, new HttpEntity<>(new RequestVO(msg.getLocationGroupName(), msg.getErrorCode())), Void.class); return null;// ww w .ja v a 2 s. c om }
From source file:org.openwms.common.comm.req.HttpRequestMessageHandler.java
@Override public Void apply(RequestMessage msg) { restTemplate.exchange("http://routing-service/v1/req", HttpMethod.POST, new HttpEntity<>(new RequestVO(msg.getActualLocation(), msg.getBarcode())), Void.class); return null;//ww w .jav a 2 s . co m }
From source file:com.bradley.musicapp.test.restapi.TrackRestControllerTest.java
@Test public void testCreate() { Track track = new Track.Builder().trackName("yolo").trackLength("03:45").build(); HttpEntity<Track> requestEntity = new HttpEntity<>(track, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<Track> responseEntity = restTemplate.exchange(URL + "api/track/create", HttpMethod.POST, requestEntity, Track.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()); System.out.println("id = " + responseEntity.getBody().getId()); id = responseEntity.getBody().getId(); Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK); }
From source file:io.pivotal.xd.chaoslemur.reporter.DataDogReporterTest.java
@Test public void sendEvent() { mockServer.expect(requestTo(URI)).andExpect(method(HttpMethod.POST)) .andRespond(withSuccess("resultSuccess", MediaType.TEXT_PLAIN)); dataDog.sendEvent("Title", "Message"); this.mockServer.verify(); }
From source file:com.mycompany.CPUTAuction.restapi.BidRestControllerTest.java
public void tesCreate() { Bid bid = new Bid.Builder(1001).amount(300).build(); //repo.save(b); //id = b.getId(); HttpEntity<Bid> requestEntity = new HttpEntity<>(bid, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/bid/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: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:com.playhaven.android.req.OpenRequest.java
public OpenRequest() { super(); setMethod(HttpMethod.POST); }