Source Code Cross Referenced for UserPermissionManagerImpl.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » component » app » messageforums » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.sakaiproject.component.app.messageforums 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/msgcntr/trunk/messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/UserPermissionManagerImpl.java $
003:         * $Id: UserPermissionManagerImpl.java 9227 2006-05-15 15:02:42Z cwen@iupui.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.component.app.messageforums;
021:
022:        import org.apache.commons.logging.Log;
023:        import org.apache.commons.logging.LogFactory;
024:        import org.sakaiproject.api.app.messageforums.Area;
025:        import org.sakaiproject.api.app.messageforums.AreaControlPermission;
026:        import org.sakaiproject.api.app.messageforums.BaseForum;
027:        import org.sakaiproject.api.app.messageforums.ForumControlPermission;
028:        import org.sakaiproject.api.app.messageforums.MessagePermissions;
029:        import org.sakaiproject.api.app.messageforums.PermissionManager;
030:        import org.sakaiproject.api.app.messageforums.Topic;
031:        import org.sakaiproject.api.app.messageforums.TopicControlPermission;
032:        import org.sakaiproject.api.app.messageforums.UserPermissionManager;
033:        import org.sakaiproject.id.api.IdManager;
034:        import org.sakaiproject.tool.api.SessionManager;
035:        import org.sakaiproject.tool.api.Placement;
036:        import org.sakaiproject.tool.cover.ToolManager;
037:        import org.sakaiproject.authz.cover.AuthzGroupService;
038:        import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
039:
040:        public class UserPermissionManagerImpl extends HibernateDaoSupport
041:                implements  UserPermissionManager {
042:
043:            private IdManager idManager;
044:
045:            private SessionManager sessionManager;
046:
047:            private PermissionManager permissionManager;
048:
049:            private static final Log LOG = LogFactory
050:                    .getLog(UserPermissionManagerImpl.class);
051:
052:            public void init() {
053:                LOG.info("init()");
054:                ;
055:            }
056:
057:            public PermissionManager getPermissionManager() {
058:                return permissionManager;
059:            }
060:
061:            public void setPermissionManager(PermissionManager permissionManager) {
062:                this .permissionManager = permissionManager;
063:            }
064:
065:            public void setSessionManager(SessionManager sessionManager) {
066:                this .sessionManager = sessionManager;
067:            }
068:
069:            public IdManager getIdManager() {
070:                return idManager;
071:            }
072:
073:            public SessionManager getSessionManager() {
074:                return sessionManager;
075:            }
076:
077:            public void setIdManager(IdManager idManager) {
078:                this .idManager = idManager;
079:            }
080:
081:            // ------------------ MESSAGE PERMISSIONS
082:
083:            public boolean canRead(Topic topic, String typeId) {
084:                MessagePermissions permission = permissionManager
085:                        .getTopicMessagePermissionForRole(topic,
086:                                getCurrentUserRole(), typeId);
087:                return permission == null ? false : permission.getRead()
088:                        .booleanValue();
089:            }
090:
091:            public boolean canReviseAny(Topic topic, String typeId) {
092:                MessagePermissions permission = permissionManager
093:                        .getTopicMessagePermissionForRole(topic,
094:                                getCurrentUserRole(), typeId);
095:                return permission == null ? false : permission.getReviseAny()
096:                        .booleanValue();
097:            }
098:
099:            public boolean canReviseOwn(Topic topic, String typeId) {
100:                MessagePermissions permission = permissionManager
101:                        .getTopicMessagePermissionForRole(topic,
102:                                getCurrentUserRole(), typeId);
103:                return permission == null ? false : permission.getReviseOwn()
104:                        .booleanValue();
105:            }
106:
107:            public boolean canDeleteAny(Topic topic, String typeId) {
108:                MessagePermissions permission = permissionManager
109:                        .getTopicMessagePermissionForRole(topic,
110:                                getCurrentUserRole(), typeId);
111:                return permission == null ? false : permission.getDeleteAny()
112:                        .booleanValue();
113:            }
114:
115:            public boolean canDeleteOwn(Topic topic, String typeId) {
116:                MessagePermissions permission = permissionManager
117:                        .getTopicMessagePermissionForRole(topic,
118:                                getCurrentUserRole(), typeId);
119:                return permission == null ? false : permission.getDeleteOwn()
120:                        .booleanValue();
121:            }
122:
123:            public boolean canMarkAsRead(Topic topic, String typeId) {
124:                MessagePermissions permission = permissionManager
125:                        .getTopicMessagePermissionForRole(topic,
126:                                getCurrentUserRole(), typeId);
127:                return permission == null ? false : permission.getMarkAsRead()
128:                        .booleanValue();
129:            }
130:
131:            public boolean canRead(BaseForum forum, String typeId) {
132:                MessagePermissions permission = permissionManager
133:                        .getForumMessagePermissionForRole(forum,
134:                                getCurrentUserRole(), typeId);
135:                return permission == null ? false : permission.getRead()
136:                        .booleanValue();
137:            }
138:
139:            public boolean canReviseAny(BaseForum forum, String typeId) {
140:                MessagePermissions permission = permissionManager
141:                        .getForumMessagePermissionForRole(forum,
142:                                getCurrentUserRole(), typeId);
143:                return permission == null ? false : permission.getReviseAny()
144:                        .booleanValue();
145:            }
146:
147:            public boolean canReviseOwn(BaseForum forum, String typeId) {
148:                MessagePermissions permission = permissionManager
149:                        .getForumMessagePermissionForRole(forum,
150:                                getCurrentUserRole(), typeId);
151:                return permission == null ? false : permission.getReviseOwn()
152:                        .booleanValue();
153:            }
154:
155:            public boolean canDeleteAny(BaseForum forum, String typeId) {
156:                MessagePermissions permission = permissionManager
157:                        .getForumMessagePermissionForRole(forum,
158:                                getCurrentUserRole(), typeId);
159:                return permission == null ? false : permission.getDeleteAny()
160:                        .booleanValue();
161:            }
162:
163:            public boolean canDeleteOwn(BaseForum forum, String typeId) {
164:                MessagePermissions permission = permissionManager
165:                        .getForumMessagePermissionForRole(forum,
166:                                getCurrentUserRole(), typeId);
167:                return permission == null ? false : permission.getDeleteOwn()
168:                        .booleanValue();
169:            }
170:
171:            public boolean canMarkAsRead(BaseForum forum, String typeId) {
172:                MessagePermissions permission = permissionManager
173:                        .getForumMessagePermissionForRole(forum,
174:                                getCurrentUserRole(), typeId);
175:                return permission == null ? false : permission.getMarkAsRead()
176:                        .booleanValue();
177:            }
178:
179:            public boolean canRead(Area area, String typeId) {
180:                MessagePermissions permission = permissionManager
181:                        .getAreaMessagePermissionForRole(getCurrentUserRole(),
182:                                typeId);
183:                return permission == null ? false : permission.getRead()
184:                        .booleanValue();
185:            }
186:
187:            public boolean canReviseAny(Area area, String typeId) {
188:                MessagePermissions permission = permissionManager
189:                        .getAreaMessagePermissionForRole(getCurrentUserRole(),
190:                                typeId);
191:                return permission == null ? false : permission.getReviseAny()
192:                        .booleanValue();
193:            }
194:
195:            public boolean canReviseOwn(Area area, String typeId) {
196:                MessagePermissions permission = permissionManager
197:                        .getAreaMessagePermissionForRole(getCurrentUserRole(),
198:                                typeId);
199:                return permission == null ? false : permission.getReviseOwn()
200:                        .booleanValue();
201:            }
202:
203:            public boolean canDeleteAny(Area area, String typeId) {
204:                MessagePermissions permission = permissionManager
205:                        .getAreaMessagePermissionForRole(getCurrentUserRole(),
206:                                typeId);
207:                return permission == null ? false : permission.getDeleteAny()
208:                        .booleanValue();
209:            }
210:
211:            public boolean canDeleteOwn(Area area, String typeId) {
212:                MessagePermissions permission = permissionManager
213:                        .getAreaMessagePermissionForRole(getCurrentUserRole(),
214:                                typeId);
215:                return permission == null ? false : permission.getDeleteOwn()
216:                        .booleanValue();
217:            }
218:
219:            public boolean canMarkAsRead(Area area, String typeId) {
220:                MessagePermissions permission = permissionManager
221:                        .getAreaMessagePermissionForRole(getCurrentUserRole(),
222:                                typeId);
223:                return permission == null ? false : permission.getMarkAsRead()
224:                        .booleanValue();
225:            }
226:
227:            // ------------------ CONTROL PERMISSIONS
228:
229:            public boolean canNewResponse(Topic topic, String typeId) {
230:                TopicControlPermission permission = permissionManager
231:                        .getTopicControlPermissionForRole(topic,
232:                                getCurrentUserRole(), typeId);
233:                return permission == null ? false : permission.getNewResponse()
234:                        .booleanValue();
235:            }
236:
237:            public boolean canResponseToResponse(Topic topic, String typeId) {
238:                TopicControlPermission permission = permissionManager
239:                        .getTopicControlPermissionForRole(topic,
240:                                getCurrentUserRole(), typeId);
241:                return permission == null ? false : permission
242:                        .getResponseToResponse().booleanValue();
243:            }
244:
245:            public boolean canMovePostings(Topic topic, String typeId) {
246:                TopicControlPermission permission = permissionManager
247:                        .getTopicControlPermissionForRole(topic,
248:                                getCurrentUserRole(), typeId);
249:                return permission == null ? false : permission
250:                        .getMovePostings().booleanValue();
251:            }
252:
253:            public boolean canChangeSettings(Topic topic, String typeId) {
254:                TopicControlPermission permission = permissionManager
255:                        .getTopicControlPermissionForRole(topic,
256:                                getCurrentUserRole(), typeId);
257:                return permission == null ? false : permission
258:                        .getChangeSettings().booleanValue();
259:            }
260:
261:            public boolean canPostToGradebook(Topic topic, String typeId) {
262:                TopicControlPermission permission = permissionManager
263:                        .getTopicControlPermissionForRole(topic,
264:                                getCurrentUserRole(), typeId);
265:                return permission == null ? false : permission
266:                        .getPostToGradebook().booleanValue();
267:            }
268:
269:            public boolean canNewTopic(BaseForum forum, String typeId) {
270:                ForumControlPermission permission = permissionManager
271:                        .getForumControlPermissionForRole(forum,
272:                                getCurrentUserRole(), typeId);
273:                return permission == null ? false : permission.getNewTopic()
274:                        .booleanValue();
275:            }
276:
277:            public boolean canNewResponse(BaseForum forum, String typeId) {
278:                ForumControlPermission permission = permissionManager
279:                        .getForumControlPermissionForRole(forum,
280:                                getCurrentUserRole(), typeId);
281:                return permission == null ? false : permission.getNewResponse()
282:                        .booleanValue();
283:            }
284:
285:            public boolean canResponseToResponse(BaseForum forum, String typeId) {
286:                ForumControlPermission permission = permissionManager
287:                        .getForumControlPermissionForRole(forum,
288:                                getCurrentUserRole(), typeId);
289:                return permission == null ? false : permission
290:                        .getResponseToResponse().booleanValue();
291:            }
292:
293:            public boolean canMovePostings(BaseForum forum, String typeId) {
294:                ForumControlPermission permission = permissionManager
295:                        .getForumControlPermissionForRole(forum,
296:                                getCurrentUserRole(), typeId);
297:                return permission == null ? false : permission
298:                        .getMovePostings().booleanValue();
299:            }
300:
301:            public boolean canChangeSettings(BaseForum forum, String typeId) {
302:                ForumControlPermission permission = permissionManager
303:                        .getForumControlPermissionForRole(forum,
304:                                getCurrentUserRole(), typeId);
305:                return permission == null ? false : permission
306:                        .getChangeSettings().booleanValue();
307:            }
308:
309:            public boolean canPostToGradebook(BaseForum forum, String typeId) {
310:                ForumControlPermission permission = permissionManager
311:                        .getForumControlPermissionForRole(forum,
312:                                getCurrentUserRole(), typeId);
313:                return permission == null ? false : permission
314:                        .getPostToGradebook().booleanValue();
315:            }
316:
317:            public boolean canNewForum(Area area, String typeId) {
318:                AreaControlPermission permission = permissionManager
319:                        .getAreaControlPermissionForRole(getCurrentUserRole(),
320:                                typeId);
321:                return permission == null ? false : permission.getNewForum()
322:                        .booleanValue();
323:            }
324:
325:            public boolean canNewTopic(Area area, String typeId) {
326:                AreaControlPermission permission = permissionManager
327:                        .getAreaControlPermissionForRole(getCurrentUserRole(),
328:                                typeId);
329:                return permission == null ? false : permission.getNewTopic()
330:                        .booleanValue();
331:            }
332:
333:            public boolean canNewResponse(Area area, String typeId) {
334:                AreaControlPermission permission = permissionManager
335:                        .getAreaControlPermissionForRole(getCurrentUserRole(),
336:                                typeId);
337:                return permission == null ? false : permission.getNewResponse()
338:                        .booleanValue();
339:            }
340:
341:            public boolean canResponseToResponse(Area area, String typeId) {
342:                AreaControlPermission permission = permissionManager
343:                        .getAreaControlPermissionForRole(getCurrentUserRole(),
344:                                typeId);
345:                return permission == null ? false : permission
346:                        .getResponseToResponse().booleanValue();
347:            }
348:
349:            public boolean canMovePostings(Area area, String typeId) {
350:                AreaControlPermission permission = permissionManager
351:                        .getAreaControlPermissionForRole(getCurrentUserRole(),
352:                                typeId);
353:                return permission == null ? false : permission
354:                        .getMovePostings().booleanValue();
355:            }
356:
357:            public boolean canChangeSettings(Area area, String typeId) {
358:                AreaControlPermission permission = permissionManager
359:                        .getAreaControlPermissionForRole(getCurrentUserRole(),
360:                                typeId);
361:                return permission == null ? false : permission
362:                        .getChangeSettings().booleanValue();
363:            }
364:
365:            public boolean canPostToGradebook(Area area, String typeId) {
366:                AreaControlPermission permission = permissionManager
367:                        .getAreaControlPermissionForRole(getCurrentUserRole(),
368:                                typeId);
369:                return permission == null ? false : permission
370:                        .getPostToGradebook().booleanValue();
371:            }
372:
373:            // helpers
374:
375:            private String getCurrentUser() {
376:                if (TestUtil.isRunningTests()) {
377:                    return "test-user";
378:                }
379:                return sessionManager.getCurrentSessionUserId();
380:            }
381:
382:            private String getCurrentUserRole() {
383:                return AuthzGroupService.getUserRole(getCurrentUser(), "/site/"
384:                        + getContextId());
385:            }
386:
387:            private String getContextId() {
388:                if (TestUtil.isRunningTests()) {
389:                    return "test-context";
390:                }
391:                Placement placement = ToolManager.getCurrentPlacement();
392:                String presentSiteId = placement.getContext();
393:                return presentSiteId;
394:            }
395:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.