Skip to content

Commit 291409d

Browse files
committed
Merge remote-tracking branch 'origin/release/2.0.0.1' into main
2 parents 4e9dc9a + 15feb34 commit 291409d

10 files changed

Lines changed: 149 additions & 58 deletions

pom.xml

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55

66
<groupId>dev.dsf</groupId>
77
<artifactId>dsf-process-ping-pong</artifactId>
8-
<version>2.0.0.0</version>
8+
<version>2.0.0.1</version>
99
<packaging>jar</packaging>
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<compileSource>17</compileSource>
1414
<compileTarget>17</compileTarget>
1515

16-
<dsf.version>1.8.0</dsf.version>
16+
<dsf.version>1.9.0</dsf.version>
17+
<spring.version>6.2.12</spring.version>
1718
<dsf.location>../dsf</dsf.location>
1819
</properties>
1920

@@ -45,21 +46,14 @@
4546
<dependency>
4647
<groupId>org.springframework</groupId>
4748
<artifactId>spring-web</artifactId>
48-
<version>6.0.10</version>
49-
<scope>provided</scope>
50-
</dependency>
51-
52-
<dependency>
53-
<groupId>org.slf4j</groupId>
54-
<artifactId>slf4j-api</artifactId>
55-
<version>2.0.7</version>
49+
<version>${spring.version}</version>
5650
<scope>provided</scope>
5751
</dependency>
5852

5953
<dependency>
6054
<groupId>com.fasterxml.jackson.datatype</groupId>
6155
<artifactId>jackson-datatype-jsr310</artifactId>
62-
<version>2.19.0</version>
56+
<version>2.20.0</version>
6357
<exclusions>
6458
<exclusion>
6559
<groupId>com.fasterxml.jackson.core</groupId>
@@ -103,7 +97,7 @@
10397
<plugin>
10498
<groupId>org.apache.maven.plugins</groupId>
10599
<artifactId>maven-compiler-plugin</artifactId>
106-
<version>3.11.0</version>
100+
<version>3.14.1</version>
107101
<configuration>
108102
<source>${compileSource}</source>
109103
<target>${compileTarget}</target>
@@ -112,12 +106,12 @@
112106
<plugin>
113107
<groupId>org.apache.maven.plugins</groupId>
114108
<artifactId>maven-surefire-plugin</artifactId>
115-
<version>3.1.2</version>
109+
<version>3.5.4</version>
116110
</plugin>
117111
<plugin>
118112
<groupId>org.apache.maven.plugins</groupId>
119113
<artifactId>maven-jar-plugin</artifactId>
120-
<version>3.3.0</version>
114+
<version>3.4.2</version>
121115
<configuration>
122116
<archive>
123117
<manifest>
@@ -134,7 +128,7 @@
134128
<plugin>
135129
<groupId>org.apache.maven.plugins</groupId>
136130
<artifactId>maven-shade-plugin</artifactId>
137-
<version>3.5.0</version>
131+
<version>3.6.1</version>
138132
<executions>
139133
<execution>
140134
<phase>package</phase>
@@ -158,18 +152,18 @@
158152
<plugin>
159153
<groupId>org.apache.maven.plugins</groupId>
160154
<artifactId>maven-dependency-plugin</artifactId>
161-
<version>3.6.0</version>
155+
<version>3.9.0</version>
162156
</plugin>
163157
<plugin>
164158
<groupId>org.apache.maven.plugins</groupId>
165159
<artifactId>maven-clean-plugin</artifactId>
166-
<version>3.3.1</version>
160+
<version>3.5.0</version>
167161
</plugin>
168162
<plugin>
169163
<groupId>org.codehaus.mojo</groupId>
170164
<artifactId>buildnumber-maven-plugin</artifactId>
171165
<!-- 3.1.0 not working, no git commit hash as buildnumber -->
172-
<version>1.4</version>
166+
<version>3.2.1</version>
173167
<executions>
174168
<execution>
175169
<phase>validate</phase>
@@ -186,15 +180,15 @@
186180
<plugin>
187181
<groupId>net.revelc.code.formatter</groupId>
188182
<artifactId>formatter-maven-plugin</artifactId>
189-
<version>2.23.0</version>
183+
<version>2.29.0</version>
190184
<configuration>
191185
<configFile>eclipse-formatter-config.xml</configFile>
192186
</configuration>
193187
</plugin>
194188
<plugin>
195189
<groupId>net.revelc.code</groupId>
196190
<artifactId>impsort-maven-plugin</artifactId>
197-
<version>1.9.0</version>
191+
<version>1.12.0</version>
198192
<configuration>
199193
<compliance>17</compliance>
200194
<groups>java.,javax.,org.,com.</groups>
@@ -218,6 +212,27 @@
218212
</workingPackages>
219213
</configuration>
220214
</plugin>
215+
<plugin>
216+
<groupId>org.apache.maven.plugins</groupId>
217+
<artifactId>maven-enforcer-plugin</artifactId>
218+
<version>3.6.2</version>
219+
<executions>
220+
<execution>
221+
<id>enforce-maven</id>
222+
<goals>
223+
<goal>enforce</goal>
224+
</goals>
225+
<configuration>
226+
<rules>
227+
<requireMavenVersion>
228+
<version>3.6.3</version>
229+
</requireMavenVersion>
230+
</rules>
231+
<fail>true</fail>
232+
</configuration>
233+
</execution>
234+
</executions>
235+
</plugin>
221236
</plugins>
222237
</build>
223238

