Search in sources :

Example 1 with PolicyException

use of org.onap.so.serviceinstancebeans.PolicyException in project so by onap.

the class MsoRequest method buildServiceErrorResponse.

public Response buildServiceErrorResponse(int httpResponseCode, MsoException exceptionType, String errorText, String messageId, List<String> variables, String version) {
    if (errorText.length() > 1999) {
        errorText = errorText.substring(0, 1999);
    }
    RequestError re = new RequestError();
    if ("PolicyException".equals(exceptionType.name())) {
        PolicyException pe = new PolicyException();
        pe.setMessageId(messageId);
        pe.setText(errorText);
        if (variables != null) {
            for (String variable : variables) {
                pe.getVariables().add(variable);
            }
        }
        re.setPolicyException(pe);
    } else {
        ServiceException se = new ServiceException();
        se.setMessageId(messageId);
        se.setText(errorText);
        if (variables != null) {
            for (String variable : variables) {
                se.getVariables().add(variable);
            }
        }
        re.setServiceException(se);
    }
    return builder.buildResponse(httpResponseCode, null, re, version);
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) ServiceException(org.onap.so.serviceinstancebeans.ServiceException) PolicyException(org.onap.so.serviceinstancebeans.PolicyException)

Aggregations

PolicyException (org.onap.so.serviceinstancebeans.PolicyException)1 RequestError (org.onap.so.serviceinstancebeans.RequestError)1 ServiceException (org.onap.so.serviceinstancebeans.ServiceException)1