/**
   * Get the user guid from a given id record and id entry. <br>
   * Return an empty string if the entry is not an EntryTypeMyLuteceUser nor
   * EntryTypeRemoteMyLuteceUser
   *
   * @param nIdRecord the id record
   * @param nIdEntry the id entry
   * @return the user GUID
   */
  public String getUserGuid(int nIdRecord, int nIdEntry) {
    String strUserGuid = StringUtils.EMPTY;
    Plugin plugin = PluginService.getPlugin(DirectoryPlugin.PLUGIN_NAME);
    IEntry entry = EntryHome.findByPrimaryKey(nIdEntry, plugin);

    if ((entry != null) && (entry.getEntryType() != null)) {
      if (((entry.getEntryType().getIdType()
                  == AppPropertiesService.getPropertyInt(
                      PROPERTY_ENTRY_TYPE_REMOTE_MYLUTECE_USER, 21))
              && DirectoryUserAttributesManager.getManager().isEnabled())
          || (entry.getEntryType().getIdType()
              == AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_MYLUTECE_USER, 19))) {
        RecordFieldFilter recordFieldFilter = new RecordFieldFilter();
        recordFieldFilter.setIdRecord(nIdRecord);
        recordFieldFilter.setIdEntry(nIdEntry);

        List<RecordField> listRecordFields =
            DirectoryService.getInstance().getRecordFieldByFilter(recordFieldFilter);

        if ((listRecordFields != null)
            && !listRecordFields.isEmpty()
            && (listRecordFields.get(0) != null)) {
          strUserGuid = listRecordFields.get(0).getValue();
        }
      }
    }

    return strUserGuid;
  }
  /**
   * Get the user infos from a given id record and id entry. <br>
   * The retrieval of the user infos depends on the entry type : <br>
   *
   * <ul>
   *   <li>If it is an {@link EntryTypeMyLuteceUser}, then it will use the {@link SecurityService}
   *       API
   *   <li>If it is an {@link EntryTypeRemoteMyLuteceUser}, then it will use the {@link
   *       UserAttributesService} API
   * </ul>
   *
   * @param strUserGuid the user guid
   * @param nIdEntry the id entry
   * @return a {@link ReferenceList}
   */
  public ReferenceList getUserInfos(String strUserGuid, int nIdEntry) {
    ReferenceList userInfos = null;

    if (StringUtils.isNotBlank(strUserGuid)) {
      Plugin plugin = PluginService.getPlugin(DirectoryPlugin.PLUGIN_NAME);
      IEntry entry = EntryHome.findByPrimaryKey(nIdEntry, plugin);

      if ((entry != null) && (entry.getEntryType() != null)) {
        if ((entry.getEntryType().getIdType()
                == AppPropertiesService.getPropertyInt(
                    PROPERTY_ENTRY_TYPE_REMOTE_MYLUTECE_USER, 21))
            && DirectoryUserAttributesManager.getManager().isEnabled()) {
          userInfos =
              DirectoryUtils.convertMapToReferenceList(
                  DirectoryUserAttributesManager.getManager().getAttributes(strUserGuid));
        } else if (entry.getEntryType().getIdType()
            == AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_MYLUTECE_USER, 19)) {
          LuteceUser user = SecurityService.getInstance().getUser(strUserGuid);

          if (user != null) {
            userInfos = DirectoryUtils.convertMapToReferenceList(user.getUserInfos());
          }
        }
      }
    }

    return userInfos;
  }