@ -26,8 +26,6 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AdapterConfiguration;
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AdapterProperty ;
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AdapterProperty ;
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.MessageFormat ;
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.MessageFormat ;
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.SiddhiExecutionPlan ;
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.SiddhiExecutionPlan ;
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventPublisher ;
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventReceiver ;
import org.wso2.carbon.device.mgt.jaxrs.exception.BadRequestException ;
import org.wso2.carbon.device.mgt.jaxrs.exception.BadRequestException ;
import org.wso2.carbon.device.mgt.jaxrs.exception.ErrorDTO ;
import org.wso2.carbon.device.mgt.jaxrs.exception.ErrorDTO ;
import org.wso2.carbon.device.mgt.jaxrs.exception.InvalidExecutionPlanException ;
import org.wso2.carbon.device.mgt.jaxrs.exception.InvalidExecutionPlanException ;
@ -118,22 +116,22 @@ public class AnalyticsArtifactsManagementServiceImpl
public Response deployEventDefinitionAsDto ( @Valid EventStream stream ) {
public Response deployEventDefinitionAsDto ( @Valid EventStream stream ) {
String tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
String tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
try {
try {
publish Stream( stream ) ;
deploy Stream( stream ) ;
return Response . ok ( ) . build ( ) ;
return Response . ok ( ) . build ( ) ;
} catch ( AxisFault e ) {
} catch ( AxisFault e ) {
String errMsg = "Failed to create event definitions for tenant Domain: " + tenantDomain ;
String errMsg = "Failed to create event definitions for tenant " + tenantDomain ;
log . error ( errMsg , e ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( RemoteException e ) {
} catch ( RemoteException e ) {
String errMsg = "Failed to connect with the remote services for tenant Domain: " + tenantDomain ;
String errMsg = "Failed to connect with the remote services for tenant " + tenantDomain ;
log . error ( errMsg , e ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( JWTClientException e ) {
} catch ( JWTClientException e ) {
String errMsg = "Failed to generate jwt token for tenant Domain: " + tenantDomain ;
String errMsg = "Failed to generate jwt token for tenant " + tenantDomain ;
log . error ( errMsg , e ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( UserStoreException e ) {
} catch ( UserStoreException e ) {
String errMsg = "Failed to connect with the user store for tenant Domain: " + tenantDomain ;
String errMsg = "Failed to connect with the user store for tenant " + tenantDomain ;
log . error ( errMsg , e ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
}
}
@ -144,7 +142,7 @@ public class AnalyticsArtifactsManagementServiceImpl
@Path ( "/receiver/{name}" )
@Path ( "/receiver/{name}" )
public Response deployEventReceiverAsString ( @PathParam ( "name" ) String name ,
public Response deployEventReceiverAsString ( @PathParam ( "name" ) String name ,
@QueryParam ( "isEdited" ) boolean isEdited ,
@QueryParam ( "isEdited" ) boolean isEdited ,
@Valid EventReceiv er receiver ) {
@Valid Adapt er receiver ) {
String tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
String tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
EventReceiverAdminServiceStub eventReceiverAdminServiceStub ;
EventReceiverAdminServiceStub eventReceiverAdminServiceStub ;
try {
try {
@ -155,20 +153,24 @@ public class AnalyticsArtifactsManagementServiceImpl
} else {
} else {
eventReceiverAdminServiceStub . editActiveEventReceiverConfiguration ( receiverDefinition , name ) ;
eventReceiverAdminServiceStub . editActiveEventReceiverConfiguration ( receiverDefinition , name ) ;
}
}
return Response . ok ( ) . build ( ) ;
} catch ( AxisFault e ) {
} catch ( AxisFault e ) {
log . error ( "Failed to create event definitions for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( RemoteException e ) {
} catch ( RemoteException e ) {
log . error ( "Failed to connect with the remote services for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( JWTClientException e ) {
} catch ( JWTClientException e ) {
log . error ( "Failed to generate jwt token for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( UserStoreException e ) {
} catch ( UserStoreException e ) {
log . error ( "Failed to connect with the user store for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
}
}
return Response . ok ( ) . entity ( name ) . build ( ) ;
}
}
@Override
@Override
@ -176,59 +178,31 @@ public class AnalyticsArtifactsManagementServiceImpl
@Path ( "/receiver" )
@Path ( "/receiver" )
public Response deployEventReceiverAsDto ( @Valid Adapter receiver ) {
public Response deployEventReceiverAsDto ( @Valid Adapter receiver ) {
String tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
String tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
String receiverName = receiver . getAdapterName ( ) ;
String adapterType = receiver . getAdapterType ( ) . toStringFormatted ( ) ;
AdapterConfiguration adapterConfiguration = receiver . getAdapterConfiguration ( ) ;
AdapterMappingConfiguration adapterMappingConfiguration = adapterConfiguration . getAdapterMappingConfiguration ( ) ;
try {
try {
List < AdapterProperty > adapterProperties = adapterConfiguration . getAdapterProperties ( ) ;
AdapterConfiguration adapterConfiguration = receiver . getAdapterConfiguration ( ) ;
if ( adapterProperties = = null ) {
log . error ( "Invalid attribute payload" ) ;
return Response . status ( Response . Status . BAD_REQUEST ) . build ( ) ;
}
boolean customMapping = adapterConfiguration . isCustomMappingEnabled ( ) ;
boolean customMapping = adapterConfiguration . isCustomMappingEnabled ( ) ;
List < MappingProperty > inputMappingProperties = adapterMappingConfiguration . getInputMappingProperties ( ) ;
validateAdapterProperties ( adapterConfiguration . getAdapterProperties ( ) ) ;
List < MappingProperty > namespaceMappingProperties = adapterMappingConfiguration . getNamespaceMappingProperties ( ) ;
if ( customMapping ) {
List < MappingProperty > correlationMappingProperties = adapterMappingConfiguration . getCorrelationMappingProperties ( ) ;
validateAdapterMapping ( adapterConfiguration . getAdapterMappingConfiguration ( ) ) ;
List < MappingProperty > payloadMappingProperties = adapterMappingConfiguration . getPayloadMappingProperties ( ) ;
List < MappingProperty > metaMappingProperties = adapterMappingConfiguration . getMetaMappingProperties ( ) ;
MessageFormat messageFormat = adapterMappingConfiguration . getMessageFormat ( ) ;
/ *
* Conditions
* - if CustomMappingEnabled check validity of property lists
* - if both inputMappingProperties and namespaceMappingProperties null check remaining property lists
* - if all correlationMappingProperties , payloadMappingProperties , metaMappingProperties null log error
* - if message format is null change the final result to TRUE
* - else continue
* * /
if ( ( customMapping & &
( inputMappingProperties = = null & & namespaceMappingProperties = = null ) & &
( correlationMappingProperties = = null & & payloadMappingProperties = = null & &
metaMappingProperties = = null ) ) | | messageFormat = = null ) {
String errMsg = "Invalid mapping payload" ;
log . error ( errMsg ) ;
return Response . status ( Response . Status . BAD_REQUEST ) . entity ( errMsg ) . build ( ) ;
}
}
String eventStreamWithVersion = receiver . getEventStreamWithVersion ( ) ;
deployReceiver ( receiver , customMapping , adapterConfiguration ) ;
publishReceiver ( receiverName , adapterType , adapterProperties , customMapping , inputMappingProperties ,
namespaceMappingProperties , correlationMappingProperties , payloadMappingProperties ,
metaMappingProperties , messageFormat , eventStreamWithVersion ) ;
return Response . ok ( ) . build ( ) ;
return Response . ok ( ) . build ( ) ;
} catch ( AxisFault e ) {
} catch ( AxisFault e ) {
log . error ( "Failed to create event definitions for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( RemoteException e ) {
} catch ( RemoteException e ) {
log . error ( "Failed to connect with the remote services for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( JWTClientException e ) {
} catch ( JWTClientException e ) {
log . error ( "Failed to generate jwt token for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( UserStoreException e ) {
} catch ( UserStoreException e ) {
log . error ( "Failed to connect with the user store for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
}
}
}
}
@ -237,33 +211,35 @@ public class AnalyticsArtifactsManagementServiceImpl
@Path ( "/publisher/{name}" )
@Path ( "/publisher/{name}" )
public Response deployEventPublisherAsString ( @PathParam ( "name" ) String name ,
public Response deployEventPublisherAsString ( @PathParam ( "name" ) String name ,
@QueryParam ( "isEdited" ) boolean isEdited ,
@QueryParam ( "isEdited" ) boolean isEdited ,
@Valid EventPublish er publisher ) {
@Valid Adapt er publisher ) {
String tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
String tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
EventPublisherAdminServiceStub eventPublisherAdminServiceStub ;
EventPublisherAdminServiceStub eventPublisherAdminServiceStub ;
try {
try {
String publisherDefinition = publisher . getDefinition ( ) ;
String publisherDefinition = publisher . getDefinition ( ) ;
eventPublisherAdminServiceStub = DeviceMgtAPIUtils . getEventPublisherAdminServiceStub ( ) ;
eventPublisherAdminServiceStub = DeviceMgtAPIUtils . getEventPublisherAdminServiceStub ( ) ;
if ( ! isEdited ) {
if ( ! isEdited ) {
eventPublisherAdminServiceStub . deployEventPublisherConfiguration ( publisherDefinition ) ;
eventPublisherAdminServiceStub . deployEventPublisherConfiguration ( publisherDefinition ) ;
} else {
} else {
eventPublisherAdminServiceStub . editActiveEventPublisherConfiguration ( publisherDefinition , name ) ;
eventPublisherAdminServiceStub . editActiveEventPublisherConfiguration ( publisherDefinition , name ) ;
}
}
return Response . ok ( ) . build ( ) ;
} catch ( AxisFault e ) {
} catch ( AxisFault e ) {
log . error ( "Failed to create event definitions for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( RemoteException e ) {
} catch ( RemoteException e ) {
log . error ( "Failed to connect with the remote services for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( JWTClientException e ) {
} catch ( JWTClientException e ) {
log . error ( "Failed to generate jwt token for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( UserStoreException e ) {
} catch ( UserStoreException e ) {
log . error ( "Failed to connect with the user store for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
}
}
return Response . ok ( ) . entity ( publisher ) . build ( ) ;
}
}
@Override
@Override
@ -271,59 +247,31 @@ public class AnalyticsArtifactsManagementServiceImpl
@Path ( "/publisher" )
@Path ( "/publisher" )
public Response deployEventPublisherAsDto ( @Valid Adapter publisher ) {
public Response deployEventPublisherAsDto ( @Valid Adapter publisher ) {
String tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
String tenantDomain = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantDomain ( ) ;
String publisherName = publisher . getAdapterName ( ) ;
String adapterType = publisher . getAdapterType ( ) . toStringFormatted ( ) ;
AdapterConfiguration adapterConfiguration = publisher . getAdapterConfiguration ( ) ;
AdapterConfiguration adapterConfiguration = publisher . getAdapterConfiguration ( ) ;
AdapterMappingConfiguration adapterMappingConfiguration = adapterConfiguration . getAdapterMappingConfiguration ( ) ;
try {
try {
List < AdapterProperty > adapterProperties = adapterConfiguration . getAdapterProperties ( ) ;
validateAdapterProperties ( adapterConfiguration . getAdapterProperties ( ) ) ;
if ( adapterProperties = = null ) {
log . error ( "Invalid attribute payload" ) ;
return Response . status ( Response . Status . BAD_REQUEST ) . build ( ) ;
}
boolean customMapping = adapterConfiguration . isCustomMappingEnabled ( ) ;
boolean customMapping = adapterConfiguration . isCustomMappingEnabled ( ) ;
String inputMappingString = adapterMappingConfiguration . getInputMappingString ( ) ;
if ( customMapping ) {
List < MappingProperty > inputMappingProperties = adapterMappingConfiguration . getInputMappingProperties ( ) ;
validateAdapterMapping ( adapterConfiguration . getAdapterMappingConfiguration ( ) ) ;
List < MappingProperty > correlationMappingProperties = adapterMappingConfiguration . getCorrelationMappingProperties ( ) ;
List < MappingProperty > payloadMappingProperties = adapterMappingConfiguration . getPayloadMappingProperties ( ) ;
List < MappingProperty > metaMappingProperties = adapterMappingConfiguration . getMetaMappingProperties ( ) ;
MessageFormat messageFormat = adapterMappingConfiguration . getMessageFormat ( ) ;
/ *
* Conditions
* - if CustomMappingEnabled check validity of property lists
* - if all correlationMappingProperties , payloadMappingProperties , metaMappingProperties null log error
* - if message format is null change the final result to TRUE
* - else continue
* /
if ( ( customMapping & &
( inputMappingProperties = = null & & inputMappingString = = null ) & &
( correlationMappingProperties = = null & & payloadMappingProperties = = null & &
metaMappingProperties = = null ) ) | | messageFormat = = null ) {
String errMsg = "Invalid mapping payload" ;
log . error ( errMsg ) ;
return Response . status ( Response . Status . BAD_REQUEST ) . entity ( errMsg ) . build ( ) ;
}
}
String eventStreamWithVersion = publisher . getEventStreamWithVersion ( ) ;
deployPublisher ( publisher , customMapping , adapterConfiguration ) ;
publishPublisher ( publisherName , adapterType , adapterProperties , customMapping
, inputMappingString , inputMappingProperties , correlationMappingProperties
, payloadMappingProperties , metaMappingProperties , messageFormat
, eventStreamWithVersion ) ;
return Response . ok ( ) . build ( ) ;
return Response . ok ( ) . build ( ) ;
} catch ( AxisFault e ) {
} catch ( AxisFault e ) {
log . error ( "Failed to create event definitions for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( RemoteException e ) {
} catch ( RemoteException e ) {
log . error ( "Failed to connect with the remote services for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( JWTClientException e ) {
} catch ( JWTClientException e ) {
log . error ( "Failed to generate jwt token for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( UserStoreException e ) {
} catch ( UserStoreException e ) {
log . error ( "Failed to connect with the user store for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
}
}
}
}
@ -338,46 +286,46 @@ public class AnalyticsArtifactsManagementServiceImpl
publishSiddhiExecutionPlan ( name , isEdited , plan . getDefinition ( ) ) ;
publishSiddhiExecutionPlan ( name , isEdited , plan . getDefinition ( ) ) ;
return Response . ok ( ) . build ( ) ;
return Response . ok ( ) . build ( ) ;
} catch ( AxisFault e ) {
} catch ( AxisFault e ) {
log . error ( "Failed to create event definitions for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( RemoteException e ) {
} catch ( RemoteException e ) {
log . error ( "Failed to connect with the remote services for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
} catch ( InvalidExecutionPlanException e ) {
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
log . error ( "Invalid Execution plan: " + tenantDomain , e ) ;
return e . getResponse ( ) ;
} catch ( JWTClientException e ) {
} catch ( JWTClientException e ) {
log . error ( "Failed to generate jwt token for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
} catch ( UserStoreException e ) {
} catch ( UserStoreException e ) {
log . error ( "Failed to connect with the user store for tenantDomain: " + tenantDomain , e ) ;
String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . build ( ) ;
log . error ( errMsg , e ) ;
return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( errMsg ) . build ( ) ;
}
}
}
}
/ * *
/ * *
* Set data to a stream dto and publish dto using a stub
* Set data to a Stream dto and deploy dto through a stub
*
*
* @param stream Stream definition
* @param stream Stream definition
* @throws RemoteException Exception that may occur during a remote method call
* @throws UserStoreException Exception that may occur during JWT token generation
* @throws JWTClientException Exception that may occur during connecting to client store
* /
* /
private void publish Stream( EventStream stream )
private void deployStream ( EventStream stream )
throws RemoteException , UserStoreException , JWTClientException {
throws RemoteException , UserStoreException , JWTClientException {
EventStreamAdminServiceStub eventStreamAdminServiceStub = null ;
List < Attribute > metaData = stream . getMetaData ( ) ;
List < Attribute > metaData = stream . getMetaData ( ) ;
List < Attribute > payloadData = stream . getPayloadData ( ) ;
List < Attribute > payloadData = stream . getPayloadData ( ) ;
List < Attribute > correlationData = stream . getCorrelationData ( ) ;
List < Attribute > correlationData = stream . getCorrelationData ( ) ;
if ( metaData . isEmpty ( ) & & correlationData . isEmpty ( ) & & payloadData . isEmpty ( ) ) {
if ( metaData . isEmpty ( ) & & correlationData . isEmpty ( ) & & payloadData . isEmpty ( ) ) {
String errMsg = "Invalid payload: event mapping attributes invalid!!!" ;
String errMsg = String . format ( "Failed to validate Stream property attributes of %s:%s" ,
stream . getName ( ) , stream . getVersion ( ) ) ;
ErrorResponse errorResponse = new ErrorResponse ( ) ;
ErrorResponse errorResponse = new ErrorResponse ( ) ;
errorResponse . setMessage ( errMsg ) ;
errorResponse . setMessage ( errMsg ) ;
log . error ( errMsg ) ;
log . error ( errMsg ) ;
throw new BadRequestException ( errorResponse ) ;
throw new BadRequestException ( errorResponse ) ;
}
}
EventStreamAdminServiceStub eventStreamAdminServiceStub =
DeviceMgtAPIUtils . getEventStreamAdminServiceStub ( ) ;
try {
try {
eventStreamAdminServiceStub = DeviceMgtAPIUtils . getEventStreamAdminServiceStub ( ) ;
EventStreamDefinitionDto eventStreamDefinitionDto = new EventStreamDefinitionDto ( ) ;
EventStreamDefinitionDto eventStreamDefinitionDto = new EventStreamDefinitionDto ( ) ;
eventStreamDefinitionDto . setName ( stream . getName ( ) ) ;
eventStreamDefinitionDto . setName ( stream . getName ( ) ) ;
eventStreamDefinitionDto . setVersion ( stream . getVersion ( ) ) ;
eventStreamDefinitionDto . setVersion ( stream . getVersion ( ) ) ;
@ -386,6 +334,7 @@ public class AnalyticsArtifactsManagementServiceImpl
eventStreamDefinitionDto . setMetaData ( addEventAttributesToDto ( metaData ) ) ;
eventStreamDefinitionDto . setMetaData ( addEventAttributesToDto ( metaData ) ) ;
eventStreamDefinitionDto . setPayloadData ( addEventAttributesToDto ( payloadData ) ) ;
eventStreamDefinitionDto . setPayloadData ( addEventAttributesToDto ( payloadData ) ) ;
eventStreamDefinitionDto . setCorrelationData ( addEventAttributesToDto ( correlationData ) ) ;
eventStreamDefinitionDto . setCorrelationData ( addEventAttributesToDto ( correlationData ) ) ;
String streamId = stream . getName ( ) + ":" + stream . getVersion ( ) ;
String streamId = stream . getName ( ) + ":" + stream . getVersion ( ) ;
if ( eventStreamAdminServiceStub . getStreamDefinitionDto ( streamId ) ! = null ) {
if ( eventStreamAdminServiceStub . getStreamDefinitionDto ( streamId ) ! = null ) {
eventStreamAdminServiceStub . editEventStreamDefinitionAsDto ( eventStreamDefinitionDto , streamId ) ;
eventStreamAdminServiceStub . editEventStreamDefinitionAsDto ( eventStreamDefinitionDto , streamId ) ;
@ -399,57 +348,40 @@ public class AnalyticsArtifactsManagementServiceImpl
}
}
/ * *
/ * *
* Set data to a receiver dto and publish dto using a stub
* Set data to a receiver dto and deploy dto through a stub
*
*
* @param receiverName Receiver name
* @param receiver Event Receiver adapter
* @param adapterType Receiver type
* @param customMapping Is Receiver mapped
* @param adapterProperties Receiver properties
* @param adapterConfiguration Adapter property and mapping configuration
* @param customMapping Is receiver mapped
* @param inputMappingProperties Receiver input attribute mapping
* @param namespaceMappingProperties Receiver name - scape attribute mapping
* @param correlationMappingProperties Receiver correlation attribute mapping
* @param payloadMappingProperties Receiver payload attribute mapping
* @param metaMappingProperties Receiver meta attribute mapping
* @param messageFormat Receiver mapping format
* @param eventStreamWithVersion Attached stream
* @throws RemoteException Exception that may occur during a remote method call
* @throws RemoteException Exception that may occur during a remote method call
* @throws UserStoreException Exception that may occur during JWT token generation
* @throws UserStoreException Exception that may occur during JWT token generation
* @throws JWTClientException Exception that may occur during connecting to client store
* @throws JWTClientException Exception that may occur during connecting to client store
* /
* /
private void publishReceiver ( String receiverName , String adapterType ,
private void deployReceiver ( Adapter receiver , boolean customMapping ,
List < AdapterProperty > adapterProperties , boolean customMapping ,
AdapterConfiguration adapterConfiguration )
List < MappingProperty > inputMappingProperties ,
List < MappingProperty > namespaceMappingProperties ,
List < MappingProperty > correlationMappingProperties ,
List < MappingProperty > payloadMappingProperties ,
List < MappingProperty > metaMappingProperties ,
MessageFormat messageFormat ,
String eventStreamWithVersion )
throws RemoteException , UserStoreException , JWTClientException {
throws RemoteException , UserStoreException , JWTClientException {
EventReceiverAdminServiceStub eventReceiverAdminServiceStub = DeviceMgtAPIUtils . getEventReceiverAdminServiceStub ( ) ;
EventReceiverAdminServiceStub eventReceiverAdminServiceStub = DeviceMgtAPIUtils . getEventReceiverAdminServiceStub ( ) ;
try {
try {
String receiverName = receiver . getAdapterName ( ) ;
String adapterType = receiver . getAdapterType ( ) . toStringFormatted ( ) ;
String eventStreamWithVersion = receiver . getEventStreamWithVersion ( ) ;
List < AdapterProperty > adapterProperties = adapterConfiguration . getAdapterProperties ( ) ;
EventReceiverConfigurationDto eventReceiverConfigurationDto = eventReceiverAdminServiceStub
EventReceiverConfigurationDto eventReceiverConfigurationDto = eventReceiverAdminServiceStub
. getActiveEventReceiverConfiguration ( receiverName ) ;
. getActiveEventReceiverConfiguration ( receiverName ) ;
// Check if adapter already exists, if so un-deploy it
if ( eventReceiverConfigurationDto ! = null ) {
if ( eventReceiverConfigurationDto ! = null ) {
eventReceiverAdminServiceStub . undeployActiveEventReceiverConfiguration ( receiverName ) ;
eventReceiverAdminServiceStub . undeployActiveEventReceiverConfiguration ( receiverName ) ;
}
}
BasicInputAdapterPropertyDto [ ] basicInputAdapterPropertyDtos = addReceiverConfigToDto ( adapterProperties ) ;
// Adding attribute properties to DTOs
AdapterMappingConfiguration adapterMappingConfiguration = adapterConfiguration . getAdapterMappingConfiguration ( ) ;
BasicInputAdapterPropertyDto [ ] basicInputAdapterPropertyDtos =
MessageFormat messageFormat = adapterMappingConfiguration . getMessageFormat ( ) ;
addReceiverConfigToDto ( adapterProperties ) ;
if ( eventReceiverAdminServiceStub . getActiveEventReceiverConfiguration ( receiverName ) = = null ) {
// Call stub deploy methods according to the message format
if ( ! messageFormat . toString ( ) . equals ( "wso2event" ) ) {
if ( ! messageFormat . toString ( ) . equals ( "wso2event" ) ) {
EventMappingPropertyDto [ ] inputMappingPropertyDtos =
EventMappingPropertyDto [ ] inputMappingPropertyDtos =
addReceiverMappingToDto ( inputMappingProperties) ;
addReceiverMappingToDto ( adapterMappingConfiguration . getInputMappingProperties ( ) ) ;
if ( messageFormat . toString ( ) . equals ( "xml" ) ) {
if ( messageFormat . toString ( ) . equals ( "xml" ) ) {
EventMappingPropertyDto [ ] namespaceMappingPropertyDtos =
EventMappingPropertyDto [ ] namespaceMappingPropertyDtos =
addReceiverMappingToDto ( namespaceMappingProperties ) ;
addReceiverMappingToDto ( adapterMappingConfiguration . getNamespaceMappingProperties ( ) ) ;
eventReceiverAdminServiceStub . deployXmlEventReceiverConfiguration ( receiverName
eventReceiverAdminServiceStub . deployXmlEventReceiverConfiguration ( receiverName
, eventStreamWithVersion , adapterType , null
, eventStreamWithVersion , adapterType , null
, namespaceMappingPropertyDtos , inputMappingPropertyDtos
, namespaceMappingPropertyDtos , inputMappingPropertyDtos
@ -470,9 +402,15 @@ public class AnalyticsArtifactsManagementServiceImpl
}
}
}
}
} else {
} else {
EventMappingPropertyDto [ ] correlationMappingPropertyDtos = addReceiverMappingToDto ( correlationMappingProperties ) ;
EventMappingPropertyDto [ ] correlationMappingPropertyDtos = addReceiverMappingToDto (
EventMappingPropertyDto [ ] metaMappingPropertyDtos = addReceiverMappingToDto ( metaMappingProperties ) ;
adapterMappingConfiguration . getCorrelationMappingProperties ( )
EventMappingPropertyDto [ ] payloadMappingPropertyDtos = addReceiverMappingToDto ( payloadMappingProperties ) ;
) ;
EventMappingPropertyDto [ ] metaMappingPropertyDtos = addReceiverMappingToDto (
adapterMappingConfiguration . getInputMappingProperties ( )
) ;
EventMappingPropertyDto [ ] payloadMappingPropertyDtos = addReceiverMappingToDto (
adapterMappingConfiguration . getPayloadMappingProperties ( )
) ;
eventReceiverAdminServiceStub . deployWso2EventReceiverConfiguration ( receiverName
eventReceiverAdminServiceStub . deployWso2EventReceiverConfiguration ( receiverName
, eventStreamWithVersion , adapterType , metaMappingPropertyDtos
, eventStreamWithVersion , adapterType , metaMappingPropertyDtos
@ -480,88 +418,81 @@ public class AnalyticsArtifactsManagementServiceImpl
, basicInputAdapterPropertyDtos , customMapping
, basicInputAdapterPropertyDtos , customMapping
, eventStreamWithVersion ) ;
, eventStreamWithVersion ) ;
}
}
}
} finally {
} finally {
cleanup ( eventReceiverAdminServiceStub ) ;
cleanup ( eventReceiverAdminServiceStub ) ;
}
}
}
}
/ * *
/ * *
* Set data to a publisher dto and publish dto using a stub
* Set data to a publisher dto and deploy dto through a stub
*
*
* @param publisherName Publisher name
* @param publisher Event Publisher adapter
* @param adapterType Publisher type
* @param customMapping Is Publisher mapped
* @param adapterProperties Publisher properties
* @param adapterConfiguration Publisher property and mapping configuration
* @param customMapping Is publisher mapped
* @param correlationMappingProperties Publisher correlation attribute mapping
* @param payloadMappingProperties Publisher payload attribute mapping
* @param metaMappingProperties Publisher meta attribute mapping
* @param messageFormat Publisher mapping format
* @param eventStreamWithVersion Attached stream
* @throws RemoteException Exception that may occur during a remote method call
* @throws RemoteException Exception that may occur during a remote method call
* @throws UserStoreException Exception that may occur during JWT token generation
* @throws UserStoreException Exception that may occur during JWT token generation
* @throws JWTClientException Exception that may occur during connecting to client store
* @throws JWTClientException Exception that may occur during connecting to client store
* /
* /
private void publishPublisher ( String publisherName , String adapterType ,
private void deployPublisher ( Adapter publisher , boolean customMapping ,
List < AdapterProperty > adapterProperties ,
AdapterConfiguration adapterConfiguration )
boolean customMapping ,
String inputMappingString ,
List < MappingProperty > inputMappingProperties ,
List < MappingProperty > correlationMappingProperties ,
List < MappingProperty > payloadMappingProperties ,
List < MappingProperty > metaMappingProperties ,
MessageFormat messageFormat ,
String eventStreamWithVersion )
throws RemoteException , UserStoreException , JWTClientException {
throws RemoteException , UserStoreException , JWTClientException {
EventPublisherAdminServiceStub eventPublisherAdminServiceStub = DeviceMgtAPIUtils . getEventPublisherAdminServiceStub ( ) ;
EventPublisherAdminServiceStub eventPublisherAdminServiceStub = DeviceMgtAPIUtils . getEventPublisherAdminServiceStub ( ) ;
// Check if adapter already exists, if so un-deploy it
try {
try {
String publisherName = publisher . getAdapterName ( ) ;
String adapterType = publisher . getAdapterType ( ) . toStringFormatted ( ) ;
String eventStreamWithVersion = publisher . getEventStreamWithVersion ( ) ;
List < AdapterProperty > adapterProperties = adapterConfiguration . getAdapterProperties ( ) ;
EventPublisherConfigurationDto eventPublisherConfigurationDto = eventPublisherAdminServiceStub
EventPublisherConfigurationDto eventPublisherConfigurationDto = eventPublisherAdminServiceStub
. getActiveEventPublisherConfiguration ( publisherName ) ;
. getActiveEventPublisherConfiguration ( publisherName ) ;
if ( eventPublisherConfigurationDto ! = null ) {
if ( eventPublisherConfigurationDto ! = null ) {
eventPublisherAdminServiceStub . undeployActiveEventPublisherConfiguration ( publisherName ) ;
eventPublisherAdminServiceStub . undeployActiveEventPublisherConfiguration ( publisherName ) ;
}
}
// Adding attribute properties to DTOs
BasicOutputAdapterPropertyDto [ ] basicOutputAdapterPropertyDtos =
BasicOutputAdapterPropertyDto [ ] basicOutputAdapterPropertyDtos =
addPublisherConfigToDto ( adapterProperties ) ;
addPublisherConfigToDto ( adapterProperties ) ;
if ( eventPublisherAdminServiceStub . getActiveEventPublisherConfiguration ( publisherName ) = = null ) {
AdapterMappingConfiguration adapterMappingConfiguration = adapterConfiguration . getAdapterMappingConfiguration ( ) ;
// Call stub deploy methods according to the message format
MessageFormat messageFormat = adapterMappingConfiguration . getMessageFormat ( ) ;
if ( ! messageFormat . toString ( ) . equals ( "wso2event" ) ) {
if ( ! messageFormat . toString ( ) . equals ( "wso2event" ) ) {
if ( ! messageFormat . toString ( ) . equals ( "map" ) ) {
if ( ! messageFormat . toString ( ) . equals ( "map" ) ) {
if ( messageFormat . toString ( ) . equals ( "xml" ) ) {
if ( messageFormat . toString ( ) . equals ( "xml" ) ) {
eventPublisherAdminServiceStub . deployXmlEventPublisherConfiguration ( publisherName
eventPublisherAdminServiceStub . deployXmlEventPublisherConfiguration ( publisherName
, eventStreamWithVersion , adapterType , inputMappingString
, eventStreamWithVersion , adapterType , adapterMapp ingConfiguration. getIn putMappingString( )
, basicOutputAdapterPropertyDtos , eventStreamWithVersion
, basicOutputAdapterPropertyDtos , eventStreamWithVersion
, customMapping ) ;
, customMapping ) ;
} else if ( messageFormat . toString ( ) . equals ( "text" ) ) {
} else if ( messageFormat . toString ( ) . equals ( "text" ) ) {
eventPublisherAdminServiceStub . deployTextEventPublisherConfiguration ( publisherName
eventPublisherAdminServiceStub . deployTextEventPublisherConfiguration ( publisherName
, eventStreamWithVersion , adapterType , inputMappingString
, eventStreamWithVersion , adapterType , adapterMapp ingConfiguration. getIn putMappingString( )
, basicOutputAdapterPropertyDtos , eventStreamWithVersion
, basicOutputAdapterPropertyDtos , eventStreamWithVersion
, customMapping ) ;
, customMapping ) ;
} else {
} else {
eventPublisherAdminServiceStub . deployJsonEventPublisherConfiguration ( publisherName
eventPublisherAdminServiceStub . deployJsonEventPublisherConfiguration ( publisherName
, eventStreamWithVersion , adapterType , inputMappingString
, eventStreamWithVersion , adapterType , adapterMapp ingConfiguration. getIn putMappingString( )
, basicOutputAdapterPropertyDtos , eventStreamWithVersion
, basicOutputAdapterPropertyDtos , eventStreamWithVersion
, customMapping ) ;
, customMapping ) ;
}
}
} else {
} else {
org . wso2 . carbon . event . publisher . stub . types . EventMappingPropertyDto [ ] inputMappingPropertyDtos =
org . wso2 . carbon . event . publisher . stub . types . EventMappingPropertyDto [ ] inputMappingPropertyDtos =
addPublisherMappingToDto ( inputMappingProperties ) ;
addPublisherMappingToDto (
adapterMappingConfiguration . getInputMappingProperties ( )
) ;
eventPublisherAdminServiceStub . deployMapEventPublisherConfiguration ( publisherName
eventPublisherAdminServiceStub . deployMapEventPublisherConfiguration ( publisherName
, eventStreamWithVersion , adapterType , inputMappingPropertyDtos
, eventStreamWithVersion , adapterType , inputMappingPropertyDtos
, basicOutputAdapterPropertyDtos , customMapping ) ;
, basicOutputAdapterPropertyDtos , customMapping ) ;
}
}
} else {
} else {
org . wso2 . carbon . event . publisher . stub . types . EventMappingPropertyDto [ ] correlationMappingPropertyDtos =
org . wso2 . carbon . event . publisher . stub . types . EventMappingPropertyDto [ ] correlationMappingPropertyDtos =
addPublisherMappingToDto ( correlationMappingProperties ) ;
addPublisherMappingToDto (
adapterMappingConfiguration . getCorrelationMappingProperties ( )
) ;
org . wso2 . carbon . event . publisher . stub . types . EventMappingPropertyDto [ ] metaMappingPropertyDtos =
org . wso2 . carbon . event . publisher . stub . types . EventMappingPropertyDto [ ] metaMappingPropertyDtos =
addPublisherMappingToDto ( metaMappingProperties ) ;
addPublisherMappingToDto (
adapterMappingConfiguration . getMetaMappingProperties ( )
) ;
org . wso2 . carbon . event . publisher . stub . types . EventMappingPropertyDto [ ] payloadMappingPropertyDtos =
org . wso2 . carbon . event . publisher . stub . types . EventMappingPropertyDto [ ] payloadMappingPropertyDtos =
addPublisherMappingToDto ( payloadMappingProperties ) ;
addPublisherMappingToDto (
adapterMappingConfiguration . getPayloadMappingProperties ( )
) ;
eventPublisherAdminServiceStub . deployWSO2EventPublisherConfiguration ( publisherName
eventPublisherAdminServiceStub . deployWSO2EventPublisherConfiguration ( publisherName
, eventStreamWithVersion , adapterType , metaMappingPropertyDtos
, eventStreamWithVersion , adapterType , metaMappingPropertyDtos
, correlationMappingPropertyDtos , payloadMappingPropertyDtos
, correlationMappingPropertyDtos , payloadMappingPropertyDtos
@ -569,7 +500,6 @@ public class AnalyticsArtifactsManagementServiceImpl
, eventStreamWithVersion ) ;
, eventStreamWithVersion ) ;
}
}
}
} finally {
} finally {
cleanup ( eventPublisherAdminServiceStub ) ;
cleanup ( eventPublisherAdminServiceStub ) ;
}
}
@ -588,24 +518,21 @@ public class AnalyticsArtifactsManagementServiceImpl
* /
* /
private void publishSiddhiExecutionPlan ( String name , boolean isEdited ,
private void publishSiddhiExecutionPlan ( String name , boolean isEdited ,
String plan )
String plan )
throws RemoteException , UserStoreException , JWTClientException ,
throws RemoteException , UserStoreException , JWTClientException {
InvalidExecutionPlanException {
EventProcessorAdminServiceStub eventProcessorAdminServiceStub = null ;
EventProcessorAdminServiceStub eventProcessorAdminServiceStub = null ;
try {
try {
eventProcessorAdminServiceStub = DeviceMgtAPIUtils . getEventProcessorAdminServiceStub ( ) ;
eventProcessorAdminServiceStub = DeviceMgtAPIUtils . getEventProcessorAdminServiceStub ( ) ;
// Validate the plan code
String validationResponse = eventProcessorAdminServiceStub . validateExecutionPlan ( plan ) ;
String validationResponse = eventProcessorAdminServiceStub . validateExecutionPlan ( plan ) ;
if ( validationResponse . equals ( "success" ) ) {
if ( validationResponse . equals ( "success" ) ) {
if ( ! isEdited ) {
if ( ! isEdited ) {
// Create a new plan
eventProcessorAdminServiceStub . deployExecutionPlan ( plan ) ;
eventProcessorAdminServiceStub . deployExecutionPlan ( plan ) ;
} else {
} else {
// Edit plan
eventProcessorAdminServiceStub . editActiveExecutionPlan ( plan , name ) ;
eventProcessorAdminServiceStub . editActiveExecutionPlan ( plan , name ) ;
}
}
} else {
} else {
ErrorDTO errorDTO = new ErrorDTO ( ) ;
ErrorDTO errorDTO = new ErrorDTO ( ) ;
errorDTO . setMessage ( validationResponse ) ;
errorDTO . setMessage ( validationResponse ) ;
log . error ( validationResponse ) ;
throw new InvalidExecutionPlanException ( errorDTO ) ;
throw new InvalidExecutionPlanException ( errorDTO ) ;
}
}
} finally {
} finally {
@ -630,6 +557,51 @@ public class AnalyticsArtifactsManagementServiceImpl
return eventStreamAttributeDtos ;
return eventStreamAttributeDtos ;
}
}
/ * *
* Validate adapter payload attributes
*
* @param adapterProperties Adapter payload attributes
* /
private void validateAdapterProperties ( List < AdapterProperty > adapterProperties ) {
if ( adapterProperties . isEmpty ( ) ) {
String errMsg = "Invalid payload: event property attributes invalid!!!" ;
ErrorResponse errorResponse = new ErrorResponse ( ) ;
errorResponse . setMessage ( errMsg ) ;
log . error ( errMsg ) ;
throw new BadRequestException ( errorResponse ) ;
}
}
/ * *
* Validate adapter mapping attributes
* < p >
* Conditions
* - if both inputMappingProperties and namespaceMappingProperties null check remaining property lists
* - if all correlationMappingProperties , payloadMappingProperties , metaMappingProperties null log error
* - if message format is null change the final result to TRUE
* - else continue
*
* @param adapterMappingConfiguration Adapter mapping attributes
* /
private void validateAdapterMapping ( AdapterMappingConfiguration adapterMappingConfiguration ) {
if ( adapterMappingConfiguration . getInputMappingString ( ) = = null & &
( adapterMappingConfiguration . getInputMappingProperties ( ) . isEmpty ( ) & &
adapterMappingConfiguration . getNamespaceMappingProperties ( ) . isEmpty ( ) ) & &
(
adapterMappingConfiguration . getCorrelationMappingProperties ( ) . isEmpty ( ) & &
adapterMappingConfiguration . getPayloadMappingProperties ( ) . isEmpty ( ) & &
adapterMappingConfiguration . getMetaMappingProperties ( ) . isEmpty ( )
)
| | adapterMappingConfiguration . getMessageFormat ( ) = = null ) {
String errMsg = "Invalid payload: event mapping attributes invalid!!!" ;
ErrorResponse errorResponse = new ErrorResponse ( ) ;
errorResponse . setMessage ( errMsg ) ;
log . error ( errMsg ) ;
throw new BadRequestException ( errorResponse ) ;
}
}
/ * *
/ * *
* This will set payload of receiver attributes to the DTO
* This will set payload of receiver attributes to the DTO
*
*
@ -655,7 +627,8 @@ public class AnalyticsArtifactsManagementServiceImpl
* @param mapProperties List of receiver mapping attributes
* @param mapProperties List of receiver mapping attributes
* @return DTO with all the receiver mapping attributes
* @return DTO with all the receiver mapping attributes
* /
* /
private EventMappingPropertyDto [ ] addReceiverMappingToDto ( List < MappingProperty > mapProperties ) {
private EventMappingPropertyDto [ ] addReceiverMappingToDto
( List < MappingProperty > mapProperties ) {
EventMappingPropertyDto [ ] eventMappingPropertyDtos = new EventMappingPropertyDto [ mapProperties . size ( ) ] ;
EventMappingPropertyDto [ ] eventMappingPropertyDtos = new EventMappingPropertyDto [ mapProperties . size ( ) ] ;
for ( int i = 0 ; i < mapProperties . size ( ) ; i + + ) {
for ( int i = 0 ; i < mapProperties . size ( ) ; i + + ) {
EventMappingPropertyDto eventMappingPropertyDto = new EventMappingPropertyDto ( ) ;
EventMappingPropertyDto eventMappingPropertyDto = new EventMappingPropertyDto ( ) ;