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


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/sam/trunk/component/src/java/org/sakaiproject/tool/assessment/facade/AgentFacade.java $
003:         * $Id: AgentFacade.java 9497 2006-05-15 23:46:05Z daisyf@stanford.edu $
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;
021:
022:        import java.io.Serializable;
023:        import java.util.Collection;
024:        import java.util.Map;
025:
026:        import javax.servlet.http.HttpServletRequest;
027:        import javax.servlet.http.HttpServletResponse;
028:
029:        import org.apache.commons.logging.Log;
030:        import org.apache.commons.logging.LogFactory;
031:
032:        import org.sakaiproject.tool.assessment.data.ifc.shared.AgentDataIfc;
033:        import org.sakaiproject.tool.assessment.osid.shared.impl.AgentImpl;
034:        import org.sakaiproject.tool.assessment.osid.shared.impl.IdImpl;
035:        import org.sakaiproject.tool.assessment.integration.helper.ifc.AgentHelper;
036:        import org.sakaiproject.tool.assessment.integration.context.IntegrationContextFactory;
037:
038:        /**
039:         * <p>Description: Facade for agent.
040:         * Uses helper to determine integration context implementation.</p>
041:         * <p>Sakai Project Copyright (c) 2005</p>
042:         * <p> </p>
043:         * @author Ed Smiley <esmiley@stanford.edu>
044:         *
045:         */
046:
047:        public class AgentFacade implements  Serializable, AgentDataIfc {
048:
049:            /**
050:             * 
051:             */
052:            private static final long serialVersionUID = 1L;
053:
054:            private static Log log = LogFactory.getLog(AgentFacade.class);
055:
056:            private static final AgentHelper helper = IntegrationContextFactory
057:                    .getInstance().getAgentHelper();
058:            private static final boolean integrated = IntegrationContextFactory
059:                    .getInstance().isIntegrated();
060:
061:            private AgentImpl agent;
062:            private String agentString;
063:            private String eid;
064:            private boolean accessViaUrl;
065:
066:            /**
067:             * Create AgentFacade for agent Id
068:             * @param agentId the agent Id
069:             */
070:            public AgentFacade(String agentId) {
071:                agent = new AgentImpl(agentId, null, new IdImpl(agentId));
072:                agentString = agentId;
073:                eid = helper.getEid(agentId);
074:            }
075:
076:            /**
077:             * Create AgentFacade and have it look up its own agentString (id).
078:             */
079:            public AgentFacade() {
080:                // If an agent string is available, UNASSIGNED_AGENT_STRING willbe replaced
081:                String agentId = helper
082:                        .getAgentString(AgentHelper.UNASSIGNED_AGENT_STRING);
083:                agent = new AgentImpl(agentId, null, new IdImpl(agentId));
084:                agentString = agentId;
085:                eid = helper.getEid(AgentHelper.UNASSIGNED_AGENT_STRING);
086:            }
087:
088:            /**
089:             * Get an osid Agent implementation class instance.
090:             *
091:             * @return an AgentImpl: osid Agent implementation class.
092:             */
093:            public static AgentImpl getAgent() {
094:                return helper.getAgent();
095:            }
096:
097:            /**
098:             * Get the agent string.
099:             * Static convenience method.
100:             * @return the agent string.
101:             */
102:            public static String getAgentString() {
103:                AgentFacade facade = new AgentFacade();
104:                return facade.agentString;
105:            }
106:
107:            /**
108:             * Get the current user's Eid.
109:             * Static convenience method.
110:             * @return the eid.
111:             */
112:            public static String getEid() {
113:                AgentFacade facade = new AgentFacade();
114:                return facade.eid;
115:            }
116:
117:            /**
118:             * Get the agent string.
119:             * Preferred approach: instantiate and then call this.
120:             * @return the agent string.
121:             */
122:            public String getAgentInstanceString() {
123:                return this .agentString;
124:            }
125:
126:            //  /**
127:            //   * Get the agent string.
128:            //   * @param req the HttpServletRequest
129:            //   * @param res the HttpServletResponse
130:            //   * @return the agent string.
131:            //   */
132:            //  public static String getAgentString(HttpServletRequest req,
133:            //                                      HttpServletResponse res)
134:            //  {
135:            //    return helper.getAgentString(agentString);
136:            //  }
137:
138:            /**
139:             * Get the Eid String of an Agent.
140:             * @return the Agent Eid.
141:             */
142:            public String getEidString() {
143:                log.debug("agentfacade.getEid(agentS) agentString = "
144:                        + agentString);
145:                return helper.getEidById(agentString);
146:            }
147:
148:            /**
149:             * Get the Agent display name.
150:             * @param agentS the Agent string.
151:             * @return the Agent display name.
152:             */
153:            public static String getDisplayName(String agentS) {
154:                return helper.getDisplayName(agentS);
155:            }
156:
157:            /**
158:             * Get the Agent display name for this agent.
159:             * @return the Agent display name.
160:             */
161:            public String getDisplayName() {
162:                return helper.getDisplayName(this .agentString);
163:            }
164:
165:            /**
166:             * Get the Agent first name.
167:             * @return the Agent first name.
168:             */
169:            public String getFirstName() {
170:                return helper.getFirstName(agentString);
171:            }
172:
173:            /**
174:             * Get the Agent last name.
175:             * @return the Agent last name.
176:             */
177:            public String getLastName() {
178:                return helper.getLastName(agentString);
179:            }
180:
181:            /**
182:             * Get the Agent last name.
183:             * @return the Agent last name.
184:             */
185:            public String getEmail() {
186:                return helper.getEmail(agentString);
187:            }
188:
189:            /**
190:             * Get role for this agent.
191:             * @return role string
192:             */
193:            public String getRole() {
194:                return helper.getRoleForCurrentAgent(agentString);
195:            }
196:
197:            /**
198:             * Get role for  agent.
199:             * @param agentString the agent string.
200:             * @return role string
201:             */
202:            public static String getRole(String agentString) {
203:                return helper.getRole(agentString);
204:            }
205:
206:            /**
207:             * Get the current site id.
208:             * @return the site id.
209:             */
210:            public static String getCurrentSiteId() {
211:                AgentFacade facade = new AgentFacade();
212:                boolean accessViaUrl = facade.isAccessViaUrl();
213:
214:                return helper.getCurrentSiteId(accessViaUrl);
215:            }
216:
217:            /**
218:             * Get the current site name.
219:             * @return the site name.
220:             */
221:            public static String getCurrentSiteName() {
222:                AgentFacade facade = new AgentFacade();
223:                boolean accessViaUrl = facade.isAccessViaUrl();
224:
225:                return helper.getCurrentSiteName(accessViaUrl);
226:            }
227:
228:            /**
229:             * Get the site name.
230:             * @param siteId  site id
231:             * @return the site name.
232:             */
233:            public static String getSiteName(String siteId) {
234:                return helper.getSiteName(siteId);
235:            }
236:
237:            public String getIdString() {
238:                return agentString;
239:            }
240:
241:            // should phrase out this one -daisyf
242:            /**
243:             * Get the display name for a specific agent id string.
244:             * @param agentId the agent id string.
245:             * @return the display name.
246:             */
247:            public static String getDisplayNameByAgentId(String agentId) {
248:                return helper.getDisplayNameByAgentId(agentId);
249:            }
250:
251:            /**
252:             * Create anonymous user and return the anonymous user id.
253:             * @return the anonymous user id.
254:             */
255:            public static String createAnonymous() {
256:                AgentFacade facade = new AgentFacade();
257:                return helper.createAnonymous(facade);
258:            }
259:
260:            /**
261:             * Is this a standlaone environment?
262:             * @return false, in this implementation
263:             */
264:            public static boolean isStandaloneEnvironment() {
265:                return !integrated;
266:            }
267:
268:            /**
269:             * Is this an integrated environment?
270:             * @return true, in this implementation
271:             */
272:            public static boolean isIntegratedEnvironment() {
273:                return integrated;
274:            }
275:
276:            //  /**
277:            //   * Get current site id from within an external servlet.
278:            //   * @param req the HttpServletRequest
279:            //   * @param res the HttpServletResponse
280:            //   * @return teh site id.
281:            //   */
282:            //  public static String getCurrentSiteIdFromExternalServlet(HttpServletRequest
283:            //    req, HttpServletResponse res)
284:            //  {
285:            //    return helper.getCurrentSiteIdFromExternalServlet(req, res);
286:            //  }
287:
288:            /**
289:             * Get the anonymous user id.
290:             * @return the anonymous user id.
291:             */
292:            public static String getAnonymousId() {
293:                AgentFacade facade = new AgentFacade();
294:                String agentString = facade.getAgentInstanceString();
295:                return helper.getAnonymousId(agentString);
296:            }
297:
298:            /**
299:             * Change the agent string
300:             * @param idString the id string.
301:             */
302:            public void setIdString(String idString) {
303:                agentString = idString;
304:            }
305:
306:            /**
307:             * Get the anonymous user id.
308:             * @return the anonymous user id.
309:             */
310:            public static Map getUserRolesFromContextRealm(Collection inUsers) {
311:                return helper.getUserRolesFromContextRealm(inUsers);
312:            }
313:
314:            //cwen
315:            public static String getRoleForAgentAndSite(String agentString,
316:                    String siteId) {
317:                return helper.getRoleForAgentAndSite(agentString, siteId);
318:            }
319:
320:            public boolean isAccessViaUrl() {
321:                return (agentString.startsWith("anonymous_"));
322:            }
323:
324:            public void setAccessViaUrl(boolean accessViaUrl) {
325:                this .accessViaUrl = accessViaUrl;
326:            }
327:
328:            public void setAgentInstanceString(String agentInstanceString) {
329:                this .agentString = agentInstanceString;
330:            }
331:
332:            /**
333:             * This is a kludge to work around a JSF scriptlet dependency introduced by cwen
334:             * on org.sakaiproject.service.component.cover.ServerConfigurationService.
335:             * @todo for 2.2 remove method when done with refactor.
336:             * @deprecated
337:             *
338:             * @return true unless it is turned off
339:             */
340:
341:            public static boolean isFileUploadAvailable() {
342:                return helper.isFileUploadAvailable();
343:            }
344:
345:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.