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


001:        /**********************************************************************************
002:         * $URL: $
003:         * $Id:  $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2006,2007 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.poll.tool.producers;
021:
022:        import org.sakaiproject.tool.api.ToolManager;
023:        import org.sakaiproject.poll.logic.PollListManager;
024:        import org.sakaiproject.user.api.UserDirectoryService;
025:        import org.sakaiproject.authz.cover.AuthzGroupService;
026:        import org.sakaiproject.authz.api.AuthzGroup;
027:        import org.sakaiproject.authz.api.Role;
028:        import org.sakaiproject.authz.cover.FunctionManager;
029:        import uk.org.ponder.rsf.components.UIBoundBoolean;
030:
031:        import uk.org.ponder.messageutil.MessageLocator;
032:        import uk.org.ponder.rsf.components.UICommand;
033:        import uk.org.ponder.rsf.components.UIContainer;
034:        import uk.org.ponder.rsf.components.UIBranchContainer;
035:        import uk.org.ponder.rsf.components.UIELBinding;
036:        import uk.org.ponder.rsf.components.UIOutput;
037:        import uk.org.ponder.rsf.components.UIForm;
038:        import uk.org.ponder.rsf.view.ComponentChecker;
039:        import uk.org.ponder.rsf.view.ViewComponentProducer;
040:        import uk.org.ponder.rsf.viewstate.ViewParameters;
041:        import uk.org.ponder.rsf.flow.jsfnav.NavigationCase;
042:        import uk.org.ponder.localeutil.LocaleGetter;
043:        import uk.org.ponder.rsf.viewstate.SimpleViewParameters;
044:        import uk.org.ponder.rsf.flow.jsfnav.NavigationCase;
045:        import uk.org.ponder.rsf.flow.jsfnav.NavigationCaseReporter;
046:        import org.sakaiproject.site.cover.SiteService;
047:        import org.sakaiproject.site.api.Site;
048:
049:        import java.util.List;
050:        import java.util.Map;
051:        import java.util.Set;
052:        import java.util.ArrayList;
053:        import java.util.Iterator;
054:
055:        import org.apache.commons.logging.Log;
056:        import org.apache.commons.logging.LogFactory;
057:
058:        public class PermissionsProducer implements  ViewComponentProducer,
059:                NavigationCaseReporter {
060:
061:            public static final String VIEW_ID = "votePermissions";
062:
063:            private UserDirectoryService userDirectoryService;
064:            private PollListManager pollListManager;
065:            private ToolManager toolManager;
066:            private MessageLocator messageLocator;
067:            private LocaleGetter localegetter;
068:
069:            private static final String PERMISSION_PREFIX = "poll";
070:            private static Log m_log = LogFactory
071:                    .getLog(PermissionsProducer.class);
072:
073:            public String getViewID() {
074:                // TODO Auto-generated method stub
075:                return VIEW_ID;
076:            }
077:
078:            public void setMessageLocator(MessageLocator messageLocator) {
079:
080:                this .messageLocator = messageLocator;
081:            }
082:
083:            public void setUserDirectoryService(
084:                    UserDirectoryService userDirectoryService) {
085:                this .userDirectoryService = userDirectoryService;
086:            }
087:
088:            public void setPollListManager(PollListManager pollListManager) {
089:                this .pollListManager = pollListManager;
090:            }
091:
092:            public void setToolManager(ToolManager toolManager) {
093:                this .toolManager = toolManager;
094:            }
095:
096:            public void setLocaleGetter(LocaleGetter localegetter) {
097:                this .localegetter = localegetter;
098:            }
099:
100:            Map perms = null;
101:
102:            public void setRoleperms(Map perms) {
103:                this .perms = perms;
104:            }
105:
106:            public void fillComponents(UIContainer tofill, ViewParameters arg1,
107:                    ComponentChecker arg2) {
108:
109:                try {
110:
111:                    //populate the site name ect
112:                    UIOutput.make(tofill, "permissions-title", messageLocator
113:                            .getMessage("permissions_title"));
114:                    UIOutput.make(tofill, "permissions-instruction",
115:                            messageLocator
116:                                    .getMessage("permissions_instruction"));
117:
118:                    Site site = SiteService.getSite(toolManager
119:                            .getCurrentPlacement().getContext());
120:                    UIOutput.make(tofill, "site-name", site.getTitle());
121:
122:                    //we need a list of permissions	
123:
124:                    String[] perms = new String[] {
125:                            PollListManager.PERMISSION_VOTE,
126:                            PollListManager.PERMISSION_ADD,
127:                            PollListManager.PERMISSION_DELETE_OWN,
128:                            PollListManager.PERMISSION_DELETE_ANY,
129:                            PollListManager.PERMISSION_EDIT_OWN,
130:                            PollListManager.PERMISSION_EDIT_ANY };
131:                    for (int i = 0; i < perms.length; i++) {
132:                        String this Perm = (String) perms[i];
133:                        this Perm = this Perm
134:                                .substring(this Perm.indexOf('.') + 1);
135:                        UIBranchContainer b = UIBranchContainer.make(tofill,
136:                                "head-row:");
137:                        UIOutput.make(b, "perm-name", this Perm);
138:                    }
139:
140:                    AuthzGroup group = AuthzGroupService.getAuthzGroup("/site/"
141:                            + toolManager.getCurrentPlacement().getContext());
142:                    Set roles = group.getRoles();
143:                    Iterator i = roles.iterator();
144:                    UIForm form = UIForm.make(tofill, "perm-form");
145:                    UIOutput.make(form, "permissions-role", messageLocator
146:                            .getMessage("permissions_role"));
147:                    while (i.hasNext()) {
148:                        Role role = (Role) i.next();
149:                        m_log.debug("got role " + role.getId());
150:                        UIBranchContainer row = UIBranchContainer.make(form,
151:                                "permission-row:", role.getId());
152:                        UIOutput.make(row, "role", role.getId());
153:                        //now iterate through the permissions
154:                        String prefix = "#{roleperms." + role.getId();
155:                        for (int ip = 0; ip < perms.length; ip++) {
156:                            String this Perm = (String) perms[ip];
157:                            this Perm = this Perm
158:                                    .substring(this Perm.indexOf('.') + 1);
159:                            UIBranchContainer col = UIBranchContainer.make(row,
160:                                    "box-row:", this Perm);
161:                            m_log.debug("drawing box for " + this Perm
162:                                    + " for role " + role.getId());
163:                            //new Boolean(role.isAllowed((String)perms[ip]))
164:                            UIBoundBoolean.make(col, "perm-box", prefix + "."
165:                                    + this Perm + "}", new Boolean(role
166:                                    .isAllowed((String) perms[ip])));
167:
168:                        }
169:                    }
170:                    UICommand sub = UICommand.make(form, "submit",
171:                            messageLocator.getMessage("new_poll_submit"),
172:                            "#{permissionAction.setPermissions}");
173:                    sub.parameters.add(new UIELBinding(
174:                            "#{permissionAction.submissionStatus}", "submit"));
175:                    UICommand cancel = UICommand.make(form, "cancel",
176:                            messageLocator.getMessage("vote_cancel"),
177:                            "#{permissionAction.cancel}");
178:                    cancel.parameters.add(new UIELBinding(
179:                            "#{permissionAction.submissionStatus}", "cancel"));
180:                } catch (Exception e) {
181:                    e.printStackTrace();
182:                }
183:            }
184:
185:            public List reportNavigationCases() {
186:                List togo = new ArrayList(); // Always navigate back to this view.
187:                togo.add(new NavigationCase(null, new SimpleViewParameters(
188:                        VIEW_ID)));
189:                togo.add(new NavigationCase("Success",
190:                        new SimpleViewParameters(PollToolProducer.VIEW_ID)));
191:                togo.add(new NavigationCase("cancel", new SimpleViewParameters(
192:                        PollToolProducer.VIEW_ID)));
193:                return togo;
194:            }
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.