diff --git a/enterprise-backwards-compatibility/admin-audit-notifiers-backwards-compatibility/pom.xml b/enterprise-backwards-compatibility/admin-audit-notifiers-backwards-compatibility/pom.xml new file mode 100644 index 0000000..497e639 --- /dev/null +++ b/enterprise-backwards-compatibility/admin-audit-notifiers-backwards-compatibility/pom.xml @@ -0,0 +1,70 @@ + + + + + fish.payara.extensions.notifiers + enterprise-backwards-compatibility + 1.1-enterprise-SNAPSHOT + + 4.0.0 + + admin-audit-notifiers-backwards-compatibility + glassfish-jar + + Asadmin Audit Notification Service Backwards Compatibility + + + + fish.payara.extensions.notifiers + notifier-backwards-compatibility-core + ${project.version} + + + fish.payara.extensions.notifiers + email-notifier-backwards-compatibility + 1.1-enterprise-SNAPSHOT + compile + + + + \ No newline at end of file diff --git a/enterprise-backwards-compatibility/admin-audit-notifiers-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/audit/AdminAuditNotifiersUpgradeService.java b/enterprise-backwards-compatibility/admin-audit-notifiers-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/audit/AdminAuditNotifiersUpgradeService.java new file mode 100644 index 0000000..2235c08 --- /dev/null +++ b/enterprise-backwards-compatibility/admin-audit-notifiers-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/audit/AdminAuditNotifiersUpgradeService.java @@ -0,0 +1,193 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://github.com/payara/Payara/blob/master/LICENSE.txt + * See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at glassfish/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * The Payara Foundation designates this particular file as subject to the "Classpath" + * exception as provided by the Payara Foundation in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +package fish.payara.extensions.notifiers.compat.audit; + +import com.sun.enterprise.config.serverbeans.Config; +import com.sun.enterprise.config.serverbeans.Configs; +import com.sun.enterprise.util.StringUtils; +import fish.payara.audit.AdminAuditConfiguration; +import fish.payara.audit.AdminAuditService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.config.Notifier; +import fish.payara.internal.notification.admin.NotificationServiceConfiguration; +import org.glassfish.api.StartupRunLevel; +import org.glassfish.hk2.api.PostConstruct; +import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.hk2.runlevel.RunLevel; +import org.glassfish.internal.api.Globals; +import org.jvnet.hk2.annotations.Service; +import org.jvnet.hk2.config.ConfigSupport; +import org.jvnet.hk2.config.TransactionFailure; + +import javax.inject.Inject; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Service that upgrades legacy {@link NotificationServiceConfiguration} on server start for the + * {@link AdminAuditService}. Split out into its own module and service since Micro doesn't have this service present. + * + * @author Andrew Pielage + */ +@Service +@RunLevel(StartupRunLevel.VAL) +public class AdminAuditNotifiersUpgradeService implements PostConstruct { + + @Inject + private Configs configs; + + @Inject + private Logger logger; + + @Inject + private ServiceLocator serviceLocator; + + @Override + public void postConstruct() { + for (Config config : configs.getConfig()) { + // First up, get the notifier configuration for each config + NotificationServiceConfiguration notificationServiceConfiguration = config.getExtensionByType( + NotificationServiceConfiguration.class); + // If there is no notifier configuration whatsoever - just exit out. This **should** be an edge case - + // default config tags for the notification service have existed for a long time + if (notificationServiceConfiguration == null) { + continue; + } + + upgradeAdminAuditService(config); + } + } + + /** + * Upgrades any configured legacy notifiers for a given {@link AdminAuditConfiguration}, before removing + * the legacy config. If there is existing "upgraded" config, it does not override it. + *

