Skip to content

Commit

Permalink
Add new method to set/get object retention & Legal Hold (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinhaashish authored Feb 13, 2020
1 parent aa42f0e commit 8427afc
Show file tree
Hide file tree
Showing 7 changed files with 953 additions and 30 deletions.
376 changes: 354 additions & 22 deletions api/src/main/java/io/minio/MinioClient.java

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions api/src/main/java/io/minio/messages/ObjectLockLegalHold.java
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");
}
}
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);
}
}

Loading

0 comments on commit 8427afc

Please sign in to comment.