1
22
23 package com.liferay.portal.velocity;
24
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27 import com.liferay.portal.model.PortletConstants;
28 import com.liferay.portlet.PortletPreferencesImpl;
29 import com.liferay.portlet.PortletPreferencesSerializer;
30
31 import javax.portlet.ReadOnlyException;
32
33
38 public class VelocityPortletPreferences {
39
40 public VelocityPortletPreferences() {
41 _preferencesImpl = new PortletPreferencesImpl();
42 }
43
44 public void reset() {
45 _preferencesImpl.reset();
46 }
47
48 public void setValue(String key, String value) throws ReadOnlyException {
49 _preferencesImpl.setValue(key, value);
50 }
51
52 public void setValues(String key, String[] values)
53 throws ReadOnlyException {
54
55 _preferencesImpl.setValues(key, values);
56 }
57
58 public String toString() {
59 try {
60 return PortletPreferencesSerializer.toXML(_preferencesImpl);
61 }
62 catch (Exception e) {
63 _log.error(e, e);
64
65 return PortletConstants.DEFAULT_PREFERENCES;
66 }
67 }
68
69 private static Log _log =
70 LogFactoryUtil.getLog(VelocityPortletPreferences.class);
71
72 private PortletPreferencesImpl _preferencesImpl;
73
74 }