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.themes;
23
24 import org.opencastproject.themes.persistence.ThemesServiceDatabaseException;
25 import org.opencastproject.util.NotFoundException;
26 import org.opencastproject.util.requests.SortCriterion;
27
28 import java.util.ArrayList;
29 import java.util.List;
30 import java.util.Optional;
31
32 /**
33 * API that defines persistent storage of themes.
34 */
35 public interface ThemesServiceDatabase {
36
37 /**
38 * Return the theme by the unique given id.
39 *
40 * @param id
41 * The unique id of the theme.
42 * @return A {@link Theme} that matches the id.
43 * @throws NotFoundException
44 * if the theme could not be found
45 * @throws ThemesServiceDatabaseException
46 * if there is a problem communicating with the underlying data store
47 */
48 Theme getTheme(long id) throws ThemesServiceDatabaseException, NotFoundException;
49
50 /**
51 * Return themes that match the query parameters
52 *
53 * @param limit
54 * Maximum amount of themes to return (optional)
55 * @param offset
56 * The offset to read data from (optional)
57 * @param sortCriteria
58 * How the resulting list should be sorted
59 * @param creatorFilter
60 * filter by creator name (optional)
61 * @param textFilter
62 * fulltext filter (optional)
63 * @return A {@link List} of {@link Theme} that match the query parameters
64 */
65 List<Theme> findThemes(
66 Optional<Integer> limit,
67 Optional<Integer> offset,
68 ArrayList<SortCriterion> sortCriteria,
69 Optional<String> creatorFilter,
70 Optional<String> textFilter
71 );
72
73 /**
74 * Crate or update a theme.
75 *
76 * @param theme
77 * The theme to create or update.
78 * @return The updated {@link Theme}.
79 * @throws ThemesServiceDatabaseException
80 * if there is a problem communicating with the underlying data store
81 */
82 Theme updateTheme(Theme theme) throws ThemesServiceDatabaseException;
83
84 /**
85 * Delete a theme by using a unique id to find it.
86 *
87 * @param id
88 * The unique id of the theme.
89 * @throws ThemesServiceDatabaseException
90 * if there is a problem communicating with the underlying data store
91 */
92 void deleteTheme(long id) throws ThemesServiceDatabaseException, NotFoundException;
93
94 /**
95 * @return Count the total number of themes.
96 *
97 * @throws ThemesServiceDatabaseException
98 * if there is a problem communicating with the underlying data store
99 */
100 int countThemes() throws ThemesServiceDatabaseException;
101
102 }