org.meshcms.core
Class SiteMap

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.meshcms.util.DirectoryParser
          extended byorg.meshcms.core.SiteMap
All Implemented Interfaces:
java.lang.Runnable

public class SiteMap
extends DirectoryParser

Contains the site map.


Nested Class Summary
static class SiteMap.CodeLocalePair
           
 
Field Summary
static java.util.regex.Pattern KEYWORDS_REGEX
           
static java.lang.String MESHCMS_CSS
          Name of the CSS that contains styles for elements of the MeshCMS interface (mail forms, editor and so on).
static java.lang.String MODULE_INCLUDE_FILE
           
static java.lang.String THEME_CSS
          Name of the stylesheet of a theme.
static java.lang.String THEME_DECORATOR
          Name of the main file of a theme.
 
Fields inherited from class org.meshcms.util.DirectoryParser
initialDir, processStartDir, recursive
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SiteMap(WebSite webSite)
          Creates a new instance of SiteMap
 
Method Summary
 void cache(Path path, byte[] b)
          Caches a page.
 PageInfo[] getBreadcrumbs(Path path)
          Returns the breadcrumbs from the root path (included) to the given path (not included).
 byte[] getCached(Path path)
          Gets a page from the cache.
 Path getCurrentWelcome(Path dirPath)
          Returns the path of the welcome file for the given directory path.
 java.util.List getLangList()
           
 long getLastModified()
          Returns the last modification time.
 java.lang.String[] getModuleNames()
          Returns an array of the names of all available modules.
 java.util.SortedMap getModulesMap()
           
 PageInfo getPageInfo(Path path)
          Returns the PageInfo for the given path.
 java.util.List getPagesInDirectory(Path path, boolean includeDir)
          Returns a list of pages contained in the directory that contains the given path; if the path denotes a directory, its contents are returned.
 java.util.List getPagesList()
          Returns the pages contained in the menu as a unmodifiable List.
 java.util.List getPagesList(Path root)
          Returns the pages contained in the menu as a unmodifiable List, using the given path as root path.
 java.util.SortedMap getPagesMap(Path root)
          Returns the pages contained in the menu as a SortedMap, using the given path as root.
 PageInfo getParentPageInfo(Path path)
          Returns the PageInfo for parent of the page at the given path.
 Path getPathInMenu(Path path)
          Returns the given path unless it is the current welcome file in its folder; in this case the folder path is returned.
 Path getRedirMatch(Path requestedPath)
           
 Path getServedPath(Path path)
          Returns the given path unless it is a folder with a welcome file; in this case the welcome file path is returned.
 java.lang.String[] getThemeNames()
          Returns an array of the names of all available themes.
 java.util.SortedMap getThemesMap()
           
 java.lang.String getTigraItems(java.lang.String contextPath, Path path, boolean tree)
          Returns the code needed to create a menu or a tree with the scripts created by SoftComplex.
 java.lang.String getTigraItems(java.lang.String contextPath, Path path, boolean tree, boolean allowHiding)
          Returns the code needed to create a menu or a tree with the scripts created by SoftComplex.
 boolean hasChildrenPages(Path path)
          Returns true if there is at least one page whose parent path is the given one.
 boolean isCached(Path path)
          Check if a page is available in the cache.
 boolean isCurrentWelcome(Path path)
          Checks if the given path is the welcome file for its directory.
 boolean isObsolete()
           
protected  void postProcess()
          This method is called at the end of the processing.
protected  boolean preProcess()
          This method is called during the process, but before any element has been processed.
protected  boolean preProcessDirectory(java.io.File file, Path path)
           
protected  void processFile(java.io.File file, Path path)
          This method will be called for any file found while parsing the base directory.
 void removeFromCache(Path path)
          Removes a page from the cache.
 void setObsolete(boolean obsolete)
          When obsolete, info contained in this site map will be discarded when a new site map is created.
 
Methods inherited from class org.meshcms.util.DirectoryParser
getInitialDir, isProcessStartDir, isRecursive, isSorted, postProcessDirectory, process, run, setInitialDir, setInitialDir, setProcessStartDir, setRecursive, setSorted
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

THEME_DECORATOR

public static final java.lang.String THEME_DECORATOR
Name of the main file of a theme.

See Also:
Constant Field Values

THEME_CSS

public static final java.lang.String THEME_CSS
Name of the stylesheet of a theme.

See Also:
Constant Field Values

MESHCMS_CSS

public static final java.lang.String MESHCMS_CSS
Name of the CSS that contains styles for elements of the MeshCMS interface (mail forms, editor and so on).

See Also:
Constant Field Values

MODULE_INCLUDE_FILE

public static final java.lang.String MODULE_INCLUDE_FILE
See Also:
Constant Field Values

KEYWORDS_REGEX

public static final java.util.regex.Pattern KEYWORDS_REGEX
Constructor Detail

SiteMap

public SiteMap(WebSite webSite)
Creates a new instance of SiteMap

Method Detail

preProcess

