use of com.google.gwt.http.client.Response in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method updatePassword.
public void updatePassword(String newPassword, String administratorPassword, final ServiceCallback callback) {
String userName = usersListBox.getValue(usersListBox.getSelectedIndex());
String serviceUrl = GWT.getHostPageBaseURL() + "api/userroledao/updatePassword";
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, serviceUrl);
try {
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
executableTypesRequestBuilder.setHeader("Content-Type", "application/json");
String json = "{\"userName\": \"" + encodeUri(userName) + "\", \"password\": \"" + encodeUri(newPassword) + "\", \"administratorPassword\": \"" + encodeUri(administratorPassword) + "\"}";
executableTypesRequestBuilder.sendRequest(json, new RequestCallback() {
public void onError(Request request, Throwable exception) {
showXulErrorMessage(Messages.getString("changePasswordErrorTitle"), Messages.getString("changePasswordErrorMessage"));
callback.serviceResult(false);
}
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() != Response.SC_OK) {
showXulErrorMessage(Messages.getString("changePasswordErrorTitle"), Messages.getString("changePasswordErrorMessage"));
callback.serviceResult(false);
} else {
callback.serviceResult(true);
}
}
});
} catch (RequestException e) {
showXulErrorMessage(Messages.getString("changePasswordErrorTitle"), Messages.getString("changePasswordErrorMessage"));
callback.serviceResult(false);
}
}
use of com.google.gwt.http.client.Response in project pentaho-platform by pentaho.
the class AbstractFilePropertiesCommand method performOperation.
public void performOperation() {
final SolutionFileActionEvent event = new SolutionFileActionEvent();
event.setAction(this.getClass().getName());
if (getRepositoryFile() != null) {
final RepositoryFile item = getRepositoryFile();
// Checking if the user has access to manage permissions
String url = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId(item.getPath()) + "/canAccess?permissions=" + // $NON-NLS-1$ //$NON-NLS-2$
MANAGE_ACLS;
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
try {
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), false);
dialog.showTab(getActiveTab());
dialog.center();
event.setMessage(exception.getMessage());
EventBusUtil.EVENT_BUS.fireEvent(event);
}
public void onResponseReceived(Request request, Response response) {
FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), Boolean.parseBoolean(response.getText()));
dialog.showTab(getActiveTab());
dialog.center();
event.setMessage("Success");
EventBusUtil.EVENT_BUS.fireEvent(event);
}
});
} catch (RequestException e) {
FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), false);
dialog.showTab(getActiveTab());
dialog.center();
event.setMessage(e.getMessage());
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
}
use of com.google.gwt.http.client.Response 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.Response 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.Response 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
}
}
Aggregations