コード例 #1
0
  /*
   * This method is currently not called by the RPC framework.  When it is, we can remove the sessionId
   * logic from the GWTServiceLookup class.
   *
   * For background information, please see http://code.google.com/p/google-web-toolkit/issues/detail?id=5668
   */
  @Override
  protected <T> RequestBuilder doPrepareRequestBuilder(
      ResponseReader responseReader,
      String methodName,
      RpcStatsContext statsContext,
      String requestData,
      AsyncCallback<T> callback) {

    RequestBuilder rb =
        super.doPrepareRequestBuilder(
            responseReader, methodName, statsContext, requestData, callback);

    String sessionId = UserSessionManager.getSessionId();
    if (sessionId != null) {
      if (Log.isDebugEnabled()) {
        Log.debug(
            "SessionRpcRequestBuilder is adding sessionId to request for (" + methodName + ")");
      }
      rb.setHeader(UserSessionManager.SESSION_NAME, sessionId);
    } else {
      Log.error("SessionRpcRequestBuilder missing sessionId for request (" + methodName + ")");
    }

    return rb;
  }
コード例 #2
0
  public static Timer startRefreshCycleWithPageRefreshInterval(
      final AutoRefresh autoRefresh, final Canvas autoRefreshCanvas, Timer refreshTimer) {

    final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();

    return startRefreshCycle(
        autoRefresh,
        autoRefreshCanvas,
        refreshTimer,
        refreshInterval,
        (int) MeasurementUtility.MINUTES);
  }
コード例 #3
0
  @Override
  protected <T> Request doInvoke(
      ResponseReader responseReader,
      String methodName,
      RpcStatsContext statsContext,
      String requestData,
      AsyncCallback<T> callback) {

    if (Log.isDebugEnabled()) {
      Log.debug("RPC method invocation: " + methodName);
    }
    if (bypassMethods.contains(methodName) || !UserSessionManager.isLoggedOut()) {
      return super.doInvoke(responseReader, methodName, statsContext, requestData, callback);
    }

    return null;
  }
コード例 #4
0
ファイル: FavoritesButton.java プロジェクト: wburns/rhq
  public void showMenu() {
    setLeft(DOM.getElementById(MenuBarView.BTN_FAV_ID).getAbsoluteLeft());
    final Set<Integer> favoriteResourceIds =
        UserSessionManager.getUserPreferences().getFavoriteResources();
    final Set<Integer> favoriteGroupIds =
        UserSessionManager.getUserPreferences().getFavoriteResourceGroups();
    final List<Integer> recentResourceIds =
        UserSessionManager.getUserPreferences().getRecentResources();
    final List<Integer> recentGroupIds =
        UserSessionManager.getUserPreferences().getRecentResourceGroups();

    // if we have no menu items at all, then show the empty menu now
    if (favoriteGroupIds.isEmpty()
        && favoriteResourceIds.isEmpty()
        && recentResourceIds.isEmpty()
        && recentGroupIds.isEmpty()) {
      favoritesMenu.showNextTo(FavoritesButton.this, "bottom");
      return;
    }

    // keep a list of all the ids we need to pull from the db. combine favs and recents to minimize
    // db round trips.
    Set<Integer> resourceIds = new HashSet<Integer>();
    Set<Integer> groupIds = new HashSet<Integer>();

    resourceIds.addAll(favoriteResourceIds);
    resourceIds.addAll(recentResourceIds);
    groupIds.addAll(favoriteGroupIds);
    groupIds.addAll(recentGroupIds);

    fetchFavorites(
        resourceIds,
        groupIds,
        new AsyncCallback<Favorites>() {

          public void onFailure(Throwable caught) {
            CoreGUI.getErrorHandler().handleError(MSG.view_dashboard_favorites_error1(), caught);
          }

          public void onSuccess(final Favorites favorites) {
            // For Ancestry we need all the resource types and ancestry resource types loaded
            HashSet<Integer> typesSet = new HashSet<Integer>();
            HashSet<String> ancestries = new HashSet<String>();
            for (Resource resource : favorites.resources) {
              typesSet.add(resource.getResourceType().getId());
              ancestries.add(resource.getAncestry());
            }

            // In addition to the types of the result resources, get the types of their ancestry
            typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));

            ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
            typeRepo.getResourceTypes(
                typesSet.toArray(new Integer[typesSet.size()]),
                new TypesLoadedCallback() {
                  @Override
                  public void onTypesLoaded(Map<Integer, ResourceType> types) {
                    // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a
                    // pojo.
                    AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);

                    // generate the menus
                    buildFavoriteResourcesMenu(
                        favorites, favoriteResourcesMenu, favoriteResourceIds, typesWrapper);
                    buildFavoriteGroupsMenu(favorites, favoriteGroupsMenu, favoriteGroupIds);
                    buildRecentlyViewedMenu(
                        favorites,
                        recentlyViewedMenu,
                        recentResourceIds,
                        recentGroupIds,
                        typesWrapper);

                    favoritesMenu.showNextTo(FavoritesButton.this, "bottom");
                  }
                });
          }
        });
  }