Search in sources :

Example 11 with XMLNode

use of org.openntf.domino.utils.xml.XMLNode in project org.openntf.domino by OpenNTF.

the class AbstractXspResource method setClassData.

/*
	 * (non-Javadoc)
	 * 
	 * @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));
        setFileDataRaw("$ClassData" + index, classEntry.getValue());
        XMLNode name = indexNode.addChildElement("text");
        name.setTextContent("WEB-INF/classes/" + DominoUtils.javaBinaryNameToFilePath(classEntry.getKey(), "/"));
        index++;
    }
}
Also used : XMLNode(org.openntf.domino.utils.xml.XMLNode) Map(java.util.Map) HashMap(java.util.HashMap)

Example 12 with XMLNode

use of org.openntf.domino.utils.xml.XMLNode in project org.openntf.domino by OpenNTF.

the class AbstractDesignBase method getItemValue.

/**
 * Reads the given item name and returns the containing string (can only read number and text items)
 *
 * @param itemName
 *            the ItemName
 * @return the values as List<Object> (text entries are returned as String, number entries as Double)
 */
public final List<Object> getItemValue(final String itemName) {
    if (getDxlFormat(true) == DxlFormat.NONE) {
        return document_.getItemValue(itemName);
    }
    List<Object> result = new ArrayList<Object>();
    // $NON-NLS-1$ //$NON-NLS-2$
    XMLNode node = getDxlNode("//item[@name='" + XMLDocument.escapeXPathValue(itemName) + "']");
    if (node != null) {
        // $NON-NLS-1$
        List<XMLNode> nodes = node.selectNodes(".//number | .//text");
        for (XMLNode child : nodes) {
            if (child.getNodeName().equals("number")) {
                // $NON-NLS-1$
                result.add(Double.parseDouble(child.getText()));
            } else {
                result.add(child.getText());
            }
        }
    }
    return result;
}
Also used : XMLNode(org.openntf.domino.utils.xml.XMLNode) ArrayList(java.util.ArrayList)

Example 13 with XMLNode

use of org.openntf.domino.utils.xml.XMLNode in project org.openntf.domino by OpenNTF.

the class FormField method setFieldType.

@Override
public void setFieldType(final Type fieldType) {
    try {
        switch(fieldType) {
            case CHECKBOX:
            case COMBOBOX:
            case DIALOGLIST:
            case RADIOBUTTON:
                // $NON-NLS-1$ //$NON-NLS-2$
                node_.setAttribute("type", "keyword");
                XMLNode keywords = this.getKeywordsNode();
                // $NON-NLS-1$
                keywords.setAttribute("ui", fieldType.toString().toLowerCase());
                // $NON-NLS-1$
                keywords.setAttribute("helperbutton", String.valueOf(fieldType == Type.DIALOGLIST));
                if (keywords.getAttribute("columns").length() == 0) {
                    // $NON-NLS-1$
                    // $NON-NLS-1$ //$NON-NLS-2$
                    keywords.setAttribute("columns", "1");
                }
                break;
            default:
                // $NON-NLS-1$
                node_.setAttribute("type", fieldType.toString().toLowerCase());
                if (fieldType == Type.PASSWORD) {
                    // $NON-NLS-1$ //$NON-NLS-2$
                    node_.setAttribute("seal", "true");
                } else if (fieldType == Type.RICHTEXTLITE) {
                    if (getKind() == Kind.COMPUTEDFORDISPLAY || getKind() == Kind.COMPUTEDWHENCOMPOSED) {
                        this.setKind(Kind.COMPUTED);
                    }
                    if (node_.getAttribute("onlyallow").isEmpty()) {
                        // $NON-NLS-1$
                        // $NON-NLS-1$
                        node_.setAttribute(// $NON-NLS-1$
                        "onlyallow", // $NON-NLS-1$
                        "picture sharedimage attachment view datepicker sharedapplet text object calendar inbox help clear graphic link");
                    }
                    if (node_.getAttribute("firstdisplay").isEmpty()) {
                        // $NON-NLS-1$
                        // $NON-NLS-1$ //$NON-NLS-2$
                        node_.setAttribute("firstdisplay", "text");
                    }
                } else if (fieldType == Type.RICHTEXT && (getKind() == Kind.COMPUTEDFORDISPLAY || getKind() == Kind.COMPUTEDWHENCOMPOSED)) {
                    setKind(Kind.COMPUTED);
                }
                break;
        }
    } catch (Exception e) {
        DominoUtils.handleException(e);
    }
}
Also used : XMLNode(org.openntf.domino.utils.xml.XMLNode)

Example 14 with XMLNode

use of org.openntf.domino.utils.xml.XMLNode in project org.openntf.domino by OpenNTF.

the class IconNote method setDASMode.

@Override
public void setDASMode(final DASMode mode) {
    // $NON-NLS-1$ //$NON-NLS-2$
    XMLNode node = getDxlNode("/note/item[@name='" + DbProperties.ALLOW_DAS.getPropertyName() + "']");
    if (node == null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        node = getDxlNode("/note").addChildElement("item");
        // $NON-NLS-1$
        node.setAttribute("name", DbProperties.ALLOW_DAS.getPropertyName());
        // $NON-NLS-1$
        node = node.addChildElement("number");
    }
    switch(mode) {
        case NONE:
            // $NON-NLS-1$
            node.setTextContent("0");
            break;
        case VIEWS:
            // $NON-NLS-1$
            node.setTextContent("1");
            break;
        case VIEWSANDDOCUMENTS:
            // $NON-NLS-1$
            node.setTextContent("2");
            break;
    }
}
Also used : XMLNode(org.openntf.domino.utils.xml.XMLNode)

Example 15 with XMLNode

use of org.openntf.domino.utils.xml.XMLNode in project org.openntf.domino by OpenNTF.

the class IconNote method setCssExpiry.

@Override
public void setCssExpiry(final int days) {
    // $NON-NLS-1$
    XMLNode node = getDxlNode("/note/item[@name='$CSSExpires']");
    if (days > Integer.MIN_VALUE) {
        if (node == null) {
            // $NON-NLS-1$ //$NON-NLS-2$
            node = getDxlNode("/note").addChildElement("item");
            // $NON-NLS-1$
            node.setAttribute("name", DbProperties.LAUNCH_XPAGE_ON_SERVER.getPropertyName());
            // $NON-NLS-1$ //$NON-NLS-2$
            node.addChildElement("text").setTextContent("1");
        }
    } else {
        if (node != null) {
            node.getParentNode().removeChild(node);
        }
    }
}
Also used : XMLNode(org.openntf.domino.utils.xml.XMLNode)

Aggregations

XMLNode (org.openntf.domino.utils.xml.XMLNode)35 ArrayList (java.util.ArrayList)7 XMLNodeList (org.openntf.domino.utils.xml.XMLNodeList)3 CDResourceFile (org.openntf.domino.nsfdata.structs.obj.CDResourceFile)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Database (org.openntf.domino.Database)1 DxlExporter (org.openntf.domino.DxlExporter)1 DatabaseDesign (org.openntf.domino.design.DatabaseDesign)1 FormField (org.openntf.domino.design.FormField)1 OpenNTFNotesException (org.openntf.domino.exceptions.OpenNTFNotesException)1 CData (org.openntf.domino.nsfdata.structs.cd.CData)1 CDObject (org.openntf.domino.nsfdata.structs.obj.CDObject)1 CDResourceEvent (org.openntf.domino.nsfdata.structs.obj.CDResourceEvent)1