com.pepper.platform.page
Class SectionPage

java.lang.Object
  extended by com.pepper.platform.page.PepperPage
      extended by com.pepper.platform.page.SectionPage
All Implemented Interfaces:
Page
Direct Known Subclasses:
ProxyPage

public class SectionPage
extends PepperPage

This class represents a Section TOC Page


Nested Class Summary
static class SectionPage.PackageInfo
          The object encapsulates info the package xml element as well as it's section id
 
Field Summary
static String DESC_EL
           
static int MAX_HISTORY_DAYS
           
static int MAX_SESSION_ENTRIES
           
static String NAME_EL
           
static String SESSION_ENTRY_EL
           
static String SESSION_HISTORY_EL
           
static String SESSION_HOST_EL
           
static String TITLE_EL
           
static String URL_EL
           
 
Fields inherited from class com.pepper.platform.page.PepperPage
log
 
Constructor Summary
SectionPage(String id, String packageId)
          Creates a new SectionPage instance.
 
Method Summary
 void addPage(Page page, com.pepper.platform.page.PageService pageService)
          Adds a new Page element to this section page.
 boolean addSessionEntry(String url, String title, String description)
          Add a new sessionEntry to the WebSession page
 boolean containsPackages()
          Returns true if this section contains any packages
 boolean containsPages()
          Returns true if this section contains any pages
 int findElementPosition(List theChildren, int startPos, String elementName, String attrName, String attrValue)
          Find the element position in the list of children
 List findFiles(String[] pageIds, String elementName)
          Return a list of Files contained in the list of pageIds passed in with the specified elementName
protected static void findPackages(List packages, String sectionId, String thePackageId, String thePackageType, List results)
          Finds packages and adds PackageInfo objects for found packages that meet the specified criteria to the passed in results list
 List findPackages(String thePackageId, String thePackageType)
          Returns a list of PackageInfo objects for found packages that meet the specified criteria.
 List getHomepageList()
          Get list of page ids where homepage attribute is set to true
static String getPackageId(org.jdom.Element packageEl)
          Get the packageId out of the package element.
 List getPageList()
          get a list of the child page elements on the section page
 int getPositionAndName(String id, StringBuffer name)
          Get relative position and name of page or package element by ID.
 void moveElement(String elementName, String attrName, String attrValue, boolean moveUp)
          Move the specified element either up or down one position relative to it's parent
 void moveElement(String elementName, String attrName, String attrValue, int index)
          Move the specified element either up or down one position relative to it's parent
 boolean remove(String elementName, String id, boolean createMoveTombstone)
          Removes the specified element from this section page.
 boolean remove(String elementName, String id, boolean makeTombstone, boolean createMoveTombstone)
          Removes the specified element from this section page.
 void remove(String elementName, String childName, String childValue)
          Remove the element whose specified child value matches the passed in child value.
 void removeAllSessions()
          Remove all web session (history) entries
 void removePage(Page page, boolean createMoveTombstone)
          Removes the specified element from this section page.
 void removePage(Page page, boolean makeTombstone, boolean createMoveTombstone)
          Removes the specified element from this section page, optionally makes a tombstone
 void removeSessionDate(String dateId)
          Describe removeSessionDate method here.
 void removeSessionEntry(String id, String sessionDate, String sessionHost)
          Describe removeSessionEntry method here.
 void removeSessionHost(String hostId, String sessionDate)
          Remove the entry
 boolean reorderPackage(String pageId, int newPosition)
          reorderPackage
 boolean reorderPage(String pageId, int newPosition)
          reorderPage
 boolean reorderPagePackageElement(String elementName, String attrName, String attrValue, int newPosition)
          This method will reorder a or element to the specified "logical" position in the document, meaning, the position of the element passed in relative to the first "valid" element (page/package) found in the page.
 void save()
          Saves this section page.
 void setPackageAttr(String thePackageId, String attrName, String attrValue)
          Find the specified package in the section and set the attribute on it
 boolean updateSessionEntry(String url, String title)
          Update the title of a webSession
 
Methods inherited from class com.pepper.platform.page.PepperPage
exists, getBackup, getBaseDir, getCreateDate, getDefaultType, getForceAutoSave, getId, getLastSaveTime, getName, getNoCache, getPackageName, getPackageVersion, getPageData, getProcessBody, getRootAttrValue, getSupportedPageTypes, getTemplate, getType, isAutoSaveEnabled, isDeletable, isHidden, isLoaded, isPageTypeSupported, isReadOnly, isSecure, load, setAutoSaveEnabled, setBackup, setBaseDir, setClassLoader, setDefaultType, setDeletable, setForceAutoSave, setHidden, setId, setLastSaveTime, setName, setNoCache, setPackageName, setPackageVersion, setPageData, setProcessBody, setReadOnly, setSecure, setSupportedPageTypes, setTemplate, setTemplateOverride, setType, toString, unload
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_SESSION_ENTRIES

