Skip to content

Commit

Permalink
Merge branch 'dev' into matchSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi authored Oct 1, 2023
2 parents 69d3502 + 777f4c9 commit 1fab207
Show file tree
Hide file tree
Showing 31 changed files with 560 additions and 107 deletions.
20 changes: 20 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
changelog:
exclude:
labels:
- ignore for release
categories:
- title: Breaking Changes 🚨
labels:
- breaking change
- title: Exciting New Features 🎉
labels:
- new feature
- title: Improvements 🌱
labels:
- improvement
- title: Bug Fixes 🛠
labels:
- bug
- title: Other Changes 📚
labels:
- "*"
18 changes: 18 additions & 0 deletions .github/workflows/removeLabel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Remove Label
on:
pull_request_target:
types: [labeled]
# Ensures that only the latest commit is running for each PR at a time.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Remove-Label:
if: contains(github.event.pull_request.labels.*.name, 'safe to test')
name: Remove label
runs-on: ubuntu-latest
steps:
- name: Remove 'safe to test'
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: "safe to test"
52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Tests
on:
push:
branches:
- '**'
tags-ignore:
- '**'
# Triggers the workflow on labeled PRs only.
pull_request_target:
types: [ labeled ]
# Ensures that only the latest commit is running for each PR at a time.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Tests:
if: contains(github.event.pull_request.labels.*.name, 'safe to test') || github.event_name == 'push'
name: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows, macOS ]
include:
- os: windows
gradlewSuffix: .bat
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
cache: false
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Artifactory
run: |
go install github.com/jfrog/jfrog-testing-infra/local-rt-setup@latest
~/go/bin/local-rt-setup
env:
RTLIC: ${{secrets.RTLIC}}
GOPROXY: direct

- name: Install Java
uses: actions/setup-java@v3
with:
java-version: "8"
distribution: "temurin"

