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


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/presence/trunk/presence-api/api/src/java/org/sakaiproject/presence/api/PresenceService.java $
003:         * $Id: PresenceService.java 7844 2006-04-17 13:06:02Z ggolden@umich.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 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.roster;
021:
022:        import java.io.BufferedInputStream;
023:        import java.io.FileInputStream;
024:        import java.io.FileNotFoundException;
025:        import java.io.IOException;
026:        import java.io.OutputStream;
027:
028:        import javax.servlet.ServletException;
029:        import javax.servlet.http.HttpServlet;
030:        import javax.servlet.http.HttpServletRequest;
031:        import javax.servlet.http.HttpServletResponse;
032:
033:        import org.apache.commons.logging.Log;
034:        import org.apache.commons.logging.LogFactory;
035:        import org.sakaiproject.api.app.profile.ProfileManager;
036:        import org.sakaiproject.component.cover.ComponentManager;
037:        import org.sakaiproject.util.ResourceLoader;
038:
039:        public class ParticipantImageServlet extends HttpServlet {
040:            private ResourceLoader msgs = new ResourceLoader(
041:                    "org.sakaiproject.tool.roster.bundle.Messages");
042:            private static final Log LOG = LogFactory
043:                    .getLog(ParticipantImageServlet.class);
044:            private static final String UNIVERSITY_ID_PHOTO = "photo";
045:            private static final String CONTENT_TYPE = "image/jpeg";
046:            private ProfileManager profileManager;
047:
048:            /**
049:             * The doGet method of the servlet. <br>
050:             *
051:             * This method is called when a form has its tag value method equals to get.
052:             *
053:             * @param request the request send by the client to the server
054:             * @param response the response send by the server to the client
055:             * @throws ServletException if an error occurred
056:             * @throws IOException if an error occurred
057:             */
058:            public void doGet(HttpServletRequest request,
059:                    HttpServletResponse response) throws ServletException,
060:                    IOException {
061:                if (LOG.isDebugEnabled())
062:                    LOG.debug("doGet(HttpServletRequest" + request
063:                            + ", HttpServletResponse" + response + ")");
064:                response.setContentType(CONTENT_TYPE);
065:                String userId = null;
066:                OutputStream stream = response.getOutputStream();
067:                userId = (String) request.getParameter(UNIVERSITY_ID_PHOTO);
068:                if (userId != null && userId.trim().length() > 0) {
069:                    displayUniversityIDPhoto(userId, stream, response);
070:                } else {
071:                    displayLocalImage(stream);
072:                }
073:
074:            }
075:
076:            private void displayUniversityIDPhoto(String userId,
077:                    OutputStream stream, HttpServletResponse response) {
078:                if (LOG.isDebugEnabled())
079:                    LOG
080:                            .debug("displayUniversityIDPhoto (String "
081:                                    + userId
082:                                    + "OutputStream stream, HttpServletResponse response)");
083:                try {
084:                    byte[] displayPhoto;
085:                    displayPhoto = getProfileManager()
086:                            .getInstitutionalPhotoByUserId(userId, true);
087:                    if (displayPhoto != null && displayPhoto.length > 0) {
088:                        LOG.debug("Display University ID photo for user:"
089:                                + userId);
090:                        response.setContentLength(displayPhoto.length);
091:                        stream.write(displayPhoto);
092:                        stream.flush();
093:
094:                    } else {
095:                        LOG.debug("Display University ID photo for user:"
096:                                + userId + " is unavailable");
097:                        displayLocalImage(stream);
098:                    }
099:                } catch (IOException e) {
100:                    LOG.error(e.getMessage(), e);
101:                }
102:
103:            }
104:
105:            private void displayLocalImage(OutputStream stream) {
106:                String unavailable_image = msgs.getString("img_off_unavail");
107:
108:                if (LOG.isDebugEnabled())
109:                    LOG.debug("displayPhotoUnavailable(OutputStream" + stream
110:                            + ", String " + unavailable_image + ")");
111:                try {
112:                    BufferedInputStream in = null;
113:                    try {
114:
115:                        in = new BufferedInputStream(new FileInputStream(
116:                                getServletContext().getRealPath(
117:                                        unavailable_image)));
118:                        int ch;
119:
120:                        while ((ch = in.read()) != -1) {
121:                            stream.write((char) ch);
122:                        }
123:                    }
124:
125:                    finally {
126:                        if (in != null)
127:                            in.close();
128:                    }
129:                } catch (FileNotFoundException e) {
130:                    LOG.error(e.getMessage(), e);
131:                } catch (IOException e) {
132:                    LOG.error(e.getMessage(), e);
133:                }
134:            }
135:
136:            /**
137:             * get the component manager
138:             * @return profile manager
139:             */
140:            public ProfileManager getProfileManager() {
141:                LOG.debug("getProfileManager()");
142:                if (profileManager == null) {
143:                    return (ProfileManager) ComponentManager
144:                            .get(ProfileManager.class.getName());
145:                }
146:                return profileManager;
147:            }
148:
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.