1 /*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for additional
4 * information regarding copyright ownership.
5 *
6 *
7 * The Apereo Foundation licenses this file to you under the Educational
8 * Community License, Version 2.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of the License
10 * at:
11 *
12 * http://opensource.org/licenses/ecl2.txt
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 *
20 */
21
22 package org.opencastproject.list.api;
23
24 import java.util.List;
25 import java.util.Map;
26
27 /**
28 * Service to generate list of key - value from different sources for autocomplete / filetring purpose
29 */
30 public interface ListProvidersService {
31
32 /**
33 * Returns the list for the given provider
34 *
35 * @param providerName
36 * The name of the source
37 * @param query
38 * The query for the list
39 * @return a list of tuple id - value from the given source
40 */
41 Map<String, String> getList(String providerName, ResourceListQuery query, boolean inverseValueKey)
42 throws ListProviderException;
43
44 /**
45 * Defines if keys and values of the given list should be translated in the administrative user interface.
46 *
47 * @param listName the name of the list
48 * @return if the results should be translated
49 *
50 * @throws ListProviderException
51 * if no list provider found for the given list name
52 */
53 boolean isTranslatable(String listName) throws ListProviderException;
54
55 /**
56 * Defines the key of a default value in the given list.
57 *
58 * @param listName the name of the list
59 * @return the key of the default value
60 *
61 * @throws ListProviderException
62 * if no list provider found for the given list name
63 */
64 String getDefault(String listName) throws ListProviderException;
65
66 /**
67 * Adds an source to the service
68 *
69 * @param name
70 * The name of the source
71 * @param provider
72 * The list provider to add
73 */
74 void addProvider(String name, ResourceListProvider provider);
75
76 void addProvider(String name, ResourceListProvider provider, String organizationId);
77
78 /**
79 * Removes the given source
80 *
81 * @param name
82 * The provider to remove
83 */
84 void removeProvider(String name);
85
86 void removeProvider(String name, String organizationId);
87
88 /**
89 * Returns if the given source name is or not available
90 *
91 * @param name
92 * The source to check
93 * @return true if a source with the given name is available in the service
94 */
95 boolean hasProvider(String name);
96
97 boolean hasProvider(String name, String organizationId);
98
99 /**
100 * Returns the resources list providers available
101 *
102 * @return the list of available providers
103 */
104 List<String> getAvailableProviders();
105 }