use of org.pentaho.mantle.client.solutionbrowser.SolutionBrowserFile in project pentaho-platform by pentaho.
the class DeleteFileCommand method performOperation.
protected void performOperation() {
if (this.getSolutionPath() != null && this.getFileNames() != null && this.getFileIds() != null) {
StringTokenizer pathTk = new StringTokenizer(this.getSolutionPath(), "\n");
StringTokenizer nameTk = new StringTokenizer(this.getFileNames(), "\n");
StringTokenizer idTk = new StringTokenizer(this.getFileIds(), "\n");
// Build Arrays since we cannot pass complex objects from the js bus
for (int i = 0; i < pathTk.countTokens(); i++) {
filesToDelete.add(new SolutionBrowserFile(idTk.tokenAt(i), nameTk.tokenAt(i), pathTk.tokenAt(i)));
}
performOperation(true);
} else {
performOperation(true);
}
}
use of org.pentaho.mantle.client.solutionbrowser.SolutionBrowserFile in project pentaho-platform by pentaho.
the class PasteFilesCommand method performSave.
void performSave(final SolutionBrowserClipboard clipBoard, Integer overwriteMode) {
@SuppressWarnings("unchecked") final List<SolutionBrowserFile> clipboardFileItems = clipBoard.getClipboardItems();
// $NON-NLS-1$
String temp = "";
for (SolutionBrowserFile file : clipboardFileItems) {
// $NON-NLS-1$
temp += file.getId() + ",";
}
// remove trailing ","
temp = temp.substring(0, temp.length() - 1);
final String filesList = temp;
String copyUrl = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId(getSolutionPath()) + "/children?mode=" + // $NON-NLS-1$//$NON-NLS-2$
overwriteMode;
String moveUrl = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId(getSolutionPath()) + // $NON-NLS-1$//$NON-NLS-2$
"/move";
RequestBuilder pasteChildrenRequestBuilder = new RequestBuilder(RequestBuilder.PUT, (SolutionBrowserClipboard.getInstance().getClipboardAction() == SolutionBrowserClipboard.ClipboardAction.CUT) ? moveUrl : copyUrl);
// $NON-NLS-1$//$NON-NLS-2$
pasteChildrenRequestBuilder.setHeader("Content-Type", "text/plain");
pasteChildrenRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
pasteChildrenRequestBuilder.sendRequest(filesList, new RequestCallback() {
@Override
public void onError(Request pasteChildrenRequest, Throwable exception) {
Window.alert(exception.getLocalizedMessage());
event.setMessage(exception.getLocalizedMessage());
EventBusUtil.EVENT_BUS.fireEvent(event);
}
@Override
public void onResponseReceived(Request pasteChildrenRequest, Response pasteChildrenResponse) {
switch(pasteChildrenResponse.getStatusCode()) {
case Response.SC_OK:
event.setMessage("Success");
EventBusUtil.EVENT_BUS.fireEvent(event);
FileChooserDialog.setIsDirty(Boolean.TRUE);
setBrowseRepoDirty(Boolean.TRUE);
// This will allow for multiple paste presses after a cut/paste.
SolutionBrowserClipboard.getInstance().setClipboardAction(SolutionBrowserClipboard.ClipboardAction.COPY);
break;
case Response.SC_FORBIDDEN:
event.setMessage(Messages.getString("pasteFilesCommand.accessDenied"));
EventBusUtil.EVENT_BUS.fireEvent(event);
break;
default:
event.setMessage(pasteChildrenResponse.getText());
EventBusUtil.EVENT_BUS.fireEvent(event);
break;
}
}
});
} catch (RequestException e) {
Window.alert(e.getLocalizedMessage());
event.setMessage(e.getLocalizedMessage());
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
Aggregations