diff --git a/dotCMS/hotfix_tracking.md b/dotCMS/hotfix_tracking.md index 338f45702ff5..47e03272630c 100644 --- a/dotCMS/hotfix_tracking.md +++ b/dotCMS/hotfix_tracking.md @@ -166,3 +166,4 @@ This maintenance release includes the following code fixes: 159. https://github.com/dotCMS/core/issues/30420 : Fix Test CircuitBreakerUrlTest.testGet and RemoteAnnouncementsLoaderIntegrationTest.TestAnnouncementsLoader #30420 160. https://github.com/dotCMS/core/issues/29535 : Investigate and Resolve Session Already Invalidated Issue for PATCH API Call with Bearer Token #29535 161. https://github.com/dotCMS/core/issues/29938 : Many to One Relationship Not Maintained When Copied to New Host #29938 +162. https://github.com/dotCMS/core/issues/30156 : Create Notifications for LTS already EOL or upcoming EOL #30156 diff --git a/dotCMS/src/main/java/com/dotcms/cms/login/LoginServiceAPIFactory.java b/dotCMS/src/main/java/com/dotcms/cms/login/LoginServiceAPIFactory.java index 0a8d63bc1828..117ade873ca4 100644 --- a/dotCMS/src/main/java/com/dotcms/cms/login/LoginServiceAPIFactory.java +++ b/dotCMS/src/main/java/com/dotcms/cms/login/LoginServiceAPIFactory.java @@ -1,15 +1,26 @@ package com.dotcms.cms.login; +import static com.dotcms.util.CollectionsUtils.list; import static com.dotmarketing.util.CookieUtil.createJsonWebTokenCookie; import java.io.Serializable; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.Optional; +import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; + +import com.dotcms.api.system.event.message.MessageSeverity; +import com.dotcms.api.system.event.message.MessageType; +import com.dotcms.api.system.event.message.SystemMessageEventUtil; +import com.dotcms.api.system.event.message.builder.SystemMessageBuilder; +import com.dotcms.concurrent.DotConcurrentFactory; +import com.liferay.portal.language.LanguageException; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -291,7 +302,11 @@ public boolean doActionLogin(String userId, this.doAuthentication(userId, rememberMe, request, response); authenticated = true; - LicenseUtil.licenseExpiresMessage(APILocator.getUserAPI().loadUserById(userId)); + final User logInUser = APILocator.getUserAPI().loadUserById(userId); + LicenseUtil.licenseExpiresMessage(logInUser); + if (Config.getBooleanProperty("show.lts.eol.message", false)) { + messageLTSVersionEOL(logInUser); + } } if (authResult != Authenticator.SUCCESS) { @@ -547,6 +562,48 @@ public User getLoggedInUser( ){ } } - + /** + * Message to show LTS version is reaching or already reached EOL. + * Must set the property date.lts.eol in dotmarketing-config.properties, the date should be in MM/dd/yyyy format. + * Must set the property show.lts.eol.message in dotmarketing-config.properties to true. + * If the user has the CMSAdmin role, show the message when the days left for LTS to EOL is less than 30. + * If the LTS already went EOL, show the message to everyone. + */ + public static void messageLTSVersionEOL(final User user) throws DotDataException, LanguageException, ParseException { + final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); + final Date dateLTSEOL = dateFormat.parse(Config.getStringProperty("date.lts.eol", "12/31/2099")); //LTS EOL Date + final long daysleftToEOL = DateUtil.diffDates(new Date(), dateLTSEOL).get("diffDays"); //days left for LTS to EOL + SystemMessageBuilder message = null; + if (APILocator.getRoleAPI().doesUserHaveRole(user, APILocator.getRoleAPI().loadCMSAdminRole()) && //check if user have CMSAdmin Role + (daysleftToEOL <= 30) && (daysleftToEOL > 0)) { //check if days left for LTS to EOL is less than 30 and over 0 + //Message Admins that EOL is less than 30 days + message = new SystemMessageBuilder() + .setMessage(LanguageUtil.format( + user.getLocale(), + "lts.expires.soon.message", + daysleftToEOL)) + .setSeverity(MessageSeverity.WARNING) + .setType(MessageType.SIMPLE_MESSAGE) + .setLife(86400000); + } + //if LTS already EOL show message to everyone + if (daysleftToEOL <= 0) { + message = new SystemMessageBuilder() + .setMessage(LanguageUtil.get( + user.getLocale(), + "lts.expired.message")) + .setSeverity(MessageSeverity.ERROR) + .setType(MessageType.SIMPLE_MESSAGE) + .setLife(86400000); + } + if (null != message) { + final SystemMessageBuilder finalMessage = message; + DotConcurrentFactory.getInstance().getSubmitter().delay(() -> { + SystemMessageEventUtil.getInstance().pushMessage(finalMessage.create(), list(user.getUserId())); + Logger.info("", finalMessage.create().getMessage().toString()); + }, + 3000, TimeUnit.MILLISECONDS); + } + } } // E:O:F:LoginServiceAPIFactory. diff --git a/dotCMS/src/main/resources/dotmarketing-config.properties b/dotCMS/src/main/resources/dotmarketing-config.properties index 406bb44113ce..edd4fc19dde2 100644 --- a/dotCMS/src/main/resources/dotmarketing-config.properties +++ b/dotCMS/src/main/resources/dotmarketing-config.properties @@ -845,3 +845,7 @@ DOT_FEATURE_FLAG_TEMPLATE_BUILDER_2=true ## Experiments - A/B Testing FEATURE_FLAG_EXPERIMENTS=true + +##LTS properties to show EOL message +show.lts.eol.message=true +date.lts.eol=05/19/2025 diff --git a/dotCMS/src/main/webapp/WEB-INF/messages/Language.properties b/dotCMS/src/main/webapp/WEB-INF/messages/Language.properties index 3ed2cc7c5ad9..bde449bcdf7a 100644 --- a/dotCMS/src/main/webapp/WEB-INF/messages/Language.properties +++ b/dotCMS/src/main/webapp/WEB-INF/messages/Language.properties @@ -5561,4 +5561,7 @@ block-editor.extension.ai-image.auto-text.placeholder=E.g. 1200x800px, vibrant c block-editor.extension.ai-image.auto-text.tooltip=Describe the size, color palette, style, mood, etc. block-editor.extension.ai-image.api-error.missing-token=Error: Incorrect API key provided. You can find your API key at https://platform.openai.com/account/api-keys. block-editor.extension.ai-image.api-error.error-publishing-ai-image=Error publishing AI image -block-editor.extension.ai-image.api-error.no-choice-returned=No choices returned \ No newline at end of file +block-editor.extension.ai-image.api-error.no-choice-returned=No choices returned + +lts.expired.message = This version of dotCMS already reached EOL. Please contact your CSM to schedule an upgrade. +lts.expires.soon.message = Your dotCMS version will reach EOL in {0} days. Please contact your CSM to schedule an upgrade.