/**
   * @see org.gbif.portal.service.DataResourceManager#findDataResources(java.lang.String, boolean,
   *     org.gbif.portal.dto.util.SearchConstraints)
   */
  public Long countDataResources(
      String resourceName,
      boolean fuzzy,
      String providerKey,
      String basisOfRecordCode,
      Date modifiedSince)
      throws ServiceException {
    BasisOfRecord basisOfRecord = null;
    if (basisOfRecordCode != null) {
      basisOfRecord = BasisOfRecord.getBasisOfRecord(basisOfRecordCode);

      if (basisOfRecord == null) {
        throw new ServiceException("No basis of record found for code " + basisOfRecordCode);
      }
    }

    DataProvider dataProvider = null;
    if (providerKey != null) {
      Long dataProviderId = parseKey(providerKey);
      dataProvider = dataProviderDAO.getDataProviderFor(dataProviderId);

      if (dataProvider == null) {
        throw new ServiceException("No DataProvider found for key " + providerKey);
      }
    }

    Long recordCount =
        dataResourceDAO.countDataResources(
            resourceName, fuzzy, dataProvider, basisOfRecord, modifiedSince);
    return recordCount;
  }
  /**
   * @see org.gbif.portal.service.DataResourceManager#findDataResources(java.lang.String, boolean,
   *     org.gbif.portal.dto.util.SearchConstraints)
   */
  public SearchResultsDTO findDataResources(
      String resourceName,
      boolean fuzzy,
      String providerKey,
      String basisOfRecordCode,
      Date modifiedSince,
      SearchConstraints searchConstraints)
      throws ServiceException {
    BasisOfRecord basisOfRecord = null;
    if (basisOfRecordCode != null) {
      basisOfRecord = BasisOfRecord.getBasisOfRecord(basisOfRecordCode);

      if (basisOfRecord == null) {
        throw new ServiceException("No basis of record found for code " + basisOfRecordCode);
      }
    }

    DataProvider dataProvider = null;
    if (providerKey != null) {
      Long dataProviderId = parseKey(providerKey);
      dataProvider = dataProviderDAO.getDataProviderFor(dataProviderId);

      if (dataProvider == null) {
        throw new ServiceException("No DataProvider found for key " + providerKey);
      }
    }

    List<DataResource> resources =
        dataResourceDAO.findDataResources(
            resourceName,
            fuzzy,
            dataProvider,
            basisOfRecord,
            modifiedSince,
            searchConstraints.getStartIndex(),
            searchConstraints.getMaxResults() + 1);
    return dataResourceDTOFactory.createResultsDTO(resources, searchConstraints.getMaxResults());
  }
 /** @see org.gbif.portal.service.DataResourceManager#getNubDataProvider() */
 public DataProviderDTO getNubDataProvider() throws ServiceException {
   DataProvider dataProvider = dataProviderDAO.getDataProviderFor(nubDataProviderId);
   return (DataProviderDTO) dataProviderDTOFactory.createDTO(dataProvider);
 }
 /** @see org.gbif.portal.service.DataResourceManager#getDataProviderFor(java.lang.String) */
 public DataProviderDTO getDataProviderFor(String dataProviderKey) throws ServiceException {
   Long dataProviderId = parseKey(dataProviderKey);
   DataProvider dataProvider = dataProviderDAO.getDataProviderFor(dataProviderId);
   return (DataProviderDTO) dataProviderDTOFactory.createDTO(dataProvider);
 }