Source Code Cross Referenced for AgentHelperImpl.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » tool » assessment » integration » helper » 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.integration.helper.standalone 
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/integration/helper/standalone/AgentHelperImpl.java $
003:         * $Id: AgentHelperImpl.java 9273 2006-05-10 22:34:28Z 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.integration.helper.standalone;
021:
022:        import java.util.Collection;
023:        import java.util.HashMap;
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:        import org.sakaiproject.tool.assessment.facade.AgentFacade;
032:        import org.sakaiproject.tool.assessment.integration.helper.ifc.AgentHelper;
033:        import org.sakaiproject.tool.assessment.osid.shared.impl.AgentImpl;
034:        import org.sakaiproject.tool.assessment.osid.shared.impl.IdImpl;
035:        import org.sakaiproject.user.cover.UserDirectoryService;
036:
037:        /**
038:         *
039:         * <p>Description:
040:         * This is a stub standalone context implementation helper delegate class for
041:         * the AgentFacade class.  "Standalone" means that Samigo (Tests and Quizzes)
042:         * is running without the context of the Sakai portal and authentication
043:         * mechanisms, and therefore we "make up" some of the values returned.</p>
044:         * <p>Note: To customize behavior you can add your own helper class to the
045:         * Spring injection via the integrationContext.xml for your context.
046:         * The particular integrationContext.xml to be used is selected by the
047:         * build process.
048:         * </p>
049:         * <p>Sakai Project Copyright (c) 2005</p>
050:         * <p> </p>
051:         * @author Ed Smiley <esmiley@stanford.edu>
052:         * based on code originally in AgentFacade
053:         */
054:        public class AgentHelperImpl implements  AgentHelper {
055:            private static Log log = LogFactory.getLog(AgentHelperImpl.class);
056:            String agentString;
057:
058:            /**
059:             * Get an osid Agent implementation class instance.
060:             *
061:             * @return an AgentImpl: osid Agent implementation class.
062:             */
063:            public AgentImpl getAgent() {
064:                AgentImpl agent = new AgentImpl("Administrator", null,
065:                        new IdImpl("admin"));
066:                return agent;
067:            }
068:
069:            /**
070:             * Get the agent string.
071:             * @return the agent string.
072:             */
073:
074:            public String getEid(String agentString) {
075:                return getAgentString(agentString);
076:            }
077:
078:            public String getEidById(String agentString) {
079:                return getAgentString(agentString);
080:            }
081:
082:            public String getAgentString(String agentString) {
083:                String agentS = "admin";
084:                try {
085:                    if (!UNASSIGNED_AGENT_STRING.equals(agentString)) {
086:                        agentS = agentString;
087:                    }
088:                } catch (Exception ex) {
089:                    log.warn(ex.getMessage());
090:                    // default
091:                }
092:                return agentS;
093:            }
094:
095:            /**
096:             * Get the agent string.
097:             * @param req the HttpServletRequest
098:             * @param res the HttpServletResponse
099:             * @return the agent string.
100:             */
101:            public String getAgentString(HttpServletRequest req,
102:                    HttpServletResponse res) {
103:                String agentS = "admin";
104:                try {
105:                    if (!UNASSIGNED_AGENT_STRING.equals(agentString)) {
106:                        agentS = agentString;
107:                    }
108:                } catch (Exception ex) {
109:                    log.warn(ex.getMessage());
110:                    // default
111:                }
112:                return agentS;
113:            }
114:
115:            /**
116:             * Get the Agent display name.
117:             * @param agentS the Agent string.
118:             * @return the Agent display name.
119:             */
120:            public String getDisplayName(String agentString) {
121:                if ("admin".equals(agentString))
122:                    return "Administrator";
123:                else if ("rachel".equals(agentString))
124:                    return "Rachel Gollub";
125:                else if ("marith".equals(agentString))
126:                    return "Margaret Petit";
127:                else
128:                    return "Dr. Who";
129:            }
130:
131:            /**
132:             * Get the Agent first name.
133:             * @param agentString teh agent string
134:             * @return the Agent first name.
135:             */
136:            public String getFirstName(String agentString) {
137:                if ("admin".equals(agentString))
138:                    return "Samigo";
139:                else if ("rachel".equals(agentString))
140:                    return "Rachel";
141:                else if ("marith".equals(agentString))
142:                    return "Margaret";
143:                else
144:                    return "Dr.";
145:            }
146:
147:            /**
148:             * Get the Agent last name.
149:             * @param agentString the agent string
150:             * @return the Agent last name.
151:             */
152:            public String getLastName(String agentString) {
153:                if ("admin".equals(agentString))
154:                    return "Administrator";
155:                else if ("rachel".equals(agentString))
156:                    return "Gollub";
157:                else if ("marith".equals(agentString))
158:                    return "Petit";
159:                else
160:                    return "Who";
161:            }
162:
163:            /**
164:             * Get the Agent email.
165:             * @param agentString teh agent string
166:             * @return the Agent email.
167:             */
168:            public String getEmail(String agentString) {
169:                String s = "";
170:                try {
171:                    if (!agentString.startsWith("anonymous_"))
172:                        s = UserDirectoryService.getUser(agentString)
173:                                .getEmail();
174:                } catch (Exception e) {
175:                    log.warn(e.getMessage());
176:                }
177:                return s;
178:            }
179:
180:            /**
181:             * Called by AgentFacade from an instance.
182:             * @param agentString the agent string for current AgentFacade instance
183:             * @return role string
184:             */
185:
186:            public String getRoleForCurrentAgent(String agentString) {
187:                return "Student";
188:            }
189:
190:            /**
191:             * For a specific agent id, get the agent role.
192:             * @param agentString the agent string
193:             * @return the agent role.
194:             */
195:            public String getRole(String agentString) {
196:                return "Maintain";
197:            }
198:
199:            /**
200:             * Get the current site id.
201:             * @return the site id.
202:             */
203:            public String getCurrentSiteId(boolean accessViaUrl) {
204:                return "Samigo Site";
205:            }
206:
207:            /**
208:             * Get the current site name.
209:             * @return the site name.
210:             */
211:            public String getCurrentSiteName(boolean accessViaUrl) {
212:                return "Samigo Site";
213:            }
214:
215:            /**
216:             * Get the site name.
217:             * @param siteId  site id
218:             * @return the site name.
219:             */
220:            public String getSiteName(String siteId) {
221:                return "Samigo Site";
222:            }
223:
224:            /**
225:             * Get the id string.
226:             * @return the id string.
227:             */
228:
229:            /**
230:             * Get the display name fo ra specific agent id string.
231:             * @param agentId the agent id string.
232:             * @return the display name.
233:             */
234:            public String getDisplayNameByAgentId(String agentId) {
235:                return "Samigo Administrator";
236:            }
237:
238:            /**
239:             * Create anonymous user and return the anonymous user id.
240:             * @return the anonymous user id.
241:             */
242:            public String createAnonymous(AgentFacade agent) {
243:                String anonymousId = "anonymous_";
244:                try {
245:                    anonymousId += (new java.util.Date()).getTime();
246:                    agent.setAgentInstanceString(anonymousId);
247:                } catch (Exception ex) {
248:                    log.warn(ex.getMessage());
249:                    // leave... ...mostly for unit testing
250:                }
251:                return anonymousId;
252:            }
253:
254:            /**
255:             * Is this a standalone environment?
256:             * @return true, always, in this implementation
257:             */
258:            public boolean isStandaloneEnvironment() {
259:                return true;
260:            }
261:
262:            /**
263:             * Is this an integrated environment?
264:             * @return false, in this implementation
265:             */
266:            public boolean isIntegratedEnvironment() {
267:                return false;
268:            }
269:
270:            /**
271:             * Get current site id from within an external servlet.
272:             * @param req the HttpServletRequest
273:             * @param res the HttpServletResponse
274:             * @return teh site id.
275:             */
276:            public String getCurrentSiteIdFromExternalServlet(
277:                    HttpServletRequest req, HttpServletResponse res) {
278:                return "Samigo Site";
279:            }
280:
281:            /**
282:             * Get the anonymous user id.
283:             * @return the anonymous user id.
284:             */
285:            public String getAnonymousId(String agentString) {
286:                String agentS = "";
287:                try {
288:                    if (!UNASSIGNED_AGENT_STRING.equals(agentString)) {
289:                        agentS = agentString;
290:                    }
291:                } catch (Exception ex) {
292:                    log.warn(ex.getMessage());
293:                    // leave... ...mostly for unit testing
294:                }
295:                return agentS;
296:            }
297:
298:            /**
299:             * Set the agent id string.
300:             * @param idString the isd string.
301:             */
302:
303:            /**
304:             * Set the agent string.
305:             * @param agentString the agent string.
306:             */
307:            public void setAgentString(String agentString) {
308:                this .agentString = agentString;
309:            }
310:
311:            /**
312:             * This gets the current site id and transforms it into the realm.
313:             *
314:             * @param inUsers the Collection of users who have their roles looked up.
315:             *                This is a Collection of userId Strings
316:             * @return Returns the map of users as keys and their roles as values.
317:             *			If the user is not in the realm then they will have a null role.
318:             */
319:            public Map getUserRolesFromContextRealm(Collection inUsers) {
320:                return new HashMap();
321:            }
322:
323:            //cwen
324:            public String getRoleForAgentAndSite(String agentString,
325:                    String siteId) {
326:                return null;
327:            }
328:
329:            /**
330:             * This is a kludge to work around a JSF scriptlet dependency introduced by cwen
331:             * on org.sakaiproject.component.cover.ServerConfigurationService.
332:             * @todo for 2.2 remove method when done with refactor.
333:             * @deprecated
334:             *
335:             * @return true unless it is turned off
336:             */
337:
338:            public boolean isFileUploadAvailable() {
339:                return true;//always, in standalone
340:            }
341:        }
w_w_w_.___j___av___a2__s_.c___o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.