use of com.google.gwt.xml.client.Element in project pentaho-platform by pentaho.
the class PermissionsPanel method prepareRequests.
/**
* @return
*/
public List<RequestBuilder> prepareRequests() {
ArrayList<RequestBuilder> requestBuilders = new ArrayList<RequestBuilder>();
String moduleBaseURL = GWT.getModuleBaseURL();
String moduleName = GWT.getModuleName();
String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
// $NON-NLS-1$//$NON-NLS-2$
String url = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId(fileSummary.getPath()) + "/acl";
RequestBuilder builder = new RequestBuilder(RequestBuilder.PUT, url);
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
builder.setHeader("Content-Type", "application/xml");
// default
if (isInheritsAcls(fileInfo)) {
removeAllAces(fileInfo);
} else {
// Check if any of the permission sets should be replaced with ALL.
// Any non-inherited Ace with a permission set containing PERM_GRANT_PERM should be replaced
// with a single PERM_ALL.
NodeList aces = fileInfo.getElementsByTagName(ACES_ELEMENT_NAME);
for (int i = 0; i < aces.getLength(); i++) {
Element ace = (Element) aces.item(i);
NodeList perms = ace.getElementsByTagName(PERMISSIONS_ELEMENT_NAME);
for (int j = 0; j < perms.getLength(); j++) {
Element perm = (Element) perms.item(j);
if (perm.getFirstChild() != null) {
if (Integer.parseInt(perm.getFirstChild().getNodeValue()) == PERM_GRANT_PERM) {
replacePermissionsWithAll(ace, fileInfo);
break;
}
}
}
}
}
// set request data in builder itself
builder.setRequestData(fileInfo.toString());
// add builder to list to return to parent for execution
requestBuilders.add(builder);
return requestBuilders;
}
use of com.google.gwt.xml.client.Element in project pentaho-platform by pentaho.
the class PermissionsPanel method addRecipient.
/**
* @param recipientName
* @param recipientType
*/
void addRecipient(String recipientName, int recipientType, Document fileInfo) {
Element newAces = fileInfo.createElement(ACES_ELEMENT_NAME);
Element newPermission = fileInfo.createElement(PERMISSIONS_ELEMENT_NAME);
Element newRecipient = fileInfo.createElement(RECIPIENT_ELEMENT_NAME);
Element newRecipientType = fileInfo.createElement(RECIPIENT_TYPE_ELEMENT_NAME);
Element modifiableElementName = fileInfo.createElement(MODIFIABLE_ELEMENT_NAME);
Text textNode = fileInfo.createTextNode(recipientName);
newRecipient.appendChild(textNode);
textNode = fileInfo.createTextNode(Integer.toString(recipientType));
newRecipientType.appendChild(textNode);
textNode = fileInfo.createTextNode(Boolean.toString(true));
modifiableElementName.appendChild(textNode);
newAces.appendChild(newPermission);
newAces.appendChild(newRecipient);
newAces.appendChild(newRecipientType);
newAces.appendChild(modifiableElementName);
fileInfo.getDocumentElement().appendChild(newAces);
// Base recipient is created at this point.
// Now give them the default perms.
String strRecipientType = Integer.toString(recipientType);
updatePermissionForUserOrRole(fileInfo, recipientName, strRecipientType, true, PERM_READ);
}
use of com.google.gwt.xml.client.Element in project data-access by pentaho.
the class XMLToDatasourceInfoConverter method getDatasourceInfoList.
private List<IDatasourceInfo> getDatasourceInfoList(Element element) {
List<IDatasourceInfo> datasourceInfoList = new ArrayList<IDatasourceInfo>();
NodeList nodeList = element.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Element ele = (Element) nodeList.item(i);
boolean editable = Boolean.parseBoolean(getNodeValueByTagName(ele, "editable"));
boolean removable = Boolean.parseBoolean(getNodeValueByTagName(ele, "removable"));
boolean importable = Boolean.parseBoolean(getNodeValueByTagName(ele, "importable"));
boolean exportable = Boolean.parseBoolean(getNodeValueByTagName(ele, "exportable"));
IDatasourceInfo info = new DatasourceInfo(getName(ele), getId(ele), getType(ele), editable, removable, importable, exportable);
datasourceInfoList.add(info);
}
return datasourceInfoList;
}
use of com.google.gwt.xml.client.Element in project gwt-test-utils by gwt-test-utils.
the class XMLElementTest method setAttribute.
@Test
public void setAttribute() {
// Given
Document document = XMLParser.createDocument();
Element element = document.createElement("elem");
// When
element.setAttribute("myAttr", "myValue");
// Then
assertThat(element.getAttribute("myAttr")).isEqualTo("myValue");
}
use of com.google.gwt.xml.client.Element in project gwt-test-utils by gwt-test-utils.
the class XMLElementTest method elementToString.
@Test
public void elementToString() {
// Given
Document document = XMLParser.createDocument();
Element e = document.createElement("ThisIsATest");
e.appendChild(document.createTextNode("SomeTextNode"));
// When
String toString = e.toString();
// Then
assertThat(toString).isEqualTo("<ThisIsATest>SomeTextNode</ThisIsATest>");
}
Aggregations