diff --git a/pom.xml b/pom.xml index bfd063a..60552af 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,8 @@ slack-notifier-console-plugin snmp-notifier-core snmp-notifier-console-plugin + teams-notifier-core + teams-notifier-console-plugin xmpp-notifier-core xmpp-notifier-console-plugin diff --git a/teams-notifier-console-plugin/pom.xml b/teams-notifier-console-plugin/pom.xml new file mode 100644 index 0000000..b53992e --- /dev/null +++ b/teams-notifier-console-plugin/pom.xml @@ -0,0 +1,62 @@ + + + + 4.0.0 + + + fish.payara.extensions.notifiers + notifiers-parent + 1.0 + + + teams-notifier-console-plugin + 1.0 + glassfish-jar + + Microsoft Teams Notifier Console Plugin + + + + fish.payara.server.internal.admingui + console-plugin-service + + + diff --git a/teams-notifier-console-plugin/src/main/java/fish/payara/admingui/notifier/teams/TeamsNotifierPlugin.java b/teams-notifier-console-plugin/src/main/java/fish/payara/admingui/notifier/teams/TeamsNotifierPlugin.java new file mode 100644 index 0000000..efac2cd --- /dev/null +++ b/teams-notifier-console-plugin/src/main/java/fish/payara/admingui/notifier/teams/TeamsNotifierPlugin.java @@ -0,0 +1,58 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2020] 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.admingui.notifier.teams; + +import java.net.URL; +import org.glassfish.api.admingui.ConsoleProvider; +import org.jvnet.hk2.annotations.Service; + +/** + * Plugin for the Payara Server admin console for the teams notifer + * @author Jonathan Coustick + */ +@Service +public class TeamsNotifierPlugin implements ConsoleProvider { + + @Override + public URL getConfiguration() { + return null; + } +} diff --git a/teams-notifier-console-plugin/src/main/resources/META-INF/admingui/console-config.xml b/teams-notifier-console-plugin/src/main/resources/META-INF/admingui/console-config.xml new file mode 100644 index 0000000..0546c5b --- /dev/null +++ b/teams-notifier-console-plugin/src/main/resources/META-INF/admingui/console-config.xml @@ -0,0 +1,47 @@ + + + + + diff --git a/teams-notifier-console-plugin/src/main/resources/fish/payara/admingui/notifier/teams/Strings.properties b/teams-notifier-console-plugin/src/main/resources/fish/payara/admingui/notifier/teams/Strings.properties new file mode 100644 index 0000000..2444f77 --- /dev/null +++ b/teams-notifier-console-plugin/src/main/resources/fish/payara/admingui/notifier/teams/Strings.properties @@ -0,0 +1,48 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright (c) 2020 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. + +notifier.teams.tabs.tabText=Teams +notifier.teams.tabs.tabToolTip=Microsoft Teams Notification Configuration +notifier.teams.configuration.pageTitle=Teams Notifier Configuration +notifier.teams.configuration.pageHelpText=Enable and configure a Teams notifier +notifier.teams.configuration.enabledLabel=Enabled +notifier.teams.configuration.enabledLabelHelpText=Enables/Disables the Teams notifier +notifier.teams.configuration.webhookUrlLabel=Webhook URL +notifier.teams.configuration.webhookUrlLabelHelpText=The URL that the webhook should send notifications to +notifier.teams.msg.success=Success +notifier.teams.buttons.test=Test \ No newline at end of file diff --git a/teams-notifier-console-plugin/src/main/resources/teams/teamsNotifierConfiguration.jsf b/teams-notifier-console-plugin/src/main/resources/teams/teamsNotifierConfiguration.jsf new file mode 100644 index 0000000..f9ec8e3 --- /dev/null +++ b/teams-notifier-console-plugin/src/main/resources/teams/teamsNotifierConfiguration.jsf @@ -0,0 +1,128 @@ + + + + + + + + + +#include "/common/shared/alertMsg_1.inc" +#include "/payaraExtras/notification/notificationConfigTabs.inc" + + + + + + + + + + + + + + +#include "/common/shared/configNameSection.inc" + + + + + + + + + + + + + + + + + + diff --git a/teams-notifier-console-plugin/src/main/resources/teams/teamsNotifierTabs.jsf b/teams-notifier-console-plugin/src/main/resources/teams/teamsNotifierTabs.jsf new file mode 100644 index 0000000..813faf7 --- /dev/null +++ b/teams-notifier-console-plugin/src/main/resources/teams/teamsNotifierTabs.jsf @@ -0,0 +1,49 @@ + + + + + + diff --git a/teams-notifier-core/pom.xml b/teams-notifier-core/pom.xml new file mode 100644 index 0000000..dd4efac --- /dev/null +++ b/teams-notifier-core/pom.xml @@ -0,0 +1,66 @@ + + + + 4.0.0 + + + fish.payara.extensions.notifiers + notifiers-parent + 1.0 + + + teams-notifier-core + glassfish-jar + 1.0 + + Microsoft Teams Notifier Implementation + + + + fish.payara.server.internal.common + internal-api + + + jakarta.platform + jakarta.jakartaee-api + + + diff --git a/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/GetTeamsNotifierConfigurationCommand.java b/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/GetTeamsNotifierConfigurationCommand.java new file mode 100644 index 0000000..a5a8988 --- /dev/null +++ b/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/GetTeamsNotifierConfigurationCommand.java @@ -0,0 +1,85 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2020] 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.teams; + +import java.util.Map; + +import org.glassfish.api.admin.CommandLock; +import org.glassfish.api.admin.ExecuteOn; +import org.glassfish.api.admin.RestEndpoint; +import org.glassfish.api.admin.RestEndpoints; +import org.glassfish.api.admin.RuntimeType; +import org.glassfish.config.support.CommandTarget; +import org.glassfish.config.support.TargetType; +import org.glassfish.hk2.api.PerLookup; +import org.jvnet.hk2.annotations.Service; + +import fish.payara.internal.notification.admin.BaseGetNotifierConfigurationCommand; +import fish.payara.internal.notification.admin.NotificationServiceConfiguration; + +/** + * Gets the configuration of the Microsoft Teams notifier + * @author jonathan coustick + */ +@Service(name = "get-teams-notifier-configuration") +@PerLookup +@CommandLock(CommandLock.LockType.NONE) +@ExecuteOn({RuntimeType.DAS, RuntimeType.INSTANCE}) +@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG}) +@RestEndpoints({ + @RestEndpoint(configBean = NotificationServiceConfiguration.class, + opType = RestEndpoint.OpType.GET, + path = "get-teams-notifier-configuration", + description = "Lists Teams Notifier Configuration") +}) +public class GetTeamsNotifierConfigurationCommand extends BaseGetNotifierConfigurationCommand { + + @Override + protected Map getNotifierConfiguration(TeamsNotifierConfiguration configuration) { + Map map = super.getNotifierConfiguration(configuration); + + if (configuration != null) { + map.put("Webhook URL", configuration.getWebhookUrl());; + } + + return map; + } + +} \ No newline at end of file diff --git a/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/SetTeamsNotifierConfigurationCommand.java b/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/SetTeamsNotifierConfigurationCommand.java new file mode 100644 index 0000000..ad59191 --- /dev/null +++ b/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/SetTeamsNotifierConfigurationCommand.java @@ -0,0 +1,85 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2020] 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.teams; + +import java.beans.PropertyVetoException; + +import org.glassfish.api.Param; +import org.glassfish.api.admin.CommandLock; +import org.glassfish.api.admin.ExecuteOn; +import org.glassfish.api.admin.RestEndpoint; +import org.glassfish.api.admin.RestEndpoints; +import org.glassfish.api.admin.RuntimeType; +import org.glassfish.config.support.CommandTarget; +import org.glassfish.config.support.TargetType; +import org.glassfish.hk2.api.PerLookup; +import org.jvnet.hk2.annotations.Service; + +import fish.payara.internal.notification.admin.BaseSetNotifierConfigurationCommand; +import fish.payara.internal.notification.admin.NotificationServiceConfiguration; + +/** + * Command to set the configuration of Microsoft Teams notifier. + * @author jonathan coustick + */ +@Service(name = "set-teams-notifier-configuration") +@PerLookup +@CommandLock(CommandLock.LockType.NONE) +@ExecuteOn({RuntimeType.DAS, RuntimeType.INSTANCE}) +@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG}) +@RestEndpoints({ + @RestEndpoint(configBean = NotificationServiceConfiguration.class, + opType = RestEndpoint.OpType.POST, + path = "set-teams-notifier-configuration", + description = "Configures Teams Notification Service") +}) +public class SetTeamsNotifierConfigurationCommand extends BaseSetNotifierConfigurationCommand { + + @Param(primary = true) + private String webhookURL; + + @Override + protected void applyValues(TeamsNotifierConfiguration configuration) throws PropertyVetoException { + super.applyValues(configuration); + configuration.setWebhookUrl(webhookURL); + + } + +} diff --git a/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/TeamsNotifier.java b/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/TeamsNotifier.java new file mode 100644 index 0000000..247949b --- /dev/null +++ b/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/TeamsNotifier.java @@ -0,0 +1,152 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2020] 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.teams; + +import org.jvnet.hk2.annotations.Service; + +import fish.payara.internal.notification.PayaraConfiguredNotifier; +import fish.payara.internal.notification.PayaraNotification; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.ConnectException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.ProtocolException; +import java.net.URL; +import java.net.UnknownHostException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import javax.json.Json; +import javax.json.JsonObjectBuilder; +import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; + +/** + * Notifier to integrate with Microsoft Teams + * @author jonathan coustick + */ +@Service(name = "teams-notifier") +public class TeamsNotifier extends PayaraConfiguredNotifier { + + private static final Logger LOGGER = Logger.getLogger(TeamsNotifier.class.getPackage().toString()); + + private URL url; + + @Override + public void handleNotification(PayaraNotification event) { + if (url == null) { + LOGGER.fine("Teams notifier received notification, but no URL was available."); + return; + } + + try { + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setDoOutput(true); + connection.setRequestMethod(HttpMethod.POST); + connection.setRequestProperty(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); + + connection.connect(); + try (OutputStream outputStream = connection.getOutputStream()) { + outputStream.write(eventToCard(event)); + outputStream.flush(); + } + + if (connection.getResponseCode() == 200) { + LOGGER.log(Level.FINE, "Message sent successfully"); + if (LOGGER.isLoggable(Level.FINEST)) { + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String response = reader.lines().collect(Collectors.joining("\n")); + LOGGER.log(Level.FINEST, response); + } + } else { + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getErrorStream())); + String response = reader.lines().collect(Collectors.joining("\n")); + LOGGER.log(Level.WARNING, response); + LOGGER.log(Level.SEVERE, "Error occurred while connecting to Microsoft Teams. Check your tokens. HTTP response code: {0}", connection.getResponseCode()); + } + } catch (MalformedURLException e) { + LOGGER.log(Level.SEVERE, "Error occurred while accessing URL: " + url.toString(), e); + } catch (ProtocolException e) { + LOGGER.log(Level.SEVERE, "Specified URL is not accepting protocol defined: " + HttpMethod.POST, e); + } catch (UnknownHostException e) { + LOGGER.log(Level.SEVERE, "Check your network connection. Cannot access URL: " + url.toString(), e); + } catch (ConnectException e) { + LOGGER.log(Level.SEVERE, "Error occurred while connecting URL: " + url.toString(), e); + } catch (IOException e) { + LOGGER.log(Level.SEVERE, "IO Error while accessing URL: " + url.toString(), e); + } + } + + @Override + public void bootstrap() { + try { + this.url = new URL(configuration.getWebhookUrl()); + } catch (MalformedURLException e) { + LOGGER.log(Level.SEVERE, "Error occurred while accessing URL: " + url, e); + } + } + + private byte[] eventToCard(PayaraNotification event) { + JsonObjectBuilder mainBuilder = Json.createObjectBuilder(); + + mainBuilder.add("@type", "MessageCard"); + mainBuilder.add("@context", "http://schema.org/extensions"); + mainBuilder.add("themeColor", "004462"); + if (event.getEventType() != null) { + mainBuilder.add("summary", event.getEventType()); + } else { + mainBuilder.add("summary", event.getSubject()); + } + + mainBuilder.add("text", String.format("%s. (host: %s, server: %s, domain: %s, instance: %s)\n%s", + event.getSubject(), + event.getHostName(), + event.getServerName(), + event.getDomainName(), + event.getInstanceName(), + event.getMessage())); + return mainBuilder.build().toString().getBytes(); + } + +} diff --git a/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/TeamsNotifierConfiguration.java b/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/TeamsNotifierConfiguration.java new file mode 100644 index 0000000..4d9e276 --- /dev/null +++ b/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/TeamsNotifierConfiguration.java @@ -0,0 +1,56 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2020] 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.teams; + +import java.beans.PropertyVetoException; + +import org.jvnet.hk2.config.Attribute; +import org.jvnet.hk2.config.Configured; + +import fish.payara.internal.notification.PayaraNotifierConfiguration; + +@Configured +public interface TeamsNotifierConfiguration extends PayaraNotifierConfiguration { + + @Attribute + String getWebhookUrl(); + void setWebhookUrl(String value) throws PropertyVetoException; + +} \ No newline at end of file diff --git a/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/package-info.java b/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/package-info.java new file mode 100644 index 0000000..62301c4 --- /dev/null +++ b/teams-notifier-core/src/main/java/fish/payara/extensions/notifiers/teams/package-info.java @@ -0,0 +1,45 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2020 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. + */ + +/** + * Extension for Payara Notification Service to enable + * sending notifications to teams. + */ +package fish.payara.extensions.notifiers.teams; diff --git a/teams-notifier-core/src/main/resources/fish/payara/extensions/notifiers/teams/get-teams-notifier-configuration.1 b/teams-notifier-core/src/main/resources/fish/payara/extensions/notifiers/teams/get-teams-notifier-configuration.1 new file mode 100644 index 0000000..af159d3 --- /dev/null +++ b/teams-notifier-core/src/main/resources/fish/payara/extensions/notifiers/teams/get-teams-notifier-configuration.1 @@ -0,0 +1,40 @@ +get-teams-notifier-configuration(1) Payara Notificaton Service Extension get-teams-notifier-configuration(1) + +NAME + get-teams-notifier-configuration - get the configuration of the Teams notifier + +SYNOPSIS + get-teams-notifier-configuration [--help] + +DESCRIPTION + The get-teams-notifier-configuration subcommand displays the configuration + of the Microsoft Teams notifier. + +OPTIONS + --help, -? + Displays the help text for the subcommand. + +EXAMPLES + Example 1, Listing the configuration + This example lists the current configuration for the notifier. + + asadmin> get-teams-notifier-configuration + Enabled Noisy Webhook URL + true true https://outlook.office.com/webhook/12345@67890/IncomingWebHook/98765/4321 + + Command get-teams-notifier-configuration executed successfully. + +EXIT STATUS + 0 + subcommand executed successfully + + 1 + error in executing the subcommand + +SEE ALSO + list-commands(1), list-components(1), list-modules(1) + + asadmin(1M) + +Jakarta EE 8 1 Oct 2020 get-teams-notifier-configuration(1) + diff --git a/teams-notifier-core/src/main/resources/fish/payara/extensions/notifiers/teams/set-teams-notifier-configuration.1 b/teams-notifier-core/src/main/resources/fish/payara/extensions/notifiers/teams/set-teams-notifier-configuration.1 new file mode 100644 index 0000000..237caaa --- /dev/null +++ b/teams-notifier-core/src/main/resources/fish/payara/extensions/notifiers/teams/set-teams-notifier-configuration.1 @@ -0,0 +1,44 @@ +set-teams-notifier-configuration(1) Payara Notificaton Service Extension set-teams-notifier-configuration(1) + +NAME + set-teams-notifier-configuration - set the configuration of the Teams notifier + +SYNOPSIS + set-teams-notifier-configuration [--help] + [--enabled={true|false}] [--dynamic={true|false}] + [webhookUrl] + + +DESCRIPTION + The set-teams-notifier-configuration subcommand sets the configuration + of the Microsoft Teams notifier. + +OPTIONS + --help, -? + Displays the help text for the subcommand. + +EXAMPLES + Example 1, Setting the configuration + This example sets configuration for the notifier + to be enabled dynamically + + asadmin> set-teams-notifier-configuration --enabled true --dynamic true https://outlook.office.com/webhook/12345@67890/IncomingWebHook/98765/4321 + + + Command set-teams-notifier-configuration executed successfully. + +EXIT STATUS + 0 + subcommand executed successfully + + 1 + error in executing the subcommand + +SEE ALSO + list-commands(1), list-components(1), list-modules(1) + + asadmin(1M) + +Jakarta EE 8 1 Oct 2020 set-teams-notifier-configuration(1) + +