diff --git a/core/src/main/java/com/adobe/aio/util/feign/FeignUtil.java b/core/src/main/java/com/adobe/aio/util/feign/FeignUtil.java
index 579b1017..d962695d 100644
--- a/core/src/main/java/com/adobe/aio/util/feign/FeignUtil.java
+++ b/core/src/main/java/com/adobe/aio/util/feign/FeignUtil.java
@@ -57,8 +57,8 @@ public class FeignUtil {
public static final String AIO_FEIGN_RETRY_MAX_PERIOD = "AIO_FEIGN_RETRY_MAX_PERIOD";
- private static final int DEFAULT_CONNECT_TIMEOUT_IN_SECONDS = 10;
- private static final int DEFAULT_READ_TIMEOUT_IN_SECONDS = 60;
+ public static final int DEFAULT_CONNECT_TIMEOUT_IN_SECONDS = 10;
+ public static final int DEFAULT_READ_TIMEOUT_IN_SECONDS = 60;
public static final long DEFAULT_RETRY_PERIOD_IN_SECONDS = 1000L;
public static final int DEFAULT_MAX_ATTEMPTS = 3;
public static final long DEFAULT_MAX_PERIOD_IN_SECONDS = 4L;
diff --git a/events_ingress/src/main/java/com/adobe/aio/event/publish/PublishService.java b/events_ingress/src/main/java/com/adobe/aio/event/publish/PublishService.java
index 821d6ef8..455c0ba8 100644
--- a/events_ingress/src/main/java/com/adobe/aio/event/publish/PublishService.java
+++ b/events_ingress/src/main/java/com/adobe/aio/event/publish/PublishService.java
@@ -25,8 +25,12 @@ CloudEvent publishCloudEvent(String providerId, String eventCode, String data)
throws JsonProcessingException;
CloudEvent publishCloudEvent(String providerId, String eventCode, String eventId, String data)
throws JsonProcessingException;
+ CloudEvent publishCloudEvent(Boolean isPhiData, String providerId, String eventCode, String eventId, JsonNode data);
+
void publishRawEvent(String providerId, String eventCode, String rawEvent);
+ void publishRawEvent(Boolean isPhiData, String providerId, String eventCode, String eventId, String rawEvent);
+
static Builder builder() {
return new Builder();
}
diff --git a/events_ingress/src/main/java/com/adobe/aio/event/publish/api/PublishApi.java b/events_ingress/src/main/java/com/adobe/aio/event/publish/api/PublishApi.java
index f2f9a8e2..209d2fe0 100644
--- a/events_ingress/src/main/java/com/adobe/aio/event/publish/api/PublishApi.java
+++ b/events_ingress/src/main/java/com/adobe/aio/event/publish/api/PublishApi.java
@@ -26,26 +26,37 @@ public interface PublishApi {
* publish a Cloud Event Payload
*
* @param body your CloudEvent Input Model
+ * @param isPhiData true if the event contains PHI Data
*/
@RequestLine("POST")
- @Headers({"Content-Type: application/cloudevents+json"})
- void publishCloudEvent(CloudEvent body);
+ @Headers({
+ "Content-Type: application/cloudevents+json",
+ "x-event-phidata: {isPhiData}"})
+ void publishCloudEvent(
+ @Param("isPhiData") Boolean isPhiData,
+ CloudEvent body);
/**
* publish a Raw Event Json Payload
+ * @param isPhiData true if the event contains PHI Data
* @param eventCode the Adobe I/O EventMetadata eventCode associated with the Event
* @param providerId the Adobe I/O EventMetadata ProviderId associated with the Event
+ * @param eventId the eventId you want to assign to this the Event (mandatory if isPhiData is true)
* @param rawEvent the Raw Event Json Payload to publish
*/
@RequestLine("POST")
@Headers({
- "Content-Type: application/json",
- "x-adobe-event-provider-id: {providerId}",
- "x-adobe-event-code: {eventCode}"
+ "Content-Type: application/json",
+ "x-event-phidata: {isPhiData}",
+ "x-event-id: {eventId}",
+ "x-adobe-event-provider-id: {providerId}",
+ "x-adobe-event-code: {eventCode}"
})
void publishRawEvent(
- @Param("providerId") String providerId,
- @Param("eventCode") String eventCode,
- JsonNode rawEvent);
+ @Param("isPhiData") Boolean isPhiData,
+ @Param("providerId") String providerId,
+ @Param("eventCode") String eventCode,
+ @Param("eventId") String eventId,
+ JsonNode rawEvent);
}
diff --git a/events_ingress/src/main/java/com/adobe/aio/event/publish/feign/FeignPublishService.java b/events_ingress/src/main/java/com/adobe/aio/event/publish/feign/FeignPublishService.java
index 1504ffe1..1cb00cc7 100644
--- a/events_ingress/src/main/java/com/adobe/aio/event/publish/feign/FeignPublishService.java
+++ b/events_ingress/src/main/java/com/adobe/aio/event/publish/feign/FeignPublishService.java
@@ -54,23 +54,37 @@ public CloudEvent publishCloudEvent(String providerId, String eventCode,
@Override
public CloudEvent publishCloudEvent(String providerId, String eventCode, String eventId,
- String data) throws JsonProcessingException {
- return publishCloudEvent(providerId, eventCode, eventId, JacksonUtil.getJsonNode(data));
+ String cloudEventData) throws JsonProcessingException {
+ return publishCloudEvent(providerId, eventCode, eventId, JacksonUtil.getJsonNode(cloudEventData));
}
@Override
public CloudEvent publishCloudEvent(String providerId, String eventCode, String eventId,
- JsonNode data) {
+ JsonNode cloudEventData) {
+ return publishCloudEvent(false, providerId, eventCode, eventId, cloudEventData);
+ }
+
+ @Override
+ public CloudEvent publishCloudEvent(Boolean isPhiData, String providerId, String eventCode, String eventId,
+ JsonNode cloudEventData) {
CloudEvent inputModel = CloudEvent.builder()
.providerId(providerId).eventCode(eventCode).eventId(eventId)
- .data(data).build();
- publishApi.publishCloudEvent(inputModel);
+ .data(cloudEventData).build();
+ publishApi.publishCloudEvent(isPhiData, inputModel);
return inputModel;
}
@Override
public void publishRawEvent(String providerId, String eventCode, String rawEvent) {
- publishApi.publishRawEvent(providerId, eventCode, getJsonNode(rawEvent));
+ publishApi.publishRawEvent(false, providerId, eventCode, null, getJsonNode(rawEvent));
+ }
+
+ @Override
+ public void publishRawEvent(Boolean isPhiData, String providerId, String eventCode, String eventId, String rawEvent) {
+ if (isPhiData !=null && isPhiData && StringUtils.isEmpty(eventId)) {
+ throw new AIOException("Cannot publish PHI data without an eventId");
+ }
+ publishApi.publishRawEvent(isPhiData, providerId, eventCode, eventId, getJsonNode(rawEvent));
}
private static JsonNode getJsonNode(String jsonPayload) {
diff --git a/events_test/pom.xml b/events_test/pom.xml
index bf057506..81573b7f 100644
--- a/events_test/pom.xml
+++ b/events_test/pom.xml
@@ -50,8 +50,10 @@
${project.version}
- org.slf4j
- slf4j-simple
+ ch.qos.logback
+ logback-classic
+ 1.2.6
+ test
org.junit.jupiter
diff --git a/events_test/src/main/java/com/adobe/aio/event/publish/PublishServiceTester.java b/events_test/src/main/java/com/adobe/aio/event/publish/PublishServiceTester.java
index 14053d6b..ac8f844e 100644
--- a/events_test/src/main/java/com/adobe/aio/event/publish/PublishServiceTester.java
+++ b/events_test/src/main/java/com/adobe/aio/event/publish/PublishServiceTester.java
@@ -16,6 +16,7 @@
import static org.junit.jupiter.api.Assertions.fail;
import com.adobe.aio.event.publish.model.CloudEvent;
+import com.adobe.aio.util.JacksonUtil;
import com.adobe.aio.util.WorkspaceUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.UUID;
@@ -37,15 +38,15 @@ public PublishServiceTester(){
.build();
}
- public String publishCloudEvent(String providerId, String eventCode) {
+ public String publishCloudEvent(Boolean isPhiData, String providerId, String eventCode) {
String eventId = UUID.randomUUID().toString();
- return this.publishCloudEvent(providerId, eventCode, eventId, getDummyDataNode(eventId));
+ return this.publishCloudEvent(isPhiData, providerId, eventCode, eventId, getDummyDataNode(eventId));
}
- public String publishCloudEvent(String providerId, String eventCode, String eventId, String data) {
+ public String publishCloudEvent(Boolean isPhiData, String providerId, String eventCode, String eventId, String data) {
try {
- CloudEvent cloudEvent = publishService.publishCloudEvent(
- providerId, eventCode, eventId, data);
+ CloudEvent cloudEvent = publishService.publishCloudEvent(isPhiData,
+ providerId, eventCode, eventId, JacksonUtil.getJsonNode(data));
logger.info("Published CloudEvent: {}", cloudEvent);
assertEquals(eventId, cloudEvent.getId());
assertEquals(CloudEvent.SOURCE_URN_PREFIX + providerId, cloudEvent.getSource());
@@ -60,6 +61,12 @@ public String publishCloudEvent(String providerId, String eventCode, String even
}
}
+ public String publishRawEvent(Boolean isPhiData, String providerId, String eventCode, String eventId) {
+ publishService.publishRawEvent(isPhiData, providerId, eventCode, eventId, getDummyDataNode(eventId));
+ logger.info("Published Raw Event: {}", getDummyDataNode(eventId));
+ return eventId;
+ }
+
public String publishRawEvent(String providerId, String eventCode) {
String eventId = UUID.randomUUID().toString();
publishService.publishRawEvent(providerId, eventCode, getDummyDataNode(eventId));
diff --git a/events_test/src/test/java/com/adobe/aio/event/journal/JournalServiceIntegrationTest.java b/events_test/src/test/java/com/adobe/aio/event/journal/JournalServiceIntegrationTest.java
index 54db3e23..221a8ba4 100644
--- a/events_test/src/test/java/com/adobe/aio/event/journal/JournalServiceIntegrationTest.java
+++ b/events_test/src/test/java/com/adobe/aio/event/journal/JournalServiceIntegrationTest.java
@@ -70,7 +70,7 @@ public void testJournalPolling()
TEST_REGISTRATION_NAME, providerId, TEST_EVENT_CODE);
registrationId = registration.getRegistrationId();
- String cloudEventId = publishServiceTester.publishCloudEvent(providerId, TEST_EVENT_CODE);
+ String cloudEventId = publishServiceTester.publishCloudEvent(false, providerId, TEST_EVENT_CODE);
boolean wasCloudEventPolled = pollJournalForEvent(
registration.getJournalUrl().getHref(), cloudEventId, isEventIdTheCloudEventId);
diff --git a/events_test/src/test/java/com/adobe/aio/event/publish/PublishServiceIntegrationTest.java b/events_test/src/test/java/com/adobe/aio/event/publish/PublishServiceIntegrationTest.java
index 5af6f473..c76aeb8b 100644
--- a/events_test/src/test/java/com/adobe/aio/event/publish/PublishServiceIntegrationTest.java
+++ b/events_test/src/test/java/com/adobe/aio/event/publish/PublishServiceIntegrationTest.java
@@ -14,12 +14,11 @@
import static com.adobe.aio.event.management.ProviderServiceIntegrationTest.TEST_EVENT_CODE;
import static com.adobe.aio.event.management.ProviderServiceIntegrationTest.TEST_EVENT_PROVIDER_LABEL;
import static com.adobe.aio.event.management.RegistrationServiceIntegrationTest.TEST_REGISTRATION_NAME;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.*;
import com.adobe.aio.event.management.ProviderServiceTester;
import com.adobe.aio.event.management.RegistrationServiceTester;
+import com.adobe.aio.exception.AIOException;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;
@@ -49,8 +48,16 @@ public void publishEventTest() {
registrationId = registrationServiceTester.createOrUpdateJournalRegistration(
TEST_REGISTRATION_NAME, providerId, TEST_EVENT_CODE).getRegistrationId();
- assertNotNull(publishCloudEvent(providerId, TEST_EVENT_CODE));
+ assertNotNull(publishCloudEvent(null, providerId, TEST_EVENT_CODE));
+ assertNotNull(publishCloudEvent(false, providerId, TEST_EVENT_CODE));
+ assertNotNull(publishCloudEvent(true, providerId, TEST_EVENT_CODE));
assertNotNull(publishRawEvent(providerId, TEST_EVENT_CODE));
+ assertNotNull(publishRawEvent(Boolean.TRUE, providerId, TEST_EVENT_CODE, "someEventId"));
+
+ final String finalProviderId = providerId;
+ Exception ex = assertThrows(AIOException.class,() -> publishRawEvent(Boolean.TRUE, finalProviderId, TEST_EVENT_CODE, null));
+ assertEquals("Cannot publish PHI data without an eventId", ex.getMessage());
+
} catch (Exception e) {
logger.error(e.getMessage(), e);
fail(e.getMessage());