1
22
23 package com.liferay.portlet;
24
25 import com.liferay.portal.util.PropsValues;
26
27 import java.io.IOException;
28 import java.io.Serializable;
29
30 import java.util.Enumeration;
31 import java.util.Map;
32
33 import javax.portlet.PortletPreferences;
34 import javax.portlet.ReadOnlyException;
35 import javax.portlet.ValidatorException;
36
37
43 public class PortletPreferencesWrapper
44 implements PortletPreferences, Serializable {
45
46 public PortletPreferencesWrapper(PortletPreferences prefs, boolean action) {
47 _prefs = prefs;
48 _action = action;
49 }
50
51 public Map getMap() {
52 return _prefs.getMap();
53 }
54
55 public Enumeration getNames() {
56 return _prefs.getNames();
57 }
58
59 public String getValue(String key, String def) {
60 return _prefs.getValue(key, def);
61 }
62
63 public void setValue(String key, String value) throws ReadOnlyException {
64 _prefs.setValue(key, value);
65 }
66
67 public String[] getValues(String key, String[] def) {
68 return _prefs.getValues(key, def);
69 }
70
71 public void setValues(String key, String[] values)
72 throws ReadOnlyException {
73
74 _prefs.setValues(key, values);
75 }
76
77 public boolean isReadOnly(String key) {
78 return _prefs.isReadOnly(key);
79 }
80
81 public void reset(String key) throws ReadOnlyException {
82 _prefs.reset(key);
83 }
84
85 public void store() throws IOException, ValidatorException {
86 if (PropsValues.TCK_URL) {
87
88
90 if (_action) {
91 _prefs.store();
92 }
93 else {
94 throw new IllegalStateException(
95 "Preferences cannot be stored inside a render call");
96 }
97 }
98 else {
99
100
102 _prefs.store();
103 }
104 }
105
106 public PortletPreferencesImpl getPreferencesImpl() {
107 return (PortletPreferencesImpl)_prefs;
108 }
109
110 private PortletPreferences _prefs = null;
111 private boolean _action;
112
113 }