Package org.openntf.domino.utils.xml

Examples of org.openntf.domino.utils.xml.XMLNode


    // TODO is this safe enough in the event of multiple folders/views with the same name?
    return getAncestorDatabase().getView(getName());
  }

  public boolean isAllowDAS() {
    XMLNode node = getDxlNode("//item[@name='$WebFlags']/text");
    return node != null && node.getText().contains("A");
  }
View Full Code Here


    XMLNode node = getDxlNode("//item[@name='$WebFlags']/text");
    return node != null && node.getText().contains("A");
  }

  public void setAllowDAS(final boolean allowDAS) {
    XMLNode node = getDxlNode("//item[@name='$WebFlags']/text");
    if (node == null) {
      node = getDxl().getDocumentElement().addChildElement("item");
      node.setAttribute("name", "$WebFlags");
      node = node.addChildElement("text");
    }
    if (allowDAS) {
      if (!node.getText().contains("A")) {
        node.setText(node.getText() + "A");
      }
    } else {
      if (node.getText().contains("A")) {
        node.setText(node.getText().replace("A", ""));
      }
    }
  }
View Full Code Here

   * @see org.openntf.domino.design.JavaResource#setClassData(java.util.Map)
   */
  @Override
  public void setClassData(final Map<String, byte[]> classData) {
    // First step, clear out the existing data, index, and size fields
    XMLNode indexNode = getDxl().selectSingleNode("//item[@name='" + CLASS_INDEX_ITEM + "']");
    XMLNode itemParent = indexNode.getParentNode();
    List<XMLNode> names = indexNode.selectNodes(".//text");
    for (int i = 0; i < names.size(); i++) {
      XMLNode dataNode = getDxl().selectSingleNode("//item[@name='$ClassData" + i + "']");
      dataNode.getParentNode().removeChild(dataNode);
      XMLNode sizeNode = getDxl().selectSingleNode("//item[@name='$ClassSize" + i + "']");
      sizeNode.getParentNode().removeChild(sizeNode);

      indexNode.removeChild(names.get(i));
    }

    int index = 0;
    for (Map.Entry<String, byte[]> classEntry : classData.entrySet()) {
      XMLNode sizeNode = itemParent.addChildElement("item");
      sizeNode.setAttribute("name", "$ClassSize" + index);
      XMLNode sizeText = sizeNode.addChildElement("number");
      sizeText.setTextContent(String.valueOf(classEntry.getValue().length));

      setFileData("$ClassData" + index, classEntry.getValue());

      XMLNode name = indexNode.addChildElement("text");
      name.setTextContent("WEB-INF/classes/" + DominoUtils.javaBinaryNameToFilePath(classEntry.getKey(), "/"));

      index++;
    }
  }
View Full Code Here

    node_.setAttribute("sort", sortOrder.toString().toLowerCase());
  }

  @Override
  public String getTitle() {
    XMLNode columnHeader = node_.selectSingleNode("columnheader");
    if (columnHeader == null) {
      return "";
    }
    return columnHeader.getAttribute("title");
  }
View Full Code Here

    return columnHeader.getAttribute("title");
  }

  @Override
  public void setTitle(final String title) {
    XMLNode columnHeader = node_.selectSingleNode("columnheader");
    if (columnHeader == null) {
      XMLNode firstChild = node_.getFirstChild();
      if (firstChild != null) {
        columnHeader = node_.insertChildElementBefore("columnheader", firstChild);
      } else {
        columnHeader = node_.addChildElement("columnheader");
      }
View Full Code Here

    return StringUtil.isEmpty(formulaActual) ? this.getItemName() : formulaActual;
  }

  // This is used so that the DXL can remain accurate - empty column formulas are illegal
  protected String getFormulaActual() {
    XMLNode formulaNode = node_.selectSingleNode("code[@event='value']/formula");
    if (formulaNode != null) {
      return formulaNode.getTextContent();
    }
    return "";
  }
View Full Code Here

    return "";
  }

  @Override
  public void setFormula(final String formula) {
    XMLNode formulaNode = node_.selectSingleNode("code[@event='value']/formula");
    if (formulaNode != null) {
      formulaNode.setTextContent(formula);
    } else {
      XMLNode code = node_.addChildElement("code");
      code.setAttribute("event", "value");
      formulaNode = code.addChildElement("formula");
      formulaNode.setTextContent(formula);
    }
  }
