HDDS-773. Loading ozone s3 bucket browser could be failed. Contributed by Elek Marton.

(cherry picked from commit 478b2cba0d)
This commit is contained in:
Bharat Viswanadham 2018-10-31 07:54:23 -07:00
parent 7495fad190
commit 81d3e1b1ae
3 changed files with 15 additions and 6 deletions

View File

@ -23,5 +23,5 @@ You need to
3. Set bucket/endpointurl during the robot test execution 3. Set bucket/endpointurl during the robot test execution
``` ```
robot -v bucket:ozonetest -v OZONE_S3_SET_CREDENTIALS:false -v ENDPOINT_URL:https://s3.us-east-2.amazonaws.com smoketest/s3 robot -v bucket:ozonetest -v OZONE_TEST:false -v OZONE_S3_SET_CREDENTIALS:false -v ENDPOINT_URL:https://s3.us-east-2.amazonaws.com smoketest/s3
``` ```

View File

@ -174,5 +174,11 @@
<version>2.15.0</version> <version>2.15.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -46,6 +46,7 @@ import org.apache.hadoop.ozone.s3.endpoint.MultiDeleteResponse.Error;
import org.apache.hadoop.ozone.s3.exception.OS3Exception; import org.apache.hadoop.ozone.s3.exception.OS3Exception;
import org.apache.hadoop.ozone.s3.exception.S3ErrorTable; import org.apache.hadoop.ozone.s3.exception.S3ErrorTable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.ozone.s3.util.S3utils; import org.apache.hadoop.ozone.s3.util.S3utils;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
@ -70,6 +71,7 @@ public class BucketEndpoint extends EndpointBase {
* for more details. * for more details.
*/ */
@GET @GET
@SuppressFBWarnings
public Response list( public Response list(
@PathParam("bucket") String bucketName, @PathParam("bucket") String bucketName,
@QueryParam("delimiter") String delimiter, @QueryParam("delimiter") String delimiter,
@ -83,12 +85,12 @@ public class BucketEndpoint extends EndpointBase {
@Context HttpHeaders hh) throws OS3Exception, IOException { @Context HttpHeaders hh) throws OS3Exception, IOException {
if (browser != null) { if (browser != null) {
try (InputStream browserPage = getClass() InputStream browserPage = getClass()
.getResourceAsStream("/browser.html")) { .getResourceAsStream("/browser.html");
return Response.ok(browserPage, return Response.ok(browserPage,
MediaType.TEXT_HTML_TYPE) MediaType.TEXT_HTML_TYPE)
.build(); .build();
}
} }
if (prefix == null) { if (prefix == null) {
@ -295,7 +297,8 @@ public class BucketEndpoint extends EndpointBase {
keyMetadata.setSize(next.getDataSize()); keyMetadata.setSize(next.getDataSize());
keyMetadata.setETag("" + next.getModificationTime()); keyMetadata.setETag("" + next.getModificationTime());
keyMetadata.setStorageClass("STANDARD"); keyMetadata.setStorageClass("STANDARD");
keyMetadata.setLastModified(Instant.ofEpochMilli(next.getModificationTime())); keyMetadata.setLastModified(Instant.ofEpochMilli(
next.getModificationTime()));
response.addKey(keyMetadata); response.addKey(keyMetadata);
} }
} }