Skip to content

Commit 3e1d4f5

Browse files
committed
Merge remote-tracking branch 'origin/release/1.0.0.0' into main
2 parents 1563b0a + 8ac681f commit 3e1d4f5

21 files changed

+438
-120
lines changed

pom.xml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
<groupId>dev.dsf</groupId>
88
<artifactId>dsf-process-allow-list</artifactId>
9-
<version>1.0.0.0-M1</version>
9+
<version>1.0.0.0</version>
1010
<packaging>jar</packaging>
1111

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

17-
<dsf.version>1.0.0-M1</dsf.version>
17+
<dsf.version>1.1.0</dsf.version>
1818
<dsf.location>../dsf</dsf.location>
1919
</properties>
2020

@@ -87,7 +87,7 @@
8787
<plugin>
8888
<groupId>org.apache.maven.plugins</groupId>
8989
<artifactId>maven-surefire-plugin</artifactId>
90-
<version>3.1.0</version>
90+
<version>3.1.2</version>
9191
</plugin>
9292
<plugin>
9393
<groupId>org.apache.maven.plugins</groupId>
@@ -109,21 +109,22 @@
109109
<plugin>
110110
<groupId>org.apache.maven.plugins</groupId>
111111
<artifactId>maven-shade-plugin</artifactId>
112-
<version>3.4.1</version>
112+
<version>3.5.0</version>
113113
</plugin>
114114
<plugin>
115115
<groupId>org.apache.maven.plugins</groupId>
116116
<artifactId>maven-dependency-plugin</artifactId>
117-
<version>3.5.0</version>
117+
<version>3.6.0</version>
118118
</plugin>
119119
<plugin>
120120
<groupId>org.apache.maven.plugins</groupId>
121121
<artifactId>maven-clean-plugin</artifactId>
122-
<version>3.2.0</version>
122+
<version>3.3.1</version>
123123
</plugin>
124124
<plugin>
125125
<groupId>org.codehaus.mojo</groupId>
126126
<artifactId>buildnumber-maven-plugin</artifactId>
127+
<!-- 3.1.0 not working, no git commit hash as buildnumber -->
127128
<version>1.4</version>
128129
<executions>
129130
<execution>
@@ -141,7 +142,7 @@
141142
<plugin>
142143
<groupId>net.revelc.code.formatter</groupId>
143144
<artifactId>formatter-maven-plugin</artifactId>
144-
<version>2.22.0</version>
145+
<version>2.23.0</version>
145146
<configuration>
146147
<configFile>eclipse-formatter-config.xml</configFile>
147148
</configuration>
@@ -272,7 +273,7 @@
272273
</configuration>
273274
</execution>
274275
<execution>
275-
<id>copy-process-plugin-to-docker-test-setup-3medic-ttp/medic1</id>
276+
<id>copy-process-plugin-to-docker-test-setup-3dic-ttp/dic1</id>
276277
<phase>package</phase>
277278
<goals>
278279
<goal>copy</goal>
@@ -285,11 +286,11 @@
285286
<version>${project.version}</version>
286287
</artifactItem>
287288
</artifactItems>
288-
<outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process</outputDirectory>
289+
<outputDirectory>${dsf.location}/dsf-docker-test-setup-3dic-ttp/dic1/bpe/process</outputDirectory>
289290
</configuration>
290291
</execution>
291292
<execution>
292-
<id>copy-process-plugin-to-docker-test-setup-3medic-ttp/medic2</id>
293+
<id>copy-process-plugin-to-docker-test-setup-3dic-ttp/dic2</id>
293294
<phase>package</phase>
294295
<goals>
295296
<goal>copy</goal>
@@ -302,11 +303,11 @@
302303
<version>${project.version}</version>
303304
</artifactItem>
304305
</artifactItems>
305-
<outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process</outputDirectory>
306+
<outputDirectory>${dsf.location}/dsf-docker-test-setup-3dic-ttp/dic2/bpe/process</outputDirectory>
306307
</configuration>
307308
</execution>
308309
<execution>
309-
<id>copy-process-plugin-to-docker-test-setup-3medic-ttp/medic3</id>
310+
<id>copy-process-plugin-to-docker-test-setup-3dic-ttp/dic3</id>
310311
<phase>package</phase>
311312
<goals>
312313
<goal>copy</goal>
@@ -319,11 +320,11 @@
319320
<version>${project.version}</version>
320321
</artifactItem>
321322
</artifactItems>
322-
<outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process</outputDirectory>
323+
<outputDirectory>${dsf.location}/dsf-docker-test-setup-3dic-ttp/dic3/bpe/process</outputDirectory>
323324
</configuration>
324325
</execution>
325326
<execution>
326-
<id>copy-process-plugin-to-docker-test-setup-3medic-ttp/ttp</id>
327+
<id>copy-process-plugin-to-docker-test-setup-3dic-ttp/ttp</id>
327328
<phase>package</phase>
328329
<goals>
329330
<goal>copy</goal>
@@ -336,7 +337,7 @@
336337
<version>${project.version}</version>
337338
</artifactItem>
338339
</artifactItems>
339-
<outputDirectory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process</outputDirectory>
340+
<outputDirectory>${dsf.location}/dsf-docker-test-setup-3dic-ttp/ttp/bpe/process</outputDirectory>
340341
</configuration>
341342
</execution>
342343
</executions>
@@ -354,28 +355,28 @@
354355
<followSymlinks>false</followSymlinks>
355356
</fileset>
356357
<fileset>
357-
<directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic1/bpe/process</directory>
358+
<directory>${dsf.location}/dsf-docker-test-setup-3dic-ttp/dic1/bpe/process</directory>
358359
<includes>
359360
<include>${project.artifactId}-${project.version}.jar</include>
360361
</includes>
361362
<followSymlinks>false</followSymlinks>
362363
</fileset>
363364
<fileset>
364-
<directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic2/bpe/process</directory>
365+
<directory>${dsf.location}/dsf-docker-test-setup-3dic-ttp/dic2/bpe/process</directory>
365366
<includes>
366367
<include>${project.artifactId}-${project.version}.jar</include>
367368
</includes>
368369
<followSymlinks>false</followSymlinks>
369370
</fileset>
370371
<fileset>
371-
<directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/medic3/bpe/process</directory>
372+
<directory>${dsf.location}/dsf-docker-test-setup-3dic-ttp/dic3/bpe/process</directory>
372373
<includes>
373374
<include>${project.artifactId}-${project.version}.jar</include>
374375
</includes>
375376
<followSymlinks>false</followSymlinks>
376377
</fileset>
377378
<fileset>
378-
<directory>${dsf.location}/dsf-docker-test-setup-3medic-ttp/ttp/bpe/process</directory>
379+
<directory>${dsf.location}/dsf-docker-test-setup-3dic-ttp/ttp/bpe/process</directory>
379380
<includes>
380381
<include>${project.artifactId}-${project.version}.jar</include>
381382
</includes>

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class AllowListProcessPluginDefinition implements ProcessPluginDefinition
1212
{
1313
public static final String VERSION = "1.0.0.0";
14-
public static final LocalDate RELEASE_DATE = LocalDate.of(2023, 5, 20);
14+
public static final LocalDate RELEASE_DATE = LocalDate.of(2023, 8, 22);
1515

1616
@Override
1717
public String getName()
@@ -34,7 +34,7 @@ public LocalDate getReleaseDate()
3434
@Override
3535
public List<String> getProcessModels()
3636
{
37-
return List.of("bpe/updateAllowList.bpmn", "bpe/downloadAllowList.bpmn");
37+
return List.of("bpe/update-allow-list.bpmn", "bpe/download-allow-list.bpmn");
3838
}
3939

4040
@Override
@@ -48,15 +48,19 @@ public Map<String, List<String>> getFhirResourcesByProcessId()
4848
{
4949
var c = "fhir/CodeSystem/dsf-allow-list.xml";
5050

51-
var aDown = "fhir/ActivityDefinition/dsf-downloadAllowList.xml";
52-
var aUp = "fhir/ActivityDefinition/dsf-updateAllowList.xml";
51+
var aDown = "fhir/ActivityDefinition/dsf-download-allow-list.xml";
52+
var aUp = "fhir/ActivityDefinition/dsf-update-allow-list.xml";
5353

5454
var sDown = "fhir/StructureDefinition/dsf-task-download-allow-list.xml";
5555
var sUp = "fhir/StructureDefinition/dsf-task-update-allow-list.xml";
5656

57+
var tDown = "fhir/Task/dsf-task-download-allow-list.xml";
58+
var tUp = "fhir/Task/dsf-task-update-allow-list.xml";
59+
5760
var v = "fhir/ValueSet/dsf-allow-list.xml";
5861

59-
return Map.of(ConstantsAllowList.PROCESS_NAME_FULL_DOWNLOAD_ALLOW_LIST, Arrays.asList(c, aDown, sDown, v),
60-
ConstantsAllowList.PROCESS_NAME_FULL_UPDATE_ALLOW_LIST, Arrays.asList(c, aUp, sUp, v));
62+
return Map.of(ConstantsAllowList.PROCESS_NAME_FULL_DOWNLOAD_ALLOW_LIST,
63+
Arrays.asList(c, aDown, sDown, tDown, v), ConstantsAllowList.PROCESS_NAME_FULL_UPDATE_ALLOW_LIST,
64+
Arrays.asList(c, aUp, sUp, tUp, v));
6165
}
6266
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ public interface ConstantsAllowList
1919

2020
String PROFILE_DSF_TASK_UPDATE_ALLOW_LIST = "http://dsf.dev/fhir/StructureDefinition/task-update-allow-list";
2121
String PROFILE_DSF_TASK_UPDATE_ALLOW_LIST_PROCESS_URI = PROCESS_DSF_URI_BASE + PROCESS_NAME_UPDATE_ALLOW_LIST;
22-
String PROFILE_DSF_TASK_UPDATE_ALLOW_LIST_MESSAGE_NAME = "updateAllowListMessage";
22+
String PROFILE_DSF_TASK_UPDATE_ALLOW_LIST_MESSAGE_NAME = "updateAllowList";
23+
24+
String BPMN_EXECUTION_VARIABLE_BUNDLE = "bundle";
25+
String BPMN_EXECUTION_VARIABLE_BUNDLE_URL = "bundleUrl";
2326
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package dev.dsf.bpe.service;
2+
3+
import java.util.EnumSet;
4+
import java.util.function.Predicate;
5+
6+
import org.camunda.bpm.engine.delegate.DelegateExecution;
7+
import org.hl7.fhir.r4.model.Bundle;
8+
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
9+
import org.hl7.fhir.r4.model.Bundle.HTTPVerb;
10+
import org.hl7.fhir.r4.model.Endpoint;
11+
import org.hl7.fhir.r4.model.Organization;
12+
import org.hl7.fhir.r4.model.OrganizationAffiliation;
13+
import org.hl7.fhir.r4.model.Resource;
14+
import org.hl7.fhir.r4.model.StringType;
15+
import org.hl7.fhir.r4.model.Task;
16+
import org.slf4j.Logger;
17+
import org.slf4j.LoggerFactory;
18+
19+
import dev.dsf.bpe.ConstantsAllowList;
20+
import dev.dsf.bpe.v1.ProcessPluginApi;
21+
import dev.dsf.bpe.v1.activity.AbstractServiceDelegate;
22+
import dev.dsf.bpe.v1.constants.CodeSystems;
23+
import dev.dsf.bpe.v1.variables.Variables;
24+
25+
public class CheckAllowList extends AbstractServiceDelegate
26+
{
27+
private static final Logger logger = LoggerFactory.getLogger(CheckAllowList.class);
28+
29+
public CheckAllowList(ProcessPluginApi api)
30+
{
31+
super(api);
32+
}
33+
34+
@Override
35+
protected void doExecute(DelegateExecution execution, Variables variables)
36+
{
37+
Bundle bundle = variables.getResource(ConstantsAllowList.BPMN_EXECUTION_VARIABLE_BUNDLE);
38+
String bundleUrl = variables.getString(ConstantsAllowList.BPMN_EXECUTION_VARIABLE_BUNDLE_URL);
39+
40+
if (!EnumSet.of(Bundle.BundleType.TRANSACTION, Bundle.BundleType.BATCH).contains(bundle.getType()))
41+
{
42+
logger.error("Bundle type TRANSACTION or BATCH expected, but got '{}' in Bundle with id '{}'",
43+
bundle.getType(), bundleUrl);
44+
throw new RuntimeException("Bundle type TRANSACTION or BATCH expected, but got '" + bundle.getType()
45+
+ "' in Bundle with id '" + bundleUrl + "'");
46+
}
47+
48+
Task task = variables.getStartTask();
49+
50+
if (bundle.getEntry().stream().anyMatch(entryNotAllowedWithError(task, bundleUrl)))
51+
{
52+
variables.updateTask(task);
53+
54+
logger.error("Expected Bundle with id '{}' containing only resource types Organization, "
55+
+ "OrganizationAffiliation or Endpoint and request methods PUT or DELETE, but found different "
56+
+ "types or methods.", bundleUrl);
57+
throw new RuntimeException("Expected Bundle with id '" + bundleUrl + " 'containing only resource "
58+
+ "types Organization, OrganizationAffiliation or Endpoint and "
59+
+ "request methods PUT or DELETE, but found different types or methods.");
60+
}
61+
}
62+
63+
private Predicate<BundleEntryComponent> entryNotAllowedWithError(Task task, String bundleUrl)
64+
{
65+
return entry ->
66+
{
67+
boolean resourceNotAllowed = resourceNotAllowedWithError(entry, task, bundleUrl);
68+
boolean requestNotAllowed = requestNotAllowedWithError(entry, task, bundleUrl);
69+
70+
// Split into two method calls and not inline to ensure that both methods
71+
// are executed so that all given error messages can be written to Task.output
72+
return resourceNotAllowed || requestNotAllowed;
73+
};
74+
}
75+
76+
private boolean resourceNotAllowedWithError(BundleEntryComponent entry, Task task, String bundleUrl)
77+
{
78+
Resource resource = entry.getResource();
79+
boolean resourceAllowed = (resource instanceof Organization || resource instanceof OrganizationAffiliation
80+
|| resource instanceof Endpoint);
81+
82+
if (!resourceAllowed)
83+
addError(task, "Resource of type '" + resource.getResourceType().name()
84+
+ "' not allowed in Bundle with id '" + bundleUrl + "'");
85+
86+
return !resourceAllowed;
87+
}
88+
89+
private boolean requestNotAllowedWithError(BundleEntryComponent entry, Task task, String bundleUrl)
90+
{
91+
boolean requestAllowed = false;
92+
93+
if (entry.hasRequest())
94+
requestAllowed = EnumSet.of(HTTPVerb.PUT, HTTPVerb.DELETE).contains(entry.getRequest().getMethod());
95+
96+
if (!requestAllowed)
97+
addError(task, "Request with Method '" + entry.getRequest().getMethod()
98+
+ "' not allowed in Bundle with id '" + bundleUrl + "'");
99+
100+
return !requestAllowed;
101+
}
102+
103+
private void addError(Task task, String message)
104+
{
105+
logger.warn(message);
106+
task.addOutput(api.getTaskHelper().createOutput(new StringType(message), CodeSystems.BpmnMessage.error()));
107+
}
108+
}

0 commit comments

Comments
 (0)