-
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
- Loading branch information
1 parent
8166510
commit b5c1c80
Showing
7 changed files
with
473 additions
and
5 deletions.
There are no files selected for viewing
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
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
79 changes: 79 additions & 0 deletions
79
api/src/main/java/io/minio/messages/ObjectLockRetention.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,79 @@ | ||
/* | ||
* 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 java.util.Date; | ||
import org.joda.time.DateTime; | ||
import com.google.api.client.util.Key; | ||
|
||
/** | ||
* Helper class to parse Amazon AWS S3 response XML containing ObjectLockRetention information. | ||
*/ | ||
@SuppressWarnings("SameParameterValue") | ||
public class ObjectLockRetention extends XmlEntity { | ||
@Key("Mode") | ||
private String mode; | ||
@Key("RetainUntilDate") | ||
private String retainUntilDate; | ||
|
||
/** | ||
* Constructs a new ObjectLockRetention object. | ||
*/ | ||
public ObjectLockRetention() throws XmlPullParserException { | ||
super(); | ||
super.name = "Retention"; | ||
} | ||
|
||
/** | ||
* Constructs a new CustomRetention object with given retention. | ||
*/ | ||
public ObjectLockRetention(RetentionMode mode, String retainUntilDate) throws XmlPullParserException { | ||
super(); | ||
super.name = "Retention"; | ||
if (mode != null) { | ||
this.mode = mode.toString(); | ||
} | ||
if (retainUntilDate != null ) { | ||
this.retainUntilDate = retainUntilDate; | ||
} | ||
} | ||
|
||
/** | ||
* Returns mode. | ||
*/ | ||
public RetentionMode mode() { | ||
return RetentionMode.fromString(mode); | ||
} | ||
|
||
/** | ||
* Returns retain until date. | ||
*/ | ||
public DateTime retainUntil() { | ||
return DateFormat.RETENTION_DATE_FORMAT.parseDateTime(retainUntilDate); | ||
} | ||
|
||
/** | ||
* Returns retain until date. | ||
*/ | ||
public Date getRetentionDate() { | ||
return DateFormat.RETENTION_DATE_FORMAT.parseDateTime(retainUntilDate).toDate(); | ||
} | ||
} | ||
|
84 changes: 84 additions & 0 deletions
84
api/src/main/java/io/minio/messages/ObjectLockRetentionConfiguration.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,84 @@ | ||
/* | ||
* 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; | ||
|
||
|
||
/** | ||
* 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 ObjectLockRetentionConfiguration extends XmlEntity { | ||
@Key("ObjectRetention") | ||
private ObjectLockRetention objectLockRetention; | ||
@Key("BypassGovernanceRetention") | ||
private boolean bypassGovernanceRetention; | ||
@Key("Version") | ||
private String versionId; | ||
|
||
/** | ||
* Constructs a new ObjectLockRetentionConfiguration object with given input parameters. | ||
*/ | ||
public ObjectLockRetentionConfiguration(RetentionMode mode, boolean bypassGovernanceRetention, | ||
DateTime retainUntilDate, String versionId) throws XmlPullParserException { | ||
super(); | ||
this.bypassGovernanceRetention = bypassGovernanceRetention; | ||
this.versionId = versionId ; | ||
this.objectLockRetention = new ObjectLockRetention(mode, | ||
retainUntilDate.toString(DateFormat.RETENTION_DATE_FORMAT)); | ||
} | ||
|
||
|
||
/** | ||
* Returns mode. | ||
*/ | ||
public RetentionMode mode() { | ||
if (objectLockRetention == null) { | ||
return null; | ||
} | ||
return objectLockRetention.mode(); | ||
} | ||
|
||
|
||
/** | ||
* Returns retantion untill date. | ||
*/ | ||
public DateTime retainUntil() { | ||
if (objectLockRetention == null) { | ||
return null; | ||
} | ||
return objectLockRetention.retainUntil(); | ||
} | ||
|
||
/** | ||
* Returns version. | ||
*/ | ||
public String version() { | ||
return this.versionId; | ||
} | ||
|
||
/** | ||
* Returns boolean for governanceBypass. | ||
*/ | ||
public boolean governanceBypass() { | ||
return this.bypassGovernanceRetention; | ||
} | ||
} |
Oops, something went wrong.