public GeoServerHomePage() {
GeoServer gs = getGeoServer();
ContactInfo contact = gs.getGlobal().getContact();
//add some contact info
add(new ExternalLink("contactURL", contact.getOnlineResource())
.add( new Label("contactName", contact.getContactOrganization())));
{
String version = String.valueOf(new ResourceModel("version").getObject());
String contactEmail = contact.getContactEmail();
HashMap<String, String>params = new HashMap<String, String>();
params.put("version", version);
params.put("contactEmail", contactEmail);
Label label = new Label("footerMessage", new StringResourceModel("GeoServerHomePage.footer", this, new Model(params)));
label.setEscapeModelStrings(false);
add(label);
}
Authentication auth = getSession().getAuthentication();
if(isAdmin(auth)) {
Fragment f = new Fragment("catalogLinks", "catalogLinksFragment", this);
Catalog catalog = getCatalog();
f.add(new BookmarkablePageLink("layersLink", LayerPage.class)
.add(new Label( "nlayers", ""+catalog.getLayers().size())));
f.add(new BookmarkablePageLink("addLayerLink", NewLayerPage.class));
f.add(new BookmarkablePageLink("storesLink",StorePage.class)
.add(new Label( "nstores", ""+catalog.getStores(StoreInfo.class).size())));
f.add(new BookmarkablePageLink("addStoreLink", NewDataPage.class));
f.add(new BookmarkablePageLink("workspacesLink",WorkspacePage.class)
.add(new Label( "nworkspaces", ""+catalog.getWorkspaces().size())));
f.add(new BookmarkablePageLink("addWorkspaceLink", WorkspaceNewPage.class));
add(f);
} else {
Label placeHolder = new Label("catalogLinks");
placeHolder.setVisible(false);
add(placeHolder);
}
// when hacking this service listing code please refer to
// http://jira.codehaus.org/browse/GEOS-2114
ListView view = new ListView("services", getServices()) {
@Override
protected void populateItem(ListItem item) {
ServiceInfo service = (ServiceInfo) item.getModelObject();
final String serviceId = service.getId();
item.add( new Label("service", service.getId().toUpperCase()) );
item.add( new ListView( "versions", service.getVersions()) {
@Override
protected void populateItem(ListItem item) {
Version version = (Version) item.getModelObject();
ExternalLink link = new ExternalLink("link", "../ows?service=" + serviceId
+ "&version=" + version.toString() + "&request=GetCapabilities");
item.add( link );
link.add( new Label( "version", version.toString() ) );
}
});
}
};
add(view);