Package org.jdom

Examples of org.jdom.Document


  *  been built with the appropriate error number, error type and error descriptions.
  */
  protected void publishSyncError(String action, java.util.List errors) {

    XmlDocumentReader xmlReader = new XmlDocumentReader();
    Document syncErrorDoc = null;
    try {
      syncErrorDoc =
        xmlReader.initializeDocument(getSyncErrorSyncPrimedDocumentUri(), getOutboundXmlValidation());
      if (syncErrorDoc == null) {
        String errMessage = "[PublishSyncError] Missing 'SyncErrorSyncPrimedDocumentUri' property in configuration document.  Can't publish sync error.";
        logger.fatal(errMessage);
        return;
      }
    }
    catch (XmlDocumentReaderException e) {
      logger.fatal("[PublishSyncError] Error initializing Sync-Error-Sync primed document, could not publish the sync error sync message.");
      logger.fatal(e.getMessage(), e);
      return;
    }

    Element eControlArea = getControlArea(syncErrorDoc.getRootElement());

    Result aResult = new Result();
    ProcessedMessageId processedMsgId = new ProcessedMessageId();

    // Build the dynamic portion of the sync document's control area
    // Our sender information will go in the "Sender" element of the primed
    // document and in the ProcessedMessageId of the Result that gets built
    // Set the sender element

    // Build the ProcessedMessageId Object out of the contents of the
    // application that had the error.
    String messageSequence = Integer.toString(getSyncErrorPublisher().incrementMessageSequence());
    try {
      // processedMsgId is going to be the same as MessageId (built below)
      processedMsgId.setProducerId(getSyncErrorPublisher().getProducerId(null).getId());
      processedMsgId.setSenderAppId(getAppName());
      processedMsgId.setMessageSeq(messageSequence);
    }
    catch (Exception e) {
      logger.fatal("Error building ProcessedMessageId Element in Sync-Error-Sync message!");
      logger.fatal(e.getMessage(), e);
    }

    // This is the control area information relevant to this Gateway
    eControlArea.removeChild("Result");
    eControlArea.removeChild("Datetime");
    eControlArea.removeChild("Sender");

    Sender sender = new Sender();
    MessageId msgId = new MessageId();
    msgId.setProducerId(getSyncErrorPublisher().getProducerId(null).getId());
    msgId.setSenderAppId(getAppName());
    msgId.setMessageSeq(messageSequence);

    sender.setMessageId(msgId);
    Authentication auth = new Authentication();
    auth.setAuthUserId(getAppName());
    sender.setAuthentication(auth);
    Element eSender = null;
    try {
      eSender = (Element)sender.buildOutputFromObject();
    }
    catch (Exception e) {
      logger.fatal("[publishSyncError1] Exception occurred building an Element from the Sender object.  Can't publish Sync error.  Exception: " + e.getMessage());
      logger.fatal(e.getMessage(), e);
      return;
    }

    // Set the datetime element
    Datetime dt = new Datetime();
    Element eDatetime = null;
    try {
      eDatetime = (Element)dt.buildOutputFromObject();
    }
    catch (Exception e) {
      logger.fatal("[publishSyncError1] Exception occurred building an Element from the Datetime object.  Can't publish Sync error.  Exception: " + e.getMessage());
      logger.fatal(e.getMessage(), e);
      return;
    }

    eControlArea.addContent(eSender);
    eControlArea.addContent(eDatetime);

    if (action == null) {
      action = "Unknown";
    }
    aResult.setAction(action);
    aResult.setStatus("failure");
    aResult.setProcessedMessageId(processedMsgId);

    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);
    }

    try {
      Element eResult = (Element)aResult.buildOutputFromObject();
      eControlArea.addContent(eResult);
      syncErrorDoc.getRootElement().removeContent(eControlArea);
      syncErrorDoc.getRootElement().addContent(eControlArea);
      TextMessage syncErrorMessage = getSyncErrorPublisher().createTextMessage();
      XMLOutputter xmlOut = new XMLOutputter();
      syncErrorMessage.setText(xmlOut.outputString(syncErrorDoc));
      if (getSyncErrorPublisher().getDefaultCommandName().length() == 0 ||
        getSyncErrorPublisher().getDefaultCommandName() == null) {
View Full Code Here


      logger.fatal(e.getMessage(), e);
      throw new JMSException(e.getMessage());
    }

    // Build an XML Document out of the contents of the message passed in...
    Document inDoc = null;
    try {
      XmlDocumentReader xmlReader = new XmlDocumentReader();
      inDoc =
          xmlReader.initializeDocument(new ByteArrayInputStream(textMsg.getText().getBytes()),
                                       false);
      Element eControlArea = getControlArea(inDoc.getRootElement());
      Element eMessageId =
        eControlArea.getChild("Sender").getChild("MessageId");
      String senderAppId = eMessageId.getChild("SenderAppId").getText();
      String producerId = eMessageId.getChild("ProducerId").getText();
      String messageSeq = eMessageId.getChild("MessageSeq").getText();
View Full Code Here

    throws XmlDocumentReaderException {
    if (fileName == null || fileName.length() == 0) {
      logger.debug("XmlDocumentReader: Null Document name passed in, can't initialize.");
      return null;
    }
    Document doc = null;
    try {
      SAXBuilder builder = new SAXBuilder(false);
      if (validate == false) {
        logger.debug("Setting the EntityResolver to IgnoreDTDResolver.");
        builder.setEntityResolver(new IgnoreDTDResolver());
View Full Code Here

    if (is == null) {
      logger.debug("XmlDocumentReader: Null Document name passed in, can't initialize.");
      return null;
    }

    Document doc = null;
    try {
      SAXBuilder builder = new SAXBuilder(false);
      logger.debug("Building document from Reader");
      if (validate == false) {
        logger.debug("Setting the EntityResolver to IgnoreDTDResolver.");
View Full Code Here

    if (docAsReader == null) {
      logger.debug("XmlDocumentReader: Null Document name passed in, can't initialize.");
      return null;
    }

    Document doc = null;
    try {
      SAXBuilder builder = new SAXBuilder(false);
      logger.debug("Building document from Reader");
      if (validate == false) {
        logger.debug("Setting the EntityResolver to IgnoreDTDResolver.");
View Full Code Here

    // which sets the 'JMSReplyTo' property to a TemporaryQueue that it's created
    // The consumer of the request should check for a ReplyTo Queue and send the
    // 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 {
View Full Code Here

    public void testInnerBeanService()
            throws Exception
    {
        assertEquals("InnerService", service.getSimpleName());
       
        Document response =
                invokeService("InnerService",
                              "/org/codehaus/xfire/aegis/getInnerBean.xml");

        addNamespace("a", "http://aegis.xfire.codehaus.org");
        assertValid("//a:getInnerBeanResponse", response);
View Full Code Here

    }

    public void testBeanServiceWSDL()
            throws Exception
    {
        Document doc = getWSDLDocument("InnerService");

        addNamespace("wsdl", WSDLWriter.WSDL11_NS);
        addNamespace("wsdlsoap", WSDLWriter.WSDL11_SOAP_NS);
        addNamespace("xsd", SoapConstants.XSD);
View Full Code Here

    public void testGenerateWsdl()
        throws Exception
    {

        Document d = getWSDLDocument("InheritanceService");

        String types = "//wsdl:types/xsd:schema/";

        // check for Employee as extension
        String employeeType = types + "xsd:complexType[@name='Employee']";
View Full Code Here

    }

    public void testLocalReceiveEmployee()
        throws Exception
    {
        Document response = invokeService("InheritanceService", "ReceiveEmployee.xml");
        addNamespace("w", "urn:xfire:inheritance");
        assertValid("//s:Body/w:receiveUserResponse", response);
    }
View Full Code Here

TOP

Related Classes of org.jdom.Document

Copyright © 2018 www.massapicom. 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.