Пример #1
0
  /*
   * Output this item. Then, if the element has child elements, output each.
   */
  private void outputItem(Element e, PrintWriter out) {
    int chk = 0;
    HashMap collection = new HashMap();
    String key = null;
    Element collectionElement = null;
    log.fine("outputing item for " + e.getAttribute("name") + ":   " + e.getAttribute("query"));
    out.println("<item>");
    out.println("<name>" + e.getAttribute("name") + "</name>");
    if (e.getTagName().equalsIgnoreCase("collection")) {

      // change made by NETTY (change collectionlist to collection)
      out.println(
          "<query>collection="
              + e.getAttribute("col_id")
              + "&amp;xsl=metadata_to_html_full</query>");
    } else {
      out.println(
          "<query>owner=" + e.getAttribute("query") + "&amp;xsl=metadata_to_html_full</query>");
    }
    // now output children

    NodeList children = e.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      Node child = children.item(i);
      if (child.getNodeType() == Node.ELEMENT_NODE) {
        chk++;
        outputItem((Element) child, out);
      }
    }

    out.println("</item>");
  }
  private void validateDTD() throws InvalidWorkflowDescriptorException {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);

    StringWriter sw = new StringWriter();
    PrintWriter writer = new PrintWriter(sw);
    writer.println(XML_HEADER);
    writer.println(DOCTYPE_DECL);
    writeXML(writer, 0);

    WorkflowLoader.AllExceptionsErrorHandler errorHandler =
        new WorkflowLoader.AllExceptionsErrorHandler();

    try {
      DocumentBuilder db = dbf.newDocumentBuilder();
      db.setEntityResolver(new DTDEntityResolver());

      db.setErrorHandler(errorHandler);
      db.parse(new InputSource(new StringReader(sw.toString())));

      if (errorHandler.getExceptions().size() > 0) {
        throw new InvalidWorkflowDescriptorException(errorHandler.getExceptions().toString());
      }
    } catch (InvalidWorkflowDescriptorException e) {
      throw e;
    } catch (Exception e) {
      throw new InvalidWorkflowDescriptorException(e.toString());
    }
  }
Пример #3
0
 /**
  * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
  *
  * @param request servlet request
  * @param response servlet response
  * @throws ServletException if a servlet-specific error occurs
  * @throws IOException if an I/O error occurs
  */
 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   response.setContentType("text/xml;charset=UTF-8");
   PrintWriter out = response.getWriter();
   try {
     // get exiting file, and output, looking for where to insert owners.
     BufferedReader in =
         new BufferedReader(
             new InputStreamReader(
                 this.getServletContext()
                     .getResourceAsStream(
                         "/WEB-INF/classes/gpt/search/browse/browse-catalog.xml")));
     log.fine("in: " + in.toString());
     String rec = null;
     while ((rec = in.readLine()) != null) {
       if (rec.contains("InsertOwnersHere")) {
         outputOwners(out);
       } else {
         out.println(rec);
       }
     }
   } finally {
     out.close();
   }
 }
Пример #4
0
 public boolean save(File file, String options) {
   PrintWriter writer = PApplet.createWriter(file);
   boolean result = write(writer);
   writer.flush();
   writer.close();
   return result;
 }
Пример #5
0
  public void marshall(
      Class parentType,
      QName elementType,
      ExtensibilityElement extension,
      PrintWriter pw,
      Definition def,
      ExtensionRegistry extReg)
      throws WSDLException {
    MIMEContent mimeContent = (MIMEContent) extension;

    if (mimeContent != null) {
      String tagName = DOMUtils.getQualifiedValue(MIMEConstants.NS_URI_MIME, "content", def);

      if (parentType != null && MIMEPart.class.isAssignableFrom(parentType)) {
        pw.print("    ");
      }

      pw.print("        <" + tagName);

      DOMUtils.printAttribute(MIMEConstants.ATTR_PART, mimeContent.getPart(), pw);
      DOMUtils.printAttribute(Constants.ATTR_TYPE, mimeContent.getType(), pw);

      Boolean required = mimeContent.getRequired();

      if (required != null) {
        DOMUtils.printQualifiedAttribute(Constants.Q_ATTR_REQUIRED, required.toString(), def, pw);
      }

      pw.println("/>");
    }
  }
