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
public class GetThemeAction extends ServiceableAction implements Initializable
Returns the theme for a site
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
__PROJECT_ENABLED_CONF_ID
global configuration about projects enabled/disabledprotected String
_homeWebView
The home web view from the configurationprotected JSONUtils
_jsonUtils
JSON Utilsprotected SiteManager
_siteManager
Authentication Token Managerprotected SourceResolver
_sourceResolver
Source Resolverprotected static String
BASE_DIR
Path of the base directory for mobileapp confstatic String
THEME_JSON
Path of the theme.json file-
Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
-
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
-
Constructor Summary
Constructors Constructor Description GetThemeAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map
act(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
initialize()
protected Map<String,Object>
parseJson()
Get the content of the json file as a mapvoid
service(ServiceManager smanager)
protected List<Object>
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.protected Map<String,Object>
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 Detail
-
__PROJECT_ENABLED_CONF_ID
protected static final String __PROJECT_ENABLED_CONF_ID
global configuration about projects enabled/disabled- See Also:
- Constant Field Values
-
BASE_DIR
protected static final String BASE_DIR
Path of the base directory for mobileapp conf- See Also:
- Constant Field Values
-
THEME_JSON
public static final String THEME_JSON
Path of the theme.json file- See Also:
- Constant Field Values
-
_siteManager
protected SiteManager _siteManager
Authentication Token Manager
-
_sourceResolver
protected SourceResolver _sourceResolver
Source Resolver
-
_jsonUtils
protected JSONUtils _jsonUtils
JSON Utils
-
_homeWebView
protected String _homeWebView
The home web view from the configuration
-
-
Constructor Detail
-
GetThemeAction
public GetThemeAction()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableAction
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception
-
parseJson
protected Map<String,Object> parseJson() throws IOException
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.JsonParseException
Parse 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
protected String getImageUrl(String relativePath, Site site)
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
-
-