src/main/java/dev/dsf/bpe/CodeSystem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public BigDecimal calculateSpeed(long bytes, Duration duration)
194194
@Override
195195
public String toUcum()
196196
{
197-
return "Kbit/s";
197+
return "kbit/s";
198198
}
199199
},
200200
Mbps
@@ -281,7 +281,7 @@ public BigDecimal calculateSpeed(long bytes, Duration duration)
281281
@Override
282282
public String toUcum()
283283
{
284-
return "KBy/s";
284+
return "kBy/s";
285285
}
286286
},
287287
MBps

src/main/java/dev/dsf/bpe/ConstantsPing.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ private ConstantsPing()
6161

6262
public static final String TIMER_INTERVAL_DEFAULT_VALUE = "PT24H";
6363

64+
public static final String PONG_TIMEOUT_DURATION_DEFAULT_VALUE = "PT30S";
65+
6466
public static final String BPMN_ERROR_CODE_UNEXPECTED_ERROR = "unexpected-error";
6567

6668
public static final String POTENTIAL_FIX_URL_BASE = "https://dsf.dev/s";

src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
public class PingProcessPluginDefinition implements ProcessPluginDefinition
1212
{
1313
public static final String RESOURCE_VERSION = "2.0";
14-
public static final String NON_RESOURCE_VERSION = "0.0";
14+
public static final String NON_RESOURCE_VERSION = "0.1";
1515
public static final String VERSION = RESOURCE_VERSION + "." + NON_RESOURCE_VERSION;
16-
public static final LocalDate RELEASE_DATE = LocalDate.of(2025, 10, 21);
16+
public static final LocalDate RELEASE_DATE = LocalDate.of(2025, 10, 22);
1717

1818
@Override
1919
public String getName()

src/main/java/dev/dsf/bpe/listener/PingPongProcessPluginDeploymentStateListener.java

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
package dev.dsf.bpe.listener;
22

3+
import static dev.dsf.bpe.PingProcessPluginDefinition.RESOURCE_VERSION;
4+
35
import java.util.List;
46
import java.util.Map;
57
import java.util.Objects;
8+
import java.util.Optional;
69
import java.util.Set;
710
import java.util.function.BiConsumer;
811
import java.util.stream.Collectors;
912

1013
import org.hl7.fhir.r4.model.Bundle;
1114
import org.hl7.fhir.r4.model.CodeSystem;
15+
import org.hl7.fhir.r4.model.Coding;
16+
import org.hl7.fhir.r4.model.DecimalType;
1217
import org.hl7.fhir.r4.model.MetadataResource;
1318
import org.hl7.fhir.r4.model.Resource;
19+
import org.hl7.fhir.r4.model.StringType;
1420
import org.hl7.fhir.r4.model.StructureDefinition;
21+
import org.hl7.fhir.r4.model.Task;
1522
import org.springframework.beans.factory.InitializingBean;
1623

1724
import dev.dsf.bpe.ConstantsPing;
18-
import dev.dsf.bpe.PingProcessPluginDefinition;
1925
import dev.dsf.bpe.v1.ProcessPluginApi;
2026
import dev.dsf.bpe.v1.ProcessPluginDeploymentStateListener;
27+
import dev.dsf.fhir.client.FhirWebserviceClient;
2128

2229
public class PingPongProcessPluginDeploymentStateListener
2330
implements ProcessPluginDeploymentStateListener, InitializingBean
@@ -52,6 +59,62 @@ public void onProcessesDeployed(List<String> activeProcesses)
5259

5360
updateOlderResourcesIfCurrentIsNewestResource(ConstantsPing.STRUCTURE_DEFINITION_URL_EXTENSION_PING_STATUS,
5461
StructureDefinition.class, adaptExtensionStructureDefinitions());
62+
63+
updateDraftTaskResources();
64+
}
65+
66+
private void updateDraftTaskResources()
67+
{
68+
FhirWebserviceClient client = api.getFhirWebserviceClientProvider().getLocalWebserviceClient();
69+
70+
String pingProcessPrefix = "http://dsf.dev/bpe/Process/ping/" + RESOURCE_VERSION;
71+
List<String> draftTaskResourceIdentifiers = List.of(pingProcessPrefix + "/task-start-ping",
72+
pingProcessPrefix + "task-start-ping-autostart");
73+
74+
for (String identifier : draftTaskResourceIdentifiers)
75+
{
76+
Optional<Task> optionalTask = searchTask(identifier).getEntry().stream()
77+
.map(Bundle.BundleEntryComponent::getResource).map(Task.class::cast).findFirst();
78+
79+
if (optionalTask.isPresent())
80+
{
81+
Task toUpdate = optionalTask.get();
82+
adaptDraftTask(toUpdate);
83+
client.update(toUpdate);
84+
}
85+
}
86+
}
87+
88+
private void adaptDraftTask(Task task)
89+
{
90+
Coding downloadResourceSizeBytesCoding = new Coding();
91+
downloadResourceSizeBytesCoding.setSystem(dev.dsf.bpe.CodeSystem.DsfPing.URL)
92+
.setCode(dev.dsf.bpe.CodeSystem.DsfPing.Code.DOWNLOAD_RESOURCE_SIZE_BYTES.getValue())
93+
.setVersion(RESOURCE_VERSION);
94+
95+
Optional<Task.ParameterComponent> optInput = api.getTaskHelper().getFirstInputParameter(task,
96+
downloadResourceSizeBytesCoding, DecimalType.class);
97+
if (optInput.isEmpty())
98+
{
99+
Task.ParameterComponent downloadResourceSizeBytes = new Task.ParameterComponent();
100+
downloadResourceSizeBytes.getType().addCoding(downloadResourceSizeBytesCoding);
101+
downloadResourceSizeBytes.setValue(new DecimalType(ConstantsPing.DOWNLOAD_RESOURCE_SIZE_BYTES_DEFAULT));
102+
task.addInput(downloadResourceSizeBytes);
103+
}
104+
105+
Coding pongTimeoutDurationCoding = new Coding();
106+
pongTimeoutDurationCoding.setSystem(dev.dsf.bpe.CodeSystem.DsfPing.URL)
107+
.setCode(dev.dsf.bpe.CodeSystem.DsfPing.Code.PONG_TIMEOUT_DURATION_ISO_8601.getValue())
108+
.setVersion(RESOURCE_VERSION);
109+
110+
optInput = api.getTaskHelper().getFirstInputParameter(task, pongTimeoutDurationCoding, StringType.class);
111+
if (optInput.isEmpty())
112+
{
113+
Task.ParameterComponent pongTimeoutDuration = new Task.ParameterComponent();
114+
pongTimeoutDuration.getType().addCoding(pongTimeoutDurationCoding);
115+
pongTimeoutDuration.setValue(new StringType(ConstantsPing.PONG_TIMEOUT_DURATION_DEFAULT_VALUE));
116+
task.addInput(pongTimeoutDuration);
117+
}
55118
}
56119

