Skip to content

Commit

Permalink
Merge pull request #8 from EMCECS/feature-folder-download
Browse files Browse the repository at this point in the history
Feature completed
  • Loading branch information
DavidASeibert authored Oct 18, 2018
2 parents 1408a9b + 6a6ddcf commit 48466be
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ FROM openjdk:8
EXPOSE 8080

WORKDIR /usr/src/app
COPY build/libs/ecs-browser-0.9.1.jar ./
COPY build/libs/ecs-browser-1.0.0rc1.jar ./

CMD [ "java", "-jar", "ecs-browser-0.9.1.jar" ]
CMD [ "java", "-jar", "ecs-browser-1.0.0rc1.jar" ]
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description = "ECS browser website"
group = 'com.emc.ecs'
version = '0.9.1'
version = '1.0.0rc1'

ext.licenseName = ''
ext.licenseUrl = ''
Expand Down Expand Up @@ -30,7 +30,7 @@ defaultTasks 'build'

jar {
baseName = 'ecs-browser'
version = '0.9.1'
version = '1.0.0rc1'
into('META-INF/dependency-license') {
from 'build/reports/dependency-license'
}
Expand Down
22 changes: 20 additions & 2 deletions src/main/java/com/emc/ecs/browser/spring/ServiceController.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,33 @@ public ResponseEntity<?> postProxy(HttpServletRequest request) throws Exception
RequestEntity<byte[]> requestEntity = new RequestEntity<byte[]>(data, newHeaders, method, new URI(resource));
RestTemplate client = new RestTemplate();
try {
dataToReturn = client.exchange(requestEntity, ListObjectsResult.class);
dataToReturn = new WrappedResponseEntity( client.exchange(requestEntity, ListObjectsResult.class) );
if ( ((ResponseEntity<ListObjectsResult>) dataToReturn).getStatusCode().is2xxSuccessful() ) {
ListObjectsResult objectsToDownload = ((ResponseEntity<ListObjectsResult>) dataToReturn).getBody();
downloadObjects( downloadFolder, objectsToDownload.getBucketName(), objectsToDownload.getObjects(), s3Config );
String separator = resource.indexOf("?") < 0 ? "?" : "&";
while ( objectsToDownload.isTruncated() ) {
String marker = objectsToDownload.getNextMarker();
if ( ( marker == null ) || marker.isEmpty() ) {
marker = objectsToDownload.getObjects().get( objectsToDownload.getObjects().size() - 1 ).getKey();
}
String newUrl = resource + separator + "marker=" + marker;
System.out.println("Another page after " + marker + " using " + newUrl );
requestEntity = new RequestEntity<byte[]>(data, newHeaders, method, new URI(newUrl));
dataToReturn = new WrappedResponseEntity( client.exchange(requestEntity, ListObjectsResult.class) );
if ( !((ResponseEntity<ListObjectsResult>) dataToReturn).getStatusCode().is2xxSuccessful() ) {
break;
}
objectsToDownload = ((ResponseEntity<ListObjectsResult>) dataToReturn).getBody();
downloadObjects( downloadFolder, objectsToDownload.getBucketName(), objectsToDownload.getObjects(), s3Config );
}
}
} catch (HttpClientErrorException e) {
dataToReturn = new ErrorData(e); // handle and display on the other end
e.printStackTrace(System.out);
} catch (Exception e) {
dataToReturn = new ErrorData(e); // handle and display on the other end
e.printStackTrace(System.out);
}
} else {
sign(method.toString(), resource, parameters, headers, s3Config);
Expand Down Expand Up @@ -289,7 +307,7 @@ private void downloadObjects(String downloadFolder, String bucketName, List<S3Ob
if ( !downloadBucket.mkdirs() ) {
throw new Exception( "Download location cannot be created: " + downloadBucket.getAbsolutePath() );
}
} else if ( downloadBucket.isDirectory() ) {
} else if ( !downloadBucket.isDirectory() ) {
throw new Exception( "Download location is not a folder: " + downloadBucket.getAbsolutePath() );
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/static/javascript/MetadataSearchPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, EMC Corporation. All rights reserved.
* Copyright (c) 2017-2018, EMC Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,6 +64,7 @@ MetadataSearchPage.prototype.getMetadataSearchParameters = function() {
separator = '&';
}
} );
metadataSearchParameters = metadataSearchParameters + separator + 'attributes=ALL_SMD';
if ( metadataSearchParameters.indexOf( 'query=' ) < 0 ) {
metadataSearchParameters = '';
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/javascript/ecs-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function combineWithDelimiter( part1, part2 ) {

function handleData( data, callback, dataProcessor ) {
if ( ( data.status && ( ( data.status >= 200 ) && ( data.status < 300 ) ) )
|| ( data.statusCode && data.statusCode == 'OK' ) ) {
|| ( data.statusCode && data.statusCode == 'OK') ) {
if (dataProcessor) {
data = dataProcessor( data );
}
Expand Down

0 comments on commit 48466be

Please sign in to comment.