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 package org.opencastproject.playlists.persistence;
22
23 import org.opencastproject.playlists.Playlist;
24 import org.opencastproject.util.NotFoundException;
25 import org.opencastproject.util.requests.SortCriterion;
26
27 import java.util.Date;
28 import java.util.List;
29
30 /**
31 * API that defines persistent storage of playlists
32 */
33 public interface PlaylistDatabaseService {
34
35 /**
36 * Gets a single playlist in the current organization context by its identifier.
37 * @param playlistId the playlist identifier
38 * @return the {@link Playlist} with the given identifier
39 * @throws NotFoundException if there is no playlist with this identifier
40 * @throws PlaylistDatabaseException if there is a problem communicating with the underlying data store
41 */
42 Playlist getPlaylist(String playlistId) throws NotFoundException, PlaylistDatabaseException;
43
44 /**
45 * Gets a single playlist by its identifier.
46 * @param playlistId the playlist identifier
47 * @param orgId the organisation identifier
48 * @return the {@link Playlist} with the given identifier
49 * @throws NotFoundException if there is no playlist with this identifier
50 * @throws PlaylistDatabaseException if there is a problem communicating with the underlying data store
51 */
52 Playlist getPlaylist(String playlistId, String orgId) throws NotFoundException, PlaylistDatabaseException;
53
54 /**
55 * Get several playlists based on their order in the database
56 * @param limit Maximum amount of playlists to return
57 * @param offset The index of the first result to return
58 * @return a list of {@link Playlist}s
59 * @throws PlaylistDatabaseException if there is a problem communicating with the underlying data store
60 */
61 List<Playlist> getPlaylists(int limit, int offset, SortCriterion sortCriterion)
62 throws PlaylistDatabaseException;
63
64 List<Playlist> getAllForAdministrativeRead(Date from, Date endDate, int limit)
65 throws PlaylistDatabaseException;
66
67 /**
68 * Creates or updates a single playlist.
69 * @param playlist The {@link Playlist}
70 * @return The updated {@link Playlist}
71 * @throws PlaylistDatabaseException if there is a problem communicating with the underlying data store
72 */
73 Playlist updatePlaylist(Playlist playlist, String orgId) throws PlaylistDatabaseException;
74
75 /**
76 * Removes a single playlist.
77 * @param playlist The {@link Playlist}
78 * @return The deleted {@link Playlist}
79 * @throws PlaylistDatabaseException if there is a problem communicating with the underlying data store
80 */
81 Playlist deletePlaylist(Playlist playlist, String orgId) throws PlaylistDatabaseException;
82 }