Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>dev.dsf</groupId>
<artifactId>dsf-process-ping-pong</artifactId>
<version>2.0.0.0-SNAPSHOT</version>
<version>2.0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
Expand Down
38 changes: 37 additions & 1 deletion src/main/java/dev/dsf/bpe/CodeSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ public enum Concept
"send-message-http-502",
"Sending a message to the remote instance resulted in HTTP status 502"
),
SEND_MESSAGE_HTTP_504(
"send-message-http-504",
"Sending a message to the remote instance resulted in HTTP status 504"
),
SEND_MESSAGE_HTTP_UNEXPECTED(
"send-message-http-unexpected",
"Sending a message to the remote instance resulted in an unexpected HTTP status code"
Expand Down Expand Up @@ -428,6 +432,10 @@ public enum Concept
"receive-message-http-502",
"Received a message and responded with HTTP status 502"
),
RECEIVE_MESSAGE_HTTP_504(
"receive-message-http-504",
"Received a message and responded with HTTP status 504"
),
RECEIVE_MESSAGE_HTTP_UNEXPECTED(
"receive-message-http-unexpected",
"Received a message and responded with an unexpected HTTP status code"
Expand Down Expand Up @@ -477,6 +485,10 @@ public enum Concept
"local-binary-delete-http-502",
"Local instance encountered a HTTP status 502 trying to clean up the binary resource"
),
LOCAL_BINARY_DELETE_HTTP_504(
"local-binary-delete-http-504",
"Local instance encountered a HTTP status 504 trying to clean up the binary resource"
),
LOCAL_BINARY_DELETE_HTTP_UNEXPECTED(
"local-binary-delete-http-unexpected",
"Local instance encountered an unexpected HTTP status code trying to clean up the binary resource"
Expand Down Expand Up @@ -510,6 +522,10 @@ public enum Concept
"remote-binary-delete-http-502",
"Remote instance encountered a HTTP status 502 trying to clean up the binary resource"
),
REMOTE_BINARY_DELETE_HTTP_504(
"remote-binary-delete-http-504",
"Remote instance encountered a HTTP status 504 trying to clean up the binary resource"
),
REMOTE_BINARY_DELETE_HTTP_UNEXPECTED(
"remote-binary-delete-http-unexpected",
"Remote instance encountered an unexpected HTTP status code trying to clean up the binary resource"
Expand All @@ -535,6 +551,10 @@ public enum Concept
"local-binary-post-http-502",
"Local instance encountered a HTTP status 502 trying to post the binary resource to its own FHIR server"
),
LOCAL_BINARY_POST_HTTP_504(
"local-binary-post-http-504",
"Local instance encountered a HTTP status 504 trying to post the binary resource to its own FHIR server"
),
LOCAL_BINARY_POST_HTTP_UNEXPECTED(
"local-binary-post-http-unexpected",
"Local instance encountered an unexpected HTTP status code trying to post the binary resource to its own FHIR server"
Expand Down Expand Up @@ -572,6 +592,10 @@ public enum Concept
"remote-binary-post-http-502",
"Remote instance encountered a HTTP status 502 trying to post the binary resource to its own FHIR server"
),
REMOTE_BINARY_POST_HTTP_504(
"remote-binary-post-http-504",
"Remote instance encountered a HTTP status 504 trying to post the binary resource to its own FHIR server"
),
REMOTE_BINARY_POST_HTTP_UNEXPECTED(
"remote-binary-post-http-unexpected",
"Remote instance encountered an unexpected HTTP status code trying to post the binary resource to its own FHIR server"
Expand Down Expand Up @@ -626,6 +650,10 @@ public enum Concept
"response-message-timeout-http-502",
"Response message timed out. Received HTTP status 502 trying to check request status on the target"
),
RESPONSE_MESSAGE_TIMEOUT_HTTP_504(
"response-message-timeout-http-504",
"Response message timed out. Received HTTP status 504 trying to check request status on the target"
),
RESPONSE_MESSAGE_TIMEOUT_HTTP_UNEXPECTED(
"response-message-timeout-http-unexpected",
"Response message timed out. Received an unexpected HTTP status code trying to check request status on the target"
Expand Down Expand Up @@ -654,7 +682,11 @@ public enum Concept
),
LOCAL_BINARY_DOWNLOAD_HTTP_502(
"local-binary-download-http-502",
"Local instance received HTTP status 500 trying to download the binary resource from the target"
"Local instance received HTTP status 502 trying to download the binary resource from the target"
),
LOCAL_BINARY_DOWNLOAD_HTTP_504(
"local-binary-download-http-504",
"Local instance received HTTP status 504 trying to download the binary resource from the target"
),
LOCAL_BINARY_DOWNLOAD_HTTP_UNEXPECTED(
"local-binary-download-http-unexpected",
Expand Down Expand Up @@ -697,6 +729,10 @@ public enum Concept
"remote-binary-download-http-502",
"Remote instance received HTTP status 502 trying to download the binary resource from this server"
),
REMOTE_BINARY_DOWNLOAD_HTTP_504(
"remote-binary-download-http-504",
"Remote instance received HTTP status 504 trying to download the binary resource from this server"
),
REMOTE_BINARY_DOWNLOAD_HTTP_UNEXPECTED(
"remote-binary-download-http-unexpected",
"Remote instance received an unexpected HTTP status trying to download the binary resource from this server"
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class PingProcessPluginDefinition implements ProcessPluginDefinition
public static final String RESOURCE_VERSION = "2.0";
public static final String NON_RESOURCE_VERSION = "0.0";
public static final String VERSION = RESOURCE_VERSION + "." + NON_RESOURCE_VERSION;
public static final LocalDate RELEASE_DATE = LocalDate.of(2023, 9, 12);
public static final LocalDate RELEASE_DATE = LocalDate.of(2025, 10, 21);

@Override
public String getName()
Expand Down
54 changes: 21 additions & 33 deletions src/main/java/dev/dsf/bpe/mail/AggregateErrorMailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;

import dev.dsf.bpe.ConstantsPing;
import dev.dsf.bpe.ProcessError;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.variables.Target;
Expand All @@ -18,15 +17,19 @@ public class AggregateErrorMailService implements InitializingBean
{
private static final Logger errorMailServiceLogger = LoggerFactory.getLogger("error-mail-service-logger");
private static final String MAIL_MESSAGE_INTRO = "Error(s) while executing ping-pong process:";
private static final String PING_PROCESS_HAS_ERRORS = "Ping process has errors";

public static final String PING_PROCESS_HAS_ERRORS = "Ping process has errors";
public static final String PONG_PROCESS_HAS_ERRORS = "Pong process has errors";

private final ProcessPluginApi api;
private final boolean sendProcessFailedMail;
private final String subject;

public AggregateErrorMailService(ProcessPluginApi api, boolean sendProcessFailedMail)
public AggregateErrorMailService(ProcessPluginApi api, boolean sendProcessFailedMail, String subject)
{
this.api = api;
this.sendProcessFailedMail = sendProcessFailedMail;
this.subject = subject;
}

@Override
Expand All @@ -39,7 +42,7 @@ public void send(IdType taskId, Map<Target, List<ProcessError>> errorsPerTarget)
{
if (sendProcessFailedMail)
{
api.getMailService().send(PING_PROCESS_HAS_ERRORS, buildMailMessage(taskId, errorsPerTarget));
api.getMailService().send(subject, buildMailMessage(taskId, errorsPerTarget));
errorMailServiceLogger.info("Sent e-mail with process errors");
}
}
Expand Down Expand Up @@ -72,40 +75,25 @@ protected String createMessage(Target target, ProcessError error)

if (error != null && error.process() != null)
{
if (ConstantsPing.PROCESS_NAME_PING.equals(error.process()))
{
b.append(api.getOrganizationProvider().getLocalOrganizationIdentifierValue().orElse("?"));
b.append('/');
b.append(api.getEndpointProvider().getLocalEndpointIdentifierValue().orElse("?"));

b.append(" -> ");

b.append(target.getOrganizationIdentifierValue());
b.append('/');
b.append(target.getEndpointIdentifierValue());

b.append(":");
}
else
{
b.append(target.getOrganizationIdentifierValue());
b.append('/');
b.append(target.getEndpointIdentifierValue());

b.append(" -> ");

b.append(api.getOrganizationProvider().getLocalOrganizationIdentifierValue().orElse("?"));
b.append('/');
b.append(api.getEndpointProvider().getLocalEndpointIdentifierValue().orElse("?"));

b.append(": ");
}
b.append(api.getOrganizationProvider().getLocalOrganizationIdentifierValue().orElse("?"));
b.append('/');
b.append(api.getEndpointProvider().getLocalEndpointIdentifierValue().orElse("?"));

b.append(" -> ");

b.append(target.getOrganizationIdentifierValue());
b.append('/');
b.append(target.getEndpointIdentifierValue());

b.append(":");
b.append("\n\t");
b.append("Description: ").append(error.concept().getDisplay());
}
else
{
b.append("Unable to display error because error is null or process is neither of 'ping' or 'pong'");
b.append("Other:");
b.append("\n\t");
b.append("Description: ").append(error.concept().getDisplay());
}

return b.toString();
Expand Down
16 changes: 1 addition & 15 deletions src/main/java/dev/dsf/bpe/message/SendPongMessage.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.dsf.bpe.message;

import java.time.Duration;
import java.util.Objects;
import java.util.stream.Stream;

import org.camunda.bpm.engine.delegate.DelegateExecution;
Expand All @@ -13,7 +12,6 @@
import dev.dsf.bpe.ConstantsPing;
import dev.dsf.bpe.ExecutionVariables;
import dev.dsf.bpe.ProcessErrors;
import dev.dsf.bpe.mail.AggregateErrorMailService;
import dev.dsf.bpe.util.ErrorListUtils;
import dev.dsf.bpe.util.task.SendTaskErrorConverter;
import dev.dsf.bpe.util.task.input.generator.DownloadResourceReferenceGenerator;
Expand All @@ -31,21 +29,9 @@ public class SendPongMessage extends AbstractTaskMessageSend
{
private static final Logger logger = LoggerFactory.getLogger(SendPongMessage.class);

private final AggregateErrorMailService errorMailService;

public SendPongMessage(ProcessPluginApi api, AggregateErrorMailService errorMailService)
public SendPongMessage(ProcessPluginApi api)
{
super(api);

this.errorMailService = errorMailService;
}

@Override
public void afterPropertiesSet() throws Exception
{
super.afterPropertiesSet();

Objects.requireNonNull(errorMailService, "errorMailService");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public void doExecuteWithErrorHandling(DelegateExecution delegateExecution, Vari
errorRemote = new ProcessError(process, CodeSystem.DsfPingError.Concept.REMOTE_BINARY_POST_HTTP_502,
ConstantsPing.POTENTIAL_FIX_URL_ERROR_HTTP);
break;
case 504:
error = new ProcessError(process, CodeSystem.DsfPingError.Concept.LOCAL_BINARY_POST_HTTP_504,
ConstantsPing.POTENTIAL_FIX_URL_ERROR_HTTP);
errorRemote = new ProcessError(process, CodeSystem.DsfPingError.Concept.REMOTE_BINARY_POST_HTTP_504,
ConstantsPing.POTENTIAL_FIX_URL_ERROR_HTTP);
break;
default:
error = new ProcessError(process, CodeSystem.DsfPingError.Concept.LOCAL_BINARY_POST_HTTP_UNEXPECTED,
ConstantsPing.POTENTIAL_FIX_URL_ERROR_HTTP);
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/dev/dsf/bpe/service/pong/StoreErrors.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.dsf.bpe.service.pong;

import java.util.Map;
import java.util.Objects;

import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.hl7.fhir.r4.model.Task;
Expand All @@ -9,19 +12,33 @@
import dev.dsf.bpe.CodeSystem;
import dev.dsf.bpe.ExecutionVariables;
import dev.dsf.bpe.ProcessErrors;
import dev.dsf.bpe.mail.AggregateErrorMailService;
import dev.dsf.bpe.service.AbstractService;
import dev.dsf.bpe.util.ErrorListUtils;
import dev.dsf.bpe.util.task.output.generator.PingStatusGenerator;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.variables.Target;
import dev.dsf.bpe.v1.variables.Variables;

public class StoreErrors extends AbstractService
{
private static final Logger logger = LoggerFactory.getLogger(StoreErrors.class);

public StoreErrors(ProcessPluginApi api)
private final AggregateErrorMailService errorMailService;

public StoreErrors(ProcessPluginApi api, AggregateErrorMailService errorMailService)
{
super(api);

this.errorMailService = errorMailService;
}

@Override
public void afterPropertiesSet() throws Exception
{
super.afterPropertiesSet();

Objects.requireNonNull(errorMailService, "errorMailService");
}

@Override
Expand All @@ -38,6 +55,10 @@ protected void doExecuteWithErrorHandling(DelegateExecution execution, Variables
PingStatusGenerator.updatePongStatusOutput(startTask, status);

variables.updateTask(startTask);

Target target = variables.getTarget();
errorMailService.send(startTask.getIdElement(), Map.of(target, errors.getEntries()));

logger.debug("Stored errors in task: " + startTask.getIdElement().getValue());
}
}
20 changes: 12 additions & 8 deletions src/main/java/dev/dsf/bpe/spring/config/PingConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import dev.dsf.bpe.service.ping.CheckPingTaskStatus;
import dev.dsf.bpe.service.ping.DownloadResourceAndMeasureSpeedInSubProcess;
import dev.dsf.bpe.service.ping.LogAndSaveError;
import dev.dsf.bpe.service.ping.LogAndSaveSendError;
import dev.dsf.bpe.service.ping.LogAndSaveUploadErrorPing;
import dev.dsf.bpe.service.ping.SavePong;
import dev.dsf.bpe.service.ping.SelectPingTargets;
Expand All @@ -45,6 +46,7 @@
import dev.dsf.bpe.service.pong.StoreUploadSpeed;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.documentation.ProcessDocumentation;
import dev.dsf.bpe.variables.codesystem.dsfpingstatus.CodeValueSerializer;
import dev.dsf.bpe.variables.duration.DurationValueSerializer;
import dev.dsf.bpe.variables.process_error.ProcessErrorValueSerializer;
import dev.dsf.bpe.variables.process_errors.ProcessErrorsValueSerializer;
Expand Down Expand Up @@ -138,13 +140,15 @@ public SendStartPing sendStartPing()
@Bean
public AggregateErrorMailService aggregateErrorMailServicePing()
{
return new AggregateErrorMailService(api, sendPingProcessFailedMail);
return new AggregateErrorMailService(api, sendPingProcessFailedMail,
AggregateErrorMailService.PING_PROCESS_HAS_ERRORS);
}

@Bean
public AggregateErrorMailService aggregateErrorMailServicePong()
{
return new AggregateErrorMailService(api, sendPongProcessFailedMail);
return new AggregateErrorMailService(api, sendPongProcessFailedMail,
AggregateErrorMailService.PONG_PROCESS_HAS_ERRORS);
}


Expand Down Expand Up @@ -201,7 +205,7 @@ public SelectPongTarget selectPongTarget()
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public SendPongMessage sendPong()
{
return new SendPongMessage(api, aggregateErrorMailServicePong());
return new SendPongMessage(api);
}

@Bean
Expand Down Expand Up @@ -297,9 +301,9 @@ public StoreDownloadSpeed storeDownloadSpeed()

@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public dev.dsf.bpe.service.ping.LogAndSaveSendError logAndSaveSendError()
public LogAndSaveSendError logAndSaveSendError()
{
return new dev.dsf.bpe.service.ping.LogAndSaveSendError(api);
return new LogAndSaveSendError(api);
}

@Bean
Expand All @@ -320,7 +324,7 @@ public SaveTimeoutError saveTimeoutError()
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public StoreErrors storeErrors()
{
return new StoreErrors(api);
return new StoreErrors(api, aggregateErrorMailServicePong());
}

@Bean
Expand All @@ -338,9 +342,9 @@ public LogAndSaveUploadErrorPong logAndSaveUploadErrorPong()
}

@Bean
public dev.dsf.bpe.variables.codesystem.dsfpingstatus.CodeValueSerializer pingStatusCodeSerializer()
public CodeValueSerializer pingStatusCodeSerializer()
{
return new dev.dsf.bpe.variables.codesystem.dsfpingstatus.CodeValueSerializer();
return new CodeValueSerializer();
}

@Bean
Expand Down
Loading