List of usage examples for org.springframework.http HttpMethod DELETE
HttpMethod DELETE
To view the source code for org.springframework.http HttpMethod DELETE.
Click Source Link
From source file:com.ge.predix.test.utils.ZoneHelper.java
public ResponseEntity<String> deleteServiceFromZac(final String zoneId) throws JsonProcessingException { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.add(this.acsZoneHeaderName, zoneId); HttpEntity<String> requestEntity = new HttpEntity<>(headers); ResponseEntity<String> response = this.zacRestTemplate.exchange( this.zacUrl + "/v1/registration/" + this.serviceId + "/" + zoneId, HttpMethod.DELETE, requestEntity, String.class); return response; }
From source file:com.sitewhere.rest.service.SiteWhereClient.java
@Override public Device deleteDevice(String hardwareId, boolean force) throws SiteWhereException { Map<String, String> vars = new HashMap<String, String>(); vars.put("hardwareId", hardwareId); String url = getBaseUrl() + "devices/{hardwareId}"; if (force) {//from ww w . ja v a2s. com url += "?force=true"; } return sendRest(url, HttpMethod.DELETE, null, Device.class, vars); }
From source file:io.gravitee.management.security.config.basic.BasicSecurityConfigurerAdapter.java
@Override protected void configure(HttpSecurity http) throws Exception { final String jwtSecret = environment.getProperty("jwt.secret"); if (jwtSecret == null || jwtSecret.isEmpty()) { throw new IllegalStateException("JWT secret is mandatory"); }//www . ja va2s . c o m http.httpBasic().realmName("Gravitee.io Management API").and().sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests() .antMatchers(HttpMethod.OPTIONS, "**").permitAll().antMatchers(HttpMethod.GET, "/user/**") .permitAll() // API requests .antMatchers(HttpMethod.GET, "/apis/**").permitAll().antMatchers(HttpMethod.POST, "/apis/**") .hasAnyAuthority("ADMIN", "API_PUBLISHER").antMatchers(HttpMethod.PUT, "/apis/**") .hasAnyAuthority("ADMIN", "API_PUBLISHER").antMatchers(HttpMethod.DELETE, "/apis/**") .hasAnyAuthority("ADMIN", "API_PUBLISHER") // Application requests .antMatchers(HttpMethod.POST, "/applications/**").hasAnyAuthority("ADMIN", "API_CONSUMER") .antMatchers(HttpMethod.PUT, "/applications/**").hasAnyAuthority("ADMIN", "API_CONSUMER") .antMatchers(HttpMethod.DELETE, "/applications/**").hasAnyAuthority("ADMIN", "API_CONSUMER") // Instance requests .antMatchers(HttpMethod.GET, "/instances/**").hasAuthority("ADMIN").anyRequest().authenticated() .and().csrf().disable().addFilterAfter(corsFilter(), AbstractPreAuthenticatedProcessingFilter.class) .addFilterBefore(new JWTAuthenticationFilter(jwtCookieGenerator, jwtSecret), BasicAuthenticationFilter.class) .addFilterAfter( new AuthenticationSuccessFilter(jwtCookieGenerator, jwtSecret, environment.getProperty("jwt.issuer", DEFAULT_JWT_ISSUER), environment .getProperty("jwt.expire-after", Integer.class, DEFAULT_JWT_EXPIRE_AFTER)), BasicAuthenticationFilter.class); }
From source file:com.ge.predix.integration.test.PrivilegeManagementAccessControlServiceIT.java
@Test public void testBatchSubjectsDataConstraintViolationSubjectIdentifier() { List<BaseSubject> subjects = new ArrayList<BaseSubject>(); subjects.add(this.privilegeHelper.createSubject("marissa")); subjects.add(this.privilegeHelper.createSubject("marissa")); try {//from w ww . j a v a 2 s. c o m this.acsAdminRestTemplate.postForEntity(this.acsUrl + PrivilegeHelper.ACS_SUBJECT_API_PATH, new HttpEntity<>(subjects, this.zone1Headers), ResponseEntity.class); } catch (HttpClientErrorException e) { Assert.assertEquals(e.getStatusCode(), HttpStatus.UNPROCESSABLE_ENTITY); return; } this.acsAdminRestTemplate.exchange(this.acsUrl + PrivilegeHelper.ACS_SUBJECT_API_PATH + "/marissa", HttpMethod.DELETE, new HttpEntity<>(this.zone1Headers), ResponseEntity.class); Assert.fail("Expected unprocessable entity http client error."); }
From source file:de.zib.gndms.gndmc.AbstractClient.java
/** * Executes a DELETE on a url, where the request header contains a given user name. * /* www . j a va2s . com*/ * @param url The url of the request. * @param dn The user name. * @return The response as entity with Void body. */ protected final ResponseEntity<Integer> unifiedDelete(final String url, final String dn) { return unifiedX(HttpMethod.DELETE, Integer.class, null, url, dn, null); }
From source file:com.formulaone.controller.merchant.MerchantControllerTest.java
/** * Test successful user deletion/*w w w .ja v a 2 s . c o m*/ */ @Test public void test_4_SuccessMerchantDeletion() { Map<String, Long> vars = new HashMap<String, Long>(); vars.put("id", createdId); try { ResponseEntity<String> resp = restTemplate.exchange(base + "/{id}", HttpMethod.DELETE, new HttpEntity<String>(httpHeaders), String.class, vars); assertThat(resp.getStatusCode(), equalTo(HttpStatus.OK)); } catch (RestClientException e) { fail("Unexpected exception happened: " + e.getMessage()); } }
From source file:org.openbaton.nse.beans.connectivitymanageragent.ConnectivityManagerRequestor.java
public HttpStatus deleteFlow(String hypervisor_name, String flow_protocol, String flow_ip) { String url = configuration.getBaseUrl() + "/flow/" + hypervisor_name + "/" + flow_protocol + "/" + flow_ip; HttpHeaders headers = new HttpHeaders(); HttpEntity<String> deleteFlowEntity = new HttpEntity<>(headers); ResponseEntity<String> deleteResponse = template.exchange(url, HttpMethod.DELETE, deleteFlowEntity, String.class); logger.debug("Deleted flow with result " + deleteResponse.getStatusCode()); return deleteResponse.getStatusCode(); }
From source file:de.zib.gndms.gndmc.AbstractClient.java
/** * Executes a DELETE on a url, where the request header contains a given user name. * /*from w ww.j ava 2 s .c om*/ * @param <T> The body type of the response. * @param clazz The type of the return value. * @param url The url of the request. * @param dn The user name. * @return The response as entity. */ protected final <T> ResponseEntity<T> unifiedDelete(final Class<T> clazz, final String url, final String dn) { return unifiedX(HttpMethod.DELETE, clazz, null, url, dn, null); }
From source file:com.ge.predix.acceptance.test.ACSAcceptanceIT.java
@Test(dataProvider = "endpointProvider") public void testCompleteACSFlow(final String endpoint, final HttpHeaders headers, final PolicyEvaluationRequestV1 policyEvalRequest, final String subjectIdentifier) throws Exception { String testPolicyName = null; BaseSubject marissa = null;//from w w w. j a v a 2 s . co m BaseResource testResource = null; try { testPolicyName = this.policyHelper.setTestPolicy(this.acsAdminRestTemplate, headers, endpoint, "src/test/resources/testCompleteACSFlow.json"); BaseSubject subject = new BaseSubject(subjectIdentifier); Attribute site = new Attribute(); site.setIssuer("issuerId1"); site.setName("site"); site.setValue("sanramon"); marissa = this.privilegeHelper.putSubject(this.acsAdminRestTemplate, subject, endpoint, headers, site); Attribute region = new Attribute(); region.setIssuer("issuerId1"); region.setName("region"); region.setValue("testregion"); // test policy asserts on this value BaseResource resource = new BaseResource(); resource.setResourceIdentifier("/alarms/sites/sanramon"); testResource = this.privilegeHelper.putResource(this.acsAdminRestTemplate, resource, endpoint, headers, region); ResponseEntity<PolicyEvaluationResult> evalResponse = this.acsAdminRestTemplate.postForEntity( endpoint + PolicyHelper.ACS_POLICY_EVAL_API_PATH, new HttpEntity<>(policyEvalRequest, headers), PolicyEvaluationResult.class); Assert.assertEquals(evalResponse.getStatusCode(), HttpStatus.OK); PolicyEvaluationResult responseBody = evalResponse.getBody(); Assert.assertEquals(responseBody.getEffect(), Effect.PERMIT); } finally { // delete policy if (null != testPolicyName) { this.acsAdminRestTemplate.exchange(endpoint + PolicyHelper.ACS_POLICY_SET_API_PATH + testPolicyName, HttpMethod.DELETE, new HttpEntity<>(headers), String.class); } // delete attributes if (null != marissa) { this.acsAdminRestTemplate.exchange( endpoint + PrivilegeHelper.ACS_SUBJECT_API_PATH + marissa.getSubjectIdentifier(), HttpMethod.DELETE, new HttpEntity<>(headers), String.class); } if (null != testResource) { String encodedResource = URLEncoder.encode(testResource.getResourceIdentifier(), "UTF-8"); URI uri = new URI(endpoint + PrivilegeHelper.ACS_RESOURCE_API_PATH + encodedResource); this.acsAdminRestTemplate.exchange(uri, HttpMethod.DELETE, new HttpEntity<>(headers), String.class); } } }
From source file:com.orange.ngsi.client.NgsiRestClientTest.java
@Test public void testDeleteContextElement_JSON() throws Exception { String responseBody = json(jsonConverter, new StatusCode(CodeEnum.CODE_200)); mockServer.expect(requestTo(baseUrl + "/ngsi10/contextEntities/123")).andExpect(method(HttpMethod.DELETE)) .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); StatusCode response = ngsiRestClient.deleteContextElement(baseUrl, null, "123").get(); this.mockServer.verify(); assertEquals(CodeEnum.CODE_200.getLabel(), response.getCode()); }