if(name != null)
{
String description = actionRequest.getParameter("description");
String locale = actionRequest.getParameter("locale");
ParameterComposite parameter = (ParameterComposite)portlet.getInitParameterSet().get(name);
if(parameter == null)
{
String value = actionRequest.getParameter("value");
parameter = portlet.addInitParameter(name, value, description, new Locale(locale));
}
else
{
parameter.addDescription(new Locale(locale), description);
}
registry.savePortletDefinition(portlet);
}
}
else if(action.equals("edit_parameter"))
{
String[] paramIds = actionRequest.getParameterValues("parameter_edit_id");
if(paramIds != null)
{
for(int i=0; i<paramIds.length; i++)
{
String paramId = paramIds[i];
ParameterComposite param = (ParameterComposite) portlet.getInitParameterSet().get(paramId);
String value = actionRequest.getParameter(paramId + ":value");
param.setValue(value);
int index = 0;
Iterator descIter = param.getDescriptionSet().iterator();
while (descIter.hasNext())
{
MutableDescription description = (MutableDescription) descIter.next();
String descParam = actionRequest.getParameter(paramId + ":description:" + index);
//changing locale not allowed.
if(descParam != null)
{
if(descParam.length() == 0)
{
descIter.remove();
}
else if(!descParam.equals(description.getDescription()))
{
description.setDescription(descParam);
}
}
index++;
}
}
}
registry.savePortletDefinition(portlet);
}
else if(action.equals("remove_parameter"))
{
String[] paramIds = actionRequest.getParameterValues("parameter_remove_id");
if(paramIds != null)
{
Iterator paramIter = portlet.getInitParameterSet().iterator();
while (paramIter.hasNext())
{
ParameterComposite param = (ParameterComposite) paramIter.next();
for(int i=0; i<paramIds.length; i++)
{
String paramId = paramIds[i];
if(param.getName().equals(paramId))
{
paramIter.remove();
break;
}
}