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.registry.Contact;
019
020import java.util.List;
021import java.util.UUID;
022
023import javax.validation.Valid;
024import javax.validation.constraints.NotNull;
025
026/**
027 * Service provides a set of operations on {@link Contact}.
028 */
029@SuppressWarnings("unused")
030public interface ContactService {
031
032  /**
033   * Add a new Contact to a target entity.
034   *
035   * @param targetEntityKey key of target entity
036   * @param contact         Contact to add
037   *
038   * @return key of Contact added
039   */
040  int addContact(@NotNull UUID targetEntityKey, @NotNull @Valid Contact contact);
041
042  /**
043   * Delete an existing Contact from a target entity by contact key.
044   *
045   * @param targetEntityKey key of target entity
046   * @param contactKey      Contact key to delete
047   */
048  void deleteContact(@NotNull UUID targetEntityKey, int contactKey);
049
050  /**
051   * List all contacts of a target entity.
052   *
053   * @param targetEntityKey key of target entity
054   *
055   * @return list of contacts that belong to the entity
056   */
057  List<Contact> listContacts(@NotNull UUID targetEntityKey);
058
059  /**
060   * Updates the given contact for the target entity.
061   *
062   * @param targetEntityKey Which must be the the owner of the contact or else an exception will be thrown.
063   * @param contact To update
064   */
065  void updateContact(@NotNull UUID targetEntityKey, @NotNull @Valid Contact contact);
066}