001/*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 *     http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014package org.gbif.api.service.collections;
015
016import org.gbif.api.model.collections.Contact;
017
018import java.util.List;
019import java.util.UUID;
020
021import javax.validation.Valid;
022import javax.validation.constraints.NotNull;
023
024/** API Service for the contacts in the collections service. */
025public interface ContactService {
026
027  /**
028   * Lists all the contacts of an entity.
029   *
030   * @param entityKey of the entity
031   * @return list of {@link org.gbif.api.model.collections.Contact}
032   */
033  List<Contact> listContactPersons(@NotNull UUID entityKey);
034
035  /**
036   * Adds a {@link Contact} contact to an entity.
037   *
038   * @param entityKey key of the entity where the contact will be added to.
039   * @param contact key of the contact to add.
040   */
041  int addContactPerson(@NotNull UUID entityKey, @NotNull @Valid Contact contact);
042
043  /**
044   * Updates a {@link Contact} contact in an entity.
045   *
046   * @param entityKey key of the entity where the contact will be updated.
047   * @param contact updated contact.
048   */
049  void updateContactPerson(@NotNull UUID entityKey, @NotNull @Valid Contact contact);
050
051  /**
052   * Removes a {@link Contact} contact from an entity.
053   *
054   * @param entityKey key of the entity where the contact will be removed from.
055   * @param contactKey key of the contact to remove.
056   */
057  void removeContactPerson(@NotNull UUID entityKey, @NotNull int contactKey);
058
059  /**
060   * Removes all the contacts from an entity.
061   *
062   * @param entityKey key of the entity where the contact will be removed from.
063   * @param newContactPersons contact persons that will replace the existing ones.
064   */
065  void replaceContactPersons(@NotNull UUID entityKey, List<@Valid Contact> newContactPersons);
066}