public static final int MAX_SESSION_ENTRIES
See Also:
Constant Field Values

MAX_HISTORY_DAYS

public static final int MAX_HISTORY_DAYS
See Also:
Constant Field Values

SESSION_HISTORY_EL

public static final String SESSION_HISTORY_EL
See Also:
Constant Field Values

SESSION_ENTRY_EL

public static final String SESSION_ENTRY_EL
See Also:
Constant Field Values

SESSION_HOST_EL

public static final String SESSION_HOST_EL
See Also:
Constant Field Values

NAME_EL

public static final String NAME_EL
See Also:
Constant Field Values

URL_EL

public static final String URL_EL
See Also:
Constant Field Values

TITLE_EL

public static final String TITLE_EL
See Also:
Constant Field Values

DESC_EL

public static final String DESC_EL
See Also:
Constant Field Values
Constructor Detail

SectionPage

public SectionPage(String id,
                   String packageId)
Creates a new SectionPage instance.

Parameters:
id - a String value representing the id of the SectionPage.
Method Detail

addPage

public void addPage(Page page,
                    com.pepper.platform.page.PageService pageService)
             throws Exception
Adds a new Page element to this section page.

Parameters:
page - the Page to be added to this section.
pageService - PageService used to look up cache rules.
Throws:
Exception - if the current instance (ie. this) of SectionPage cannot be loaded in order to add the specified page.

remove

public boolean remove(String elementName,
                      String id,
                      boolean createMoveTombstone)
               throws Exception
Removes the specified element from this section page.

Parameters:
elementName - a String containing the element name to be removed.
id - a String containing the id of the element to be removed.
createMoveTombstone - If true, creates a pageMoved tombstone instead of a pageRemoved tombstone when deleting the reference to the page.
Returns:
boolean - whether the remove was successfull or not
Throws:
Exception - if the current instance (ie. this) of SectionPage cannot be loaded in order to remove the specified page.

remove

public boolean remove(String elementName,
                      String id,
                      boolean makeTombstone,
                      boolean createMoveTombstone)
               throws Exception
Removes the specified element from this section page.

Parameters:
elementName - a String containing the element name to be removed.
id - a String containing the id of the element to be removed.
makeTombstone - If true then make a tombstone for this element
createMoveTombstone - If true, creates a pageMoved tombstone instead of a pageRemoved tombstone when deleting the reference to the page.
Returns:
boolean - whether the remove was successfull or not
Throws:
Exception - if the current instance (ie. this) of SectionPage cannot be loaded in order to remove the specified page.
Since:
3.2

remove

public void remove(String elementName,
                   String childName,
                   String childValue)
            throws Exception
Remove the element whose specified child value matches the passed in child value. For example, remove the "Program" element whose "Name" (child) is "Foo"

Parameters:
elementName - Element to remove
childName - Name of child to attempt to match
childValue - Value of child to match
Throws:
Exception - if an error occurs

moveElement

public void moveElement(String elementName,
                        String attrName,
                        String attrValue,
                        boolean moveUp)
                 throws Exception
Move the specified element either up or down one position relative to it's parent

Parameters:
elementName - The name of the element to move
attrName - The attribute name to match
attrValue - The attribute value to match
moveUp - true to move the element up one position in the list, false to move it down in the list
Throws:
Exception - if an error occurs

moveElement

public void moveElement(String elementName,
                        String attrName,
                        String attrValue,
                        int index)
                 throws Exception
Move the specified element either up or down one position relative to it's parent

Parameters:
elementName - The name of the element to move
attrName - The attribute name to match
attrValue - The attribute value to match
index - The order to put it in
Throws:
Exception - if an error occurs

reorderPagePackageElement

public boolean reorderPagePackageElement(String elementName,
                                         String attrName,
                                         String attrValue,
                                         int newPosition)
                                  throws Exception
This method will reorder a or element to the specified "logical" position in the document, meaning, the position of the element passed in relative to the first "valid" element (page/package) found in the page.

Parameters:
elementName - a String value
attrName - a String value
attrValue - a String value
newPosition - an int value
Returns:
boolean true if the element was moved up in the list (i.e. if the newPosition < originalPos), return false if moved down the list (newPosition > originalPos)
Throws:
Exception - if an error occurs

findElementPosition

public int findElementPosition(List theChildren,
                               int startPos,
                               String elementName,
                               String attrName,
                               String attrValue)
Find the element position in the list of children

Parameters:
theChildren - a List value
startPos - an int value
elementName - a String value
attrName - a String value
attrValue - a String value
Returns:
the position found

getPositionAndName

public int getPositionAndName(String id,
                              StringBuffer name)
Get relative position and name of page or package element by ID.

Parameters:
id - a String page or package ID value
name - a StringBuffer return element name ("page" or "program", etc.)
Returns:
pos an int return element position (0 - n-1, -1 if not found)

removePage

public void removePage(Page page,
                       boolean createMoveTombstone)
                throws Exception
