use of com.google.gwt.xml.client.Node in project pentaho-platform by pentaho.
the class AdhocRunInBackgroundCommand method parseFolderId.
private RequestBuilder parseFolderId(Response response) {
String folderId = null;
Document repository = XMLParser.parse(response.getText());
NodeList fileNodeList = repository.getElementsByTagName("file");
for (int i = 0; i < fileNodeList.getLength(); i++) {
Element element = (Element) fileNodeList.item(i);
Node pathNode = element.getElementsByTagName("path").item(0);
if (getOutputLocationPath().equals(pathNode.getFirstChild().getNodeValue())) {
folderId = element.getElementsByTagName("id").item(0).getFirstChild().getNodeValue();
}
}
RequestBuilder scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.POST, contextURL + "plugin/reporting/api/jobs/" + jobId + "/schedule?confirm=true&folderId=" + folderId + "&newName=" + getOutputName() + "&recalculateFinished=" + getRecalculateFinished());
scheduleFileRequestBuilder.setHeader("Content-Type", "application/json");
scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
return scheduleFileRequestBuilder;
}
use of com.google.gwt.xml.client.Node in project pentaho-platform by pentaho.
the class PermissionsPanel method removeAllAces.
/**
*/
private void removeAllAces(Document fileInfo) {
// Window.alert("removeAllAces() called with: \n" + fileInfo.toString());
NodeList aces = fileInfo.getElementsByTagName(ACES_ELEMENT_NAME);
while (aces != null && aces.getLength() > 0) {
for (int i = 0; i < aces.getLength(); i++) {
Node ace = aces.item(i);
ace.getParentNode().removeChild(ace);
}
aces = fileInfo.getElementsByTagName(ACES_ELEMENT_NAME);
}
}
use of com.google.gwt.xml.client.Node in project pentaho-platform by pentaho.
the class PermissionsPanel method replacePermissionsWithAll.
private void replacePermissionsWithAll(Element ace, Document fileInfo) {
NodeList perms = ace.getElementsByTagName(PERMISSIONS_ELEMENT_NAME);
int childCount = perms.getLength();
for (int i = 0; i < childCount; i++) {
Node perm = perms.item(i);
if (perm != null) {
ace.removeChild(perm);
}
}
Element newPerm = fileInfo.createElement(PERMISSIONS_ELEMENT_NAME);
Text textNode = fileInfo.createTextNode(Integer.toString(PERM_ALL));
newPerm.appendChild(textNode);
ace.appendChild(newPerm);
}
use of com.google.gwt.xml.client.Node in project pentaho-platform by pentaho.
the class PermissionsPanel method getNames.
/**
* @param type
* @return list of names of given "type"
*/
protected List<String> getNames(final Document fileInfo, int type) {
List<String> names = new ArrayList<String>();
NodeList aces = fileInfo.getElementsByTagName(ACES_ELEMENT_NAME);
for (int i = 0; i < aces.getLength(); i++) {
Element ace = (Element) aces.item(i);
NodeList recipientTypeList = ace.getElementsByTagName(RECIPIENT_TYPE_ELEMENT_NAME);
Node recipientNode = recipientTypeList.item(0);
String nodeValue = recipientNode.getFirstChild().getNodeValue();
int recipientType = Integer.parseInt(nodeValue);
if (recipientType == type) {
names.add(ace.getElementsByTagName(RECIPIENT_ELEMENT_NAME).item(0).getFirstChild().getNodeValue());
}
}
return names;
}
use of com.google.gwt.xml.client.Node in project pentaho-platform by pentaho.
the class PasteFilesCommand method performOperation.
/*
* (non-Javadoc)
*
* @see org.pentaho.mantle.client.commands.AbstractCommand#performOperation(boolean)
*/
@Override
protected void performOperation(boolean feedback) {
final SolutionBrowserClipboard clipBoard = SolutionBrowserClipboard.getInstance();
@SuppressWarnings("unchecked") final List<SolutionBrowserFile> clipboardFileItems = clipBoard.getClipboardItems();
if (clipboardFileItems != null && clipboardFileItems.size() > 0 && getSolutionPath() != null) {
String getChildrenUrl = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId(getSolutionPath()) + "/tree?depth=1" + "&showHidden=" + // $NON-NLS-1$ //$NON-NLS-2$
SolutionBrowserPanel.getInstance().getSolutionTree().isShowHiddenFiles();
RequestBuilder childrenRequestBuilder = new RequestBuilder(RequestBuilder.GET, getChildrenUrl);
try {
childrenRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
childrenRequestBuilder.sendRequest(null, new RequestCallback() {
@Override
public void onError(Request getChildrenRequest, Throwable exception) {
Window.alert(exception.getLocalizedMessage());
event.setMessage(exception.getLocalizedMessage());
EventBusUtil.EVENT_BUS.fireEvent(event);
}
@Override
public void onResponseReceived(Request getChildrenRequest, Response getChildrenResponse) {
event.setMessage("Click");
EventBusUtil.EVENT_BUS.fireEvent(event);
boolean cutSameDir = false;
if (getChildrenResponse.getStatusCode() >= 200 && getChildrenResponse.getStatusCode() < 300) {
boolean promptForOptions = false;
Document children = XMLParser.parse(getChildrenResponse.getText());
NodeList childrenNameNodes = children.getElementsByTagName(NAME_NODE_TAG);
List<String> childNames = new ArrayList<String>();
for (int i = 0; i < childrenNameNodes.getLength(); i++) {
Node childNameNode = childrenNameNodes.item(i);
childNames.add(childNameNode.getFirstChild().getNodeValue());
}
for (SolutionBrowserFile file : clipboardFileItems) {
if (file.getPath() != null) {
String pasteFileParentPath = file.getPath();
// $NON-NLS-1$
String fileNameWithExt = pasteFileParentPath.substring(pasteFileParentPath.lastIndexOf("/") + 1, pasteFileParentPath.length());
// $NON-NLS-1$
pasteFileParentPath = pasteFileParentPath.substring(0, pasteFileParentPath.lastIndexOf("/"));
if (childNames.contains(fileNameWithExt) && !getSolutionPath().equals(pasteFileParentPath)) {
promptForOptions = true;
break;
} else if (childNames.contains(fileNameWithExt) && getSolutionPath().equals(pasteFileParentPath) && SolutionBrowserClipboard.getInstance().getClipboardAction() == SolutionBrowserClipboard.ClipboardAction.CUT) {
cutSameDir = true;
break;
}
}
}
if (promptForOptions) {
final OverwritePromptDialog overwriteDialog = new OverwritePromptDialog();
final IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
event.setMessage("Cancel");
EventBusUtil.EVENT_BUS.fireEvent(event);
overwriteDialog.hide();
}
public void okPressed() {
performSave(clipBoard, overwriteDialog.getOverwriteMode());
}
};
overwriteDialog.setCallback(callback);
overwriteDialog.center();
} else {
if (!cutSameDir) {
performSave(clipBoard, 2);
} else {
event.setMessage("Cancel");
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
} else {
Window.alert(getChildrenResponse.getText());
}
}
});
} catch (RequestException e) {
Window.alert(e.getLocalizedMessage());
}
}
}
Aggregations