57120
private <T extends MetadataResource> void updateOlderResourcesIfCurrentIsNewestResource(String url, Class<T> type,
@@ -74,6 +137,12 @@ private Bundle search(Class<? extends Resource> type, String url)
74137
Map.of("url", List.of(url)));
75138
}
76139

140+
private Bundle searchTask(String identifier)
141+
{
142+
return api.getFhirWebserviceClientProvider().getLocalWebserviceClient().search(Task.class,
143+
Map.of("identifier", List.of(identifier), "status", List.of("draft")));
144+
}
145+
77146
private <T extends MetadataResource> List<T> extractAndSortResources(Bundle bundle, Class<T> type, String url)
78147
{
79148
return bundle.getEntry().stream().filter(Bundle.BundleEntryComponent::hasResource)
@@ -100,8 +169,7 @@ else if (version1.major < version2.major)
100169

101170
private boolean currentIsNewestResource(List<? extends MetadataResource> resources)
102171
{
103-
return !resources.isEmpty() && PingProcessPluginDefinition.RESOURCE_VERSION
104-
.equals(resources.get(resources.size() - 1).getVersion());
172+
return !resources.isEmpty() && RESOURCE_VERSION.equals(resources.get(resources.size() - 1).getVersion());
105173
}
106174

107175
private MinorMajorVersion getMajorMinorVersion(String version)

src/main/java/dev/dsf/bpe/service/ping/CheckPingTaskStatus.java

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package dev.dsf.bpe.service.ping;
22

3-
import java.util.Objects;
4-
53
import org.camunda.bpm.engine.delegate.BpmnError;
64
import org.camunda.bpm.engine.delegate.DelegateExecution;
75
import org.hl7.fhir.r4.model.Task;
@@ -38,28 +36,34 @@ protected void doExecuteWithErrorHandling(DelegateExecution delegateExecution, V
3836
Target target = variables.getTarget();
3937
String correlationKey = target.getCorrelationKey();
4038

41-
String taskId = (String) delegateExecution.getVariableLocal(ExecutionVariables.pingTaskId.name());
39+
// Do not use getVariableLocal() here. CheckPingTaskStatus gets executed in a child execution of the one that
40+
// stored the variable. GetVariableLocal() will only look in the child execution's variables and find nothing.
41+
// GetVariable() or the DSF API's getString() does look for values in the parent execution's variables.
42+
String taskId = variables.getString(ExecutionVariables.pingTaskId.name());
4243

43-
Objects.requireNonNull(taskId);
44-
FhirWebserviceClient fhirWebserviceClient = api.getFhirWebserviceClientProvider()
45-
.getWebserviceClient(target.getEndpointUrl());
4644
try
4745
{
48-
Task pingTask = fhirWebserviceClient.withRetry(3, 1000).read(Task.class, taskId);
49-
ProcessError error = switch (pingTask.getStatus())
46+
if (taskId != null)
5047
{
51-
case COMPLETED -> new ProcessError(ConstantsPing.PROCESS_NAME_PING,
52-
CodeSystem.DsfPingError.Concept.RESPONSE_MESSAGE_TIMEOUT_STATUS_COMPLETED, null);
53-
case FAILED -> new ProcessError(ConstantsPing.PROCESS_NAME_PING,
54-
CodeSystem.DsfPingError.Concept.RESPONSE_MESSAGE_TIMEOUT_STATUS_FAILED, null);
55-
case INPROGRESS -> new ProcessError(ConstantsPing.PROCESS_NAME_PING,
56-
CodeSystem.DsfPingError.Concept.RESPONSE_MESSAGE_TIMEOUT_STATUS_IN_PROGRESS, null);
57-
case REQUESTED -> new ProcessError(ConstantsPing.PROCESS_NAME_PING,
58-
CodeSystem.DsfPingError.Concept.RESPONSE_MESSAGE_TIMEOUT_STATUS_REQUESTED, null);
59-
default -> new ProcessError(ConstantsPing.PROCESS_NAME_PING,
60-
CodeSystem.DsfPingError.Concept.RESPONSE_MESSAGE_TIMEOUT_STATUS_UNEXPECTED, null);
61-
};
62-
ErrorListUtils.add(error, delegateExecution, correlationKey);
48+
FhirWebserviceClient fhirWebserviceClient = api.getFhirWebserviceClientProvider()
49+
.getWebserviceClient(target.getEndpointUrl());
50+
51+
Task pingTask = fhirWebserviceClient.withRetry(3, 1000).read(Task.class, taskId);
52+
ProcessError error = switch (pingTask.getStatus())
53+
{
54+
case COMPLETED -> new ProcessError(ConstantsPing.PROCESS_NAME_PING,
55+
CodeSystem.DsfPingError.Concept.RESPONSE_MESSAGE_TIMEOUT_STATUS_COMPLETED, null);
56+
case FAILED -> new ProcessError(ConstantsPing.PROCESS_NAME_PING,
57+
CodeSystem.DsfPingError.Concept.RESPONSE_MESSAGE_TIMEOUT_STATUS_FAILED, null);
58+
case INPROGRESS -> new ProcessError(ConstantsPing.PROCESS_NAME_PING,
59+
CodeSystem.DsfPingError.Concept.RESPONSE_MESSAGE_TIMEOUT_STATUS_IN_PROGRESS, null);
60+
case REQUESTED -> new ProcessError(ConstantsPing.PROCESS_NAME_PING,
61+
CodeSystem.DsfPingError.Concept.RESPONSE_MESSAGE_TIMEOUT_STATUS_REQUESTED, null);
62+
default -> new ProcessError(ConstantsPing.PROCESS_NAME_PING,
63+
CodeSystem.DsfPingError.Concept.RESPONSE_MESSAGE_TIMEOUT_STATUS_UNEXPECTED, null);
64+
};
65+
ErrorListUtils.add(error, delegateExecution, correlationKey);
66+
}
6367
}
6468
catch (WebApplicationException e)
6569
{

src/main/java/dev/dsf/bpe/util/task/SendTaskErrorConverter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ private static ProcessErrorWithStatusCode convertWebApplicationException(WebAppl
286286
CodeSystem.DsfPingError.Concept.SEND_MESSAGE_HTTP_401,
287287
ConstantsPing.POTENTIAL_FIX_URL_ERROR_HTTP),
288288
CodeSystem.DsfPingStatus.Code.NOT_ALLOWED);
289-
case 403 ->
290-
{
289+
case 403 -> {
291290
if (messageWithReference)
292291
{
293292
yield new ProcessErrorWithStatusCode(
@@ -332,8 +331,7 @@ yield new ProcessErrorWithStatusCode(
332331
CodeSystem.DsfPingError.Concept.RECEIVE_MESSAGE_HTTP_401,
333332
ConstantsPing.POTENTIAL_FIX_URL_ERROR_HTTP),
334333
CodeSystem.DsfPingStatus.Code.NOT_ALLOWED);
335-
case 403 ->
336-
{
334+
case 403 -> {
337335
if (messageWithReference)
338336
{
339337
yield new ProcessErrorWithStatusCode(

src/main/resources/fhir/Task/dsf-task-start-ping-autostart.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
</type>
5656
<valueString value="PT24H"/>
5757
</input>
58-
<input>
58+
<!--Resource will get updated in DeploymentStateListener because FHIR validation does not use the version of the CodeSystem
59+
to differentiate between CodeSystems that differ from one plugin version to the next-->
60+
<!--<input>
5961
<type>
6062
<coding>
6163
<system value="http://dsf.dev/fhir/CodeSystem/ping"/>
@@ -74,5 +76,5 @@
7476
</coding>
7577
</type>
7678
<valueString value="PT30S"/>
77-
</input>
79+
</input>-->
7880
</Task>

0 commit comments

Comments
 (0)