List of usage examples for org.springframework.http HttpMethod PUT
HttpMethod PUT
To view the source code for org.springframework.http HttpMethod PUT.
Click Source Link
From source file:com.auditbucket.client.AbRestClient.java
public String flushTags(List<TagInputBean> tagInputBean) { if (tagInputBean.isEmpty()) return "OK"; RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); HttpHeaders httpHeaders = getHeaders(userName, password); HttpEntity<List<TagInputBean>> requestEntity = new HttpEntity<>(tagInputBean, httpHeaders); try {//www .j a v a 2 s . c o m // ToDo logServerMessage - error state will be returned in arraylist ResponseEntity<ArrayList> response = restTemplate.exchange(NEW_TAG, HttpMethod.PUT, requestEntity, ArrayList.class); logServerMessages(response); return "OK"; } catch (HttpClientErrorException e) { // to test, try to log against no existing fortress. logger.error("Datagio server error processing Tags {}", getErrorMessage(e)); return null; } catch (HttpServerErrorException e) { logger.error("Datagio server error processing Tags {}", getErrorMessage(e)); return null; } }
From source file:org.zalando.boot.etcd.EtcdClient.java
/** * Sets the value of the node with the given key in etcd. Any previously * existing key-value pair is returned as prevNode in the etcd response. * // w ww .j av a2 s. c o m * @param key * the node's key * @param value * the node's value * @return the response from etcd with the node * @throws EtcdException * in case etcd returned an error */ public EtcdResponse put(final String key, final String value) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE); builder.pathSegment(key); MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1); payload.set("value", value); return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class); }
From source file:com.orange.ngsi.client.NgsiRestClient.java
/** * Update the attribute value instance of a context element * @param url the URL of the broker/* ww w . j a va2 s. c om*/ * @param httpHeaders the HTTP header to use, or null for default * @param entityID the ID of the entity * @param attributeName the name of the attribute * @param valueID the instant ID of the attribute * @param updateContextAttribute attribute values to update * @return a future for a StatusCode */ public ListenableFuture<StatusCode> updateContextAttributeValue(String url, HttpHeaders httpHeaders, String entityID, String attributeName, String valueID, UpdateContextAttribute updateContextAttribute) { return request(HttpMethod.PUT, url + entitiesPath + entityID + attributesPath + attributeName + valuesPath + valueID, httpHeaders, updateContextAttribute, StatusCode.class); }
From source file:com.gooddata.dataload.processes.ProcessService.java
/** * Update process with data from appstore by given project. * Process must have set path field to valid appstore path in order to deploy from appstore. * This method is asynchronous, because when deploying from appstore, deployment worker can be triggered. * * @param project project to which the process belongs * @param process to update//w w w .j a v a 2 s. c om * @return updated process * @deprecated use {@link #updateProcessFromAppstore(DataloadProcess)} */ @Deprecated public FutureResult<DataloadProcess> updateProcessFromAppstore(Project project, DataloadProcess process) { notNull(project, "project"); notNull(process, "process"); notEmpty(process.getPath(), "process path"); return postProcess(process, getProcessUri(project, process.getId()), HttpMethod.PUT); }
From source file:org.cloudfoundry.identity.uaa.integration.ClientAdminEndpointsIntegrationTests.java
@Test public void testUpdateClient() throws Exception { BaseClientDetails client = createClient("client_credentials"); client.setResourceIds(Collections.singleton("foo")); client.setClientSecret(null);//from ww w . j ava 2 s . c o m client.setAuthorities(AuthorityUtils.commaSeparatedStringToAuthorityList("some.crap")); client.setAccessTokenValiditySeconds(60); client.setRefreshTokenValiditySeconds(120); // client.setAdditionalInformation(Collections.<String,Object>singletonMap("foo", Arrays.asList("rab"))); ResponseEntity<Void> result = serverRunning.getRestTemplate().exchange( serverRunning.getUrl("/oauth/clients/{client}"), HttpMethod.PUT, new HttpEntity<BaseClientDetails>(client, headers), Void.class, client.getClientId()); assertEquals(HttpStatus.OK, result.getStatusCode()); ResponseEntity<String> response = serverRunning.getForString("/oauth/clients/" + client.getClientId(), headers); assertEquals(HttpStatus.OK, response.getStatusCode()); String body = response.getBody(); assertTrue(body.contains(client.getClientId())); assertTrue(body.contains("some.crap")); assertTrue(body.contains("refresh_token_validity\":120")); assertTrue(body.contains("access_token_validity\":60")); // assertTrue("Wrong body: " + body, body.contains("\"foo\":[\"rab\"]")); }
From source file:org.cloudfoundry.identity.uaa.integration.ScimUserEndpointsIntegrationTests.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test// w w w .j ava 2 s . c o m public void updateUserWithBadAttributeFails() throws Exception { ResponseEntity<ScimUser> created = createUser(JOE, "Joe", "User", "joe@blah.com"); ScimUser joe = created.getBody(); HttpHeaders headers = new HttpHeaders(); headers.add("If-Match", "\"" + joe.getVersion() + "\""); ObjectMapper mapper = new ObjectMapper(); Map<String, Object> map = new HashMap<String, Object>( mapper.readValue(mapper.writeValueAsString(joe), Map.class)); map.put("nottheusername", JOE + "0"); ResponseEntity<Map> response = client.exchange(serverRunning.getUrl(userEndpoint) + "/{id}", HttpMethod.PUT, new HttpEntity<Map>(map, headers), Map.class, joe.getId()); Map<String, Object> joe1 = response.getBody(); assertTrue("Wrong message: " + joe1, ((String) joe1.get("message")).toLowerCase().contains("unrecognized field")); }
From source file:org.zalando.boot.etcd.EtcdClientTest.java
@Test public void compareAndSwapWithPrevExistAndSetTtl() throws EtcdException { server.expect(/*from w w w . j av a2 s . c om*/ MockRestRequestMatchers.requestTo("http://localhost:2379/v2/keys/sample?ttl=60&prevExist=false")) .andExpect(MockRestRequestMatchers.method(HttpMethod.PUT)) .andExpect(MockRestRequestMatchers.content().contentType(MediaType.APPLICATION_FORM_URLENCODED)) .andExpect(MockRestRequestMatchers.content().string("value=Hello+world")).andRespond( MockRestResponseCreators.withSuccess(new ClassPathResource("EtcdClientTest_delete.json"), MediaType.APPLICATION_JSON)); EtcdResponse response = client.compareAndSwap("sample", "Hello world", 60, false); Assert.assertNotNull("response", response); server.verify(); }
From source file:gateway.test.ServiceTests.java
/** * Test PUT /service/{serviceId}/* www. ja va 2 s. co m*/ */ @Test public void testUpdateMetadata() { // Mock HttpEntity<Service> request = new HttpEntity<Service>(null, null); doReturn(new ResponseEntity<PiazzaResponse>(new SuccessResponse("Yes", "Gateway"), HttpStatus.OK)) .when(restTemplate).exchange(any(String.class), eq(HttpMethod.PUT), any(request.getClass()), eq(SuccessResponse.class)); // Test ResponseEntity<PiazzaResponse> entity = serviceController.updateService("123456", mockService, user); // Verify assertTrue(entity.getBody() instanceof SuccessResponse); // Test Exception doThrow(new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR)).when(restTemplate).exchange( any(String.class), eq(HttpMethod.PUT), any(request.getClass()), eq(SuccessResponse.class)); ResponseEntity<PiazzaResponse> entity2 = serviceController.updateService("123456", mockService, user); assertTrue(entity2.getStatusCode().equals(HttpStatus.INTERNAL_SERVER_ERROR)); assertTrue(entity2.getBody() instanceof ErrorResponse); }
From source file:com.gooddata.dataload.processes.ProcessService.java
/** * Update process with data from appstore by given project. * Process must have set path field to valid appstore path in order to deploy from appstore. * This method is asynchronous, because when deploying from appstore, deployment worker can be triggered. * * @param process to update/*from w w w. j a v a 2 s . c o m*/ * @return updated process */ public FutureResult<DataloadProcess> updateProcessFromAppstore(DataloadProcess process) { notNull(process, "process"); notNull(process.getUri(), "process.uri"); notEmpty(process.getPath(), "process path must not be empty"); return postProcess(process, URI.create(process.getUri()), HttpMethod.PUT); }
From source file:org.cloudfoundry.identity.uaa.integration.PasswordChangeEndpointIntegrationTests.java
@Test @OAuth2ContextConfiguration(resource = OAuth2ContextConfiguration.Implicit.class, initialize = false) public void testUserMustSupplyOldPassword() throws Exception { MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>(); parameters.set("source", "credentials"); parameters.set("username", joe.getUserName()); parameters.set("password", "password"); context.getAccessTokenRequest().putAll(parameters); PasswordChangeRequest change = new PasswordChangeRequest(); change.setPassword("newpassword"); HttpHeaders headers = new HttpHeaders(); ResponseEntity<Void> result = client.exchange(serverRunning.getUrl(userEndpoint) + "/{id}/password", HttpMethod.PUT, new HttpEntity<PasswordChangeRequest>(change, headers), null, joe.getId()); assertEquals(HttpStatus.BAD_REQUEST, result.getStatusCode()); }