Пример #6
0
 /**
  * ** Encodes the specified DBRecordKyes into XML and writes it to ** a specified PrintWriter
  * ** @param out The PrintWriter ** @param dbrk The list of DBRecordKeys
  */
 public static void printXML(PrintWriter out, DBRecordKey... dbrk) {
   if (out != null) {
     out.write("<" + DBFactory.TAG_RecordKeys + ">\n");
     for (int i = 0; i < dbrk.length; i++) {
       dbrk[i].printXML(out, 4);
     }
     out.write("</" + DBFactory.TAG_RecordKeys + ">\n");
     out.flush();
   }
 }
Пример #7
0
  public void handlePageBody(PageContext pc) throws ServletException, IOException {
    ServletContext context = pc.getServletContext();
    Document doc = null;
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder = factory.newDocumentBuilder();
      doc = builder.newDocument();
    } catch (Exception e) {
      throw new ServletException(e);
    }

    Element rootElem = doc.createElement("xaf");
    doc.appendChild(rootElem);

    try {
      DatabaseContextFactory.createCatalog(pc, rootElem);
      transform(pc, doc, ACE_CONFIG_ITEM_PROPBROWSERXSL);
    } catch (NamingException e) {
      PrintWriter out = pc.getResponse().getWriter();
      out.write(e.toString());
      e.printStackTrace(out);
    }
  }
  public void marshall(
      Class parentType,
      QName elementType,
      ExtensibilityElement extension,
      PrintWriter pw,
      Definition def,
      ExtensionRegistry extReg)
      throws WSDLException {
    SOAPBody soapBody = (SOAPBody) extension;

    if (soapBody != null) {
      String tagName = DOMUtils.getQualifiedValue(SOAPConstants.NS_URI_SOAP, "body", def);

      if (parentType != null && MIMEPart.class.isAssignableFrom(parentType)) {
        pw.print("    ");
      }

      pw.print("        <" + tagName);

      DOMUtils.printAttribute(
          SOAPConstants.ATTR_PARTS, StringUtils.getNMTokens(soapBody.getParts()), pw);
      DOMUtils.printAttribute(SOAPConstants.ATTR_USE, soapBody.getUse(), pw);
      DOMUtils.printAttribute(
          SOAPConstants.ATTR_ENCODING_STYLE,
          StringUtils.getNMTokens(soapBody.getEncodingStyles()),
          pw);
      DOMUtils.printAttribute(Constants.ATTR_NAMESPACE, soapBody.getNamespaceURI(), pw);

      Boolean required = soapBody.getRequired();

      if (required != null) {
        DOMUtils.printQualifiedAttribute(Constants.Q_ATTR_REQUIRED, required.toString(), def, pw);
      }

      pw.println("/>");
    }
  }
  /**
   * Makes a XML text representation.
   *
   * @param buffer
   */
  public void makeTextElement(PrintWriter buffer) {
    int size;
    String prefix = rNSContext_.getPrefixByUri("http://www.asahi-net.or.jp/~cs8k-cyu/bulletml");
    buffer.print("<");
    URelaxer.makeQName(prefix, "direction", buffer);
    rNSContext_.makeNSMappings(buffer);

    if (type_ != null) {
      buffer.print(" ");
      buffer.print("type");
      buffer.print("=\"");
      buffer.print(URelaxer.escapeAttrQuot(getType()));
      buffer.print("\"");
    }

    buffer.print(">");
    buffer.print("</");
    URelaxer.makeQName(prefix, "direction", buffer);
    buffer.print(">");
  }
