Commit c16bd5fd authored by dietricf's avatar dietricf
Browse files

Merge branch 'DEVELOP' of...

Merge branch 'DEVELOP' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.backend into MIGRATE_TO_ORACLE
parents 34b24774 5a3f7257
......@@ -30,6 +30,14 @@ import java.util.Date;
@Data
public class ForeignFailureDataDto implements Serializable {
private boolean isAutopublish;
private boolean isOnceOnlyImport;
private boolean isExcludeEquals;
private boolean isExcludeAlreadyEdited;
@NotNull
private boolean isPlanned;
......
......@@ -24,6 +24,7 @@ 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.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.messaging.MessageChannel;
......@@ -45,6 +46,15 @@ public class ImportService {
@Autowired
SAMOMapper samoMapper;
@Value("${gridFailureInformation.autopublish:false}")
private boolean autopublish;
@Value("${gridFailureInformation.onceOnlyImport:false}")
private boolean onceOnlyImport;
@Value("${gridFailureInformation.excludeEquals:true}")
private boolean excludeEquals;
@Value("${gridFailureInformation.excludeAlreadyEdited:true}")
private boolean excludeAlreadyEdited;
public void importSAMOOutage(String samoOutageJson) {
try {
SAMOOutage samoOutage = objectMapper.readValue(samoOutageJson, SAMOOutage.class);
......@@ -69,6 +79,10 @@ public class ImportService {
private ForeignFailureDataDto createForeignFailureData(SAMOOutage samoOutage) {
ForeignFailureDataDto foreignFailureDataDto = samoMapper.toForeignFailureDataDto(samoOutage);
foreignFailureDataDto.setAutopublish(autopublish);
foreignFailureDataDto.setOnceOnlyImport(onceOnlyImport);
foreignFailureDataDto.setExcludeEquals(excludeEquals);
foreignFailureDataDto.setExcludeAlreadyEdited(excludeAlreadyEdited);
foreignFailureDataDto.setBranch(Constants.BRANCH_ELECTRICITY); //fixme klärung: logik einbauen
foreignFailureDataDto.setPlanned(false); //fixme klärung
return foreignFailureDataDto;
......
......@@ -29,12 +29,15 @@ logging:
org.springframework.web: ERROR
server:
port: 9198
max-http-header-size: 262144
sftp:
enable-polling: true
host: 169.50.13.154
#privateKey: classpath:/keys/privateOpenKQServer_key-SAMO-Interface
#privateKey: file:C:\keys\privateOpenKQServer_key-SAMO-Interface
privateKey:
privateKeyPassphrase:
user: ${GFI_SAMO_SFTP_USERNAME}
......@@ -43,6 +46,12 @@ sftp:
directory: /opt/transfer/SAMOInterfaceDEVsftpTest/
fileFilter: '*.json'
cron: 0/10 * * ? * * # Check for new file in directory every 'cron' time
gridFailureInformation:
autopublish: false
onceOnlyImport: false
excludeEquals: true
excludeAlreadyEdited: false
---
spring:
......@@ -100,9 +109,6 @@ server:
session:
tracking-modes: cookie
swagger:
baseUrl: /test-stoerungsauskunft-interface
sftp:
enable-polling: false
host: 169.50.13.154
......
......@@ -36,7 +36,10 @@ server:
tracking-modes: cookie
gridFailureInformation:
maxListSize: 2000
autopublish: false
onceOnlyImport: false
excludeEquals: true
excludeAlreadyEdited: true
logging.level.org.eclipse.openk.gridfailureinformation.jobs.stoerauskunftinterface.api.StoerauskunftApi: DEBUG
......
......@@ -55,6 +55,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
......@@ -113,6 +117,15 @@
<version>4.2.1.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.ws/spring-ws-test -->
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-test</artifactId>
<version>3.0.10.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
......@@ -147,6 +160,12 @@
<artifactId>spring-cloud-stream-test-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>5.3.2.RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
......@@ -214,8 +233,6 @@
<generatePackage>org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl</generatePackage>
<schemaIncludes>
<include>*.wsdl</include>
<!-- <include>countries.wsdl</include> -->
<!-- <include>Stoerungenservice.wsdl</include> -->
</schemaIncludes>
<catalog>${project.basedir}/src/main/resources/catalog.cat</catalog>
</configuration>
......@@ -226,6 +243,39 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>ftp</id>
<phase>install</phase>
<configuration>
<tasks>
<scp todir="fdietrich@169.50.13.154:/opt/mics/sarisInterface/"
sftp="true" port="22" trust="true"
keyfile="${user.home}/.ssh/privateOpenKQServer.ppk"
failonerror="false" verbose="true" passphrase="">
<fileset dir="${project.build.directory}">
<include name="*.jar" />
</fileset>
</scp>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
......
<GetAktuelleGVUsInfoAllgemeinResponse xmlns="http://tempuri.org/">
<GetAktuelleGVUsInfoAllgemeinResult>
<ViewGeplanteVU>
<VersorgungsunterbrechungID>95674</VersorgungsunterbrechungID>
<Beginn>2020-02-11T09:00:00</Beginn>
<Ende>2020-02-11T11:00:00</Ende>
<AnzahlKunden>0</AnzahlKunden>
<Ort>Jesteburg</Ort>
<Ortsteil>Jesteburg </Ortsteil>
<Strasse>Kleckerwaldweg</Strasse>
<Hausnummern>56-58</Hausnummern>
<Bemerkung>ON Umschwenken in neue Trafostation
Kabelarbeiten</Bemerkung>
<Realisiert>false</Realisiert>
<StrassenAbschnittID>335587</StrassenAbschnittID>
<LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
<Stoerung>286047</Stoerung>
<Plz>21266</Plz>
<SparteID>2899</SparteID>
<Sparte>GVU Strom</Sparte>
</ViewGeplanteVU>
<ViewGeplanteVU>
<VersorgungsunterbrechungID>95709</VersorgungsunterbrechungID>
<Beginn>2020-02-11T09:00:00</Beginn>
<Ende>2020-02-11T11:30:00</Ende>
<AnzahlKunden>0</AnzahlKunden>
<Ort>Hollern-Twielenfleth</Ort>
<Strasse>Feriendorf Altes Land</Strasse>
<Hausnummern>75,77</Hausnummern>
<Bemerkung>Wasserschaden bei Hs.Nr.77
HAK von der Wand nehmen damit die Wand erneuert werden kann.</Bemerkung>
<Realisiert>false</Realisiert>
<StrassenAbschnittID>333815</StrassenAbschnittID>
<LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
<Stoerung>286453</Stoerung>
<Plz>21723</Plz>
<SparteID>2899</SparteID>
<Sparte>GVU Strom</Sparte>
</ViewGeplanteVU>
<ViewGeplanteVU>
<VersorgungsunterbrechungID>95733</VersorgungsunterbrechungID>
<Beginn>2020-02-11T10:30:00</Beginn>
<Ende>2020-02-11T15:00:00</Ende>
<AnzahlKunden>0</AnzahlKunden>
<Ort>Bülkau</Ort>
<Ortsteil>Bülkau </Ortsteil>
<Strasse>Süderende</Strasse>
<Hausnummern>29-48</Hausnummern>
<Bemerkung>Kabelstörung bei Hs. Nr.33</Bemerkung>
<Realisiert>false</Realisiert>
<StrassenAbschnittID>312795</StrassenAbschnittID>
<LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
<Stoerung>286625</Stoerung>
<Plz>21782</Plz>
<SparteID>2899</SparteID>
<Sparte>GVU Strom</Sparte>
</ViewGeplanteVU>
<ViewGeplanteVU>
<VersorgungsunterbrechungID>95687</VersorgungsunterbrechungID>
<Beginn>2020-02-11T12:00:00</Beginn>
<Ende>2020-02-11T15:00:00</Ende>
<AnzahlKunden>0</AnzahlKunden>
<Ort>Schwanewede</Ort>
<Ortsteil>Schwanewede </Ortsteil>
<Strasse>Lindenstr.</Strasse>
<Hausnummern>23-29</Hausnummern>
<Bemerkung>Austausch eines defekten Kabelverteilers (Beschädigung). </Bemerkung>
<Realisiert>false</Realisiert>
<StrassenAbschnittID>362161</StrassenAbschnittID>
<LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
<Stoerung>286118</Stoerung>
<Plz>28790</Plz>
<SparteID>2899</SparteID>
<Sparte>GVU Strom</Sparte>
</ViewGeplanteVU>
<ViewGeplanteVU>
<VersorgungsunterbrechungID>95647</VersorgungsunterbrechungID>
<Beginn>2020-02-11T13:00:00</Beginn>
<Ende>2020-02-11T14:30:00</Ende>
<AnzahlKunden>0</AnzahlKunden>
<Ort>Dörpen</Ort>
<Ortsteil>Neudörpen </Ortsteil>
<Strasse>Neudörpen</Strasse>
<Hausnummern>14a; 15; 16; 17; 31; 34</Hausnummern>
<Bemerkung>KVS Wechsel bei Hs.Nr.: Neudörpen 15</Bemerkung>
<Realisiert>false</Realisiert>
<StrassenAbschnittID>317353</StrassenAbschnittID>
<LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
<Stoerung>285933</Stoerung>
<Plz>26892</Plz>
<SparteID>2899</SparteID>
<Sparte>GVU Strom</Sparte>
</ViewGeplanteVU>
<ViewGeplanteVU>
<VersorgungsunterbrechungID>95661</VersorgungsunterbrechungID>
<Beginn>2020-02-12T09:00:00</Beginn>
<Ende>2020-02-12T11:00:00</Ende>
<AnzahlKunden>0</AnzahlKunden>
<Ort>Lathen</Ort>
<Ortsteil>Lathen </Ortsteil>
<Strasse>Zur Düne</Strasse>
<Hausnummern>10+15</Hausnummern>
<Bemerkung>KVS tausch</Bemerkung>
<Realisiert>false</Realisiert>
<StrassenAbschnittID>339961</StrassenAbschnittID>
<LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
<Stoerung>285988</Stoerung>
<Plz>49762</Plz>
<SparteID>2899</SparteID>
<Sparte>GVU Strom</Sparte>
</ViewGeplanteVU>
<ViewGeplanteVU>
<VersorgungsunterbrechungID>95743</VersorgungsunterbrechungID>
<Beginn>2020-02-12T10:00:00</Beginn>
<Ende>2020-02-12T12:00:00</Ende>
<AnzahlKunden>0</AnzahlKunden>
<Ort>Grasberg</Ort>
<Ortsteil>Meinershausen </Ortsteil>
<Strasse>Meinershauser Str.</Strasse>
<Hausnummern>150-174</Hausnummern>
<Bemerkung/>
<Realisiert>false</Realisiert>
<StrassenAbschnittID>327076</StrassenAbschnittID>
<LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
<Stoerung>286676</Stoerung>
<Plz>28879</Plz>
<SparteID>2899</SparteID>
<Sparte>GVU Strom</Sparte>
</ViewGeplanteVU>
</GetAktuelleGVUsInfoAllgemeinResult>
</GetAktuelleGVUsInfoAllgemeinResponse>
# must be unique in a given SonarQube instance
sonar.projectKey=openk.pta.de:stoerungsauskunftinterface
sonar.projectKey=openk.pta.de:sarisinterface
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=grid-failure-information.stoerungsauskunftinterface
sonar.projectName=grid-failure-information.sarisinterface
sonar.projectVersion=0.0.1_Snapshot
sonar.java.binaries=target/classes
......@@ -10,10 +10,10 @@ sonar.language=
sonar.sourceEncoding=UTF-8
sonar.sources=src/main
sonar.exclusions=**/model/*.java,**/viewmodel/*.java,**/dtos/*.java, **/RabbitMqConfig.java
sonar.exclusions=**/model/*.java,**/viewmodel/*.java,**/dtos/*.java, **/RabbitMqConfig.java, **/WebServiceMessageSenderWithAuth.java
sonar.tests=src/test
#sonar.test.inclusions=**/*.spec.ts
sonar.test.exclusions=**/model/**,**/viewmodel/**,**/dtos/*.java, **/RabbitMqConfig.java
sonar.test.exclusions=**/model/**,**/viewmodel/**,**/dtos/*.java, **/RabbitMqConfig.java, **/WebServiceMessageSenderWithAuth.java
#sonar.ts.tslintconfigpath=tslint.json
sonar.typescript.lcov.reportPaths=coverage/lcov.info
\ No newline at end of file
/*
*******************************************************************************
* 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.sarisinterface.api;
import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.StoerungsauskunftOutage;
import org.eclipse.openk.gridfailureinformation.sarisinterface.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);
}
package org.eclipse.openk.gridfailureinformation.sarisinterface.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);
}
}
package org.eclipse.openk.gridfailureinformation.sarisinterface.config;
import lombok.extern.log4j.Log4j2;
import org.eclipse.openk.gridfailureinformation.sarisinterface.constants.Constants;
import org.eclipse.openk.gridfailureinformation.sarisinterface.service.ImportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -13,26 +14,28 @@ import org.springframework.scheduling.annotation.Scheduled;
@Log4j2
@Configuration
@EnableScheduling
@ConditionalOnProperty(prefix = "stoerungsauskunft.scheduling-import", name = "enabled", havingValue = "true", matchIfMissing = false)
@ConditionalOnProperty(prefix = "saris.scheduling-import", name = "enabled", havingValue = "true", matchIfMissing = false)
public class ImportSchedulerConfig {
private static final String SCHEDULER_NAME = "Stoerauskunftimport-Scheduler";
private static final String SCHEDULER_NAME = "SARIS-Import-Scheduler";
@Autowired
ImportService importService;
@Value("${stoerungsauskunft.scheduling-import.cron}")
@Value("${saris.scheduling-import.cron}")
private String cronExpression;
@Bean
public void logConfigLdap() {
public void logConfigScheduler() {
log.info(SCHEDULER_NAME + " is enabled with cron expression: " + cronExpression);
}
@Scheduled(cron = "${stoerungsauskunft.scheduling-import.cron}")
public void scheduleTaskImportUserNotifications() {
log.info("Executing" + SCHEDULER_NAME + " task: Importing available usernotifications from stoerungsauskunft.de");
importService.importUserNotifications();
log.info("Finished " + SCHEDULER_NAME + " task: Importing available usernotifications from stoerungsauskunft.de");
@Scheduled(cron = "${saris.scheduling-import.cron}")
public void scheduleTaskImportMessages() {
log.info("Executing" + SCHEDULER_NAME + " task: Importing available messages from SARIS");
importService.importForeignFailures(Constants.SARIS_ELECTRICITY_BRANCH_ID);
importService.importForeignFailures(Constants.SARIS_WATER_BRANCH_ID);
importService.importForeignFailures(Constants.SARIS_GAS_BRANCH_ID);
log.info("Finished " + SCHEDULER_NAME + " task: Importing available messages from SARIS");
}
}
......@@ -12,38 +12,57 @@
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.samointerface.config;
import lombok.extern.log4j.Log4j2;
package org.eclipse.openk.gridfailureinformation.sarisinterface.config;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import javax.servlet.ServletContext;
@Log4j2
@Configuration
@EnableSwagger2
@Profile({"!test","!prod"})
public class SwaggerConfig {
@EnableWebSecurity
@EnableGlobalMethodSecurity(
prePostEnabled = true,
securedEnabled = true,
jsr250Enabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Value("${security.endpoint.user}")
private String user;
@Value("${security.endpoint.password}")
private String password;
@Value("${swagger.baseUrl:}")
public String baseUrl;
@Value("${swagger.proxyUrl:}")
public String proxyUrl;
@Override
protected void configure(HttpSecurity http ) throws Exception {
http
.csrf().disable()
.authorizeRequests().anyRequest().authenticated()
.and()
.httpBasic();
}
@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);
public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth)
throws Exception
{
auth.inMemoryAuthentication()
.withUser(user)
.password(passwordEncoder().encode(password))
.roles("USER");
}
}
package org.eclipse.openk.gridfailureinformation.sarisinterface.config;
/*
import com.sun.xml.internal.ws.developer.JAXBContextFactory;
import feign.codec.Decoder;
import feign.codec.Encoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SoapClientConfig {
private static final JAXBContextFactory jaxbFactory = new JAXBContextFactory.Builder()
.withMarshallerJAXBEncoding("UTF-8")
.withMarshallerSchemaLocation("http://apihost http://apihost/schema.xsd")
.build();
@Bean
public Encoder feignEncoder() {
return new SOAPEncoder(jaxbFactory);
}
@Bean
public Decoder feignDecoder() {
return new SOAPDecoder(jaxbFactory);
}
}*/
......@@ -2,6 +2,7 @@
package org.eclipse.openk.gridfailureinformation.sarisinterface.config;
import org.eclipse.openk.gridfailureinformation.sarisinterface.service.SarisWebservice;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
......@@ -9,11 +10,13 @@ import org.springframework.oxm.jaxb.Jaxb2Marshaller;
@Configuration
public class SoapConfiguration {
@Value("${saris.apiUrl}")
public String sarisApiUrl;
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();