01: /*
02: * Copyright ? 2006 Sun Microsystems, Inc. All rights reserved.
03: *
04: * Sun Microsystems, Inc. has intellectual property rights relating to
05: * technology embodied in the product that is described in this document.
06: * In particular, and without limitation, these intellectual property
07: * rights may include one or more of the U.S. patents listed at
08: * http://www.sun.com/patents and one or more additional patents or
09: * pending patent applications in the U.S. and in other countries.
10: *
11: * U.S. Government Rights - Commercial software. Government users are subject
12: * to the Sun Microsystems, Inc. standard license agreement and applicable
13: * provisions of the FAR and its supplements. Use is subject to license terms.
14: * This distribution may include materials developed by third parties.
15: * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
16: * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
17: */
18: package com.sun.portal.app.blog.env;
19:
20: import com.sun.portal.app.blog.BlogPortletException;
21: import com.sun.portal.portlet.service.provision.PortletProvisionPreferences;
22: import com.sun.portal.portlet.service.provision.PortletProvisionPreferencesException;
23: import java.util.List;
24:
25: /**
26: * Implementation of Preferences running in a portlet environment.
27: */
28: public class PortletProvisionPrefs extends AbstractPrefs {
29: private PortletProvisionPreferences ppp;
30:
31: public PortletProvisionPrefs(PortletProvisionPreferences ppp) {
32: this .ppp = ppp;
33: }
34:
35: protected String getPreference(String key)
36: throws BlogPortletException {
37: try {
38: List vals = ppp.getValues(key);
39: if (vals == null || vals.size() == 0) {
40: return null;
41: }
42: return (String) vals.get(0);
43: } catch (PortletProvisionPreferencesException ppe) {
44: throw new BlogPortletException(ppe);
45: }
46: }
47:
48: protected void setPreference(String key, String val)
49: throws BlogPortletException {
50: try {
51: ppp.setValue(key, val);
52: } catch (PortletProvisionPreferencesException ppe) {
53: throw new BlogPortletException(ppe);
54: }
55: }
56:
57: public void store() throws BlogPortletException {
58: // nothing
59: }
60: }
|