com.dell.cpsd.common.rabbitmq.validators.MessageValidationException Maven / Gradle / Ivy
/**
* Copyright © 2017 Dell Inc. or its subsidiaries. All Rights Reserved.
* Dell EMC Confidential/Proprietary Information
*/
package com.dell.cpsd.common.rabbitmq.validators;
import com.dell.cpsd.common.rabbitmq.exceptions.ApplicationException;
import java.util.List;
/**
* Exception signaling that message validation failed.
*
*
* Copyright © 2017 Dell Inc. or its subsidiaries. All Rights Reserved.
* Dell EMC Confidential/Proprietary Information
*
*/
public class MessageValidationException extends ApplicationException
{
private static final long serialVersionUID = -2326041223674348892L;
private ValidationResult validationResult;
public MessageValidationException(ValidationResult validationResult)
{
super(validationResult.getLocalizedErrors());
this.validationResult = validationResult;
}
private static String getFirstError(ValidationResult result)
{
if (result == null)
{
return null;
}
List errors = result.getErrors();
if (errors == null || errors.isEmpty())
{
return null;
}
return errors.get(0);
}
public ValidationResult getValidationResult()
{
return validationResult;
}
public String getFirstError()
{
return getFirstError(validationResult);
}
}