-
Notifications
You must be signed in to change notification settings - Fork 155
list all files under specific folder #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
I-Iege
wants to merge
1
commit into
jfrog:dev
Choose a base branch
from
I-Iege:list_all_files
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
api/src/main/java/org/jfrog/artifactory/client/FolderHandle.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package org.jfrog.artifactory.client; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
| import org.jfrog.artifactory.client.model.FileList; | ||
|
|
||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| public interface FolderHandle extends ItemHandle { | ||
| FileList list(boolean deep, boolean listFolders, boolean timestamps); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
api/src/main/java/org/jfrog/artifactory/client/model/FileList.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package org.jfrog.artifactory.client.model; | ||
|
|
||
| import java.util.Date; | ||
| import java.util.List; | ||
|
|
||
| public interface FileList { | ||
|
|
||
| String getUri(); | ||
| Date getCreated(); | ||
| List<ListItem> getFiles(); | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
api/src/main/java/org/jfrog/artifactory/client/model/ListItem.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package org.jfrog.artifactory.client.model; | ||
|
|
||
| import java.util.Date; | ||
|
|
||
| public interface ListItem { | ||
| String getUri(); | ||
| Long getSize(); | ||
| Date getLastModified(); | ||
| Boolean isFolder(); | ||
| String getSha1(); | ||
| } |
43 changes: 43 additions & 0 deletions
43
services/src/main/groovy/org/jfrog/artifactory/client/impl/FolderHandleImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package org.jfrog.artifactory.client.impl; | ||
|
|
||
| import org.jfrog.artifactory.client.FolderHandle; | ||
| import org.jfrog.artifactory.client.model.FileList; | ||
| import org.jfrog.artifactory.client.model.impl.FileListImpl; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class FolderHandleImpl extends ItemHandleImpl implements FolderHandle { | ||
|
|
||
| private final String baseApiPath; | ||
|
|
||
| private final ArtifactoryImpl artifactory; | ||
| private final String repo; | ||
| private final String path; | ||
|
|
||
| FolderHandleImpl(ArtifactoryImpl artifactory, String baseApiPath, String repo, String path, Class itemType) { | ||
| super(artifactory, baseApiPath, repo, path, itemType); | ||
| this.artifactory = artifactory; | ||
| this.repo = repo; | ||
| this.path = path; | ||
| this.baseApiPath = baseApiPath; | ||
| } | ||
|
|
||
| public FileList list(boolean deep, boolean listFolders, boolean timestamps) { | ||
| String deepInt = toInt(deep); | ||
| String listFoldersInt = toInt(listFolders); | ||
| String timestampsInt = toInt(timestamps); | ||
| String url = String.format("%s/storage/%s/%s?list&deep=%s&listFolders=%s&mdTimestamps=%s", | ||
| baseApiPath, repo, path, deepInt, listFoldersInt, timestampsInt); | ||
|
|
||
| FileListImpl fileListImpl = new FileListImpl(); | ||
| try { | ||
| return artifactory.get(url, fileListImpl.getClass(), null); | ||
| } catch (IOException e) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| private String toInt(boolean b) { | ||
| return b?"1":"0"; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
services/src/main/java/org/jfrog/artifactory/client/model/impl/FileListImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package org.jfrog.artifactory.client.model.impl; | ||
|
|
||
| import org.jfrog.artifactory.client.model.FileList; | ||
| import org.jfrog.artifactory.client.model.ListItem; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Date; | ||
| import java.util.List; | ||
|
|
||
| public class FileListImpl implements FileList { | ||
|
|
||
| String uri; | ||
| Date created; | ||
| ListItemImpl[] files; | ||
|
|
||
| FileListImpl(String uri, Date created, ListItemImpl[] files) { | ||
| this.uri = uri; | ||
| this.created = created; | ||
| this.files = files; | ||
| } | ||
|
|
||
| public FileListImpl() { | ||
| } | ||
|
|
||
| @Override | ||
| public String getUri() { | ||
| return uri; | ||
| } | ||
|
|
||
| @Override | ||
| public Date getCreated() { | ||
| return created; | ||
| } | ||
|
|
||
| @Override | ||
| public List<ListItem> getFiles() { | ||
| return Arrays.asList(files); | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
services/src/main/java/org/jfrog/artifactory/client/model/impl/ListItemImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package org.jfrog.artifactory.client.model.impl; | ||
|
|
||
| import org.jfrog.artifactory.client.model.File; | ||
| import org.jfrog.artifactory.client.model.ListItem; | ||
|
|
||
| import java.util.Date; | ||
|
|
||
| public class ListItemImpl implements ListItem { | ||
| String uri; | ||
| Long size; | ||
| Date lastModified; | ||
| Boolean folder; | ||
| String sha1; | ||
|
|
||
| ListItemImpl(String uri, Long size, Date lastModified, Boolean folder) { | ||
| this.uri = uri; | ||
| this.size = size; | ||
| this.lastModified = lastModified; | ||
| this.folder = folder; | ||
| } | ||
|
|
||
| ListItemImpl() { | ||
| } | ||
|
|
||
| @Override | ||
| public String getUri() { | ||
| return uri; | ||
| } | ||
|
|
||
| @Override | ||
| public Long getSize() { | ||
| return size; | ||
| } | ||
|
|
||
| @Override | ||
| public Date getLastModified() { | ||
| return lastModified; | ||
| } | ||
|
|
||
| @Override | ||
| public Boolean isFolder() { | ||
| return folder; | ||
| } | ||
|
|
||
| @Override | ||
| public String getSha1() { | ||
| return sha1; | ||
| } | ||
|
|
||
| } |
2 changes: 1 addition & 1 deletion
2
services/src/main/resources/artifactory.client.release.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| version=2.9.1 | ||
| version=2.9.x-SNAPSHOT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this new interface (and its implementing class)?
I can see that it is used as the returned value for this new API -
but the returned value of this API can also be -
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i need it for the deserialization because the return data has this structure:
String uri;
Date created;
ListItemImpl[] files;