diff options
Diffstat (limited to 'common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java')
-rw-r--r-- | common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java b/common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java index 6b3bb545de..2fe3910486 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java @@ -21,36 +21,35 @@ package org.onap.so.client.aai; import java.util.List; - import org.onap.so.client.aai.entities.AAIError; import org.onap.so.client.aai.entities.ServiceException; public class AAIErrorFormatter { - private final AAIError error; - public AAIErrorFormatter(AAIError error) { - this.error = error; - } - - public String getMessage() { - if (error.getRequestError() != null && - error.getRequestError().getServiceException() != null) { - ServiceException serviceException = error.getRequestError().getServiceException(); - return this.fillInTemplate(serviceException.getText(), serviceException.getVariables()); - } - - return "no parsable error message found"; - } - - protected String fillInTemplate(String text, List<String> variables) { - for (int i = 0; i < variables.size(); i++) { - variables.set(i, this.format(variables.get(i), variables)); - } - - return format(text, variables); - } - - protected String format(String s, List<String> variables) { - return String.format(s.replaceAll("%(\\d+)", "%$1\\$s"), variables.toArray()); - } + private final AAIError error; + + public AAIErrorFormatter(AAIError error) { + this.error = error; + } + + public String getMessage() { + if (error.getRequestError() != null && error.getRequestError().getServiceException() != null) { + ServiceException serviceException = error.getRequestError().getServiceException(); + return this.fillInTemplate(serviceException.getText(), serviceException.getVariables()); + } + + return "no parsable error message found"; + } + + protected String fillInTemplate(String text, List<String> variables) { + for (int i = 0; i < variables.size(); i++) { + variables.set(i, this.format(variables.get(i), variables)); + } + + return format(text, variables); + } + + protected String format(String s, List<String> variables) { + return String.format(s.replaceAll("%(\\d+)", "%$1\\$s"), variables.toArray()); + } } |