@Override
public IDataProvider<DescriptionBean> getDataProvider()
{
JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
PortletApplication app = locator.getPortletRegistry().getPortletApplication(paNodeBean.getApplicationName());
final UserAttribute attribute = app.getUserAttribute(userAttr.getName());
List<DescriptionBean> list = new ArrayList<DescriptionBean>();
for (Description description : attribute.getDescriptions())
{
list.add(new DescriptionBean(description));
}
return new ListDataProvider<DescriptionBean>(list);
}
@Override
protected Button saveButton(String componentId)
{
return new Button(componentId)
{
@Override
public void onSubmit()
{
FeedbackPanel feed = (FeedbackPanel) getPage().get("feedback");
try
{
PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
if (newLocale != null && newDescription != null)
{
UserAttribute attr = app.getUserAttribute(userAttr.getName());
Locale locale = new Locale(newLocale);
Description targetDescription = null;
for (Description description : attr.getDescriptions())
{
if (description.getLocale().equals(locale))
{
targetDescription = description;
break;
}
}
if (targetDescription == null)
{
targetDescription = attr.addDescription(newLocale);
}
targetDescription.setDescription(newDescription);
newLocale = null;
newDescription = null;
}
registry.updatePortletApplication(app);
StringResourceModel resModel = new StringResourceModel("pam.details.action.status.application.saveOK", this, null, new Object [] { paNodeBean.getApplicationName() } );
feed.info(resModel.getString());
}
catch (RegistryException e)
{
logger.error("Failed to update portlet application.", e);
StringResourceModel resModel = new StringResourceModel("pam.details.action.status.application.saveFailure", this, null, new Object [] { paNodeBean.getApplicationName(), e.getMessage() } );
feed.info(resModel.getString());
}
}
};
}
@Override
public void delete(IModel<DescriptionBean>[] fields)
{
FeedbackPanel feed = (FeedbackPanel) getPage().get("feedback");
try
{
PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
UserAttribute attr = app.getUserAttribute(name);
if (attr != null)
{
for (Iterator<Description> it = attr.getDescriptions().iterator(); it.hasNext(); )
{
Description description = it.next();
for (IModel<DescriptionBean> descriptionBeanModel : fields)
{