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
Fields Modifier and Type Field Description protected CatalogsManager
_catalogsManager
The ODF Catalog enumerationprotected ContentHelper
_contentHelper
Content helperprotected ContentTypesHelper
_contentTypesHelper
Content types helperprotected ContentTypeExtensionPoint
_cTypeEP
The content type extension point.protected Map<String,Map<String,Boolean>>
_hasOdfRoot
For each site, indicate if an ODF root is present.protected I18nUtils
_i18nUtils
The i18n utils.protected ServiceManager
_manager
Avalon service managerprotected OdfClassificationHandler
_odfClassificationHandler
Root orgunit providerprotected OdfReferenceTableHelper
_odfReferenceTableHelper
Odf reference table helperprotected OdfProgramRestrictionManager
_odfRestrictionsManager
Restriction managerprotected Map<String,Map<String,Map<String,Set<String>>>>
_odfRootPages
The ODF root pages, indexed by workspace, site and sitemap name.protected RootOrgUnitProvider
_orgUnitProvider
Root orgunit providerprotected AmetysObjectResolver
_resolver
The ametys object resolver.protected WorkspaceSelector
_workspaceSelector
The workspace selector.static String
CATALOG_DATA_NAME
Catalog data name.static String
LEVEL1_ATTRIBUTE_NAME
First level attribute name.static String
LEVEL2_ATTRIBUTE_NAME
Second level attribute name.protected static List<String>
NON_ELIGIBLE_CTYPES_FOR_LEVEL
Content types that are not eligible for first and second levelstatic String
ROLE
The avalon role.
-
Constructor Summary
Constructors Constructor Description OdfPageHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Page
_getOdfRootPage(String siteName, String sitemapName)
Get the ODF root page.protected Set<Page>
_getOdfRootPages(String siteName, String sitemapName)
Get the ODF root page.void
clearRootCache()
Clear the ODF root page cache.void
clearRootCache(String siteName, String sitemapName)
Clear the ODF root page cache for a given site and language.String
computeLevelsPath(Page rootPage, Program parentProgram)
Compute the path from the root odf page, representing the first and second level pages.String
decodeLevelValue(String value)
Decode level value used in a URIString
encodeLevelValue(String value)
Encode level value to be use into a URI.String
getCatalog(Page rootPage)
Get the catalog value of the ODF root pageMap<String,I18nizableText>
getCatalogs()
Get the ODF catalogsMap<String,ModelItem>
getEligibleAttributesForLevel()
Get the eligible enumerated attribute definitions for ODF page levelMap<String,ModelItem>
getEnumeratedAttributes(String programContentTypeId, boolean allowMultiple)
Get the enumerated attribute definitions for the given content type.String
getLevel1Metadata(String siteName, String sitemapName, String catalog)
Get the first level metadata name.String
getLevel1Metadata(Page rootPage)
Get the first level metadata name.String
getLevel1PageName(Page rootPage, Program program)
Get the name of the page of first level for a given programMap<String,OdfClassificationHandler.LevelValue>
getLevel1Values(String siteName, String sitemapName, String catalog)
Get the first level metadata values (with translated label).Map<String,OdfClassificationHandler.LevelValue>
getLevel1Values(Page rootPage)
Get the first level metadata values (with translated label)String
getLevel2Metadata(String siteName, String sitemapName, String catalog)
Get the second level metadata name.String
getLevel2Metadata(Page rootPage)
Get the second level metadata name.String
getLevel2PageName(Page rootPage, Program program)
Get the name of the page of second level for a given programMap<String,OdfClassificationHandler.LevelValue>
getLevel2Values(String siteName, String sitemapName, String catalog)
Get the second level metadata values (with translated label).Map<String,OdfClassificationHandler.LevelValue>
getLevel2Values(Page rootPage)
Get the second level metadata values (with translated label).Page
getOdfRootPage(String siteName, String sitemapName)
Get the first ODF root page.Page
getOdfRootPage(String siteName, String sitemapName, String catalogName)
Get ODF root page of a specific catalog.List<String>
getOdfRootPageIds(String siteName, String sitemapName)
Get the id of ODF root pagesSet<Page>
getOdfRootPages(String siteName, String sitemapName)
Get the ODF root pages.String
getOrgunitIdFromUaiCode(Page rootPage, String uaiCode)
Get the orgunit identifier given an uai codeString
getPageName(ProgramItem item)
Returns the page's name of aProgramItem
.String
getProgramLevel1Value(Page rootPage, Program program)
Get the first level value of a program by extracting and transforming the raw program valueString
getProgramLevel2Value(Page rootPage, Program program)
Get the second level value of a program by extracting and transforming the raw program valueString
getProgramLevelValue(Program program, String levelMetaPath)
Get the level value of a program by extracting and transforming the raw program value at the desired metadata pathAmetysObjectIterable<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 restrictionsAmetysObjectIterable<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 restrictionsboolean
hasOdfRootPage(Site site)
Test if the given site has at least one sitemap with an odf root page.void
initialize()
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 Detail
-
LEVEL1_ATTRIBUTE_NAME
public static final String LEVEL1_ATTRIBUTE_NAME
First level attribute name.- See Also:
- Constant Field Values
-
LEVEL2_ATTRIBUTE_NAME
public static final String LEVEL2_ATTRIBUTE_NAME
Second level attribute name.- See Also:
- Constant Field Values
-
CATALOG_DATA_NAME
public static final String CATALOG_DATA_NAME
Catalog data name.- See Also:
- Constant Field Values
-
NON_ELIGIBLE_CTYPES_FOR_LEVEL
protected static final List<String> NON_ELIGIBLE_CTYPES_FOR_LEVEL
Content types that are not eligible for first and second level
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver.
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils.
-
_cTypeEP
protected ContentTypeExtensionPoint _cTypeEP
The content type extension point.
-
_catalogsManager
protected CatalogsManager _catalogsManager
The ODF Catalog enumeration
-
_workspaceSelector
protected WorkspaceSelector _workspaceSelector
The workspace selector.
-
_odfRootPages
protected Map<String,Map<String,Map<String,Set<String>>>> _odfRootPages
The ODF root pages, indexed by workspace, site and sitemap name.
-
_hasOdfRoot
protected Map<String,Map<String,Boolean>> _hasOdfRoot
For each site, indicate if an ODF root is present.
-
_manager
protected ServiceManager _manager
Avalon service manager
-
_odfRestrictionsManager
protected OdfProgramRestrictionManager _odfRestrictionsManager
Restriction manager
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
Content types helper
-
_contentHelper
protected ContentHelper _contentHelper
Content helper
-
_odfReferenceTableHelper
protected OdfReferenceTableHelper _odfReferenceTableHelper
Odf reference table helper
-
_orgUnitProvider
protected RootOrgUnitProvider _orgUnitProvider
Root orgunit provider
-
_odfClassificationHandler
protected OdfClassificationHandler _odfClassificationHandler
Root orgunit provider
-
-
Constructor Detail
-
OdfPageHandler
public OdfPageHandler()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getOdfRootPage
public Page getOdfRootPage(String siteName, String sitemapName) throws AmetysRepositoryException
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
public boolean hasOdfRootPage(Site site)
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
public boolean isValidRestriction(Page rootPage, Program program)
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
public void clearRootCache()
Clear the ODF root page cache.
-
clearRootCache
public void clearRootCache(String siteName, String sitemapName)
Clear the ODF root page cache for a given site and language.- Parameters:
siteName
- the current site.sitemapName
- the current sitemap/language.
-
isODFRootPage
public boolean isODFRootPage(Page page)
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
public String getCatalog(Page rootPage)
Get the catalog value of the ODF root page- Parameters:
rootPage
- The ODF root page- Returns:
- the catalog value
-
getLevel1Metadata
public String getLevel1Metadata(String siteName, String sitemapName, String catalog)
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
public String getLevel1Metadata(Page rootPage)
Get the first level metadata name.- Parameters:
rootPage
- the ODF root page.- Returns:
- the first level metadata name.
-
getLevel2Metadata
public String getLevel2Metadata(String siteName, String sitemapName, String catalog)
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
public String getLevel2Metadata(Page rootPage)
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
public String getProgramLevelValue(Program program, String levelMetaPath)
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
public String getProgramLevel1Value(Page rootPage, Program program)
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
public String getProgramLevel2Value(Page rootPage, Program program)
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
public String getLevel1PageName(Page rootPage, Program program)
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
public String getLevel2PageName(Page rootPage, Program program)
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
public String getOrgunitIdFromUaiCode(Page rootPage, String uaiCode)
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
public Map<String,OdfClassificationHandler.LevelValue> getLevel1Values(Page rootPage)
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
public Map<String,OdfClassificationHandler.LevelValue> getLevel2Values(Page rootPage)
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
public String encodeLevelValue(String value)
Encode level value to be use into a URI. Double-encode characters ':', '-' and '/'.- Parameters:
value
- The raw value- Returns:
- the encoded value
-
decodeLevelValue
public String decodeLevelValue(String value)
Decode level value used in a URI- Parameters:
value
- The encoded value- Returns:
- the decoded value
-
getPageName
public String getPageName(ProgramItem item)
- Parameters:
item
- The program item- Returns:
- The page's name
- Throws:
IllegalArgumentException
- if the program item is not aAbstractProgram
nor aCourse
.
-
getEligibleAttributesForLevel
public Map<String,ModelItem> getEligibleAttributesForLevel()
Get the eligible enumerated attribute definitions for ODF page level- Returns:
- the eligible attribute definitions
-
getCatalogs
public Map<String,I18nizableText> 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
public String computeLevelsPath(Page rootPage, Program parentProgram)
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
-
-