@Override
  public FriendlyURL saveStagedModel(FriendlyURL friendlyURL) throws PortalException {

    if (friendlyURL.isMain()) {
      FriendlyURL mainFriendlyURL =
          _friendlyURLLocalService.getMainFriendlyURL(
              friendlyURL.getCompanyId(), friendlyURL.getGroupId(),
              friendlyURL.getClassNameId(), friendlyURL.getClassPK());

      if (!mainFriendlyURL.equals(friendlyURL)) {
        mainFriendlyURL.setMain(false);

        _friendlyURLLocalService.updateFriendlyURL(mainFriendlyURL);
      }
    }

    friendlyURL.setUrlTitle(
        _friendlyURLLocalService.getUniqueUrlTitle(
            friendlyURL.getCompanyId(),
            friendlyURL.getGroupId(),
            friendlyURL.getClassNameId(),
            friendlyURL.getClassPK(),
            friendlyURL.getUrlTitle()));

    return _friendlyURLLocalService.updateFriendlyURL(friendlyURL);
  }
  @Override
  public void deleteStagedModel(FriendlyURL friendlyURL) throws PortalException {

    _friendlyURLLocalService.deleteFriendlyURL(
        friendlyURL.getCompanyId(),
        friendlyURL.getGroupId(),
        friendlyURL.getClassNameId(),
        friendlyURL.getClassPK(),
        friendlyURL.getUrlTitle());
  }
  @Override
  public FriendlyURL addStagedModel(PortletDataContext portletDataContext, FriendlyURL friendlyURL)
      throws PortalException {

    return _friendlyURLLocalService.addFriendlyURL(
        friendlyURL.getCompanyId(),
        friendlyURL.getGroupId(),
        friendlyURL.getClassNameId(),
        friendlyURL.getClassPK(),
        friendlyURL.getUrlTitle());
  }