Skip to content

Commit cb38f09

Browse files
committed
Adding undelete object command
1 parent bc6102d commit cb38f09

File tree

6 files changed

+214
-0
lines changed

6 files changed

+214
-0
lines changed

contract/5_0_x_contract.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4602,6 +4602,32 @@
46024602
</ResponseCodes>
46034603
<Version>1.BDA9A7110ADB2C122D0CA705B6B1D6FA</Version>
46044604
</RequestHandler>
4605+
<RequestHandler Classification="spectrads3" Name="com.spectralogic.s3.server.handler.reqhandler.spectrads3.object.UndeleteObjectRequestHandler">
4606+
<Request Action="BULK_MODIFY" HttpVerb="PUT" IncludeIdInPath="false" Resource="OBJECT" ResourceType="NON_SINGLETON">
4607+
<OptionalQueryParams>
4608+
<Param Name="VersionId" Type="java.util.UUID"/>
4609+
</OptionalQueryParams>
4610+
<RequiredQueryParams>
4611+
<Param Name="BucketId" Type="java.util.UUID"/>
4612+
<Param Name="Name" Type="java.lang.String"/>
4613+
</RequiredQueryParams>
4614+
</Request>
4615+
<ResponseCodes>
4616+
<ResponseCode>
4617+
<Code>200</Code>
4618+
<ResponseTypes>
4619+
<ResponseType Type="com.spectralogic.s3.common.dao.domain.ds3.S3Object"/>
4620+
</ResponseTypes>
4621+
</ResponseCode>
4622+
<ResponseCode>
4623+
<Code>404</Code>
4624+
<ResponseTypes>
4625+
<ResponseType Type="com.spectralogic.s3.server.domain.HttpErrorResultApiBean"/>
4626+
</ResponseTypes>
4627+
</ResponseCode>
4628+
</ResponseCodes>
4629+
<Version>1.94C075BD3FE76604F8ED084C9B9E4AE5</Version>
4630+
</RequestHandler>
46054631
<RequestHandler Classification="spectrads3" Name="com.spectralogic.s3.server.handler.reqhandler.spectrads3.object.VerifyPhysicalPlacementForObjectsRequestHandler">
46064632
<Request Action="SHOW" HttpVerb="GET" IncludeIdInPath="true" Operation="VERIFY_PHYSICAL_PLACEMENT" Resource="BUCKET" ResourceType="NON_SINGLETON">
46074633
<OptionalQueryParams>
@@ -5442,6 +5468,12 @@
54425468
<ResponseType Type="com.spectralogic.s3.common.dao.domain.ds3.StorageDomainMember"/>
54435469
</ResponseTypes>
54445470
</ResponseCode>
5471+
<ResponseCode>
5472+
<Code>400</Code>
5473+
<ResponseTypes>
5474+
<ResponseType Type="com.spectralogic.s3.server.domain.HttpErrorResultApiBean"/>
5475+
</ResponseTypes>
5476+
</ResponseCode>
54455477
</ResponseCodes>
54465478
<Version>1.2861D535C9E907B2316C6DD326F9C9DB</Version>
54475479
</RequestHandler>

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3Client.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,13 @@ GetPhysicalPlacementForObjectsSpectraS3Response getPhysicalPlacementForObjectsSp
13791379
GetPhysicalPlacementForObjectsWithFullDetailsSpectraS3Response getPhysicalPlacementForObjectsWithFullDetailsSpectraS3(final GetPhysicalPlacementForObjectsWithFullDetailsSpectraS3Request request)
13801380
throws IOException;
13811381

