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

This commit is contained in:
Bharat Viswanadham 2018-10-31 07:54:23 -07:00
parent b519f3f2a0
commit 478b2cba0d
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
```
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>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

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