Ejemplo n.º 1
0
  private Map<AlertType, String> checkPermissions(CurrentUser currentUser) {
    Map<AlertType, String> alMap = new HashMap<>();

    boolean canViewAllContent =
        currentUser.hasPermissions(PermissionName.STORIES_CAN_VIEW_ALL_CONTENT.name());

    boolean canViewStories =
        currentUser.hasPermissions(PermissionName.STORIES_CAN_VIEW_STORIES.name());

    boolean canViewBranchContent =
        currentUser.hasPermissions(PermissionName.STORIES_CAN_VIEW_BRANCH_CONTENT.name());

    boolean canCreateContent =
        currentUser.hasPermissions(PermissionName.STORIES_CAN_CREATE_CONTENT.name());

    if (canViewAllContent) {

      if (!canCreateContent && !getSearchFilter().isEmpty()) {
        alMap.put(AlertType.WARNING, "You dont have permissions to create a new story.");

        return alMap;
      }

      if (!getSearchFilter().isEmpty()) {
        alMap.put(AlertType.INFO, "You are viewing filtered content.");

        return alMap;
      }

      return alMap;
    }

    if (canViewBranchContent) {
      alMap.put(
          AlertType.WARNING,
          "Sorry !, you have limited permissions and can only view contents "
              + "belonging to your branch.");

      return alMap;
    }

    if (!canViewStories && !canCreateContent) {
      alMap.put(
          AlertType.WARNING,
          "Sorry !, you have no permissions to create a story or view this content.");

      return alMap;
    } else if (canViewStories && !canCreateContent) {
      alMap.put(
          AlertType.INFO,
          "Sorry ! , you dont have permissions to create or add a new story/news article");

      return alMap;
    }

    alMap.put(AlertType.WARNING, "Sorry !, you have no permissions to access these content.");

    return alMap;
  }
Ejemplo n.º 2
0
  @Override
  protected void onAttach() {
    super.onAttach();
    Element label = chkMineOnly.getElement().getElementsByTagName("label").getItem(0);
    label.getStyle().setTop(14, Unit.PX);

    canCreateStory = hasPermission(PermissionName.STORIES_CAN_CREATE_CONTENT.name());
    panelLoadStories.clear();
    if (!canCreateStory) {
      panelCreateStory.addStyleName("hide");
    }
  }