01: /*
02: * (C) Copyright 2000 - 2005 Nabh Information Systems, Inc.
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: */
19:
20: package com.nabhinc.portlet.useradmin;
21:
22: import java.io.IOException;
23: import java.rmi.RemoteException;
24:
25: import javax.portlet.PortletException;
26: import javax.portlet.RenderRequest;
27: import javax.portlet.RenderResponse;
28:
29: import com.nabhinc.portal.api.PortalInformationStore;
30: import com.nabhinc.portal.api.PortalInformationStoreLocator;
31: import com.nabhinc.portal.model.UserPreferences;
32: import com.nabhinc.portlet.mvcportlet.core.BaseRequestProcessor;
33: import com.nabhinc.portlet.mvcportlet.core.RenderConfig;
34: import com.nabhinc.portlet.mvcportlet.core.RenderProcessor;
35:
36: /**
37: *
38: *
39: * @author Padmanabh Dabke
40: * (c) 2007 Nabh Information Systems, Inc. All Rights Reserved.
41: */
42: public class UserPreferenceManager extends BaseRequestProcessor
43: implements RenderProcessor {
44:
45: public String process(RenderRequest request,
46: RenderResponse response, RenderConfig renderConfig)
47: throws PortletException, IOException {
48:
49: String username = request.getRemoteUser();
50: if (username == null)
51: return "unlogged-user";
52:
53: try {
54: PortalInformationStore storeInfo = PortalInformationStoreLocator
55: .getPortalInformationStore();
56: UserPreferences userPref = storeInfo
57: .getUserPreferences(username);
58: if (userPref == null)
59: userPref = new UserPreferences();
60: //request.setAttribute("user_locale", userPref.getPreferredLocale());
61: //request.setAttribute("user_timezone", userPref.getTimezone());
62: request.setAttribute("showemail", Boolean.toString(userPref
63: .isShowEmail()));
64: request.setAttribute("showname", Boolean.toString(userPref
65: .isShowName()));
66: request.setAttribute("user_profile.user_preferences",
67: userPref);
68: return "success";
69: } catch (RemoteException ex) {
70: throw new PortletException(
71: "Failed to retrieve user preferences.", ex);
72: }
73: }
74: }
|