{
super(id);
this.paNodeBean = paNodeBeanParam;
PortletApplication app = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry().getPortletApplication(this.paNodeBean.getApplicationName());
PortletDefinition definition = app.getPortlet(this.paNodeBean.getName());
setExpirationCache(new Integer(definition.getExpirationCache()));
Form form = new Form("form");
form.add(new TextField<Integer>("expirationCache", new PropertyModel<Integer>(this, "expirationCache")));
form.add(new Label("uniqueName", definition.getUniqueName()));
form.add(new Label("preferenceValidator", definition.getPreferenceValidatorClassname()));
form.add(new Label("className", definition.getPortletClass()));
JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
form.add(new LocalizedDisplayNameEditor("localizationEditor", locator, paNodeBean)
{
@Override
public IDataProvider<DisplayNameBean> getDataProvider()
{
PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
PortletDefinition def = app.getPortlet(paNodeBean.getName());
List<DisplayNameBean> list = new LinkedList<DisplayNameBean>();
for (DisplayName displayName : def.getDisplayNames())
{
list.add(new DisplayNameBean(displayName));
}
return new ListDataProvider<DisplayNameBean>(list);
}
@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)
{