@Override protected String executeUpload(String uploadURL, Map<String, String> params, Map<String, File> files, UploadProgress writeListener) throws Exception { if (isVerbose()) { String msg = "API call: " + uploadURL; if (params != null && params.size() > 0) msg += ",P" + params; if (files != null && files.size() > 0) msg += ",F" + files; trace(msg); } return super.executeUpload(uploadURL, params, files, writeListener); }
public String executeRequest(String url) throws Exception { HttpClient httpClient = HttpClientHelper.createClient(this.beesClientConfiguration); GetMethod getMethod = new GetMethod(url); decorateWithAuthorization(getMethod); int code = httpClient.executeMethod(getMethod); String response = getResponseString(getMethod.getResponseBodyAsStream()); if (code >= 300) { processError(response, code); } return response; }
public String getRequestURL(String method, Map<String, String> methodParams) throws Exception { return getRequestURL(method, methodParams, true); }
protected String executeUpload(String uploadURL, Map<String, String> params, Map<String, File> files, UploadProgress writeListener) throws Exception { HashMap<String, String> clientParams = getDefaultParameters(); clientParams.putAll(params); parts.add(new StringPart("sig", calculateSignature(clientParams))); client.getHttpConnectionManager().getParams().setConnectionTimeout( 10000); decorateWithAuthorization(filePost); int status = client.executeMethod(filePost); String response = getResponseString(filePost.getResponseBodyAsStream()); if (status == HttpStatus.SC_OK) { trace("upload complete, response=" + response); } else { trace("upload failed, response=" + HttpStatus.getStatusText(status)); processError(response, status);
public String getRequestURL(String method, Map<String, String> methodParams, boolean asActionParam) throws Exception { HashMap<String, String> urlParams = getDefaultParameters(); StringBuilder requestURL = getApiUrl(asActionParam ? null : method); requestURL.append("?"); requestURL.append("="); if (secret!=null) requestURL.append(calculateSignature(urlParams));
@Override public String executeRequest(String url) throws Exception { trace("API call: " + url); String response = super.executeRequest(url); traceResponse(response); return response; }
@Override protected boolean execute() throws Exception { // install the artifact try { ArtifactInstallFactory installFactory = artifactInstallFactoryProvider.get(); if (forceInstall()) installFactory.setForceInstall(true); if (localrepo != null) installFactory.setLocalRepository(localrepo); installFactory.setBeesClientConfiguration(getBeesClientBase().getBeesClientConfiguration()); GAV gav = new GAV(getArtifact()); if (pom != null && jar != null) { gav = installFactory.install(gav, jar, pom); } else gav = installFactory.install(gav); System.out.println("Plugin installed: " + gav); } catch (Exception e) { throw (IOException) new IOException("Failed to install " + getArtifact()).initCause(e); } return true; }
private String calculateSignature(Map<String, String> entries) throws Exception { StringBuilder sigData = new StringBuilder(); ArrayList<Map.Entry<String, String>> sortedParams = new ArrayList<Map.Entry<String, String>>(entries.entrySet()); Collections.sort(sortedParams, new Comparator<Map.Entry<String, String>>() { public int compare(Entry<String, String> e1, Entry<String, String> e2) { return e1.getKey().compareTo(e2.getKey()); } }); for (Map.Entry<String, String> entry : sortedParams) { String key = entry.getKey(); String value = entry.getValue(); sigData.append(key); sigData.append(value); } // append the signature return getSignature(sigData.toString(), secret); }
@Override public String executeRequest(String url) throws Exception { trace("API call: " + url); String response = super.executeRequest(url); traceResponse(response); return response; }
@Override public RemoteRepository decorate(RemoteRepository repo) { try { BeesClientConfiguration bcc = bees.get().getBeesClientConfiguration(); if (bcc==null) return repo; if (bcc.getProxyHost() != null && bcc.getProxyPort() > 0) { String proxyType = Proxy.TYPE_HTTP; if (repo.getUrl().startsWith("https")) proxyType = Proxy.TYPE_HTTPS; Proxy proxy = new Proxy(proxyType, bcc.getProxyHost(), bcc.getProxyPort(), null); if (bcc.getProxyUser() != null) { Authentication authentication = new Authentication(bcc.getProxyUser(), bcc.getProxyPassword()); proxy.setAuthentication(authentication); } repo.setProxy(proxy); } return repo; } catch (IOException e) { throw (Error)new Error("Failed to configure remote repository").initCause(e); } } }
public InputStream executeCometRequest(String url) throws Exception { HttpClient httpClient = HttpClientHelper.createClient(this.beesClientConfiguration); HttpParams params = httpClient.getParams(); params.setIntParameter(HttpConnectionParams.SO_TIMEOUT, 0); GetMethod getMethod = new GetMethod(url); decorateWithAuthorization(getMethod); int code = httpClient.executeMethod(getMethod); if (code >= 300) { processError(getResponseString(getMethod.getResponseBodyAsStream()), code); } return getMethod.getResponseBodyAsStream(); }
@Override protected String executeUpload(String uploadURL, Map<String, String> params, Map<String, File> files, UploadProgress writeListener) throws Exception { if (isVerbose()) { String msg = "API call: " + uploadURL; if (params != null && params.size() > 0) msg += ",P" + params; if (files != null && files.size() > 0) msg += ",F" + files; trace(msg); } return super.executeUpload(uploadURL, params, files, writeListener); }