Source Code Cross Referenced for MessageStatsRecorder.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » services » stats » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.services.stats 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2002 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.services.stats;
007:
008:        import org.jasig.portal.ChannelDefinition;
009:        import org.jasig.portal.UserProfile;
010:        import org.jasig.portal.layout.node.IUserLayoutChannelDescription;
011:        import org.jasig.portal.layout.node.IUserLayoutFolderDescription;
012:        import org.jasig.portal.security.IPerson;
013:
014:        /**
015:         * Formulates stats messages which can be logged, printed, etc.
016:         * Subclasses need to override <code>outputMessage(String message)</code>.
017:         * @author Ken Weiner, kweiner@unicon.net
018:         * @version $Revision: 36546 $
019:         * 
020:         * @deprecated IStatsRecorder implementation is replaced with a much more flexible system based on the Spring ApplicationEventPublisher 
021:         * and Event Listeners. For more information see:
022:         * http://www.ja-sig.org/wiki/display/UPC/Proposal+to+Deprecate+IStatsRecorder
023:         */
024:        public abstract class MessageStatsRecorder implements  IStatsRecorder {
025:
026:            public void recordLogin(IPerson person) {
027:                String msg = getDisplayName(person)
028:                        + " logged in successfully at " + new java.util.Date();
029:                outputMessage(fixMsg(msg));
030:            }
031:
032:            public void recordLogout(IPerson person) {
033:                String msg = getDisplayName(person) + " logged out at "
034:                        + new java.util.Date();
035:                outputMessage(fixMsg(msg));
036:            }
037:
038:            public void recordSessionCreated(IPerson person) {
039:                String msg = "Session created for " + getDisplayName(person)
040:                        + " " + "at " + new java.util.Date();
041:                outputMessage(fixMsg(msg));
042:            }
043:
044:            public void recordSessionDestroyed(IPerson person) {
045:                String msg = "Session destroyed for " + getDisplayName(person)
046:                        + " " + "at " + new java.util.Date();
047:                outputMessage(fixMsg(msg));
048:            }
049:
050:            public void recordChannelDefinitionPublished(IPerson person,
051:                    ChannelDefinition channelDef) {
052:                String msg = "Channel '" + channelDef.getName() + "' "
053:                        + "was published by " + getDisplayName(person) + " "
054:                        + "at " + new java.util.Date();
055:                outputMessage(fixMsg(msg));
056:            }
057:
058:            public void recordChannelDefinitionModified(IPerson person,
059:                    ChannelDefinition channelDef) {
060:                String msg = "Channel '" + channelDef.getName() + "' "
061:                        + "was modified by " + getDisplayName(person) + " "
062:                        + "at " + new java.util.Date();
063:                outputMessage(fixMsg(msg));
064:            }
065:
066:            public void recordChannelDefinitionRemoved(IPerson person,
067:                    ChannelDefinition channelDef) {
068:                String msg = "Channel '" + channelDef.getName() + "' "
069:                        + "was removed by " + getDisplayName(person) + " "
070:                        + "at " + new java.util.Date();
071:                outputMessage(fixMsg(msg));
072:            }
073:
074:            public void recordChannelAddedToLayout(IPerson person,
075:                    UserProfile profile,
076:                    IUserLayoutChannelDescription channelDesc) {
077:                String msg = "Channel [" + channelDesc.getName() + ", "
078:                        + channelDesc.getChannelPublishId() + ", "
079:                        + channelDesc.getChannelSubscribeId() + "] "
080:                        + "was added to layout " + profile.getLayoutId() + " "
081:                        + "by " + getDisplayName(person) + " " + "at "
082:                        + new java.util.Date();
083:                outputMessage(fixMsg(msg));
084:            }
085:
086:            public void recordChannelUpdatedInLayout(IPerson person,
087:                    UserProfile profile,
088:                    IUserLayoutChannelDescription channelDesc) {
089:                String msg = "Channel [" + channelDesc.getName() + ", "
090:                        + channelDesc.getChannelPublishId() + ", "
091:                        + channelDesc.getChannelSubscribeId() + "] "
092:                        + "was updated in layout " + profile.getLayoutId()
093:                        + " " + "by " + getDisplayName(person) + " " + "at "
094:                        + new java.util.Date();
095:                outputMessage(fixMsg(msg));
096:            }
097:
098:            public void recordChannelMovedInLayout(IPerson person,
099:                    UserProfile profile,
100:                    IUserLayoutChannelDescription channelDesc) {
101:                String msg = "Channel [" + channelDesc.getName() + ", "
102:                        + channelDesc.getChannelPublishId() + ", "
103:                        + channelDesc.getChannelSubscribeId() + "] "
104:                        + "was moved in layout " + profile.getLayoutId() + " "
105:                        + "by " + getDisplayName(person) + " " + "at "
106:                        + new java.util.Date();
107:                outputMessage(fixMsg(msg));
108:            }
109:
110:            public void recordChannelRemovedFromLayout(IPerson person,
111:                    UserProfile profile,
112:                    IUserLayoutChannelDescription channelDesc) {
113:                String msg = "Channel [" + channelDesc.getName() + ", "
114:                        + channelDesc.getChannelPublishId() + ", "
115:                        + channelDesc.getChannelSubscribeId() + "] "
116:                        + "was removed from layout " + profile.getLayoutId()
117:                        + " " + "by " + getDisplayName(person) + " " + "at "
118:                        + new java.util.Date();
119:                outputMessage(fixMsg(msg));
120:            }
121:
122:            public void recordFolderAddedToLayout(IPerson person,
123:                    UserProfile profile, IUserLayoutFolderDescription folderDesc) {
124:                String msg = "Folder [" + folderDesc.getName() + ", "
125:                        + folderDesc.getId() + "] " + "was added to layout "
126:                        + profile.getLayoutId() + " " + "by "
127:                        + getDisplayName(person) + " " + "at "
128:                        + new java.util.Date();
129:                outputMessage(fixMsg(msg));
130:            }
131:
132:            public void recordFolderUpdatedInLayout(IPerson person,
133:                    UserProfile profile, IUserLayoutFolderDescription folderDesc) {
134:                String msg = "Folder [" + folderDesc.getName() + ", "
135:                        + folderDesc.getId() + "] " + "was updated in layout "
136:                        + profile.getLayoutId() + " " + "by "
137:                        + getDisplayName(person) + " " + "at "
138:                        + new java.util.Date();
139:                outputMessage(fixMsg(msg));
140:            }
141:
142:            public void recordFolderMovedInLayout(IPerson person,
143:                    UserProfile profile, IUserLayoutFolderDescription folderDesc) {
144:                String msg = "Folder [" + folderDesc.getName() + ", "
145:                        + folderDesc.getId() + "] " + "was moved in layout "
146:                        + profile.getLayoutId() + " " + "by "
147:                        + getDisplayName(person) + " " + "at "
148:                        + new java.util.Date();
149:                outputMessage(fixMsg(msg));
150:            }
151:
152:            public void recordFolderRemovedFromLayout(IPerson person,
153:                    UserProfile profile, IUserLayoutFolderDescription folderDesc) {
154:                String msg = "Folder [" + folderDesc.getName() + ", "
155:                        + folderDesc.getId() + "] "
156:                        + "was removed from layout " + profile.getLayoutId()
157:                        + " " + "by " + getDisplayName(person) + " " + "at "
158:                        + new java.util.Date();
159:                outputMessage(fixMsg(msg));
160:            }
161:
162:            public void recordChannelInstantiated(IPerson person,
163:                    UserProfile profile,
164:                    IUserLayoutChannelDescription channelDesc) {
165:                String msg = "Channel [" + channelDesc.getName() + ", "
166:                        + channelDesc.getChannelPublishId() + ", "
167:                        + channelDesc.getChannelSubscribeId() + "] "
168:                        + "was instantiated in layout " + profile.getLayoutId()
169:                        + " " + "by " + getDisplayName(person) + " " + "at "
170:                        + new java.util.Date();
171:                outputMessage(fixMsg(msg));
172:            }
173:
174:            public void recordChannelRendered(IPerson person,
175:                    UserProfile profile,
176:                    IUserLayoutChannelDescription channelDesc) {
177:                String msg = "Channel [" + channelDesc.getName() + ", "
178:                        + channelDesc.getChannelPublishId() + ", "
179:                        + channelDesc.getChannelSubscribeId() + "] "
180:                        + "was rendered in layout " + profile.getLayoutId()
181:                        + " " + "by " + getDisplayName(person) + " " + "at "
182:                        + new java.util.Date();
183:                outputMessage(fixMsg(msg));
184:            }
185:
186:            public void recordChannelTargeted(IPerson person,
187:                    UserProfile profile,
188:                    IUserLayoutChannelDescription channelDesc) {
189:                String msg = "Channel [" + channelDesc.getName() + ", "
190:                        + channelDesc.getChannelPublishId() + ", "
191:                        + channelDesc.getChannelSubscribeId() + "] "
192:                        + "was targeted in layout " + profile.getLayoutId()
193:                        + " " + "by " + getDisplayName(person) + " " + "at "
194:                        + new java.util.Date();
195:                outputMessage(fixMsg(msg));
196:            }
197:
198:            /**
199:             * Outputs the message formulated according
200:             * to the stat being recorded.  Subclasses
201:             * have the responsibility of implementing 
202:             * this method.
203:             * @param message, the message to output
204:             */
205:            protected abstract void outputMessage(String message);
206:
207:            /**
208:             * Creates a name suitable for displaying in a
209:             * stats message.  Indicates if user is a "guest" user.
210:             * @param person, the person
211:             * @return name, the display name for the user
212:             */
213:            private String getDisplayName(IPerson person) {
214:                String name = null;
215:                if (person != null) {
216:                    String userName = (String) person
217:                            .getAttribute(IPerson.USERNAME);
218:                    if (person.isGuest()) {
219:                        name = "GUEST_USER (" + fixNull(userName) + ")";
220:                    } else {
221:                        String firstName = (String) person
222:                                .getAttribute("givenName");
223:                        String lastName = (String) person.getAttribute("sn");
224:                        name = fixNull(firstName) + " " + fixNull(lastName)
225:                                + " (" + fixNull(userName) + ")";
226:                    }
227:                } else {
228:                    name = "NULL_PERSON";
229:                }
230:                return name;
231:            }
232:
233:            /**
234:             * Replaces null String with an empty String
235:             * @param s, the string to fix
236:             * @return s, the fixed string
237:             */
238:            private String fixNull(String s) {
239:                return s == null ? "" : s;
240:            }
241:
242:            /**
243:             * Prepends a string to each message to make it
244:             * clear that it came from the LoggingStatsRecorder
245:             * @param msg, the message to log
246:             * @return msg, the message prepended with a string that
247:             * identifies the message as having come from a stats recorder
248:             */
249:            private String fixMsg(String msg) {
250:                return "STATS-RECORDER: " + msg;
251:            }
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.