From bed68289b539cf8669f89c0da3da9f5c85af5778 Mon Sep 17 00:00:00 2001 From: Yohan Avishke Date: Mon, 2 Sep 2019 10:10:22 +0530 Subject: [PATCH] Make stream persisting optional At the moment of creating a stream it will be persisted by default. This was made a optional choice by using a query flag through this commit. --- .../mgt/jaxrs/service/api/DeviceEventManagementService.java | 5 +++-- .../jaxrs/service/impl/DeviceEventManagementServiceImpl.java | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java index 26904a9cdff..c49f9698c1b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java @@ -123,6 +123,7 @@ public interface DeviceEventManagementService { Response deployDeviceTypeEventDefinition(@ApiParam(name = "type", value = "The device type, such as android, ios," + " and windows.", required = false) @PathParam("type")String deviceType, + @QueryParam("skipPersist")boolean skipPersist, @ApiParam(name = "deviceTypeEvent", value = "Add the data to complete " + "the DeviceTypeEvent object.", required = true) @Valid DeviceTypeEvent deviceTypeEvent); @@ -357,7 +358,7 @@ public interface DeviceEventManagementService { @QueryParam("max") double max ); - + @GET @Path("/{type}") @ApiOperation( @@ -411,4 +412,4 @@ public interface DeviceEventManagementService { " ios, or windows.", required = false) @PathParam("type")String deviceType) ; -} \ No newline at end of file +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java index 2bbcee2d43a..e6fe0e4f8c6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java @@ -192,6 +192,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe @Path("/{type}") @Override public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType, + @QueryParam("skipPersist") boolean skipPersist, @Valid DeviceTypeEvent deviceTypeEvent) { TransportType transportType = deviceTypeEvent.getTransportType(); EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList(); @@ -208,7 +209,9 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION; publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, deviceType); - publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes); + if (!skipPersist) { + publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes); + } publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType); try { PrivilegedCarbonContext.startTenantFlow();