Class OdfPageHandler
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.odfweb.repository.OdfPageHandler
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Serviceable
public class OdfPageHandler
extends AbstractLogEnabled
implements Component, Initializable, Serviceable
Component providing methods to retrieve ODF virtual pages, such as the ODF root,
level 1 and 2 metadata names, and so on.
-
Field Summary
Modifier and TypeFieldDescriptionprotected CatalogsManager
The ODF Catalog enumerationprotected ContentHelper
Content helperprotected ContentTypesHelper
Content types helperprotected ContentTypeExtensionPoint
The content type extension point.For each site, indicate if an ODF root is present.protected I18nUtils
The i18n utils.protected ServiceManager
Avalon service managerprotected OdfClassificationHandler
Root orgunit providerprotected OdfReferenceTableHelper
Odf reference table helperprotected OdfProgramRestrictionManager
Restriction managerThe ODF root pages, indexed by workspace, site and sitemap name.protected RootOrgUnitProvider
Root orgunit providerprotected AmetysObjectResolver
The ametys object resolver.protected WorkspaceSelector
The workspace selector.static final String
Catalog data name.static final String
First level attribute name.static final String
Second level attribute name.Content types that are not eligible for first and second levelstatic final String
The avalon role. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Page
_getOdfRootPage
(String siteName, String sitemapName) Get the ODF root page._getOdfRootPages
(String siteName, String sitemapName) Get the ODF root page.void
Clear the ODF root page cache.void
clearRootCache
(String siteName, String sitemapName) Clear the ODF root page cache for a given site and language.computeLevelsPath
(Page rootPage, Program parentProgram) Compute the path from the root odf page, representing the first and second level pages.decodeLevelValue
(String value) Decode level value used in a URIencodeLevelValue
(String value) Encode level value to be use into a URI.getCatalog
(Page rootPage) Get the catalog value of the ODF root pageGet the ODF catalogsGet the eligible enumerated attribute definitions for ODF page levelgetEnumeratedAttributes
(String programContentTypeId, boolean allowMultiple) Get the enumerated attribute definitions for the given content type.getLevel1Metadata
(String siteName, String sitemapName, String catalog) Get the first level metadata name.getLevel1Metadata
(Page rootPage) Get the first level metadata name.getLevel1PageName
(Page rootPage, Program program) Get the name of the page of first level for a given programgetLevel1Values
(String siteName, String sitemapName, String catalog) Get the first level metadata values (with translated label).getLevel1Values
(Page rootPage) Get the first level metadata values (with translated label)getLevel2Metadata
(String siteName, String sitemapName, String catalog) Get the second level metadata name.getLevel2Metadata
(Page rootPage) Get the second level metadata name.getLevel2PageName
(Page rootPage, Program program) Get the name of the page of second level for a given programgetLevel2Values
(String siteName, String sitemapName, String catalog) Get the second level metadata values (with translated label).getLevel2Values
(Page rootPage) Get the second level metadata values (with translated label).getOdfRootPage
(String siteName, String sitemapName) Get the first ODF root page.getOdfRootPage
(String siteName, String sitemapName, String catalogName) Get ODF root page of a specific catalog.getOdfRootPageIds
(String siteName, String sitemapName) Get the id of ODF root pagesgetOdfRootPages
(String siteName, String sitemapName) Get the ODF root pages.getOrgunitIdFromUaiCode
(Page rootPage, String uaiCode) Get the orgunit identifier given an uai codegetPageName
(ProgramItem item) Returns the page's name of aProgramItem
.getProgramLevel1Value
(Page rootPage, Program program) Get the first level value of a program by extracting and transforming the raw program valuegetProgramLevel2Value
(Page rootPage, Program program) Get the second level value of a program by extracting and transforming the raw program valuegetProgramLevelValue
(Program program, String levelMetaPath) Get the level value of a program by extracting and transforming the raw program value at the desired metadata pathgetProgramsWithRestrictions
(Page rootPage, String level1, String level2, String programCode, String programName) Get the programs available for a ODF root page, taking account the site's restrictionsgetProgramsWithRestrictions
(Page rootPage, String level1Metadata, String level1, String level2Metadata, String level2, String programCode, String programName) Get the programs available for a ODF root page, taking account the site's restrictionsboolean
hasOdfRootPage
(Site site) Test if the given site has at least one sitemap with an odf root page.void
boolean
isODFRootPage
(Page page) Determines if the page is a ODF root pageboolean
isValidRestriction
(Page rootPage, Program program) Determines if the program is part of the site restrictionsvoid
service
(ServiceManager serviceManager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The avalon role. -
LEVEL1_ATTRIBUTE_NAME
First level attribute name.- See Also:
-
LEVEL2_ATTRIBUTE_NAME
Second level attribute name.- See Also:
-
CATALOG_DATA_NAME
Catalog data name.- See Also:
-
NON_ELIGIBLE_CTYPES_FOR_LEVEL
Content types that are not eligible for first and second level -
_resolver
The ametys object resolver. -
_i18nUtils
The i18n utils. -
_cTypeEP
The content type extension point. -
_catalogsManager
The ODF Catalog enumeration -
_workspaceSelector
The workspace selector. -
_odfRootPages
The ODF root pages, indexed by workspace, site and sitemap name. -
_hasOdfRoot
For each site, indicate if an ODF root is present. -
_manager
Avalon service manager -
_odfRestrictionsManager
Restriction manager -
_contentTypesHelper
Content types helper -
_contentHelper
Content helper -
_odfReferenceTableHelper
Odf reference table helper -
_orgUnitProvider
Root orgunit provider -
_odfClassificationHandler
Root orgunit provider
-
-
Constructor Details
-
OdfPageHandler
public OdfPageHandler()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getOdfRootPage
Get the first ODF root page.- Parameters:
siteName
- The site namesitemapName
- The sitemap's name- Returns:
- a ODF root page or null if not found.
- Throws:
AmetysRepositoryException
- if an error occurs
-
getOdfRootPage
public Page getOdfRootPage(String siteName, String sitemapName, String catalogName) throws AmetysRepositoryException Get ODF root page of a specific catalog.- Parameters:
siteName
- The site namesitemapName
- The sitemap namecatalogName
- The catalog name- Returns:
- the ODF root page or null if not found.
- Throws:
AmetysRepositoryException
- if an error occurs
-
getOdfRootPageIds
public List<String> getOdfRootPageIds(String siteName, String sitemapName) throws AmetysRepositoryException Get the id of ODF root pages- Parameters:
siteName
- The site namesitemapName
- The sitemap name- Returns:
- The ids of ODF root pages
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getOdfRootPages
public Set<Page> getOdfRootPages(String siteName, String sitemapName) throws AmetysRepositoryException Get the ODF root pages.- Parameters:
siteName
- the current site.sitemapName
- the current sitemap/language.- Returns:
- the ODF root pages
- Throws:
AmetysRepositoryException
- if an error occurs.
-
hasOdfRootPage
Test if the given site has at least one sitemap with an odf root page.- Parameters:
site
- the site to test.- Returns:
- true if the site has at least one sitemap with an odf root page, false otherwise.
-
isValidRestriction
Determines if the program is part of the site restrictions- Parameters:
rootPage
- The ODF root pageprogram
- The program- Returns:
true
the program is part of the site restrictions
-
clearRootCache
Clear the ODF root page cache. -
clearRootCache
Clear the ODF root page cache for a given site and language.- Parameters:
siteName
- the current site.sitemapName
- the current sitemap/language.
-
isODFRootPage
Determines if the page is a ODF root page- Parameters:
page
- The page to test- Returns:
- true if the page is a ODF root page
-
_getOdfRootPage
protected Page _getOdfRootPage(String siteName, String sitemapName) throws AmetysRepositoryException Get the ODF root page.- Parameters:
siteName
- the current site.sitemapName
- the current sitemap/language.- Returns:
- the ODF root page or null if not found.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
_getOdfRootPages
protected Set<Page> _getOdfRootPages(String siteName, String sitemapName) throws AmetysRepositoryException Get the ODF root page.- Parameters:
siteName
- the current site.sitemapName
- the current sitemap/language.- Returns:
- the ODF root page or null if not found.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getCatalog
Get the catalog value of the ODF root page- Parameters:
rootPage
- The ODF root page- Returns:
- the catalog value
-
getLevel1Metadata
Get the first level metadata name.- Parameters:
siteName
- the site name.sitemapName
- the sitemap name.catalog
- the current selected catalog.- Returns:
- the first level metadata name.
-
getLevel1Metadata
Get the first level metadata name.- Parameters:
rootPage
- the ODF root page.- Returns:
- the first level metadata name.
-
getLevel2Metadata
Get the second level metadata name.- Parameters:
siteName
- the site name.sitemapName
- the sitemap name.catalog
- the current selected catalog.- Returns:
- the second level metadata name.
-
getLevel2Metadata
Get the second level metadata name.- Parameters:
rootPage
- the ODF root page.- Returns:
- the second level metadata name.
-
getLevel1Values
public Map<String,OdfClassificationHandler.LevelValue> getLevel1Values(String siteName, String sitemapName, String catalog) Get the first level metadata values (with translated label).- Parameters:
siteName
- the site name.sitemapName
- the sitemap name.catalog
- the current selected catalog.- Returns:
- the first level metadata values.
-
getProgramLevelValue
Get the level value of a program by extracting and transforming the raw program value at the desired metadata path- Parameters:
program
- The programlevelMetaPath
- The desired metadata path that represent a level- Returns:
- The final level value
-
getProgramLevel1Value
Get the first level value of a program by extracting and transforming the raw program value- Parameters:
rootPage
- The root pageprogram
- The program- Returns:
- The final level value or
null
if not found
-
getProgramLevel2Value
Get the second level value of a program by extracting and transforming the raw program value- Parameters:
rootPage
- The root pageprogram
- The program- Returns:
- The final level value or
null
if not found
-
getLevel1PageName
Get the name of the page of first level for a given program- Parameters:
rootPage
- The ODF root pageprogram
- The program- Returns:
- The page's name
-
getLevel2PageName
Get the name of the page of second level for a given program- Parameters:
rootPage
- The ODF root pageprogram
- The program- Returns:
- The page's name
-
getOrgunitIdFromUaiCode
Get the orgunit identifier given an uai code- Parameters:
rootPage
- Odf root pageuaiCode
- The uai code- Returns:
- The orgunit id or null if not found
-
getProgramsWithRestrictions
public AmetysObjectIterable<Program> getProgramsWithRestrictions(Page rootPage, String level1, String level2, String programCode, String programName) Get the programs available for a ODF root page, taking account the site's restrictions- Parameters:
rootPage
- The ODF root pagelevel1
- filters results with a level1 value. Can be null.level2
- filters results with a level2 value. Can be null.programCode
- expected program code. Can be null.programName
- expected program name. Can be null.- Returns:
- an iterator over resulting programs
-
getProgramsWithRestrictions
public AmetysObjectIterable<Program> getProgramsWithRestrictions(Page rootPage, String level1Metadata, String level1, String level2Metadata, String level2, String programCode, String programName) Get the programs available for a ODF root page, taking account the site's restrictions- Parameters:
rootPage
- The ODF root pagelevel1Metadata
- metadata name for first levellevel1
- filters results with a level1 value. Can be null.level2Metadata
- metadata name for second levellevel2
- filters results with a level2 value. Can be null.programCode
- expected program code. Can be null.programName
- expected program name. Can be null.- Returns:
- an iterator over resulting programs
-
getLevel1Values
Get the first level metadata values (with translated label)- Parameters:
rootPage
- the ODF root page.- Returns:
- the first level metadata values. Can be empty if there is no level1 attribute on root page.
-
getLevel2Values
public Map<String,OdfClassificationHandler.LevelValue> getLevel2Values(String siteName, String sitemapName, String catalog) Get the second level metadata values (with translated label).- Parameters:
siteName
- the site name.sitemapName
- the sitemap name.catalog
- the current selected catalog.- Returns:
- the second level metadata values.
-
getLevel2Values
Get the second level metadata values (with translated label).- Parameters:
rootPage
- the ODF root page.- Returns:
- the second level metadata values. Can be empty if there is no level2 attribute on root page.
-
encodeLevelValue
Encode level value to be use into a URI. Double-encode characters ':', '-' and '/'.- Parameters:
value
- The raw value- Returns:
- the encoded value
-
decodeLevelValue
Decode level value used in a URI- Parameters:
value
- The encoded value- Returns:
- the decoded value
-
getPageName
- Parameters:
item
- The program item- Returns:
- The page's name
- Throws:
IllegalArgumentException
- if the program item is not aAbstractProgram
nor aCourse
.
-
getEligibleAttributesForLevel
Get the eligible enumerated attribute definitions for ODF page level- Returns:
- the eligible attribute definitions
-
getCatalogs
Get the ODF catalogs- Returns:
- the ODF catalogs
-
getEnumeratedAttributes
public Map<String,ModelItem> getEnumeratedAttributes(String programContentTypeId, boolean allowMultiple) Get the enumerated attribute definitions for the given content type. Attribute with enumerator or content attribute are considered as enumerated- Parameters:
programContentTypeId
- The content type's idallowMultiple
-true
true to allow multiple attributes- Returns:
- The definitions of enumerated attributes
-
computeLevelsPath
Compute the path from the root odf page, representing the first and second level pages.- Parameters:
rootPage
- The odf root pageparentProgram
- The program to compute- Returns:
- the path
-