1382+
@ResponsePayloadModel("S3Object")
1383+
@Action("BULK_MODIFY")
1384+
@Resource("OBJECT")
1385+
1386+
UndeleteObjectSpectraS3Response undeleteObjectSpectraS3(final UndeleteObjectSpectraS3Request request)
1387+
throws IOException;
1388+
13821389
@ResponsePayloadModel("PhysicalPlacement")
13831390
@Action("SHOW")
13841391
@Resource("BUCKET")

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3ClientImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,10 @@ public GetPhysicalPlacementForObjectsWithFullDetailsSpectraS3Response getPhysica
858858
return new GetPhysicalPlacementForObjectsWithFullDetailsSpectraS3ResponseParser().response(this.netClient.getResponse(request));
859859
}
860860
@Override
861+
public UndeleteObjectSpectraS3Response undeleteObjectSpectraS3(final UndeleteObjectSpectraS3Request request) throws IOException {
862+
return new UndeleteObjectSpectraS3ResponseParser().response(this.netClient.getResponse(request));
863+
}
864+
@Override
861865
public VerifyPhysicalPlacementForObjectsSpectraS3Response verifyPhysicalPlacementForObjectsSpectraS3(final VerifyPhysicalPlacementForObjectsSpectraS3Request request) throws IOException {
862866
return new VerifyPhysicalPlacementForObjectsSpectraS3ResponseParser().response(this.netClient.getResponse(request));
863867
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
// This code is auto-generated, do not modify
17+
package com.spectralogic.ds3client.commands.parsers;
18+
19+
import com.spectralogic.ds3client.commands.parsers.interfaces.AbstractResponseParser;
20+
import com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils;
21+
import com.spectralogic.ds3client.commands.spectrads3.UndeleteObjectSpectraS3Response;
22+
import com.spectralogic.ds3client.models.S3Object;
23+
import com.spectralogic.ds3client.networking.WebResponse;
24+
import com.spectralogic.ds3client.serializer.XmlOutput;
25+
import java.io.IOException;
26+
import java.io.InputStream;
27+
28+
public class UndeleteObjectSpectraS3ResponseParser extends AbstractResponseParser<UndeleteObjectSpectraS3Response> {
29+
private final int[] expectedStatusCodes = new int[]{200};
30+
31+
@Override
32+
public UndeleteObjectSpectraS3Response parseXmlResponse(final WebResponse response) throws IOException {
33+
final int statusCode = response.getStatusCode();
34+
if (ResponseParserUtils.validateStatusCode(statusCode, expectedStatusCodes)) {
35+
switch (statusCode) {
36+
case 200:
37+
try (final InputStream inputStream = response.getResponseStream()) {
38+
final S3Object result = XmlOutput.fromXml(inputStream, S3Object.class);
39+
return new UndeleteObjectSpectraS3Response(result, this.getChecksum(), this.getChecksumType());
40+
}
41+
42+
default:
43+
assert false: "validateStatusCode should have made it impossible to reach this line";
44+
}
45+
}
46+
47+
throw ResponseParserUtils.createFailedRequest(response, expectedStatusCodes);
48+
}
49+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
// This code is auto-generated, do not modify
17+
package com.spectralogic.ds3client.commands.spectrads3;
18+
19+
import com.spectralogic.ds3client.networking.HttpVerb;
20+
import com.spectralogic.ds3client.commands.interfaces.AbstractRequest;
21+
import com.google.common.net.UrlEscapers;
22+
import java.util.UUID;
23+
24+
public class UndeleteObjectSpectraS3Request extends AbstractRequest {
25+
26+
// Variables
27+
28+
private final String bucketId;
29+
30+
private final String name;
31+
32+
private String versionId;
33+
34+
// Constructor
35+
36+
37+
public UndeleteObjectSpectraS3Request(final String bucketId, final String name) {
38+
this.bucketId = bucketId;
39+
this.name = name;
40+
41+
this.updateQueryParam("bucket_id", bucketId);
42+
43+
this.updateQueryParam("name", name);
44+
45+
}
46+
47+
public UndeleteObjectSpectraS3Request withVersionId(final UUID versionId) {
48+
this.versionId = versionId.toString();
49+
this.updateQueryParam("version_id", versionId);
50+
return this;
51+
}
52+
53+
54+
public UndeleteObjectSpectraS3Request withVersionId(final String versionId) {
55+
this.versionId = versionId;
56+
this.updateQueryParam("version_id", versionId);
57+
return this;
58+
}
59+
60+
61+
62+
@Override
63+
public HttpVerb getVerb() {
64+
return HttpVerb.PUT;
65+
}
66+
67+
@Override
68+
public String getPath() {
69+
return "/_rest_/object";
70+
}
71+
72+
public String getBucketId() {
73+
return this.bucketId;
74+
}
75+
76+
77+
public String getName() {
78+
return this.name;
79+
}
80+
81+
82+
public String getVersionId() {
83+
return this.versionId;
84+
}
85+
86+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
// This code is auto-generated, do not modify
17+
package com.spectralogic.ds3client.commands.spectrads3;
18+
19+
import com.spectralogic.ds3client.models.S3Object;
20+
import com.spectralogic.ds3client.models.ChecksumType;
21+
import com.spectralogic.ds3client.commands.interfaces.AbstractResponse;
22+
23+
public class UndeleteObjectSpectraS3Response extends AbstractResponse {
24+
25+
private final S3Object s3ObjectResult;
26+
27+
public UndeleteObjectSpectraS3Response(final S3Object s3ObjectResult, final String checksum, final ChecksumType.Type checksumType) {
28+
super(checksum, checksumType);
29+
this.s3ObjectResult = s3ObjectResult;
30+
}
31+
32+
public S3Object getS3ObjectResult() {
33+
return this.s3ObjectResult;
34+
}
35+
36+
}

0 commit comments

Comments
 (0)