private void updatePortalPage(final PortalPage portalPage, final DashboardState dashboardState) {
   // update the portalPageStore's title and layout if they changed.
   if (!portalPage.getLayout().equals(dashboardState.getLayout())
       || !StringUtils.equals(portalPage.getName(), dashboardState.getTitle())) {
     final PortalPage.Builder builder = PortalPage.portalPage(portalPage);
     builder.name(dashboardState.getTitle());
     builder.layout(dashboardState.getLayout());
     portalPageStore.update(builder.build());
   }
 }
  /**
   * Get the number of people who have added the dashboard as a favourite. Used to warn against
   * deleting.
   *
   * @return the number of users (not including owner) that has favourited the dashboard.
   */
  public int getOtherFavouriteCount() {
    if (otherFavouriteCount == null) {
      final PortalPage page = getPortalPage();

      // We want to know how many times it has been favourited by OTHER people
      final boolean isFavourite = favouritesService.isFavourite(getRemoteUser(), page);
      final int count =
          isFavourite
              ? page.getFavouriteCount().intValue() - 1
              : page.getFavouriteCount().intValue();
      otherFavouriteCount = new Long(count);
    }
    return otherFavouriteCount.intValue();
  }
  public int getOtherFavouriteCount() {
    if (otherFavouriteCount == null) {
      final PortalPage dashboard = getDashboard();

      // We want to know how many times it has been favourited by OTHER people
      User dashboardOwner = UserUtils.getUser(dashboard.getOwnerUserName());
      final boolean isFavourite = favouriteService.isFavourite(dashboardOwner, dashboard);
      final int count =
          isFavourite
              ? dashboard.getFavouriteCount().intValue() - 1
              : dashboard.getFavouriteCount().intValue();
      otherFavouriteCount = (long) count;
    }
    return otherFavouriteCount.intValue();
  }
 public String getPageName(final PortalPage portalPage) {
   if (portalPage != null) {
     return portalPage.getName();
   } else {
     return null;
   }
 }
  @Override
  public String doDefault() throws Exception {
    if (!isDashboardPluginEnabled()) {
      String link = getAdministratorContactLink();
      addErrorMessage(getText("admin.errors.portalpages.plugin.disabled", link));
      return ERROR;
    }

    final PortalPage defaultPortalPage = portalPageService.getSystemDefaultPortalPage();
    if (defaultPortalPage == null) {
      return ERROR;
    }
    defaultPortalPageId = defaultPortalPage.getId();

    if (!permissionService.isWritableBy(
        DashboardId.valueOf(defaultPortalPageId.toString()), getUsername())) {
      return ERROR;
    }
    return SUCCESS;
  }
 public String getPageName() {
   final PortalPage page = getPortalPage();
   return page != null ? page.getName() : null;
 }