Package org.ametys.plugins.core.ui.help
Class HelpManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.core.ui.help.HelpManager
-
- All Implemented Interfaces:
FileReloader
,LogEnabled
,Initializable
,Component
,Serviceable
public class HelpManager extends AbstractLogEnabled implements Component, Serviceable, FileReloader, Initializable
Provides the url associated to a family/id
-
-
Field Summary
Fields Modifier and Type Field Description private FileReloaderUtils
_fileReloader
private HelpExtensionPoint
_helpEP
protected Map<String,HelpLink>
_links
The map of rightId, Right of declared rightsprivate static String
DEFAULT_HELP_URL
private static String
DEFAULT_SEARCH_URL
static String
ROLE
The avalon role
-
Constructor Summary
Constructors Constructor Description HelpManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private HelpLink
_addLink(Configuration linkConfiguration, String pluginName, String featureName)
adds a link in the global plugin mapprivate String
_getAnyLanguageHelp(String family, String id)
private String
_getAnyLanguageHelp(HelpLink helpLink)
private String
_getHelp(String family, String id, String lang)
Map<String,Object>
getDefaultHelpUrl()
Get the default help urlString
getHelp(String family, String id, String lang)
Get the url for help for this family/id or null if not foundString
getHelp(String family, String id, List<String> languages)
Get the url for help for this family/id or null if not foundMap<String,Object>
getHelpUrl(String family, String id, String lang)
Get the url for help for this family/id.String
getId(String sourceUrl)
Get an unique ID for this File ReloaderMap<String,Object>
getSearchUrl()
Get the search urlvoid
initialize()
Map<String,HelpLink>
parseConfigFile(Configuration configuration, String pluginName, String featureName)
parse a configuration file for a plugin (plugin name and id)void
service(ServiceManager manager)
void
updateFile(String sourceUrl, Source source, InputStream is)
Update the file, the sourceUrl is only there if you manage multiple files, the Configuration object is already present to read it-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
DEFAULT_HELP_URL
private static final String DEFAULT_HELP_URL
- See Also:
- Constant Field Values
-
DEFAULT_SEARCH_URL
private static final String DEFAULT_SEARCH_URL
- See Also:
- Constant Field Values
-
_fileReloader
private FileReloaderUtils _fileReloader
-
_helpEP
private HelpExtensionPoint _helpEP
-
-
Constructor Detail
-
HelpManager
public HelpManager()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getHelpUrl
public Map<String,Object> getHelpUrl(String family, String id, String lang) throws Exception
Get the url for help for this family/id. The result is a map containing "url", "error" and "error-cause"- Parameters:
family
- the family for this link (for example an extension point)id
- id in the family (must be unique in the family)lang
- requested language- Returns:
- an Map containg the URL for help. If this language is not found, a default language will be searched, then any language. If nothing is found, the url will be null.
- Throws:
Exception
- impossible to read the default help file
-
getDefaultHelpUrl
public Map<String,Object> getDefaultHelpUrl()
Get the default help url- Returns:
- The result (map with an url key, or possible error)
-
getSearchUrl
public Map<String,Object> getSearchUrl()
Get the search url- Returns:
- The result (map with an url key, or possible error)
-
getHelp
public String getHelp(String family, String id, String lang) throws Exception
Get the url for help for this family/id or null if not found- Parameters:
family
- the family for this link (for example an extension point)id
- id in the family (must be unique in the family)lang
- requested language- Returns:
- an URL for help. If this language is not found, a default language will be searched, then any language, and null if really nothing is found
- Throws:
Exception
- impossible to read the default help file
-
getHelp
public String getHelp(String family, String id, List<String> languages) throws Exception
Get the url for help for this family/id or null if not found- Parameters:
family
- the family for this link (for example an extension point)id
- id in the family (must be unique in the family)languages
- Ordered list of requested languages- Returns:
- an URL for help. If no language is found, a default language will be searched, then any other language, and null if really nothing is found
- Throws:
Exception
- impossible to read the default help file
-
_getAnyLanguageHelp
private String _getAnyLanguageHelp(String family, String id)
-
_getAnyLanguageHelp
private String _getAnyLanguageHelp(HelpLink helpLink)
-
updateFile
public void updateFile(String sourceUrl, Source source, InputStream is) throws Exception
Description copied from interface:FileReloader
Update the file, the sourceUrl is only there if you manage multiple files, the Configuration object is already present to read it- Specified by:
updateFile
in interfaceFileReloader
- Parameters:
sourceUrl
- the url of the file.source
- the source to read, can be null if no file was readis
- the input stream to read, can be null if no file was read- Throws:
Exception
- something went wrong while reading the inputstream
-
getId
public String getId(String sourceUrl)
Description copied from interface:FileReloader
Get an unique ID for this File Reloader- Specified by:
getId
in interfaceFileReloader
- Parameters:
sourceUrl
- this is passed as an argument if your class read multiple files. If it reads only one file, the full class name can be a good enough ID- Returns:
- an unique ID
-
parseConfigFile
public Map<String,HelpLink> parseConfigFile(Configuration configuration, String pluginName, String featureName)
parse a configuration file for a plugin (plugin name and id)- Parameters:
configuration
- the configurationpluginName
- Unique identifier for the plugin hosting the extension (for logs)featureName
- Unique feature identifier (unique for a given pluginName) (for logs)- Returns:
- a map of HelpLink.uniqueId HelpLink representing the help URLs found in the configuration file
-
_addLink
private HelpLink _addLink(Configuration linkConfiguration, String pluginName, String featureName)
adds a link in the global plugin map- Parameters:
linkConfiguration
- link node in the configurationpluginName
- Unique identifier for the plugin hosting the extension (for logs)featureName
- Unique feature identifier (unique for a given pluginName) (for logs)- Returns:
- the link or null
-
-