Search in sources :

Example 11 with NodeList

use of com.google.gwt.xml.client.NodeList in project pentaho-platform by pentaho.

the class PermissionsPanel method updatePermissionForUserOrRole.

/**
 * @param recipient
 * @param grant     true = grant the Permission, false = deny the Permission (remove it if present)
 * @param perm      The integer value of the Permission as defined in <code>RepositoryFilePermissions</code>
 */
private void updatePermissionForUserOrRole(Document fileInfo, String recipient, String recipientType, boolean grant, int perm) {
    // first let's see if this node exists
    Node foundPermission = null;
    NodeList aces = fileInfo.getElementsByTagName(ACES_ELEMENT_NAME);
    for (int i = 0; i < aces.getLength(); i++) {
        Element ace = (Element) aces.item(i);
        if (ace.getElementsByTagName(RECIPIENT_ELEMENT_NAME).item(0).getFirstChild().getNodeValue().equals(recipient) && ace.getElementsByTagName(RECIPIENT_TYPE_ELEMENT_NAME).item(0).getFirstChild().getNodeValue().equals(recipientType)) {
            NodeList permissions = ace.getElementsByTagName(PERMISSIONS_ELEMENT_NAME);
            for (int j = 0; j < permissions.getLength(); j++) {
                Node testNode = permissions.item(j);
                if (testNode.getFirstChild() != null && Integer.parseInt(testNode.getFirstChild().getNodeValue()) == perm) {
                    foundPermission = testNode;
                    break;
                }
            }
            break;
        }
    }
    if (grant) {
        if (foundPermission != null) {
            // This permission already exists.
            return;
        }
        addPermission(recipient, recipientType, perm, fileInfo);
    } else {
        if (foundPermission != null) {
            foundPermission.getParentNode().removeChild(foundPermission);
        }
    }
}
Also used : Node(com.google.gwt.xml.client.Node) NodeList(com.google.gwt.xml.client.NodeList) Element(com.google.gwt.xml.client.Element)

Example 12 with NodeList

use of com.google.gwt.xml.client.NodeList in project pentaho-platform by pentaho.

the class PermissionsPanel method addPermission.

/**
 * @param recipient
 * @param permission
 */
private void addPermission(String recipient, String recipientType, int permission, Document fileInfo) {
    NodeList aces = fileInfo.getElementsByTagName(ACES_ELEMENT_NAME);
    for (int i = 0; i < aces.getLength(); i++) {
        Element ace = (Element) aces.item(i);
        if (ace.getElementsByTagName(RECIPIENT_ELEMENT_NAME).item(0).getFirstChild().getNodeValue().equals(recipient) && ace.getElementsByTagName(RECIPIENT_TYPE_ELEMENT_NAME).item(0).getFirstChild().getNodeValue().equals(recipientType)) {
            Element newPerm = fileInfo.createElement(PERMISSIONS_ELEMENT_NAME);
            Text textNode = fileInfo.createTextNode(Integer.toString(permission));
            newPerm.appendChild(textNode);
            ace.appendChild(newPerm);
        }
    }
}
Also used : NodeList(com.google.gwt.xml.client.NodeList) Element(com.google.gwt.xml.client.Element) Text(com.google.gwt.xml.client.Text)

Example 13 with NodeList

use of com.google.gwt.xml.client.NodeList in project data-access by pentaho.

the class DatabaseConnectionConverter method getNodesByTagName.

/*
   * Return all node matching the tagName, starting from the current element
   * location
   */
private List<Node> getNodesByTagName(Element element, String tagName) {
    List<Node> nodes = new ArrayList<Node>();
    NodeList list = element.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
        Node node = list.item(i);
        if (node != null && node.getNodeName().equals(tagName)) {
            nodes.add(node);
        }
    }
    return nodes;
}
Also used : Node(com.google.gwt.xml.client.Node) NodeList(com.google.gwt.xml.client.NodeList) ArrayList(java.util.ArrayList)

Aggregations

NodeList (com.google.gwt.xml.client.NodeList)13 Element (com.google.gwt.xml.client.Element)9 Node (com.google.gwt.xml.client.Node)7 ArrayList (java.util.ArrayList)7 RequestBuilder (com.google.gwt.http.client.RequestBuilder)4 Document (com.google.gwt.xml.client.Document)4 Request (com.google.gwt.http.client.Request)2 RequestCallback (com.google.gwt.http.client.RequestCallback)2 RequestException (com.google.gwt.http.client.RequestException)2 Response (com.google.gwt.http.client.Response)2 Text (com.google.gwt.xml.client.Text)2 FlexTable (com.google.gwt.user.client.ui.FlexTable)1 HTML (com.google.gwt.user.client.ui.HTML)1 Label (com.google.gwt.user.client.ui.Label)1 List (java.util.List)1 IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)1 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)1 PromptDialogBox (org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox)1 OverwritePromptDialog (org.pentaho.mantle.client.dialogs.OverwritePromptDialog)1 SolutionBrowserClipboard (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserClipboard)1