Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISH-370 Created Microsoft Teams notifier #11

Merged
merged 7 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
<module>snmp-notifier-console-plugin</module>
<module>xmpp-notifier-core</module>
<module>xmpp-notifier-console-plugin</module>
<module>teams-notifier-core</module>
Cousjava marked this conversation as resolved.
Show resolved Hide resolved
<module>teams-notifier-console-plugin</module>
</modules>

<dependencyManagement>
Expand Down
62 changes: 62 additions & 0 deletions teams-notifier-console-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>fish.payara.extensions.notifiers</groupId>
<artifactId>notifiers-parent</artifactId>
<version>1.0</version>
</parent>

<artifactId>teams-notifier-console-plugin</artifactId>
<version>1.0</version>
<packaging>glassfish-jar</packaging>

<name>Microsoft Teams Notifier Console Plugin</name>

<dependencies>
<dependency>
<groupId>fish.payara.server.internal.admingui</groupId>
<artifactId>console-plugin-service</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*

DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

Copyright (c) 2017 Payara Foundation. All rights reserved.
Cousjava marked this conversation as resolved.
Show resolved Hide resolved

The contents of this file are subject to the terms of 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://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
or packager/legal/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 packager/legal/LICENSE.txt.
*/

package fish.payara.admingui.notifier.teams;

import java.net.URL;
import org.glassfish.api.admingui.ConsoleProvider;
import org.jvnet.hk2.annotations.Service;