Removes the specified element from this section page.

Parameters:
page - the Page to be removed from this section page.
createMoveTombstone - If true, creates a pageMoved tombstone instead of a pageRemoved tombstone when deleting the reference to the page.
Throws:
Exception - if the current instance (ie. this) of SectionPage cannot be loaded in order to add remove the specified page.

removePage

public void removePage(Page page,
                       boolean makeTombstone,
                       boolean createMoveTombstone)
                throws Exception
Removes the specified element from this section page, optionally makes a tombstone

Parameters:
page - the Page to be removed from this section page.
makeTombstone - true to make a tombstone
createMoveTombstone - If true, creates a pageMoved tombstone instead of a pageRemoved tombstone when deleting the reference to the page.
Throws:
Exception - if the current instance (ie. this) of SectionPage cannot be loaded in order to add remove the specified page.
Since:
3.2

reorderPage

public boolean reorderPage(String pageId,
                           int newPosition)
                    throws Exception
reorderPage

Parameters:
pageId - a String value
newPosition - an int value
Returns:
a boolean value
Throws:
Exception - if an error occurs

reorderPackage

public boolean reorderPackage(String pageId,
                              int newPosition)
                       throws Exception
reorderPackage

Parameters:
pageId - a String value
newPosition - an int value
Returns:
a boolean value
Throws:
Exception - if an error occurs

getPageList

public List getPageList()
get a list of the child page elements on the section page

Returns:
A list of page elements

getPackageId

public static String getPackageId(org.jdom.Element packageEl)
Get the packageId out of the package element. This will first get the "id" attribute from the element which represents the package's URL. It will then parse the URL to find the packageId

Parameters:
packageEl - an Element value
Returns:
a String value

setPackageAttr

public void setPackageAttr(String thePackageId,
                           String attrName,
                           String attrValue)
Find the specified package in the section and set the attribute on it

Parameters:
thePackageId - The packageId to find
attrName - Name of the attribute to set
attrValue - Value of the attribute to set

findPackages

public List findPackages(String thePackageId,
                         String thePackageType)
Returns a list of PackageInfo objects for found packages that meet the specified criteria.

Parameters:
thePackageId - If null, all packages of specified type (if type not null), will be returned. If not null, the particular package will be returned.
thePackageType - The type of packages to return (i.e. "music", "journal", etc). If null all packages will be returned or the package with the specified packageId will be returned.
Returns:
a List of PackageInfo objects

containsPackages

public boolean containsPackages()
Returns true if this section contains any packages

Returns:
a boolean value

containsPages

public boolean containsPages()
Returns true if this section contains any pages

Returns:
a boolean value

findPackages

protected static void findPackages(List packages,
                                   String sectionId,
                                   String thePackageId,
                                   String thePackageType,
                                   List results)
Finds packages and adds PackageInfo objects for found packages that meet the specified criteria to the passed in results list

Parameters:
packages - A list of package elements to be searched packages
thePackageId - If null, all packages of specified type (if type not null), will be returned. If not null, the particular package will be returned.
thePackageType - The type of packages to return (i.e. "music", "journal", etc). If null all packages will be returned or the package with the specified packageId will be returned.
results - An array list that found PackageInfo objects will be added to

addSessionEntry

public boolean addSessionEntry(String url,
                               String title,
                               String description)
Add a new sessionEntry to the WebSession page

Parameters:
url - a String value
title - a String value
description - a String value
Returns:
true if the dom was modified

updateSessionEntry

public boolean updateSessionEntry(String url,
                                  String title)
Update the title of a webSession

Parameters:
url - a String value
title - a String value
Returns:
true if the dom was modified

save

public void save()
          throws Exception
Saves this section page.

Specified by:
save in interface Page
Overrides:
save in class PepperPage
Throws:
Exception - if a low-level error occurrs.
See Also:
Page

getHomepageList

public List getHomepageList()
Get list of page ids where homepage attribute is set to true

Returns:
List of pageIds which represent pages that have a homepage attribute set to true

removeAllSessions

public void removeAllSessions()
Remove all web session (history) entries


removeSessionDate

public void removeSessionDate(String dateId)
Describe removeSessionDate method here.

Parameters:
dateId - a String value

removeSessionHost

public void removeSessionHost(String hostId,
                              String sessionDate)
Remove the entry

Parameters:
hostId - a String value
sessionDate - a String value

removeSessionEntry

public void removeSessionEntry(String id,
                               String sessionDate,
                               String sessionHost)
Describe removeSessionEntry method here.

Parameters:
id - a String value
sessionDate - a String value
sessionHost - a String value

findFiles

public List findFiles(String[] pageIds,
                      String elementName)
Return a list of Files contained in the list of pageIds passed in with the specified elementName

Parameters:
pageIds - the pageIds to search for
elementName - the name of the element that contains the relative path name of the file
Returns:
List of Files


Copyright © 2006-2007 Pepper Computer, Inc. All Rights Reserved.