} else if ( result != null ) {
// now set the failure information in the temporary context
ContextManager contextManager = null;
try {
contextManager = (ContextManager) this.manager.lookup( ContextManager.ROLE );
SessionContext temp = contextManager.getContext( SessionConstants.TEMPORARY_CONTEXT );
final DocumentFragment fragment = result.result.createDocumentFragment();
final Node root = result.result.getDocumentElement();
root.normalize();
Node child;
boolean appendedNode = false;
while (root.hasChildNodes() ) {
child = root.getFirstChild();
root.removeChild(child);
// Leave out empty text nodes before any other node
if (appendedNode
|| child.getNodeType() != Node.TEXT_NODE
|| child.getNodeValue().trim().length() > 0) {
fragment.appendChild(child);
appendedNode = true;
}
}
temp.appendXML("/", fragment);
} catch ( ServiceException se ) {
throw new ProcessingException("Unable to lookup session manager.", se);
} finally {
this.manager.release( contextManager );
}