-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new method to set/get object retention & Legal Hold (#836)
- Loading branch information
1 parent
aa42f0e
commit 8427afc
Showing
7 changed files
with
953 additions
and
30 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
api/src/main/java/io/minio/messages/ObjectLockLegalHold.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. | ||
* | ||
* Licensed 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 io.minio.messages; | ||
|
||
import org.xmlpull.v1.XmlPullParserException; | ||
import com.google.api.client.util.Key; | ||
|
||
|
||
/** | ||
* Helper class to construct create bucket configuration request XML for Amazon AWS S3. | ||
*/ | ||
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "URF_UNREAD_FIELD") | ||
public class ObjectLockLegalHold extends XmlEntity{ | ||
@Key("Status") | ||
private String status; | ||
|
||
/** | ||
* Constructs a new ObjectLockLegalHold object . | ||
*/ | ||
public ObjectLockLegalHold() throws XmlPullParserException { | ||
super(); | ||
super.name = "LegalHold"; | ||
} | ||
|
||
/** | ||
* Constructs a new ObjectLockLegalHold object with given status. | ||
*/ | ||
public ObjectLockLegalHold(boolean status) throws XmlPullParserException { | ||
this(); | ||
if (status) { | ||
this.status = "ON"; | ||
} else { | ||
this.status = "OFF"; | ||
} | ||
} | ||
|
||
/** | ||
* Indicates whether the specified object has a Legal Hold in place or not. | ||
*/ | ||
public boolean status() { | ||
return status != null && status.equals("ON"); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
api/src/main/java/io/minio/messages/ObjectRetentionConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. | ||
* | ||
* Licensed 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 io.minio.messages; | ||
|
||
import org.xmlpull.v1.XmlPullParserException; | ||
|
||
import io.minio.DateFormat; | ||
import org.joda.time.DateTime; | ||
import com.google.api.client.util.Key; | ||
import io.minio.errors.InvalidArgumentException; | ||
|
||
/** | ||
* Helper class to parse Amazon AWS S3 response XML containing ObjectLockRetention information. | ||
*/ | ||
@SuppressWarnings("SameParameterValue") | ||
public class ObjectRetentionConfiguration extends XmlEntity { | ||
@Key("Mode") | ||
private String mode; | ||
@Key("RetainUntilDate") | ||
private String retainUntilDate; | ||
|
||
/** | ||
* Constructs a new ObjectRetentionConfiguration object. | ||
*/ | ||
public ObjectRetentionConfiguration() throws XmlPullParserException { | ||
super(); | ||
super.name = "Retention"; | ||
} | ||
|
||
/** | ||
* Constructs a new ObjectRetentionConfiguration object with given retention | ||
* until date and mode. | ||
*/ | ||
public ObjectRetentionConfiguration(RetentionMode mode, DateTime retainUntilDate) throws XmlPullParserException, | ||
InvalidArgumentException { | ||
this(); | ||
if (mode == null) { | ||
throw new InvalidArgumentException("null mode is not allowed"); | ||
} | ||
this.mode = mode.toString(); | ||
if (retainUntilDate == null) { | ||
throw new InvalidArgumentException("null retainUntilDate is not allowed"); | ||
} | ||
this.retainUntilDate = retainUntilDate.toString(DateFormat.EXPIRATION_DATE_FORMAT); | ||
} | ||
|
||
/** | ||
* Returns mode. | ||
*/ | ||
public RetentionMode mode() { | ||
return this.mode == null ? null : RetentionMode.fromString(this.mode); | ||
} | ||
|
||
/** | ||
* Returns retain until date. | ||
*/ | ||
public DateTime retainUntilDate() { | ||
return this.retainUntilDate == null ? null : | ||
DateFormat.EXPIRATION_DATE_FORMAT.parseDateTime(this.retainUntilDate); | ||
} | ||
} | ||
|
Oops, something went wrong.