use of com.google.gwt.xml.client.Element 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);
}
}
}
use of com.google.gwt.xml.client.Element 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);
}
}
}
use of com.google.gwt.xml.client.Element in project data-access by pentaho.
the class DatabaseConnectionConverter method convertToObject.
public IDatabaseConnection convertToObject(String xml) {
Document document = XMLParser.parse(xml);
Element element = document.getDocumentElement();
IDatabaseConnection databaseConnection = new DatabaseConnection();
databaseConnection.setDatabaseName(getNodeValueByTagName(element, DATABASE_NAME));
databaseConnection.setHostname(getNodeValueByTagName(element, HOSTNAME));
databaseConnection.setIndexTablespace(getNodeValueByTagName(element, INDEX_TABLESPACE));
databaseConnection.setDataTablespace(getNodeValueByTagName(element, DATA_TABLESPACE));
databaseConnection.setName(getNodeValueByTagName(element, NAME));
databaseConnection.setUsername(getNodeValueByTagName(element, USERNAME));
databaseConnection.setPassword(getNodeValueByTagName(element, PASSWORD));
databaseConnection.setDatabasePort(getNodeValueByTagName(element, DATABASE_PORT));
databaseConnection.setAccessType(DatabaseAccessType.getAccessTypeByName(getNodeValueByTagName(element, ACCESS_TYPE)));
databaseConnection.setDatabaseType((DatabaseType) databaseTypeHelper.getDatabaseTypeByShortName(getNodeValueByTagName(element, DATABASE_TYPE)));
databaseConnection.setPassword(getNodeValueByTagName(element, PASSWORD));
databaseConnection.setInformixServername(getNodeValueByTagName(element, SERVER_NAME));
for (Node node : getNodesByTagName(element, ATTRIBUTES)) {
databaseConnection.getAttributes().put(node.getNodeName(), node.getNodeValue());
}
return databaseConnection;
}
use of com.google.gwt.xml.client.Element in project data-access by pentaho.
the class DatabaseConnectionConverter method convertToXml.
public String convertToXml(IDatabaseConnection dbConn) {
Document document = XMLParser.createDocument();
try {
Element databaseConnection = document.createElement(DATABASE_CONNECTION);
document.appendChild(databaseConnection);
Element databaseName = document.createElement(DATABASE_NAME);
Text databaseNameText = document.createTextNode(dbConn.getDatabaseName());
databaseName.appendChild(databaseNameText);
databaseConnection.appendChild(databaseName);
Element databasePort = document.createElement(DATABASE_PORT);
Text databasePortText = document.createTextNode(dbConn.getDatabasePort());
databasePort.appendChild(databasePortText);
databaseConnection.appendChild(databasePort);
Element hostname = document.createElement(HOSTNAME);
Text hostnameText = document.createTextNode(dbConn.getHostname());
hostname.appendChild(hostnameText);
databaseConnection.appendChild(hostname);
Element indexTablespace = document.createElement(INDEX_TABLESPACE);
Text indexTablespaceText = document.createTextNode(dbConn.getIndexTablespace());
indexTablespace.appendChild(indexTablespaceText);
databaseConnection.appendChild(indexTablespace);
Element dataTablespace = document.createElement(DATA_TABLESPACE);
Text dataTablespaceText = document.createTextNode(dbConn.getIndexTablespace());
dataTablespace.appendChild(dataTablespaceText);
databaseConnection.appendChild(dataTablespace);
Element informixServername = document.createElement(SERVER_NAME);
Text informixServernameText = document.createTextNode(dbConn.getInformixServername());
informixServername.appendChild(informixServernameText);
databaseConnection.appendChild(informixServername);
Element name = document.createElement(NAME);
Text nameText = document.createTextNode(dbConn.getName());
name.appendChild(nameText);
databaseConnection.appendChild(name);
Element username = document.createElement(USERNAME);
Text usernameTxt = document.createTextNode(dbConn.getUsername());
username.appendChild(usernameTxt);
databaseConnection.appendChild(username);
Element password = document.createElement(PASSWORD);
Text passwordText = document.createTextNode(dbConn.getPassword());
password.appendChild(passwordText);
databaseConnection.appendChild(password);
Element accessType = document.createElement(ACCESS_TYPE);
Text accessTypeText = document.createTextNode(dbConn.getAccessType().getName());
accessType.appendChild(accessTypeText);
databaseConnection.appendChild(accessType);
Element databaseType = document.createElement(DATABASE_TYPE);
Text databaseTypeText = document.createTextNode(dbConn.getDatabaseType().getShortName());
databaseType.appendChild(databaseTypeText);
databaseConnection.appendChild(databaseType);
Element attrributes = document.createElement(ATTRIBUTES);
databaseConnection.appendChild(attrributes);
Map<String, String> attributeMap = dbConn.getAttributes();
for (String key : attributeMap.keySet()) {
Element attribute = document.createElement(key);
Text attributeText = document.createTextNode(attributeMap.get(key));
attribute.appendChild(attributeText);
attrributes.appendChild(attribute);
}
return document.toString();
} catch (Exception e) {
return null;
}
}
use of com.google.gwt.xml.client.Element in project data-access by pentaho.
the class DatasourceServiceManagerGwtImpl method convertReponseToList.
private List<String> convertReponseToList(Response response) {
List<String> dataList = new ArrayList<String>();
Document document = (Document) XMLParser.parse(response.getText());
Element element = document.getDocumentElement();
Node node = element.getFirstChild();
boolean done = false;
do {
try {
dataList.add(getNodeValueByTagName(node, "Item"));
node = (node.getNextSibling() != null) ? node.getNextSibling() : null;
if (node == null) {
done = true;
}
} catch (Exception e) {
done = true;
}
} while (!done);
return dataList;
}
Aggregations