use of com.google.gwt.http.client.RequestException in project pentaho-platform by pentaho.
the class DeleteFolderCommand method performOperation.
protected void performOperation(boolean feedback) {
final SolutionFolderActionEvent event = new SolutionFolderActionEvent();
event.setAction(this.getClass().getName());
final String filesList = repositoryFile.getId();
final String folderName = repositoryFile.getTitle() == null ? repositoryFile.getName() : repositoryFile.getTitle();
final HTML messageTextBox = new HTML(Messages.getString("moveToTrashQuestionFolder", escapeHtmlEntities(folderName)));
final PromptDialogBox folderDeleteWarningDialogBox = new PromptDialogBox(Messages.getString("moveToTrash"), Messages.getString("yesMoveToTrash"), Messages.getString("no"), true, true);
folderDeleteWarningDialogBox.setContent(messageTextBox);
final IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
folderDeleteWarningDialogBox.hide();
}
public void okPressed() {
// $NON-NLS-1$
String deleteFilesURL = contextURL + "api/repo/files/delete";
RequestBuilder deleteFilesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, deleteFilesURL);
deleteFilesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
// $NON-NLS-1$//$NON-NLS-2$
deleteFilesRequestBuilder.setHeader("Content-Type", "text/plain");
try {
deleteFilesRequestBuilder.sendRequest(filesList, new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("couldNotDeleteFolder"), false, false, true);
dialogBox.center();
event.setMessage(Messages.getString("couldNotDeleteFolder"));
EventBusUtil.EVENT_BUS.fireEvent(event);
}
@Override
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == 200) {
new RefreshRepositoryCommand().execute(false);
event.setMessage("Success");
FileChooserDialog.setIsDirty(Boolean.TRUE);
setBrowseRepoDirty(Boolean.TRUE);
EventBusUtil.EVENT_BUS.fireEvent(event);
} else {
MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("couldNotDeleteFolder"), false, false, true);
dialogBox.center();
event.setMessage(Messages.getString("couldNotDeleteFolder"));
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
});
} catch (RequestException e) {
MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("couldNotDeleteFolder"), false, false, true);
dialogBox.center();
event.setMessage(Messages.getString("couldNotDeleteFolder"));
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
};
folderDeleteWarningDialogBox.setCallback(callback);
folderDeleteWarningDialogBox.center();
}
use of com.google.gwt.http.client.RequestException in project pentaho-platform by pentaho.
the class DeletePermanentFileCommand method performOperation.
/*
* (non-Javadoc)
*
* @see com.google.gwt.user.client.Command#execute()
*/
protected void performOperation(boolean feedback) {
final SolutionFileActionEvent event = new SolutionFileActionEvent();
event.setAction(this.getClass().getName());
VerticalPanel vp = new VerticalPanel();
String deleteMessage;
final PromptDialogBox deleteConfirmDialog;
if (mode.equals("purge")) {
deleteMessage = Messages.getString("deleteAllQuestion");
deleteConfirmDialog = new PromptDialogBox(Messages.getString("emptyTrash"), Messages.getString("yesEmptyTrash"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vp);
} else {
if (MULTIPLE_DELETE_TYPE.equals(type)) {
deleteMessage = Messages.getString("deleteMultiQuestion");
} else {
deleteMessage = Messages.getString("deleteQuestion", type);
}
deleteConfirmDialog = new PromptDialogBox(Messages.getString("permDelete"), Messages.getString("yesPermDelete"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vp);
}
// $NON-NLS-1$
vp.add(new HTML(deleteMessage));
final IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
deleteConfirmDialog.hide();
}
public void okPressed() {
String temp = "";
// Add js file list
temp = temp + fileList;
// remove trailing ","
temp = temp.substring(0, temp.length() - 1);
final String filesList = temp;
// $NON-NLS-1$
String deleteFilesURL = contextURL + "api/repo/files/deletepermanent";
RequestBuilder deleteFilesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, deleteFilesURL);
// $NON-NLS-1$//$NON-NLS-2$
deleteFilesRequestBuilder.setHeader("Content-Type", "text/plain");
deleteFilesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
deleteFilesRequestBuilder.sendRequest(filesList, new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("couldNotDeleteFile"), false, false, true);
dialogBox.center();
event.setMessage(Messages.getString("couldNotDeleteFile"));
EventBusUtil.EVENT_BUS.fireEvent(event);
}
@Override
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == 200) {
new RefreshRepositoryCommand().execute(false);
event.setMessage("Success");
FileChooserDialog.setIsDirty(Boolean.TRUE);
setBrowseRepoDirty(Boolean.TRUE);
EventBusUtil.EVENT_BUS.fireEvent(event);
} else {
event.setMessage(Messages.getString("couldNotDeleteFile"));
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
});
} catch (RequestException e) {
MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("couldNotDeleteFile"), false, false, true);
dialogBox.center();
event.setMessage(Messages.getString("couldNotDeleteFile"));
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
};
if (!feedback) {
callback.okPressed();
} else {
deleteConfirmDialog.setCallback(callback);
deleteConfirmDialog.center();
}
}
use of com.google.gwt.http.client.RequestException in project pentaho-platform by pentaho.
the class MantleController method executeAdminContent.
private void executeAdminContent() {
try {
RequestCallback internalCallback = new RequestCallback() {
public void onError(Request request, Throwable exception) {
}
public void onResponseReceived(Request request, Response response) {
JsArray<JsSetting> jsSettings = null;
try {
jsSettings = JsSetting.parseSettingsJson(response.getText());
} catch (Throwable t) {
// happens when there are no settings
}
if (jsSettings == null) {
return;
}
for (int i = 0; i < jsSettings.length(); i++) {
String content = jsSettings.get(i).getValue();
// $NON-NLS-1$
StringTokenizer nameValuePairs = new StringTokenizer(content, ";");
String perspective = null, content_panel_id = null, content_url = null;
for (int j = 0; j < nameValuePairs.countTokens(); j++) {
String currentToken = nameValuePairs.tokenAt(j).trim();
if (currentToken.startsWith("perspective=")) {
// $NON-NLS-1$
// $NON-NLS-1$
perspective = currentToken.substring("perspective=".length());
}
if (currentToken.startsWith("content-panel-id=")) {
// $NON-NLS-1$
// $NON-NLS-1$
content_panel_id = currentToken.substring("content-panel-id=".length());
}
if (currentToken.startsWith("content-url=")) {
// $NON-NLS-1$
// $NON-NLS-1$
content_url = currentToken.substring("content-url=".length());
}
}
if (content_panel_id != null && content_url != null) {
overrideContentPanelId = content_panel_id;
overrideContentUrl = content_url;
}
if (perspective != null) {
PerspectiveManager.getInstance().setPerspective(perspective);
}
if (perspective == null && content_panel_id == null && content_url == null) {
GwtMessageBox warning = new GwtMessageBox();
// $NON-NLS-1$
warning.setTitle(Messages.getString("warning"));
warning.setMessage(content);
warning.setButtons(new Object[GwtMessageBox.ACCEPT]);
// $NON-NLS-1$
warning.setAcceptLabel(Messages.getString("close"));
warning.show();
}
}
}
};
RequestBuilder builder = // $NON-NLS-1$
new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "api/mantle/getAdminContent");
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
// $NON-NLS-1$ //$NON-NLS-2$
builder.setHeader("accept", "application/json");
builder.sendRequest(null, internalCallback);
// TO DO Reset the menuItem click for browser and workspace here?
} catch (RequestException e) {
// ignore
}
}
use of com.google.gwt.http.client.RequestException in project pentaho-platform by pentaho.
the class MantleXul method xulLoaded.
/**
* Callback method for the MantleXulLoader. This is called when the Xul file has been processed.
*
* @param runner
* GwtXulRunner instance ready for event handlers and initializing.
*/
public void xulLoaded(GwtXulRunner runner) {
// handlers need to be wrapped generically in GWT, create one and pass it our reference.
// instantiate our Model and Controller
controller = new MantleController(new MantleModel(this));
// Add handler to container
container = (GwtXulDomContainer) runner.getXulDomContainers().get(0);
container.addEventHandler(controller);
try {
runner.initialize();
} catch (XulException e) {
// $NON-NLS-1$
Window.alert("Error initializing XUL runner: " + e.getMessage());
e.printStackTrace();
return;
}
// Get the toolbar from the XUL doc
// $NON-NLS-1$
Widget bar = (Widget) container.getDocumentRoot().getElementById("mainToolbarWrapper").getManagedObject();
// $NON-NLS-1$
Widget xultoolbar = (Widget) container.getDocumentRoot().getElementById("mainToolbar").getManagedObject();
xultoolbar.getElement().removeClassName("toolbar");
toolbar.setStylePrimaryName("mainToolbar-Wrapper");
toolbar.setWidget(bar);
// Get the menubar from the XUL doc
// $NON-NLS-1$
Widget menu = (Widget) container.getDocumentRoot().getElementById("mainMenubar").getManagedObject();
menubar.setWidget(menu);
// check based on user permissions
final String moduleBaseURL = GWT.getModuleBaseURL();
final String moduleName = GWT.getModuleName();
final String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
// $NON-NLS-1$
final String url = contextURL + "api/repo/files/canCreate";
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
executableTypesRequestBuilder.setHeader("accept", "text/plain");
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// showError(exception);
}
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == Response.SC_OK) {
Boolean visible = new Boolean(response.getText());
controller.setMenuBarEnabled("newmenu", visible);
controller.setToolBarButtonEnabled("newButton", visible);
}
}
});
} catch (RequestException e) {
// showError(e);
}
// get the admin perspective from the XUL doc
// $NON-NLS-1$
Widget admin = (Widget) container.getDocumentRoot().getElementById("adminPerspective").getManagedObject();
admin.setStyleName("admin-perspective");
admin.getElement().getStyle().clearHeight();
admin.getElement().getStyle().clearWidth();
adminPerspective.setWidget(admin);
Panel adminContentPanel = (Panel) container.getDocumentRoot().getElementById("adminContentPanel").getManagedObject();
adminContentPanel.add(adminContentDeck);
adminContentDeck.setHeight("100%");
adminContentDeck.getElement().getStyle().setProperty("height", "100%");
fetchPluginOverlays();
}
use of com.google.gwt.http.client.RequestException in project pentaho-platform by pentaho.
the class MantleXul method configureAdminCatTree.
public void configureAdminCatTree() {
String serviceUrl = GWT.getHostPageBaseURL() + "api/ldap/config/getAttributeValues";
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, serviceUrl);
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
}
public void onResponseReceived(Request request, Response response) {
String securityProvider = response.getText();
enableUsersRolesTreeItem(securityProvider.contains("DB_BASED_AUTHENTICATION"));
}
});
} catch (RequestException e) {
// ignored
}
}
Aggregations