diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java similarity index 95% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoService.java rename to components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java index 7f34536ede..094781fe79 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java @@ -68,15 +68,21 @@ import javax.ws.rs.core.Response; @Scope( name = "View Analytics", description = "", - key = "perm:geo-service:analytics", - permissions = {"/device-mgt/devices/owning-device/analytics"} + key = "perm:geo-service:analytics-view", + permissions = {"/device-mgt/devices/owning-device/view-analytics"} + ), + @Scope( + name = "Manage Alerts", + description = "", + key = "perm:geo-service:alerts-manage", + permissions = {"/device-mgt/devices/owning-device/manage-alerts"} ) } ) @Path("/geo-services") @Api(value = "Geo Service", description = "This carries all the resources related to the geo service functionalities.") -public interface GeoService { +public interface GeoLocationBasedService { /** * Retrieve Analytics for the device type */ @@ -92,7 +98,7 @@ public interface GeoService { tags = "Geo Service Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view") }) } ) @@ -161,7 +167,7 @@ public interface GeoService { tags = "Geo Service Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") }) } ) @@ -226,7 +232,7 @@ public interface GeoService { tags = "Geo Service Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") }) } ) @@ -291,7 +297,7 @@ public interface GeoService { tags = "Geo Service Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") }) } ) @@ -355,7 +361,7 @@ public interface GeoService { tags = "Geo Service Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") }) } ) @@ -400,8 +406,8 @@ public interface GeoService { String deviceType, @ApiParam( name = "from", - value = "Get stats from what time", - required = true) + value = "Get stats from what time", + required = true) @QueryParam("from") long from, @ApiParam( name = "to", @@ -415,13 +421,13 @@ public interface GeoService { consumes = "application/json", produces = "application/json", httpMethod = "DELETE", - value = "Create Geo alerts for the device", + value = "Deletes Geo alerts for the device", notes = "", response = Response.class, tags = "Geo Service Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") }) } ) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java similarity index 94% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoServiceImpl.java rename to components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java index b81df06d52..04bfeff0d7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java @@ -35,11 +35,12 @@ import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorization 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.GeoServiceException; +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.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.jaxrs.service.api.GeoService; +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; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtUtil; @@ -64,9 +65,9 @@ import java.util.Map; /** * The api for */ -public class GeoServiceImpl implements GeoService { +public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { - private static Log log = LogFactory.getLog(GeoServiceImpl.class); + private static Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class); @Path("stats/{deviceType}/{deviceId}") @GET @@ -149,10 +150,10 @@ public class GeoServiceImpl implements GeoService { identifier.setId(deviceId); identifier.setType(deviceType); - org.wso2.carbon.device.mgt.common.geo.service.GeoService geoService = DeviceMgtAPIUtils.getGeoService(); + GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); geoService.createGeoAlert(alert, identifier, alertType); return Response.ok().build(); - } catch (DeviceAccessAuthorizationException | GeoServiceException e) { + } catch (DeviceAccessAuthorizationException | GeoLocationBasedServiceException e) { String error = "Error occurred while creating the geo alert for " + deviceType + " with id: " + deviceId; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); @@ -182,10 +183,10 @@ public class GeoServiceImpl implements GeoService { identifier.setId(deviceId); identifier.setType(deviceType); - org.wso2.carbon.device.mgt.common.geo.service.GeoService geoService = DeviceMgtAPIUtils.getGeoService(); + GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); geoService.updateGeoAlert(alert, identifier, alertType); return Response.ok().build(); - } catch (DeviceAccessAuthorizationException | GeoServiceException e) { + } catch (DeviceAccessAuthorizationException | GeoLocationBasedServiceException e) { String error = "Error occurred while creating the geo alert for " + deviceType + " with id: " + deviceId; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); @@ -216,10 +217,10 @@ public class GeoServiceImpl implements GeoService { identifier.setId(deviceId); identifier.setType(deviceType); - org.wso2.carbon.device.mgt.common.geo.service.GeoService geoService = DeviceMgtAPIUtils.getGeoService(); + GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); geoService.removeGeoAlert(alertType, identifier, queryName); return Response.ok().build(); - } catch (DeviceAccessAuthorizationException | GeoServiceException e) { + } catch (DeviceAccessAuthorizationException | GeoLocationBasedServiceException e) { String error = "Error occurred while removing the geo alert for " + deviceType + " with id: " + deviceId; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); @@ -249,7 +250,7 @@ public class GeoServiceImpl implements GeoService { identifier.setId(deviceId); identifier.setType(deviceType); - org.wso2.carbon.device.mgt.common.geo.service.GeoService geoService = DeviceMgtAPIUtils.getGeoService(); + GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); if (GeoServices.ALERT_TYPE_WITHIN.equals(alertType)) { List alerts = geoService.getWithinAlerts(identifier); @@ -271,7 +272,7 @@ public class GeoServiceImpl implements GeoService { return Response.ok().entity(alerts).build(); } return null; - } catch (DeviceAccessAuthorizationException | GeoServiceException e) { + } catch (DeviceAccessAuthorizationException | GeoLocationBasedServiceException e) { String error = "Error occurred while getting the geo alerts for " + deviceType + " with id: " + deviceId; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index 2df2daba39..8b12b4a285 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -44,7 +44,7 @@ import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorization import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; -import org.wso2.carbon.device.mgt.common.geo.service.GeoService; +import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; @@ -427,9 +427,10 @@ public class DeviceMgtAPIUtils { return gadgetDataService; } - public static GeoService getGeoService() { + public static GeoLocationProviderService getGeoService() { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - GeoService geoService = (GeoService) ctx.getOSGiService(GeoService.class, null); + GeoLocationProviderService + geoService = (GeoLocationProviderService) ctx.getOSGiService(GeoLocationProviderService.class, null); if (geoService == null) { throw new IllegalStateException("Geo Service has not been initialized."); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index b59be7cf4f..572b64922b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -80,7 +80,7 @@ - + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoServiceException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoLocationBasedServiceException.java similarity index 77% rename from components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoServiceException.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoLocationBasedServiceException.java index 91154e03e2..e9eb31f329 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoServiceException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoLocationBasedServiceException.java @@ -20,7 +20,7 @@ package org.wso2.carbon.device.mgt.common.geo.service; /** * Custom exception class of Geo Service related operations. */ -public class GeoServiceException extends Exception { +public class GeoLocationBasedServiceException extends Exception { private static final long serialVersionUID = -7151990041029070298L; @@ -34,26 +34,26 @@ public class GeoServiceException extends Exception { this.errorMessage = errorMessage; } - public GeoServiceException(String msg, Exception nestedEx) { + public GeoLocationBasedServiceException(String msg, Exception nestedEx) { super(msg, nestedEx); setErrorMessage(msg); } - public GeoServiceException(String message, Throwable cause) { + public GeoLocationBasedServiceException(String message, Throwable cause) { super(message, cause); setErrorMessage(message); } - public GeoServiceException(String msg) { + public GeoLocationBasedServiceException(String msg) { super(msg); setErrorMessage(msg); } - public GeoServiceException() { + public GeoLocationBasedServiceException() { super(); } - public GeoServiceException(Throwable cause) { + public GeoLocationBasedServiceException(Throwable cause) { super(cause); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoLocationProviderService.java similarity index 78% rename from components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoService.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoLocationProviderService.java index 1880634c77..d8375ab583 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoLocationProviderService.java @@ -26,26 +26,26 @@ import java.util.List; * This represents the Geo service functionality which should be implemented by * required GeoServiceManagers. */ -public interface GeoService { +public interface GeoLocationProviderService { - List getWithinAlerts(DeviceIdentifier identifier) throws GeoServiceException; + List getWithinAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException; - List getExitAlerts(DeviceIdentifier identifier) throws GeoServiceException; + List getExitAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException; boolean createGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType) - throws GeoServiceException; + throws GeoLocationBasedServiceException; boolean updateGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType) - throws GeoServiceException; + throws GeoLocationBasedServiceException; boolean removeGeoAlert(String alertType, DeviceIdentifier identifier, String queryName) - throws GeoServiceException; + throws GeoLocationBasedServiceException; - String getSpeedAlerts(DeviceIdentifier identifier) throws GeoServiceException; + String getSpeedAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException; - String getProximityAlerts(DeviceIdentifier identifier) throws GeoServiceException; + String getProximityAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException; - List getStationaryAlerts(DeviceIdentifier identifier) throws GeoServiceException; + List getStationaryAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException; - List getTrafficAlerts(DeviceIdentifier identifier) throws GeoServiceException; + List getTrafficAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoServcieManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java similarity index 93% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoServcieManagerImpl.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java index 400a7b1693..36b56e357a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoServcieManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java @@ -39,8 +39,8 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoServices; import org.wso2.carbon.device.mgt.common.geo.service.Alert; import org.wso2.carbon.device.mgt.common.geo.service.GeoFence; -import org.wso2.carbon.device.mgt.common.geo.service.GeoService; -import org.wso2.carbon.device.mgt.common.geo.service.GeoServiceException; +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.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub; import org.wso2.carbon.identity.jwt.client.extension.JWTClient; @@ -78,9 +78,9 @@ import static org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoSer * This class will read events, set alerts, read alerts related to geo-fencing and it will * use Registry as the persistence storage. */ -public class GeoServcieManagerImpl implements GeoService { +public class GeoLocationProviderServiceImpl implements GeoLocationProviderService { - private static Log log = LogFactory.getLog(GeoServcieManagerImpl.class); + private static Log log = LogFactory.getLog(GeoLocationProviderServiceImpl.class); /** * required soap header for authorization @@ -110,7 +110,7 @@ public class GeoServcieManagerImpl implements GeoService { private static final String SSLV3 = "SSLv3"; @Override - public List getWithinAlerts(DeviceIdentifier identifier) throws GeoServiceException { + public List getWithinAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException { Registry registry = getGovernanceRegistry(); String registryPath = GeoServices.REGISTRY_PATH_FOR_ALERTS + @@ -151,14 +151,14 @@ public class GeoServcieManagerImpl implements GeoService { } return fences; } catch (RegistryException | IOException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Error occurred while getting the geo alerts for " + identifier.getType() + " with id: " + identifier.getId(), e); } } @Override - public List getExitAlerts(DeviceIdentifier identifier) throws GeoServiceException { + public List getExitAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException { Registry registry = getGovernanceRegistry(); String registryPath = GeoServices.REGISTRY_PATH_FOR_ALERTS + @@ -199,7 +199,7 @@ public class GeoServcieManagerImpl implements GeoService { } return fences; } catch (RegistryException | IOException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Error occurred while getting the geo alerts for " + identifier.getType() + " with id: " + identifier.getId(), e); } @@ -207,18 +207,18 @@ public class GeoServcieManagerImpl implements GeoService { @Override public boolean createGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType) - throws GeoServiceException { + throws GeoLocationBasedServiceException { return saveGeoAlert(alert, identifier, alertType, false); } @Override public boolean updateGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType) - throws GeoServiceException { + throws GeoLocationBasedServiceException { return saveGeoAlert(alert, identifier, alertType, true); } public boolean saveGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType, boolean isUpdate) - throws GeoServiceException { + throws GeoLocationBasedServiceException { Type type = new TypeToken>() { }.getType(); @@ -256,7 +256,7 @@ public class GeoServcieManagerImpl implements GeoService { } else if (GeoServices.ALERT_TYPE_TRAFFIC.equals(alertType)) { content = parseMap.get(GeoServices.GEO_FENCE_GEO_JSON); } else { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Unrecognized execution plan type: " + alertType + " while creating geo alert"); } @@ -288,24 +288,24 @@ public class GeoServcieManagerImpl implements GeoService { } else { log.error("Execution plan validation failed: " + validationResponse); } - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Error occurred while " + action + " geo " + alertType + " alert for " + identifier.getType() + " with id: " + identifier.getId()); } return true; } catch (AxisFault axisFault) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Event processor admin service initialization failed while " + action + " geo alert '" + alertType + "' for " + identifier.getType() + " " + "device with id: " + identifier.getId(), axisFault ); } catch (IOException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Event processor admin service failed while " + action + " geo alert '" + alertType + "' for " + identifier.getType() + " " + "device with id: " + identifier.getId(), e); } catch (JWTClientException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "JWT token creation failed while " + action + " geo alert '" + alertType + "' for " + identifier.getType() + " device with id:" + identifier.getId(), e); } finally { @@ -314,7 +314,7 @@ public class GeoServcieManagerImpl implements GeoService { } private String getRegistryPath(String alertType, DeviceIdentifier identifier, String queryName) - throws GeoServiceException { + throws GeoLocationBasedServiceException { String path = ""; if (GeoServices.ALERT_TYPE_WITHIN.equals(alertType)) { path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_WITHIN + @@ -335,7 +335,7 @@ public class GeoServcieManagerImpl implements GeoService { path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_TRAFFIC + "/" + identifier.getId() + "/" + queryName; } else { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Unrecognized execution plan type: " + alertType); } return path; @@ -351,7 +351,7 @@ public class GeoServcieManagerImpl implements GeoService { @Override public boolean removeGeoAlert(String alertType, DeviceIdentifier identifier, String queryName) - throws GeoServiceException { + throws GeoLocationBasedServiceException { removeFromRegistry(alertType, identifier, queryName); String executionPlanName = getExecutionPlanName(alertType, queryName, identifier.getId()); EventProcessorAdminServiceStub eventprocessorStub = null; @@ -360,14 +360,14 @@ public class GeoServcieManagerImpl implements GeoService { eventprocessorStub.undeployActiveExecutionPlan(executionPlanName); return true; } catch (IOException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Event processor admin service stub invocation failed while removing geo alert '" + alertType + "': " + executionPlanName + " for " + identifier.getType() + " device with id:" + identifier.getId(), e ); } catch (JWTClientException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "JWT token creation failed while removing geo alert '" + alertType + "': " + executionPlanName + " for " + identifier.getType() + " device with id:" + identifier.getId(), e @@ -378,13 +378,13 @@ public class GeoServcieManagerImpl implements GeoService { } private void removeFromRegistry(String alertType, DeviceIdentifier identifier, String queryName) - throws GeoServiceException { + throws GeoLocationBasedServiceException { String path = "unknown"; try { path = getRegistryPath(alertType, identifier, queryName); getGovernanceRegistry().delete(path); } catch (RegistryException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Error occurred while removing " + alertType + " alert for " + identifier.getType() + " device with id:" + identifier.getId() + " from the path: " + path); } @@ -437,7 +437,7 @@ public class GeoServcieManagerImpl implements GeoService { } @Override - public String getSpeedAlerts(DeviceIdentifier identifier) throws GeoServiceException { + public String getSpeedAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException { try { Registry registry = getGovernanceRegistry(); Resource resource = registry.get(GeoServices.REGISTRY_PATH_FOR_ALERTS + @@ -455,7 +455,7 @@ public class GeoServcieManagerImpl implements GeoService { } @Override - public String getProximityAlerts(DeviceIdentifier identifier) throws GeoServiceException { + public String getProximityAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException { try { Registry registry = getGovernanceRegistry(); Resource resource = registry.get(GeoServices.REGISTRY_PATH_FOR_ALERTS + @@ -479,7 +479,7 @@ public class GeoServcieManagerImpl implements GeoService { } @Override - public List getStationaryAlerts(DeviceIdentifier identifier) throws GeoServiceException { + public List getStationaryAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException { Registry registry = getGovernanceRegistry(); String registryPath = GeoServices.REGISTRY_PATH_FOR_ALERTS + @@ -524,14 +524,14 @@ public class GeoServcieManagerImpl implements GeoService { } return fences; } catch (RegistryException | IOException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Error occurred while getting the geo alerts for " + identifier.getType() + " with id: " + identifier.getId(), e); } } @Override - public List getTrafficAlerts(DeviceIdentifier identifier) throws GeoServiceException { + public List getTrafficAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException { Registry registry = getGovernanceRegistry(); String registryPath = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_STATIONARY + "/" + identifier.getId() + "/"; @@ -571,30 +571,31 @@ public class GeoServcieManagerImpl implements GeoService { } return fences; } catch (RegistryException | IOException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Error occurred while getting the geo alerts for " + identifier.getType() + " with id: " + identifier.getId(), e); } } - private Registry getGovernanceRegistry() throws GeoServiceException { + private Registry getGovernanceRegistry() throws GeoLocationBasedServiceException { try { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); return DeviceManagementDataHolder.getInstance().getRegistryService() .getGovernanceSystemRegistry( tenantId); } catch (RegistryException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Error in retrieving governance registry instance: " + e.getMessage(), e); } } - private String parseTemplate(String alertType, Map parseMap) throws GeoServiceException { + private String parseTemplate(String alertType, Map parseMap) throws + GeoLocationBasedServiceException { String templatePath = "alerts/Geo-ExecutionPlan-" + alertType + "_alert.siddhiql"; InputStream resource = getClass().getClassLoader().getResourceAsStream(templatePath); if (resource == null) { - throw new GeoServiceException("Could not find template in path : " + templatePath); + throw new GeoLocationBasedServiceException("Could not find template in path : " + templatePath); } try { //Read template @@ -606,13 +607,13 @@ public class GeoServcieManagerImpl implements GeoService { } return template; } catch (IOException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Error occurred while populating the template for the Within Alert", e); } } private void updateRegistry(String path, DeviceIdentifier identifier, Object content, Map options) - throws GeoServiceException { + throws GeoLocationBasedServiceException { try { Registry registry = getGovernanceRegistry(); @@ -624,7 +625,7 @@ public class GeoServcieManagerImpl implements GeoService { } registry.put(path, newResource); } catch (RegistryException e) { - throw new GeoServiceException( + throw new GeoLocationBasedServiceException( "Error occurred while setting the Within Alert for " + identifier.getType() + " with id: " + identifier.getId(), e); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index 32e9e978e1..0c45b6ffda 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -25,7 +25,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; -import org.wso2.carbon.device.mgt.common.geo.service.GeoService; +import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; @@ -45,7 +45,7 @@ import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.device.mgt.core.config.tenant.PlatformConfigurationManagementServiceImpl; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.GroupManagementDAOFactory; -import org.wso2.carbon.device.mgt.core.geo.service.GeoServcieManagerImpl; +import org.wso2.carbon.device.mgt.core.geo.service.GeoLocationProviderServiceImpl; import org.wso2.carbon.device.mgt.core.notification.mgt.NotificationManagementServiceImpl; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; @@ -289,8 +289,8 @@ public class DeviceManagementServiceComponent { deviceAccessAuthorizationService, null); /* Registering Geo Service */ - GeoService geoService = new GeoServcieManagerImpl(); - bundleContext.registerService(GeoService.class.getName(), geoService, null); + GeoLocationProviderService geoService = new GeoLocationProviderServiceImpl(); + bundleContext.registerService(GeoLocationProviderService.class.getName(), geoService, null); /* Registering App Management service */ try { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 2e85a4798b..55d73af4f6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -149,7 +149,8 @@ "perm:device-types:events:view", "perm:admin:device-type", "perm:device:enroll", - "perm:geo-service:analytics" + "perm:geo-service:analytics-view", + "perm:geo-service:alerts-manage" ], "isOAuthEnabled": true, "backendRestEndpoints": {