PortletDefinition def = PortletApplicationUtils.getPortletOrClone(app, paNodeBean.getName());
if (newLocale != null && newDescription != null)
{
InitParam param = def.getInitParam(initParam.getParamName());
Locale locale = new Locale(newLocale);
Description targetDescription = null;
for (Description description : param.getDescriptions())
{
if (description.getLocale().equals(locale))
{
targetDescription = description;
break;
}
}
if (targetDescription == null)
{
targetDescription = param.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 = PortletApplicationUtils.getPortletOrClone(app, paNodeBean.getName());
InitParam initParam = def.getInitParam(name);
if (initParam != null)
{
for (Iterator<Description> it = initParam.getDescriptions().iterator(); it.hasNext(); )
{
Description description = it.next();
for (IModel<DescriptionBean> descriptionBeanModel : fields)
{
if (descriptionBeanModel.getObject().getLocale().equals(description.getLocale()))
{
it.remove();
break;
}
}