Пример #10
0
 /**
  * ** Encodes this DBRecordKey into XML and writes it to a specified PrintWriter ** @param out The
  * PrintWriter ** @param indent The number of spaces to indent ** @param sequence Optional
  * sequence value ** @param soapXML True for SOAP XML
  */
 public void printXML(PrintWriter out, int indent, int sequence, boolean soapXML) {
   if (out != null) {
     out.write(this.toXML(null, indent, sequence, soapXML).toString());
     out.flush();
   }
 }
  public void writeXML(PrintWriter out, int indent) {
    XMLUtil.printIndent(out, indent++);
    out.println("<workflow>");

    Iterator iter = metaAttributes.entrySet().iterator();

    while (iter.hasNext()) {
      Map.Entry entry = (Map.Entry) iter.next();
      XMLUtil.printIndent(out, indent);
      out.print("<meta name=\"");
      out.print(XMLUtil.encode(entry.getKey()));
      out.print("\">");
      out.print(XMLUtil.encode(entry.getValue()));
      out.println("</meta>");
    }

    if (registers.size() > 0) {
      XMLUtil.printIndent(out, indent++);
      out.println("<registers>");

      for (int i = 0; i < registers.size(); i++) {
        RegisterDescriptor register = (RegisterDescriptor) registers.get(i);
        register.writeXML(out, indent);
      }

      XMLUtil.printIndent(out, --indent);
      out.println("</registers>");
    }

    if (timerFunctions.size() > 0) {
      XMLUtil.printIndent(out, indent++);
      out.println("<trigger-functions>");

      Iterator iterator = timerFunctions.entrySet().iterator();

      while (iterator.hasNext()) {
        Map.Entry entry = (Map.Entry) iterator.next();
        XMLUtil.printIndent(out, indent++);
        out.println("<trigger-function id=\"" + entry.getKey() + "\">");

        FunctionDescriptor trigger = (FunctionDescriptor) entry.getValue();
        trigger.writeXML(out, indent);
        XMLUtil.printIndent(out, --indent);
        out.println("</trigger-function>");
      }

      while (iterator.hasNext()) {}

      XMLUtil.printIndent(out, --indent);
      out.println("</trigger-functions>");
    }

    if (getGlobalConditions() != null) {
      XMLUtil.printIndent(out, indent++);
      out.println("<global-conditions>");

      getGlobalConditions().writeXML(out, indent);

      out.println("</global-conditions>");
    }

    XMLUtil.printIndent(out, indent++);
    out.println("<initial-actions>");

    for (int i = 0; i < initialActions.size(); i++) {
      ActionDescriptor action = (ActionDescriptor) initialActions.get(i);
      action.writeXML(out, indent);
    }

    XMLUtil.printIndent(out, --indent);
    out.println("</initial-actions>");

    if (globalActions.size() > 0) {
      XMLUtil.printIndent(out, indent++);
      out.println("<global-actions>");

      for (int i = 0; i < globalActions.size(); i++) {
        ActionDescriptor action = (ActionDescriptor) globalActions.get(i);
        action.writeXML(out, indent);
      }

      XMLUtil.printIndent(out, --indent);
      out.println("</global-actions>");
    }

    if (commonActions.size() > 0) {
      XMLUtil.printIndent(out, indent++);
      out.println("<common-actions>");

      Iterator iterator = getCommonActions().values().iterator();

      while (iterator.hasNext()) {
        ActionDescriptor action = (ActionDescriptor) iterator.next();
        action.writeXML(out, indent);
      }

      XMLUtil.printIndent(out, --indent);
      out.println("</common-actions>");
    }

    XMLUtil.printIndent(out, indent++);
    out.println("<steps>");

    for (int i = 0; i < steps.size(); i++) {
      StepDescriptor step = (StepDescriptor) steps.get(i);
      step.writeXML(out, indent);
    }

    XMLUtil.printIndent(out, --indent);
    out.println("</steps>");

    if (splits.size() > 0) {
      XMLUtil.printIndent(out, indent++);
      out.println("<splits>");

      for (int i = 0; i < splits.size(); i++) {
        SplitDescriptor split = (SplitDescriptor) splits.get(i);
        split.writeXML(out, indent);
      }

      XMLUtil.printIndent(out, --indent);
      out.println("</splits>");
    }

    if (joins.size() > 0) {
      XMLUtil.printIndent(out, indent++);
      out.println("<joins>");

      for (int i = 0; i < joins.size(); i++) {
        JoinDescriptor join = (JoinDescriptor) joins.get(i);
        join.writeXML(out, indent);
      }

      XMLUtil.printIndent(out, --indent);
      out.println("</joins>");
    }

    XMLUtil.printIndent(out, --indent);
    out.println("</workflow>");
  }
Пример #12
0
 // Sends this object and its kids to a Writer with an indent of 2 spaces,
 // including the declaration at the top so that the output will be valid XML.
 public boolean write(PrintWriter output) {
   output.print(format(2));
   output.flush();
   return true;
 }