summaryrefslogtreecommitdiffstats
path: root/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java')
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java194
1 files changed, 97 insertions, 97 deletions
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java
index e61cf2e8..92a8269a 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java
@@ -36,37 +36,37 @@ public class Result<RV> {
private static final String SUCCESS = "Success";
public static final String[] EMPTY_VARS = new String[0];
- public final static int OK=0,
- ERR_Security = 1,
- ERR_Denied = 2,
- ERR_Policy = 3,
- ERR_BadData = 4,
- ERR_NotImplemented = 5,
- ERR_NotFound = 6,
- ERR_ConflictAlreadyExists = 7,
- ERR_ActionNotCompleted = 8,
- ERR_Backend = 9,
- ERR_General = 20;
-
- public final RV value;
- public final int status;
- public final String details;
- public final String[] variables;
-
- protected Result(RV value, int status, String details, String[] variables) {
- this.value = value;
- if(value==null) {
- specialCondition|=EMPTY_LIST;
- }
- this.status = status;
- this.details = details;
- if(variables==null) {
- this.variables = EMPTY_VARS;
- } else {
- this.variables=variables;
- }
- }
-
+ public final static int OK=0,
+ ERR_Security = 1,
+ ERR_Denied = 2,
+ ERR_Policy = 3,
+ ERR_BadData = 4,
+ ERR_NotImplemented = 5,
+ ERR_NotFound = 6,
+ ERR_ConflictAlreadyExists = 7,
+ ERR_ActionNotCompleted = 8,
+ ERR_Backend = 9,
+ ERR_General = 20;
+
+ public final RV value;
+ public final int status;
+ public final String details;
+ public final String[] variables;
+
+ protected Result(RV value, int status, String details, String[] variables) {
+ this.value = value;
+ if(value==null) {
+ specialCondition|=EMPTY_LIST;
+ }
+ this.status = status;
+ this.details = details;
+ if(variables==null) {
+ this.variables = EMPTY_VARS;
+ } else {
+ this.variables=variables;
+ }
+ }
+
/**
* Create a Result class with "OK" status and "Success" for details
*
@@ -77,7 +77,7 @@ public class Result<RV> {
* @return
*/
public static<R> Result<R> ok(R value) {
- return new Result<R>(value,OK,SUCCESS,null);
+ return new Result<R>(value,OK,SUCCESS,null);
}
/**
@@ -86,7 +86,7 @@ public class Result<RV> {
* @return
*/
public static<R> Result<R[]> ok(R value[]) {
- return new Result<R[]>(value,OK,SUCCESS,null).emptyList(value.length==0);
+ return new Result<R[]>(value,OK,SUCCESS,null).emptyList(value.length==0);
}
/**
@@ -95,7 +95,7 @@ public class Result<RV> {
* @return
*/
public static<R> Result<Set<R>> ok(Set<R> value) {
- return new Result<Set<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);
+ return new Result<Set<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);
}
/**
@@ -104,7 +104,7 @@ public class Result<RV> {
* @return
*/
public static<R> Result<List<R>> ok(List<R> value) {
- return new Result<List<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);
+ return new Result<List<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);
}
/**
@@ -113,7 +113,7 @@ public class Result<RV> {
* @return
*/
public static<R> Result<Collection<R>> ok(Collection<R> value) {
- return new Result<Collection<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);
+ return new Result<Collection<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);
}
@@ -122,7 +122,7 @@ public class Result<RV> {
* @return
*/
public static Result<Void> ok() {
- return new Result<Void>(null,OK,SUCCESS,null);
+ return new Result<Void>(null,OK,SUCCESS,null);
}
/**
@@ -133,7 +133,7 @@ public class Result<RV> {
* @return
*/
// public static<R> Result<R> err(int status, String details) {
-// return new Result<R>(null,status,details,null);
+// return new Result<R>(null,status,details,null);
// }
/**
@@ -144,7 +144,7 @@ public class Result<RV> {
* @return
*/
public static<R> Result<R> err(int status, String details, String ... variables) {
- return new Result<R>(null,status,details,variables);
+ return new Result<R>(null,status,details,variables);
}
/**
@@ -153,19 +153,19 @@ public class Result<RV> {
* @return
*/
public static<R> Result<R> err(Result<?> pdr) {
- return new Result<R>(null,pdr.status,pdr.details,pdr.variables);
- }
+ return new Result<R>(null,pdr.status,pdr.details,pdr.variables);
+ }
/**
* Create General Error from Exception
* @param e
* @return
*/
- public static<R> Result<R> err(Exception e) {
- return new Result<R>(null,ERR_General,e.getMessage(),EMPTY_VARS);
- }
+ public static<R> Result<R> err(Exception e) {
+ return new Result<R>(null,ERR_General,e.getMessage(),EMPTY_VARS);
+ }
- /**
+ /**
* Create a Status (usually non OK, with a details statement
* @param value
* @param status
@@ -173,7 +173,7 @@ public class Result<RV> {
* @return
*/
public static<R> Result<R> create(R value, int status, String details, String ... vars) {
- return new Result<R>(value,status,details,vars);
+ return new Result<R>(value,status,details,vars);
}
/**
@@ -184,18 +184,18 @@ public class Result<RV> {
* @return
*/
public static<R> Result<R> create(R value, Result<?> result) {
- return new Result<R>(value,result.status,result.details,result.variables);
+ return new Result<R>(value,result.status,result.details,result.variables);
}
private static final int PARTIAL_CONTENT = 0x001;
private static final int EMPTY_LIST = 0x002;
/**
- * AAF Specific problems, etc
- *
- * @author Jonathan
- *
- */
+ * AAF Specific problems, etc
+ *
+ * @author Jonathan
+ *
+ */
/**
* specialCondition is a bit field to enable multiple conditions, e.g. PARTIAL_CONTENT
@@ -218,10 +218,10 @@ public class Result<RV> {
*/
public Result<RV> partialContent(boolean hasPartialContent) {
if (hasPartialContent) {
- specialCondition |= PARTIAL_CONTENT;
- } else {
- specialCondition &= (~PARTIAL_CONTENT);
- }
+ specialCondition |= PARTIAL_CONTENT;
+ } else {
+ specialCondition &= (~PARTIAL_CONTENT);
+ }
return this;
}
@@ -231,7 +231,7 @@ public class Result<RV> {
* @return
*/
public boolean isEmpty() {
- return (specialCondition & EMPTY_LIST) == EMPTY_LIST;
+ return (specialCondition & EMPTY_LIST) == EMPTY_LIST;
}
/**
@@ -242,11 +242,11 @@ public class Result<RV> {
* @return
*/
public Result<RV> emptyList(boolean emptyList) {
- if (emptyList) {
- specialCondition |= EMPTY_LIST;
- } else {
- specialCondition &= (~EMPTY_LIST);
- }
+ if (emptyList) {
+ specialCondition |= EMPTY_LIST;
+ } else {
+ specialCondition &= (~EMPTY_LIST);
+ }
return this;
}
@@ -257,7 +257,7 @@ public class Result<RV> {
* @return
*/
public boolean isOK() {
- return status == OK;
+ return status == OK;
}
/**
@@ -266,7 +266,7 @@ public class Result<RV> {
* @return
*/
public boolean notOK() {
- return status != OK;
+ return status != OK;
}
/**
@@ -275,7 +275,7 @@ public class Result<RV> {
* @return
*/
public boolean isOKhasData() {
- return status == OK && (specialCondition & EMPTY_LIST) != EMPTY_LIST;
+ return status == OK && (specialCondition & EMPTY_LIST) != EMPTY_LIST;
}
@@ -285,44 +285,44 @@ public class Result<RV> {
* @return
*/
public boolean notOKorIsEmpty() {
- return status != OK || (specialCondition & EMPTY_LIST) == EMPTY_LIST;
+ return status != OK || (specialCondition & EMPTY_LIST) == EMPTY_LIST;
}
@Override
public String toString() {
- if(status==0) {
- return details;
- } else {
- StringBuilder sb = new StringBuilder();
- sb.append(status);
- sb.append(':');
- sb.append(String.format(details,((Object[])variables)));
- if(isEmpty()) {
- sb.append("{empty}");
- }
- if(value!=null) {
- sb.append('-');
- sb.append(value.toString());
- }
- return sb.toString();
- }
+ if(status==0) {
+ return details;
+ } else {
+ StringBuilder sb = new StringBuilder();
+ sb.append(status);
+ sb.append(':');
+ sb.append(String.format(details,((Object[])variables)));
+ if(isEmpty()) {
+ sb.append("{empty}");
+ }
+ if(value!=null) {
+ sb.append('-');
+ sb.append(value.toString());
+ }
+ return sb.toString();
+ }
}
public String errorString() {
- StringBuilder sb = new StringBuilder();
- switch(status) {
- case 1: sb.append("Security"); break;
- case 2: sb.append("Denied"); break;
- case 3: sb.append("Policy"); break;
- case 4: sb.append("BadData"); break;
- case 5: sb.append("NotImplemented"); break;
- case 6: sb.append("NotFound"); break;
- case 7: sb.append("AlreadyExists"); break;
- case 8: sb.append("ActionNotComplete"); break;
- default: sb.append("Error");
- }
- sb.append(" - ");
- sb.append(String.format(details, (Object[])variables));
- return sb.toString();
+ StringBuilder sb = new StringBuilder();
+ switch(status) {
+ case 1: sb.append("Security"); break;
+ case 2: sb.append("Denied"); break;
+ case 3: sb.append("Policy"); break;
+ case 4: sb.append("BadData"); break;
+ case 5: sb.append("NotImplemented"); break;
+ case 6: sb.append("NotFound"); break;
+ case 7: sb.append("AlreadyExists"); break;
+ case 8: sb.append("ActionNotComplete"); break;
+ default: sb.append("Error");
+ }
+ sb.append(" - ");
+ sb.append(String.format(details, (Object[])variables));
+ return sb.toString();
}
}