View Full Code Here

      byte[] reconData = record.getBytes();

      // Write out the first chunk
      int firstChunk = reconData.length > 20544 ? 20544 : reconData.length;
      String firstChunkData = printBase64Binary(Arrays.copyOfRange(reconData, 0, firstChunk));
      XMLNode documentNode = getDxl().selectSingleNode("//note");
      XMLNode fileDataNode = documentNode.addChildElement("item");
      fileDataNode.setAttribute("name", itemName);
      fileDataNode = fileDataNode.addChildElement("rawitemdata");
      fileDataNode.setAttribute("type", "1");
      fileDataNode.setText(firstChunkData);

      // Write out any remaining chunks
      int remaining = reconData.length - firstChunk;
      int chunks = remaining / 20516;
      if (remaining % 20516 > 0) {
        chunks++;
      }
      int offset = firstChunk;
      for (int i = 0; i < chunks; i++) {
        int chunkSize = remaining > 20516 ? 20516 : remaining;
        String chunkData = printBase64Binary(Arrays.copyOfRange(reconData, offset, offset + chunkSize));

        fileDataNode = documentNode.addChildElement("item");
        fileDataNode.setAttribute("name", itemName);
        fileDataNode = fileDataNode.addChildElement("rawitemdata");
        fileDataNode.setAttribute("type", "1");
        fileDataNode.setText(chunkData);

        remaining -= 20516;
        offset += chunkSize;
      }

      // Also set the file size if we're setting the main field
      if (DEFAULT_FILEDATA_FIELD.equals(itemName)) {
        XMLNode fileSizeNode = getDocumentElement().selectSingleNode("//item[@name='$FileSize']");
        if (fileSizeNode == null) {
          fileSizeNode = getDocumentElement().addChildElement("item");
          fileSizeNode.setAttribute("name", "$FileSize");
          fileSizeNode.setAttribute("sign", "true");
          fileSizeNode = fileSizeNode.addChildElement("number");
        } else {
          fileSizeNode = fileSizeNode.selectSingleNode("number");
        }
        fileSizeNode.setText(String.valueOf(fileData.length));
      }
    } catch (IOException ioe) {
      DominoUtils.handleException(ioe);
    }
  }
View Full Code Here

  @Override
  public void setName(final String title) {
    super.setName(title);

    // Also set the $FileNames field
    XMLNode fileNamesNode = getDocumentElement().selectSingleNode("//item[@name='$FileNames']");
    if (fileNamesNode == null) {
      fileNamesNode = getDocumentElement().addChildElement("item");
      fileNamesNode.setAttribute("name", "$FileNames");
      fileNamesNode.setAttribute("sign", "true");
      fileNamesNode = fileNamesNode.addChildElement("text");
    } else {
      fileNamesNode = fileNamesNode.selectSingleNode("text");
    }
    fileNamesNode.setText(title);
  }
View Full Code Here

      removeFlag(DESIGN_FLAG_HIDEFROMDESIGNLIST);
    }
  }

  private XMLNode getMimeTypeNode() {
    XMLNode dataNode = getDxl().selectSingleNode("//item[@name='$MimeType']");
    if (dataNode == null) {
      dataNode = getDocumentElement().addChildElement("item");
      dataNode.setAttribute("name", "$MimeType");
      dataNode = dataNode.addChildElement("text");
    } else {
      dataNode = dataNode.selectSingleNode("text");
    }
    return dataNode;
  }
View Full Code Here

TOP

Related Classes of org.openntf.domino.utils.xml.XMLNode

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.