Source Code Cross Referenced for PermissionBean.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » tool » messageforums » ui » 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.tool.messageforums.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/msgcntr/trunk/messageforums-app/src/java/org/sakaiproject/tool/messageforums/ui/PermissionBean.java $
003:         * $Id: PermissionBean.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.tool.messageforums.ui;
021:
022:        import java.util.ArrayList;
023:        import java.util.Iterator;
024:        import java.util.List;
025:        import java.util.ResourceBundle;
026:
027:        import javax.faces.model.SelectItem;
028:
029:        import org.sakaiproject.api.app.messageforums.DBMembershipItem;
030:        import org.sakaiproject.api.app.messageforums.MessageForumsTypeManager;
031:        import org.sakaiproject.api.app.messageforums.PermissionLevel;
032:        import org.sakaiproject.api.app.messageforums.PermissionLevelManager;
033:        import org.sakaiproject.component.cover.ComponentManager;
034:        import org.sakaiproject.util.ResourceLoader;
035:        import org.sakaiproject.api.app.messageforums.PermissionsMask;
036:
037:        public class PermissionBean {
038:
039:            /** Path to bundle messages */
040:            private static final String MESSAGECENTER_BUNDLE = "org.sakaiproject.api.app.messagecenter.bundle.Messages";
041:
042:            /** Keys for bundle messages */
043:            public static final String OWN = "perm_own";
044:            public static final String ALL = "perm_all";
045:            public static final String NONE = "perm_none";
046:
047:            private String selectedLevel;
048:            private DBMembershipItem item;
049:            private PermissionLevelManager permissionLevelManager;
050:
051:            public PermissionBean(DBMembershipItem item,
052:                    PermissionLevelManager permissionLevelManager) {
053:                this .permissionLevelManager = permissionLevelManager;
054:                this .item = item;
055:                selectedLevel = item.getPermissionLevel().getName();
056:            }
057:
058:            /**
059:             * @return Returns the selectedLevel.
060:             */
061:            public String getSelectedLevel() {
062:                return selectedLevel;
063:            }
064:
065:            /**
066:             * @param selectedLevel
067:             *          The selectedLevel to set.
068:             */
069:            public void setSelectedLevel(String selectedLevel) {
070:                this .selectedLevel = selectedLevel;
071:                setPermissionsForLevel(selectedLevel);
072:            }
073:
074:            private void setPermissionsForLevel(String selectedLevel) {
075:                if (selectedLevel != null) {
076:                    if (!selectedLevel.equals("Custom")) {
077:                        PermissionLevel permLevel = permissionLevelManager
078:                                .getPermissionLevelByName(selectedLevel);
079:                        this .item.setPermissionLevel(permLevel);
080:                    } else {
081:                        MessageForumsTypeManager typeManager = (MessageForumsTypeManager) ComponentManager
082:                                .get("org.sakaiproject.api.app.messageforums.MessageForumsTypeManager");
083:                        if (!this .item.getPermissionLevel().getTypeUuid()
084:                                .equals(typeManager.getCustomLevelType())) {
085:                            PermissionLevel permLevel = permissionLevelManager
086:                                    .createPermissionLevel(selectedLevel,
087:                                            typeManager.getCustomLevelType(),
088:                                            new PermissionsMask());
089:                            this .item.setPermissionLevel(permLevel);
090:                        }
091:                    }
092:                }
093:            }
094:
095:            public boolean getChangeSettings() {
096:                if (item != null
097:                        && item.getPermissionLevel() != null
098:                        && item.getPermissionLevel().getChangeSettings() != null)
099:                    return item.getPermissionLevel().getChangeSettings()
100:                            .booleanValue();
101:                else
102:                    return false;
103:            }
104:
105:            public void setChangeSettings(boolean changeSettings) {
106:                this .item.getPermissionLevel().setChangeSettings(
107:                        new Boolean(changeSettings));
108:            }
109:
110:            public boolean getDeleteAny() {
111:                if (item != null && item.getPermissionLevel() != null
112:                        && item.getPermissionLevel().getDeleteAny() != null)
113:                    return item.getPermissionLevel().getDeleteAny()
114:                            .booleanValue();
115:                else
116:                    return false;
117:            }
118:
119:            public void setDeleteAny(boolean deleteAny) {
120:                this .item.getPermissionLevel().setDeleteAny(
121:                        new Boolean(deleteAny));
122:            }
123:
124:            public boolean getDeleteOwn() {
125:                if (item != null && item.getPermissionLevel() != null
126:                        && item.getPermissionLevel().getDeleteOwn() != null)
127:                    return item.getPermissionLevel().getDeleteOwn()
128:                            .booleanValue();
129:
130:                else
131:                    return false;
132:            }
133:
134:            public void setDeleteOwn(boolean deleteOwn) {
135:                this .item.getPermissionLevel().setDeleteOwn(
136:                        new Boolean(deleteOwn));
137:            }
138:
139:            public boolean getMarkAsRead() {
140:                if (item != null && item.getPermissionLevel() != null
141:                        && item.getPermissionLevel().getMarkAsRead() != null)
142:                    return item.getPermissionLevel().getMarkAsRead()
143:                            .booleanValue();
144:                else
145:                    return false;
146:            }
147:
148:            public void setMarkAsRead(boolean markAsRead) {
149:                this .item.getPermissionLevel().setMarkAsRead(
150:                        new Boolean(markAsRead));
151:            }
152:
153:            public boolean getModeratePostings() {
154:                if (item != null
155:                        && item.getPermissionLevel() != null
156:                        && item.getPermissionLevel().getModeratePostings() != null)
157:                    return item.getPermissionLevel().getModeratePostings()
158:                            .booleanValue();
159:                else
160:                    return false;
161:            }
162:
163:            public void setModeratePostings(boolean moderatePostings) {
164:                this .item.getPermissionLevel().setModeratePostings(
165:                        new Boolean(moderatePostings));
166:            }
167:
168:            public boolean getMovePosting() {
169:                if (item != null && item.getPermissionLevel() != null
170:                        && item.getPermissionLevel().getMovePosting() != null)
171:                    return item.getPermissionLevel().getMovePosting()
172:                            .booleanValue();
173:                else
174:                    return false;
175:            }
176:
177:            public void setMovePosting(boolean movePosting) {
178:                this .item.getPermissionLevel().setMovePosting(
179:                        new Boolean(movePosting));
180:            }
181:
182:            public boolean getNewForum() {
183:                if (item != null && item.getPermissionLevel() != null
184:                        && item.getPermissionLevel().getNewForum() != null)
185:                    return item.getPermissionLevel().getNewForum()
186:                            .booleanValue();
187:                else
188:                    return false;
189:            }
190:
191:            public void setNewForum(boolean newForum) {
192:                this .item.getPermissionLevel().setNewForum(
193:                        new Boolean(newForum));
194:            }
195:
196:            public boolean getNewResponse() {
197:                if (item != null && item.getPermissionLevel() != null
198:                        && item.getPermissionLevel().getNewResponse() != null)
199:                    return item.getPermissionLevel().getNewResponse()
200:                            .booleanValue();
201:                else
202:                    return false;
203:            }
204:
205:            public void setNewResponse(boolean newResponse) {
206:                this .item.getPermissionLevel().setNewResponse(
207:                        new Boolean(newResponse));
208:            }
209:
210:            public boolean getNewTopic() {
211:                if (item != null && item.getPermissionLevel() != null
212:                        && item.getPermissionLevel().getNewTopic() != null)
213:                    return item.getPermissionLevel().getNewTopic()
214:                            .booleanValue();
215:                else
216:                    return false;
217:            }
218:
219:            public void setNewTopic(boolean newTopic) {
220:                this .item.getPermissionLevel().setNewTopic(
221:                        new Boolean(newTopic));
222:            }
223:
224:            public boolean getPostToGradebook() {
225:                if (item != null
226:                        && item.getPermissionLevel() != null
227:                        && item.getPermissionLevel().getPostToGradebook() != null)
228:                    return item.getPermissionLevel().getPostToGradebook()
229:                            .booleanValue();
230:                else
231:                    return false;
232:            }
233:
234:            public void setPostToGradebook(boolean postGrades) {
235:                this .item.getPermissionLevel().setPostToGradebook(
236:                        new Boolean(postGrades));
237:            }
238:
239:            public boolean getRead() {
240:                if (item != null && item.getPermissionLevel() != null
241:                        && item.getPermissionLevel().getRead() != null)
242:                    return item.getPermissionLevel().getRead().booleanValue();
243:                else
244:                    return false;
245:            }
246:
247:            public void setRead(boolean read) {
248:                this .item.getPermissionLevel().setRead(new Boolean(read));
249:            }
250:
251:            public boolean getResponseToResponse() {
252:                if (item != null
253:                        && item.getPermissionLevel() != null
254:                        && item.getPermissionLevel().getNewResponseToResponse() != null)
255:                    return item.getPermissionLevel().getNewResponseToResponse()
256:                            .booleanValue();
257:                else
258:                    return false;
259:            }
260:
261:            public void setResponseToResponse(boolean responseToResponse) {
262:                this .item.getPermissionLevel().setNewResponseToResponse(
263:                        new Boolean(responseToResponse));
264:            }
265:
266:            public boolean getReviseAny() {
267:                if (item != null && item.getPermissionLevel() != null
268:                        && item.getPermissionLevel().getReviseAny() != null)
269:                    return item.getPermissionLevel().getReviseAny()
270:                            .booleanValue();
271:                else
272:                    return false;
273:            }
274:
275:            public void setReviseAny(boolean reviseAny) {
276:                this .item.getPermissionLevel().setReviseAny(
277:                        new Boolean(reviseAny));
278:            }
279:
280:            public boolean getReviseOwn() {
281:                if (item != null && item.getPermissionLevel() != null
282:                        && item.getPermissionLevel().getReviseOwn() != null)
283:                    return item.getPermissionLevel().getReviseOwn()
284:                            .booleanValue();
285:                else
286:                    return false;
287:            }
288:
289:            public void setReviseOwn(boolean reviseOwn) {
290:                this .item.getPermissionLevel().setReviseOwn(
291:                        new Boolean(reviseOwn));
292:            }
293:
294:            /**
295:             * @return Returns the deletePosting.
296:             */
297:            public String getDeletePostings() {
298:                if (getDeleteAny()) {
299:                    return getResourceBundleString(ALL);
300:                }
301:                if (getDeleteOwn()) {
302:                    return getResourceBundleString(OWN);
303:                }
304:                return getResourceBundleString(NONE);
305:            }
306:
307:            /**
308:             * @param deletePosting The deletePosting to set.
309:             */
310:            public void setDeletePostings(String deletePosting) {
311:                if (deletePosting.equals(getResourceBundleString(ALL))) {
312:                    setDeleteAny(true);
313:                    setDeleteOwn(true);
314:                } else if (deletePosting.equals(getResourceBundleString(OWN))) {
315:                    setDeleteAny(false);
316:                    setDeleteOwn(true);
317:                } else if (deletePosting.equals(getResourceBundleString(NONE))) {
318:                    setDeleteAny(false);
319:                    setDeleteOwn(false);
320:                }
321:            }
322:
323:            /**
324:             * @return Returns the revisePostings.
325:             */
326:            public String getRevisePostings() {
327:                String test = getResourceBundleString(NONE);
328:
329:                if (getReviseAny()) {
330:                    test = getResourceBundleString(ALL);
331:                }
332:                if (getReviseOwn()) {
333:                    test = getResourceBundleString(OWN);
334:                }
335:                //    return getResourceBundleString(NONE);
336:                return test;
337:            }
338:
339:            /**
340:             * @param revisePostings The revisePostings to set.
341:             */
342:            public void setRevisePostings(String revisePostings) {
343:                if (revisePostings.equals(getResourceBundleString(ALL))) {
344:                    setReviseAny(true);
345:                    setReviseOwn(false);
346:                } else if (revisePostings.equals(getResourceBundleString(OWN))) {
347:                    setReviseAny(false);
348:                    setReviseOwn(true);
349:                } else if (revisePostings.equals(getResourceBundleString(NONE))) {
350:                    setReviseAny(false);
351:                    setReviseOwn(false);
352:                }
353:            }
354:
355:            /**
356:             * @return Returns the item.
357:             */
358:            public DBMembershipItem getItem() {
359:                return item;
360:            }
361:
362:            /**
363:             * Pulls messages from bundle
364:             * 
365:             * @param key
366:             * 			Key of message to get
367:             * 
368:             * @return
369:             * 			String for key passed in or [missing: key] if not found
370:             */
371:            public static String getResourceBundleString(String key) {
372:                final ResourceBundle rb = ResourceBundle
373:                        .getBundle(MESSAGECENTER_BUNDLE);
374:                return rb.getString(key);
375:            }
376:
377:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.