private static void addStatusMessageForEachCause(final Throwable cause, final int currentCauseDepth, final int maxIncludedCauseDepth, final List<Element> statusDetailElements,
final Marshaller xacml3Marshaller) throws JAXBException
{
if (cause == null)
{
return;
}
assert statusDetailElements != null;
final DOMResult domResult = new DOMResult();
xacml3Marshaller.marshal(Xacml3JaxbHelper.XACML_3_0_OBJECT_FACTORY.createStatusMessage(cause.getMessage()), domResult);
statusDetailElements.add(((Document) domResult.getNode()).getDocumentElement());
if (currentCauseDepth == maxIncludedCauseDepth)
{
return;
}
addStatusMessageForEachCause(cause.getCause(), currentCauseDepth + 1, maxIncludedCauseDepth, statusDetailElements, xacml3Marshaller);
}