public void success(ActionInvocation invocation) { log.fine("Successful browse action, reading output argument values"); BrowseResult result = new BrowseResult( invocation.getOutput("Result").getValue().toString(), (UnsignedIntegerFourBytes) invocation.getOutput("NumberReturned").getValue(), (UnsignedIntegerFourBytes) invocation.getOutput("TotalMatches").getValue(), (UnsignedIntegerFourBytes) invocation.getOutput("UpdateID").getValue()); boolean proceed = receivedRaw(invocation, result); if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) { try { DIDLParser didlParser = new DIDLParser(); DIDLContent didl = didlParser.parse(result.getResult()); received(invocation, didl); updateStatus(Status.OK); } catch (Exception ex) { invocation.setFailure( new ActionException( ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex)); failure(invocation, null); } } else { received(invocation, new DIDLContent()); updateStatus(Status.NO_CONTENT); } }
public void readBody(ActionResponseMessage responseMsg, ActionInvocation actionInvocation) throws UnsupportedDataException { log.fine("Reading body of " + responseMsg + " for: " + actionInvocation); if (log.isLoggable(Level.FINER)) { log.finer( "===================================== SOAP BODY BEGIN ============================================"); log.finer(responseMsg.getBodyString()); log.finer( "-===================================== SOAP BODY END ============================================"); } String body = getMessageBody(responseMsg); try { DocumentBuilderFactory factory = createDocumentBuilderFactory(); factory.setNamespaceAware(true); DocumentBuilder documentBuilder = factory.newDocumentBuilder(); documentBuilder.setErrorHandler(this); Document d = documentBuilder.parse(new InputSource(new StringReader(body))); Element bodyElement = readBodyElement(d); ActionException failure = readBodyFailure(d, bodyElement); if (failure == null) { readBodyResponse(d, bodyElement, responseMsg, actionInvocation); } else { actionInvocation.setFailure(failure); } } catch (Exception ex) { throw new UnsupportedDataException("Can't transform message payload: " + ex, ex, body); } }