Skip to content
Snippets Groups Projects
Commit b74a2e5c authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' into OZG-3363-helm-chart-anpassungen

parents 7ab0a33e e9534453
No related branches found
No related tags found
No related merge requests found
Showing
with 89 additions and 23 deletions
......@@ -31,7 +31,7 @@
<parent>
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>common</artifactId>
......
......@@ -29,7 +29,7 @@
<parent>
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>formcycle-adapter</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
</parent>
<artifactId>formcycle-adapter-impl</artifactId>
......
......@@ -29,14 +29,14 @@
<parent>
<groupId>de.itvsh.kop.common</groupId>
<artifactId>kop-common-dependencies</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<relativePath />
</parent>
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>formcycle-adapter-interface</artifactId>
<name>EM - Formcycle Adapter - Interface</name>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
<properties>
<pluto.version>1.8.0</pluto.version>
......
......@@ -29,7 +29,7 @@
<parent>
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
</parent>
<artifactId>formcycle-adapter</artifactId>
......
......@@ -30,7 +30,7 @@
<parent>
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
......
......@@ -29,7 +29,7 @@
<parent>
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
......
......@@ -31,7 +31,7 @@
<parent>
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
......
......@@ -37,7 +37,7 @@
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Eingangs Adapter - Parent</name>
......
......@@ -29,7 +29,7 @@
<parent>
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
......
......@@ -30,7 +30,7 @@
<parent>
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
</parent>
<artifactId>semantik-adapter</artifactId>
......
......@@ -153,20 +153,20 @@ class ZipAttachmentReaderTest {
}
@Test
@DisplayName("should delete all temporary files after their associated input streams have been closed")
@DisplayName("should delete all temporary files after last reading of inputstream")
@SneakyThrows
void shouldDeleteContentFiles() {
void shouldDeleteContentFilesOnFinalRead() {
cleanupTempFiles();
var contentEntries = new ZipAttachmentReader().readContent(loadZip(ZIP_2_FILE_NAME));
contentEntries.forEach(this::closeInputStream);
contentEntries.forEach(this::closeInputStreamFinalRead);
assertTrue(noFilesWithSuffixInTempDirectory());
}
@SneakyThrows
private void closeInputStream(IncomingFile entry) {
entry.getContentStream().close();
private void closeInputStreamFinalRead(IncomingFile entry) {
entry.getContentStreamForFinalRead().close();
}
@Test
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>de.itvsh.kop.eingangsadapter</groupId>
<artifactId>parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<version>1.10.0-SNAPSHOT</version>
</parent>
<artifactId>xta-adapter</artifactId>
<name>Eingangs Adapter - XTA</name>
......
......@@ -79,4 +79,6 @@ class Actions {
private URI statusList;
@NotNull
private URI fetchRequest;
@NotNull
private URI closeRequest;
}
......@@ -19,13 +19,17 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.webservices.client.WebServiceTemplateBuilder;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.stereotype.Service;
import org.springframework.ws.soap.SoapFaultDetailElement;
import org.springframework.ws.soap.addressing.client.ActionCallback;
import org.springframework.ws.soap.addressing.version.Addressing10;
import org.springframework.ws.soap.client.SoapFaultClientException;
import org.w3._2005._08.addressing.AttributedURIType;
import de.itvsh.kop.eingangsadapter.common.errorhandling.TechnicalException;
import de.xoev.transport.xta._211.ContentType;
import de.xoev.transport.xta._211.ExceptionType;
import de.xoev.transport.xta._211.GenericContentContainer;
import eu.osci.ws._2008._05.transport.MsgBoxCloseRequestType;
import eu.osci.ws._2008._05.transport.MsgBoxFetchRequest;
import eu.osci.ws._2008._05.transport.MsgBoxStatusListRequestType;
import eu.osci.ws._2008._05.transport.MsgSelector;
......@@ -38,6 +42,9 @@ import lombok.extern.log4j.Log4j2;
@Service
class XtaRemoteService {
private static final String ERROR_ON_CLOSE_LOG_TEMPLATE = "Error result on close request.\nReason: %s";
private static final String DETAIL_LOG_TEMPLATE = "Code: %s, Message: %s";
@Autowired
@Valid
private XtaProperties properties;
......@@ -143,8 +150,48 @@ class XtaRemoteService {
}
public void close(@NonNull XtaMessageId messageId) {
// TODO Auto-generated method stub
LOG.warn("close not jet implemented");
var callback = new ActionCallback(properties.getActions().getCloseRequest(), new Addressing10(), getTargetUri());
var template = webServiceTemplateBuilder.setMarshaller(osciMarshaller).setUnmarshaller(xoevMarshaller).build();
try {
template.marshalSendAndReceive(buildCloseRequest(messageId.toString()), callback);
} catch (SoapFaultClientException e) {
logErrorOnClose(e);
}
}
private JAXBElement<MsgBoxCloseRequestType> buildCloseRequest(String msgId) {
MsgBoxCloseRequestType request = new MsgBoxCloseRequestType();
var lastMsgReceived = request.getLastMsgReceived();
AttributedURIType attribute = new AttributedURIType();
attribute.setValue(msgId);
lastMsgReceived.add(attribute);
return new ObjectFactory().createMsgBoxCloseRequest(request);
}
private void logErrorOnClose(SoapFaultClientException e) {
try {
var fault = e.getSoapFault();
StringBuilder logBuilder = new StringBuilder(ERROR_ON_CLOSE_LOG_TEMPLATE.formatted(e.getSoapFault().getFaultStringOrReason()));
var entries = fault.getFaultDetail().getDetailEntries();
entries.forEachRemaining(entry -> logBuilder.append("\n").append(formatFaultEntry(entry)));
LOG.error(logBuilder.toString(), e);
} catch (Exception e1) {
LOG.error("Error on loggging close error", e1);
LOG.error("origin error was", e);
}
}
private String formatFaultEntry(SoapFaultDetailElement soapfaultdetailelement1) {
@SuppressWarnings("unchecked")
ExceptionType exceptionType = ((JAXBElement<ExceptionType>) xoevMarshaller.unmarshal(soapfaultdetailelement1.getSource())).getValue();
return DETAIL_LOG_TEMPLATE.formatted(exceptionType.getErrorCode().getCode(), exceptionType.getErrorCode().getName().toString());
}
}
......@@ -2,6 +2,7 @@ package de.ozgcloud.eingang.xta;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Profile;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
......@@ -10,6 +11,7 @@ import de.itvsh.kop.eingangsadapter.semantik.SemantikAdapter;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
@Profile("!itcase")
@Log4j2
@Component
class XtaRunner implements ApplicationListener<ContextRefreshedEvent> {
......
......@@ -14,3 +14,4 @@ ozgcloud:
actions:
status-list: "http://www.osci.eu/ws/2008/05/transport/urn/messageTypes/MsgBoxStatusListRequest"
fetch-request: "http://www.osci.eu/ws/2008/05/transport/urn/messageTypes/MsgBoxFetchRequest"
close-request: "http://www.osci.eu/ws/2008/05/transport/urn/messageTypes/MsgBoxCloseRequest"
......@@ -14,6 +14,7 @@ import org.mockito.Captor;
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.context.annotation.Bean;
import org.springframework.test.context.ActiveProfiles;
import de.itvsh.kop.common.test.TestUtils;
......@@ -24,7 +25,7 @@ import de.itvsh.kop.eingangsadapter.common.formdata.ServiceKonto.PostfachAddress
import de.itvsh.kop.eingangsadapter.common.formdata.StringBasedIdentifier;
import de.itvsh.kop.eingangsadapter.router.VorgangRemoteService;
@SpringBootTest(classes = Application.class)
@SpringBootTest(classes = { Application.class, ActivateXTARunnerConfig.class })
@ActiveProfiles({ "local", "itcase" })
class XtaITCase {
......@@ -99,4 +100,12 @@ class XtaITCase {
return formDataCaptor.getValue();
}
}
class ActivateXTARunnerConfig {
@Bean
XtaRunner xtaRunner() {
return new XtaRunner();
}
}
\ No newline at end of file
package de.ozgcloud.eingang.xta;
import java.util.UUID;
class XtaMessageTestFactory {
static final XtaMessageId MESSAGE_ID = XtaMessageId.from(UUID.randomUUID().toString());
static final XtaMessageId MESSAGE_ID = XtaMessageId.from("urn:de:xta:messageid:dataport_xta_210:81e40808-91c6-4765-aaf4-1aa62fec8be9");
static XtaMessage create() {
return createBuilder().build();
......
......@@ -61,4 +61,11 @@ class XtaRemoteServiceITCase {
}
}
@Nested
class TestClose {
@Test
void shouldThrowNoException() {
assertThatNoException().isThrownBy(() -> remoteService.close(XtaMessageTestFactory.MESSAGE_ID));
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment