@SuppressWarnings({"rawtypes", "unchecked"})
  public GeoServerHomePage() {
    GeoServer gs = getGeoServer();
    ContactInfo contact = gs.getGlobal().getSettings().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 == null ? "*****@*****.**" : 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)) {
      Stopwatch sw = Stopwatch.createStarted();
      Fragment f = new Fragment("catalogLinks", "catalogLinksFragment", this);
      Catalog catalog = getCatalog();

      NumberFormat numberFormat = NumberFormat.getIntegerInstance(getLocale());
      numberFormat.setGroupingUsed(true);

      final Filter allLayers = acceptAll();
      final Filter allStores = acceptAll();
      final Filter allWorkspaces = acceptAll();

      final int layerCount = catalog.count(LayerInfo.class, allLayers);
      final int storesCount = catalog.count(StoreInfo.class, allStores);
      final int wsCount = catalog.count(WorkspaceInfo.class, allWorkspaces);

      f.add(
          new BookmarkablePageLink("layersLink", LayerPage.class)
              .add(new Label("nlayers", numberFormat.format(layerCount))));
      f.add(new BookmarkablePageLink("addLayerLink", NewLayerPage.class));

      f.add(
          new BookmarkablePageLink("storesLink", StorePage.class)
              .add(new Label("nstores", numberFormat.format(storesCount))));
      f.add(new BookmarkablePageLink("addStoreLink", NewDataPage.class));

      f.add(
          new BookmarkablePageLink("workspacesLink", WorkspacePage.class)
              .add(new Label("nworkspaces", numberFormat.format(wsCount))));
      f.add(new BookmarkablePageLink("addWorkspaceLink", WorkspaceNewPage.class));
      add(f);

      sw.stop();
    } else {
      Label placeHolder = new Label("catalogLinks");
      placeHolder.setVisible(false);
      add(placeHolder);
    }

    final IModel<List<GeoServerHomePageContentProvider>> contentProviders;
    contentProviders = getContentProviders(GeoServerHomePageContentProvider.class);
    ListView<GeoServerHomePageContentProvider> contentView =
        new ListView<GeoServerHomePageContentProvider>("contributedContent", contentProviders) {
          private static final long serialVersionUID = 1L;

          @Override
          protected void populateItem(ListItem<GeoServerHomePageContentProvider> item) {
            GeoServerHomePageContentProvider provider = item.getModelObject();
            Component extraContent = provider.getPageBodyComponent("contentList");
            if (null == extraContent) {
              Label placeHolder = new Label("contentList");
              placeHolder.setVisible(false);
              extraContent = placeHolder;
            }
            item.add(extraContent);
          }
        };
    add(contentView);

    final IModel<List<CapabilitiesHomePageLinkProvider>> capsProviders;
    capsProviders = getContentProviders(CapabilitiesHomePageLinkProvider.class);

    ListView<CapabilitiesHomePageLinkProvider> capsView =
        new ListView<CapabilitiesHomePageLinkProvider>("providedCaps", capsProviders) {
          private static final long serialVersionUID = 1L;

          @Override
          protected void populateItem(ListItem<CapabilitiesHomePageLinkProvider> item) {
            CapabilitiesHomePageLinkProvider provider = item.getModelObject();
            Component capsList = provider.getCapabilitiesComponent("capsList");
            item.add(capsList);
          }
        };
    add(capsView);
  }
    /**
     * Handles contacts.
     *
     * @param config the service.
     */
    private void handleContact() {
      final GeoServer gs = wcs.getGeoServer();
      String tmp = "";

      SettingsInfo settings = gs.getSettings();
      ContactInfo contact = settings.getContact();

      if (((contact != null) && (contact.getContactPerson() != ""))
          || ((contact.getContactOrganization() != null)
              && (contact.getContactOrganization() != ""))) {
        start("wcs:responsibleParty");

        tmp = contact.getContactPerson();
        if ((tmp != null) && (tmp != "")) {
          element("wcs:individualName", tmp);
        } else {
          // not optional
          element("wcs:individualName", "");
        }

        tmp = contact.getContactOrganization();
        if ((tmp != null) && (tmp != "")) {
          element("wcs:organisationName", tmp);
        }

        tmp = contact.getContactPosition();

        if ((tmp != null) && (tmp != "")) {
          element("wcs:positionName", tmp);
        }

        start("wcs:contactInfo");

        start("wcs:phone");
        tmp = contact.getContactVoice();

        if ((tmp != null) && (tmp != "")) {
          element("wcs:voice", tmp);
        }

        tmp = contact.getContactFacsimile();

        if ((tmp != null) && (tmp != "")) {
          element("wcs:facsimile", tmp);
        }

        end("wcs:phone");

        start("wcs:address");
        tmp = contact.getAddressType();

        if ((tmp != null) && (tmp != "")) {
          String addr = "";
          addr = contact.getAddress();

          if ((addr != null) && (addr != "")) {
            element("wcs:deliveryPoint", tmp + " " + addr);
          }
        } else {
          tmp = contact.getAddress();

          if ((tmp != null) && (tmp != "")) {
            element("wcs:deliveryPoint", tmp);
          }
        }

        tmp = contact.getAddressCity();

        if ((tmp != null) && (tmp != "")) {
          element("wcs:city", tmp);
        }

        tmp = contact.getAddressState();

        if ((tmp != null) && (tmp != "")) {
          element("wcs:administrativeArea", tmp);
        }

        tmp = contact.getAddressPostalCode();

        if ((tmp != null) && (tmp != "")) {
          element("wcs:postalCode", tmp);
        }

        tmp = contact.getAddressCountry();

        if ((tmp != null) && (tmp != "")) {
          element("wcs:country", tmp);
        }

        tmp = contact.getContactEmail();

        if ((tmp != null) && (tmp != "")) {
          element("wcs:electronicMailAddress", tmp);
        }

        end("wcs:address");

        tmp = contact.getOnlineResource();

        if ((tmp != null) && (tmp != "")) {
          AttributesImpl attributes = new AttributesImpl();
          attributes.addAttribute("", "xlink:href", "xlink:href", "", tmp);
          start("wcs:onlineResource", attributes);
          end("wcs:onlineResource");
        }

        end("wcs:contactInfo");

        end("wcs:responsibleParty");
      }
    }