com.lionbridge.content.sdk.ErrorManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liox-content-sdk-java Show documentation
Show all versions of liox-content-sdk-java Show documentation
Client for Lionbridge Ondemand API
package com.lionbridge.content.sdk;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import java.util.List;
public class ErrorManager {
@JacksonXmlElementWrapper(useWrapping=true)
@JacksonXmlProperty(localName="Errors")
private List errors;
@JacksonXmlProperty(localName="Status")
private String status = "";
private String errorCode="";
public ContentAPIException generateException() {
ContentAPIException exception;
StringBuilder builder = new StringBuilder();
LBError error = errors.get(0);
if (error != null && error.getSimpleMessage() != null && !error.getSimpleMessage().isEmpty()) {
if (error.getDetailedMessage() != null) {
builder.append(error.getSimpleMessage()).append(": ").append(error.getDetailedMessage());
exception = new ContentAPIException(builder.toString());
} else{
exception = new ContentAPIException(error.getSimpleMessage());
}
} else {
exception = new ContentAPIException(this.errorCode);
}
exception.setErrors(errors);
return exception;
}
public String toXmlString() {
StringBuilder xmlString = new StringBuilder("\n");
if(null != this.errors) {
for(LBError currentError : this.errors) {
xmlString.append("\n\t");
xmlString.append("\n\t\t").append(currentError.getReasonCode()).append(" ");
xmlString.append("\n\t\t").append(currentError.getSimpleMessage()).append(" ");
xmlString.append("\n\t\t").append(currentError.getDetailedMessage()).append(" ");
xmlString.append("\n\t ");
}
}
xmlString.append("\n ");
return xmlString.toString();
}
public List getErrors() {
return this.errors;
}
public void setErrors(final List errors) {
this.errors = errors;
}
public final String getStatus() {
return this.status;
}
public final void setStatus(final String status) {
this.status = status;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(final String errorCode) {
this.errorCode = errorCode;
}
}