+ * Split out from {@link LegacyNotifierUpgradeService} since Micro doesn't have the admin audit service + * and so runs into ClassNotFoundExceptions. + * + * @param config The {@link Config} to upgrade the {@link AdminAuditConfiguration} of. + */ + private void upgradeAdminAuditService(Config config) { + AdminAuditConfiguration adminAuditConfiguration = config.getExtensionByType( + AdminAuditConfiguration.class); + + if (adminAuditConfiguration == null) { + logger.log(Level.WARNING, "Could not find admin audit service configuration to upgrade for config: {0}", + config.getName()); + return; + } + + if (serviceLocator == null) { + serviceLocator = Globals.getDefaultBaseServiceLocator(); + if (serviceLocator == null) { + logger.log(Level.WARNING, "Could not find service locator to upgrade admin audit service. " + + "Notifiers for this service may behave unexpectedly"); + return; + } + } + + // For each legacy notifier in the admin audit configuration, upgrade it + for (Notifier notifier : adminAuditConfiguration.getLegacyNotifierList()) { + // Find all of the notifier upgrade services by searching for the contract + List legacyNotifierUpgradeServices = serviceLocator.getAllServices( + LegacyNotifierUpgradeService.class); + + // Search through the services until we find the upgrade service that matches what we're trying to upgrade + for (LegacyNotifierUpgradeService legacyNotifierUpgradeService : legacyNotifierUpgradeServices) { + // Since we're working with a ConfigBeanProxy we can't simply do notifier.getClass() since this would + // return the proxy class. Instead, we can grab the interfaces of this proxy to what's actually being + // proxied. In this case, each ConfigBeanProxy *should* only only have a single interface: the notifier + // config bean interface that we're trying to get (e.g. EmailNotifier) for our comparison + if (legacyNotifierUpgradeService.getUpgradeNotifierClass().equals( + notifier.getClass().getInterfaces()[0])) { + upgradeAdminAuditService(adminAuditConfiguration, notifier, + legacyNotifierUpgradeService.getNewNotifierName()); + break; + } + } + } + } + + /** + * Upgrades a legacy notifier of the given type for a given {@link AdminAuditConfiguration} before removing the + * legacy config. If there is existing "upgraded" config, it does not override it. + *

+ * Split out from {@link LegacyNotifierUpgradeService} since Micro doesn't have the admin audit service + * and so runs into ClassNotFoundExceptions. + * + * @param adminAuditConfiguration The {@link AdminAuditConfiguration} to upgrade + * @param notifierName The name of the notifier, corresponding to its XML tag in the domain.xml + * @param The type of legacy {@link Notifier} to upgrade + */ + private void upgradeAdminAuditService(AdminAuditConfiguration adminAuditConfiguration, + T notifier, String notifierName) { + + if (StringUtils.ok(notifier.getEnabled()) && Boolean.valueOf(notifier.getEnabled())) { + // Since this is enabled, there might be something for us to do. + // Get the new notifier config list to see if this notifier is enabled - we don't want to override an + // existing value + List notifiers = adminAuditConfiguration.getNotifierList(); + + if (!notifiers.contains(notifierName)) { + // No existing config to override, so let's migrate old to new + try { + ConfigSupport.apply(adminAuditConfigurationProxy -> { + adminAuditConfigurationProxy.getNotifierList().add(notifierName); + return adminAuditConfigurationProxy; + }, adminAuditConfiguration); + } catch (TransactionFailure transactionFailure) { + logger.log(Level.WARNING, "Failed to upgrade legacy notifier configuration", transactionFailure); + } + } + // And finally, delete the legacy config + try { + ConfigSupport.apply(adminAuditConfigurationProxy -> { + adminAuditConfigurationProxy.getLegacyNotifierList().remove(notifier); + return adminAuditConfigurationProxy; + }, adminAuditConfiguration); + } catch (TransactionFailure transactionFailure) { + logger.log(Level.WARNING, "Failed to remove legacy notifier configuration", transactionFailure); + } + } + } + +} \ No newline at end of file diff --git a/enterprise-backwards-compatibility/cdi-eventbus-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/cdieventbus/CdiEventBusUpgradeService.java b/enterprise-backwards-compatibility/cdi-eventbus-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/cdieventbus/CdiEventBusUpgradeService.java index b003387..12d6011 100644 --- a/enterprise-backwards-compatibility/cdi-eventbus-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/cdieventbus/CdiEventBusUpgradeService.java +++ b/enterprise-backwards-compatibility/cdi-eventbus-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/cdieventbus/CdiEventBusUpgradeService.java @@ -41,7 +41,8 @@ package fish.payara.extensions.notifiers.compat.cdieventbus; import com.sun.enterprise.config.serverbeans.Config; -import fish.payara.extensions.notifiers.compat.BaseNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.UpgradesNotifier; import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import org.glassfish.api.StartupRunLevel; import org.glassfish.hk2.runlevel.RunLevel; @@ -54,7 +55,8 @@ */ @Service @RunLevel(StartupRunLevel.VAL) -public class CdiEventBusUpgradeService extends BaseNotifierUpgradeService { +@UpgradesNotifier(CdiEventBusNotifier.class) +public class CdiEventBusUpgradeService extends LegacyNotifierUpgradeService { private static final String notifierName = "cdieventbus-notifier"; @@ -74,8 +76,12 @@ public void postConstruct() { upgradeRequestTracingService(config, notifierName, CdiEventBusNotifier.class); upgradeMonitoringService(config, notifierName, CdiEventBusNotifier.class); upgradeHealthCheckService(config, notifierName, CdiEventBusNotifier.class); - upgradeAdminAuditService(config, notifierName, CdiEventBusNotifier.class); } } + @Override + public String getNewNotifierName() { + return notifierName; + } + } diff --git a/enterprise-backwards-compatibility/datadog-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/datadog/DatadogNotifierUpgradeService.java b/enterprise-backwards-compatibility/datadog-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/datadog/DatadogNotifierUpgradeService.java index 8dc7e1d..8134b47 100644 --- a/enterprise-backwards-compatibility/datadog-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/datadog/DatadogNotifierUpgradeService.java +++ b/enterprise-backwards-compatibility/datadog-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/datadog/DatadogNotifierUpgradeService.java @@ -40,7 +40,8 @@ package fish.payara.extensions.notifiers.compat.datadog; import com.sun.enterprise.config.serverbeans.Config; -import fish.payara.extensions.notifiers.compat.BaseNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.UpgradesNotifier; import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import org.glassfish.api.StartupRunLevel; import org.glassfish.hk2.runlevel.RunLevel; @@ -53,7 +54,8 @@ */ @Service @RunLevel(StartupRunLevel.VAL) -public class DatadogNotifierUpgradeService extends BaseNotifierUpgradeService { +@UpgradesNotifier(DatadogNotifier.class) +public class DatadogNotifierUpgradeService extends LegacyNotifierUpgradeService { private static final String notifierName = "datadog-notifier"; @@ -73,7 +75,11 @@ public void postConstruct() { upgradeRequestTracingService(config, notifierName, DatadogNotifier.class); upgradeMonitoringService(config, notifierName, DatadogNotifier.class); upgradeHealthCheckService(config, notifierName, DatadogNotifier.class); - upgradeAdminAuditService(config, notifierName, DatadogNotifier.class); } } + + @Override + public String getNewNotifierName() { + return notifierName; + } } diff --git a/enterprise-backwards-compatibility/email-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/email/EmailNotifierUpgradeService.java b/enterprise-backwards-compatibility/email-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/email/EmailNotifierUpgradeService.java index 28b2fa2..0630ffa 100644 --- a/enterprise-backwards-compatibility/email-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/email/EmailNotifierUpgradeService.java +++ b/enterprise-backwards-compatibility/email-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/email/EmailNotifierUpgradeService.java @@ -41,7 +41,8 @@ import com.sun.enterprise.config.serverbeans.Config; import com.sun.enterprise.util.StringUtils; -import fish.payara.extensions.notifiers.compat.BaseNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.UpgradesNotifier; import fish.payara.extensions.notifiers.email.EmailNotifierConfiguration; import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import org.glassfish.api.StartupRunLevel; @@ -59,7 +60,8 @@ */ @Service @RunLevel(StartupRunLevel.VAL) -public class EmailNotifierUpgradeService extends BaseNotifierUpgradeService { +@UpgradesNotifier(EmailNotifier.class) +public class EmailNotifierUpgradeService extends LegacyNotifierUpgradeService { private static final String notifierName = "email-notifier"; @@ -76,8 +78,8 @@ public void postConstruct() { } // Next up, get the email notifier configuration for this config, creating default config tags if required - EmailNotifierConfiguration emailNotifierConfiguration = getNotifierConfiguration( - notificationServiceConfiguration, EmailNotifierConfiguration.class); + EmailNotifierConfiguration emailNotifierConfiguration = getEmailNotifierConfiguration( + notificationServiceConfiguration); // If we don't find the config or fail to create one, exit out - something has gone fundamentally wrong if (emailNotifierConfiguration == null) { logger.log(Level.WARNING, @@ -92,10 +94,44 @@ public void postConstruct() { upgradeRequestTracingService(config, notifierName, EmailNotifier.class); upgradeMonitoringService(config, notifierName, EmailNotifier.class); upgradeHealthCheckService(config, notifierName, EmailNotifier.class); - upgradeAdminAuditService(config, notifierName, EmailNotifier.class); } } + /** + * Retrieves the {@link EmailNotifierConfiguration} for a given {@link NotificationServiceConfiguration}. + * + * @param notificationServiceConfiguration The {@link NotificationServiceConfiguration} to get config from + * @return The {@link EmailNotifierConfiguration} for the specified {@link NotificationServiceConfiguration}, or + * null if it can't be found or created + */ + protected EmailNotifierConfiguration getEmailNotifierConfiguration( + NotificationServiceConfiguration notificationServiceConfiguration) { + EmailNotifierConfiguration emailNotifierConfiguration = notificationServiceConfiguration + .getNotifierConfigurationByType(EmailNotifierConfiguration.class); + // Will be null if no default config tags present + if (emailNotifierConfiguration == null) { + try { + // Create a transaction around the notifier config we want to add the element to, grab it's list + // of notifiers, and add a new child element to it + ConfigSupport.apply(notificationServiceConfigurationProxy -> { + notificationServiceConfigurationProxy.getNotifierConfigurationList().add( + notificationServiceConfigurationProxy.createChild(EmailNotifierConfiguration.class)); + return notificationServiceConfigurationProxy; + }, notificationServiceConfiguration); + } catch (TransactionFailure transactionFailure) { + logger.log(Level.WARNING, "Failed to upgrade legacy notifier configuration", transactionFailure); + return null; + } + + // Get the newly created config element + emailNotifierConfiguration = notificationServiceConfiguration.getNotifierConfigurationByType( + EmailNotifierConfiguration.class); + } + + // Could still be null! + return emailNotifierConfiguration; + } + private void upgradeNotifierService(EmailNotifierConfiguration emailNotifierConfiguration) { // Get the attributes to upgrade String to = emailNotifierConfiguration.getTo(); @@ -128,4 +164,9 @@ private void upgradeNotifierService(EmailNotifierConfiguration emailNotifierConf } } + @Override + public String getNewNotifierName() { + return notifierName; + } + } diff --git a/enterprise-backwards-compatibility/eventbus-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/eventbus/EventBusNotifierUpgradeService.java b/enterprise-backwards-compatibility/eventbus-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/eventbus/EventBusNotifierUpgradeService.java index 88d3068..13b3952 100644 --- a/enterprise-backwards-compatibility/eventbus-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/eventbus/EventBusNotifierUpgradeService.java +++ b/enterprise-backwards-compatibility/eventbus-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/eventbus/EventBusNotifierUpgradeService.java @@ -41,7 +41,8 @@ package fish.payara.extensions.notifiers.compat.eventbus; import com.sun.enterprise.config.serverbeans.Config; -import fish.payara.extensions.notifiers.compat.BaseNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.UpgradesNotifier; import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import org.glassfish.api.StartupRunLevel; import org.glassfish.hk2.runlevel.RunLevel; @@ -54,7 +55,8 @@ */ @Service @RunLevel(StartupRunLevel.VAL) -public class EventBusNotifierUpgradeService extends BaseNotifierUpgradeService { +@UpgradesNotifier(EventBusNotifier.class) +public class EventBusNotifierUpgradeService extends LegacyNotifierUpgradeService { private static final String notifierName = "eventbus-notifier"; @@ -74,7 +76,11 @@ public void postConstruct() { upgradeRequestTracingService(config, notifierName, EventBusNotifier.class); upgradeMonitoringService(config, notifierName, EventBusNotifier.class); upgradeHealthCheckService(config, notifierName, EventBusNotifier.class); - upgradeAdminAuditService(config, notifierName, EventBusNotifier.class); } } + + @Override + public String getNewNotifierName() { + return notifierName; + } } diff --git a/enterprise-backwards-compatibility/jms-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/jms/JmsNotifierUpgradeService.java b/enterprise-backwards-compatibility/jms-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/jms/JmsNotifierUpgradeService.java index cf81a01..26aae9e 100644 --- a/enterprise-backwards-compatibility/jms-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/jms/JmsNotifierUpgradeService.java +++ b/enterprise-backwards-compatibility/jms-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/jms/JmsNotifierUpgradeService.java @@ -41,7 +41,8 @@ package fish.payara.extensions.notifiers.compat.jms; import com.sun.enterprise.config.serverbeans.Config; -import fish.payara.extensions.notifiers.compat.BaseNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.UpgradesNotifier; import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import org.glassfish.api.StartupRunLevel; import org.glassfish.hk2.runlevel.RunLevel; @@ -54,7 +55,8 @@ */ @Service @RunLevel(StartupRunLevel.VAL) -public class JmsNotifierUpgradeService extends BaseNotifierUpgradeService { +@UpgradesNotifier(JmsNotifier.class) +public class JmsNotifierUpgradeService extends LegacyNotifierUpgradeService { private static final String notifierName = "jms-notifier"; @@ -74,7 +76,11 @@ public void postConstruct() { upgradeRequestTracingService(config, notifierName, JmsNotifier.class); upgradeMonitoringService(config, notifierName, JmsNotifier.class); upgradeHealthCheckService(config, notifierName, JmsNotifier.class); - upgradeAdminAuditService(config, notifierName, JmsNotifier.class); } } + + @Override + public String getNewNotifierName() { + return notifierName; + } } diff --git a/enterprise-backwards-compatibility/log-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/log/LogNotifierUpgradeService.java b/enterprise-backwards-compatibility/log-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/log/LogNotifierUpgradeService.java index e41e260..8fcf741 100644 --- a/enterprise-backwards-compatibility/log-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/log/LogNotifierUpgradeService.java +++ b/enterprise-backwards-compatibility/log-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/log/LogNotifierUpgradeService.java @@ -41,7 +41,8 @@ package fish.payara.extensions.notifiers.compat.log; import com.sun.enterprise.config.serverbeans.Config; -import fish.payara.extensions.notifiers.compat.BaseNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.UpgradesNotifier; import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import org.glassfish.api.StartupRunLevel; import org.glassfish.hk2.runlevel.RunLevel; @@ -54,7 +55,8 @@ */ @Service @RunLevel(StartupRunLevel.VAL) -public class LogNotifierUpgradeService extends BaseNotifierUpgradeService { +@UpgradesNotifier(LogNotifier.class) +public class LogNotifierUpgradeService extends LegacyNotifierUpgradeService { private static final String notifierName = "log-notifier"; @@ -74,7 +76,11 @@ public void postConstruct() { upgradeRequestTracingService(config, notifierName, LogNotifier.class); upgradeMonitoringService(config, notifierName, LogNotifier.class); upgradeHealthCheckService(config, notifierName, LogNotifier.class); - upgradeAdminAuditService(config, notifierName, LogNotifier.class); } } + + @Override + public String getNewNotifierName() { + return notifierName; + } } diff --git a/enterprise-backwards-compatibility/newrelic-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/newrelic/NewRelicNotifierUpgradeService.java b/enterprise-backwards-compatibility/newrelic-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/newrelic/NewRelicNotifierUpgradeService.java index 259bc66..eb98287 100644 --- a/enterprise-backwards-compatibility/newrelic-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/newrelic/NewRelicNotifierUpgradeService.java +++ b/enterprise-backwards-compatibility/newrelic-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/newrelic/NewRelicNotifierUpgradeService.java @@ -41,7 +41,8 @@ package fish.payara.extensions.notifiers.compat.newrelic; import com.sun.enterprise.config.serverbeans.Config; -import fish.payara.extensions.notifiers.compat.BaseNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.UpgradesNotifier; import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import org.glassfish.api.StartupRunLevel; import org.glassfish.hk2.runlevel.RunLevel; @@ -54,7 +55,8 @@ */ @Service @RunLevel(StartupRunLevel.VAL) -public class NewRelicNotifierUpgradeService extends BaseNotifierUpgradeService { +@UpgradesNotifier(NewRelicNotifier.class) +public class NewRelicNotifierUpgradeService extends LegacyNotifierUpgradeService { private static final String notifierName = "newrelic-notifier"; @@ -74,7 +76,11 @@ public void postConstruct() { upgradeRequestTracingService(config, notifierName, NewRelicNotifier.class); upgradeMonitoringService(config, notifierName, NewRelicNotifier.class); upgradeHealthCheckService(config, notifierName, NewRelicNotifier.class); - upgradeAdminAuditService(config, notifierName, NewRelicNotifier.class); } } + + @Override + public String getNewNotifierName() { + return notifierName; + } } diff --git a/enterprise-backwards-compatibility/notifier-backwards-compatibility-core/src/main/java/fish/payara/extensions/notifiers/compat/BaseNotifierUpgradeService.java b/enterprise-backwards-compatibility/notifier-backwards-compatibility-core/src/main/java/fish/payara/extensions/notifiers/compat/LegacyNotifierUpgradeService.java similarity index 68% rename from enterprise-backwards-compatibility/notifier-backwards-compatibility-core/src/main/java/fish/payara/extensions/notifiers/compat/BaseNotifierUpgradeService.java rename to enterprise-backwards-compatibility/notifier-backwards-compatibility-core/src/main/java/fish/payara/extensions/notifiers/compat/LegacyNotifierUpgradeService.java index 3fff930..1fc0446 100644 --- a/enterprise-backwards-compatibility/notifier-backwards-compatibility-core/src/main/java/fish/payara/extensions/notifiers/compat/BaseNotifierUpgradeService.java +++ b/enterprise-backwards-compatibility/notifier-backwards-compatibility-core/src/main/java/fish/payara/extensions/notifiers/compat/LegacyNotifierUpgradeService.java @@ -43,15 +43,13 @@ import com.sun.enterprise.config.serverbeans.Config; import com.sun.enterprise.config.serverbeans.Configs; import com.sun.enterprise.util.StringUtils; -import fish.payara.audit.AdminAuditConfiguration; import fish.payara.extensions.notifiers.compat.config.Notifier; -import fish.payara.internal.notification.PayaraNotifierConfiguration; -import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import fish.payara.jmx.monitoring.configuration.MonitoringServiceConfiguration; import fish.payara.nucleus.healthcheck.configuration.HealthCheckServiceConfiguration; import fish.payara.nucleus.requesttracing.configuration.RequestTracingServiceConfiguration; import org.glassfish.api.admin.config.ConfigurationUpgrade; import org.glassfish.hk2.api.PostConstruct; +import org.jvnet.hk2.annotations.Contract; import org.jvnet.hk2.config.ConfigSupport; import org.jvnet.hk2.config.TransactionFailure; @@ -61,11 +59,14 @@ import java.util.logging.Logger; /** - * Base class that the notifier upgrade services pull from, containing generic methods shared by all. + * Contract for notifier upgrade services, containing generic methods shared by all. * * @author Andrew Pielage */ -public abstract class BaseNotifierUpgradeService implements ConfigurationUpgrade, PostConstruct { +@Contract +public abstract class LegacyNotifierUpgradeService implements ConfigurationUpgrade, PostConstruct { + + public static final String UPGRADES_NOTIFIER_METADATA = "UpgradesNotifier"; @Inject protected Configs configs; @@ -73,41 +74,10 @@ public abstract class BaseNotifierUpgradeService implements ConfigurationUpgrade @Inject protected Logger logger; - /** - * Retrieves the {@link PayaraNotifierConfiguration} for a given {@link NotificationServiceConfiguration}. - * - * @param notificationServiceConfiguration The {@link NotificationServiceConfiguration} to get config from - * @param notifierConfigurationClass The {@link PayaraNotifierConfiguration} to get - * @param The type of {@link PayaraNotifierConfiguration} to get - * @return The {@link PayaraNotifierConfiguration} for the specified {@link NotificationServiceConfiguration}, or - * null if it can't be found or created - */ - protected T getNotifierConfiguration( - NotificationServiceConfiguration notificationServiceConfiguration, Class notifierConfigurationClass) { - T notifierConfiguration = notificationServiceConfiguration.getNotifierConfigurationByType( - notifierConfigurationClass); - // Will be null if no default config tags present - if (notifierConfiguration == null) { - try { - // Create a transaction around the notifier config we want to add the element to, grab it's list - // of notifiers, and add a new child element to it - ConfigSupport.apply(notificationServiceConfigurationProxy -> { - notificationServiceConfigurationProxy.getNotifierConfigurationList().add( - notificationServiceConfigurationProxy.createChild(notifierConfigurationClass)); - return notificationServiceConfigurationProxy; - }, notificationServiceConfiguration); - } catch (TransactionFailure transactionFailure) { - logger.log(Level.WARNING, "Failed to upgrade legacy notifier configuration", transactionFailure); - return null; - } - - // Get the newly created config element - notifierConfiguration = notificationServiceConfiguration.getNotifierConfigurationByType( - notifierConfigurationClass); - } + public abstract String getNewNotifierName(); - // Could still be null! - return notifierConfiguration; + public Class getUpgradeNotifierClass() { + return getClass().getAnnotation(UpgradesNotifier.class).value(); } /** @@ -272,58 +242,4 @@ protected void upgradeHealthCheckService(Config config, Str } } - /** - * Upgrades any configured legacy notifiers for a given {@link AdminAuditConfiguration}, before removing - * the legacy config. If there is existing "upgraded" config, it does not override it. - * - * @param config The {@link Config} to upgrade the {@link AdminAuditConfiguration} of. - * @param notifierName The name of the notifier, corresponding to its XML tag in the domain.xml - * @param notifierClass The legacy {@link Notifier} to upgrade - * @param The type of legacy {@link Notifier} to upgrade - */ - protected void upgradeAdminAuditService(Config config, String notifierName, - Class notifierClass) { - AdminAuditConfiguration adminAuditConfiguration = config.getExtensionByType( - AdminAuditConfiguration.class); - - if (adminAuditConfiguration == null) { - logger.log(Level.WARNING, "Could not find admin audit service configuration to upgrade for config: {0}", - config.getName()); - return; - } - - T notifier = adminAuditConfiguration.getLegacyNotifierByType(notifierClass); - if (notifier == null) { - // If no config found, nothing to do! - return; - } - - if (StringUtils.ok(notifier.getEnabled()) && Boolean.valueOf(notifier.getEnabled())) { - // Since this is enabled, there might be something for us to do. - // Get the new notifier config list to see if this notifier is enabled - we don't want to override an - // existing value - List notifiers = adminAuditConfiguration.getNotifierList(); - if (!notifiers.contains(notifierName)) { - // No existing config to override, so let's migrate old to new - try { - ConfigSupport.apply(adminAuditConfigurationProxy -> { - adminAuditConfigurationProxy.getNotifierList().add(notifierName); - return adminAuditConfigurationProxy; - }, adminAuditConfiguration); - } catch (TransactionFailure transactionFailure) { - logger.log(Level.WARNING, "Failed to upgrade legacy notifier configuration", transactionFailure); - } - } - // And finally, delete the legacy config - try { - ConfigSupport.apply(adminAuditConfigurationProxy -> { - adminAuditConfigurationProxy.getLegacyNotifierList().remove(notifier); - return adminAuditConfigurationProxy; - }, adminAuditConfiguration); - } catch (TransactionFailure transactionFailure) { - logger.log(Level.WARNING, "Failed to remove legacy notifier configuration", transactionFailure); - } - } - } - } diff --git a/enterprise-backwards-compatibility/notifier-backwards-compatibility-core/src/main/java/fish/payara/extensions/notifiers/compat/UpgradesNotifier.java b/enterprise-backwards-compatibility/notifier-backwards-compatibility-core/src/main/java/fish/payara/extensions/notifiers/compat/UpgradesNotifier.java new file mode 100644 index 0000000..ad7bcea --- /dev/null +++ b/enterprise-backwards-compatibility/notifier-backwards-compatibility-core/src/main/java/fish/payara/extensions/notifiers/compat/UpgradesNotifier.java @@ -0,0 +1,64 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://github.com/payara/Payara/blob/master/LICENSE.txt + * See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at glassfish/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * The Payara Foundation designates this particular file as subject to the "Classpath" + * exception as provided by the Payara Foundation in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +package fish.payara.extensions.notifiers.compat; + +import fish.payara.extensions.notifiers.compat.config.Notifier; +import org.glassfish.hk2.api.Metadata; + +import javax.inject.Qualifier; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Qualifier used to mark and add metadata to the upgrade services implementing the {@link LegacyNotifierUpgradeService} + * contract. + */ +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface UpgradesNotifier { + + @Metadata(LegacyNotifierUpgradeService.UPGRADES_NOTIFIER_METADATA) + Class value(); + +} \ No newline at end of file diff --git a/enterprise-backwards-compatibility/pom.xml b/enterprise-backwards-compatibility/pom.xml index fcf8cd0..4d4e4a8 100644 --- a/enterprise-backwards-compatibility/pom.xml +++ b/enterprise-backwards-compatibility/pom.xml @@ -66,6 +66,7 @@ slack-notifier-backwards-compatibility snmp-notifier-backwards-compatibility xmpp-notifier-backwards-compatibility + admin-audit-notifiers-backwards-compatibility \ No newline at end of file diff --git a/enterprise-backwards-compatibility/slack-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/slack/SlackNotifierUpgradeService.java b/enterprise-backwards-compatibility/slack-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/slack/SlackNotifierUpgradeService.java index 419edcd..bcee717 100644 --- a/enterprise-backwards-compatibility/slack-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/slack/SlackNotifierUpgradeService.java +++ b/enterprise-backwards-compatibility/slack-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/slack/SlackNotifierUpgradeService.java @@ -41,7 +41,8 @@ package fish.payara.extensions.notifiers.compat.slack; import com.sun.enterprise.config.serverbeans.Config; -import fish.payara.extensions.notifiers.compat.BaseNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.UpgradesNotifier; import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import org.glassfish.api.StartupRunLevel; import org.glassfish.hk2.runlevel.RunLevel; @@ -54,7 +55,8 @@ */ @Service @RunLevel(StartupRunLevel.VAL) -public class SlackNotifierUpgradeService extends BaseNotifierUpgradeService { +@UpgradesNotifier(SlackNotifier.class) +public class SlackNotifierUpgradeService extends LegacyNotifierUpgradeService { private static final String notifierName = "slack-notifier"; @@ -74,7 +76,11 @@ public void postConstruct() { upgradeRequestTracingService(config, notifierName, SlackNotifier.class); upgradeMonitoringService(config, notifierName, SlackNotifier.class); upgradeHealthCheckService(config, notifierName, SlackNotifier.class); - upgradeAdminAuditService(config, notifierName, SlackNotifier.class); } } + + @Override + public String getNewNotifierName() { + return notifierName; + } } diff --git a/enterprise-backwards-compatibility/snmp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/snmp/SnmpNotificationConfigurer.java b/enterprise-backwards-compatibility/snmp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/snmp/SnmpNotificationConfigurer.java index ebe5fc0..bf5cb50 100644 --- a/enterprise-backwards-compatibility/snmp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/snmp/SnmpNotificationConfigurer.java +++ b/enterprise-backwards-compatibility/snmp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/snmp/SnmpNotificationConfigurer.java @@ -93,7 +93,7 @@ public class SnmpNotificationConfigurer extends BaseSetNotifierConfigurationComm @Param(name = "hostName") private String hostName; - @Param(name = "port", defaultValue = "162", optional = true) + @Param(name = "snmpPort", defaultValue = "162", optional = true, alias = "snmpport") private Integer port; @Override @@ -137,7 +137,7 @@ protected void configureNotifier(AdminCommandContext context, String commandName } if (port != null) { - parameterMap.insert("port", port.toString()); + parameterMap.insert("snmpPort", port.toString()); } try { diff --git a/enterprise-backwards-compatibility/snmp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/snmp/SnmpNotifierUpgradeService.java b/enterprise-backwards-compatibility/snmp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/snmp/SnmpNotifierUpgradeService.java index 0897f54..eed6d50 100644 --- a/enterprise-backwards-compatibility/snmp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/snmp/SnmpNotifierUpgradeService.java +++ b/enterprise-backwards-compatibility/snmp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/snmp/SnmpNotifierUpgradeService.java @@ -41,7 +41,8 @@ package fish.payara.extensions.notifiers.compat.snmp; import com.sun.enterprise.config.serverbeans.Config; -import fish.payara.extensions.notifiers.compat.BaseNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.UpgradesNotifier; import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import org.glassfish.api.StartupRunLevel; import org.glassfish.hk2.runlevel.RunLevel; @@ -54,7 +55,8 @@ */ @Service @RunLevel(StartupRunLevel.VAL) -public class SnmpNotifierUpgradeService extends BaseNotifierUpgradeService { +@UpgradesNotifier(SnmpNotifier.class) +public class SnmpNotifierUpgradeService extends LegacyNotifierUpgradeService { private static final String notifierName = "snmp-notifier"; @@ -74,7 +76,11 @@ public void postConstruct() { upgradeRequestTracingService(config, notifierName, SnmpNotifier.class); upgradeMonitoringService(config, notifierName, SnmpNotifier.class); upgradeHealthCheckService(config, notifierName, SnmpNotifier.class); - upgradeAdminAuditService(config, notifierName, SnmpNotifier.class); } } + + @Override + public String getNewNotifierName() { + return notifierName; + } } diff --git a/enterprise-backwards-compatibility/xmpp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/xmpp/XmppNotificationConfigurer.java b/enterprise-backwards-compatibility/xmpp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/xmpp/XmppNotificationConfigurer.java index 66fa9e9..ae83aa6 100644 --- a/enterprise-backwards-compatibility/xmpp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/xmpp/XmppNotificationConfigurer.java +++ b/enterprise-backwards-compatibility/xmpp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/xmpp/XmppNotificationConfigurer.java @@ -84,7 +84,7 @@ public class XmppNotificationConfigurer extends BaseSetNotifierConfigurationComm @Param(name = "hostName") private String hostName; - @Param(name = "port", defaultValue = "5222", optional = true) + @Param(name = "xmppPort", defaultValue = "5222", optional = true, alias = "xmppport") private Integer port; @Param(name = "serviceName") @@ -132,7 +132,7 @@ protected void configureNotifier(AdminCommandContext context, String commandName } if (port != null) { - parameterMap.insert("port", port.toString()); + parameterMap.insert("xmppPort", port.toString()); } if (StringUtils.ok(serviceName)) { diff --git a/enterprise-backwards-compatibility/xmpp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/xmpp/XmppNotifierUpgradeService.java b/enterprise-backwards-compatibility/xmpp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/xmpp/XmppNotifierUpgradeService.java index 91f00b9..b593f7a 100644 --- a/enterprise-backwards-compatibility/xmpp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/xmpp/XmppNotifierUpgradeService.java +++ b/enterprise-backwards-compatibility/xmpp-notifier-backwards-compatibility/src/main/java/fish/payara/extensions/notifiers/compat/xmpp/XmppNotifierUpgradeService.java @@ -41,7 +41,8 @@ package fish.payara.extensions.notifiers.compat.xmpp; import com.sun.enterprise.config.serverbeans.Config; -import fish.payara.extensions.notifiers.compat.BaseNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.LegacyNotifierUpgradeService; +import fish.payara.extensions.notifiers.compat.UpgradesNotifier; import fish.payara.internal.notification.admin.NotificationServiceConfiguration; import org.glassfish.api.StartupRunLevel; import org.glassfish.hk2.runlevel.RunLevel; @@ -54,7 +55,8 @@ */ @Service @RunLevel(StartupRunLevel.VAL) -public class XmppNotifierUpgradeService extends BaseNotifierUpgradeService { +@UpgradesNotifier(XmppNotifier.class) +public class XmppNotifierUpgradeService extends LegacyNotifierUpgradeService { private static final String notifierName = "xmpp-notifier"; @@ -74,7 +76,11 @@ public void postConstruct() { upgradeRequestTracingService(config, notifierName, XmppNotifier.class); upgradeMonitoringService(config, notifierName, XmppNotifier.class); upgradeHealthCheckService(config, notifierName, XmppNotifier.class); - upgradeAdminAuditService(config, notifierName, XmppNotifier.class); } } + + @Override + public String getNewNotifierName() { + return notifierName; + } } diff --git a/pom.xml b/pom.xml index 32b56c1..a2adf63 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ Payara Notifiers Parent - 5.26.0 + 5.27.0-SNAPSHOT 1.8 1.8 @@ -318,6 +318,17 @@ false + + payara-nexus-enterprise-snapshots + Payara Enterprise Snapshots + https://nexus.payara.fish/repository/payara-enterprise-snapshots-private + + false + + + true + + @@ -347,8 +358,8 @@ https://nexus.payara.fish/repository/payara-enterprise-artifacts-private/ - payara-nexus-snapshots - https://nexus.payara.fish/repository/payara-snapshots/ + payara-nexus-enterprise-snapshots + https://nexus.payara.fish/repository/payara-enterprise-snapshots-private/ diff --git a/snmp-notifier-console-plugin/src/main/resources/snmp/SNMPNotifierConfiguration.jsf b/snmp-notifier-console-plugin/src/main/resources/snmp/SNMPNotifierConfiguration.jsf index 4f45da3..3a8e2f2 100644 --- a/snmp-notifier-console-plugin/src/main/resources/snmp/SNMPNotifierConfiguration.jsf +++ b/snmp-notifier-console-plugin/src/main/resources/snmp/SNMPNotifierConfiguration.jsf @@ -143,7 +143,7 @@ holder. label="$resource{i18nsnn.notifier.snmp.configuration.portLabel}" helpText="$resource{i18nsnn.notifier.snmp.configuration.portLabelHelpText}"> + text="#{pageSession.valueMap['snmpPort']}" /> diff --git a/snmp-notifier-core/src/main/java/fish/payara/extensions/notifiers/snmp/GetSnmpNotifierConfigurationCommand.java b/snmp-notifier-core/src/main/java/fish/payara/extensions/notifiers/snmp/GetSnmpNotifierConfigurationCommand.java index f8fe16c..9c0749e 100644 --- a/snmp-notifier-core/src/main/java/fish/payara/extensions/notifiers/snmp/GetSnmpNotifierConfigurationCommand.java +++ b/snmp-notifier-core/src/main/java/fish/payara/extensions/notifiers/snmp/GetSnmpNotifierConfigurationCommand.java @@ -79,7 +79,7 @@ protected Map getNotifierConfiguration(SnmpNotifierConfiguration map.put("OID", configuration.getOid()); map.put("Version", configuration.getVersion()); map.put("Host Name", configuration.getHost()); - map.put("Port", configuration.getPort()); + map.put("SNMP Port", configuration.getPort()); } return map; diff --git a/snmp-notifier-core/src/main/java/fish/payara/extensions/notifiers/snmp/SetSnmpNotifierConfigurationCommand.java b/snmp-notifier-core/src/main/java/fish/payara/extensions/notifiers/snmp/SetSnmpNotifierConfigurationCommand.java index fa3f3ae..fadecd3 100644 --- a/snmp-notifier-core/src/main/java/fish/payara/extensions/notifiers/snmp/SetSnmpNotifierConfigurationCommand.java +++ b/snmp-notifier-core/src/main/java/fish/payara/extensions/notifiers/snmp/SetSnmpNotifierConfigurationCommand.java @@ -83,7 +83,7 @@ public class SetSnmpNotifierConfigurationCommand extends BaseSetNotifierConfigur @Param(name = "hostName") private String hostName; - @Param(name = "port", defaultValue = "162", optional = true) + @Param(name = "snmpPort", defaultValue = "162", optional = true, alias = "snmpport") private Integer port; @Override diff --git a/xmpp-notifier-console-plugin/src/main/resources/xmpp/xmppNotifierConfiguration.jsf b/xmpp-notifier-console-plugin/src/main/resources/xmpp/xmppNotifierConfiguration.jsf index 06bd556..bf459fe 100644 --- a/xmpp-notifier-console-plugin/src/main/resources/xmpp/xmppNotifierConfiguration.jsf +++ b/xmpp-notifier-console-plugin/src/main/resources/xmpp/xmppNotifierConfiguration.jsf @@ -132,7 +132,7 @@ holder. label="$resource{i18nxn.notifier.xmpp.configuration.portLabel}" helpText="$resource{i18nxn.notifier.xmpp.configuration.portLabelHelpText}"> + text="#{pageSession.valueMap['xmppPort']}" /> getNotifierConfiguration(XmppNotifierConfiguration if (configuration != null) { map.put("Host Name", configuration.getHost()); - map.put("Port", configuration.getPort()); + map.put("XMPP Port", configuration.getPort()); map.put("Service Name", configuration.getServiceName()); map.put("Username", configuration.getUsername()); map.put("Password", configuration.getPassword()); diff --git a/xmpp-notifier-core/src/main/java/fish/payara/extensions/notifier/xmpp/SetXmppNotifierConfigurationCommand.java b/xmpp-notifier-core/src/main/java/fish/payara/extensions/notifier/xmpp/SetXmppNotifierConfigurationCommand.java index d716eb2..4ae8c94 100644 --- a/xmpp-notifier-core/src/main/java/fish/payara/extensions/notifier/xmpp/SetXmppNotifierConfigurationCommand.java +++ b/xmpp-notifier-core/src/main/java/fish/payara/extensions/notifier/xmpp/SetXmppNotifierConfigurationCommand.java @@ -74,7 +74,7 @@ public class SetXmppNotifierConfigurationCommand extends BaseSetNotifierConfigur @Param(name = "hostName") private String hostName; - @Param(name = "port", defaultValue = "5222", optional = true) + @Param(name = "xmppPort", defaultValue = "5222", optional = true, alias = "xmppport") private Integer port; @Param(name = "serviceName")