Example usage for com.google.gwt.http.client RequestCallback RequestCallback

List of usage examples for com.google.gwt.http.client RequestCallback RequestCallback

Introduction

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

Prototype

RequestCallback

Source Link

Usage

From source file:ecplugins.openstack.client.CreateConfiguration.java

License:Apache License

private void waitForJob(final String jobId) {
    CgiRequestProxy cgiRequestProxy = new CgiRequestProxy(getPluginName(), "openstackMonitor.cgi");
    Map<String, String> cgiParams = new HashMap<String, String>();

    cgiParams.put("jobId", jobId);

    // Pass debug flag to CGI, which will use it to determine whether to
    // clean up a successful job
    if ("1".equals(getGetParameter("debug"))) {
        cgiParams.put("debug", "1");
    }//ww w .  j  av  a  2s  .  c  o  m

    try {
        cgiRequestProxy.issueGetRequest(cgiParams, new RequestCallback() {
            @Override
            public void onError(Request request, Throwable exception) {
                addErrorMessage("CGI request failed: ", exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                String responseString = response.getText();

                if (getLog().isDebugEnabled()) {
                    getLog().debug("CGI response received: " + responseString);
                }

                if (responseString.startsWith("Success")) {

                    // We're done!
                    cancel();
                } else {
                    SimpleErrorBox error = getUIFactory().createSimpleErrorBox(
                            "Error occurred during configuration creation: " + responseString);
                    CommanderUrlBuilder urlBuilder = createUrl("jobDetails.php").setParameter("jobId", jobId);

                    error.add(new Anchor("(See job for details)", urlBuilder.buildString()));
                    addErrorMessage(error);
                }
            }
        });
    } catch (RequestException e) {
        addErrorMessage("CGI request failed: ", e);
    }
}

From source file:ecplugins.openstack.client.OpenStackConfigListLoader.java

License:Apache License

private void loadConfigs(Map<String, String> cgiParams) {

    try {//from  w ww . ja  va2  s.  c o m
        String request = m_cgiRequestProxy.issueGetRequest(cgiParams, new RequestCallback() {
            @Override
            public void onError(Request request, Throwable exception) {
                ((HasErrorPanel) m_component).addErrorMessage("Error loading OpenStack configuration list: ",
                        exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                String responseString = response.getText();

                // if HTML returned we never made it to the CGI
                Boolean isHtml = (responseString.indexOf("DOCTYPE HTML") != -1);
                String error;

                if (!isHtml) {
                    error = m_configList.parseResponse(responseString);
                } else {
                    error = responseString;
                }

                if (m_component.getLog().isDebugEnabled()) {
                    m_component.getLog().debug("Recieved CGI response: " + responseString + " isHTML:" + isHtml
                            + " error:" + error);
                }

                if (error != null) {
                    ((HasErrorPanel) m_component).addErrorMessage(error);
                } else {

                    if (StringUtil.isEmpty(m_editorName) || m_configList.isEmpty()) {

                        // We're done!
                        if (m_callback != null) {
                            m_callback.onComplete();
                        }
                    } else {
                        loadEditors();
                    }
                }
            }
        });

        if (m_component.getLog().isDebugEnabled()) {
            m_component.getLog().debug("Issued CGI request: " + request);
        }
    } catch (RequestException e) {

        if (m_component instanceof HasErrorPanel) {
            ((HasErrorPanel) m_component).addErrorMessage("Error loading OpenStack configuration list: ", e);
        } else {
            m_component.getLog().error(e);
        }
    }
}

From source file:ecplugins.s3.client.ConfigurationList.java

License:Apache License

@SuppressWarnings("OverlyComplexAnonymousInnerClass")
private void waitForJob(final String jobId) {
    CgiRequestProxy cgiRequestProxy = new CgiRequestProxy(ComponentBaseFactory.getPluginName(),
            "s3Monitor.cgi");
    Map<String, String> cgiParams = new HashMap<String, String>();

    cgiParams.put("jobId", jobId);

    // Pass debug flag to CGI, which will use it to determine whether to
    // clean up a successful job
    if ("1".equals(getGetParameter("debug"))) {
        cgiParams.put("debug", "1");
    }//from w  w w.  j a va  2s  .  co  m

    try {
        cgiRequestProxy.issueGetRequest(cgiParams, new RequestCallback() {
            @Override
            public void onError(Request request, Throwable exception) {

                // noinspection HardCodedStringLiteral
                addErrorMessage("CGI request failed:: ", exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                String responseString = response.getText();

                if (getLog().isDebugEnabled()) {
                    getLog().debug("CGI response received: " + responseString);
                }

                if (responseString.startsWith("Success")) {

                    // We're done!
                    Location.reload();
                } else {
                    @SuppressWarnings({ "HardCodedStringLiteral", "StringConcatenation" })
                    SimpleErrorBox error = getUIFactory().createSimpleErrorBox(
                            "Error occurred during configuration deletion: " + responseString);
                    CommanderUrlBuilder urlBuilder = CommanderUrlBuilder.createUrl("jobDetails.php")
                            .setParameter("jobId", jobId);

                    // noinspection HardCodedStringLiteral
                    error.add(new Anchor("(See job for details)", urlBuilder.buildString()));
                    addErrorMessage(error);
                }
            }
        });
    } catch (RequestException e) {

        // noinspection HardCodedStringLiteral
        addErrorMessage("CGI request failed:: ", e);
    }
}

From source file:ecplugins.s3.client.CreateConfiguration.java

License:Apache License

@SuppressWarnings("OverlyComplexAnonymousInnerClass")
private void waitForJob(final String jobId) {
    CgiRequestProxy cgiRequestProxy = new CgiRequestProxy(getPluginName(), "s3Monitor.cgi");
    Map<String, String> cgiParams = new HashMap<String, String>();

    cgiParams.put("jobId", jobId);

    // Pass debug flag to CGI, which will use it to determine whether to
    // clean up a successful job
    if ("1".equals(getGetParameter("debug"))) {
        cgiParams.put("debug", "1");
    }//www. j  av  a 2  s. c  o  m

    try {
        cgiRequestProxy.issueGetRequest(cgiParams, new RequestCallback() {
            @Override
            public void onError(Request request, Throwable exception) {

                // noinspection HardCodedStringLiteral
                addErrorMessage("CGI request failed: ", exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                String responseString = response.getText();

                if (getLog().isDebugEnabled()) {
                    getLog().debug("CGI response received: " + responseString);
                }

                if (responseString.startsWith("Success")) {

                    // We're done!
                    cancel();
                } else {
                    @SuppressWarnings({ "HardCodedStringLiteral", "StringConcatenation" })
                    SimpleErrorBox error = getUIFactory().createSimpleErrorBox(
                            "Error occurred during configuration creation: " + responseString);
                    CommanderUrlBuilder urlBuilder = createUrl("jobDetails.php").setParameter("jobId", jobId);

                    // noinspection HardCodedStringLiteral
                    error.add(new Anchor("(See job for details)", urlBuilder.buildString()));
                    addErrorMessage(error);
                }
            }
        });
    } catch (RequestException e) {

        // noinspection HardCodedStringLiteral
        addErrorMessage("CGI request failed: ", e);
    }
}

From source file:ecplugins.s3.client.S3ConfigListLoader.java

License:Apache License

@SuppressWarnings("OverlyComplexAnonymousInnerClass")
private void loadConfigs(Map<String, String> cgiParams) {

    try {// w ww  . j av a2 s  .co  m
        String request = m_cgiRequestProxy.issueGetRequest(cgiParams, new RequestCallback() {
            @Override
            public void onError(
                    @SuppressWarnings("AnonymousClassVariableHidesContainingMethodVariable") Request request,
                    Throwable exception) {

                // noinspection HardCodedStringLiteral
                ((HasErrorPanel) m_component).addErrorMessage("Error loading S3 configuration list: ",
                        exception);
            }

            @Override
            public void onResponseReceived(
                    @SuppressWarnings("AnonymousClassVariableHidesContainingMethodVariable") Request request,
                    Response response) {
                @NonNls
                String responseString = response.getText();

                // if HTML returned we never made it to the CGI
                Boolean isHtml = responseString.contains("DOCTYPE HTML");
                String error;

                if (isHtml) {
                    error = responseString;
                } else {
                    error = m_configList.parseResponse(responseString);
                }

                if (m_component.getLog().isDebugEnabled()) {
                    m_component.getLog().debug("Recieved CGI response: " + responseString + " isHTML:" + isHtml
                            + " error:" + error);
                }

                if (error == null) {

                    if (StringUtil.isEmpty(m_editorName) || m_configList.isEmpty()) {

                        // We're done!
                        if (m_callback != null) {
                            m_callback.onComplete();
                        }
                    } else {
                        loadEditors();
                    }
                } else {
                    ((HasErrorPanel) m_component).addErrorMessage(error);
                }
            }
        });

        if (m_component.getLog().isDebugEnabled()) {
            m_component.getLog().debug("Issued CGI request: " + request);
        }
    } catch (RequestException e) {

        if (m_component instanceof HasErrorPanel) {

            // noinspection HardCodedStringLiteral
            ((HasErrorPanel) m_component).addErrorMessage("Error loading S3 configuration list: ", e);
        } else {
            m_component.getLog().error(e);
        }
    }
}

From source file:ecplugins.weblogic.client.ConfigurationList.java

License:Apache License

private void waitForJob(final String jobId) {
    CgiRequestProxy cgiRequestProxy = new CgiRequestProxy(getPluginName(), "weblogicMonitor.cgi");
    Map<String, String> cgiParams = new HashMap<String, String>();

    cgiParams.put("jobId", jobId);

    // Pass debug flag to CGI, which will use it to determine whether to
    // clean up a successful job
    if ("1".equals(getGetParameter("debug"))) {
        cgiParams.put("debug", "1");
    }//from   www . java 2 s.  c  om

    try {
        cgiRequestProxy.issueGetRequest(cgiParams, new RequestCallback() {
            @Override
            public void onError(Request request, Throwable exception) {
                addErrorMessage("CGI request failed:: ", exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                String responseString = response.getText();

                if (getLog().isDebugEnabled()) {
                    getLog().debug("CGI response received: " + responseString);
                }

                if (responseString.startsWith("Success")) {

                    // We're done!
                    Location.reload();
                } else {
                    SimpleErrorBox error = getUIFactory().createSimpleErrorBox(
                            "Error occurred during configuration deletion: " + responseString);
                    CommanderUrlBuilder urlBuilder = CommanderUrlBuilder.createUrl("jobDetails.php")
                            .setParameter("jobId", jobId);

                    error.add(new Anchor("(See job for details)", urlBuilder.buildString()));
                    addErrorMessage(error);
                }
            }
        });
    } catch (RequestException e) {
        addErrorMessage("CGI request failed:: ", e);
    }
}

From source file:ecplugins.weblogic.client.CreateConfiguration.java

License:Apache License

private void waitForJob(final String jobId) {
    CgiRequestProxy cgiRequestProxy = new CgiRequestProxy(getPluginName(), "weblogicMonitor.cgi");
    Map<String, String> cgiParams = new HashMap<String, String>();

    cgiParams.put("jobId", jobId);

    // Pass debug flag to CGI, which will use it to determine whether to
    // clean up a successful job
    if ("1".equals(getGetParameter("debug"))) {
        cgiParams.put("debug", "1");
    }//from  ww w . j av a 2s .  c  om

    try {
        cgiRequestProxy.issueGetRequest(cgiParams, new RequestCallback() {
            @Override
            public void onError(Request request, Throwable exception) {
                addErrorMessage("CGI request failed: ", exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                String responseString = response.getText();

                if (getLog().isDebugEnabled()) {
                    getLog().debug("CGI response received: " + responseString);
                }

                if (responseString.startsWith("Success")) {

                    // We're done!
                    cancel();
                } else {
                    SimpleErrorBox error = getUIFactory().createSimpleErrorBox(
                            "Error occurred during configuration creation: " + responseString);
                    CommanderUrlBuilder urlBuilder = createUrl("jobDetails.php").setParameter("jobId", jobId);

                    error.add(new Anchor("(See job for details)", urlBuilder.buildString()));
                    addErrorMessage(error);
                }
            }
        });
    } catch (RequestException e) {
        addErrorMessage("CGI request failed: ", e);
    }
}

From source file:ecplugins.weblogic.client.WebLogicConfigListLoader.java

License:Apache License

private void loadConfigs(Map<String, String> cgiParams) {

    try {/*w  w  w .  jav a  2  s  .c o  m*/
        String request = m_cgiRequestProxy.issueGetRequest(cgiParams, new RequestCallback() {
            @Override
            public void onError(Request request, Throwable exception) {
                ((HasErrorPanel) m_component).addErrorMessage("Error loading WebLogic configuration list: ",
                        exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                String responseString = response.getText();

                // if HTML returned we never made it to the CGI
                Boolean isHtml = (responseString.indexOf("DOCTYPE HTML") != -1);
                String error;

                if (!isHtml) {
                    error = m_configList.parseResponse(responseString);
                } else {
                    error = responseString;
                }

                if (m_component.getLog().isDebugEnabled()) {
                    m_component.getLog().debug("Recieved CGI response: " + responseString + " isHTML:" + isHtml
                            + " error:" + error);
                }

                if (error != null) {
                    ((HasErrorPanel) m_component).addErrorMessage(error);
                } else {

                    if (StringUtil.isEmpty(m_editorName) || m_configList.isEmpty()) {

                        // We're done!
                        if (m_callback != null) {
                            m_callback.onComplete();
                        }
                    } else {
                        loadEditors();
                    }
                }
            }
        });

        if (m_component.getLog().isDebugEnabled()) {
            m_component.getLog().debug("Issued CGI request: " + request);
        }
    } catch (RequestException e) {

        if (m_component instanceof HasErrorPanel) {
            ((HasErrorPanel) m_component).addErrorMessage("Error loading WebLogic configuration list: ", e);
        } else {
            m_component.getLog().error(e);
        }
    }
}

From source file:ecplugins.websphere.client.ConfigurationList.java

License:Apache License

private void waitForJob(final String jobId) {
    CgiRequestProxy cgiRequestProxy = new CgiRequestProxy(getPluginName(), "websphereMonitor.cgi");
    Map<String, String> cgiParams = new HashMap<String, String>();

    cgiParams.put("jobId", jobId);

    // Pass debug flag to CGI, which will use it to determine whether to
    // clean up a successful job
    if ("1".equals(getGetParameter("debug"))) {
        cgiParams.put("debug", "1");
    }/*from   www. ja v a2s .  co m*/

    try {
        cgiRequestProxy.issueGetRequest(cgiParams, new RequestCallback() {
            @Override
            public void onError(Request request, Throwable exception) {
                addErrorMessage("CGI request failed:: ", exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                String responseString = response.getText();

                if (getLog().isDebugEnabled()) {
                    getLog().debug("CGI response received: " + responseString);
                }

                if (responseString.startsWith("Success")) {

                    // We're done!
                    Location.reload();
                } else {
                    SimpleErrorBox error = getUIFactory().createSimpleErrorBox(
                            "Error occurred during configuration deletion: " + responseString);
                    CommanderUrlBuilder urlBuilder = CommanderUrlBuilder.createUrl("jobDetails.php")
                            .setParameter("jobId", jobId);

                    error.add(new Anchor("(See job for details)", urlBuilder.buildString()));
                    addErrorMessage(error);
                }
            }
        });
    } catch (RequestException e) {
        addErrorMessage("CGI request failed:: ", e);
    }
}

From source file:ecplugins.websphere.client.CreateConfiguration.java

License:Apache License

private void waitForJob(final String jobId) {
    CgiRequestProxy cgiRequestProxy = new CgiRequestProxy(getPluginName(), "websphereMonitor.cgi");
    Map<String, String> cgiParams = new HashMap<String, String>();

    cgiParams.put("jobId", jobId);

    // Pass debug flag to CGI, which will use it to determine whether to
    // clean up a successful job
    if ("1".equals(getGetParameter("debug"))) {
        cgiParams.put("debug", "1");
    }// w  w w .  j a  v  a2  s  . c  om

    try {
        cgiRequestProxy.issueGetRequest(cgiParams, new RequestCallback() {
            @Override
            public void onError(Request request, Throwable exception) {
                addErrorMessage("CGI request failed: ", exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                String responseString = response.getText();

                if (getLog().isDebugEnabled()) {
                    getLog().debug("CGI response received: " + responseString);
                }

                if (responseString.startsWith("Success")) {

                    // We're done!
                    cancel();
                } else {
                    SimpleErrorBox error = getUIFactory().createSimpleErrorBox(
                            "Error occurred during configuration creation: " + responseString);
                    CommanderUrlBuilder urlBuilder = createUrl("jobDetails.php").setParameter("jobId", jobId);

                    error.add(new Anchor("(See job for details)", urlBuilder.buildString()));
                    addErrorMessage(error);
                }
            }
        });
    } catch (RequestException e) {
        addErrorMessage("CGI request failed: ", e);
    }
}