protected boolean preProcess()
Description copied from class: DirectoryParser
This method is called during the process, but before any element has been processed. If it returns false, no processing will take place.

The base implementation does nothing and returns true.

Overrides:
preProcess in class DirectoryParser
Returns:
always true

preProcessDirectory

protected boolean preProcessDirectory(java.io.File file,
                                      Path path)
Overrides:
preProcessDirectory in class DirectoryParser

processFile

protected void processFile(java.io.File file,
                           Path path)
Description copied from class: DirectoryParser
This method will be called for any file found while parsing the base directory.

Overrides:
processFile in class DirectoryParser
Parameters:
file - the file to be processed
path - the path of the file (relative to the base directory)

postProcess

protected void postProcess()
Description copied from class: DirectoryParser
This method is called at the end of the processing. It is called even if DirectoryParser.preProcess() returned false.

The base implementation does nothing.

Overrides:
postProcess in class DirectoryParser

getPageInfo

public PageInfo getPageInfo(Path path)
Returns the PageInfo for the given path.


getParentPageInfo

public PageInfo getParentPageInfo(Path path)
Returns the PageInfo for parent of the page at the given path.


getPathInMenu

public Path getPathInMenu(Path path)
Returns the given path unless it is the current welcome file in its folder; in this case the folder path is returned.


getServedPath

public Path getServedPath(Path path)
Returns the given path unless it is a folder with a welcome file; in this case the welcome file path is returned.


getCurrentWelcome

public Path getCurrentWelcome(Path dirPath)
Returns the path of the welcome file for the given directory path. This method returns null if the path is not a directory or if there is no welcome file into it.


isCurrentWelcome

public boolean isCurrentWelcome(Path path)
Checks if the given path is the welcome file for its directory.


getLastModified

public long getLastModified()
Returns the last modification time.


getTigraItems

public java.lang.String getTigraItems(java.lang.String contextPath,
                                      Path path,
                                      boolean tree)
Returns the code needed to create a menu or a tree with the scripts created by SoftComplex.

Parameters:
contextPath - the context path as returned from HttpServletRequest.getContextPath()
path - the root path for the menu (if null, the root path is used)
tree - true to get the items for a tree, false to get the items for a menu
Returns:
a string that can be used as content for the menu_items.js file needed by those scripts

getTigraItems

public java.lang.String getTigraItems(java.lang.String contextPath,
                                      Path path,
                                      boolean tree,
                                      boolean allowHiding)
Returns the code needed to create a menu or a tree with the scripts created by SoftComplex.

Parameters:
contextPath - the context path as returned from HttpServletRequest.getContextPath()
path - the root path for the menu (if null, the root path is used)
tree - true to get the items for a tree, false to get the items for a menu
allowHiding - honours the "hide submenu" option
Returns:
a string that can be used as content for the menu_items.js file needed by those scripts

getPagesMap

public java.util.SortedMap getPagesMap(Path root)
Returns the pages contained in the menu as a SortedMap, using the given path as root. All keys are of type Path and all values are of type PageInfo. Note that the ordering of the map is the natural order of Path.

See Also:
Path

getLangList

public java.util.List getLangList()

hasChildrenPages

public boolean hasChildrenPages(Path path)
Returns true if there is at least one page whose parent path is the given one.


getPagesInDirectory

public java.util.List getPagesInDirectory(Path path,
                                          boolean includeDir)
Returns a list of pages contained in the directory that contains the given path; if the path denotes a directory, its contents are returned.

Parameters:
includeDir - if true, the directory itself is included in the list

getPagesList

public java.util.List getPagesList()
Returns the pages contained in the menu as a unmodifiable List. All members of the list are of type PageInfo. Pages are sorted using a PageInfoComparator.


getPagesList

public java.util.List getPagesList(Path root)
Returns the pages contained in the menu as a unmodifiable List, using the given path as root path. All members of the list are of type PageInfo. Pages are sorted using a PageInfoComparator.


getBreadcrumbs

public PageInfo[] getBreadcrumbs(Path path)
Returns the breadcrumbs from the root path (included) to the given path (not included).


getThemeNames

public java.lang.String[] getThemeNames()
Returns an array of the names of all available themes.


getModuleNames

public java.lang.String[] getModuleNames()
Returns an array of the names of all available modules.


cache

public void cache(Path path,
                  byte[] b)
Caches a page.


removeFromCache

public void removeFromCache(Path path)
Removes a page from the cache.


getCached

public byte[] getCached(Path path)
Gets a page from the cache.


isCached

public boolean isCached(Path path)
Check if a page is available in the cache.


getThemesMap

public java.util.SortedMap getThemesMap()

getModulesMap

public java.util.SortedMap getModulesMap()

isObsolete

public boolean isObsolete()
See Also:
setObsolete(boolean)

setObsolete

public void setObsolete(boolean obsolete)
When obsolete, info contained in this site map will be discarded when a new site map is created.


getRedirMatch

public Path getRedirMatch(Path requestedPath)