Source Code Cross Referenced for AuthzQueriesFacade.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » tool » assessment » facade » authz » standalone » 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.assessment.facade.authz.standalone 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL$
003:         * $Id$
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 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.assessment.facade.authz.standalone;
021:
022:        import java.util.ArrayList;
023:        import java.util.Date;
024:        import java.util.HashMap;
025:        import java.util.List;
026:        import java.util.ResourceBundle;
027:
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.springframework.dao.DataAccessException;
031:        import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
032:
033:        import org.sakaiproject.tool.assessment.data.dao.authz.AuthorizationData;
034:        import org.sakaiproject.tool.assessment.facade.AgentFacade;
035:        import org.sakaiproject.tool.assessment.facade.AuthzQueriesFacadeAPI;
036:
037:        /**
038:         * <p>Description: Facade for AuthZ queries, standalone version.
039:         * <p>Sakai Project Copyright (c) 2005</p>
040:         * <p> </p>
041:         * @author Rachel Gollub <rgollub@stanford.edu>
042:         * @author Ed Smiley <esmiley@stanford.edu>
043:         */
044:        public class AuthzQueriesFacade extends HibernateDaoSupport implements 
045:                AuthzQueriesFacadeAPI {
046:            private static Log log = LogFactory
047:                    .getLog(AuthzQueriesFacade.class);
048:
049:            // stores sql strings
050:            private static ResourceBundle res = ResourceBundle
051:                    .getBundle("org.sakaiproject.tool.assessment.facade.authz.resource.AuthzResource");
052:
053:            public boolean hasPrivilege(String functionName) {
054:                return true;
055:            }
056:
057:            /**
058:             * Is the agent {agentId} authorized to do {function} to {qualifier}?
059:             * @param agentId the agent id.
060:             * @param functionId the function to be performed.
061:             * @param qualifierId the target of the function.
062:             * @return true if authorized (always in standalone)
063:             */
064:            public boolean isAuthorized(String agentId, String function,
065:                    String qualifier) {
066:                return true;
067:            }
068:
069:            /**
070:             * Create an authorization record for {agentId} authorized to do {function}
071:             * to {qualifier}
072:             * @param agentId the agent id.
073:             * @param functionId the function to be performed.
074:             * @param qualifierId the target of the function.
075:             * @return the authorization data
076:             */
077:            public AuthorizationData createAuthorization(String agentId,
078:                    String functionId, String qualifierId) {
079:                AuthorizationData a = new AuthorizationData(agentId,
080:                        functionId, qualifierId, new Date(), new Date(),
081:                        AgentFacade.getAgentString(), new Date(), Boolean.TRUE);
082:                getHibernateTemplate().save(a);
083:                return a;
084:            }
085:
086:            /**
087:             * Remove authorization from qualifier (target).
088:             * @param qualifierId the target.
089:             */
090:            public void removeAuthorizationByQualifier(String qualifierId,
091:                    boolean isPublishedAssessment) {
092:                String query = res.getString("select_authdata_q_id")
093:                        + qualifierId + "'";
094:                String clause = "";
095:                if (isPublishedAssessment) {
096:                    clause = " and (a.functionId='OWN_PUBLISHED_ASSESSMENT'"
097:                            + " or a.functionId='TAKE_PUBLISHED_ASSESSMENT'"
098:                            + " or a.functionId='VIEW_PUBLISHED_ASSESSMENT_FEEDBACK'"
099:                            + " or a.functionId='GRADE_PUBLISHED_ASSESSMENT'"
100:                            + " or a.functionId='VIEW_PUBLISHED_ASSESSMENT')";
101:                } else {
102:                    clause = " and a.functionId='EDIT_ASSESSMENT'";
103:                }
104:
105:                List l = getHibernateTemplate().find(query + clause);
106:                getHibernateTemplate().deleteAll(l);
107:            }
108:
109:            /** This returns a HashMap containing
110:             * (String a.qualiferId, AuthorizationData a)
111:             * agentId is a site for now but can be a user
112:             *
113:             * @param agentId the agent id
114:             * @return HashMap containing qualiferId, AuthorizationData
115:             */
116:            public HashMap getAuthorizationToViewAssessments(String agentId) {
117:                HashMap h = new HashMap();
118:                List l = getAuthorizationByAgentAndFunction(agentId, res
119:                        .getString("VIEW_PUB"));
120:                for (int i = 0; i < l.size(); i++) {
121:                    AuthorizationData a = (AuthorizationData) l.get(i);
122:                    h.put(a.getQualifierId(), a);
123:                }
124:                return h;
125:            }
126:
127:            /**
128:             * This returns a HashMap containing authorization data.
129:             * @param agentId is a site for now but can be a user
130:             * @param functionId the function to be performed.
131:             * @return HashMap containing (String a.qualiferId, AuthorizationData a)
132:             */
133:            public List getAuthorizationByAgentAndFunction(String agentId,
134:                    String functionId) {
135:                try {
136:                    String query = res.getString("select_authdata_a_id")
137:                            + agentId + res.getString("and_f_id") + functionId
138:                            + "'";
139:
140:                    List list = getHibernateTemplate().find(query);
141:                    return list;
142:                } catch (DataAccessException ex) {
143:                    log.warn("getAuthorizationByAgentAndFunction " + ex);
144:                    return new ArrayList();//empty
145:                }
146:            }
147:
148:            /**
149:             * Get authorization list by qualifier and function.
150:             * @param functionId the function to be performed.
151:             * @param qualifierId the target of the function.
152:             * @return the list of authorizations.
153:             */
154:            public List getAuthorizationByFunctionAndQualifier(
155:                    String functionId, String qualifierId) {
156:                try {
157:                    String query = res.getString("select_authdata_f_id")
158:                            + functionId + res.getString("and_q_id")
159:                            + qualifierId + "'";
160:
161:                    List list = getHibernateTemplate().find(query);
162:                    //System.out.println("list="+list);
163:                    return list;
164:                } catch (DataAccessException ex) {
165:                    log.warn("getAuthorizationByAgentAndFunction " + ex);
166:                    return new ArrayList();//empty
167:                }
168:            }
169:
170:            /**
171:             * Check if member of site.
172:             * @param siteId the site id
173:             * @return true if a member.
174:             */
175:            public boolean checkMembership(String siteId) {
176:                return true;
177:            }
178:
179:            ///////////////////////////////////////////////////////////////////////////////
180:            // The following methods are not implemented in the standalone version of
181:            // AuthzQueriesFacade.  Currently they are not used in the standalone context,
182:            // so they are left throwing UnsupportedOperationExceptions.
183:            //
184:            // If required for standalone context at some point in the future, you'll
185:            // need to implement these, and also should add them to AuthzQueriesFacadeAPI.
186:            //
187:            ///////////////////////////////////////////////////////////////////////////////
188:
189:            /**
190:             * UNIMPLEMENTED.
191:             * Check the agent {agentId} authorized to do {function} to {qualifier}?
192:             * @todo If required for standalone context at some point in the future,
193:             * you'll need to implement this
194:             * org.sakaiproject.tool.assessment.integration.helper.ifc.AuthzHelper method
195:             * @param agentId the agent id.
196:             * @param functionId the function to be performed.
197:             * @param qualifierId the target of the function.
198:             * @return --throw UnsupportedOperationException
199:             */
200:            public boolean checkAuthorization(String agentId,
201:                    String functionId, String qualifierId) {
202:                throw new java.lang.UnsupportedOperationException(
203:                        "Method checkAuthorization() not yet implemented for standalone context.");
204:            }
205:
206:            /**
207:             * UNIMPLEMENTED.
208:             * Warning. Oddly named method.  Just following the convention.
209:             * Actually using select from ...AuthorizationData...
210:             * @todo If required for standalone context at some point in the future,
211:             * you'll need to implement this
212:             * org.sakaiproject.tool.assessment.integration.helper.ifc.AuthzHelper method
213:             * @param agentId the agent id.
214:             * @param functionId the function to be performed.
215:             * @return --throw UnsupportedOperationException
216:             */
217:            public ArrayList getAssessments(String agentId, String functionId) {
218:                throw new java.lang.UnsupportedOperationException(
219:                        "Method getAssessments() not yet implemented for standalone context.");
220:            }
221:
222:            /**
223:             * UNIMPLEMENTED.
224:             *
225:             * @todo If required for standalone context at some point in the future,
226:             * you'll need to implement this org.sakaiproject.tool.assessment.integration.helper.ifc.AuthzHelper method
227:             * @param agentId the agent id.
228:             * @param functionId the function to be performed.
229:             * @return --throw UnsupportedOperationException
230:             */
231:            public ArrayList getAssessmentsByAgentAndFunction(String agentId,
232:                    String functionId) {
233:                throw new java.lang.UnsupportedOperationException(
234:                        "Method getAssessmentsByAgentAndFunction() not yet implemented for standalone context.");
235:            }
236:
237:        }
w__ww___.j__a___v__a___2s__.__c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.