From 9f94f86401734f171b4bb12f1bd8247f6c200974 Mon Sep 17 00:00:00 2001 From: charitha Date: Fri, 6 Oct 2017 13:38:03 +0530 Subject: [PATCH] Rename GeoAnalyticsConfigurations to OperationAnalyticsConfiguration --- .../impl/GeoLocationBasedServiceImpl.java | 18 +++++++------- .../mgt/common/device/details/DeviceInfo.java | 24 ------------------- .../core/config/DeviceManagementConfig.java | 14 +++++------ ...a => OperationAnalyticsConfiguration.java} | 18 +++++++------- .../mgt/core/util/DeviceManagerUtil.java | 16 +++++++++++-- .../modules/business-controllers/device.js | 2 +- .../cdmf.unit.geo-dashboard/geo-dashboard.js | 2 +- features/device-mgt/pom.xml | 1 + 8 files changed, 42 insertions(+), 53 deletions(-) rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/geo/location/{GeoLocationConfiguration.java => OperationAnalyticsConfiguration.java} (65%) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java index 04bfeff0d74..2543d1a85ef 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java @@ -31,15 +31,15 @@ import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoServices; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; import org.wso2.carbon.device.mgt.common.geo.service.Alert; import org.wso2.carbon.device.mgt.common.geo.service.Event; import org.wso2.carbon.device.mgt.common.geo.service.GeoFence; -import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException; +import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants; -import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; -import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; +import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.device.mgt.jaxrs.service.api.GeoLocationBasedService; import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; @@ -76,13 +76,13 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { public Response getGeoDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("deviceType") String deviceType, @QueryParam("from") long from, @QueryParam("to") long to) { - //First, check whether the Geo Location service has been enabled in the cdmf-config.xml file - DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance() - .getDeviceManagementConfig(); - if (deviceManagementConfig != null) { - if(!deviceManagementConfig.getGeoLocationConfiguration().getPublishLocationOperationResponse()){ - return Response.status(Response.Status.BAD_REQUEST.getStatusCode()).build(); + try { + if (!DeviceManagerUtil.isPublishOperationResponseEnabled()) { + return Response.status(Response.Status.BAD_REQUEST.getStatusCode()) + .entity("Operation publishing does not exists").build(); } + } catch (DeviceManagementException e) { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(e.getMessage()).build(); } String tableName = "IOT_PER_DEVICE_STREAM_GEO_FUSEDSPATIALEVENT"; String fromDate = String.valueOf(from); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceInfo.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceInfo.java index b7f5a5b14cd..05c8345183f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceInfo.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceInfo.java @@ -144,30 +144,6 @@ public class DeviceInfo implements Serializable { this.location = location; } - public String getIMEI() { - if (IMEI != null) { - return IMEI; - } else { - return ""; - } - } - - public void setIMEI(String IMEI) { - this.IMEI = IMEI; - } - - public String getIMSI() { - if (IMSI != null) { - return IMSI; - } else { - return ""; - } - } - - public void setIMSI(String IMSI) { - this.IMSI = IMSI; - } - public String getDeviceModel() { if (deviceModel != null) { return deviceModel; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java index 72f9944fb2d..2c039b0bef8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java @@ -18,7 +18,7 @@ package org.wso2.carbon.device.mgt.core.config; import org.wso2.carbon.device.mgt.core.config.cache.CertificateCacheConfiguration; -import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration; +import org.wso2.carbon.device.mgt.core.config.geo.location.OperationAnalyticsConfiguration; import org.wso2.carbon.device.mgt.core.config.cache.DeviceCacheConfiguration; import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations; import org.wso2.carbon.device.mgt.core.config.pagination.PaginationConfiguration; @@ -48,7 +48,7 @@ public final class DeviceManagementConfig { private DeviceStatusTaskConfig deviceStatusTaskConfig; private DeviceCacheConfiguration deviceCacheConfiguration; private CertificateCacheConfiguration certificateCacheConfiguration; - private GeoLocationConfiguration geoLocationConfiguration; + private OperationAnalyticsConfiguration operationAnalyticsConfiguration; private String defaultGroupsConfiguration; @XmlElement(name = "ManagementRepository", required = true) @@ -142,13 +142,13 @@ public final class DeviceManagementConfig { this.certificateCacheConfiguration = certificateCacheConfiguration; } - @XmlElement(name = "GeoLocationConfiguration", required = true) - public GeoLocationConfiguration getGeoLocationConfiguration() { - return geoLocationConfiguration; + @XmlElement(name = "OperationAnalyticsConfiguration", required = true) + public OperationAnalyticsConfiguration getOperationAnalyticsConfiguration() { + return operationAnalyticsConfiguration; } - public void setGeoLocationConfiguration(GeoLocationConfiguration geoLocationConfiguration) { - this.geoLocationConfiguration = geoLocationConfiguration; + public void setOperationAnalyticsConfiguration(OperationAnalyticsConfiguration operationAnalyticsConfiguration) { + this.operationAnalyticsConfiguration = operationAnalyticsConfiguration; } @XmlElement(name = "DefaultGroupsConfiguration", required = true) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/geo/location/GeoLocationConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/geo/location/OperationAnalyticsConfiguration.java similarity index 65% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/geo/location/GeoLocationConfiguration.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/geo/location/OperationAnalyticsConfiguration.java index e1aeb1a45c5..8cc2053e646 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/geo/location/GeoLocationConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/geo/location/OperationAnalyticsConfiguration.java @@ -22,21 +22,21 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; /** - * This class represents the information related to Geo Location configuration. + * This class represents the information related to Device Operation Analytics configuration. */ -@XmlRootElement(name = "GeoLocationConfiguration") -public class GeoLocationConfiguration { +@XmlRootElement(name = "OperationAnalyticsConfiguration") +public class OperationAnalyticsConfiguration { - private boolean publishLocationOperationResponse; + private boolean publishOperationResponse; private boolean isEnabled; - public boolean getPublishLocationOperationResponse() { - return publishLocationOperationResponse; + public boolean getPublishOperationResponse() { + return publishOperationResponse; } - @XmlElement(name = "PublishLocationOperationResponse", required = true) - public void setPublishLocationOperationResponse(boolean publishLocationOperationResponse) { - this.publishLocationOperationResponse = publishLocationOperationResponse; + @XmlElement(name = "PublishOperationResponse", required = true) + public void setPublishOperationResponse(boolean publishOperationResponse) { + this.publishOperationResponse = publishOperationResponse; } public boolean getIsEnabled() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index 19ab94ca8a6..5d81c89e49c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -31,6 +31,7 @@ import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.GroupPaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.TransactionManagementException; +import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; @@ -415,11 +416,22 @@ public final class DeviceManagerUtil { return limit; } - public static boolean isPublishLocationOperationResEnabled() throws DeviceManagementException { + public static boolean isOperationAnalyticsEnabled() throws DeviceManagementException { DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance(). getDeviceManagementConfig(); if (deviceManagementConfig != null) { - return deviceManagementConfig.getGeoLocationConfiguration().getPublishLocationOperationResponse(); + return deviceManagementConfig.getOperationAnalyticsConfiguration().getIsEnabled(); + } else { + throw new DeviceManagementException("Device-Mgt configuration has not initialized. Please check the " + + "cdm-config.xml file."); + } + } + + public static boolean isPublishOperationResponseEnabled() throws DeviceManagementException { + DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance(). + getDeviceManagementConfig(); + if (deviceManagementConfig != null && isOperationAnalyticsEnabled()) { + return deviceManagementConfig.getOperationAnalyticsConfiguration().getPublishOperationResponse(); } else { throw new DeviceManagementException("Device-Mgt configuration has not initialized. Please check the " + "cdm-config.xml file."); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js index c83585e96b9..ef6cf7357f3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js @@ -73,7 +73,7 @@ deviceModule = function () { } var userName = carbonUser.username + "@" + carbonUser.domain; var locationHistory = []; - var geoServicesEnabled = devicemgtProps.serverConfig.geoLocationConfiguration.isEnabled; + var geoServicesEnabled = devicemgtProps.serverConfig.operationAnalyticsConfiguration.isEnabled; if (geoServicesEnabled) { try { var fromDate = new Date(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.js index f18b1172595..4094fc89dc4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.js @@ -60,6 +60,6 @@ function onRequest(context) { } else { viewModel.lastLocation = stringify({}); } - viewModel.geoServicesEnabled = devicemgtProps.serverConfig.geoLocationConfiguration.isEnabled; + viewModel.geoServicesEnabled = devicemgtProps.serverConfig.operationAnalyticsConfiguration.isEnabled; return viewModel; } \ No newline at end of file diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index e4878583934..fe682a6a8d8 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -33,6 +33,7 @@ http://wso2.org + org.wso2.carbon.device.mgt.basics.feature org.wso2.carbon.device.mgt.server.feature org.wso2.carbon.device.mgt.ui.feature org.wso2.carbon.device.mgt.api.feature