Skip to content

Commit

Permalink
Address bala's comment
Browse files Browse the repository at this point in the history
  • Loading branch information
sinhaashish committed May 29, 2020
1 parent 6e50845 commit 305c1f3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 58 deletions.
21 changes: 12 additions & 9 deletions examples/DisableObjectLegalHold.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@ public static void main(String[] args)
.object("my-objectname")
.build());

// Check if the object legal hold is enabled or not.
System.out.println(
" Is object legal hold is enabled "
+ minioClient.isObjectLegalHoldEnabled(
IsObjectLegalHoldEnabledArgs.builder()
.bucket("my-bucketname")
.object("my-objectname")
.versionId("object-versionId")
.build()));
boolean status =
minioClient.isObjectLegalHoldEnabled(
IsObjectLegalHoldEnabledArgs.builder()
.bucket("my-bucketname")
.object("my-objectname")
.build());

if (status) {
System.out.println("Legal hold is on");
} else {
System.out.println("Legal hold is off");
}

} catch (MinioException e) {
System.out.println("Error occurred: " + e);
Expand Down
21 changes: 12 additions & 9 deletions examples/EnableObjectLegalHold.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@ public static void main(String[] args)
.versionId("object-versionId")
.build());

// Check if the object legal hold is enabled or not.
System.out.println(
" Is object legal hold is enabled "
+ minioClient.isObjectLegalHoldEnabled(
IsObjectLegalHoldEnabledArgs.builder()
.bucket("my-bucketname")
.object("my-objectname")
.versionId("object-versionId")
.build()));
boolean status =
minioClient.isObjectLegalHoldEnabled(
IsObjectLegalHoldEnabledArgs.builder()
.bucket("my-bucketname")
.object("my-objectname")
.build());

if (status) {
System.out.println("Legal hold is on");
} else {
System.out.println("Legal hold is off");
}

} catch (MinioException e) {
System.out.println("Error occurred: " + e);
Expand Down
48 changes: 8 additions & 40 deletions functional/FunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3520,8 +3520,9 @@ public static void composeObject_test6() throws Exception {

/** Test: enableObjectLegalHold(EnableObjectLegalHoldArgs args) */
public static void enableObjectLegalHold_test() throws Exception {
String methodName = "enableObjectLegalHold(EnableObjectLegalHoldArgs args)";
if (!mintEnv) {
System.out.println("Test: enableObjectLegalHold(EnableObjectLegalHoldArgs args)");
System.out.println("Test: " + methodName);
}
long startTime = System.currentTimeMillis();
String bucketName = getRandomName();
Expand All @@ -3542,38 +3543,22 @@ public static void enableObjectLegalHold_test() throws Exception {
}
client.disableObjectLegalHold(
DisableObjectLegalHoldArgs.builder().bucket(bucketName).object(objectName).build());
mintSuccessLog("enableObjectLegalHold(EnableObjectLegalHoldArgs args)", null, startTime);
mintSuccessLog(methodName, null, startTime);
} finally {
client.removeObject(
RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build());
client.removeBucket(RemoveBucketArgs.builder().bucket(bucketName).build());
}
} catch (Exception e) {
ErrorResponse errorResponse = null;
if (e instanceof ErrorResponseException) {
ErrorResponseException exp = (ErrorResponseException) e;
errorResponse = exp.errorResponse();
}

// Ignore NotImplemented error
if (errorResponse != null && errorResponse.errorCode() == ErrorCode.NOT_IMPLEMENTED) {
mintIgnoredLog("enableObjectLegalHold(EnableObjectLegalHoldArgs args)", null, startTime);
} else {
mintFailedLog(
"enableObjectLegalHold(EnableObjectLegalHoldArgs args)",
null,
startTime,
null,
e.toString() + " >>> " + Arrays.toString(e.getStackTrace()));
throw e;
}
handleException(methodName, null, startTime, e);
}
}

/** Test: disableObjectLegalHold(DisableObjectLegalHoldArgs args) */
public static void disableObjectLegalHold_test() throws Exception {
String methodName = "disableObjectLegalHold(DisableObjectLegalHoldArgs args)";
if (!mintEnv) {
System.out.println("Test: disableObjectLegalHold(DisableObjectLegalHoldArgs args)");
System.out.println("Test: " + methodName);
}
long startTime = System.currentTimeMillis();
String bucketName = getRandomName();
Expand All @@ -3597,26 +3582,9 @@ public static void disableObjectLegalHold_test() throws Exception {
RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build());
client.removeBucket(RemoveBucketArgs.builder().bucket(bucketName).build());
}
mintSuccessLog("disableObjectLegalHold(DisableObjectLegalHoldArgs args)", null, startTime);
mintSuccessLog(methodName, null, startTime);
} catch (Exception e) {
ErrorResponse errorResponse = null;
if (e instanceof ErrorResponseException) {
ErrorResponseException exp = (ErrorResponseException) e;
errorResponse = exp.errorResponse();
}

// Ignore NotImplemented error
if (errorResponse != null && errorResponse.errorCode() == ErrorCode.NOT_IMPLEMENTED) {
mintIgnoredLog("disableObjectLegalHold(DisableObjectLegalHoldArgs args)", null, startTime);
} else {
mintFailedLog(
"disableObjectLegalHold(DisableObjectLegalHoldArgs args)",
null,
startTime,
null,
e.toString() + " >>> " + Arrays.toString(e.getStackTrace()));
throw e;
}
handleException(methodName, null, startTime, e);
}
}

Expand Down

0 comments on commit 305c1f3

Please sign in to comment.