Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public enum S3GAction implements AuditAction {
CREATE_DIRECTORY,
GENERATE_SECRET,
REVOKE_SECRET,
GET_OBJECT_TORRENT,
GET_OBJECT_TAGGING,
PUT_OBJECT_TAGGING,
DELETE_OBJECT_TAGGING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public ObjectEndpoint() {
protected void init() {
super.init();
ObjectOperationHandler chain = ObjectOperationHandlerChain.newBuilder(this)
.add(new ObjectGetTorrentHandler())
.add(new ObjectAclHandler())
.add(new ObjectTaggingHandler())
.add(new MultipartKeyHandler())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.ozone.s3.endpoint;

import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.NOT_IMPLEMENTED;
import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.newError;

import java.io.IOException;
import javax.ws.rs.core.Response;
import org.apache.hadoop.ozone.audit.S3GAction;
import org.apache.hadoop.ozone.s3.endpoint.ObjectEndpoint.ObjectRequestContext;
import org.apache.hadoop.ozone.s3.exception.OS3Exception;
import org.apache.hadoop.ozone.s3.util.S3Consts.QueryParams;

/**
* Handles GET object {@code ?torrent} ({@code GetObjectTorrent}).
* <p>
* This operation is not implemented; previously the request incorrectly fell
* through to GetObject and returned the raw object body.
*/
class ObjectGetTorrentHandler extends ObjectOperationHandler {

@Override
Response handleGetRequest(ObjectRequestContext context, String keyName)
throws IOException, OS3Exception {
if (queryParams().get(QueryParams.TORRENT) == null) {
return null;
}

context.setAction(S3GAction.GET_OBJECT_TORRENT);
throw newError(NOT_IMPLEMENTED, "GetObjectTorrent");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public static final class QueryParams {
public static final String PREFIX = "prefix";
public static final String START_AFTER = "start-after";
public static final String TAGGING = "tagging";
// GetObjectTorrent is not implemented
public static final String TORRENT = "torrent";
public static final String UPLOAD_ID = "uploadId";
public static final String UPLOAD_ID_MARKER = "upload-id-marker";
public static final String UPLOADS = "uploads";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.ozone.s3.endpoint;

import static org.apache.hadoop.ozone.s3.endpoint.EndpointTestUtils.assertErrorResponse;
import static org.apache.hadoop.ozone.s3.endpoint.EndpointTestUtils.get;

import java.io.IOException;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientStub;
import org.apache.hadoop.ozone.s3.exception.S3ErrorTable;
import org.apache.hadoop.ozone.s3.util.S3Consts.QueryParams;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/** Tests for {@code GET /{bucket}/{key}?torrent} ({@code GetObjectTorrent}). */
public class TestObjectGetTorrent {

private static final String BUCKET_NAME = "b1";
private static final String KEY_NAME = "key1";
private ObjectEndpoint objectEndpoint;

@BeforeEach
public void setup() throws IOException {
final OzoneClient clientStub = new OzoneClientStub();
clientStub.getObjectStore().createS3Bucket(BUCKET_NAME);

objectEndpoint = EndpointBuilder.newObjectEndpointBuilder()
.setClient(clientStub)
.build();
}

@Test
public void getObjectTorrentIsNotImplemented() {
objectEndpoint.queryParamsForTest().set(QueryParams.TORRENT, "");

assertErrorResponse(S3ErrorTable.NOT_IMPLEMENTED, () -> get(objectEndpoint, BUCKET_NAME, KEY_NAME));
}
}