Source Code Cross Referenced for CurrentUser.java in  » Content-Management-System » contelligent » de » finix » contelligent » components » util » 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 » Content Management System » contelligent » de.finix.contelligent.components.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2006 C:1 Financial Services GmbH
003:         *
004:         * This software is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License Version 2.1, as published by the Free Software Foundation.
007:         *
008:         * This software is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011:         * Lesser General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU Lesser General Public
014:         * License along with this library; if not, write to the Free Software
015:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016:         */
017:
018:        package de.finix.contelligent.components.util;
019:
020:        import java.io.IOException;
021:        import java.io.Writer;
022:        import java.util.Collection;
023:        import java.util.Collections;
024:        import java.util.Map;
025:
026:        import de.finix.contelligent.CallData;
027:        import de.finix.contelligent.Component;
028:        import de.finix.contelligent.ComponentContext;
029:        import de.finix.contelligent.core.security.User;
030:        import de.finix.contelligent.logging.LoggingService;
031:        import de.finix.contelligent.render.ParameterDescription;
032:        import de.finix.contelligent.render.Renderable;
033:        import de.finix.contelligent.render.Renderer;
034:        import de.finix.contelligent.search.Metainfo;
035:        import de.finix.contelligent.util.StringUtils;
036:
037:        /**
038:         * A <code>CurrentUser</code> may be used to render some information about the
039:         * current user of the actual session. If rendered without parameter the
040:         * {@link User#getDisplayName display-name} of the user gets rendered, if the
041:         * parameter {@link #PARAM_KEY key} is used, the value of the parameter
042:         * determines what information gets rendered:
043:         * <UL>
044:         * <LI>'name' - the {@link User#getDisplayName display-name} of the user
045:         * <LI>'id' - the {@link User#getName id} of the user
046:         * <LI>'groupId' - the {@link User#getGroupId group-id} of the user
047:         * <LI>'roles' - the {@link User#getRoles roles} of the user in comma separated
048:         * value format
049:         * <LI>'principalString' - the {@link User#toPrincipalString full-id} of the
050:         * user that is user-id plus group-id
051:         * </UL>
052:         * <BR>
053:         * To render any additional user data use {@link UserHomeRenderer}.
054:         */
055:        public class CurrentUser implements  Component, Renderable, Renderer {
056:            final static org.apache.log4j.Logger log = LoggingService
057:                    .getLogger(CurrentUser.class);
058:
059:            final static private String PARAM_KEY = "key";
060:
061:            // default at index 0
062:            final static private String[] validKeys = new String[] { "name",
063:                    "id", "groupId", "roles", "principalString" };
064:
065:            final static private ParameterDescription[] parameters = new ParameterDescription[] { new ParameterDescription(
066:                    PARAM_KEY,
067:                    ("The key of the data to render, one of ["
068:                            + StringUtils.createCSV(validKeys, ',')
069:                            + "]. If rendered without parameter the display-name of the user gets rendered"
070:                            + " or else the value of the parameter determines what information gets rendered:\n"
071:                            + " 'name'              - the display-name of the user\n"
072:                            + " 'id'                - the id of the user\n"
073:                            + " 'groupId'           - the group-id of the user\n"
074:                            + " 'roles'             - the roles of the user in comma separated value format\n" + " 'principalString'   - the full-id of the user that is user-id plus group-id"),
075:                    false, true, validKeys) };
076:
077:            protected ComponentContext ctx;
078:
079:            public ParameterDescription[] getParameterDescription() {
080:                return parameters;
081:            }
082:
083:            /**
084:             * Implementation of {@link Component#postCreate}. This implementation
085:             * doesn't do anything.
086:             */
087:            public void postCreate() {
088:            }
089:
090:            /**
091:             * Implementation of {@link Component#setComponentContext}.
092:             */
093:            public void setComponentContext(ComponentContext ctx) {
094:                this .ctx = ctx;
095:            }
096:
097:            /**
098:             * Implementation of {@link Component#getComponentContext}.
099:             */
100:            public ComponentContext getComponentContext() {
101:                return ctx;
102:            }
103:
104:            /**
105:             * Implementation of {@link Component#isDynamic}. This implementation
106:             * always returns true.
107:             */
108:            public boolean isDynamic() {
109:                return true;
110:            }
111:
112:            /**
113:             * Implementation of {@link Component#mayChangeContent}. This
114:             * implementation always returns false.
115:             */
116:            public boolean mayChangeContent() {
117:                return false;
118:            }
119:
120:            /**
121:             * Implementation of {@link Component#putSearchMetainfo}. This
122:             * implementation doesn't do anything.
123:             */
124:            public void putSearchMetainfo(Metainfo metainfo, CallData callData) {
125:            }
126:
127:            /**
128:             * returns the path of this component as string. (without a trailing
129:             * separator!)
130:             */
131:            final public String toString() {
132:                if (ctx != null) {
133:                    return ctx.getPath().toString();
134:                } else {
135:                    return "CurrentUser (name unknown)";
136:                }
137:            }
138:
139:            public Renderer getRenderer() {
140:                return this ;
141:            }
142:
143:            public Collection getSensitiveCategories() {
144:                return Collections.EMPTY_SET;
145:            }
146:
147:            public void render(Writer writer, Map parameterMap,
148:                    CallData callData) throws IOException {
149:                String key = validKeys[0];
150:                if (parameterMap != null && parameterMap.containsKey(PARAM_KEY)) {
151:                    key = ((String[]) parameterMap.get(PARAM_KEY))[0];
152:                }
153:                User currentUser = callData.getUser();
154:                if ("name".equals(key)) {
155:                    if (log.isDebugEnabled())
156:                        log.debug("writing display-name of user '"
157:                                + currentUser + "' ...");
158:                    writer.write(currentUser.getDisplayName());
159:                } else if ("id".equals(key)) {
160:                    if (log.isDebugEnabled())
161:                        log.debug("writing id of user '" + currentUser
162:                                + "' ...");
163:                    writer.write(currentUser.getName());
164:                } else if ("groupId".equals(key)) {
165:                    if (log.isDebugEnabled())
166:                        log.debug("writing group-id of user '" + currentUser
167:                                + "' ...");
168:                    writer.write(currentUser.getGroupId());
169:                } else if ("roles".equals(key)) {
170:                    if (log.isDebugEnabled())
171:                        log.debug("writing roles of user '" + currentUser
172:                                + "' (in CSV format) ...");
173:                    writer.write(StringUtils.createCSV(currentUser.getRoles(),
174:                            ','));
175:                } else if ("principalString".equals(key)) {
176:                    if (log.isDebugEnabled())
177:                        log.debug("writing principal-string of user '"
178:                                + currentUser + "' ...");
179:                    writer.write(currentUser.toPrincipalString());
180:                } else {
181:                    // this should never be reached because system checks valid
182:                    // parameter values.
183:                    writer.write(currentUser.getDisplayName());
184:                }
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.