Move the date macro to a separate module #112#113
Conversation
* Created a submodule for the date macro * Created a submodule for the date macro api * separated the date configuration from the task manager application and created a new configuration class for the date macro * Moved the date macro logic from the task-manager-application-default to date-macro-default * Created a submodule for the date macro ui and moved translations and skin * code refactoring
trrenty
left a comment
There was a problem hiding this comment.
We have one more possible problem which we need to address. If an user has made changes to the Administration Section of the Task App before the upgrade, the storage format/display format will be lost/not taken into consideration anymore. This will cause the task macros to not work anymore unless the user changes the Admin section of the Date macro to match the other one.
To fix this, we could have, in the default module of the task app, a listener that on initialization will do the following:
- Look for the Administration.xml page of the Task App.
- Get the TaskManagerConfigurationClass object from that page
- If the storageDateFormat/displayDateFormat are not empty (after an upgrade, the Administration.xml file should still have the removed properties and the changed values)
- Get the Configuration.xml file of the Date macro.
- Get the ConfigurationClass of that page
- Update the storageDateFormat/displayDateFormat if they are empty
Let me know if you see a better solution.
This is an example of a listener that implements Initializable: https://github.com/xwikisas/application-confluence-migrator-pro/blob/main/application-confluence-migrator-pro-default/src/main/java/com/xwiki/confluencepro/internal/DocumentFilterOverrideListener.java
application-task-ui/src/main/resources/TaskManager/TaskManagerConfigurationClass.xml
Show resolved
Hide resolved
application-task-api/src/main/java/com/xwiki/task/TaskConfiguration.java
Show resolved
Hide resolved
...pplication-task-date-default/src/main/java/com/xwiki/task/date/script/DateScriptService.java
Show resolved
Hide resolved
application-task-date/application-task-date-ui/src/main/resources/DateMacro/Configuration.xml
Outdated
Show resolved
Hide resolved
application-task-date/application-task-date-ui/src/main/resources/DateMacro/WebHome.xml
Outdated
Show resolved
Hide resolved
application-task-default/src/main/java/com/xwiki/task/internal/DefaultTaskConfiguration.java
Show resolved
Hide resolved
* moved date macro script service from default to api module * added back as deprecated the replaced classes and methods * removed code leftover * made Date macro.WebHome visible * added a listener to migrate the date format configuration from the task applicationm configuration to the new date macro configuration * code refactoring
...n-task-date-default/src/main/java/com/xwiki/task/date/internal/DefaultDateConfiguration.java
Outdated
Show resolved
Hide resolved
application-task-default/src/main/java/com/xwiki/task/internal/DateFormatOverrideListener.java
Outdated
Show resolved
Hide resolved
application-task-default/src/main/java/com/xwiki/task/internal/DateFormatOverrideListener.java
Outdated
Show resolved
Hide resolved
application-task-default/src/main/java/com/xwiki/task/internal/DateFormatOverrideListener.java
Outdated
Show resolved
Hide resolved
| try { | ||
| maybeReplaceDateFormat(); | ||
| } catch (ConfigurationSaveException e) { | ||
| throw new InitializationException(e.getMessage()); |
There was a problem hiding this comment.
I think it would be better to ignore it rather than throw an InitializationException. I believe the thrown exception will print the entire stack in the server logs which is quite the overkill. I believe the exception is thrown only when restarting the wiki, right? Or is it thrown even at upgrade time as well
There was a problem hiding this comment.
I'm not entirely sure what you're referring to. The initialize method is called at every startup and every upgrade, so an error may occur at every start and upgrade. I think it's ok to log the error, as it should not be a common occurrence.
* modified date groupid * code refactoring
Created a submodule for the date macro, separated the date configuration from the task manager application and created a new configuration class for the date macro.
Moved the date macro logic from the application-task-default to application-task-date-default. Created a submodule for the date macro ui and moved translations and skins.