From e643db08d1e52800f95e0d4f02c3f4ec71a02c47 Mon Sep 17 00:00:00 2001 From: Yohan Avishke Date: Fri, 11 Oct 2019 09:21:51 +0530 Subject: [PATCH] Change event attribute mapping logic and error handling Event attribute mapping logic was moved to service layer from the api layer and a created a meaningful error message. --- .../impl/AnalyticsArtifactsManagementServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java index 72266166eb..443177d18a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java @@ -607,18 +607,18 @@ public class AnalyticsArtifactsManagementServiceImpl } /** - * This will set payload of event attributes to the DTO + * This will set payload of event attribute's mapping to the DTO * * @param attributes list of event attributes * @return DTO with all the event attributes */ private EventStreamAttributeDto[] addEventAttributesToDto(List attributes) { EventStreamAttributeDto[] eventStreamAttributeDtos = new EventStreamAttributeDto[attributes.size()]; - for (int i = 0; i < attributes.size(); i++) { + for (Attribute attribute : attributes) { EventStreamAttributeDto eventStreamAttributeDto = new EventStreamAttributeDto(); - eventStreamAttributeDto.setAttributeName(attributes.get(i).getName()); - eventStreamAttributeDto.setAttributeType(attributes.get(i).getType().toString()); - eventStreamAttributeDtos[i] = eventStreamAttributeDto; + eventStreamAttributeDto.setAttributeName(attribute.getName()); + eventStreamAttributeDto.setAttributeType(attribute.getType().toString()); + } return eventStreamAttributeDtos; }