List of usage examples for org.apache.http.client.methods HttpPut HttpPut
public HttpPut(final String uri)
From source file:com.urbancode.ud.client.EnvironmentClient.java
public void addEnvironmentToTeam(String application, String environment, String team, String type) throws IOException { String uri = url + "/cli/environment/teams?team=" + encodePath(team) + "&type=" + encodePath(type) + "&environment=" + encodePath(environment); if (!StringUtils.isEmpty(application)) { uri = uri + "&application=" + encodePath(application); }//from w w w . j av a 2 s . c o m HttpPut method = new HttpPut(uri); invokeMethod(method); }
From source file:org.fusesource.fabric.itests.paxexam.FabricMavenProxyTest.java
@Test public void testUpload() throws Exception { String featureLocation = System.getProperty("feature.location"); System.out.println("Testing with feature from:" + featureLocation); System.err.println(executeCommand("fabric:create -n")); Set<Container> containers = ContainerBuilder.create(2).withName("maven").withProfiles("fabric") .assertProvisioningResult().build(); FabricService fabricService = getFabricService(); CuratorFramework curator = getCurator(); List<String> children = getChildren(curator, ZkPath.MAVEN_PROXY.getPath("upload")); List<String> uploadUrls = new ArrayList<String>(); for (String child : children) { String uploadeUrl = getSubstitutedPath(curator, ZkPath.MAVEN_PROXY.getPath("upload") + "/" + child); uploadUrls.add(uploadeUrl);/*from w w w. j ava2s . co m*/ } //Pick a random maven proxy from the list. Random random = new Random(); int index = random.nextInt(uploadUrls.size()); String targetUrl = uploadUrls.get(index); String uploadUrl = targetUrl + "itest/itest/1.0/itest-1.0-features.xml"; System.out.println("Using URI: " + uploadUrl); DefaultHttpClient client = new DefaultHttpClient(); HttpPut put = new HttpPut(uploadUrl); client.getCredentialsProvider().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin", "admin")); FileNIOEntity entity = new FileNIOEntity(new File(featureLocation), "text/xml"); put.setEntity(entity); HttpResponse response = client.execute(put); System.err.println("Response:" + response.getStatusLine()); Assert.assertTrue( response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 202); System.err.println( executeCommand("fabric:profile-edit --repositories mvn:itest/itest/1.0/xml/features default")); System.err.println(executeCommand("fabric:profile-edit --features example-cbr default")); Provision.waitForContainerStatus(containers, PROVISION_TIMEOUT); }
From source file:org.fusesource.fabric.itests.smoke.FabricMavenProxyTest.java
@Test public void testUpload() throws Exception { String featureLocation = System.getProperty("feature.location"); System.out.println("Testing with feature from:" + featureLocation); System.err.println(executeCommand("fabric:create -n")); Set<Container> containers = ContainerBuilder.create(2).withName("maven").withProfiles("fabric") .assertProvisioningResult().build(); FabricService fabricService = getFabricService(); CuratorFramework curator = getCurator(); List<String> children = getChildren(curator, ZkPath.MAVEN_PROXY.getPath("upload")); List<String> uploadUrls = new ArrayList<String>(); for (String child : children) { String uploadeUrl = getSubstitutedPath(curator, ZkPath.MAVEN_PROXY.getPath("upload") + "/" + child); uploadUrls.add(uploadeUrl);//from w w w . j a va 2s . c o m } //Pick a random maven proxy from the list. Random random = new Random(); int index = random.nextInt(uploadUrls.size()); String targetUrl = uploadUrls.get(index); String uploadUrl = targetUrl + "itest/itest/1.0/itest-1.0-features.xml"; System.out.println("Using URI: " + uploadUrl); DefaultHttpClient client = new DefaultHttpClient(); HttpPut put = new HttpPut(uploadUrl); client.getCredentialsProvider().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin", "admin")); FileNIOEntity entity = new FileNIOEntity(new File(featureLocation), "text/xml"); put.setEntity(entity); HttpResponse response = client.execute(put); System.err.println("Response:" + response.getStatusLine()); Assert.assertTrue( response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 202); System.err.println( executeCommand("fabric:profile-edit --repositories mvn:itest/itest/1.0/xml/features default")); System.err.println(executeCommand("fabric:profile-edit --features example-cbr default")); Provision.containerStatus(containers, PROVISION_TIMEOUT); }
From source file:com.arrow.acn.client.api.SoftwareReleaseScheduleApi.java
public HidModel update(String hid, UpdateSoftwareReleaseScheduleModel model) { String method = "update"; try {//from www . j ava 2s. c om URI uri = buildUri(String.format(UPDATE_URL, hid)); HidModel result = execute(new HttpPut(uri), JsonUtils.toJson(model), HidModel.class); log(method, result); return result; } catch (Throwable e) { logError(method, e); throw new AcnClientException(method, e); } }
From source file:org.yaoha.ApiConnector.java
public HttpResponse createNewChangeset() throws ClientProtocolException, IOException, OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException { URI uri = null;/* w w w . java 2s .co m*/ try { uri = new URI("http", apiUrl, "/api/0.6/changeset/create", null, null); } catch (URISyntaxException e) { Log.e(ApiConnector.class.getSimpleName(), "Creating new changeset failed:"); Log.e(ApiConnector.class.getSimpleName(), e.getMessage()); } HttpPut request = new HttpPut(uri); request.setHeader(userAgentHeader); String requestString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<osm>" + "<changeset>" + "<tag k=\"created_by\" v=\"YAOHA\"/>" + "<tag k=\"comment\" v=\"Updating opening hours\"/>" + "</changeset>" + "</osm>"; HttpEntity entity = new StringEntity(requestString, HTTP.UTF_8); request.setEntity(entity); consumer.sign(request); return client.execute(request); }
From source file:org.esxx.js.protocol.HTTPHandler.java
@Override public Object save(Context cx, Scriptable thisObj, Object data, ContentType send_ct, ContentType recv_ct) throws Exception { HttpPut put = new HttpPut(jsuri.getURI()); attachObject(data, send_ct, put, cx); Result result = sendRequest(cx, thisObj, recv_ct, put); if (result.status < 200 || result.status >= 300) { throw new JavaScriptException(makeJSResponse(cx, thisObj, result), null, 0); }/*from ww w .j a v a 2s. com*/ return result.object; }
From source file:com.urbancode.ud.client.ComponentClient.java
public void addComponentVersionStatus(String componentName, String versionName, String statusName) throws IOException { String uri = url + "/cli/version/addStatus?component=" + encodePath(componentName) + "&version=" + encodePath(versionName) + "&status=" + encodePath(statusName); HttpPut method = new HttpPut(uri); invokeMethod(method);/*from w ww . ja v a 2 s . co m*/ }
From source file:org.jboss.as.test.integration.web.security.servlet.methods.DenyUncoveredHttpMethodsTestCase.java
@Test public void testPutMethod() throws Exception { HttpPut httpPut = new HttpPut(getURL()); HttpResponse response = getHttpResponse(httpPut); assertThat(statusCodeOf(response), is(HttpServletResponse.SC_FORBIDDEN)); }
From source file:com.urbancode.ud.client.SystemClient.java
public void setSystemConfiguration(Map<String, String> properties) throws JSONException, IOException { String uri = url + "/cli/systemConfiguration"; JSONObject jsonToSend = new JSONObject(); for (String key : properties.keySet()) { jsonToSend.put(key, properties.get(key)); }// w w w. j a va 2 s . co m HttpPut method = new HttpPut(uri); method.setEntity(getStringEntity(jsonToSend)); invokeMethod(method); }
From source file:org.deviceconnect.android.profile.restful.test.NormalVibrationProfileTestCase.java
/** * Vibration????./*from w ww.j av a 2 s. c om*/ * <pre> * ?HTTP * Method: PUT * Path: /vibration/vibrate?deviceid=xxxx&pattern=xxxx * </pre> * <pre> * ?? * result?0??????? * </pre> */ public void testPutVibrate002() { StringBuilder builder = new StringBuilder(); builder.append(DCONNECT_MANAGER_URI); builder.append("/" + VibrationProfileConstants.PROFILE_NAME); builder.append("/" + VibrationProfileConstants.ATTRIBUTE_VIBRATE); builder.append("?"); builder.append(DConnectProfileConstants.PARAM_DEVICE_ID + "=" + getDeviceId()); builder.append("&"); builder.append(VibrationProfileConstants.PARAM_PATTERN + "=500,500,500"); builder.append("&"); builder.append(AuthorizationProfileConstants.PARAM_ACCESS_TOKEN + "=" + getAccessToken()); try { HttpUriRequest request = new HttpPut(builder.toString()); JSONObject root = sendRequest(request); assertResultOK(root); } catch (JSONException e) { fail("Exception in JSONObject." + e.getMessage()); } }