Example usage for com.google.gwt.http.client RequestBuilder setHeader

List of usage examples for com.google.gwt.http.client RequestBuilder setHeader

Introduction

In this page you can find the example usage for com.google.gwt.http.client RequestBuilder setHeader.

Prototype

public void setHeader(String header, String value) 

Source Link

Document

Sets a request header with the given name and value.

Usage

From source file:org.pentaho.mantle.client.admin.UserRolesAdminPanelController.java

License:Open Source License

private void processLDAPOrJDBCmode() {
    final String url = GWT.getHostPageBaseURL() + "api/system/authentication-provider";
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
    executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    executableTypesRequestBuilder.setHeader("accept", "application/json");
    try {/*from ww w  .  j  a  v a2s.  c o  m*/
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            }

            public void onResponseReceived(Request request, Response response) {
                String resText = response.getText();
                usingPentahoSecurity = resText.contains("\"jackrabbit\"") || resText.contains("\"super\"");
                userRolePermissions(usingPentahoSecurity);
            }
        });
    } catch (RequestException e) {
        userRolePermissions(false);
    }
}

From source file:org.pentaho.mantle.client.admin.UserRolesAdminPanelController.java

License:Open Source License

private void modifyUserRoles(final String userName, String serviceUrl) {
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, serviceUrl);
    try {//  w  ww .j a  v a2  s.  co m
        executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                displayErrorInMessageBox(Messages.getString("Error"), exception.getLocalizedMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                checkForError(Messages.getString("Error"), response);
                getRolesForUser(userName);
                initializeRoles(rolesListBox.getValue(rolesListBox.getSelectedIndex()), "api/userroledao/roles",
                        rolesListBox);
            }
        });
    } catch (RequestException e) {
        displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
    }
}

From source file:org.pentaho.mantle.client.admin.UserRolesAdminPanelController.java

License:Open Source License

private void modifyRoleUsers(final String roleName, String serviceUrl) {
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, serviceUrl);
    try {// w w w.jav  a2s.  c o  m
        executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                displayErrorInMessageBox(Messages.getString("Error"), exception.getLocalizedMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                checkForError(Messages.getString("Error"), response);
                getUsersInRole(roleName);
                initializeAvailableUsers(usersListBox.getValue(usersListBox.getSelectedIndex()));
            }
        });
    } catch (RequestException e) {
        displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
    }
}

From source file:org.pentaho.mantle.client.admin.UserRolesAdminPanelController.java

License:Open Source License

public void activate() {
    processLDAPOrJDBCmode();//  w  ww. j a  va  2s  .c  o m
    initializeActionBaseSecurityElements();
    initializeAvailableUsers(null);

    final String url = GWT.getHostPageBaseURL() + "api/system/authentication-provider";
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
    executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    executableTypesRequestBuilder.setHeader("accept", "application/json");
    try {
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            }

            public void onResponseReceived(Request request, Response response) {
                boolean usingPentahoSecurity = response.getText().contains("jackrabbit");
                if (!usingPentahoSecurity) {
                    initializeRoles(null, "api/userrolelist/roles?addExtraRoles=false", rolesListBox);
                } else {
                    initializeRoles(null, "api/userroledao/roles", rolesListBox);
                }
                initializeRoles(null, "api/userrolelist/extraRoles", systemRolesListBox);

            }
        });
    } catch (RequestException e) {
        // ignored
    }
}

From source file:org.pentaho.mantle.client.commands.AboutCommand.java

License:Open Source License

protected void performOperation(boolean feedback) {
    if (StringUtils.isEmpty(MantleApplication.mantleRevisionOverride) == false) {
        showAboutDialog(MantleApplication.mantleRevisionOverride);
    } else {/* w w  w. j a  va  2  s . co m*/
        final String url = GWT.getHostPageBaseURL() + "api/version/show"; //$NON-NLS-1$
        RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
        requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        requestBuilder.setHeader("accept", "text/plain");
        try {
            requestBuilder.sendRequest(null, new RequestCallback() {

                public void onError(Request request, Throwable exception) {
                    // showError(exception);
                }

                public void onResponseReceived(Request request, Response response) {
                    showAboutDialog(response.getText());
                }
            });
        } catch (RequestException e) {
            Window.alert(e.getMessage());
            // showError(e);
        }
    }
}

From source file:org.pentaho.mantle.client.commands.AbstractCommand.java

License:Open Source License

/**
 * Checks if the user is logged in, if the user is then it perform operation other wise user if ask to perform
 * the login operation again//ww  w.  j  a  va2 s  .c o m
 * 
 * @param feedback
 *          if the feedback needs to be sent back to the caller. Not used currently
 */
public void execute(final boolean feedback) {
    try {
        final String url = ScheduleHelper.getFullyQualifiedURL() + "api/mantle/isAuthenticated"; //$NON-NLS-1$
        RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
        requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        requestBuilder.setHeader("accept", "text/plain");
        requestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable caught) {
                doLogin(feedback);
            }

            public void onResponseReceived(Request request, Response response) {
                performOperation(feedback);
            }

        });
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    }
}

From source file:org.pentaho.mantle.client.commands.AbstractCommand.java

License:Open Source License

/**
 * Checks if the user is logged in, if the user is then it perform operation other wise user if ask to perform
 * the login operation again.//from ww w  .ja v a 2  s  .com
 * <p>
 * After the operation is executed, the CommandCallback object receives an afterExecute() notification.
 * 
 * @param commandCallback
 *          CommandCallback object to receive execution notification.
 * @param feedback
 *          if the feedback needs to be sent back to the caller. Not used currently
 */
public void execute(final CommandCallback commandCallback, final boolean feedback) {
    this.commandCallback = commandCallback;

    try {
        final String url = ScheduleHelper.getFullyQualifiedURL() + "api/mantle/isAuthenticated"; //$NON-NLS-1$
        RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
        requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        requestBuilder.setHeader("accept", "text/plain");
        requestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable caught) {
                doLogin(feedback);
            }

            public void onResponseReceived(Request request, Response response) {
                performOperation(feedback);
                commandCallback.afterExecute();
            }

        });
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    }

}

From source file:org.pentaho.mantle.client.commands.AbstractCommand.java

License:Open Source License

/**
 * Checks if the user is logged in, if the user is then it perform operation other wise user if ask to perform
 * the login operation again//  w  w w  .  ja v  a  2 s  .  co m
 */
public void execute() {
    try {
        final String url = ScheduleHelper.getFullyQualifiedURL() + "api/mantle/isAuthenticated"; //$NON-NLS-1$
        RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
        requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        requestBuilder.setHeader("accept", "text/plain");
        requestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable caught) {
                doLogin();
            }

            public void onResponseReceived(Request request, Response response) {
                performOperation();
            }

        });
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    }
}

From source file:org.pentaho.mantle.client.commands.AbstractFilePropertiesCommand.java

License:Open Source License

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=" + MANAGE_ACLS; //$NON-NLS-1$ //$NON-NLS-2$
        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
        try {/*w  ww  .j  a  v a2 s.  c om*/
            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);
        }
    }
}

From source file:org.pentaho.mantle.client.commands.AdhocRunInBackgroundCommand.java

License:Open Source License

private RequestBuilder createTreeRequest() {
    RequestBuilder scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.GET, contextURL
            + "api/repo/files/" + NameUtils.encodeRepositoryPath(getOutputLocationPath()) + "/tree?depth=1");
    scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    return scheduleFileRequestBuilder;
}