org.ow2.petals.binding.soap.util.SOAPFaultHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of petals-bc-soap Show documentation
Show all versions of petals-bc-soap Show documentation
The PEtALS SOAP JBI binding component based on Axis2 and Jetty.
The newest version!
/**
* Copyright (c) 2006-2012 EBM WebSourcing, 2012-2023 Linagora
*
* This program/library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or (at your
* option) any later version.
*
* This program/library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program/library; If not, see http://www.gnu.org/licenses/
* for the GNU Lesser General Public License version 2.1.
*/
package org.ow2.petals.binding.soap.util;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
import org.apache.axiom.soap.SOAPFaultCode;
import org.apache.axiom.soap.SOAPFaultDetail;
import org.apache.axiom.soap.SOAPFaultReason;
/**
* The SOAP Fault Helper.
*
* @author Frederic Gardes - EBM WebSourcing
* @author Christophe DENEUX - Linagora
*/
public final class SOAPFaultHelper {
/**
* The message by default for the faults.
*/
private static final String JBI_FAULT_STRING = "A fault occured at the JBI level, see details.";
/**
* Not allow to instantiate.
*/
private SOAPFaultHelper() {
// Utility class --> No constructor
}
/**
*
* Create a Business SOAP fault from the provided body content.
*
*
* The content of the body is used as fault details.
*
*
* @param soapFactory
* The factory used to create the fault and identify the version
* @param jbiNmContent
* Content of the normalized message returned at JBI level
* @return The business SOAP fault associated to the normalized message returned at JBI level
*/
public static SOAPFault createBusinessSOAPFault(final SOAPFactory soapFactory, final OMElement jbiNmContent) {
final SOAPFault soapFault = soapFactory.createSOAPFault();
final SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode();
// As it's a business fault, the fault code is 'CLIENT'
soapFaultCode.setText(soapFactory.getSOAPVersion().getSenderFaultCode());
soapFault.setCode(soapFaultCode);
final SOAPFaultReason soapFaultReason = soapFactory.createSOAPFaultReason();
soapFaultReason.setText(JBI_FAULT_STRING);
soapFault.setReason(soapFaultReason);
final SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail();
soapFaultDetail.addDetailEntry(jbiNmContent);
soapFault.setDetail(soapFaultDetail);
return soapFault;
}
}