MutablePortletApplication mpa = registry.getPortletApplication(paName);
boolean modified = false;
Iterator userAttrIter = mpa.getUserAttributes().iterator();
while (userAttrIter.hasNext())
{
UserAttribute userAttr = (UserAttribute) userAttrIter.next();
userAttrName = userAttr.getName();
String description = actionRequest.getParameter(userAttrName + ":description");
if(!userAttr.getDescription().equals(description))
{
userAttr.setDescription(description);
modified = true;
}
}
if (modified)
{
registry.updatePortletApplication(mpa);
}
}
catch (RegistryException e)
{
throw new PortletException("Failed update user attribute: " + userAttrName, e);
}
}
else if(action.equals("add_user_attribute"))
{
String userAttrName = actionRequest.getParameter("user_attr_name");
String userAttrDesc = actionRequest.getParameter("user_attr_desc");
if (userAttrName != null && userAttrName.trim().length() > 0)
{
try
{
MutablePortletApplication mpa = registry.getPortletApplication(paName);
mpa.addUserAttribute(userAttrName, userAttrDesc);
registry.updatePortletApplication(mpa);
}
catch (RegistryException e)
{
throw new PortletException("Failed add user attribute: " + userAttrName, e);
}
}
}
else if(action.equals("remove_user_attribute"))
{
String[] userAttrNames = actionRequest.getParameterValues("user_attr_id");
if(userAttrNames != null)
{
String userAttrName = "";
try
{
int count = 0;
MutablePortletApplication mpa = registry.getPortletApplication(paName);
Iterator userAttrIter = mpa.getUserAttributes().iterator();
while (userAttrIter.hasNext())
{
UserAttribute userAttr = (UserAttribute) userAttrIter.next();
for(int ix = 0; ix < userAttrNames.length; ix++)
{
userAttrName = userAttrNames[ix];
if(userAttr.getName().equals(userAttrName))
{
userAttrIter.remove();
count++;
break;
}