public static Document createSoapResponseDocument( Document responseXml ) {
return createSoapResponseDocument( responseXml, "content" );
}
private static Element createSoapFaultElement( List messages ) {
Element faultElement = new DefaultElement( "SOAP-ENV:Fault" );
// TODO mlowery begin hack: copied in getFirstError code from MessageFormatter
// to avoid needing an IPentahoSession
String message = null;
String errorStart = PentahoMessenger.getUserString( "ERROR" ); //$NON-NLS-1$
int pos = errorStart.indexOf( '{' );
if ( pos != -1 ) {
errorStart = errorStart.substring( 0, pos );
}
Iterator msgIterator = messages.iterator();
while ( msgIterator.hasNext() ) {
String msg = (String) msgIterator.next();
if ( msg.indexOf( errorStart ) == 0 ) {
message = msg;
}
}
// TODO mlowery end hack
if ( message == null ) {
message = Messages.getInstance().getErrorString( "SoapHelper.ERROR_0001_UNKNOWN_ERROR" ); //$NON-NLS-1$
}
// Envelope envelope = new Envelope();
// Fault fault = new Fault( );
// TODO: Generate the following message using the envelope and fault objects
// TODO determine if this is a reciever or a sender problem by examining
// the error code
boolean senderFault = ( message.indexOf( "SolutionEngine.ERROR_0002" ) != -1 ) || //$NON-NLS-1$ // solution not specifed
( message.indexOf( "SolutionEngine.ERROR_0003" ) != -1 ) || //$NON-NLS-1$ // Path not specifeid
( message.indexOf( "SolutionEngine.ERROR_0004" ) != -1 ) || //$NON-NLS-1$ // Action not specified
( message.indexOf( "SolutionEngine.ERROR_0005" ) != -1 ); //$NON-NLS-1$ // Action not found
// send the error code
// TODO parse out the error code
faultElement
.addElement( "SOAP-ENV:Fault" ).addElement( "SOAP-ENV:Subcode" ).addElement( "SOAP-ENV:Value" ).addCDATA( message ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if ( senderFault ) {
faultElement.addElement( "SOAP-ENV:faultactor" ).setText( "SOAP-ENV:Client" ); //$NON-NLS-1$ //$NON-NLS-2$
} else {
faultElement.addElement( "SOAP-ENV:faultactor" ).setText( "SOAP-ENV:Server" ); //$NON-NLS-1$ //$NON-NLS-2$
}
Element faultTextElement = faultElement.addElement( "SOAP-ENV:faultstring" ).addElement( "SOAP-ENV:Text" );
faultTextElement.addAttribute( "xml:lang", LocaleHelper.getDefaultLocale().toString() );
faultTextElement.addCDATA( message );
Element detailElement = faultElement.addElement( "SOAP-ENV:Detail" );
Iterator messageIterator = messages.iterator();
while ( messageIterator.hasNext() ) {
detailElement.addElement( "message" ).addAttribute( "name", "trace" ).addCDATA( (String) messageIterator.next() );
}
return faultElement;