Class SiteSection

    • Constructor Detail

      • SiteSection

        public SiteSection​(String mainname,
                           String prefix,
                           int visiblePages,
                           String[][] pagesAndTitles,
                           String dirname,
                           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 String getTitle​(javax.servlet.http.HttpServletRequest req,
                               String url,
                               Locale locale)
        Given a URL, returns the corresponding page title.
        Parameters:
        req - the HTTP request object to respond to
        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.
      • getPath

        public String getPath​(javax.servlet.http.HttpServletRequest req,
                              String url)
        Given a URL, returns the path part without schema, context path and query string.
        Parameters:
        req - the HTTP request object to respond to
        url - a given URL.
        Returns:
        the path part of a URL without the schema, context path and query string
      • getPageFromPage

        public String getPageFromPage​(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​(StringBuilder sb,
                                           javax.servlet.http.HttpServletRequest req,
                                           String url,
                                           String subMenu,
                                           Locale locale)
                                    throws 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:
        IOException - If there is a problem writing to the page.
      • getDirname

        public 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 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​(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.