001/*
002 * Copyright 2020 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.api.service.registry;
017
018import org.gbif.api.model.common.paging.Pageable;
019import org.gbif.api.model.common.paging.PagingResponse;
020import org.gbif.api.model.registry.Dataset;
021import org.gbif.api.model.registry.Installation;
022import org.gbif.api.model.registry.Organization;
023import org.gbif.api.model.registry.search.KeyTitleResult;
024import org.gbif.api.model.registry.search.OrganizationRequestSearchParams;
025import org.gbif.api.vocabulary.Country;
026
027import java.util.List;
028import java.util.UUID;
029
030import javax.annotation.Nullable;
031import javax.validation.constraints.NotNull;
032
033@SuppressWarnings("unused")
034public interface OrganizationService extends NetworkEntityService<Organization> {
035
036  /**
037   * Provides paging service to list datasets hosted by, but not owned by, a specific organization.
038   */
039  PagingResponse<Dataset> hostedDatasets(@NotNull UUID organizationKey, @Nullable Pageable page);
040
041  /** Provides paging service to list datasets published by a specific organization. */
042  PagingResponse<Dataset> publishedDatasets(@NotNull UUID organizationKey, @Nullable Pageable page);
043
044  /** Provides paging service to list installations for the organization. */
045  PagingResponse<Installation> installations(
046      @NotNull UUID organizationKey, @Nullable Pageable page);
047
048  /** Provides access to all organizations from a country. */
049  PagingResponse<Organization> listByCountry(Country country, @Nullable Pageable page);
050
051  /** Provides access to deleted organizations. */
052  PagingResponse<Organization> listDeleted(OrganizationRequestSearchParams searchParams);
053
054  /** Provides access to organizations that are awaiting their endorsement approval. */
055  PagingResponse<Organization> listPendingEndorsement(@Nullable Pageable page);
056
057  /** Provides access to organizations that are not publishing (e.g. owning) any datasets. */
058  PagingResponse<Organization> listNonPublishing(@Nullable Pageable page);
059
060  /** Provides a simple suggest service. */
061  List<KeyTitleResult> suggest(@Nullable String q);
062
063  /**
064   * Confirm the endorsement of a new {@link Organization} by providing a confirmationKey.
065   * Confirming the endorsement of an {@link Organization} may not be required or possible depending
066   * how the {@link Organization} was created.
067   *
068   * @param organizationKey key of the organization
069   * @param confirmationKey (aka challenge code)
070   * @return endorsement was confirmed using the provided keys
071   */
072  boolean confirmEndorsement(@NotNull UUID organizationKey, @NotNull UUID confirmationKey);
073
074  /**
075   * Confirm the endorsement of a new {@link Organization} without a confirmationKey. Confirming the
076   * endorsement of an {@link Organization} may not be required or possible depending how the {@link
077   * Organization} was created.
078   *
079   * @param organizationKey key of the organization
080   * @return endorsement was confirmed using the provided keys
081   */
082  boolean confirmEndorsement(@NotNull UUID organizationKey);
083
084  /**
085   * Revoke the endorsement of the {@link Organization}.
086   *
087   * @param organizationKey key of the organization
088   * @return endorsement was confirmed using the provided keys
089   */
090  boolean revokeEndorsement(@NotNull UUID organizationKey);
091
092  /**
093   * Provides paging service to list organizations that can be filtered by multiple parameters.
094   *
095   * @param searchParams {@link OrganizationRequestSearchParams}
096   * @return list of organizations ordered by creation date with the latest coming first
097   */
098  PagingResponse<Organization> list(OrganizationRequestSearchParams searchParams);
099}