public void launchApplyWizard() {
    // this callback is directly called from the standalone branch
    // or after the running server instances are retrieved in the domain branch
    final Callback<ApplyContext, Throwable> contextCallback =
        new Callback<ApplyContext, Throwable>() {
          @Override
          public void onFailure(final Throwable caught) {
            Log.error("Unable to launch apply patch wizard", caught);
            Console.error(
                Console.CONSTANTS.patch_manager_apply_new_wizard_error(), caught.getMessage());
          }

          @Override
          public void onSuccess(final ApplyContext context) {
            window = new DefaultWindow(Console.CONSTANTS.patch_manager_apply_patch());
            window.setWidth(480);
            window.setHeight(NORMAL_WINDOW_HEIGHT);
            window.trapWidget(
                new ApplyWizard(
                        PatchManagerPresenter.this,
                        context,
                        Console.CONSTANTS.patch_manager_apply_patch(),
                        dispatcher,
                        patchManager)
                    .asWidget());
            window.setGlassEnabled(true);
            window.center();
          }
        };

    if (bootstrapContext.isStandalone()) {
      contextCallback.onSuccess(
          new ApplyContext(
              true,
              null,
              Collections.<String>emptyList(),
              patchManager.baseAddress(),
              bootstrapContext.getProperty(BootstrapContext.PATCH_API)));
    } else {
      final String host = domainManager.getSelectedHost();
      dispatcher.execute(
          new DMRAction(getRunningServersOp(host)),
          new GetRunningServersCallback(contextCallback) {
            @Override
            protected void onServers(final List<String> runningServers) {
              contextCallback.onSuccess(
                  new ApplyContext(
                      false,
                      host,
                      runningServers,
                      patchManager.baseAddress(),
                      bootstrapContext.getProperty(BootstrapContext.PATCH_API)));
            }
          });
    }
  }
Beispiel #2
0
  // This method is called via a global method defined in AuthImpl.register()
  @SuppressWarnings("unused")
  void finish(String hash) {
    TokenInfo info = new TokenInfo();
    String error = null;
    String errorDesc = "";
    String errorUri = "";

    // Iterate over keys and values in the string hash value to find relevant
    // information like the access token or an error message. The string will be
    // in the form of: #key1=val1&key2=val2&key3=val3 (etc.)
    int idx = 1;
    while (idx < hash.length() - 1) {
      // Grab the next key (between start and '=')
      int nextEq = hash.indexOf('=', idx);
      if (nextEq < 0) {
        break;
      }
      String key = hash.substring(idx, nextEq);

      // Grab the next value (between '=' and '&')
      int nextAmp = hash.indexOf('&', nextEq);
      nextAmp = nextAmp < 0 ? hash.length() : nextAmp;
      String val = hash.substring(nextEq + 1, nextAmp);

      // Start looking from here from now on.
      idx = nextAmp + 1;

      // Store relevant values to be used later.
      if (key.equals("access_token")) {
        info.accessToken = val;
      } else if (key.equals("expires_in")) {
        // expires_in is seconds, convert to milliseconds and add to now
        Double expiresIn = Double.valueOf(val) * 1000;
        info.expires = String.valueOf(clock.now() + expiresIn);
      } else if (key.equals("error")) {
        error = val;
      } else if (key.equals("error_description")) {
        errorDesc = " (" + val + ")";
      } else if (key.equals("error_uri")) {
        errorUri = "; see: " + val;
      }
    }

    if (error != null) {
      lastCallback.onFailure(
          new RuntimeException("Error from provider: " + error + errorDesc + errorUri));
    } else if (info.accessToken == null) {
      lastCallback.onFailure(new RuntimeException("Could not find access_token in hash " + hash));
    } else {
      setToken(lastRequest, info);
      lastCallback.onSuccess(info.accessToken);
    }
  }
 @Override
 public void start(Callback<Component, Exception> callback) {
   iconRegistry.registerIcon(
       new Icon(
           "default.projecttype.small.icon", "default/project.png", resources.defaultProject()));
   iconRegistry.registerIcon(
       new Icon("default.folder.small.icon", "default/folder.png", resources.defaultFolder()));
   iconRegistry.registerIcon(
       new Icon("default.file.small.icon", "default/file.png", resources.defaultFile()));
   iconRegistry.registerIcon(new Icon("default", "default/default.jpg", resources.defaultIcon()));
   callback.onSuccess(this);
 }
Beispiel #4
0
 private static void handleSuccess(Callback<Position, PositionError> callback, PositionImpl pos) {
   callback.onSuccess(pos);
 }
Beispiel #5
0
 private static void handleFailure(
     Callback<Position, PositionError> callback, int code, String msg) {
   callback.onFailure(new PositionError(code, msg));
 }