View Javadoc
1   /******************************************************************************
2    * BuckoVidLib.java - Primary business object interface
3    * $Id: BuckoVidLib.java,v 1.28 2015/05/14 03:00:03 dick Exp $
4    * 
5    * BuckoVidLib - The BuckoSoft Video Library
6    * Copyright(c) 2014 - Dick Balaska
7    * 
8    * $Log: BuckoVidLib.java,v $
9    * Revision 1.28  2015/05/14 03:00:03  dick
10   * getPlexUrl is a property to be read, not hardcoded in.
11   *
12   * Revision 1.27  2015/05/11 01:57:54  dick
13   * /statistics wants a session so we don't count restricted movies.
14   *
15   * Revision 1.26  2015/05/08 02:37:14  dick
16   * findVideosAndThings(key, max) returns videos, actors, directors, and writers
17   *
18   * Revision 1.25  2015/05/07 00:15:38  dick
19   * findMaxResults is a user config option.
20   *
21   * Revision 1.24  2015/05/06 17:04:09  dick
22   * Add findVideos().
23   * Remove unused unprotected video lookups.
24   *
25   * Revision 1.23  2015/05/06 03:36:53  dick
26   * hideRestricted allows a user with restricted access to temporarily turn it off.
27   *
28   * Revision 1.22  2015/05/05 04:26:00  dick
29   * Persist backgroundDelay and artShowDelay.
30   *
31   * Revision 1.21  2015/05/04 20:36:09  dick
32   * getBackgroundFit() needs to know if we are running the ArtShow, which may be different
33   * than the normal backgroundFit.
34   *
35   * Revision 1.20  2015/05/03 18:02:10  dick
36   * Add UserAttributes and backgroundFit handling.
37   *
38   * Revision 1.19  2015/05/01 12:46:11  dick
39   * Implement a thread to dynamically update the database from plex.
40   *
41   * Revision 1.18  2015/04/30 06:34:27  dick
42   * Getting lists of VideoBase is always protected by session.
43   *
44   * Revision 1.17  2015/04/30 03:18:04  dick
45   * Deal mostly with VideoBase. Only fetch full Video when we really need it.
46   * Protect all (most) calls to the restricted section of the library by session.
47   *
48   * Revision 1.16  2015/04/27 14:59:12  dick
49   * Support having restricted LibrarySections that you must have access to get to.
50   *
51   * Revision 1.15  2015/04/01 02:39:09  dick
52   * getDirectorVideos(key)
53   * stub getActorVideos and getWriterVideos.
54   * Build the video mappings of directors and genres so hibernate figures them out.
55   *
56   * Revision 1.14  2015/03/29 04:05:02  dick
57   * Improve statistics.
58   *
59   * Revision 1.13  2015/03/25 06:13:52  dick
60   * Keys are ints, not Strings.
61   *
62   * Revision 1.12  2015/03/21 09:21:12  dick
63   * getLibraryListVideos(key) returns one LibrarySection's videos.
64   *
65   * Revision 1.11  2014/11/01 08:05:05  dick
66   * Count TV episodes.
67   *
68   * Revision 1.10  2014/10/26 05:36:57  dick
69   * recentlyAdded status can display 2 videos.
70   *
71   * Revision 1.9  2014/10/23 05:00:10  dick
72   * WishList handling.
73   *
74   * Revision 1.8  2014/10/20 01:25:29  dick
75   * getRecentlyAdded().
76   *
77   * Revision 1.7  2014/10/17 08:11:19  dick
78   * Add the database and getFailedToRip().
79   *
80   * Revision 1.6  2014/10/09 08:34:35  dick
81   * Use the Video as a key for the client, not just the image url.
82   *
83   * Revision 1.5  2014/10/08 04:25:44  dick
84   * Load the entire library and implement fetching an image.
85   *
86   * Revision 1.4  2014/10/07 02:28:05  dick
87   * Implement getSectionList().
88   *
89   * Revision 1.3  2014/10/06 08:09:45  dick
90   * Still skeleton object, really an interface.
91   */
92  package com.buckosoft.BuckoVidLib.business;
93  
94  import java.util.List;
95  
96  import javax.servlet.http.HttpServletRequest;
97  
98  import com.buckosoft.BuckoVidLib.domain.FailedToRip;
99  import com.buckosoft.BuckoVidLib.domain.LibrarySection;
100 import com.buckosoft.BuckoVidLib.domain.TVSeason;
101 import com.buckosoft.BuckoVidLib.domain.UserAttribute;
102 import com.buckosoft.BuckoVidLib.domain.Video;
103 import com.buckosoft.BuckoVidLib.domain.VideoBase;
104 import com.buckosoft.BuckoVidLib.domain.WishList;
105 import com.buckosoft.BuckoVidLib.domain.rest.RestVideo;
106 import com.buckosoft.BuckoVidLib.domain.rest.admin.RestRefreshStatus;
107 
108 /** Primary business object interface. <br>
109  * In the BuckoVidLib world, key always refers to the hashKey of an item, which is an int usually represented as a base36 string
110  * @author dick
111  * @since 2014-10-06
112  */
113 public interface BuckoVidLib {
114 	
115 	List<LibrarySection>	getSectionList();
116 	List<LibrarySection>	getSectionList(boolean allowRestricted);
117 	RestVideo				getRandomMovie(boolean allowRestricted);
118 	Video					getVideoFromKey(int key, boolean allowRestricted);
119 	VideoBase				getVideoBaseFromKey(int key, boolean allowRestricted);
120 	List<FailedToRip>		getFailedToRip();
121 	List<WishList>			getWishList();
122 	List<VideoBase>			getRecentlyAdded(int count, boolean allowRestricted);
123 	List<VideoBase>			getLibraryListVideos(int key);
124 	List<VideoBase>			getDirectorVideos(int key);
125 	List<VideoBase>			getWriterVideos(int key);
126 	List<VideoBase>			getActorVideos(int key);
127 	List<RestVideo>			findVideosAndThings(String key, boolean allowRestricted, int maxReturned);
128 	
129 	TVSeason				getTVSeasonFromHashKey(int key);
130 	long					getLastUpdateTime();
131 	
132 	int						getMovieCount(boolean allowRestricted);
133 	int						getTVShowCount(boolean allowRestricted);
134 	int						getTVEpisodeCount(boolean allowRestricted);
135 
136 	List<UserAttribute>		getUserAttributes(int userId);
137 	void					saveUserAttributes(List<UserAttribute> list);
138 	
139 	/** Is this user allowed access to the restricted sections, and does he want to see them?
140 	 * @param request The request containing the session containing the User
141 	 * @return true if he has access and desire.
142 	 */
143 	boolean isAllowRestricted(HttpServletRequest request);
144 
145 	boolean isHideRestricted(HttpServletRequest request);
146 	void	setHideRestricted(HttpServletRequest request, boolean hideRestricted);
147 
148 	/** Is this user an Admin?
149 	 * @param request The request containing the session containing the User
150 	 * @return true if he is an Admin.
151 	 */
152 	boolean isAdmin(HttpServletRequest request);
153 
154 	/** Get the background fit style.
155 	 * @param request The request containing the session containing the User
156 	 * @param artShow Maybe we are running the ArtShow and want the override. Grey background needs a real style for the ArtShow.
157 	 * @return
158 	 */
159 	int		getBackgroundFit(HttpServletRequest request, boolean artShow);
160 	void	setBackgroundFit(HttpServletRequest request, int backgroundFit);
161 
162 	
163 	void	setBackgroundDelays(HttpServletRequest request, int backgroundDelay, int artShowDelay);
164 
165 	int		getFindMaxResults(HttpServletRequest request);
166 	void	setFindMaxResults(HttpServletRequest request, int findMaxResults);
167 
168 	void startRefreshLibraryFromPlex();
169 	RestRefreshStatus getRefreshLibraryFromPlexStatus();
170 	
171 	/** Get the base url for our plex server from the properties file.
172 	 * @return http://lamp/plex
173 	 */
174 	String	getPlexUrl();
175 	
176 }