{
super(id);
detailList = new ArrayList<KeyVal>();
JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
PortletApplication app = locator.getPortletRegistry().getPortletApplication(paNodeBean.getApplicationName());
detailList.add(new KeyVal("Name", app.getName()));
detailList.add(new KeyVal("Version", app.getVersion()));
detailList.add(new KeyVal("Description", getDescription(app)));
detailList.add(new KeyVal("Type", getType(app)));
detailList.add(new KeyVal("Services", new Object()
{
String toString(Iterator<JetspeedServiceReference> it)
{
StringBuffer buffer = new StringBuffer();
while (it.hasNext())
{
buffer.append(it.next().getName() + "<br/>");
}
return buffer.toString();
}
}.toString(app.getJetspeedServices().iterator())));
final RefreshingView<KeyVal> dataRepeater = new RefreshingView<KeyVal>("data", new PropertyModel<List<KeyVal>>(this, "detailList"))
{
@Override
protected void populateItem(Item<KeyVal> item)
{
final KeyVal field = item.getModelObject();
item.add(new Label("name", field.getKey()));
item.add(new Label("value", field.getValue()).setEscapeModelStrings(false));
}
@Override
protected Iterator<IModel<KeyVal>> getItemModels()
{
List<KeyVal> list = (List<KeyVal>) getDefaultModelObject();
return new ModelIteratorAdapter<KeyVal>(list.iterator())
{
@Override
protected IModel<KeyVal> model(KeyVal object)
{
return new Model<KeyVal>(object);
}
};
}
};
jetspeedSecurityContraintNames = new ArrayList<String>(Arrays.asList(""));
PageManager pageManager = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPageManager();
try
{
for (Object secConstDefObj : pageManager.getPageSecurity().getSecurityConstraintsDefs())
{
SecurityConstraintsDef secConstDef = (SecurityConstraintsDef) secConstDefObj;
jetspeedSecurityContraintNames.add(secConstDef.getName());
}
}
catch (Exception e)
{
logger.error("Failed to retrieve jetspeed security constraint defs from page manager.", e);
}
jetspeedSecurityConstraint = app.getJetspeedSecurityConstraint();
Form form = new Form("form");
form.add(dataRepeater);
form.add(new DropDownChoice<String>("jetspeedConstraint", new PropertyModel<String>(this, "jetspeedSecurityConstraint"), jetspeedSecurityContraintNames));
form.add(new Button("jsecSave", 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());
app.setJetspeedSecurityConstraint("".equals(jetspeedSecurityConstraint) ? null : jetspeedSecurityConstraint);
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 jetspeed security constraint defs of application.", e);
StringResourceModel resModel = new StringResourceModel("pam.details.action.status.application.saveFailure", this, null, new Object [] { paNodeBean.getApplicationName(), e.getMessage() } );
feed.info(resModel.getString());
}
}
});
form.add(new Label("resourceBundle", app.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());
PortletFactory factory = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletFactory();
factory.reloadResourceBundles(app);
}
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(), e.getMessage() } );
feed.info(resModel.getString());
}
}
};
reloadResourceBundlesButton.add(new JavascriptEventConfirmation("onclick", new ResourceModel("pam.details.resource.bundle.reload.confirm")));
reloadResourceBundlesButton.setEnabled(!StringUtils.isBlank(app.getResourceBundle()));
form.add(reloadResourceBundlesButton);
Button refreshSearchIndexButton = new Button("refreshSearchIndex", new ResourceModel("pam.details.search.index.refresh"))
{
@Override
public void onSubmit()
{
FeedbackPanel feed = (FeedbackPanel) getPage().get("feedback");
try
{
SearchEngine searchEngine = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getSearchEngine();
PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
List<PortletDefinition> portletDefList = app.getPortlets();
List<Object> list = new ArrayList<Object>();
list.addAll(portletDefList);
list.add(app);