Merge branch 'DEVELOP' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.backend into SI-155-SAMO-Schnittstelle
diff --git a/SAMO-Interface/.gitignore b/SAMO-Interface/.gitignore
new file mode 100644
index 0000000..22921f0
--- /dev/null
+++ b/SAMO-Interface/.gitignore
@@ -0,0 +1,37 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### Logs ###
+/logs
+
+### Sonar ###
+/.scannerwork
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/SAMO-Interface/Dockerfile_DevServer b/SAMO-Interface/Dockerfile_DevServer
new file mode 100644
index 0000000..66c3eaa
--- /dev/null
+++ b/SAMO-Interface/Dockerfile_DevServer
@@ -0,0 +1,13 @@
+FROM openjdk:8-jre-alpine
+
+ENV JAVA_TOOL_OPTIONS -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
+ENV HTTP_PROXY http://webproxy3.pta.de:8080
+ENV HTTPS_PROXY http://webproxy3.pta.de:8080
+ENV TZ Europe/Berlin
+
+# install tzdata to set the right timezone
+RUN apk add --no-cache tzdata
+
+COPY /target/grid-failure-information.backend.stoerungsauskunft-interface.jar /usr/src/cbd/
+WORKDIR usr/src/cbd
+CMD ["java", "-jar", "-Dspring.profiles.active=devserver", "grid-failure-information.backend.stoerungsauskunft-interface.jar"]
\ No newline at end of file
diff --git a/SAMO-Interface/lombok.config b/SAMO-Interface/lombok.config
new file mode 100644
index 0000000..a23edb4
--- /dev/null
+++ b/SAMO-Interface/lombok.config
@@ -0,0 +1,2 @@
+config.stopBubbling = true
+lombok.addLombokGeneratedAnnotation = true
\ No newline at end of file
diff --git a/SAMO-Interface/mvnw b/SAMO-Interface/mvnw
new file mode 100644
index 0000000..a16b543
--- /dev/null
+++ b/SAMO-Interface/mvnw
@@ -0,0 +1,310 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="`which java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found .mvn/wrapper/maven-wrapper.jar"
+ fi
+else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+ fi
+ if [ -n "$MVNW_REPOURL" ]; then
+ jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ else
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ fi
+ while IFS="=" read key value; do
+ case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+ esac
+ done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Downloading from: $jarUrl"
+ fi
+ wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+ if $cygwin; then
+ wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
+ fi
+
+ if command -v wget > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ wget "$jarUrl" -O "$wrapperJarPath"
+ else
+ wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
+ fi
+ elif command -v curl > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ curl -o "$wrapperJarPath" "$jarUrl" -f
+ else
+ curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
+ fi
+
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ # For Cygwin, switch paths to Windows format before running javac
+ if $cygwin; then
+ javaClass=`cygpath --path --windows "$javaClass"`
+ fi
+ if [ -e "$javaClass" ]; then
+ if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Compiling MavenWrapperDownloader.java ..."
+ fi
+ # Compiling the Java class
+ ("$JAVA_HOME/bin/javac" "$javaClass")
+ fi
+ if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ # Running the downloader
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Running MavenWrapperDownloader.java ..."
+ fi
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+ echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/SAMO-Interface/mvnw.cmd b/SAMO-Interface/mvnw.cmd
new file mode 100644
index 0000000..c8d4337
--- /dev/null
+++ b/SAMO-Interface/mvnw.cmd
@@ -0,0 +1,182 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM https://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+
+FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
+) else (
+ if not "%MVNW_REPOURL%" == "" (
+ SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ )
+
+ powershell -Command "&{"^
+ "$webclient = new-object System.Net.WebClient;"^
+ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+ "}"^
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
+ "}"
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
+)
+@REM End of extension
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%
diff --git a/SAMO-Interface/pom.xml b/SAMO-Interface/pom.xml
new file mode 100644
index 0000000..1ccfd73
--- /dev/null
+++ b/SAMO-Interface/pom.xml
@@ -0,0 +1,218 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>2.2.4.RELEASE</version>
+ <relativePath/> <!-- lookup parent from repository -->
+ </parent>
+ <groupId>org.eclipse.openk</groupId>
+ <artifactId>grid-failure-information.backend.samo-interface</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>grid-failure-information.samo-interface</name>
+ <description>Grid-Failure-Information Project for openKONSEQUENZ</description>
+
+ <properties>
+ <skip.asciidoc>false</skip.asciidoc>
+ <maven.test.skip>false</maven.test.skip>
+
+ <java.version>1.8</java.version>
+ <spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
+ <springfox.version>2.9.2</springfox.version>
+ <spring-security-test.version>5.2.1.RELEASE</spring-security-test.version>
+ <powerMockReflect.version>2.0.0</powerMockReflect.version>
+ <sonar-maven-plugin.version>3.2</sonar-maven-plugin.version>
+ <asciidoctor-maven-plugin-version>1.5.3</asciidoctor-maven-plugin-version>
+ <asciidoctorj-pdf-version>1.5.0-alpha.11</asciidoctorj-pdf-version>
+ <asciidoctorj-version>1.5.4</asciidoctorj-version>
+ <asciidoctorj-diagram-versions>1.5.4.1</asciidoctorj-diagram-versions>
+ <jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version>
+ <jruby-complete-version>9.0.0.0</jruby-complete-version>
+ <mapstruct.version>1.2.0.Final</mapstruct.version>
+ <flyway-core.version>6.0.8</flyway-core.version>
+ <postgresql.version>42.2.8</postgresql.version>
+ <lombock.version>1.18.10</lombock.version>
+ <h2.version>1.4.200</h2.version>
+ <jsonwebtoken.version>0.9.1</jsonwebtoken.version>
+ <openfeign.version>2.2.0.RELEASE</openfeign.version>
+ <keycloak-core.version>3.4.2.Final</keycloak-core.version>
+ <nexmo.version>5.2.1</nexmo.version>
+ <rabbitmq.version>5.2.0</rabbitmq.version>
+ </properties>
+
+ <dependencies>
+ <!-- https://mvnrepository.com/artifact/org.springframework.amqp/spring-rabbit-test -->
+ <dependency>
+ <groupId>org.springframework.amqp</groupId>
+ <artifactId>spring-rabbit-test</artifactId>
+ <version>2.2.7.RELEASE</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web-services</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-amqp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-integration</artifactId>
+ <version>2.2.5.RELEASE</version>
+ </dependency>
+
+ <!-- https://mvnrepository.com/artifact/org.springframework.integration/spring-integration-sftp -->
+ <dependency>
+ <groupId>org.springframework.integration</groupId>
+ <artifactId>spring-integration-sftp</artifactId>
+ <version>5.3.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${lombok.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.mapstruct</groupId>
+ <artifactId>mapstruct-processor</artifactId>
+ <version>${mapstruct.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <version>${springfox.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ <version>${springfox.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-reflect</artifactId>
+ <version>${powerMockReflect.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.batch</groupId>
+ <artifactId>spring-batch-core</artifactId>
+ <version>4.2.1.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.batch</groupId>
+ <artifactId>spring-batch-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.rabbitmq</groupId>
+ <artifactId>amqp-client</artifactId>
+ <version>${rabbitmq.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-openfeign</artifactId>
+ <version>${openfeign.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
+ <version>${openfeign.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-contract-wiremock</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-stream-test-support</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
+ </dependencies>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-dependencies</artifactId>
+ <version>${spring-cloud.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>${jacoco-maven-plugin.version}</version>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <output>file</output>
+ <append>true</append>
+ <excludes>
+ <exclude>**/Globals.*</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>jacoco-initialize</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>jacoco-site</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.sonarsource.scanner.maven</groupId>
+ <artifactId>sonar-maven-plugin</artifactId>
+ <version>${sonar-maven-plugin.version}</version>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/SAMO-Interface/pom_backup.xml b/SAMO-Interface/pom_backup.xml
new file mode 100644
index 0000000..159e251
--- /dev/null
+++ b/SAMO-Interface/pom_backup.xml
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>2.2.4.RELEASE</version>
+ <relativePath/> <!-- lookup parent from repository -->
+ </parent>
+ <groupId>org.eclipse.openk</groupId>
+ <artifactId>grid-failure-information.backend.saris-interface</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>grid-failure-information.saris-interface</name>
+ <description>Grid-Failure-Information Project for openKONSEQUENZ</description>
+
+ <properties>
+ <skip.asciidoc>false</skip.asciidoc>
+ <maven.test.skip>false</maven.test.skip>
+
+ <java.version>1.8</java.version>
+ <spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
+ <springfox.version>2.9.2</springfox.version>
+ <spring-security-test.version>5.2.1.RELEASE</spring-security-test.version>
+ <powerMockReflect.version>2.0.0</powerMockReflect.version>
+ <sonar-maven-plugin.version>3.2</sonar-maven-plugin.version>
+ <asciidoctor-maven-plugin-version>1.5.3</asciidoctor-maven-plugin-version>
+ <asciidoctorj-pdf-version>1.5.0-alpha.11</asciidoctorj-pdf-version>
+ <asciidoctorj-version>1.5.4</asciidoctorj-version>
+ <asciidoctorj-diagram-versions>1.5.4.1</asciidoctorj-diagram-versions>
+ <jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version>
+ <jruby-complete-version>9.0.0.0</jruby-complete-version>
+ <mapstruct.version>1.2.0.Final</mapstruct.version>
+ <flyway-core.version>6.0.8</flyway-core.version>
+ <postgresql.version>42.2.8</postgresql.version>
+ <lombock.version>1.18.10</lombock.version>
+ <h2.version>1.4.200</h2.version>
+ <jsonwebtoken.version>0.9.1</jsonwebtoken.version>
+ <openfeign.version>2.2.0.RELEASE</openfeign.version>
+ <keycloak-core.version>3.4.2.Final</keycloak-core.version>
+ <nexmo.version>5.2.1</nexmo.version>
+ <rabbitmq.version>5.2.0</rabbitmq.version>
+ </properties>
+
+ <dependencies>
+ <!-- https://mvnrepository.com/artifact/org.springframework.amqp/spring-rabbit-test -->
+ <dependency>
+ <groupId>org.springframework.amqp</groupId>
+ <artifactId>spring-rabbit-test</artifactId>
+ <version>2.2.7.RELEASE</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-amqp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-integration</artifactId>
+ <version>2.2.5.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${lombok.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.mapstruct</groupId>
+ <artifactId>mapstruct-processor</artifactId>
+ <version>${mapstruct.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <version>${springfox.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ <version>${springfox.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-reflect</artifactId>
+ <version>${powerMockReflect.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.batch</groupId>
+ <artifactId>spring-batch-core</artifactId>
+ <version>4.2.1.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.batch</groupId>
+ <artifactId>spring-batch-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.rabbitmq</groupId>
+ <artifactId>amqp-client</artifactId>
+ <version>${rabbitmq.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-openfeign</artifactId>
+ <version>${openfeign.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
+ <version>${openfeign.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-contract-wiremock</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-stream-test-support</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
+ </dependencies>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-dependencies</artifactId>
+ <version>${spring-cloud.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>${jacoco-maven-plugin.version}</version>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <output>file</output>
+ <append>true</append>
+ <excludes>
+ <exclude>**/Globals.*</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>jacoco-initialize</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>jacoco-site</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.sonarsource.scanner.maven</groupId>
+ <artifactId>sonar-maven-plugin</artifactId>
+ <version>${sonar-maven-plugin.version}</version>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/SAMO-Interface/sonar-project.properties b/SAMO-Interface/sonar-project.properties
new file mode 100644
index 0000000..16f4b39
--- /dev/null
+++ b/SAMO-Interface/sonar-project.properties
@@ -0,0 +1,19 @@
+# must be unique in a given SonarQube instance
+sonar.projectKey=openk.pta.de:samointerface
+# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
+sonar.projectName=grid-failure-information.samointerface
+sonar.projectVersion=0.0.1_Snapshot
+sonar.java.binaries=target/classes
+
+# Language
+sonar.language=
+
+sonar.sourceEncoding=UTF-8
+sonar.sources=src/main
+sonar.exclusions=**/model/*.java,**/viewmodel/*.java,**/dtos/*.java, **/RabbitMqConfig.java
+sonar.tests=src/test
+#sonar.test.inclusions=**/*.spec.ts
+sonar.test.exclusions=**/model/**,**/viewmodel/**,**/dtos/*.java, **/RabbitMqConfig.java
+#sonar.ts.tslintconfigpath=tslint.json
+
+sonar.typescript.lcov.reportPaths=coverage/lcov.info
\ No newline at end of file
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/SarisInterfaceApplication.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/SarisInterfaceApplication.java
new file mode 100644
index 0000000..d736ac8
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/SarisInterfaceApplication.java
@@ -0,0 +1,15 @@
+package org.eclipse.openk.gridfailureinformation.samointerface;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+@SpringBootApplication
+@EnableFeignClients
+public class SarisInterfaceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SarisInterfaceApplication.class);
+ }
+
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/api/StoerungsauskunftApi.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/api/StoerungsauskunftApi.java
new file mode 100644
index 0000000..db72880
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/api/StoerungsauskunftApi.java
@@ -0,0 +1,37 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+*/
+package org.eclipse.openk.gridfailureinformation.samointerface.api;
+
+import org.eclipse.openk.gridfailureinformation.samointerface.dtos.StoerungsauskunftOutage;
+import org.eclipse.openk.gridfailureinformation.samointerface.dtos.StoerungsauskunftUserNotification;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+
+
+@FeignClient(name="Stoerauskunft.de", url= "${stoerungsauskunft.apiUrl}")
+public interface StoerungsauskunftApi {
+
+ @PostMapping(value= "/outage")
+ feign.Response postOutage(@RequestBody List<StoerungsauskunftOutage> outage);
+
+ @GetMapping(value= "/reports")
+ List<StoerungsauskunftUserNotification> getUserNotification(@RequestParam(value="sectorType") Integer sectorType);
+
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/FeignClientConfig.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/FeignClientConfig.java
new file mode 100644
index 0000000..066b93b
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/FeignClientConfig.java
@@ -0,0 +1,24 @@
+package org.eclipse.openk.gridfailureinformation.samointerface.config;
+
+import feign.RequestInterceptor;
+import feign.auth.BasicAuthRequestInterceptor;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Log4j2
+@Configuration
+public class FeignClientConfig {
+
+ @Value("${stoerungsauskunft.user}")
+ public String user;
+ @Value("${stoerungsauskunft.password}")
+ public String password;
+
+ @Bean
+ public RequestInterceptor basicAuthRequestInterceptor() {
+ return new BasicAuthRequestInterceptor(user, password);
+ }
+
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/SFTPConfig.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/SFTPConfig.java
new file mode 100644
index 0000000..bc7a03a
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/SFTPConfig.java
@@ -0,0 +1,150 @@
+package org.eclipse.openk.gridfailureinformation.samointerface.config;
+
+import com.jcraft.jsch.ChannelSftp;
+import lombok.extern.log4j.Log4j2;
+import org.eclipse.openk.gridfailureinformation.samointerface.service.ImportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.Resource;
+import org.springframework.integration.annotation.InboundChannelAdapter;
+import org.springframework.integration.annotation.Poller;
+import org.springframework.integration.annotation.ServiceActivator;
+import org.springframework.integration.annotation.Transformer;
+import org.springframework.integration.core.MessageSource;
+import org.springframework.integration.file.FileHeaders;
+import org.springframework.integration.file.remote.session.CachingSessionFactory;
+import org.springframework.integration.file.remote.session.SessionFactory;
+import org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice;
+import org.springframework.integration.sftp.filters.SftpSimplePatternFileListFilter;
+import org.springframework.integration.sftp.inbound.SftpStreamingMessageSource;
+import org.springframework.integration.sftp.session.DefaultSftpSessionFactory;
+import org.springframework.integration.sftp.session.SftpFileInfo;
+import org.springframework.integration.sftp.session.SftpRemoteFileTemplate;
+import org.springframework.integration.transformer.StreamTransformer;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.MessageHandler;
+import org.springframework.messaging.MessagingException;
+
+import java.io.InputStream;
+
+@Log4j2
+@Configuration
+@ConditionalOnProperty(prefix = "sftp", name = "enable-polling", havingValue = "true", matchIfMissing = false)
+public class SFTPConfig {
+
+ @Autowired
+ ImportService importService;
+
+ @Value("${sftp.host:}")
+ public String sftpHost;
+ @Value("${sftp.port:22}")
+ public int sftpPort;
+ @Value("${sftp.user:}")
+ public String sftpUser;
+ @Value("${sftp.password:}")
+ public String sftpPwd;
+
+ @Value("${sftp.privateKey:#{null}}")
+ private Resource sftpPrivateKey;
+ @Value("${sftp.privateKeyPassphrase:}")
+ private String sftpPrivateKeyPassphrase;
+
+ @Value("${sftp.directory:}")
+ public String sftDirectory;
+ @Value("${sftp.fileFilter:*.*}")
+ public String sftpFileFilter;
+ @Value("${sftp.deleteRemoteFile:false}")
+ public boolean deleteRemoteFile;
+
+ private long remoteFileLastModified = 0;
+
+ @Bean
+ public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory() {
+ DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
+ factory.setHost(sftpHost);
+ factory.setPort(sftpPort);
+ factory.setUser(sftpUser);
+ if (sftpPrivateKey != null) {
+ log.info("Using privatekey for SSH-Connection");
+ factory.setPrivateKey(sftpPrivateKey);
+ factory.setPrivateKeyPassphrase(sftpPrivateKeyPassphrase);
+ } else {
+ log.info("Using User/Password for SSH-Connection");
+ factory.setPassword(sftpPwd);
+ }
+
+ factory.setAllowUnknownKeys(true);
+ return new CachingSessionFactory<>(factory);
+ }
+
+ @Bean
+ @InboundChannelAdapter(channel = "stream", poller = @Poller(cron = "${sftp.cron}"))
+ public MessageSource<InputStream> sftpMessageSource() {
+ SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template());
+ String remoteDirecotry = sftDirectory;
+ messageSource.setRemoteDirectory(remoteDirecotry);
+ messageSource.setFilter(new SftpSimplePatternFileListFilter(sftpFileFilter));
+ messageSource.setFileInfoJson(false);
+ return messageSource;
+ }
+
+ @Bean
+ public SftpRemoteFileTemplate template() {
+ return new SftpRemoteFileTemplate(sftpSessionFactory());
+ }
+
+ @Bean
+ @Transformer(inputChannel = "stream", outputChannel = "data")
+ public org.springframework.integration.transformer.Transformer transformer() {
+ return new StreamTransformer("UTF-8");
+ }
+
+
+ @ServiceActivator(inputChannel = "data", adviceChain = "afterChain")
+ @Bean
+ public MessageHandler handler() {
+
+ return new MessageHandler() {
+ @Override
+ public void handleMessage(Message<?> message) throws MessagingException {
+
+ if (isFileModified(message)) {
+ log.debug("File modified or new: "+ message.getHeaders().get(FileHeaders.REMOTE_FILE));
+ String payload = (String) message.getPayload();
+ importService.importSAMOOutage(payload);
+ }
+ }
+ };
+ }
+
+ private boolean isFileModified(Message<?> message) {
+ SftpFileInfo remoteFileInfo = (SftpFileInfo) message.getHeaders().get(FileHeaders.REMOTE_FILE_INFO);
+ long modified = 0;
+ if (remoteFileInfo != null) {
+ modified = remoteFileInfo.getModified();
+ }
+ if (modified != remoteFileLastModified && modified != 0) {
+ remoteFileLastModified = modified;
+ return true;
+ }
+ return false;
+ }
+
+ @Bean
+ public ExpressionEvaluatingRequestHandlerAdvice afterChain() {
+
+ ExpressionEvaluatingRequestHandlerAdvice advice = new ExpressionEvaluatingRequestHandlerAdvice();
+ if (deleteRemoteFile) {
+ advice.setOnSuccessExpressionString("@template.remove(headers['file_remoteDirectory'] + headers['file_remoteFile'])");
+ }
+ advice.setPropagateEvaluationFailures(true);
+ return advice;
+
+ }
+
+}
+
+
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/SwaggerConfig.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/SwaggerConfig.java
new file mode 100644
index 0000000..8123284
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/SwaggerConfig.java
@@ -0,0 +1,35 @@
+package org.eclipse.openk.gridfailureinformation.samointerface.config;
+
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.paths.RelativePathProvider;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import javax.servlet.ServletContext;
+
+@Log4j2
+@Configuration
+@EnableSwagger2
+@Profile({"!test","!prod"})
+public class SwaggerConfig {
+
+ @Value("${swagger.baseUrl:}")
+ public String baseUrl;
+ @Value("${swagger.proxyUrl:}")
+ public String proxyUrl;
+
+ @Bean
+ public Docket api(ServletContext servletContext) {
+ return new Docket(DocumentationType.SWAGGER_2).pathProvider(new RelativePathProvider(servletContext) {
+ @Override
+ public String getApplicationBasePath() {
+ return baseUrl + super.getApplicationBasePath();
+ }
+ }).host(proxyUrl);
+ }
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/rabbitMq/RabbitMqConfig.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/rabbitMq/RabbitMqConfig.java
new file mode 100644
index 0000000..77a3727
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/rabbitMq/RabbitMqConfig.java
@@ -0,0 +1,73 @@
+package org.eclipse.openk.gridfailureinformation.samointerface.config.rabbitMq;
+
+import lombok.Data;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.DirectExchange;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.rabbit.annotation.EnableRabbit;
+import org.springframework.amqp.rabbit.core.RabbitAdmin;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.integration.annotation.ServiceActivator;
+import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.config.EnableIntegration;
+import org.springframework.messaging.MessageChannel;
+import org.springframework.messaging.MessageHandler;
+
+import javax.annotation.PostConstruct;
+
+@Profile("!test")
+@Configuration
+@Log4j2
+@EnableRabbit
+@EnableIntegration
+@Data
+public class RabbitMqConfig {
+
+ @Autowired
+ private RabbitTemplate rabbitTemplate;
+
+ @Autowired
+ private RabbitMqProperties rabbitMqProperties;
+
+ @Bean
+ public MessageChannel failureImportChannel() {
+ return new DirectChannel();
+ }
+
+ @PostConstruct
+ public void buildAllQueues() {
+ log.info("RabbitMqConfig: Configuring all Exchanges and Queues");
+
+ RabbitAdmin admin = new RabbitAdmin(rabbitTemplate);
+
+ // Neuerstellung Exchange und Queues (Import) falls diese nicht vorhanden sind (passiert nur dann!)
+ DirectExchange importExchange = new DirectExchange(rabbitMqProperties.getImportExchange());
+ log.info("************** Configure Import RabbitMQ **************");
+ log.info("ImportExchange: " + rabbitMqProperties.getImportExchange());
+ admin.declareExchange(importExchange);
+ Queue importQueue = new Queue(rabbitMqProperties.getImportQueue());
+ log.info("ImportQueue: " + rabbitMqProperties.getImportQueue());
+ log.info("ImportKey: " + rabbitMqProperties.getImportKey());
+ admin.declareQueue(importQueue);
+ admin.declareBinding(BindingBuilder.bind(importQueue).to(importExchange).with(rabbitMqProperties.getImportKey()));
+
+ }
+
+ @Bean
+ @ServiceActivator(inputChannel = "failureImportChannel")
+ public MessageHandler messageHandler() {
+
+ return message -> rabbitTemplate.convertAndSend(rabbitMqProperties.getImportExchange(),
+ rabbitMqProperties.getImportKey(), message.getPayload(), message1 -> {
+ message1.getMessageProperties().getHeaders().put("metaId", message.getHeaders().get("metaId"));
+ message1.getMessageProperties().getHeaders().put("description", message.getHeaders().get("description"));
+ message1.getMessageProperties().getHeaders().put("source", message.getHeaders().get("source"));
+ return message1;
+ });
+ }
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/rabbitMq/RabbitMqProperties.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/rabbitMq/RabbitMqProperties.java
new file mode 100644
index 0000000..6e0d653
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/config/rabbitMq/RabbitMqProperties.java
@@ -0,0 +1,30 @@
+package org.eclipse.openk.gridfailureinformation.samointerface.config.rabbitMq;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Getter
+@Setter
+@Configuration
+@ConfigurationProperties(prefix = "spring.rabbitmq", ignoreUnknownFields = true)
+public class RabbitMqProperties {
+
+ private String host;
+ private String port;
+ private String username;
+ private String password;
+
+ private String importExchange;
+ private String importQueue;
+ private String importKey;
+
+}
+
+
+
+
+
+
+
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/constants/Constants.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/constants/Constants.java
new file mode 100644
index 0000000..8f7d097
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/constants/Constants.java
@@ -0,0 +1,30 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+*/
+package org.eclipse.openk.gridfailureinformation.samointerface.constants;
+
+public final class Constants {
+
+ public static final String BRANCH_ELECTRICITY = "S";
+ public static final String VOLTAGE_LVL_LOW = "NS";
+
+ public static final String PLANNED_OUTAGE = "planned";
+ public static final String UNPLANNED_OUTAGE = "unplanned";
+ public static final String SRC_SAMO = "SAMO";
+
+
+ private Constants() {
+ // empty Constructor for the sake of SONAR
+ }
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/controller/ImportController.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/controller/ImportController.java
new file mode 100644
index 0000000..9b150df
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/controller/ImportController.java
@@ -0,0 +1,51 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.samointerface.controller;
+
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import lombok.extern.log4j.Log4j2;
+import org.eclipse.openk.gridfailureinformation.samointerface.service.ImportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.xml.bind.JAXBException;
+
+@Log4j2
+@RestController
+@RequestMapping("/samo")
+public class ImportController {
+
+ @Autowired
+ private ImportService importService;
+
+ @GetMapping("/test")
+ @ApiOperation(value = "Import von Störungsinformationen von SARIS zu SIT")
+ @ApiResponses(value = {
+ @ApiResponse(code = 201, message = "Störungsinformation erfolgreich importiert"),
+ @ApiResponse(code = 500, message = "Konnte nicht durchgeführt werden")
+ })
+ @ResponseStatus(HttpStatus.OK)
+ public void testSamo() throws JAXBException {
+
+ System.err.println("tester");
+ }
+
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/ForeignFailureDataDto.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/ForeignFailureDataDto.java
new file mode 100644
index 0000000..554449c
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/ForeignFailureDataDto.java
@@ -0,0 +1,89 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.samointerface.dtos;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import javax.validation.constraints.*;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class ForeignFailureDataDto implements Serializable {
+
+ @NotNull
+ private boolean isPlanned;
+
+ @JsonProperty("description")
+ private String description;
+
+ @NotNull
+ @Pattern(regexp = "^$|(S|W|F|G|TK|ST)")
+ private String branch;
+
+ @Pattern(regexp="^$|(NS|MS|HS)")
+ private String voltageLevel;
+
+ @Pattern(regexp="^$|(ND|MD|HD)")
+ private String pressureLevel;
+
+ @NotNull
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ private Date failureBegin;
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ private Date failureEndPlanned;
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ private Date failureEndResupplied;
+
+ @Size(max=10)
+ @Pattern(regexp="^$|[A-Za-z0-9_/-]+")
+ private String postcode;
+
+ @Size(max=200)
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()-]+")
+ private String city;
+
+ @Size(max=200)
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()-]+")
+ private String district;
+
+ @Size(max=200)
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()-]+")
+ private String street;
+
+ @Size(max=10)
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()-]+")
+ private String housenumber;
+
+ @Size(max=200)
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()-]+")
+ private String stationId;
+
+ @Size(max=200)
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()-]+")
+ private String stationDescription;
+
+ private BigDecimal longitude;
+ private BigDecimal latitude;
+
+ @Min(0L)
+ @Max(100000L)
+ private Long radiusInMeters;
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/ForeignFailureMessageDto.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/ForeignFailureMessageDto.java
new file mode 100644
index 0000000..c20f22b
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/ForeignFailureMessageDto.java
@@ -0,0 +1,45 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.samointerface.dtos;
+
+import lombok.Data;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+
+@Data
+public class ForeignFailureMessageDto implements Serializable {
+
+ @NotNull
+ @Size(max=256)
+ @Pattern(regexp="[A-Za-z0-9\\s_/:.-]+")
+ private String metaId;
+
+ @Size(max=256)
+ @Pattern(regexp="^$|[A-Za-z0-9\\s_/(),.;:-]+")
+ private String description;
+
+ @NotNull
+ @Size(max=100)
+ @Pattern(regexp="[A-Za-z0-9\\s_/(),.;:-]+")
+ private String source;
+
+ @NotNull
+ private @Valid ForeignFailureDataDto payload;
+
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/SAMOOutage.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/SAMOOutage.java
new file mode 100644
index 0000000..a081837
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/SAMOOutage.java
@@ -0,0 +1,18 @@
+package org.eclipse.openk.gridfailureinformation.samointerface.dtos;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class SAMOOutage implements Serializable {
+
+ private String id; //klären unique ID
+ private String voltageLevel;
+ private String pressureLevel;
+ private String description;
+ private Date failureBegin;
+ private Date failureEndResupplied;
+
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/StoerungsauskunftOutage.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/StoerungsauskunftOutage.java
new file mode 100644
index 0000000..023a3b0
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/StoerungsauskunftOutage.java
@@ -0,0 +1,27 @@
+package org.eclipse.openk.gridfailureinformation.samointerface.dtos;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class StoerungsauskunftOutage implements Serializable {
+
+ private String id;
+ private String operatorID;
+ private String type;
+ private Integer origin;
+ private Integer geoType;
+ private String date;
+ private String estimatedEnding;
+ private String postcode;
+ private String city;
+ private String district;
+ private String ags;
+ private Integer radius;
+ private String coordinates;
+ private String liveInfo;
+ private Integer social;
+ private String socialText;
+
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/StoerungsauskunftUserNotification.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/StoerungsauskunftUserNotification.java
new file mode 100644
index 0000000..0b5efbe
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/dtos/StoerungsauskunftUserNotification.java
@@ -0,0 +1,24 @@
+package org.eclipse.openk.gridfailureinformation.samointerface.dtos;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@Data
+public class StoerungsauskunftUserNotification implements Serializable {
+
+ private String id;
+ private String date;
+ private String postcode;
+ private String city;
+ private String street;
+ private String houseNo;
+ private String district;
+ private String ags;
+ private String lat;
+ private String lng;
+ private String comment;
+
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/exceptions/InternalServerErrorException.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/exceptions/InternalServerErrorException.java
new file mode 100644
index 0000000..9fdd3e6
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/exceptions/InternalServerErrorException.java
@@ -0,0 +1,25 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.samointerface.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
+public class InternalServerErrorException extends RuntimeException{
+ public InternalServerErrorException(String message) {
+ super(message);
+ }
+}
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/mapper/SAMOMapper.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/mapper/SAMOMapper.java
new file mode 100644
index 0000000..d9f0f31
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/mapper/SAMOMapper.java
@@ -0,0 +1,37 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.samointerface.mapper;
+
+import org.eclipse.openk.gridfailureinformation.samointerface.constants.Constants;
+import org.eclipse.openk.gridfailureinformation.samointerface.dtos.ForeignFailureDataDto;
+import org.eclipse.openk.gridfailureinformation.samointerface.dtos.SAMOOutage;
+import org.eclipse.openk.gridfailureinformation.samointerface.dtos.StoerungsauskunftUserNotification;
+import org.mapstruct.AfterMapping;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.MappingTarget;
+import org.mapstruct.Mappings;
+import org.mapstruct.Named;
+import org.mapstruct.ReportingPolicy;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface SAMOMapper {
+
+ ForeignFailureDataDto toForeignFailureDataDto(SAMOOutage srcEntity);
+
+}
\ No newline at end of file
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/mapper/StoerungsauskunftMapper.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/mapper/StoerungsauskunftMapper.java
new file mode 100644
index 0000000..f1b9b7d
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/mapper/StoerungsauskunftMapper.java
@@ -0,0 +1,76 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.samointerface.mapper;
+
+import org.eclipse.openk.gridfailureinformation.samointerface.constants.Constants;
+import org.eclipse.openk.gridfailureinformation.samointerface.dtos.ForeignFailureDataDto;
+import org.eclipse.openk.gridfailureinformation.samointerface.dtos.StoerungsauskunftUserNotification;
+import org.mapstruct.*;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface StoerungsauskunftMapper {
+
+ final Pattern STREET_HOUSENUMBER_PATTERN = Pattern.compile("(^\\D+)(\\d.*)");
+
+ @Mappings({
+ @Mapping(target = "description", source = "comment"),
+ @Mapping(target = "failureBegin", source = "date", dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"),
+ @Mapping(target = "longitude", source = "lng"),
+ @Mapping(target = "latitude", source = "lat"),
+ @Mapping(target = "street", source = "street", qualifiedByName = "streetMapperToForeignFailureDataDto"),
+ @Mapping(target = "housenumber", source = "houseNo"),
+ })
+ ForeignFailureDataDto toForeignFailureDataDto(StoerungsauskunftUserNotification srcEntity);
+
+
+ @AfterMapping
+ default void afterMappingProcess(StoerungsauskunftUserNotification srcEntity, @MappingTarget ForeignFailureDataDto targetEntity){
+ if (targetEntity.getHousenumber() == null || targetEntity.getHousenumber().isEmpty()){
+ targetEntity.setHousenumber(housenumberMapperToForeignFailureDataDto(srcEntity.getStreet()));
+ }
+ targetEntity.setRadiusInMeters(0L);
+ targetEntity.setVoltageLevel(Constants.VOLTAGE_LVL_LOW);
+ }
+
+ @Named("streetMapperToForeignFailureDataDto")
+ default String streetMapperToForeignFailureDataDto(String streetFromUserNotification) {
+ if (streetFromUserNotification == null || streetFromUserNotification.isEmpty()) return "";
+ String street = streetFromUserNotification;
+ Matcher matcher = STREET_HOUSENUMBER_PATTERN.matcher(streetFromUserNotification);
+ if (matcher.matches()) {
+ street = matcher.group(1).trim();
+ }
+ return street;
+ }
+
+ @Named("housenumberMapperToForeignFailureDataDto")
+ default String housenumberMapperToForeignFailureDataDto(String streetFromUserNotification) {
+ if (streetFromUserNotification == null || streetFromUserNotification.isEmpty()) return "";
+ String housenumber = "";
+ Matcher matcher = STREET_HOUSENUMBER_PATTERN.matcher(streetFromUserNotification);
+ if (matcher.matches()) {
+ housenumber = matcher.group(2).trim();
+ }
+ return housenumber;
+ }
+
+ /* Exportmapper */
+
+
+
+}
\ No newline at end of file
diff --git a/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/service/ImportService.java b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/service/ImportService.java
new file mode 100644
index 0000000..66d5223
--- /dev/null
+++ b/SAMO-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/samointerface/service/ImportService.java
@@ -0,0 +1,93 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.samointerface.service;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.log4j.Log4j2;
+import org.eclipse.openk.gridfailureinformation.samointerface.constants.Constants;
+import org.eclipse.openk.gridfailureinformation.samointerface.dtos.ForeignFailureDataDto;
+import org.eclipse.openk.gridfailureinformation.samointerface.dtos.ForeignFailureMessageDto;
+import org.eclipse.openk.gridfailureinformation.samointerface.dtos.SAMOOutage;
+import org.eclipse.openk.gridfailureinformation.samointerface.exceptions.InternalServerErrorException;
+import org.eclipse.openk.gridfailureinformation.samointerface.mapper.SAMOMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.messaging.MessageChannel;
+import org.springframework.messaging.support.MessageBuilder;
+import org.springframework.stereotype.Service;
+
+@Service
+@Log4j2
+@EnableConfigurationProperties
+@ConfigurationProperties(prefix = "rabbitmq")
+public class ImportService {
+
+ @Autowired
+ private MessageChannel failureImportChannel;
+
+ @Autowired
+ private ObjectMapper objectMapper;
+
+ @Autowired
+ SAMOMapper samoMapper;
+
+ public void importSAMOOutage(String samoOutageJson) {
+ try {
+ SAMOOutage samoOutage = objectMapper.readValue(samoOutageJson, SAMOOutage.class);
+ ForeignFailureMessageDto foreignFailureMessageDto = createForeignFailureMessageDto(samoOutage);
+ log.info("Succeeded");
+ } catch (JsonProcessingException e) {
+ log.error("Error parsing SAMOOutage", e);
+ }
+
+ }
+
+ private ForeignFailureMessageDto createForeignFailureMessageDto(SAMOOutage samoOutage) {
+ ForeignFailureMessageDto foreignFailureMessageDto = new ForeignFailureMessageDto();
+ foreignFailureMessageDto.setMetaId(samoOutage.getId()); //fixme klärung
+ foreignFailureMessageDto.setSource(Constants.SRC_SAMO);
+ ForeignFailureDataDto foreignFailureDataDto = createForeignFailureData(samoOutage);
+ foreignFailureMessageDto.setPayload(foreignFailureDataDto);
+ return foreignFailureMessageDto;
+ }
+
+ private ForeignFailureDataDto createForeignFailureData(SAMOOutage samoOutage) {
+ ForeignFailureDataDto foreignFailureDataDto = samoMapper.toForeignFailureDataDto(samoOutage);
+ foreignFailureDataDto.setBranch(Constants.BRANCH_ELECTRICITY); //fixme klärung: logik einbauen
+ foreignFailureDataDto.setPlanned(false); //fixme klärung
+ return foreignFailureDataDto;
+ }
+
+ public void pushForeignFailure(ForeignFailureMessageDto foreignFailureMessageDto) {
+
+ try {
+ failureImportChannel.send(
+ MessageBuilder.withPayload(
+ objectMapper.writeValueAsString(foreignFailureMessageDto.getPayload()))
+ .setHeader("metaId", foreignFailureMessageDto.getMetaId())
+ .setHeader("description", foreignFailureMessageDto.getDescription())
+ .setHeader("source", foreignFailureMessageDto.getSource())
+ .build());
+ log.info("Succesfully sent message from SAMO-Interface to main-app with metaId: " + foreignFailureMessageDto.getMetaId());
+ } catch (Exception e) {
+ log.debug(e.getMessage(), e);
+ throw new InternalServerErrorException("could.not.push.message");
+ }
+
+ }
+
+}
diff --git a/SAMO-Interface/src/main/resources/application.yml b/SAMO-Interface/src/main/resources/application.yml
new file mode 100644
index 0000000..9b9a28f
--- /dev/null
+++ b/SAMO-Interface/src/main/resources/application.yml
@@ -0,0 +1,172 @@
+# *******************************************************************************
+# Copyright (c) 2019 Contributors to the Eclipse Foundation
+#
+# See the NOTICE file(s) distributed with this work for additional
+# information regarding copyright ownership.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0 which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# SPDX-License-Identifier: EPL-2.0
+# *******************************************************************************
+spring:
+ rabbitmq:
+ host: entdockergss
+ port: 5672
+ username: ${GFI_RABBITMQ_USERNAME}
+ password: ${GFI_RABBITMQ_PASSWORD}
+
+ # Importkanal
+ importExchange: sitImportExchange
+ importQueue: sitImportQueue
+ importkey: sitImportExchange.failureImportKey
+
+logging:
+ level:
+ root: INFO
+ org.eclipse.openk: INFO
+ org.springframework.web: ERROR
+
+server:
+ max-http-header-size: 262144
+
+jwt:
+ tokenHeader: Authorization
+ useStaticJwt: false
+ staticJwt: x
+
+gridFailureInformation:
+ maxListSize: 2000
+
+feign:
+ client:
+ config:
+ default:
+ connectTimeout: 60000
+ readTimeout: 60000
+cors:
+ corsEnabled: false
+
+stoerungsauskunft:
+ apiUrl: https://stage-api-operator.stoerungsauskunft.de/api/v1.0/
+ user: ${GFI_STOERUNGSAUSKUNFT_USERNAME}
+ password: ${GFI_STOERUNGSAUSKUNFT_PASSWORD}
+ scheduling-import:
+ enabled: false
+ cron: 0 */15 * ? * *
+
+sftp:
+ enable-polling: true
+ host: 169.50.13.154
+ #privateKey: classpath:/keys/privateOpenKQServer_key-SAMO-Interface
+ privateKey:
+ privateKeyPassphrase:
+ user: ${GFI_SAMO_SFTP_USERNAME}
+ password: ${GFI_SAMO_SFTP_PASSWORD}
+ deleteRemoteFile: false
+ directory: /opt/transfer/SAMOInterfaceDEVsftpTest/
+ fileFilter: '*.json'
+ cron: 0/5 * * ? * * # Check for new file in directory every 'cron' time
+---
+
+spring:
+ profiles: test
+
+jwt:
+ tokenHeader: Authorization
+ useStaticJwt: true
+ staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI5MGI0NGFkOC1iYjlmLTQ1MzktYTQwYy0yYjQyZTNkNjNiOGEiLCJleHAiOjE1Nzg2NTU3OTUsIm5iZiI6MCwiaWF0IjoxNTc4NjU1NDk1LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiODYyNjY5NmYtZjFhMi00ZGI1LTkyZWYtZTlhMjQ2Njg1YTU0IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZWxvZ2Jvb2stYmFja2VuZCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjJmMWIzODE5LWZjNjQtNDEzNC1iNWQxLWY3ZWY4NzU5NDBkNCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsia29uLWFkbWluIiwia29uLXdyaXRlciIsImtvbi1hY2Nlc3MiLCJrb24tcmVhZGVyIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJuYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSBUZXN0ZXJMYXN0bmFtZV9yd2EiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0ZXN0dXNlcl9yd2EiLCJnaXZlbl9uYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSIsImZhbWlseV9uYW1lIjoiVGVzdGVyTGFzdG5hbWVfcndhIn0.DAYXuv4tKn8RXqO1jyttnD-tF4nShUBQyfe4bKbAiPAyY2x5YbAf3M4eXnLrGqo8-loGKldICC28bL0LaMA3KKkQEOfW5sfpGqoN6212vs89mOklt0TJYc5PMXwFgJ5WC_TKjdwq7-aaDafOEWehV0U1ut3s-94ovNYIEn29nzXm2W1ldoXJEq03F880jlysQ5zlRvGF7eXEEpFfI2URyyNQ2UWh0Ssfq-gOAt2pbF1u6prA5RfvUmZ3v1eu21YLGZtgqPqxb1l6odyH3ip15j_HdgnTeo52ymxuRUj65Mskme3V5ev2DitHI9vZgnpV8Idhb4TTWliBeGCOMfDFCg
+
+---
+
+spring:
+ profiles: devserver
+
+logging:
+ level:
+ root: INFO
+ org.eclipse.openk: DEBUG
+ org.springframework.web: ERROR
+
+jwt:
+ tokenHeader: Authorization
+ useStaticJwt: false
+ staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI5MGI0NGFkOC1iYjlmLTQ1MzktYTQwYy0yYjQyZTNkNjNiOGEiLCJleHAiOjE1Nzg2NTU3OTUsIm5iZiI6MCwiaWF0IjoxNTc4NjU1NDk1LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiODYyNjY5NmYtZjFhMi00ZGI1LTkyZWYtZTlhMjQ2Njg1YTU0IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZWxvZ2Jvb2stYmFja2VuZCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjJmMWIzODE5LWZjNjQtNDEzNC1iNWQxLWY3ZWY4NzU5NDBkNCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsia29uLWFkbWluIiwia29uLXdyaXRlciIsImtvbi1hY2Nlc3MiLCJrb24tcmVhZGVyIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJuYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSBUZXN0ZXJMYXN0bmFtZV9yd2EiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0ZXN0dXNlcl9yd2EiLCJnaXZlbl9uYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSIsImZhbWlseV9uYW1lIjoiVGVzdGVyTGFzdG5hbWVfcndhIn0.DAYXuv4tKn8RXqO1jyttnD-tF4nShUBQyfe4bKbAiPAyY2x5YbAf3M4eXnLrGqo8-loGKldICC28bL0LaMA3KKkQEOfW5sfpGqoN6212vs89mOklt0TJYc5PMXwFgJ5WC_TKjdwq7-aaDafOEWehV0U1ut3s-94ovNYIEn29nzXm2W1ldoXJEq03F880jlysQ5zlRvGF7eXEEpFfI2URyyNQ2UWh0Ssfq-gOAt2pbF1u6prA5RfvUmZ3v1eu21YLGZtgqPqxb1l6odyH3ip15j_HdgnTeo52ymxuRUj65Mskme3V5ev2DitHI9vZgnpV8Idhb4TTWliBeGCOMfDFCg
+
+server:
+ port: 9196
+
+cors:
+ corsEnabled: true
+
+---
+
+spring:
+ profiles: devserver-unsecure
+
+logging:
+ level:
+ root: INFO
+ org.eclipse.openk: DEBUG
+ org.springframework.web: ERROR
+
+jwt:
+ tokenHeader: Authorization
+ useStaticJwt: true
+ staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI5MGI0NGFkOC1iYjlmLTQ1MzktYTQwYy0yYjQyZTNkNjNiOGEiLCJleHAiOjE1Nzg2NTU3OTUsIm5iZiI6MCwiaWF0IjoxNTc4NjU1NDk1LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiODYyNjY5NmYtZjFhMi00ZGI1LTkyZWYtZTlhMjQ2Njg1YTU0IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZWxvZ2Jvb2stYmFja2VuZCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjJmMWIzODE5LWZjNjQtNDEzNC1iNWQxLWY3ZWY4NzU5NDBkNCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsia29uLWFkbWluIiwia29uLXdyaXRlciIsImtvbi1hY2Nlc3MiLCJrb24tcmVhZGVyIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJuYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSBUZXN0ZXJMYXN0bmFtZV9yd2EiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0ZXN0dXNlcl9yd2EiLCJnaXZlbl9uYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSIsImZhbWlseV9uYW1lIjoiVGVzdGVyTGFzdG5hbWVfcndhIn0.DAYXuv4tKn8RXqO1jyttnD-tF4nShUBQyfe4bKbAiPAyY2x5YbAf3M4eXnLrGqo8-loGKldICC28bL0LaMA3KKkQEOfW5sfpGqoN6212vs89mOklt0TJYc5PMXwFgJ5WC_TKjdwq7-aaDafOEWehV0U1ut3s-94ovNYIEn29nzXm2W1ldoXJEq03F880jlysQ5zlRvGF7eXEEpFfI2URyyNQ2UWh0Ssfq-gOAt2pbF1u6prA5RfvUmZ3v1eu21YLGZtgqPqxb1l6odyH3ip15j_HdgnTeo52ymxuRUj65Mskme3V5ev2DitHI9vZgnpV8Idhb4TTWliBeGCOMfDFCg
+
+server:
+ port: 9197
+
+cors:
+ corsEnabled: true
+
+---
+
+spring:
+ profiles: devserver-branch
+ rabbitmq:
+ # Importkanal
+ importExchange: sitImportExchange_branch
+ importQueue: sitImportQueue_branch
+ importkey: sitImportExchange.failureImportKey
+
+---
+
+spring:
+ profiles: qserver
+ rabbitmq:
+ host: localhost
+ port: 5672
+ username: ${GFI_RABBITMQ_USERNAME}
+ password: ${GFI_RABBITMQ_PASSWORD}
+
+ # Importkanal
+ importExchange: sitImportExchange
+ importQueue: sitImportQueue
+ importkey: sitImportExchange.failureImportKey
+
+logging:
+ level:
+ root: INFO
+ org.eclipse.openk: DEBUG
+ org.springframework.web: ERROR
+
+server:
+ port: 9195
+ max-http-header-size: 262144
+ servlet:
+ session:
+ tracking-modes: cookie
+
+jwt:
+ tokenHeader: Authorization
+ useStaticJwt: false
+ staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI5MGI0NGFkOC1iYjlmLTQ1MzktYTQwYy0yYjQyZTNkNjNiOGEiLCJleHAiOjE1Nzg2NTU3OTUsIm5iZiI6MCwiaWF0IjoxNTc4NjU1NDk1LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiODYyNjY5NmYtZjFhMi00ZGI1LTkyZWYtZTlhMjQ2Njg1YTU0IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZWxvZ2Jvb2stYmFja2VuZCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjJmMWIzODE5LWZjNjQtNDEzNC1iNWQxLWY3ZWY4NzU5NDBkNCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsia29uLWFkbWluIiwia29uLXdyaXRlciIsImtvbi1hY2Nlc3MiLCJrb24tcmVhZGVyIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJuYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSBUZXN0ZXJMYXN0bmFtZV9yd2EiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0ZXN0dXNlcl9yd2EiLCJnaXZlbl9uYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSIsImZhbWlseV9uYW1lIjoiVGVzdGVyTGFzdG5hbWVfcndhIn0.DAYXuv4tKn8RXqO1jyttnD-tF4nShUBQyfe4bKbAiPAyY2x5YbAf3M4eXnLrGqo8-loGKldICC28bL0LaMA3KKkQEOfW5sfpGqoN6212vs89mOklt0TJYc5PMXwFgJ5WC_TKjdwq7-aaDafOEWehV0U1ut3s-94ovNYIEn29nzXm2W1ldoXJEq03F880jlysQ5zlRvGF7eXEEpFfI2URyyNQ2UWh0Ssfq-gOAt2pbF1u6prA5RfvUmZ3v1eu21YLGZtgqPqxb1l6odyH3ip15j_HdgnTeo52ymxuRUj65Mskme3V5ev2DitHI9vZgnpV8Idhb4TTWliBeGCOMfDFCg
+
+cors:
+ corsEnabled: true
+
+swagger:
+ baseUrl: /test-stoerungsauskunft-interface
\ No newline at end of file
diff --git a/SAMO-Interface/src/main/resources/application_localdev.yml b/SAMO-Interface/src/main/resources/application_localdev.yml
new file mode 100644
index 0000000..ef109a2
--- /dev/null
+++ b/SAMO-Interface/src/main/resources/application_localdev.yml
@@ -0,0 +1,95 @@
+# *******************************************************************************
+# Copyright (c) 2019 Contributors to the Eclipse Foundation
+#
+# See the NOTICE file(s) distributed with this work for additional
+# information regarding copyright ownership.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0 which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# SPDX-License-Identifier: EPL-2.0
+# *******************************************************************************
+spring:
+ rabbitmq:
+ host: entdockergss
+ port: 5672
+ username: ${GFI_RABBITMQ_USERNAME}
+ password: ${GFI_RABBITMQ_PASSWORD}
+
+ # Importkanal
+ importExchange: sitImportExchange_localdev
+ importQueue: sitImportQueue_localdev
+ importkey: sitImportExchange.failureImportKey_localdev
+
+logging:
+ level:
+ root: INFO
+ org.eclipse.openk: DEBUG
+ org.springframework.web: ERROR
+
+eureka:
+ client:
+ service-url:
+ defaulZone: http://localhost:8761/
+ instance:
+ prefer-ip-address: true
+
+index-channel:
+ enabled: true
+
+server:
+ port: 9196
+ max-http-header-size: 262144
+ servlet:
+ session:
+ tracking-modes: cookie
+
+gridFailureInformation:
+ maxListSize: 2000
+
+jwt:
+ tokenHeader: Authorization
+ useStaticJwt: false
+ staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI5MGI0NGFkOC1iYjlmLTQ1MzktYTQwYy0yYjQyZTNkNjNiOGEiLCJleHAiOjE1Nzg2NTU3OTUsIm5iZiI6MCwiaWF0IjoxNTc4NjU1NDk1LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiODYyNjY5NmYtZjFhMi00ZGI1LTkyZWYtZTlhMjQ2Njg1YTU0IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZWxvZ2Jvb2stYmFja2VuZCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjJmMWIzODE5LWZjNjQtNDEzNC1iNWQxLWY3ZWY4NzU5NDBkNCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsia29uLWFkbWluIiwia29uLXdyaXRlciIsImtvbi1hY2Nlc3MiLCJrb24tcmVhZGVyIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJuYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSBUZXN0ZXJMYXN0bmFtZV9yd2EiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0ZXN0dXNlcl9yd2EiLCJnaXZlbl9uYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSIsImZhbWlseV9uYW1lIjoiVGVzdGVyTGFzdG5hbWVfcndhIn0.DAYXuv4tKn8RXqO1jyttnD-tF4nShUBQyfe4bKbAiPAyY2x5YbAf3M4eXnLrGqo8-loGKldICC28bL0LaMA3KKkQEOfW5sfpGqoN6212vs89mOklt0TJYc5PMXwFgJ5WC_TKjdwq7-aaDafOEWehV0U1ut3s-94ovNYIEn29nzXm2W1ldoXJEq03F880jlysQ5zlRvGF7eXEEpFfI2URyyNQ2UWh0Ssfq-gOAt2pbF1u6prA5RfvUmZ3v1eu21YLGZtgqPqxb1l6odyH3ip15j_HdgnTeo52ymxuRUj65Mskme3V5ev2DitHI9vZgnpV8Idhb4TTWliBeGCOMfDFCg
+
+feign:
+ client:
+ config:
+ default:
+ connectTimeout: 5000
+ readTimeout: 5000
+ loggerLevel: FULL
+
+logging.level.org.eclipse.openk.gridfailureinformation.jobs.stoerauskunftinterface.api.StoerauskunftApi: DEBUG
+
+cors:
+ corsEnabled: true
+
+stoerungsauskunft:
+ apiUrl: https://stage-api-operator.stoerungsauskunft.de/api/v1.0/
+ user: ${GFI_STOERUNGSAUSKUNFT_USERNAME}
+ password: ${GFI_STOERUNGSAUSKUNFT_PASSWORD}
+ scheduling-import:
+ enabled: false
+ cron: 0 */15 * ? * *
+
+---
+
+spring:
+ profiles: dev-db
+ rabbitmq:
+ host: entdockergss
+ port: 5672
+ username: ${GFI_RABBITMQ_USERNAME}
+ password: ${GFI_RABBITMQ_PASSWORD}
+
+ # Importkanal
+# importExchange: sitImportExchange_localdev_saris_simon
+# importQueue: sitImportQueue_localdev_saris_simon
+# importkey: sitImportExchange.failureImportKey_localdev_simon
+
+ # Importkanal
+ importExchange: sitImportExchange
+ importQueue: sitImportQueue
+ importkey: sitImportExchange.failureImportKey
diff --git a/SAMO-Interface/src/main/resources/logback-spring.xml b/SAMO-Interface/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..e441ee9
--- /dev/null
+++ b/SAMO-Interface/src/main/resources/logback-spring.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+ <property name="LOGS" value="./logs"/>
+
+ <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <Pattern>
+ %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%c{60}): %msg%n%throwable
+ </Pattern>
+ </layout>
+ </appender>
+
+ <appender name="RollingFileStd" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${LOGS}/samoInterface.log</file>
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <Pattern>%d %p %c{60} [%t] %m%n</Pattern>
+ </encoder>
+
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${LOGS}/archived/samoInterface-%d{yyyy-MM-dd}.gz</fileNamePattern>
+ <MaxHistory>30</MaxHistory>
+ <cleanHistoryOnStart>true</cleanHistoryOnStart>
+ </rollingPolicy>
+ </appender>
+
+ <appender name="RollingFileFeign" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${LOGS}/feignclient.log</file>
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <Pattern>%d %p %c{60} [%t] %m%n</Pattern>
+ </encoder>
+
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${LOGS}/archived/feignclient-%d{yyyy-MM-dd}.gz</fileNamePattern>
+ <MaxHistory>30</MaxHistory>
+ <cleanHistoryOnStart>true</cleanHistoryOnStart>
+ </rollingPolicy>
+ </appender>
+
+ <!-- LOG everything at INFO level -->
+ <root level="info">
+ <appender-ref ref="RollingFileStd"/>
+ <appender-ref ref="Console"/>
+ </root>
+
+ <!-- LOG "com.baeldungorg.eclipse.openk.contactbasedata*" at INFO level -->
+ <logger name="org.eclipse.openk.gridfailureinformation.samointerface" level="info" additivity="false">
+ <appender-ref ref="RollingFileStd"/>
+ <appender-ref ref="Console"/>
+ </logger>
+
+ <logger name="org.eclipse.openk.gridfailureinformation.samointerface.api.StoerungsauskunftApi" level="info" additivity="false">
+ <appender-ref ref="RollingFileFeign"/>
+ </logger>
+
+</configuration>
\ No newline at end of file
diff --git a/SAMO-Interface/src/main/resources/messages.properties b/SAMO-Interface/src/main/resources/messages.properties
new file mode 100644
index 0000000..b8b3b11
--- /dev/null
+++ b/SAMO-Interface/src/main/resources/messages.properties
@@ -0,0 +1,5 @@
+#Fehlermeldungen
+could.not.push.message=Das Objekt konnte nicht an RabbitMQ gesendet werden.
+
+
+
diff --git a/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/config/TestConfiguration.java b/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/config/TestConfiguration.java
new file mode 100644
index 0000000..6fe759e
--- /dev/null
+++ b/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/config/TestConfiguration.java
@@ -0,0 +1,82 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.samointerface.config;
+
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.rabbitmq.client.Channel;
+import org.eclipse.openk.gridfailureinformation.samointerface.SarisInterfaceApplication;
+import org.eclipse.openk.gridfailureinformation.samointerface.config.rabbitMq.RabbitMqConfig;
+import org.eclipse.openk.gridfailureinformation.samointerface.mapper.StoerungsauskunftMapperImpl;
+import org.springframework.amqp.rabbit.annotation.EnableRabbit;
+import org.springframework.amqp.rabbit.connection.Connection;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.amqp.rabbit.test.TestRabbitTemplate;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.messaging.MessageChannel;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+
+import java.io.IOException;
+
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.BDDMockito.willReturn;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+
+@EntityScan(basePackageClasses = SarisInterfaceApplication.class)
+@ContextConfiguration( initializers = {ConfigFileApplicationContextInitializer.class})
+@TestPropertySource("spring.config.location=classpath:application.yml")
+@EnableRabbit
+public class TestConfiguration {
+
+ @Bean
+ ObjectMapper objectMapper() { return new ObjectMapper(); }
+
+ @Bean
+ public StoerungsauskunftMapperImpl stoerungsauskunftMapper() {return new StoerungsauskunftMapperImpl();}
+
+ @Bean
+ public MessageChannel failureImportChannel() {return mock(MessageChannel.class);}
+
+ @Bean
+ @Qualifier("rabbitMqConfig")
+ public RabbitMqConfig rabbitMqConfig() {
+ RabbitMqConfig rabbitMqConfigMock = mock(RabbitMqConfig.class);
+ doNothing().when(rabbitMqConfigMock).buildAllQueues();
+ return rabbitMqConfigMock;
+ }
+
+ @Bean
+ public TestRabbitTemplate template() throws IOException {
+ return new TestRabbitTemplate(connectionFactory());
+ }
+
+ @Bean
+ public ConnectionFactory connectionFactory() throws IOException {
+ ConnectionFactory factory = mock(ConnectionFactory.class);
+ Connection connection = mock(Connection.class);
+ Channel channel = mock(Channel.class);
+ willReturn(connection).given(factory).createConnection();
+ willReturn(channel).given(connection).createChannel(anyBoolean());
+ given(channel.isOpen()).willReturn(true);
+ return factory;
+ }
+
+}
diff --git a/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/controller/ImportControllerTest.java b/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/controller/ImportControllerTest.java
new file mode 100644
index 0000000..0328049
--- /dev/null
+++ b/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/controller/ImportControllerTest.java
@@ -0,0 +1,57 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.samointerface.controller;
+
+import org.eclipse.openk.gridfailureinformation.samointerface.SarisInterfaceApplication;
+import org.eclipse.openk.gridfailureinformation.samointerface.api.StoerungsauskunftApi;
+import org.eclipse.openk.gridfailureinformation.samointerface.service.ImportService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.web.servlet.MockMvc;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@SpringBootTest(classes = SarisInterfaceApplication.class)
+@AutoConfigureMockMvc
+@ActiveProfiles("test")
+public class ImportControllerTest {
+
+ @MockBean
+ private StoerungsauskunftApi stoerungsauskunftApi;
+
+ @MockBean
+ private ImportService importService;
+
+ @Autowired
+ private MockMvc mockMvc;
+
+
+// @Test
+// public void shouldCallImport() throws Exception {
+//
+// mockMvc.perform(get("/stoerungsauskunft/usernotification-import-test"))
+// .andExpect(status().is2xxSuccessful());
+//
+// verify(importService, times(1)).importUserNotifications();
+// }
+}
\ No newline at end of file
diff --git a/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/service/ImportServiceTest.java b/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/service/ImportServiceTest.java
new file mode 100644
index 0000000..79c76cc
--- /dev/null
+++ b/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/service/ImportServiceTest.java
@@ -0,0 +1,77 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.samointerface.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.eclipse.openk.gridfailureinformation.samointerface.SarisInterfaceApplication;
+import org.eclipse.openk.gridfailureinformation.samointerface.api.StoerungsauskunftApi;
+import org.eclipse.openk.gridfailureinformation.samointerface.config.TestConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+
+@SpringBootTest(classes = SarisInterfaceApplication.class)
+@ContextConfiguration(classes = {TestConfiguration.class})
+@ActiveProfiles("test")
+public class ImportServiceTest {
+
+ @Autowired
+ private ImportService importService;
+
+ @Autowired
+ ObjectMapper objectMapper;
+
+ @MockBean
+ StoerungsauskunftApi stoerungsauskunftApi;
+
+ /* @Test
+ public void shoulImportUserNotification() throws IOException {
+
+ ImportService importExportServicSpy = spy(importService);
+
+ InputStream is = new ClassPathResource("UsernotificationJsonResponse.json").getInputStream();
+ List<StoerungsauskunftUserNotification> userNotificationList =
+ objectMapper.readValue(is, new TypeReference<List<StoerungsauskunftUserNotification>>() {
+ });
+ when(stoerungsauskunftApi.getUserNotification(any(Integer.class))).thenReturn(userNotificationList);
+
+ importExportServicSpy.importUserNotifications();
+
+ verify(importExportServicSpy, times(userNotificationList.size())).pushForeignFailure(any(ForeignFailureMessageDto.class));
+ }
+
+ @Test
+ public void shoulImportUserNotificationMapperTest1() throws IOException {
+
+ ImportService importExportServicSpy = spy(importService);
+
+ InputStream is = new ClassPathResource("UsernotificationJsonResponse.json").getInputStream();
+ List<StoerungsauskunftUserNotification> userNotificationList =
+ objectMapper.readValue(is, new TypeReference<List<StoerungsauskunftUserNotification>>() {
+ });
+ when(stoerungsauskunftApi.getUserNotification(any(Integer.class))).thenReturn(userNotificationList);
+
+ importExportServicSpy.importUserNotifications();
+
+ verify(importExportServicSpy, times(userNotificationList.size())).pushForeignFailure(any(ForeignFailureMessageDto.class));
+ }*/
+
+
+}
diff --git a/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/util/ResourceLoaderBase.java b/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/util/ResourceLoaderBase.java
new file mode 100644
index 0000000..2cfe7ad
--- /dev/null
+++ b/SAMO-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/samointerface/util/ResourceLoaderBase.java
@@ -0,0 +1,86 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2018 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+*/
+
+package org.eclipse.openk.gridfailureinformation.samointerface.util;
+
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.io.ByteOrderMark;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.BOMInputStream;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+@Log4j2
+public class ResourceLoaderBase {
+
+ private String stream2String(InputStream is, String filename) {
+ StringWriter writer = new StringWriter();
+ BOMInputStream bomInputStream = new BOMInputStream(is, false, ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE,
+ ByteOrderMark.UTF_32BE, ByteOrderMark.UTF_32LE);
+
+ try {
+ IOUtils.copy(bomInputStream, writer, StandardCharsets.UTF_8.name());
+ } catch (IOException e) {
+ log.error("Fehler in stream2String()", e);
+ return "";
+ }
+
+ log.debug("Datei erfolgreich eingelesen: " + filename);
+ return writer.toString();
+ }
+
+ public String loadStringFromResource(String filename) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream inputStream = classLoader.getResourceAsStream(filename);
+ if (inputStream==null){
+ log.error("Datei nicht gefunden: " + filename);
+ return null;
+ }
+ log.debug("Datei existiert: " + filename);
+ try {
+ URL resource = classLoader.getResource(filename);
+ if (resource != null) {
+ URI uri = resource.toURI();
+ log.debug("Uniform Resource Identifier (URI): " + uri);
+ }
+ } catch (URISyntaxException e) {
+ log.error("Fehler in loadStringFromResource: " + filename, e);
+ }
+
+ return stream2String(inputStream, filename);
+ }
+
+ public String loadFromPath(String path) {
+ try {
+ Path paths = Paths.get(path);
+ log.debug("paths: " + path);
+ try (InputStream inputStream = Files.newInputStream(Paths.get(path))) {
+ return stream2String(inputStream, paths.getFileName().toString());
+ }
+ } catch (IOException e) {
+ log.error("Fehler in loadFromPath", e);
+ return null;
+ }
+ }
+}
diff --git a/SAMO-Interface/src/test/resources/SAMO-ImportJsonFile.json b/SAMO-Interface/src/test/resources/SAMO-ImportJsonFile.json
new file mode 100644
index 0000000..c9adfa0
--- /dev/null
+++ b/SAMO-Interface/src/test/resources/SAMO-ImportJsonFile.json
@@ -0,0 +1,8 @@
+{
+ "id": 24,
+ "failureBegin": "2020-08-11T23:45.000Z",
+ "failureEndResupplied": "2020-10-11T23:45.000Z",
+ "voltageLevel": "55237",
+ "pressureLevel": "Bornheim",
+ "description": "Bschreibung Test"
+}
diff --git a/SAMO-Interface/src/test/resources/application.yml b/SAMO-Interface/src/test/resources/application.yml
new file mode 100644
index 0000000..843be83
--- /dev/null
+++ b/SAMO-Interface/src/test/resources/application.yml
@@ -0,0 +1,76 @@
+# *******************************************************************************
+# Copyright (c) 2019 Contributors to the Eclipse Foundation
+#
+# See the NOTICE file(s) distributed with this work for additional
+# information regarding copyright ownership.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0 which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# SPDX-License-Identifier: EPL-2.0
+# *******************************************************************************
+spring:
+ rabbitmq:
+ host: host
+ port: 5672
+ username: userName
+ password: secPwd
+
+ # Importkanal
+ importExchange: sitImportExchange_dev
+ importQueue: sitImportQueue_dev
+ importkey: sitImportExchange.failureImportKey_dev
+
+ # Exportkanal
+ exportExchange: sitExportExchange_dev
+ exportQueue: stoerungsauskunft_export_queue_test_simon
+ exportKey: stoerungsauskunft_export_key_test_simon
+
+
+server:
+ max-http-header-size: 262144
+
+jwt:
+ tokenHeader: Authorization
+ useStaticJwt: false
+ staticJwt: x
+
+gridFailureInformation:
+ maxListSize: 2000
+
+
+feign:
+ client:
+ config:
+ default:
+ connectTimeout: 60000
+ readTimeout: 60000
+cors:
+ corsEnabled: false
+
+stoerungsauskunft:
+ apiUrl: https://stage-api-operator.stoerungsauskunft.de/api/v1.0/
+ user: userName
+ password: secPwd
+ scheduling-import:
+ enabled: false
+ cron: 0 */15 * ? * *
+
+---
+
+spring:
+ profiles: test
+
+jwt:
+ tokenHeader: Authorization
+ useStaticJwt: true
+ staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI5MGI0NGFkOC1iYjlmLTQ1MzktYTQwYy0yYjQyZTNkNjNiOGEiLCJleHAiOjE1Nzg2NTU3OTUsIm5iZiI6MCwiaWF0IjoxNTc4NjU1NDk1LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiODYyNjY5NmYtZjFhMi00ZGI1LTkyZWYtZTlhMjQ2Njg1YTU0IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZWxvZ2Jvb2stYmFja2VuZCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjJmMWIzODE5LWZjNjQtNDEzNC1iNWQxLWY3ZWY4NzU5NDBkNCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsia29uLWFkbWluIiwia29uLXdyaXRlciIsImtvbi1hY2Nlc3MiLCJrb24tcmVhZGVyIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJuYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSBUZXN0ZXJMYXN0bmFtZV9yd2EiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0ZXN0dXNlcl9yd2EiLCJnaXZlbl9uYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSIsImZhbWlseV9uYW1lIjoiVGVzdGVyTGFzdG5hbWVfcndhIn0.DAYXuv4tKn8RXqO1jyttnD-tF4nShUBQyfe4bKbAiPAyY2x5YbAf3M4eXnLrGqo8-loGKldICC28bL0LaMA3KKkQEOfW5sfpGqoN6212vs89mOklt0TJYc5PMXwFgJ5WC_TKjdwq7-aaDafOEWehV0U1ut3s-94ovNYIEn29nzXm2W1ldoXJEq03F880jlysQ5zlRvGF7eXEEpFfI2URyyNQ2UWh0Ssfq-gOAt2pbF1u6prA5RfvUmZ3v1eu21YLGZtgqPqxb1l6odyH3ip15j_HdgnTeo52ymxuRUj65Mskme3V5ev2DitHI9vZgnpV8Idhb4TTWliBeGCOMfDFCg
+
+stoerungsauskunft:
+ apiUrl: https://stage-api-operator.stoerungsauskunft.de/api/v1.0/
+ user: userName
+ password: secPwd
+ scheduling-import:
+ enabled: true
+ cron: 0 */15 * ? * *
\ No newline at end of file
diff --git a/SAMO-Interface/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/SAMO-Interface/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
new file mode 100644
index 0000000..ca6ee9c
--- /dev/null
+++ b/SAMO-Interface/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
@@ -0,0 +1 @@
+mock-maker-inline
\ No newline at end of file
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/GfiGrid.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/GfiGrid.java
index 80acae3..ae4196a7 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/GfiGrid.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/GfiGrid.java
@@ -66,12 +66,14 @@
DecisionTask<GfiProcessSubject> decideUpdated = new DecideFailureInfoUpdated();
ProcessTask storeEditStatusUpdated = new ShortcutTask( UPDATED );
ProcessTask resetPublishedFlagOnChannels = new ResetPublishedFlagOnChannelsTask();
+ ProcessTask rePublishToMailChannelsUpdated = new RePublishFailureToMailChannelsTask(UPDATED);
DecisionTask<GfiProcessSubject> decideHasSubordinatedInfos = new DecideFailureInfoHasSubordinatedInfos();
ProcessTask storeEditStatusOfParentForChildren = new StoreEditStatusOfParentToChildrenTask();
ProcessTask completedEndpoint = register( COMPLETED,
new UIStoreFailureInformationTask( "State COMPETED UI Task", true));
+ ProcessTask rePublishToMailChannelsCompleted = new RePublishFailureToMailChannelsTask(COMPLETED);
ProcessTask setEndDate = new SetEndDateTask();
@@ -95,8 +97,10 @@
decideUpdated.connectOutputTo(PORT1, storeEditStatusUpdated);
decideUpdated.connectOutputTo(PORT2, setEndDate);
decideUpdated.connectOutputTo(PORT3, storeEditStatusCanceled);
- setEndDate.connectOutputTo(decidePublishedOnComplete);
+ setEndDate.connectOutputTo(rePublishToMailChannelsCompleted);
+ rePublishToMailChannelsCompleted.connectOutputTo(decidePublishedOnComplete);
decidePublishedOnComplete.connectOutputTo(YES, storePublicationStatusWithdrawn);
+ //for complete republishTask
decidePublishedOnComplete.connectOutputTo(NO, decideHasSubordinatedInfos);
storePublicationStatusWithdrawn.connectOutputTo(decideHasSubordinatedInfos);
decideHasSubordinatedInfos.connectOutputTo(NO, completedEndpoint);
@@ -112,7 +116,9 @@
storePublicationStatusPublished.connectOutputTo(updateMessage);
storeEditStatusUpdated.connectOutputTo(resetPublishedFlagOnChannels);
- resetPublishedFlagOnChannels.connectOutputTo(qualifyMessage);
+ resetPublishedFlagOnChannels.connectOutputTo(rePublishToMailChannelsUpdated);
+ //for updated republishTask
+ rePublishToMailChannelsUpdated.connectOutputTo(qualifyMessage);
}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/ProcessHelper.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/ProcessHelper.java
index 4c74443..588a4d0 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/ProcessHelper.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/ProcessHelper.java
@@ -5,6 +5,7 @@
import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessState;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessEnvironment;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessState;
+import org.eclipse.openk.gridfailureinformation.constants.Constants;
import org.eclipse.openk.gridfailureinformation.exceptions.InternalServerErrorException;
import org.eclipse.openk.gridfailureinformation.exceptions.NotFoundException;
import org.eclipse.openk.gridfailureinformation.model.RefFailureClassification;
@@ -17,6 +18,7 @@
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@@ -64,14 +66,20 @@
return environment.getFailureInformationService().storeFailureInfo(dto, GfiProcessState.NEW);
}
- public void publishFailureInformation( FailureInformationDto dto ) {
+ public void publishFailureInformation(FailureInformationDto dto, boolean onlyMail, GfiProcessState processState) {
TblFailureInformation tblFailureInfo = environment.getFailureInformationRepository().findByUuid(dto.getUuid()).orElseThrow(()-> new NotFoundException(""));
List<TblFailureInformationPublicationChannel> channelList = environment.getChannelRepository().findByTblFailureInformation(tblFailureInfo);
+ List<String> finalChannelList = new ArrayList<>();
- String[] channels = new String[channelList.size()];
- environment.getExportService().exportFailureInformation(dto.getUuid(),
- channelList.stream().map(TblFailureInformationPublicationChannel::getPublicationChannel).collect(Collectors.toList()).toArray(channels));
+ if (onlyMail){
+ //finalChannelList = channelList.stream().map(TblFailureInformationPublicationChannel::getPublicationChannel).filter(c -> c.equals(Constants.PUBLICATION_CHANNEL_MAIL)).collect(Collectors.toList());
+ finalChannelList.add(Constants.PUBLICATION_CHANNEL_MAIL);
+ } else {
+ finalChannelList = channelList.stream().map(TblFailureInformationPublicationChannel::getPublicationChannel).collect(Collectors.toList());
+ }
+
+ environment.getExportService().exportFailureInformation(dto.getUuid(), finalChannelList.toArray(new String[0]), processState);
}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/PublishFailureToChannelsTask.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/PublishFailureToChannelsTask.java
index a3185e8..d24d3a3 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/PublishFailureToChannelsTask.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/PublishFailureToChannelsTask.java
@@ -28,7 +28,7 @@
@Override
protected void onLeaveStep(GfiProcessSubject subject) {
- subject.getProcessHelper().publishFailureInformation( subject.getFailureInformationDto() );
+ subject.getProcessHelper().publishFailureInformation( subject.getFailureInformationDto(), false, null );
log.debug("PublishFailureToChannelsTask onLeaveStep");
}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/RePublishFailureToMailChannelsTask.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/RePublishFailureToMailChannelsTask.java
new file mode 100644
index 0000000..600424f
--- /dev/null
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/RePublishFailureToMailChannelsTask.java
@@ -0,0 +1,39 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2018 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+*/
+
+package org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks;
+
+import lombok.extern.log4j.Log4j2;
+import org.eclipse.openk.gridfailureinformation.bpmn.base.tasks.ServiceTask;
+import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessState;
+import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessSubject;
+
+@Log4j2
+public class RePublishFailureToMailChannelsTask extends ServiceTask<GfiProcessSubject> {
+
+ private GfiProcessState processState;
+
+ public RePublishFailureToMailChannelsTask(GfiProcessState processState) {
+ super("Meldung an Kanäle veröffentlichen");
+ this.processState = processState;
+ }
+
+ @Override
+ protected void onLeaveStep(GfiProcessSubject subject) {
+ subject.getProcessHelper().publishFailureInformation( subject.getFailureInformationDto(), true , processState );
+
+ log.debug("PublishFailureToChannelsTask onLeaveStep");
+ }
+}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/constants/Constants.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/constants/Constants.java
index 1d9872b..400a2bb 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/constants/Constants.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/constants/Constants.java
@@ -42,6 +42,8 @@
public static final String S = "S";
public static final String CHANNEL_NOT_EXISTING = "channel.not.existing";
+ public static final String PUBLICATION_CHANNEL_MAIL = "Mail";
+
private Constants() {
// empty Constructor for the sake of SONAR
}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/ExportController.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/ExportController.java
index a892078..6a02b9b 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/ExportController.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/ExportController.java
@@ -31,7 +31,7 @@
})
public ResponseEntity exportFailureInformation (@PathVariable UUID failureInfoUuid, @RequestBody String[] channels) {
- exportService.exportFailureInformation(failureInfoUuid, channels);
+ exportService.exportFailureInformation(failureInfoUuid, channels, null);
return ResponseEntity.ok().build();
}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/TblDistributionGroup.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/TblDistributionGroup.java
index d00dd60..b94a859 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/TblDistributionGroup.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/TblDistributionGroup.java
@@ -25,11 +25,20 @@
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tbl_distribution_group_id_seq")
@SequenceGenerator(name = "tbl_distribution_group_id_seq", sequenceName = "tbl_distribution_group_id_seq", allocationSize = 1)
+
@Column(name = "id", updatable = false)
private Long id;
private UUID uuid;
private String name;
- private String distributionText;
- private String emailSubject;
+
+ private String emailSubjectPublish;
+ private String distributionTextPublish;
+
+ private String emailSubjectUpdate;
+ private String distributionTextUpdate;
+
+ private String emailSubjectComplete;
+ private String distributionTextComplete;
+
}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionGroupService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionGroupService.java
index 3089e0f..b215289 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionGroupService.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionGroupService.java
@@ -83,8 +83,6 @@
.orElseThrow(() -> new NotFoundException("distribution.group.uuid.not.existing"));
TblDistributionGroup groupToSave = distributionGroupMapper.toTblDistributionGroup(distributionGroupDto);
- groupToSave.setName(distributionGroupDto.getName());
- groupToSave.setDistributionText(distributionGroupDto.getDistributionText());
groupToSave.setId(group.getId());
TblDistributionGroup savedGroup = distributionGroupRepository.save(groupToSave);
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java
index 6eb80a2..935734a 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.log4j.Log4j2;
import org.eclipse.openk.gridfailureinformation.api.SitCacheApi;
+import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessState;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks.ProcessHelper;
import org.eclipse.openk.gridfailureinformation.config.ResourceConfig;
import org.eclipse.openk.gridfailureinformation.config.rabbitMq.RabbitMqChannel;
@@ -91,7 +92,7 @@
@Value("${distribution-group-publisher.name}")
private String publisherDistributionGroup;
- public boolean exportFailureInformation(UUID uuid, String[] targetChannels){
+ public boolean exportFailureInformation(UUID uuid, String[] targetChannels, GfiProcessState processState){
log.info("Start exporting failureInformation with uuid: " + uuid);
countExportedMessages = 0;
for(String targetChannel: targetChannels){
@@ -108,7 +109,8 @@
TblFailureInformation existingTblFailureInfo = failureInformationRepository.findByUuid( uuid )
.orElseThrow(NotFoundException::new);
- if( !isChannelAlreadyPublished( targetChannel, existingTblFailureInfo)) {
+ //Wenn State mitgeliefert wird dann sende mail (zb. bei Update oder Complete State)
+ if( !isChannelAlreadyPublished( targetChannel, existingTblFailureInfo) || processState != null) {
//Nullsafe check
if (Boolean.TRUE.equals(rChannel.getIsMailType())) {
@@ -122,7 +124,7 @@
return false;
}
- distributionGroups.forEach( x -> prepareMessage(existingTblFailureInfo, x, rChannel));
+ distributionGroups.forEach( x -> prepareMessage(existingTblFailureInfo, x, rChannel, processState));
}
else {
@@ -134,8 +136,12 @@
sendMessageToRabbitMq(rabbitMqMessageDto, rChannel);
}
- // mark channel as published
- markChannelAsPublished(targetChannel, existingTblFailureInfo);
+ // State wird nur beim RePublishFailureToMailChannelsTask für Update und Complete mitgegeben,
+ // hier nicht zurücksetzen (dies passiert immer noch beim resetPublishedFlagOnChannels Task)
+ if (processState == null) {
+ markChannelAsPublished(targetChannel, existingTblFailureInfo);
+ }
+
}
}
@@ -146,7 +152,7 @@
public boolean exportFailureInformationReminderMail(UUID uuid){
- String targetChannel = "Mail";
+ String targetChannel = Constants.PUBLICATION_CHANNEL_MAIL;
RabbitMqChannel rChannel = getAvailableRabbitMqChannel(targetChannel);
if(getAvailableRabbitMqChannel(targetChannel) == null){
@@ -168,7 +174,7 @@
TblDistributionGroup distributionGroup = distributionGroupOptional.get();
- prepareMessage(existingTblFailureInfo, distributionGroup, rChannel);
+ prepareMessage(existingTblFailureInfo, distributionGroup, rChannel, null);
return true;
}
@@ -264,7 +270,7 @@
}
- private void prepareMessage(TblFailureInformation existingTblFailureInfo, TblDistributionGroup distributionGroup, RabbitMqChannel rabbitMqChannel){
+ private void prepareMessage(TblFailureInformation existingTblFailureInfo, TblDistributionGroup distributionGroup, RabbitMqChannel rabbitMqChannel, GfiProcessState processState){
List<String> mailAddresses= new ArrayList<>();
@@ -288,20 +294,34 @@
return;
}
rabbitMqMessageDto.setMailAddresses(mailAddresses);
-
-
- //Holen des zum Verteiler zugehörigen Textes
- //Ersatz der gekennzeichneten Stellen im Text mit vorhandenen Infos und Eintrag ins MessageDto
- String distributionText = distributionGroup.getDistributionText();
- String preparedBody = replacePlaceholders(distributionText, existingTblFailureInfo);
- String emailSubject = replacePlaceholders(distributionGroup.getEmailSubject(), existingTblFailureInfo);
- rabbitMqMessageDto.setBody(preparedBody);
- rabbitMqMessageDto.setEmailSubject(emailSubject);
+ setMailTextAndSubject(existingTblFailureInfo, distributionGroup, processState, rabbitMqMessageDto);
sendMessageToRabbitMq(rabbitMqMessageDto, rabbitMqChannel);
}
+ private void setMailTextAndSubject(TblFailureInformation existingTblFailureInfo,
+ TblDistributionGroup distributionGroup, GfiProcessState processState,
+ RabbitMqMessageDto rabbitMqMessageDto) {
+ //Holen des zum Verteiler zugehörigen Textes
+ //Ersatz der gekennzeichneten Stellen im Text mit vorhandenen Infos und Eintrag ins MessageDto
+ String distributionText = distributionGroup.getDistributionTextPublish();
+ String emailSubject = distributionGroup.getEmailSubjectPublish();
+
+ if (processState == GfiProcessState.COMPLETED) {
+ distributionText = distributionGroup.getDistributionTextComplete();
+ emailSubject = distributionGroup.getEmailSubjectComplete();
+ } else if (processState == GfiProcessState.UPDATED) {
+ distributionText = distributionGroup.getDistributionTextUpdate();
+ emailSubject = distributionGroup.getEmailSubjectUpdate();
+ }
+
+ String finalDistributionText = replacePlaceholders(distributionText, existingTblFailureInfo);
+ String finalEmailSubject = replacePlaceholders(emailSubject, existingTblFailureInfo);
+ rabbitMqMessageDto.setBody(finalDistributionText);
+ rabbitMqMessageDto.setEmailSubject(finalEmailSubject);
+ }
+
private void sendMessageToRabbitMq(RabbitMqMessageDto rabbitMqMessageDto, RabbitMqChannel rabbitMqChannel){
try{
rabbitTemplate.convertAndSend(rabbitMqProperties.getExportExchange(), rabbitMqChannel.getExportKey(), objectMapper.writeValueAsString(rabbitMqMessageDto));
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/DistributionGroupDto.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/DistributionGroupDto.java
index e2d1217..f19d8a3 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/DistributionGroupDto.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/DistributionGroupDto.java
@@ -26,8 +26,15 @@
@JsonProperty("id")
private UUID uuid;
private String name;
- private String distributionText;
- private String emailSubject;
+
+ private String emailSubjectPublish;
+ private String distributionTextPublish;
+
+ private String emailSubjectUpdate;
+ private String distributionTextUpdate;
+
+ private String emailSubjectComplete;
+ private String distributionTextComplete;
}
diff --git a/gfsBackendService/src/main/resources/db/migration/V0_XX__automatischer_Meldungsversand.sql b/gfsBackendService/src/main/resources/db/migration/V0_XX__automatischer_Meldungsversand.sql
new file mode 100644
index 0000000..1918cff
--- /dev/null
+++ b/gfsBackendService/src/main/resources/db/migration/V0_XX__automatischer_Meldungsversand.sql
@@ -0,0 +1,22 @@
+-----------------------------------------------------------------------------------
+-- *******************************************************************************
+-- * Copyright (c) 2019 Contributors to the Eclipse Foundation
+-- *
+-- * See the NOTICE file(s) distributed with this work for additional
+-- * information regarding copyright ownership.
+-- *
+-- * This program and the accompanying materials are made available under the
+-- * terms of the Eclipse Public License v. 2.0 which is available at
+-- * http://www.eclipse.org/legal/epl-2.0.
+-- *
+-- * SPDX-License-Identifier: EPL-2.0
+-- *******************************************************************************
+-----------------------------------------------------------------------------------
+ALTER TABLE public.TBL_DISTRIBUTION_GROUP RENAME DISTRIBUTION_TEXT TO DISTRIBUTION_TEXT_PUBLISH;
+ALTER TABLE public.TBL_DISTRIBUTION_GROUP RENAME EMAIL_SUBJECT TO EMAIL_SUBJECT_PUBLISH;
+
+ALTER TABLE public.TBL_DISTRIBUTION_GROUP ADD COLUMN EMAIL_SUBJECT_COMPLETE varchar(255);
+ALTER TABLE public.TBL_DISTRIBUTION_GROUP ADD COLUMN DISTRIBUTION_TEXT_COMPLETE varchar(2048);
+
+ALTER TABLE public.TBL_DISTRIBUTION_GROUP ADD COLUMN EMAIL_SUBJECT_UPDATE varchar(255);
+ALTER TABLE public.TBL_DISTRIBUTION_GROUP ADD COLUMN DISTRIBUTION_TEXT_UPDATE varchar(2048);
\ No newline at end of file
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/DistributionGroupControllerTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/DistributionGroupControllerTest.java
index dab7589..90d6855 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/DistributionGroupControllerTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/DistributionGroupControllerTest.java
@@ -89,7 +89,7 @@
.contentType(MediaType.APPLICATION_JSON)
.content(new ObjectMapper().writeValueAsString(groupDto)))
.andExpect(jsonPath("$.name", is(groupDto.getName())))
- .andExpect(jsonPath("$.distributionText", is(groupDto.getDistributionText())))
+ .andExpect(jsonPath("$.distributionTextPublish", is(groupDto.getDistributionTextPublish())))
.andExpect(status().is2xxSuccessful());
}
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/ExportControllerTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/ExportControllerTest.java
index 99d5b48..2ee5479 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/ExportControllerTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/ExportControllerTest.java
@@ -16,11 +16,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.openk.gridfailureinformation.GridFailureInformationApplication;
-import org.eclipse.openk.gridfailureinformation.service.AddressService;
+import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessState;
import org.eclipse.openk.gridfailureinformation.service.ExportService;
import org.eclipse.openk.gridfailureinformation.support.MockDataHelper;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
-import org.eclipse.openk.gridfailureinformation.viewmodel.HousenumberUuidDto;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
@@ -30,14 +29,11 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
-import java.util.List;
-import java.util.Optional;
import java.util.UUID;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest(classes = GridFailureInformationApplication.class)
@@ -58,7 +54,7 @@
FailureInformationDto failureInfoDto = MockDataHelper.mockFailureInformationDto();
String[] channels = {"[\"TEST\"]"};
- when( exportService.exportFailureInformation(any(UUID.class), any(String[].class))).thenReturn(true);
+ when( exportService.exportFailureInformation(any(UUID.class), any(String[].class), any(GfiProcessState.class))).thenReturn(true);
mockMvc.perform(put("/export/{failureInfoUuid}", failureInfoDto.getUuid().toString())
.contentType(MediaType.APPLICATION_JSON)
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ExportServiceTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ExportServiceTest.java
index 3044024..bbd6986 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ExportServiceTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ExportServiceTest.java
@@ -117,7 +117,7 @@
String[] channels = {"Mail"};
- boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels);
+ boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels, null);
Mockito.verify(rabbitTemplate, times(0)).convertAndSend(any(), any(), any(Object.class));
assertFalse(isMailPushed);
@@ -150,7 +150,7 @@
String[] channels = {"Mail"};
- boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels);
+ boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels, null);
Mockito.verify(rabbitTemplate, times(0)).convertAndSend(any(), any(), any(Object.class));
assertFalse(isMailPushed);
@@ -179,7 +179,7 @@
String[] channels = {"Mail"};
- boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels);
+ boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels, null);
Mockito.verify(rabbitTemplate, times(2)).convertAndSend(any(), any(), any(Object.class));
assertTrue(isMailPushed);
@@ -216,7 +216,7 @@
String[] channels = {"Mail"};
- boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels);
+ boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels, null);
Mockito.verify(rabbitTemplate, times(2)).convertAndSend(any(), any(), any(Object.class));
assertTrue(isMailPushed);
@@ -264,7 +264,7 @@
String[] channels = {"Mail"};
- boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels);
+ boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels, null);
Mockito.verify(rabbitTemplate, times(2)).convertAndSend(any(), any(), any(Object.class));
assertTrue(isMailPushed);
@@ -294,7 +294,7 @@
String[] channels = {"Störungsauskunft.de"};
- boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels);
+ boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels, null);
Mockito.verify(rabbitTemplate, times(1)).convertAndSend(any(), any(), any(Object.class));
assertTrue(isMailPushed);
@@ -320,7 +320,7 @@
String[] channels = {"Mail"};
- boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels);
+ boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels, null);
assertFalse(isMailPushed);
@@ -344,7 +344,7 @@
String[] channels = {"Mail"};
- boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels);
+ boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels, null);
assertFalse(isMailPushed);
@@ -367,7 +367,7 @@
String[] channels = {"TEST", "TEST2"};
- boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels);
+ boolean isMailPushed = exportServiceLocal.exportFailureInformation(UUID.randomUUID(), channels, null);
assertFalse(isMailPushed);
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java
index 6163397..bfb7bd4 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java
@@ -1207,8 +1207,8 @@
tblDistributionGroup.setId(1L);
tblDistributionGroup.setUuid(UUID.randomUUID());
tblDistributionGroup.setName("Testverteiler - Abteilung intern");
- tblDistributionGroup.setDistributionText("Liebe Kollegen blabla ...");
- tblDistributionGroup.setEmailSubject("Betreff Test");
+ tblDistributionGroup.setDistributionTextPublish("Liebe Kollegen blabla ...");
+ tblDistributionGroup.setEmailSubjectPublish("Betreff Test");
return tblDistributionGroup;
}
@@ -1219,7 +1219,7 @@
tblDistributionGroup.setId(2L);
tblDistributionGroup.setUuid(UUID.randomUUID());
tblDistributionGroup.setName("Testverteiler - Gruppe intern");
- tblDistributionGroup.setDistributionText("Liebste Kollegen blabla ...");
+ tblDistributionGroup.setDistributionTextPublish("Liebste Kollegen blabla ...");
return tblDistributionGroup;
}
@@ -1238,8 +1238,8 @@
DistributionGroupDto distributionGroupDto = new DistributionGroupDto();
distributionGroupDto.setUuid(UUID.randomUUID());
distributionGroupDto.setName("Testverteiler - Abteilung intern");
- distributionGroupDto.setDistributionText("Liebe Kollegen blabla ...");
- distributionGroupDto.setEmailSubject("TestBetreff");
+ distributionGroupDto.setDistributionTextPublish("Liebe Kollegen blabla ...");
+ distributionGroupDto.setEmailSubjectPublish("TestBetreff");
return distributionGroupDto;
}
@@ -1249,7 +1249,7 @@
DistributionGroupDto distributionGroupDto = new DistributionGroupDto();
distributionGroupDto.setUuid(UUID.randomUUID());
distributionGroupDto.setName("Testverteiler - Kunden extern");
- distributionGroupDto.setDistributionText("Sehr geehrte Damen und Herren blabla ...");
+ distributionGroupDto.setDistributionTextPublish("Sehr geehrte Damen und Herren blabla ...");
return distributionGroupDto;
}