001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * 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. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018:
019: package org.apache.roller.business;
020:
021: import java.util.Date;
022: import java.util.List;
023: import java.util.Map;
024: import org.apache.roller.RollerException;
025: import org.apache.roller.pojos.WeblogTemplate;
026: import org.apache.roller.pojos.PermissionsData;
027: import org.apache.roller.pojos.UserData;
028: import org.apache.roller.pojos.WebsiteData;
029:
030: /**
031: * Manages users, weblogs, permissions, and weblog pages.
032: */
033: public interface UserManager {
034:
035: /**
036: * Add new user object to Roller. User will be given the global editor role,
037: * unless it's the first user, who will get the global admin role.
038: * @param user User object to be added, initialized with name, password, etc.
039: */
040: public void addUser(UserData newUser) throws RollerException;
041:
042: /**
043: * Store a single user.
044: */
045: public void saveUser(UserData data) throws RollerException;
046:
047: /**
048: * Remove user.
049: */
050: public void removeUser(UserData user) throws RollerException;
051:
052: /**
053: * Get user by id.
054: */
055: public UserData getUser(String id) throws RollerException;
056:
057: /**
058: * Get user object by user name (only enabled users)
059: */
060: public UserData getUserByUserName(String userName)
061: throws RollerException;
062:
063: /**
064: * Get user object by user name, optionally include dis-enabled users
065: */
066: public UserData getUserByUserName(String userName, Boolean enabled)
067: throws RollerException;
068:
069: /**
070: * Get all enabled users
071: */
072: public List getUsers(int offset, int length) throws RollerException;
073:
074: /**
075: * Get all users, optionally include dis-enabled users.
076: * @param enabled True for enabled only, false for disabled only, null for all
077: * @param startDate Restrict to those created after (or null for all)
078: * @param endDate Restrict to those created before (or null for all)
079: */
080: public List getUsers(Boolean enabled, Date startDate, Date endDate,
081: int offset, int length) throws RollerException;
082:
083: /**
084: * Get all users or a website.
085: *
086: * @param website Get all users of this website (or null for all)
087: * @returns List of UserData objects.
088: */
089: public List getUsers(WebsiteData website, Boolean enabled,
090: int offset, int length) throws RollerException;
091:
092: /**
093: * Returns users whose usernames or email addresses start with a string.
094: * @param startsWith String to match userNames and emailAddresses against
095: * @param offset Offset into results (for paging)
096: * @param length Max to return (for paging)
097: * @param enabled True for only enalbed, false for disabled, null for all
098: * @return List of (up to length) users that match startsWith string
099: */
100: public List getUsersStartingWith(String startsWith,
101: Boolean enabled, int offset, int length)
102: throws RollerException;
103:
104: /**
105: * Get map with 26 entries, one for each letter A-Z and
106: * containing integers reflecting the number of users whose
107: * names start with each letter.
108: */
109: public Map getUserNameLetterMap() throws RollerException;
110:
111: /** Get collection of users whose names begin with specified letter */
112: public List getUsersByLetter(char letter, int offset, int length)
113: throws RollerException;
114:
115: /**
116: * Get map with 26 entries, one for each letter A-Z and
117: * containing integers reflecting the number of weblogs whose
118: * names start with each letter.
119: */
120: public Map getWeblogHandleLetterMap() throws RollerException;
121:
122: /** Get collection of weblogs whose handles begin with specified letter */
123: public List getWeblogsByLetter(char letter, int offset, int length)
124: throws RollerException;
125:
126: /**
127: * Add new website, give creator admin permission, creates blogroll,
128: * creates categories and other objects required for new website.
129: * @param newWebsite New website to be created, must have creator.
130: */
131: public void addWebsite(WebsiteData newWebsite)
132: throws RollerException;
133:
134: /**
135: * Store a single weblog.
136: */
137: public void saveWebsite(WebsiteData data) throws RollerException;
138:
139: /**
140: * Remove website object.
141: */
142: public void removeWebsite(WebsiteData website)
143: throws RollerException;
144:
145: /**
146: * Get website object by name.
147: */
148: public WebsiteData getWebsite(String id) throws RollerException;
149:
150: /**
151: * Get website specified by handle (or null if enabled website not found).
152: * @param handle Handle of website
153: */
154: public WebsiteData getWebsiteByHandle(String handle)
155: throws RollerException;
156:
157: /**
158: * Get website specified by handle with option to return only enabled websites.
159: * @param handle Handle of website
160: */
161: public WebsiteData getWebsiteByHandle(String handle, Boolean enabled)
162: throws RollerException;
163:
164: /**
165: * Get websites optionally restricted by user, enabled and active status.
166: * @param user Get all websites for this user (or null for all)
167: * @param offset Offset into results (for paging)
168: * @param len Maximum number of results to return (for paging)
169: * @param enabled Get all with this enabled state (or null or all)
170: * @param active Get all with this active state (or null or all)
171: * @param startDate Restrict to those created after (or null for all)
172: * @param endDate Restrict to those created before (or null for all)
173: * @returns List of WebsiteData objects.
174: */
175: public List getWebsites(UserData user, Boolean enabled,
176: Boolean active, Date startDate, Date endDate, int offset,
177: int length) throws RollerException;
178:
179: /**
180: * Get websites ordered by descending number of comments.
181: * @param startDate Restrict to those created after (or null for all)
182: * @param endDate Restrict to those created before (or null for all)
183: * @param offset Offset into results (for paging)
184: * @param len Maximum number of results to return (for paging)
185: * @returns List of WebsiteData objects.
186: */
187: public List getMostCommentedWebsites(Date startDate, Date endDate,
188: int offset, int length) throws RollerException;
189:
190: /**
191: * Save permissions object.
192: */
193: public void savePermissions(PermissionsData perms)
194: throws RollerException;
195:
196: /**
197: * Remove permissions object.
198: */
199: public void removePermissions(PermissionsData perms)
200: throws RollerException;
201:
202: /**
203: * Get permissions object by id.
204: */
205: public PermissionsData getPermissions(String id)
206: throws RollerException;
207:
208: /**
209: * Get pending permissions for user.
210: * @param user User (not null)
211: * @returns List of PermissionsData objects.
212: */
213: public List getPendingPermissions(UserData user)
214: throws RollerException;
215:
216: /**
217: * Get pending permissions for website.
218: * @param website Website (not null)
219: * @returns List of PermissionsData objects.
220: */
221: public List getPendingPermissions(WebsiteData user)
222: throws RollerException;
223:
224: /**
225: * Get permissions of user in website.
226: * @param website Website (not null)
227: * @param user User (not null)
228: * @return PermissionsData object
229: */
230: public PermissionsData getPermissions(WebsiteData website,
231: UserData user) throws RollerException;
232:
233: /**
234: * Get all permissions in website
235: * @param website Website (not null)
236: * @return PermissionsData object
237: */
238: public List getAllPermissions(WebsiteData website)
239: throws RollerException;
240:
241: /**
242: * Get all permissions of user
243: * @param user User (not null)
244: * @return PermissionsData object
245: */
246: public List getAllPermissions(UserData user) throws RollerException;
247:
248: /**
249: * Invite user to join a website with specific permissions
250: * @param website Website to be joined (persistent instance)
251: * @param user User to be invited (persistent instance)
252: * @param perms Permissions mask (see statics in PermissionsData)
253: * @return New PermissionsData object, with pending=true
254: */
255: public PermissionsData inviteUser(WebsiteData website,
256: UserData user, short perms) throws RollerException;
257:
258: /**
259: * Retire user from a website
260: * @param website Website to be retired from (persistent instance)
261: * @param user User to be retired (persistent instance)
262: */
263: public void retireUser(WebsiteData website, UserData user)
264: throws RollerException;
265:
266: /**
267: * Store page.
268: */
269: public void savePage(WeblogTemplate data) throws RollerException;
270:
271: /**
272: * Remove page.
273: */
274: public void removePage(WeblogTemplate page) throws RollerException;
275:
276: /**
277: * Get page by id.
278: */
279: public WeblogTemplate getPage(String id) throws RollerException;
280:
281: /**
282: * Get user's page by name.
283: */
284: public WeblogTemplate getPageByName(WebsiteData w, String p)
285: throws RollerException;
286:
287: /**
288: * Get website's page by link.
289: */
290: public WeblogTemplate getPageByLink(WebsiteData w, String p)
291: throws RollerException;
292:
293: /**
294: * Get website's pages
295: */
296: public List getPages(WebsiteData w) throws RollerException;
297:
298: /**
299: * Release any resources held by manager.
300: */
301: public void release();
302:
303: }
|