}
@Override
public void delete(IModel<DisplayNameBean>[] 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());
for (Iterator<DisplayName> it = def.getDisplayNames().iterator(); it.hasNext(); )
{
DisplayName displayName = it.next();
for (IModel<DisplayNameBean> displayNameBeanModel : fields)
{
if (displayNameBeanModel.getObject().getLocale().equals(displayName.getLocale()))
{
it.remove();
break;
}
}
}
registry.savePortletDefinition(def);
StringResourceModel resModel = new StringResourceModel("pam.details.action.status.portlet.saveOK", this, null, new Object [] { paNodeBean.getName() } );
feed.info(resModel.getString());
}
catch (FailedToStorePortletDefinitionException 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
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 && newDisplayName != null)
{
Locale locale = new Locale(newLocale);
DisplayName targetDisplayName = null;
for (DisplayName displayName : def.getDisplayNames())
{
if (displayName.getLocale().equals(locale))
{
targetDisplayName = displayName;
break;
}
}
if (targetDisplayName == null)
{
targetDisplayName = def.addDisplayName(newLocale);
}
targetDisplayName.setDisplayName(newDisplayName);
newLocale = null;
newDisplayName = 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());
}
}
};
}
});
form.add(new Button("save", new ResourceModel("pam.details.action.save"))
{
@Override
public void onSubmit()
{
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());
def.setExpirationCache(getExpirationCache().intValue());
registry.savePortletDefinition(def);
StringResourceModel resModel = new StringResourceModel("pam.details.action.status.portlet.saveOK", this, null, new Object [] { paNodeBean.getName() } );
feed.info(resModel.getString());
}
catch (FailedToStorePortletDefinitionException e)
{
logger.error("Failed to store 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());
}
}
});
form.add(new Label("resourceBundle", definition.getResourceBundle()));
Button reloadResourceBundlesButton = new Button("reloadResourceBundle", new ResourceModel("pam.details.resource.bundle.reload"))
{
@Override
public void onSubmit()
{
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());
PortletFactory factory = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletFactory();
factory.reloadResourceBundles(def);
}
catch (Exception e)
{
logger.error("Failed to reload the resource bundle of application.", e);
StringResourceModel resModel = new StringResourceModel("pam.details.action.status.resource.bundle.reloadFailure", this, null, new Object [] { paNodeBean.getApplicationName() + "::" + paNodeBean.getName(), e.getMessage() } );
feed.info(resModel.getString());
}
}
};
reloadResourceBundlesButton.add(new JavascriptEventConfirmation("onclick", new ResourceModel("pam.details.resource.bundle.reload.confirm")));