dk.netarkivet.common.webinterface
Class SiteSection

java.lang.Object
  extended by dk.netarkivet.common.webinterface.SiteSection
Direct Known Subclasses:
BitPreservationSiteSection, DefinitionsSiteSection, HistorySiteSection, QASiteSection, StatusSiteSection

public abstract class SiteSection
extends java.lang.Object

This class holds information about one section of the site, including information about what to put in the menu sidebar and how to determine which page you're in.


Constructor Summary
SiteSection(java.lang.String mainname, java.lang.String prefix, int visiblePages, java.lang.String[][] pagesAndTitles, java.lang.String dirname, java.lang.String bundle)
          Create a new SiteSection object.
 
Method Summary
static void cleanup()
          Clean up sitesections.
abstract  void close()
          Called when webserver shuts down.
 void generateNavigationTree(javax.servlet.jsp.JspWriter out, java.lang.String url, java.util.Locale locale)
          Generate this section's part of the navigation tree (sidebar).
 java.lang.String getDirname()
          Return the directory name of this site section.
static java.util.List<SiteSection> getSections()
          The list of sections of the website.
 java.lang.String getTitle(java.lang.String url, java.util.Locale locale)
          Given a URL, returns the corresponding page title.
abstract  void initialize()
          Called when the site section is first deployed.
static boolean isDeployed(java.lang.String dirName)
          Check whether a section with a given dirName is deployed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SiteSection

public SiteSection(java.lang.String mainname,
                   java.lang.String prefix,
                   int visiblePages,
                   java.lang.String[][] pagesAndTitles,
                   java.lang.String dirname,
                   java.lang.String bundle)
Create a new SiteSection object.

Parameters:
mainname - The name of the entire section used in the sidebar.
prefix - The prefix that all the JSP pages will have.
visiblePages - How many of the pages will be visible in the menu (taken from the start of the list).
pagesAndTitles - The actual pages and title-labels, without the prefix and jsp extension, involved in the section. They must be given as an array of 2-element arrays.
dirname - The top level directory this site section is deployed under.
bundle - The resource bundle with translations of this sitesection.
Throws:
ArgumentNotValid - if any of the elements of pagesAndTitles are not a 2-element array.
Method Detail

getTitle

public java.lang.String getTitle(java.lang.String url,
                                 java.util.Locale locale)
Given a URL, returns the corresponding page title.

Parameters:
url - a given URL.
locale - the current locale.
Returns:
the corresponding page title, or null if it is not in this section, or is null.
Throws:
ArgumentNotValid - on null locale.

generateNavigationTree

public void generateNavigationTree(javax.servlet.jsp.JspWriter out,
                                   java.lang.String url,
                                   java.util.Locale locale)
                            throws java.io.IOException
Generate this section's part of the navigation tree (sidebar). This outputs balanced HTML to the JspWriter. It uses a locale to generate the right titles.

Parameters:
out - A place to write our HTML
url - The url of the page we're currently viewing. The list of subpages will only be displayed if the page we're viewing is one that belongs to this section.
locale - The locale to generate the navigation tree for.
Throws:
java.io.IOException - If there is a problem writing to the page.

getDirname

public java.lang.String getDirname()
Return the directory name of this site section.

Returns:
The dirname.

initialize

public abstract void initialize()
Called when the site section is first deployed. Meant to be overridden by subclasses.


close

public abstract void close()
Called when webserver shuts down. Meant to be overridden by subclasses.


getSections

public static java.util.List<SiteSection> getSections()
The list of sections of the website. Each section has a number of pages, as defined in the sitesection classes read from settings. These handle outputting their HTML part of the sidebar, depending on where in the site we are.

Returns:
A list of site sections instantiated from settings.
Throws:
IOFailure - if site sections cannot be read from settings.

cleanup

public static void cleanup()
Clean up sitesections. This method calls close on all deployed site sections, and resets the list of site sections.


isDeployed

public static boolean isDeployed(java.lang.String dirName)
Check whether a section with a given dirName is deployed.

Parameters:
dirName - The dirName to check for
Returns:
True of deployed, false otherwise.
Throws:
ArgumentNotValid - if dirName is null or empty.