throws SystemException {
try {
Map preferences = prefs.getPreferences();
DocumentFactory docFactory = DocumentFactory.getInstance();
Element portletPreferences =
docFactory.createElement("portlet-preferences");
Iterator itr = preferences.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry entry = (Map.Entry)itr.next();
Preference preference = (Preference)entry.getValue();
Element prefEl = docFactory.createElement("preference");
Element nameEl = docFactory.createElement("name");
nameEl.addText(preference.getName());
prefEl.add(nameEl);
String[] values = preference.getValues();
for (int i = 0; i < values.length; i++) {
Element valueEl = docFactory.createElement("value");
valueEl.addText(values[i]);
prefEl.add(valueEl);
}
if (preference.isReadOnly()) {
Element valueEl = docFactory.createElement("read-only");
valueEl.addText("true");
}
portletPreferences.add(prefEl);
}