public DownloadableArtifact withProperty(String name, Object value) { super.withProperty(name, value); return this; }
public Searches searches() { return new SearchesImpl(this, API_BASE); }
@Override public ArtifactorySystem system() { return new ArtifactorySystemImpl(this, API_BASE); }
private List getPermissionTargets() throws Exception { ArtifactoryRequest req = new ArtifactoryRequestImpl() .method(ArtifactoryRequest.Method.GET) .apiUrl("api/security/permissions") .responseType(ArtifactoryRequest.ContentType.JSON); ArtifactoryResponse response = artifactory.restCall(req); List<String> responseBody = response.parseBody(List.class); return responseBody; }
private void uploadBuild() throws Exception { ArtifactoryRequest buildRequest = new ArtifactoryRequestImpl() .method(ArtifactoryRequest.Method.PUT) .requestType(ArtifactoryRequest.ContentType.JSON) .responseType(ArtifactoryRequest.ContentType.JSON) .apiUrl("api/build") .requestBody(buildBody); artifactory.restCall(buildRequest); }
public RepositoryHandle repository(String repo) { if (StringUtils.isBlank(repo)) { throw new IllegalArgumentException("Repository name is required"); } return new RepositoriesImpl(this, API_BASE).repository(repo); }
public InputStream getInputStream(String path) throws IOException { HttpResponse httpResponse = get(path, null, null); if (httpResponse.getStatusLine().getStatusCode() == 200) { return httpResponse.getEntity().getContent(); } throw newHttpResponseException(httpResponse); }
@Override public <T> T parseBody(Class<T> toType) throws IOException { Util.configureObjectMapper(objectMapper); try { return objectMapper.readValue(rawBody, toType); } catch (IOException e) { throw new IOException("Failed casting response entity to " + toType.toString() + ". response status: " + getStatusLine().toString() + ". raw entity: " + this.rawBody, e); } }
public Repositories repositories() { return new RepositoriesImpl(this, API_BASE); }
public Plugins plugins() { return new PluginsImpl(this, API_BASE); }
public Storage storage() { return new StorageImpl(this); }
public Security security() { return new SecurityImpl(this, API_BASE); }
@Override public boolean isSuccessResponse() { int status = getStatusLine().getStatusCode(); return status >= 200 && status < 300; } }
public InputStream doDownload() throws IOException { String params = parseParams(props, "=") + parseParams(mandatoryProps, "+="); if (params.length() > 0) { params = ";" + params; } String uri = String.format("/%s/%s%s", repo, path, params); return artifactory.getInputStream(uri); }
private String executeApi(String command) throws Exception { ArtifactoryRequest renameRequest = new ArtifactoryRequestImpl() .method(ArtifactoryRequest.Method.POST) .apiUrl("api/system/replications/" + command) .responseType(ArtifactoryRequest.ContentType.TEXT); return artifactory.restCall(renameRequest).getRawBody(); }
private void calcSha256ForItem(String repoName, String path) throws Exception { String content = "{\"repoKey\":\""+ repoName +"\", \"path\":\""+path+"\"}"; ArtifactoryRequest request = new ArtifactoryRequestImpl() .apiUrl("api/checksum/sha256") .method(ArtifactoryRequest.Method.POST) .requestType(ArtifactoryRequest.ContentType.JSON) .requestBody(content); artifactory.restCall(request); } }
public DownloadableArtifact withProperty(String name, Object... values) { super.withProperty(name, values); return this; }
private String deleteBuild(String name) throws Exception { ArtifactoryRequest deleteBuild = new ArtifactoryRequestImpl() .apiUrl("api/build/" + name) .method(ArtifactoryRequest.Method.DELETE) .responseType(ArtifactoryRequest.ContentType.TEXT) .addQueryParam("buildNumbers", (String) buildBody.get("number")) .addQueryParam("deleteAll", "1") .addQueryParam("artifacts", "1"); return artifactory.restCall(deleteBuild).getRawBody(); }
@Test public void testRequestWithTextResponse() throws Exception { ArtifactoryRequest systemInfo = new ArtifactoryRequestImpl() .method(ArtifactoryRequest.Method.GET) .apiUrl("api/system/ping") .responseType(ArtifactoryRequest.ContentType.TEXT); ArtifactoryResponse response = artifactory.restCall(systemInfo); assertTrue(response.isSuccessResponse()); }
@Test public void testRequestWithJsonResponse() throws Exception { ArtifactoryRequest versionRequest = new ArtifactoryRequestImpl() .apiUrl("api/system/version") .responseType(ArtifactoryRequest.ContentType.JSON) .method(ArtifactoryRequest.Method.GET); ArtifactoryResponse response = artifactory.restCall(versionRequest); Map<String, Object> versionRequestResponse = response.parseBody(Map.class); assertTrue(versionRequestResponse.containsKey("version")); assertTrue(versionRequestResponse.containsKey("revision")); assertTrue(versionRequestResponse.containsKey("addons")); }