Class GetThemeAction
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.acting.AbstractAction
org.apache.cocoon.acting.ServiceableAction
org.ametys.plugins.mobileapp.action.GetThemeAction
- All Implemented Interfaces:
Initializable
,Component
,LogEnabled
,Serviceable
,Action
Returns the theme for a site
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
global configuration about projects enabled/disabledprotected String
The home web view from the configurationprotected JSONUtils
JSON Utilsprotected SiteManager
Authentication Token Managerprotected SourceResolver
Source Resolverprotected static final String
Path of the base directory for mobileapp confstatic final String
Path of the theme.json fileFields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionact
(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) protected String
getImageUrl
(String relativePath, Site site) Get thu full url of the theme image, based on the site url and used skinvoid
Get the content of the json file as a mapvoid
service
(ServiceManager smanager) transformList
(List<Object> jsonList, Site site) Parse the input json, and transform all String called src to be relative to the site and skin used.transformMap
(Map<String, Object> jsonMap, Site site) Parse the input json, and transform all String called src to be relative to the site and skin used.protected Object
transformObject
(String key, Object object, Site site) Parse the input json, and transform all String called src to be relative to the site and skin used.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
__PROJECT_ENABLED_CONF_ID
global configuration about projects enabled/disabled- See Also:
-
BASE_DIR
Path of the base directory for mobileapp conf- See Also:
-
THEME_JSON
Path of the theme.json file- See Also:
-
_siteManager
Authentication Token Manager -
_sourceResolver
Source Resolver -
_jsonUtils
JSON Utils -
_homeWebView
The home web view from the configuration
-
-
Constructor Details
-
GetThemeAction
public GetThemeAction()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableAction
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception -
parseJson
Get the content of the json file as a map- Returns:
- the map representing the json file
- Throws:
IOException
- impossible to read the json file
-
transformMap
protected Map<String,Object> transformMap(Map<String, Object> jsonMap, Site site) throws MalformedURLException, IOException, com.google.gson.JsonParseExceptionParse the input json, and transform all String called src to be relative to the site and skin used.- Parameters:
jsonMap
- the map read from the json filesite
- site to use to get it's url and skin- Returns:
- the json map with src modified
- Throws:
MalformedURLException
- impossible to find the json fileIOException
- impossible to read the json filecom.google.gson.JsonParseException
- json file inexistant or invalid
-
transformList
protected List<Object> transformList(List<Object> jsonList, Site site) throws MalformedURLException, IOException, com.google.gson.JsonParseException Parse the input json, and transform all String called src to be relative to the site and skin used.- Parameters:
jsonList
- a list in the json filesite
- site to use to get it's url and skin- Returns:
- the json map with src modified
- Throws:
MalformedURLException
- impossible to find the json fileIOException
- impossible to read the json filecom.google.gson.JsonParseException
- json file inexistant or invalid
-
transformObject
protected Object transformObject(String key, Object object, Site site) throws MalformedURLException, IOException, com.google.gson.JsonParseException Parse the input json, and transform all String called src to be relative to the site and skin used.- Parameters:
key
- in case the item was in a map, the key associated (only src will be translated)object
- the object to read from the jsonsite
- site to use to get it's url and skin- Returns:
- the json map with src modified
- Throws:
MalformedURLException
- impossible to find the json fileIOException
- impossible to read the json filecom.google.gson.JsonParseException
- json file inexistant or invalid
-
getImageUrl
Get thu full url of the theme image, based on the site url and used skin- Parameters:
relativePath
- path of the image in the skinsite
- site used- Returns:
- the image full url
-