Ejemplo n.º 1
0
  /**
   * Update the content panel with the new history
   *
   * @param historyTokens the history tokens
   */
  public void update(final List<String> historyTokens) {
    HistoryResolver foundResolver = null;
    for (final HistoryResolver resolver : resolvers) {
      if (historyTokens.get(0).equals(resolver.getHistoryToken())) {
        currHistoryPath = historyTokens;
        foundResolver = resolver;
        break;
      }
    }

    if (foundResolver != null) {
      update(historyTokens, foundResolver);
    } else {
      HistoryUtils.newHistory(Theme.RESOLVER, "Error404.html");
    }
  }
Ejemplo n.º 2
0
  private void update(final List<String> historyTokens, final HistoryResolver resolver) {
    resolver.isCurrentUserPermitted(
        new AsyncCallback<Boolean>() {

          public void onFailure(Throwable caught) {
            AsyncCallbackUtils.defaultFailureTreatment(caught);
          }

          public void onSuccess(Boolean permitted) {
            if (!permitted.booleanValue()) {
              // UserLogin.getInstance().showSuggestLoginDialog();

              UserLogin.getInstance()
                  .getAuthenticatedUser(
                      new AsyncCallback<User>() {
                        @Override
                        public void onFailure(Throwable caught) {
                          UserLogin.getInstance().showSuggestLoginDialog();
                        }

                        @Override
                        public void onSuccess(User user) {
                          if (user.isGuest()) {
                            UserLogin.getInstance().showSuggestLoginDialog();
                          } else {
                            Dialogs.showInformationDialog(
                                messages.authorizationDeniedAlert(),
                                messages.authorizationDeniedAlertMessageExceptionSimple(),
                                messages.dialogOk(),
                                new AsyncCallback<Void>() {
                                  @Override
                                  public void onFailure(Throwable caught) {
                                    HistoryUtils.newHistory(Welcome.RESOLVER);
                                  }

                                  @Override
                                  public void onSuccess(Void result) {
                                    HistoryUtils.newHistory(Welcome.RESOLVER);
                                  }
                                });
                          }
                        }
                      });
            } else {
              resolver.resolve(
                  HistoryUtils.tail(historyTokens),
                  new AsyncCallback<Widget>() {

                    public void onFailure(Throwable caught) {
                      if (caught instanceof BadHistoryTokenException) {
                        // Dialogs.showInformationDialog(messages.notFoundError(),
                        // messages.pageNotFound(caught.getMessage()),
                        // messages.dialogOk());
                        // if (currWidget == null) {
                        // Tools.newHistory(Welcome.RESOLVER);
                        // }
                        HistoryUtils.newHistory(Theme.RESOLVER, "Error404.html");
                      } else {
                        AsyncCallbackUtils.defaultFailureTreatment(caught);
                      }
                    }

                    public void onSuccess(Widget widget) {
                      if (widget != null) {
                        if (widget != currWidget) {
                          currWidget = widget;
                          setWidget(widget);
                        }
                        setWindowTitle(historyTokens);
                      }
                    }
                  });
            }
          }
        });
  }