Class SiteSection
- java.lang.Object
-
- dk.netarkivet.common.webinterface.SiteSection
-
- Direct Known Subclasses:
BitPreservationSiteSection
,DefinitionsSiteSection
,HarvestChannelSiteSection
,HistorySiteSection
,QASiteSection
,StatusSiteSection
,TestSiteSection
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
Constructors Constructor Description 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
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static void
cleanup()
Clean up site sections.abstract void
close()
Called when webserver shuts down.void
generateNavigationTree(java.lang.StringBuilder sb, javax.servlet.http.HttpServletRequest req, java.lang.String url, java.lang.String subMenu, 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.java.lang.String
getPageFromPage(java.lang.String page)
Returns the first sub path of a given path without schema, context path and query string.java.lang.String
getPath(javax.servlet.http.HttpServletRequest req, java.lang.String url)
Given a URL, returns the path part without schema, context path and query string.static java.util.List<SiteSection>
getSections()
The list of sections of the website.java.lang.String
getTitle(javax.servlet.http.HttpServletRequest req, 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.
-
-
-
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(javax.servlet.http.HttpServletRequest req, java.lang.String url, java.util.Locale locale)
Given a URL, returns the corresponding page title.- Parameters:
req
- the HTTP request object to respond tourl
- 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.
-
getPath
public java.lang.String getPath(javax.servlet.http.HttpServletRequest req, java.lang.String url)
Given a URL, returns the path part without schema, context path and query string.- Parameters:
req
- the HTTP request object to respond tourl
- a given URL.- Returns:
- the path part of a URL without the schema, context path and query string
-
getPageFromPage
public java.lang.String getPageFromPage(java.lang.String page)
Returns the first sub path of a given path without schema, context path and query string.- Parameters:
page
- a processed path without schema, context path and query string- Returns:
-
generateNavigationTree
public void generateNavigationTree(java.lang.StringBuilder sb, javax.servlet.http.HttpServletRequest req, java.lang.String url, java.lang.String subMenu, 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 HTMLurl
- 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 site sections. 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.
-
-