Skip to content

Commit 4dbc9a5

Browse files
committed
Merge remote-tracking branch 'origin/issues/4_new_organization_roles'
into develop
2 parents 1bbc572 + 0de4718 commit 4dbc9a5

20 files changed

+411
-99
lines changed

pom.xml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<compileSource>17</compileSource>
1515
<compileTarget>17</compileTarget>
1616

17-
<dsf.version>1.0.0-M1</dsf.version>
17+
<dsf.version>1.0.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.0.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,15 +142,15 @@
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>
148149
</plugin>
149150
<plugin>
150151
<groupId>net.revelc.code</groupId>
151152
<artifactId>impsort-maven-plugin</artifactId>
152-
<version>1.8.0</version>
153+
<version>1.9.0</version>
153154
<configuration>
154155
<compliance>17</compliance>
155156
<groups>java.,javax.,org.,com.</groups>
@@ -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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ public interface ConstantsAllowList
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;
2222
String PROFILE_DSF_TASK_UPDATE_ALLOW_LIST_MESSAGE_NAME = "updateAllowListMessage";
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+
}

src/main/java/dev/dsf/bpe/service/DownloadAllowList.java

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package dev.dsf.bpe.service;
22

3-
import java.util.EnumSet;
43
import java.util.List;
54

65
import org.camunda.bpm.engine.delegate.DelegateExecution;
76
import org.hl7.fhir.r4.model.Bundle;
8-
import org.hl7.fhir.r4.model.Bundle.BundleType;
97
import org.hl7.fhir.r4.model.IdType;
108
import org.hl7.fhir.r4.model.Reference;
119
import org.hl7.fhir.r4.model.Task;
@@ -29,47 +27,31 @@ public DownloadAllowList(ProcessPluginApi api)
2927
}
3028

3129
@Override
32-
protected void doExecute(DelegateExecution execution, Variables variables) throws Exception
30+
protected void doExecute(DelegateExecution execution, Variables variables)
3331
{
3432
Task task = variables.getStartTask();
3533
IdType bundleId = getBundleId(task);
3634
FhirWebserviceClient requesterClient = api.getFhirWebserviceClientProvider()
3735
.getWebserviceClient(bundleId.getBaseUrl());
3836

39-
Bundle bundle;
4037
try
4138
{
39+
Bundle bundle;
40+
4241
if (bundleId.hasVersionIdPart())
4342
bundle = requesterClient.read(Bundle.class, bundleId.getIdPart(), bundleId.getVersionIdPart());
4443
else
4544
bundle = requesterClient.read(Bundle.class, bundleId.getIdPart());
45+
46+
variables.setString(ConstantsAllowList.BPMN_EXECUTION_VARIABLE_BUNDLE_URL, bundleId.getValue());
47+
variables.setResource(ConstantsAllowList.BPMN_EXECUTION_VARIABLE_BUNDLE, bundle);
4648
}
4749
catch (WebApplicationException e)
4850
{
49-
logger.error("Error while reading Bundle with id {} from organization {}: {}", bundleId.getValue(),
51+
logger.error("Error while reading Bundle with id '{}' from organization {}: {}", bundleId.getValue(),
5052
task.getRequester().getReference(), e.getMessage());
51-
throw new RuntimeException("Error while reading Bundle with id " + bundleId.getValue()
52-
+ " from organization " + task.getRequester().getReference() + ", " + e.getMessage(), e);
53-
}
54-
55-
if (!EnumSet.of(BundleType.TRANSACTION, BundleType.BATCH).contains(bundle.getType()))
56-
{
57-
logger.error("Bundle type TRANSACTION or BATCH expected, but got {}", bundle.getType());
58-
throw new RuntimeException("Bundle type TRANSACTION or BATCH expected, but got " + bundle.getType());
59-
}
60-
61-
try
62-
{
63-
logger.debug("Posting bundle to local endpoint: {}",
64-
api.getFhirContext().newXmlParser().encodeResourceToString(bundle));
65-
api.getFhirWebserviceClientProvider().getLocalWebserviceClient().withMinimalReturn().postBundle(bundle);
66-
}
67-
catch (Exception e)
68-
{
69-
logger.error("Error while executing Bundle with id {} from organization {} locally: {}",
70-
bundleId.getValue(), task.getRequester().getReference(), e.getMessage());
71-
throw new RuntimeException("Error while executing Bundle with id " + bundleId.getValue()
72-
+ " from organization " + task.getRequester().getReference() + " locally, " + e.getMessage(), e);
53+
throw new RuntimeException("Error while reading Bundle with id '" + bundleId.getValue()
54+
+ "' from organization " + task.getRequester().getReference() + ": " + e.getMessage(), e);
7355
}
7456
}
7557

@@ -82,19 +64,19 @@ private IdType getBundleId(Task task)
8264

8365
if (bundleReferences.size() != 1)
8466
{
85-
logger.error("Task input parameter {} contains unexpected number of Bundle IDs, expected 1, got {}",
67+
logger.error("Task input parameter '{}' contains unexpected number of Bundle IDs, expected 1, got {}",
8668
ConstantsAllowList.CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST, bundleReferences.size());
8769
throw new RuntimeException(
88-
"Task input parameter " + ConstantsAllowList.CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST
89-
+ " contains unexpected number of Bundle IDs, expected 1, got " + bundleReferences.size());
70+
"Task input parameter '" + ConstantsAllowList.CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST
71+
+ "' contains unexpected number of Bundle IDs, expected 1, got " + bundleReferences.size());
9072
}
9173
else if (!bundleReferences.get(0).hasReference()
9274
|| !bundleReferences.get(0).getReference().contains("/Bundle/"))
9375
{
94-
logger.error("Task input parameter {} has no Bundle reference",
76+
logger.error("Task input parameter '{}' has no Bundle reference",
9577
ConstantsAllowList.CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST);
96-
throw new RuntimeException("Task input parameter "
97-
+ ConstantsAllowList.CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST + " has no Bundle reference");
78+
throw new RuntimeException("Task input parameter '"
79+
+ ConstantsAllowList.CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST + "' has no Bundle reference");
9880
}
9981

10082
return new IdType(bundleReferences.get(0).getReference());

0 commit comments

Comments
 (0)