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