Examples of XMLOutputter


Examples of org.jdom.output.XMLOutputter

    // response to that queue.  The QueueRequestor will wait for a response on
    // that TemporaryQueue.

    Document responseDoc = null;
    TextMessage outMessage = createTextMessage();
    XMLOutputter xmlOut = new XMLOutputter();
    String requestBody = xmlOut.outputString(doc);
    logger.debug("Producing Request:\n" + requestBody);
    try {
      outMessage.setText(requestBody);
      outMessage.setStringProperty(MessageProducer.COMMAND_NAME, theObject.getCommandName());
      outMessage.setStringProperty(MessageProducer.MESSAGE_NAME, theObject.getCommandName());   // backward compatibility
View Full Code Here

Examples of org.jdom.output.XMLOutputter

    logger.debug("eLayout is " + layoutName);

    java.util.List lFields = eLayout.getChildren("Field");
    logger.debug("There are " + lFields.size() + " Fields in the " + layoutName + " Layout.");

    XMLOutputter xmlOut = new XMLOutputter();
    for (int i=0; i<lFields.size(); i++) {
      Element eField = (Element)lFields.get(i);
      buildElement(xeo, eOutput, eField, true);
      logger.debug("eOutput is now " + xmlOut.outputString(eOutput));
    }

    logger.debug("XmlLayout - Build Output From Object - Ended Processing.");

    return eOutput;
View Full Code Here

Examples of org.jdom.output.XMLOutputter

     *
     * @param document the Document to format
     * @return a String containing XML
     */
    private static String formatDocument(Document document) throws IOException {       
        final XMLOutputter outputter = new XMLOutputter();
        final StringWriter writer = new StringWriter();
       
        outputter.output(document, writer);
       
        return writer.getBuffer().toString();
    }
View Full Code Here

Examples of org.jdom.output.XMLOutputter

      replyDoc.getRootElement().removeChild(DATA_AREA);
    }

    // Build the reply document as if there were no errors.
    String strReplyDoc = buildReplyDocument(senderControlArea, replyDoc);
    XMLOutputter xmlOut = new XMLOutputter();

    // Now add the errors into the control area
    Result aResult = new Result();

    Document localReplyDoc = null;
    try {
      XmlDocumentReader xmlReader = new XmlDocumentReader();
      localReplyDoc = xmlReader.initializeDocument(new ByteArrayInputStream(strReplyDoc.getBytes()), false);
      Element replyControlArea = getControlArea(localReplyDoc.getRootElement());
      localReplyDoc.getRootElement().removeContent(replyControlArea);
      Element eResult = replyControlArea.getChild("Result");
      aResult.buildObjectFromInput(eResult);
      aResult.setStatus("failure");

      for (int i=0; i<errors.size(); i++) {
        org.openeai.moa.objects.resources.Error anError =
          (org.openeai.moa.objects.resources.Error)errors.get(i);
        aResult.addError(anError);
      }

      replyControlArea.removeChild("Result");
      replyControlArea.addContent((Element)aResult.buildOutputFromObject());
      localReplyDoc.getRootElement().addContent(replyControlArea);
      if (needsDataArea) {
        localReplyDoc.getRootElement().addContent(new Element(DATA_AREA));
      }
      return xmlOut.outputString(localReplyDoc);
    }
    catch (Exception e) {
      // We'll just have to return the replyDoc after we've added our error
      // to it without the Dynamic ControlArea information...
      logger.fatal("Error building error reply document.");
View Full Code Here

Examples of org.jdom.output.XMLOutputter

  *  Generic-Response-Reply document or a 'response-reply' document specific to the message object/action
  *  being processed (e.g. InstitutionalIdentity-Response-Reply).
  */
  public final String buildReplyDocument(Element senderControlArea, Document replyDoc) {

    XMLOutputter xmlOut = new XMLOutputter();
    Document localReplyDoc = (Document)replyDoc.clone();

    String msgAction = senderControlArea.getAttribute(MESSAGE_ACTION).getValue();

    Element replyControlArea = getControlArea(localReplyDoc.getRootElement());
    localReplyDoc.getRootElement().removeContent(replyControlArea);

    // A DataArea will only exist for some reply documents,
    // later when we rebuild the reply document, we'll check to see
    // if this element is null before we try to add it back into
    // the document.  We need to do this so when we re-build the document
    // we can add the ControlArea and DataAreas in the proper order...
    Element replyDataArea = localReplyDoc.getRootElement().getChild(DATA_AREA);
    if (replyDataArea != null) {
      localReplyDoc.getRootElement().removeChild(DATA_AREA);
    }

    replyControlArea.removeChild("Result");
    replyControlArea.removeChild("Datetime");
    replyControlArea.removeChild("Sender");

    Result aResult = new Result();

    ProcessedMessageId processedMsgId = new ProcessedMessageId();
    Element eRequestSender = senderControlArea.getChild("Sender");

    processedMsgId.setProducerId(eRequestSender.getChild("MessageId").
      getChild("ProducerId").getText());
    processedMsgId.setSenderAppId(eRequestSender.getChild("MessageId").
      getChild("SenderAppId").getText());
    processedMsgId.setMessageSeq(eRequestSender.getChild("MessageId").
      getChild("MessageSeq").getText());

    aResult.setAction(msgAction);
    aResult.setStatus("success");
    aResult.setProcessedMessageId(processedMsgId);

    // Set the sender element (the replier)
    Sender sender = new Sender();

    MessageId replierMsgId = new MessageId();
    replierMsgId.setProducerId(eRequestSender.getChild("MessageId").
      getChild("ProducerId").getText());
    replierMsgId.setSenderAppId(getAppName());
    replierMsgId.setMessageSeq(eRequestSender.getChild("MessageId").
      getChild("MessageSeq").getText());
    sender.setMessageId(replierMsgId);

    Authentication auth = new Authentication();
    auth.setAuthUserId(getAppName());
    auth.setAuthUserSignature(getAppName());
    sender.setAuthentication(auth);

    Element eSender = null;
    try {
      XmlLayout xmlLayout = (XmlLayout)sender.getOutputLayoutManager("xml");
      sender.setOutputLayoutManager(xmlLayout);
      eSender = (Element)sender.buildOutputFromObject();
    }
    catch (Exception e) {
      logger.fatal("[buildReplyDocument] Exception occurred building an Element from the Sender object.  Exception: " + e.getMessage());
      return xmlOut.outputString(replyDoc);
    }

    // Set the datetime element (for the replier)
    Datetime dt = new Datetime();
    Element eDatetime = null;
    try {
      eDatetime = (Element)dt.buildOutputFromObject();
    }
    catch (Exception e) {
      logger.fatal("[buildReplyDocument] Exception occurred building an Element from the Datetime object.  Exception: " + e.getMessage());
      return xmlOut.outputString(replyDoc);
    }

    try {
      replyControlArea.addContent(eSender);
      replyControlArea.addContent(eDatetime);
      replyControlArea.addContent((Element)aResult.buildOutputFromObject());
      localReplyDoc.getRootElement().addContent(replyControlArea);
      if (replyDataArea != null) {
        localReplyDoc.getRootElement().addContent(replyDataArea);
      }
    }
    catch (Exception e) {
      logger.fatal("Error building reply document, returning Reply Document passed in");
      logger.fatal(e.getMessage(), e);
      return xmlOut.outputString(replyDoc);
    }
    return xmlOut.outputString(localReplyDoc);
  }
View Full Code Here

Examples of org.jdom.output.XMLOutputter

    try {
      EnterpriseLayoutManager elm = getOutputLayoutManager("xml");
      if (elm != null) {
        Object obj = elm.buildOutputFromObject(this);
        if (obj instanceof Element) {
          XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
          logger.info(fmt.outputString((Element)obj));
        }
      }
    }
    catch (Exception exc) {
      logger.fatal("dumpData: Exception caught: " + exc.getMessage());
View Full Code Here

Examples of org.jdom.output.XMLOutputter

      xeo.setOutputLayoutManager(outElm);
      xeo.setInputLayoutManager(inElm);

      logger.debug("re-building object from input...");
      xeo.buildObjectFromInput(eOutput);
      XMLOutputter xmlOut = new XMLOutputter();
      String objAsXmlString = xmlOut.outputString((Element)xeo.buildOutputFromObject());
      logger.debug("[toXmlString] " + className + " as an XML String: \n" + objAsXmlString);

      // To test to make sure it doesn't have any goofy characters in it...
      // If it does, an exception will be thrown here.
      XmlDocumentReader xmlReader = new XmlDocumentReader();
View Full Code Here

Examples of org.jdom.output.XMLOutputter

  * @throws TransportExceptom if errors occur.
  **/
  public boolean publishMessage(ActionableEnterpriseObject theObject, Document doc)
  throws TransportException {
    TextMessage outMessage = createTextMessage();
    XMLOutputter xmlOut = new XMLOutputter();
    String messageBody = xmlOut.outputString(doc);
    String xmlMsgId = theObject.getMessageId().toString();
    logger.debug("PubSubProducer: ProducerId is: " + getProducerId(null).getId());
    logger.debug("PubSubProducer: MessageId is: " + xmlMsgId);

    try {
View Full Code Here

Examples of org.jdom.output.XMLOutputter

    Element dataArea = updateDoc.getRootElement().getChild("DataArea");

    Element oldElement = dataArea.getChild("NewData").getChild(getElementName());
    Element oldBaselineElement = dataArea.getChild("BaselineData").getChild(getElementName());

    XMLOutputter xmlOut = new XMLOutputter();
    Element newElement = null;
    try {
      newElement = (Element)buildOutputFromObject();
    }
    catch (EnterpriseLayoutException e) {
      logger.fatal("Error building updateMessage for object " + getClass().getName() + " content of object: " + toString());
      String errMessage = "Error building updateMessage for object " +
        getClass().getName() + "  Exception: " + e.getMessage();
      throw new EnterpriseObjectUpdateException(errMessage, e);
    }

    // need check for null baseline!
    if (getBaseline() == null) {
      logger.warn("buildUpdateMessage:  baseline is null!");
      try {
        setBaseline((XmlEnterpriseObject)clone());
        getBaseline().buildObjectFromInput(oldBaselineElement);
      }
      catch (Exception e) {
        logger.fatal("Error building baseline object from element for object (baseline/clone) " +
          getBaseline().getClass().getName() + " content of element: " +
          xmlOut.outputString(oldBaselineElement));
        String errMessage = "Error building baseline object from element for object " +
          getClass().getName() + "  Exception: " + e.getMessage();
        throw new EnterpriseObjectUpdateException(errMessage, e);
      }
    }
View Full Code Here

Examples of org.jdom.output.XMLOutputter

  //============================================================================
  //============================================================================
  private void outputXMLDocument(Document doc, String message) {
    try {
      XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
      logger.fatal(message);
      logger.fatal("\n" + fmt.outputString(doc));
    }
    catch (Exception exc) {
      logger.fatal("Error converting XML Document to String.");
      logger.fatal(exc.getMessage(), exc);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.