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


001:        /* Copyright 2001 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.channels.UserPreferences;
007:
008:        import org.jasig.portal.ChannelRuntimeData;
009:        import org.jasig.portal.ChannelRuntimeProperties;
010:        import org.jasig.portal.ChannelStaticData;
011:        import org.jasig.portal.IPrivilegedChannel;
012:        import org.jasig.portal.IUserPreferencesManager;
013:        import org.jasig.portal.PortalControlStructures;
014:        import org.jasig.portal.PortalEvent;
015:        import org.jasig.portal.PortalException;
016:        import org.jasig.portal.StylesheetSet;
017:        import org.jasig.portal.ThemeStylesheetDescription;
018:        import org.jasig.portal.UserPreferences;
019:        import org.jasig.portal.UserProfile;
020:        import org.jasig.portal.layout.IUserLayoutManager;
021:        import org.jasig.portal.layout.IUserLayoutStore;
022:        import org.jasig.portal.layout.UserLayoutStoreFactory;
023:        import org.apache.commons.logging.Log;
024:        import org.apache.commons.logging.LogFactory;
025:        import org.xml.sax.ContentHandler;
026:
027:        /** 
028:         * CUserPreferences manages User Layout, user preferences and profiles.
029:         * 
030:         * @author Peter Kharchenko, pkharchenko@unicon.net
031:         * @author Ken Weiner, kweiner@unicon.net
032:         * @version $Revision: 35755 $
033:         */
034:        public class CUserPreferences implements  IPrivilegedChannel {
035:            private static final Log log = LogFactory
036:                    .getLog(CUserPreferences.class);
037:            IUserPreferencesManager upm;
038:            ChannelRuntimeData runtimeData = null;
039:            ChannelStaticData staticData = null;
040:            StylesheetSet set = null;
041:            private static final String sslLocation = "/org/jasig/portal/channels/CUserPreferences/CUserPreferences.ssl";
042:            private UserPreferences up = null;
043:            public static final int MANAGE_PREFERENCES = 1;
044:            public static final int MANAGE_PROFILES = 2;
045:            IPrivilegedChannel internalState = null;
046:            IPrivilegedChannel managePreferences = null;
047:            IPrivilegedChannel manageProfiles = null;
048:            protected IUserLayoutStore ulsdb;
049:            private boolean initialized = false;
050:            UserProfile editedProfile = null;
051:
052:            public CUserPreferences() throws PortalException {
053:                this .runtimeData = new ChannelRuntimeData();
054:                this .set = new StylesheetSet(this .getClass().getResource(
055:                        sslLocation).toString());
056:                this .set.setMediaProps("/properties/media.properties");
057:
058:                manageProfiles = new ManageProfilesState(this );
059:                ulsdb = UserLayoutStoreFactory.getUserLayoutStoreImpl();
060:            }
061:
062:            protected IUserPreferencesManager getUserPreferencesManager() {
063:                return upm;
064:            }
065:
066:            protected IUserLayoutManager getUserLayoutManager() {
067:                return getUserPreferencesManager().getUserLayoutManager();
068:            }
069:
070:            protected UserPreferences getCurrentUserPreferences() {
071:                return up;
072:            }
073:
074:            protected ChannelRuntimeData getRuntimeData() {
075:                return runtimeData;
076:            }
077:
078:            protected StylesheetSet getStylesheetSet() {
079:                return set;
080:            }
081:
082:            public void setPortalControlStructures(PortalControlStructures pcs)
083:                    throws PortalException {
084:                if (upm == null)
085:                    upm = pcs.getUserPreferencesManager();
086:                if (up == null)
087:                    up = upm.getUserPreferencesCopy();
088:                // instantiate the browse state here
089:
090:                if (!initialized) {
091:                    instantiateManagePreferencesState(up.getProfile());
092:                    // Initial state should be manage preferences
093:                    internalState = managePreferences;
094:                    internalState.setStaticData(staticData);
095:                    editedProfile = up.getProfile();
096:                    initialized = true;
097:                }
098:                if (internalState != null) {
099:                    internalState.setPortalControlStructures(pcs);
100:                }
101:            }
102:
103:            /**
104:             * Instantiates appropriate managePreferences object.
105:             *
106:             * @param profile profile for which preferences are to be edited
107:             */
108:            private void instantiateManagePreferencesState(UserProfile profile) {
109:                try {
110:                    ThemeStylesheetDescription tsd = ulsdb
111:                            .getThemeStylesheetDescription(profile
112:                                    .getThemeStylesheetId());
113:                    if (tsd != null) {
114:                        String cupmClass = tsd
115:                                .getCustomUserPreferencesManagerClass();
116:                        managePreferences = (IPrivilegedChannel) Class.forName(
117:                                cupmClass).newInstance();
118:                        ((BaseState) managePreferences).setContext(this );
119:                    } else {
120:                        log
121:                                .error("CUserPreferences::instantiateManagePreferencesState() : unable to retrieve theme stylesheet description. stylesheetId="
122:                                        + profile.getThemeStylesheetId());
123:                        managePreferences = new GPreferencesState(this );
124:                    }
125:                } catch (Exception e) {
126:                    log.error("Error instantiating user profile [" + profile
127:                            + "]", e);
128:                    managePreferences = new GPreferencesState(this );
129:                }
130:            }
131:
132:            /** Returns channel runtime properties
133:             * @return handle to runtime properties
134:             */
135:            public ChannelRuntimeProperties getRuntimeProperties() {
136:                // Channel will always render, so the default values are ok
137:                return new ChannelRuntimeProperties();
138:            }
139:
140:            /** Processes layout-level events coming from the portal
141:             * @param ev a portal layout event
142:             */
143:            public void receiveEvent(PortalEvent ev) {
144:                // no events for this channel
145:                if (internalState != null) {
146:                    internalState.receiveEvent(ev);
147:                }
148:            }
149:
150:            /** Receive static channel data from the portal
151:             * @param sd static channel data
152:             */
153:            public void setStaticData(ChannelStaticData sd)
154:                    throws PortalException {
155:                this .staticData = sd;
156:            }
157:
158:            /** CUserPreferences listens for an HttpRequestParameter "userPreferencesAction"
159:             * and based on its value changes state between profile management and layout/stylesheet
160:             * preferences.
161:             * @param rd handle to channel runtime data
162:             */
163:            public void setRuntimeData(ChannelRuntimeData rd)
164:                    throws PortalException {
165:                this .runtimeData = rd;
166:                String action = runtimeData
167:                        .getParameter("userPreferencesAction");
168:                if (action != null) {
169:                    Integer profileId = null;
170:                    try {
171:                        profileId = new Integer(runtimeData
172:                                .getParameter("profileId"));
173:                    } catch (NumberFormatException nfe) {
174:                    }
175:                    ;
176:                    boolean systemProfile = false;
177:                    if (profileId != null) {
178:                        String profileType = runtimeData
179:                                .getParameter("profileType");
180:                        if (profileType != null && profileType.equals("system"))
181:                            systemProfile = true;
182:                    }
183:
184:                    if (action.equals("manageProfiles")) {
185:                        this .internalState = manageProfiles;
186:                    } else if (action.equals("managePreferences")) {
187:                        if (profileId != null) {
188:                            // find the profile mapping
189:                            try {
190:                                if (systemProfile) {
191:                                    UserProfile newProfile = ulsdb
192:                                            .getSystemProfileById(profileId
193:                                                    .intValue());
194:                                    if (newProfile != null
195:                                            && (!(editedProfile
196:                                                    .isSystemProfile() && editedProfile
197:                                                    .getProfileId() == newProfile
198:                                                    .getProfileId()))) {
199:                                        // new profile has been selected
200:                                        editedProfile = newProfile;
201:                                        instantiateManagePreferencesState(editedProfile);
202:                                    }
203:                                } else {
204:                                    UserProfile newProfile = ulsdb
205:                                            .getUserProfileById(
206:                                                    upm.getPerson(), profileId
207:                                                            .intValue());
208:                                    if (newProfile != null
209:                                            && (editedProfile.isSystemProfile() || (editedProfile
210:                                                    .getProfileId() != newProfile
211:                                                    .getProfileId()))) {
212:                                        // new profile has been selected
213:                                        editedProfile = newProfile;
214:                                        instantiateManagePreferencesState(editedProfile);
215:                                    }
216:                                }
217:                            } catch (Exception e) {
218:                                throw new PortalException(e);
219:                            }
220:                        }
221:
222:                        if (editedProfile == null) {
223:                            editedProfile = up.getProfile();
224:                        }
225:
226:                        //        managePreferences.setRuntimeData(rd);
227:                        this .internalState = managePreferences;
228:                    }
229:                }
230:
231:                if (internalState != null) {
232:                    internalState.setRuntimeData(rd);
233:                }
234:            }
235:
236:            /**
237:             * Output channel content to the portal
238:             * @param out a sax document handler
239:             */
240:            public void renderXML(ContentHandler out) throws PortalException {
241:                internalState.renderXML(out);
242:            }
243:
244:            protected UserPreferences getUserPreferencesFromStore(
245:                    UserProfile profile) throws Exception {
246:                up = ulsdb.getUserPreferences(getUserPreferencesManager()
247:                        .getPerson(), profile);
248:                up.synchronizeWithUserLayoutXML(UserLayoutStoreFactory
249:                        .getUserLayoutStoreImpl().getUserLayout(
250:                                getUserPreferencesManager().getPerson(),
251:                                getCurrentUserPreferences().getProfile()));
252:                return up;
253:            }
254:
255:            protected UserProfile getEditedUserProfile() {
256:                return editedProfile;
257:            }
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.