/**
*
* @author Jonathan Coustick
*/
@Service
public class TeamsNotifierPlugin implements ConsoleProvider {

@Override
public URL getConfiguration() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<console-config id="teamsNotifier">
<integration-point
id="teamsNotifier"
type="fish.payara.admingui:notifierTab"
priority="40"
parentId="notificationConfigTabs"
content="teams/teamsNotifierTabs.jsf"
/>
</console-config>
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<!--
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.
-->

<!initPage
setResourceBundle(key="i18nc" bundle="org.glassfish.common.admingui.Strings");
setResourceBundle(key="i18ncs" bundle="org.glassfish.cluster.admingui.Strings");
setResourceBundle(key="i18nemn" bundle="fish.payara.admingui.notifier.teams.Strings");
/>
<!composition template="/templates/default.layout" guiTitle="$resource{i18nemn.notifier.teams.configuration.pageTitle}" >
<!define name="content">
<event>
<!beforeCreate
getRequestValue(key="configName" value="#{pageSession.configName}" );
createMap(result="#{pageSession.attrsMap}")
mapPut(map="#{pageSession.attrsMap}" key="target" value="#{pageSession.configName}");
gf.restRequest(endpoint="#{sessionScope.NOTIFICATION_CONFIG_URL}/get-teams-notifier-configuration?target=#{pageSession.configName}"
method="GET" result="#{requestScope.resp}");
setPageSessionAttribute(key="valueMap", value="#{requestScope.resp.data.extraProperties.notifierConfiguration}");
mapPut(map="#{pageSession.valueMap}" key="target" value="#{pageSession.configName}");
setPageSessionAttribute(key="convertToFalseList", value={"enabled", "noisy"});

if (#{pageSession.valueMap['enabled']}=true) {
setPageSessionAttribute(key="enabledSelected", value="true");
}
if (#{pageSession.valueMap['noisy']}=true) {
setPageSessionAttribute(key="noisy", value="true");
}
setPageSessionAttribute(key="dynamic", value="true");
/>
</event>
<sun:form id="propertyForm">
#include "/common/shared/alertMsg_1.inc"
#include "/payaraExtras/notification/notificationConfigTabs.inc"
<sun:title id="propertyContentPage" title="$resource{i18nemn.notifier.teams.configuration.pageTitle}"
helpText="$resource{i18nemn.notifier.teams.configuration.pageHelpText}" >
<sun:button id = "test" text="$resource{i18nemn.notifier.teams.buttons.test}">
<!command
createMap(result="#{pageSession.attrsMap}");
mapPut(map="#{pageSession.attrsMap}" key="notifiers" value="teams-notifier");
gf.restRequest(endpoint="#{sessionScope.NOTIFICATION_CONFIG_URL}/test-notifier-configuration" method="GET"
attrs="#{pageSession.attrsMap}" result="#{requestScope.result}");
if ("#{requestScope.result.data['exit_code']} = SUCCESS") {
prepareAlertMsg(summary="$resource{i18nemn.notifier.teams.msg.success}", type="success");
}
/>
</sun:button>
<!facet pageButtonsTop>
<sun:panelGroup id="topButtons">
<sun:button id="saveButton" text="$resource{i18n.button.Save}"
onClick="if (guiValidate('#{reqMsg}','#{reqInt}','#{reqPort}')) submitAndDisable(this, '$resource{i18n.button.Processing}'); return false;" >
<!command
mapPut(map="#{pageSession.valueMap}" key="enabled" value="#{pageSession.enabledSelected}");
mapPut(map="#{pageSession.valueMap}" key="noisy" value="#{pageSession.noisy}");
mapPut(map="#{pageSession.valueMap}" key="dynamic" value="#{pageSession.dynamic}");
prepareSuccessfulMsg();
gf.updateEntity(endpoint="#{sessionScope.NOTIFICATION_CONFIG_URL}/set-teams-notifier-configuration"
attrs="#{pageSession.valueMap}" convertToFalse="#{pageSession.convertToFalseList}");
/>
</sun:button>
</sun:panelGroup>
</facet>
</sun:title>

<sun:propertySheet id="propertySheet">
#include "/common/shared/configNameSection.inc"
<sun:propertySheetSection id="slackNotifierProperties">
<sun:property id="enabledProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18nemn.notifier.teams.configuration.enabledLabel}"
helpText="$resource{i18nemn.notifier.teams.configuration.enabledLabelHelpText}">
<sun:checkbox id="enabledProp" selected="#{pageSession.enabledSelected}" selectedValue="true" />
</sun:property>
<sun:property id="noisy" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18nn.notification.configuration.notifier.noisyLabel}"
helpText="$resource{i18nn.notification.configuration.notifier.noisyLabelHelpText}">
<sun:checkbox id="noisy" selected="#{pageSession.noisy}" selectedValue="true" />
</sun:property>
<sun:property id="dynamic" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18nn.notification.configuration.dynamic}"
helpText="$resource{i18nn.notification.configuration.notifier.dynamicHelp}">
<sun:checkbox id="dynamic" selected="#{pageSession.dynamic}" selectedValue="true" />
</sun:property>
<sun:property id="webhookUrlProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18nemn.notifier.teams.configuration.webhookUrlLabel}"
helpText="$resource{i18nemn.notifier.teams.configuration.webhookUrlLabelHelpText}">
<sun:textField id="webhookUrlField" columns="$int{75}" maxLength="512"
text="#{pageSession.valueMap['webhookUrl']}" styleClass="required"
required="#{true}"/>
</sun:property>
</sun:propertySheetSection>
</sun:propertySheet>
</sun:form>
</define>
</composition>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--
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.
-->
<sun:tab id="teamsNotificationTab" immediate="true" text="$resource{i18nebn.notifier.teams.tabs.tabText}"
toolTip="$resource{i18nebn.notifier.teams.tabs.tabToolTip}">
<!beforeCreate
setResourceBundle(key="i18nebn" bundle="fish.payara.admingui.notifier.teams.Strings");
setResourceBundle(key="i18nc" bundle="org.glassfish.common.admingui.Strings");
/>
<!command
setSessionAttribute(key="notificationConfigTab" value="teamsNotificationTab");
gf.redirect(page="#{request.contextPath}/teamsNotifier/teams/teamsNotifierConfiguration.jsf?configName=#{pageSession.configName}");
/>
</sun:tab>

Loading