Class SystemHelper
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.runtime.plugins.admin.system.SystemHelper
-
- All Implemented Interfaces:
Component
,Contextualizable
,LogEnabled
,Serviceable
public class SystemHelper extends AbstractLogEnabled implements Component, Serviceable, Contextualizable
Helper for manipulating system announcement
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SystemHelper.SystemAnnouncement
Class representing the system announcement file
-
Field Summary
Fields Modifier and Type Field Description static String
ADMINISTRATOR_SYSTEM_FILE
The relative path to the file where system information are saved (announcement, maintenance...)static String
ROLE
Avalon role
-
Constructor Summary
Constructors Constructor Description SystemHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
contextualize(Context context)
Map
deleteAnnouncement(String language)
Delete a announcementMap<String,Object>
editAnnouncement(String language, String message, boolean override)
Add or edit a system announcementlong
getSystemAnnoucementLastModificationDate()
Return the date of the last modification of the annonceString
getSystemAnnouncement(String languageCode)
Returns the system announcement for the given language code, or for the default language code if there is no specified announcement for the given language code.
Returns null if the system announcements are not activated.boolean
isSystemAnnouncementAvailable()
Tests if system announcements are active.SystemHelper.SystemAnnouncement
readValues()
Read the system announcement's valuesvoid
service(ServiceManager serviceManager)
void
setAnnouncementAvailable(boolean available)
Enables or disable system announcement-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
ADMINISTRATOR_SYSTEM_FILE
public static final String ADMINISTRATOR_SYSTEM_FILE
The relative path to the file where system information are saved (announcement, maintenance...)- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SystemHelper
public SystemHelper()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
setAnnouncementAvailable
public void setAnnouncementAvailable(boolean available) throws ProcessingException
Enables or disable system announcement- Parameters:
available
- true to enable system announcement- Throws:
ProcessingException
- if an error occurred
-
editAnnouncement
public Map<String,Object> editAnnouncement(String language, String message, boolean override) throws Exception
Add or edit a system announcement- Parameters:
language
- the language typed in by the user or "*" if modifying the default messagemessage
- the message to add nor editoverride
- true to override the existing value if exists- Returns:
- the result map
- Throws:
Exception
- if an exception occurs
-
deleteAnnouncement
public Map deleteAnnouncement(String language) throws ProcessingException
Delete a announcement- Parameters:
language
- the language of the announcement to delete- Returns:
- an empty map
- Throws:
ProcessingException
- if an exception occurs
-
isSystemAnnouncementAvailable
public boolean isSystemAnnouncementAvailable()
Tests if system announcements are active.- Returns:
- true if system announcements are active.
-
getSystemAnnoucementLastModificationDate
public long getSystemAnnoucementLastModificationDate()
Return the date of the last modification of the annonce- Returns:
- The date of the last modification or 0 if there is no announce file
-
getSystemAnnouncement
public String getSystemAnnouncement(String languageCode)
Returns the system announcement for the given language code, or for the default language code if there is no specified announcement for the given language code.
Returns null if the system announcements are not activated.- Parameters:
languageCode
- the desired language code of the system announcement- Returns:
- the system announcement in the specified language code, or in the default language code, or null if announcements are not active.
-
readValues
public SystemHelper.SystemAnnouncement readValues()
Read the system announcement's values- Returns:
- The system announcement values;
-
-