@Override
public IDataProvider<DescriptionBean> getDataProvider()
{
PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
PortletDefinition def = app.getPortlet(paNodeBean.getName());
final SecurityRoleRef secRoleRef = def.getSecurityRoleRef(securityRoleRef.getRoleName());
List<DescriptionBean> list = new ArrayList<DescriptionBean>();
for (Description description : secRoleRef.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()
{
PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
PortletDefinition def = app.getPortlet(paNodeBean.getName());
if (newLocale != null && newDescription != null)
{
SecurityRoleRef secRoleRef = def.getSecurityRoleRef(securityRoleRef.getRoleName());
Locale locale = new Locale(newLocale);
Description targetDescription = null;
for (Description description : secRoleRef.getDescriptions())
{
if (description.getLocale().equals(locale))
{
targetDescription = description;
break;
}
}
if (targetDescription == null)
{
targetDescription = securityRoleRef.addDescription(newLocale);
}
targetDescription.setDescription(newDescription);
newLocale = null;
newDescription = null;
}
FeedbackPanel feed = (FeedbackPanel) getPage().get("feedback");
try
{
registry.savePortletDefinition(def);
StringResourceModel resModel = new StringResourceModel("pam.details.action.status.portlet.saveOK", this, null, new Object [] { paNodeBean.getName() } );
feed.info(resModel.getString());
}
catch (RegistryException e)
{
logger.error("Failed to save portlet definition.", e);
StringResourceModel resModel = new StringResourceModel("pam.details.action.status.portlet.saveFailure", this, null, new Object [] { paNodeBean.getName(), 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());
PortletDefinition def = app.getPortlet(paNodeBean.getName());
SecurityRoleRef secRoleRef = def.getSecurityRoleRef(securityRoleRef.getRoleName());
if (secRoleRef != null)
{
for (Iterator<Description> it = secRoleRef.getDescriptions().iterator(); it.hasNext(); )
{