- name: Run tests
run: ./gradlew${{ matrix.gradlewSuffix }} clean test
49 changes: 43 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
|Branch|Status|
|:---:|:---:|
|master|[![Build status](https://ci.appveyor.com/api/projects/status/sarjlbpi6dfgrd5w/branch/master?svg=true)](https://ci.appveyor.com/project/jfrog-ecosystem/artifactory-client-java/branch/master)
|dev|[![Build status](https://ci.appveyor.com/api/projects/status/sarjlbpi6dfgrd5w/branch/dev?svg=true)](https://ci.appveyor.com/project/jfrog-ecosystem/artifactory-client-java/branch/dev)
<div align="center">

# Artifactory Java Client

[![Scanned by Frogbot](https://raw.github.com/jfrog/frogbot/master/images/frogbot-badge.svg)](https://github.com/jfrog/frogbot#readme)

| Branch |Status|
|:------:|:---:|
|master|[![Test](https://github.com/jfrog/artifactory-client-java/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/jfrog/artifactory-client-java/actions/workflows/tests.yml?query=branch%3Amaster)
|dev|[![Test](https://github.com/jfrog/artifactory-client-java/actions/workflows/tests.yml/badge.svg?branch=dev)](https://github.com/jfrog/artifactory-client-java/actions/workflows/tests.yml?query=branch%3Adev)

</div>

Artifactory Java client provides simple yet powerful Artifactory connection and management within your Java code.

The client allows managing Artifactory repositories, users, groups, permissions and system configuration. It also allows
Expand Down Expand Up @@ -218,6 +224,16 @@ InputStream iStream = artifactory.repository("RepoName")
.doDownload();
```

##### Downloading Artifact with custom headers

```groovy
Map<String, String> headers = new HashMap<>();
headers.put("Range", "bytes=0-10");
InputStream iStream = artifactory.repository("RepoName")
.download("path/to/fileToDownload.txt")
.doDownloadWithHeaders(headers);
```

#### File, Folder and Repository Info

##### File Info
Expand Down Expand Up @@ -835,16 +851,37 @@ org.apache.http.Header[] headers = response.getAllHeaders();
org.apache.http.StatusLine statusLine = response.getStatusLine();
// A convenience method for verifying success
assert response.isSuccessResponse()
assert response.isSuccessResponse();
// Get the response raw body
String rawBody = response.rawBody();
String rawBody = response.getRawBody();
// If the the response raw body has a JSON format, populate an object with the body content,
// by providing a object's class.
List<Map<String, String>> parsedBody = response.parseBody(List.class);
```

Executing an Artifactory streaming REST API

```groovy
ArtifactoryRequest repositoryRequest = new ArtifactoryRequestImpl().apiUrl("api/repositories")
.method(ArtifactoryRequest.Method.GET)
.responseType(ArtifactoryRequest.ContentType.JSON);
ArtifactoryStreamingResponse response = artifactory.streamingRestCall(repositoryRequest);
// Get the response headers
org.apache.http.Header[] headers = response.getAllHeaders();
// Get the response status information
org.apache.http.StatusLine statusLine = response.getStatusLine();
// A convenience method for verifying success
assert response.isSuccessResponse();
// Get the response raw body using input stream
String rawBody = IOUtils.toString(response.getInputStream(), StandardCharsets.UTF_8);
```

## Building and Testing the Sources

The code is built using Gradle and includes integration tests.
Expand Down
9 changes: 9 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Release Notes

| Release notes moved to https://github.com/jfrog/artifactory-client-java/releases |
|----------------------------------------------------------------------------------------------------------------------------------------------------------|

## 2.15.0 (July 21, 2023)
- Support for the Cargo package manager.

## 2.14.0 (May 15, 2023)
- New option for performing download with custom headers.

## 2.13.1 (Jan 29, 2023)
- Change contentType to enable APIs with chinese parameter.

Expand Down
12 changes: 12 additions & 0 deletions api/src/main/java/org/jfrog/artifactory/client/Artifactory.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.jfrog.artifactory.client;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpUriRequest;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -42,12 +44,22 @@ public interface Artifactory extends ApiInterface, AutoCloseable {

ArtifactoryResponse restCall(ArtifactoryRequest artifactoryRequest) throws IOException;

ArtifactoryStreamingResponse streamingRestCall(ArtifactoryRequest artifactoryRequest) throws IOException;

InputStream getInputStream(String path) throws IOException;

InputStream getInputStreamWithHeaders(String path, Map<String, String> headers) throws IOException;

HttpResponse execute(HttpUriRequest request) throws IOException;

default public <T> T get(String path, Class<? extends T> object, Class<T> interfaceObject) throws IOException {
return null;
}

default public <T> T get(String path, Class<? extends T> object, Class<T> interfaceObject, Map<String, String> headers) throws IOException {
return null;
}

default public <T> T post(String path, org.apache.http.entity.ContentType contentType, String content,
Map<String, String> headers, Class<? extends T> object, Class<T> interfaceObject) throws IOException {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
package org.jfrog.artifactory.client;

import org.apache.http.Header;
import org.apache.http.StatusLine;

import java.io.IOException;

/**
* ArtifactoryResponse object returned from {@link Artifactory#restCall(ArtifactoryRequest)}.
* acts as a wrapper for {@link org.apache.http.HttpResponse} but removes the need to handle response stream.
*/
public interface ArtifactoryResponse {

Header[] getAllHeaders();

StatusLine getStatusLine();
public interface ArtifactoryResponse extends BaseArtifactoryResponse {

String getRawBody();

<T> T parseBody(Class<T> toType) throws IOException;

boolean isSuccessResponse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.jfrog.artifactory.client;

import java.io.IOException;
import java.io.InputStream;


/**
* ArtifactoryStreamingResponse object returned from {@link Artifactory#streamingRestCall(ArtifactoryRequest)}.
* acts as a wrapper for {@link org.apache.http.HttpResponse}.
*/
public interface ArtifactoryStreamingResponse extends BaseArtifactoryResponse, AutoCloseable {
InputStream getInputStream() throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.jfrog.artifactory.client;
import org.apache.http.Header;
import org.apache.http.StatusLine;

public interface BaseArtifactoryResponse {

Header[] getAllHeaders();

StatusLine getStatusLine();

boolean isSuccessResponse();

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

/**
* @author jbaruch
Expand All @@ -14,6 +15,7 @@ public interface DownloadableArtifact extends Artifact<DownloadableArtifact> {

InputStream doDownload() throws IOException;

InputStream doDownloadWithHeaders(Map<String, String> headers) throws IOException;
DownloadableArtifact withProperty(String name, Object... values);

DownloadableArtifact withProperty(String name, Object value);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.jfrog.artifactory.client.model.repository.settings;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public interface CargoRepositorySettings extends RepositorySettings {
String getGitRegistryUrl();
Boolean isCargoInternalIndex();
Boolean isCargoAnonymousAccess();
}
20 changes: 0 additions & 20 deletions ci/appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
currentVersion=2.13.x-SNAPSHOT
currentVersion=2.16.0
4 changes: 2 additions & 2 deletions release/pipelines.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pipelines:
- name: javaClientReleaseGit
integrations:
- name: il_automation
- name: entplus_deployer
- name: ecosys_entplus_deployer
- name: mvn_central
execution:
onExecute:
Expand All @@ -47,7 +47,7 @@ pipelines:
# Configure JFrog CLI
- curl -fL https://install-cli.jfrog.io | sh
- jf c rm --quiet
- jf c add internal --url=$int_entplus_deployer_url --user=$int_entplus_deployer_user --password=$int_entplus_deployer_apikey
- jf c add internal --url=$int_ecosys_entplus_deployer_url --user=$int_ecosys_entplus_deployer_user --password=$int_ecosys_entplus_deployer_apikey
- jf gradlec --use-wrapper --deploy-ivy-desc=false --deploy-maven-desc --uses-plugin --repo-resolve ecosys-maven-remote --repo-deploy ecosys-oss-release-local

# Sync changes with dev
Expand Down
4 changes: 2 additions & 2 deletions release/pipelines.snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pipelines:
inputResources:
- name: javaClientSnapshotGit
integrations:
- name: entplus_deployer
- name: ecosys_entplus_deployer
execution:
onStart:
# Save gradle cache
Expand All @@ -35,7 +35,7 @@ pipelines:
# Configure JFrog CLI
- curl -fL https://install-cli.jfrog.io | sh
- jf c rm --quiet
- jf c add internal --url=$int_entplus_deployer_url --user=$int_entplus_deployer_user --password=$int_entplus_deployer_apikey
- jf c add internal --url=$int_ecosys_entplus_deployer_url --user=$int_ecosys_entplus_deployer_user --password=$int_ecosys_entplus_deployer_apikey
- jf gradlec --use-wrapper --deploy-ivy-desc=false --deploy-maven-desc --uses-plugin --repo-resolve ecosys-maven-remote --repo-deploy ecosys-oss-snapshot-local

# Run audit
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.jfrog.artifactory.client.impl;

import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;

public abstract class AbstractArtifactoryResponseImpl {

private final HttpResponse httpResponse;

public AbstractArtifactoryResponseImpl(HttpResponse httpResponse) {
this.httpResponse = httpResponse;
}

public HttpResponse getHttpResponse() {
return httpResponse;
}

public Header[] getAllHeaders() {
return this.httpResponse.getAllHeaders();
}

public StatusLine getStatusLine() {
return this.httpResponse.getStatusLine();
}

}
Loading

0 comments on commit 1fab207

Please sign in to comment.