List of usage examples for org.apache.http.client.methods HttpPut HttpPut
public HttpPut(final String uri)
From source file:com.github.rnewson.couchdb.lucene.couchdb.HttpUtils.java
public static final int put(final HttpClient httpClient, final String url, final String body) throws IOException { final HttpPut put = new HttpPut(url); if (body != null) { put.setHeader("Content-Type", Constants.APPLICATION_JSON); put.setEntity(new StringEntity(body, "UTF-8")); }//from ww w .j a v a2 s. c om return httpClient.execute(put, new StatusCodeResponseHandler()); }
From source file:com.jaeksoft.searchlib.remote.UriWriteStream.java
public UriWriteStream(URI uri, File file) throws IOException { HttpPut httpPut = new HttpPut(uri.toASCIIString()); httpPut.setConfig(requestConfig);/*from w w w . java2 s .c om*/ FileEntity fre = new FileEntity(file, ContentType.DEFAULT_BINARY); httpPut.setEntity(fre); execute(httpPut); }
From source file:com.subgraph.vega.impl.scanner.handlers.PutChecks.java
@Override public void initialize(IPathState ps) { final IInjectionModuleContext ctx = ps.createModuleContext(); HttpUriRequest req = new HttpPut(ps.getPath().getUri().resolve("PUT-putfile")); ctx.submitRequest(req, this); }
From source file:WSpatern.LoginWS.java
public void getLoginAuth(String user, String password) { try {//w w w.j a v a 2 s.c om DefaultHttpClient client = new DefaultHttpClient(); HttpPut putRequest = new HttpPut("https://documenta-dms.com/DMSWS/api/v1/login/"); StringEntity input = new StringEntity("<user>\n" + "<username>" + user + "</username>\n" + "<password>" + password + "</password>\n" + "</user>"); input.setContentType("application/xml"); System.out.println("Out Put Of WS " + input); putRequest.setEntity(input); HttpResponse response = client.execute(putRequest); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String line = null; while ((line = rd.readLine()) != null) { System.out.println(line); if (!line.contains("<html>")) { parseXML(line); } else { valid = false; } } } catch (UnsupportedEncodingException ex) { Logger.getLogger(LoginWS.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(LoginWS.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.talend.dataprep.api.service.command.dataset.SetFavorite.java
private SetFavorite(String dataSetId, boolean unset) { super(GenericCommand.DATASET_GROUP); execute(() -> new HttpPut(datasetServiceUrl + "/datasets/" + dataSetId + "/favorite?unset=" + unset)); onError(e -> new TDPException(APIErrorCodes.UNABLE_TO_SET_FAVORITE_DATASET, e, ExceptionContext.build().put("id", dataSetId))); on(HttpStatus.OK).then(Defaults.<String>asNull()); }
From source file:com.restfiddle.handler.http.PutHandler.java
public RfResponseDTO process(RfRequestDTO rfRequestDTO) throws IOException { RfResponseDTO response = null;//from ww w . j av a 2 s .c om CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPut httpPut = new HttpPut(rfRequestDTO.getApiUrl()); httpPut.addHeader("Content-Type", "application/json"); httpPut.setEntity(new StringEntity(rfRequestDTO.getApiBody())); try { response = processHttpRequest(httpPut, httpclient); } finally { httpclient.close(); } return response; }
From source file:test.java.ecplugins.weblogic.TestUtils.java
public static void setResourceAndWorkspace(String resourceName, String workspaceName, String pluginName) throws Exception { props = getProperties();/*from w w w . jav a 2s . com*/ HttpClient httpClient = new DefaultHttpClient(); JSONObject jo = new JSONObject(); jo.put("projectName", pluginName); jo.put("resourceName", resourceName); jo.put("workspaceName", workspaceName); HttpPut httpPutRequest = new HttpPut("http://" + props.getProperty(StringConstants.COMMANDER_SERVER) + ":8000/rest/v1.0/projects/" + pluginName); String encoding = new String( org.apache.commons.codec.binary.Base64.encodeBase64(org.apache.commons.codec.binary.StringUtils .getBytesUtf8(props.getProperty(StringConstants.COMMANDER_USER) + ":" + props.getProperty(StringConstants.COMMANDER_PASSWORD)))); StringEntity input = new StringEntity(jo.toString()); input.setContentType("application/json"); httpPutRequest.setEntity(input); httpPutRequest.setHeader("Authorization", "Basic " + encoding); HttpResponse httpResponse = httpClient.execute(httpPutRequest); if (httpResponse.getStatusLine().getStatusCode() >= 400) { throw new RuntimeException("Failed to set resource " + resourceName + " to project " + pluginName); } System.out.println("Set the resource as " + resourceName + " and workspace as " + workspaceName + " successfully for " + pluginName); }
From source file:com.agile_coder.poker.client.android.MessageSender.java
public void revealEstimates() { HttpClient client = new DefaultHttpClient(); String message = host + "/poker/reveal"; HttpPut put = new HttpPut(message); try {//from w ww .jav a2s .c om HttpResponse resp = client.execute(put); if (resp.getStatusLine().getStatusCode() != 204) { throw new IllegalStateException(); } } catch (IOException e) { throw new IllegalStateException(e); } }
From source file:eu.prestoprime.p4gui.connection.AdminConnection.java
public static String createUserID(P4Service service, USER_ROLE role) { String path = service.getURL() + "/conf/user/" + role; try {/*from ww w .j a v a2s .com*/ P4HttpClient client = new P4HttpClient(service.getUserID()); HttpRequestBase request = new HttpPut(path); HttpResponse response = client.executeRequest(request); HttpEntity entity = response.getEntity(); if (entity != null) { String line; BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent())); if ((line = reader.readLine()) != null) { return line; } } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:org.talend.dataprep.api.service.command.dataset.UpdateDataSet.java
private UpdateDataSet(String id, InputStream dataSetContent) { super(GenericCommand.DATASET_GROUP); execute(() -> {// w w w.ja v a2 s.com final HttpPut put = new HttpPut(datasetServiceUrl + "/datasets/" + id); //$NON-NLS-1$ //$NON-NLS-2$ put.setHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE); put.setEntity(new InputStreamEntity(dataSetContent)); return put; }); on(HttpStatus.NO_CONTENT).then(emptyString()); on(HttpStatus.OK).then(asString()); }