From 13267f4a42072adc4f5f1973445e846ddb0917dc Mon Sep 17 00:00:00 2001 From: Johannes Hahn Date: Tue, 22 Aug 2023 10:26:51 +0200 Subject: [PATCH] Rename notification type class to UpdateAvailable --- .../rhn/domain/notification/NotificationMessage.java | 8 ++++---- .../domain/notification/types/NotificationType.java | 2 +- ...ailableNotification.java => UpdateAvailable.java} | 12 +++++++----- .../notification/types/test/UpdateAvailableTest.java | 10 +++++----- .../com/redhat/rhn/taskomatic/task/DailySummary.java | 4 ++-- java/conf/rhn_java.conf | 2 +- .../manager/notifications/notification-messages.tsx | 4 ++-- 7 files changed, 22 insertions(+), 20 deletions(-) rename java/code/src/com/redhat/rhn/domain/notification/types/{UpdateAvailableNotification.java => UpdateAvailable.java} (93%) diff --git a/java/code/src/com/redhat/rhn/domain/notification/NotificationMessage.java b/java/code/src/com/redhat/rhn/domain/notification/NotificationMessage.java index 39bed5cd696f..e4398979a1d1 100644 --- a/java/code/src/com/redhat/rhn/domain/notification/NotificationMessage.java +++ b/java/code/src/com/redhat/rhn/domain/notification/NotificationMessage.java @@ -25,7 +25,7 @@ import com.redhat.rhn.domain.notification.types.PaygAuthenticationUpdateFailed; import com.redhat.rhn.domain.notification.types.StateApplyFailed; import com.redhat.rhn.domain.notification.types.SubscriptionWarning; -import com.redhat.rhn.domain.notification.types.UpdateAvailableNotification; +import com.redhat.rhn.domain.notification.types.UpdateAvailable; import com.google.gson.Gson; @@ -135,8 +135,8 @@ public NotificationData getNotificationData() { return new Gson().fromJson(getData(), EndOfLifePeriod.class); case SubscriptionWarning: return new Gson().fromJson(getData(), SubscriptionWarning.class); - case UpdateAvailableNotification: - return new Gson().fromJson(getData(), UpdateAvailableNotification.class); + case UpdateAvailable: + return new Gson().fromJson(getData(), UpdateAvailable.class); default: throw new RuntimeException("Notification type not found"); } } @@ -156,7 +156,7 @@ public String getTypeAsString() { case PaygAuthenticationUpdateFailed: return "PAYG refresh failed"; case EndOfLifePeriod: return "End of Life Period"; case SubscriptionWarning: return "Subscription Warning"; - case UpdateAvailableNotification: return "Updates are Available"; + case UpdateAvailable: return "Updates are Available"; default: return getType().name(); } } diff --git a/java/code/src/com/redhat/rhn/domain/notification/types/NotificationType.java b/java/code/src/com/redhat/rhn/domain/notification/types/NotificationType.java index c89c44a79469..99ca32a3548d 100644 --- a/java/code/src/com/redhat/rhn/domain/notification/types/NotificationType.java +++ b/java/code/src/com/redhat/rhn/domain/notification/types/NotificationType.java @@ -26,5 +26,5 @@ public enum NotificationType { PaygAuthenticationUpdateFailed, EndOfLifePeriod, SubscriptionWarning, - UpdateAvailableNotification, + UpdateAvailable, } diff --git a/java/code/src/com/redhat/rhn/domain/notification/types/UpdateAvailableNotification.java b/java/code/src/com/redhat/rhn/domain/notification/types/UpdateAvailable.java similarity index 93% rename from java/code/src/com/redhat/rhn/domain/notification/types/UpdateAvailableNotification.java rename to java/code/src/com/redhat/rhn/domain/notification/types/UpdateAvailable.java index 1558f19daec1..92ea99cfdfe4 100644 --- a/java/code/src/com/redhat/rhn/domain/notification/types/UpdateAvailableNotification.java +++ b/java/code/src/com/redhat/rhn/domain/notification/types/UpdateAvailable.java @@ -14,7 +14,6 @@ */ package com.redhat.rhn.domain.notification.types; - import com.redhat.rhn.common.conf.ConfigDefaults; import com.redhat.rhn.common.localization.LocalizationService; import com.redhat.rhn.domain.notification.NotificationMessage; @@ -25,10 +24,13 @@ import java.io.IOException; -public class UpdateAvailableNotification implements NotificationData { +/** + * Notification data for an update being available for the server. + */ +public class UpdateAvailable implements NotificationData { private static final LocalizationService LOCALIZATION_SERVICE = LocalizationService.getInstance(); - private static final Logger LOG = LogManager.getLogger(UpdateAvailableNotification.class); + private static final Logger LOG = LogManager.getLogger(UpdateAvailable.class); private static final String UYUNI_PATCH_REPO = "systemsmanagement_Uyuni_Stable_Patches"; private static final String UYUNI_UPDATE_REPO = "systemsmanagement_Uyuni_Stable"; @@ -41,7 +43,7 @@ public class UpdateAvailableNotification implements NotificationData { * * @param runtimeIn runtime object for command execution */ - public UpdateAvailableNotification(Runtime runtimeIn) { + public UpdateAvailable(Runtime runtimeIn) { this.runtime = runtimeIn; } @@ -85,7 +87,7 @@ public NotificationMessage.NotificationMessageSeverity getSeverity() { @Override public NotificationType getType() { - return NotificationType.UpdateAvailableNotification; + return NotificationType.UpdateAvailable; } @Override diff --git a/java/code/src/com/redhat/rhn/domain/notification/types/test/UpdateAvailableTest.java b/java/code/src/com/redhat/rhn/domain/notification/types/test/UpdateAvailableTest.java index b39e3f14ced3..df327b7a6b53 100644 --- a/java/code/src/com/redhat/rhn/domain/notification/types/test/UpdateAvailableTest.java +++ b/java/code/src/com/redhat/rhn/domain/notification/types/test/UpdateAvailableTest.java @@ -21,7 +21,7 @@ import com.redhat.rhn.common.conf.ConfigDefaults; import com.redhat.rhn.domain.notification.NotificationMessage; import com.redhat.rhn.domain.notification.types.NotificationType; -import com.redhat.rhn.domain.notification.types.UpdateAvailableNotification; +import com.redhat.rhn.domain.notification.types.UpdateAvailable; import com.redhat.rhn.testing.MockObjectTestCase; import org.jmock.Expectations; @@ -45,8 +45,8 @@ public void setUp() { @Test public void testPropertiesAndStrings() { - UpdateAvailableNotification notification = new UpdateAvailableNotification(runtimeMock); - assertEquals(NotificationType.UpdateAvailableNotification, notification.getType()); + UpdateAvailable notification = new UpdateAvailable(runtimeMock); + assertEquals(NotificationType.UpdateAvailable, notification.getType()); assertEquals(NotificationMessage.NotificationMessageSeverity.warning, notification.getSeverity()); assertEquals("Updates are available.", notification.getSummary()); if (ConfigDefaults.get().isUyuni()) { @@ -77,7 +77,7 @@ public void testUpdatesAvailable() { e.printStackTrace(); } - UpdateAvailableNotification notification = new UpdateAvailableNotification(runtimeMock); + UpdateAvailable notification = new UpdateAvailable(runtimeMock); assertTrue(notification.updateAvailable()); } @@ -97,7 +97,7 @@ public void testNoUpdatesAvailable() { e.printStackTrace(); } - UpdateAvailableNotification notification = new UpdateAvailableNotification(runtimeMock); + UpdateAvailable notification = new UpdateAvailable(runtimeMock); assertFalse(notification.updateAvailable()); } } diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/DailySummary.java b/java/code/src/com/redhat/rhn/taskomatic/task/DailySummary.java index 486bd01d398d..5e970a7a2674 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/DailySummary.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/DailySummary.java @@ -24,7 +24,7 @@ import com.redhat.rhn.domain.notification.UserNotificationFactory; import com.redhat.rhn.domain.notification.types.EndOfLifePeriod; import com.redhat.rhn.domain.notification.types.SubscriptionWarning; -import com.redhat.rhn.domain.notification.types.UpdateAvailableNotification; +import com.redhat.rhn.domain.notification.types.UpdateAvailable; import com.redhat.rhn.domain.org.OrgFactory; import com.redhat.rhn.domain.role.RoleFactory; import com.redhat.rhn.frontend.dto.ActionMessage; @@ -142,7 +142,7 @@ private void processSubscriptionWarningNotification() { } private void processUpdateAvailableNotification() { - UpdateAvailableNotification uan = new UpdateAvailableNotification(Runtime.getRuntime()); + UpdateAvailable uan = new UpdateAvailable(Runtime.getRuntime()); if (uan.updateAvailable()) { NotificationMessage notificationMessage = UserNotificationFactory.createNotificationMessage(uan); diff --git a/java/conf/rhn_java.conf b/java/conf/rhn_java.conf index 60374aafe58f..0ff252b7690f 100644 --- a/java/conf/rhn_java.conf +++ b/java/conf/rhn_java.conf @@ -217,7 +217,7 @@ java.kiwi_os_image_building_enabled = true java.notifications_lifetime = 30 # Configure the disablement of notification messages by type - example disabling all notification types -#java.notifications_type_disabled = OnboardingFailed,ChannelSyncFailed,ChannelSyncFinished,CreateBootstrapRepoFailed,StateApplyFailed,UpdateAvailableNotification,SubscriptionWarning +#java.notifications_type_disabled = OnboardingFailed,ChannelSyncFailed,ChannelSyncFinished,CreateBootstrapRepoFailed,StateApplyFailed,UpdateAvailable,SubscriptionWarning java.notifications_type_disabled = ChannelSyncFinished # Maximal number of parallel connections to refresh from SCC diff --git a/web/html/src/manager/notifications/notification-messages.tsx b/web/html/src/manager/notifications/notification-messages.tsx index 98635783b675..bb45aa9b54da 100644 --- a/web/html/src/manager/notifications/notification-messages.tsx +++ b/web/html/src/manager/notifications/notification-messages.tsx @@ -56,8 +56,8 @@ const _MESSAGE_TYPE = { id: "SubscriptionWarning", text: t("Subscription Warning"), }, - UpdateAvailableNotification: { - id: "UpdateAvailableNotification", + UpdateAvailable: { + id: "UpdateAvailable", text: t("Update Notification"), }, };