Skip to content

Commit

Permalink
Merge pull request #314 from KPMP/develop
Browse files Browse the repository at this point in the history
Release (update to fix space)
  • Loading branch information
rlreamy authored Oct 15, 2024
2 parents 353ccb1 + a1e66db commit 33dc814
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/kpmp/globus/GlobusService.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ protected String getFileManagerUrl(String fullDirName) {
public List<GlobusFileListing> getFilesAndDirectoriesAtEndpoint(String packageId) throws JsonProcessingException, IOException {
String topDirectory = env.getProperty("GLOBUS_DIR");
String fullDirName = topDirectory + "/" + packageId;

GenericUrl url = new GenericUrl(API_URL + "/operation/endpoint/" + endpointID + "/ls?path=" + fullDirName);
fullDirName.replace(" ", "+");
GenericUrl url = new GenericUrl(API_URL + "/operation/endpoint/" + endpointID + "/ls?path=" + fullDirName + "&type:dir");

HttpRequest request = requestFactory.buildGetRequest(url);
request.setParser(new JsonObjectParser(JSON_FACTORY));

Type type = new TypeToken<GlobusListingResponse>() {
}.getType();
Type type = new TypeToken<GlobusListingResponse>() {}.getType();
HttpResponse response = request.execute();
GlobusListingResponse globusListing = (GlobusListingResponse) response.parseAs(type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,31 @@ public void testProcessGlobusDirectory() throws JsonProcessingException, IOExcep
assertEquals(expectedResults, actualListing);
}

@Test
public void testProcessGlobusDirectory_spacesInDirectoryNames() throws JsonProcessingException, IOException {
Map<String, List<String>> actualListing = new HashMap<String, List<String>>();
GlobusFileListing globusFile1 = new GlobusFileListing();
globusFile1.setName("file1");
globusFile1.setType("file");
GlobusFileListing globusFile2 = new GlobusFileListing();
globusFile2.setName("file2");
globusFile2.setType("file");
when(globus.getFilesAndDirectoriesAtEndpoint("123/directory 1")).thenReturn(Arrays.asList(globusFile1, globusFile2));
GlobusFileListing globusFile3 = new GlobusFileListing();
globusFile3.setName("file3");
globusFile3.setType("file");
GlobusFileListing globusFile4 = new GlobusFileListing();
globusFile4.setName("file4");
globusFile4.setType("file");
when(globus.getFilesAndDirectoriesAtEndpoint("123/directory2")).thenReturn(Arrays.asList(globusFile3, globusFile4));
Map<String, List<String>> expectedResults = new HashMap<>();
expectedResults.put("directory 1", Arrays.asList("file1", "file2"));
expectedResults.put("directory2", Arrays.asList("file3", "file4"));

actualListing = service.processGlobusDirectory(new HashMap<String, List<String>>(), Arrays.asList("directory 1", "directory2"), "123", "", "");

assertEquals(expectedResults, actualListing);
}

@Test
public void testProcessGlobusDirectory_withSubdirectories() throws JsonProcessingException, IOException {
Expand Down

0 comments on commit 33dc814

Please sign in to comment.