Class SystemHelper
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.runtime.plugins.admin.system.SystemHelper
- All Implemented Interfaces:
Initializable
,Component
,Contextualizable
,LogEnabled
,Serviceable
public class SystemHelper
extends AbstractLogEnabled
implements Component, Serviceable, Contextualizable, Initializable
Helper for manipulating system announcement
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Class representing the system announcement file -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
contextualize
(Context context) deleteAnnouncement
(String language) Delete a announcementeditAnnouncement
(String language, String message, boolean override) Add or edit a system announcementlong
Return the date of the last modification of the annoncegetSystemAnnouncement
(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.Get the system announcement availabilityvoid
boolean
Tests if system announcements are active.Read the system announcement's valuesvoid
scheduleAnnouncement
(String startDateStr, String endDateStr) Schedule a system announcementvoid
service
(ServiceManager serviceManager) void
setAnnouncementAvailable
(boolean available) Enables or disable system announcementMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ADMINISTRATOR_SYSTEM_FILENAME
The relative path to the file where system information are saved (announcement, maintenance...)- See Also:
-
ROLE
Avalon role
-
-
Constructor Details
-
SystemHelper
public SystemHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
setAnnouncementAvailable
Enables or disable system announcement- Parameters:
available
- true to enable system announcement- Throws:
ProcessingException
- if an error occurred
-
scheduleAnnouncement
Schedule a system announcement- Parameters:
startDateStr
- the planned start date. Can be null for no start dateendDateStr
- the planned end date. Can be null for no end date- 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
Delete a announcement- Parameters:
language
- the language of the announcement to delete- Returns:
- an empty map
- Throws:
ProcessingException
- if an exception occurs
-
isSystemAnnouncementAvailable
Tests if system announcements are active.- Returns:
- true if system announcements are active.
-
getSystemAnnouncementAvailability
Get the system announcement availability- Returns:
- a map with the state, start date and end date
-
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
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
Read the system announcement's values- Returns:
- The system announcement values;
-