Class ODFPageCache
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.odfweb.repository.ODFPageCache
-
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
public class ODFPageCache extends AbstractLogEnabled implements Serviceable, Contextualizable, Component
Maintains a per-request cache, dispatching ODF virtual pages accross degrees and domains.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ODFPageCache.LevelComparator
-
Field Summary
Fields Modifier and Type Field Description private static String
__ATT_CACHE_PREFIX
private static String
__ATT_CACHE_PROGRAM_PREFIX
private static String
__NO_FIRST_DATA_KEY
private static String
__NO_SECOND_DATA_KEY
private AmetysObjectFactoryExtensionPoint
_ametysObjectFactoryEP
private Context
_context
private OdfPageHandler
_odfPageHandler
private WorkspaceSelector
_workspaceSelector
static String
ROLE
Avalon role.
-
Constructor Summary
Constructors Constructor Description ODFPageCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Program
_getProgramWithRestrictions(Page rootPage, String level1, String level2, String programCode, String programName)
void
clearCache(Page rootPage)
Clear page cachevoid
contextualize(Context context)
(package private) Page
getChildProgramPage(Page rootPage, Page parentPage, String level1, String level2, String path)
Get the child page from its relative path.(package private) Program
getProgram(Page rootPage, String level1, String level2, String programCode, String programName)
Get cached program(package private) Map<String,Map<String,Collection<Program>>>
getProgramCache(Page rootPage, boolean computeIfNotPresent)
(package private) Optional<Program>
getProgramFromPageName(Page rootPage, String level1, String level2, String pageName)
Get cached program corresponding to the page name(package private) Optional<AmetysObjectIterable<Program>>
getPrograms(Page rootPage, String level1, String level2, boolean computeIfNotPresent)
Get programs to given levelsvoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__NO_FIRST_DATA_KEY
private static final String __NO_FIRST_DATA_KEY
- See Also:
- Constant Field Values
-
__NO_SECOND_DATA_KEY
private static final String __NO_SECOND_DATA_KEY
- See Also:
- Constant Field Values
-
__ATT_CACHE_PREFIX
private static final String __ATT_CACHE_PREFIX
- See Also:
- Constant Field Values
-
__ATT_CACHE_PROGRAM_PREFIX
private static final String __ATT_CACHE_PROGRAM_PREFIX
- See Also:
- Constant Field Values
-
_odfPageHandler
private OdfPageHandler _odfPageHandler
-
_workspaceSelector
private WorkspaceSelector _workspaceSelector
-
_ametysObjectFactoryEP
private AmetysObjectFactoryExtensionPoint _ametysObjectFactoryEP
-
-
Constructor Detail
-
ODFPageCache
public ODFPageCache()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getProgramCache
Map<String,Map<String,Collection<Program>>> getProgramCache(Page rootPage, boolean computeIfNotPresent)
-
getPrograms
Optional<AmetysObjectIterable<Program>> getPrograms(Page rootPage, String level1, String level2, boolean computeIfNotPresent)
Get programs to given levels- Parameters:
rootPage
- The ODF root pagelevel1
- The value of first level ornull
if there is no first levellevel2
- The value of second level ornull
if there is no second levelcomputeIfNotPresent
- When false, no result will be returned if the root page in not already in the cache- Returns:
- The matching programs
-
getChildProgramPage
Page getChildProgramPage(Page rootPage, Page parentPage, String level1, String level2, String path) throws UnknownAmetysObjectException
Get the child page from its relative path.- Parameters:
rootPage
- The ODF root pageparentPage
- The parent pagelevel1
- The value of first level ornull
if there is no first levellevel2
- The value of second level ornull
if there is no second levelpath
- the path of the child page- Returns:
- the child page
- Throws:
UnknownAmetysObjectException
- if no child page was found at the given path
-
getProgramFromPageName
Optional<Program> getProgramFromPageName(Page rootPage, String level1, String level2, String pageName)
Get cached program corresponding to the page name- Parameters:
rootPage
- The ODF root pagelevel1
- The value of first level ornull
if there is no first levellevel2
- The value of second level ornull
if there is no second levelpageName
- the page's name- Returns:
- The program if found
-
getProgram
Program getProgram(Page rootPage, String level1, String level2, String programCode, String programName)
Get cached program- Parameters:
rootPage
- The ODF root pagelevel1
- The value of first level ornull
if there is no first levellevel2
- The value of second level ornull
if there is no second levelprogramCode
- The code of program. Can be null if programName is not null.programName
- The name of program. Can be null if programCode is not null.- Returns:
- program The program
-
_getProgramWithRestrictions
private Program _getProgramWithRestrictions(Page rootPage, String level1, String level2, String programCode, String programName)
-
clearCache
public void clearCache(Page rootPage)
Clear page cache- Parameters:
rootPage
- The ODF root page
-
-