mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Exception name change and minor modifications
This commit is contained in:
parent
46dbbdbcb8
commit
c0024ce26f
@ -178,7 +178,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
|
||||
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();
|
||||
} catch (AlertAlreadyExist e) {
|
||||
} catch (AlertAlreadyExistException e) {
|
||||
String error = "A geo alert with this name already exists.";
|
||||
log.error(error,e);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
|
||||
@ -215,7 +215,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
|
||||
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();
|
||||
} catch (AlertAlreadyExist e) {
|
||||
} catch (AlertAlreadyExistException e) {
|
||||
String error = "A geo alert with this name already exists.";
|
||||
log.error(error,e);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
|
||||
|
||||
@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.common.geo.service;
|
||||
* Custom exception class for geo alert definition operations.
|
||||
*/
|
||||
|
||||
public class AlertAlreadyExist extends Exception {
|
||||
public class AlertAlreadyExistException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 4709355511911265093L;
|
||||
private String errorMessage;
|
||||
@ -34,7 +34,7 @@ public class AlertAlreadyExist extends Exception {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public AlertAlreadyExist(String msg) {
|
||||
public AlertAlreadyExistException(String msg) {
|
||||
super(msg);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
@ -33,10 +33,10 @@ public interface GeoLocationProviderService {
|
||||
List<GeoFence> getExitAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException;
|
||||
|
||||
boolean createGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
|
||||
throws GeoLocationBasedServiceException, AlertAlreadyExist;
|
||||
throws GeoLocationBasedServiceException, AlertAlreadyExistException;
|
||||
|
||||
boolean updateGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
|
||||
throws GeoLocationBasedServiceException, AlertAlreadyExist;
|
||||
throws GeoLocationBasedServiceException, AlertAlreadyExistException;
|
||||
|
||||
boolean removeGeoAlert(String alertType, DeviceIdentifier identifier, String queryName)
|
||||
throws GeoLocationBasedServiceException;
|
||||
|
||||
@ -41,7 +41,7 @@ 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.GeoLocationProviderService;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExist;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException;
|
||||
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;
|
||||
@ -208,18 +208,18 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
||||
|
||||
@Override
|
||||
public boolean createGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
|
||||
throws GeoLocationBasedServiceException, AlertAlreadyExist {
|
||||
throws GeoLocationBasedServiceException, AlertAlreadyExistException {
|
||||
return saveGeoAlert(alert, identifier, alertType, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
|
||||
throws GeoLocationBasedServiceException, AlertAlreadyExist {
|
||||
throws GeoLocationBasedServiceException, AlertAlreadyExistException {
|
||||
return saveGeoAlert(alert, identifier, alertType, true);
|
||||
}
|
||||
|
||||
public boolean saveGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType, boolean isUpdate)
|
||||
throws GeoLocationBasedServiceException, AlertAlreadyExist {
|
||||
throws GeoLocationBasedServiceException, AlertAlreadyExistException {
|
||||
|
||||
Type type = new TypeToken<Map<String, String>>() {
|
||||
}.getType();
|
||||
@ -278,7 +278,8 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
||||
try {
|
||||
existingPlanName = eventprocessorStub.getActiveExecutionPlan(executionPlanName);
|
||||
if (existingPlanName.contains(executionPlanName)) {
|
||||
throw new AlertAlreadyExist("Execution plan with this name already exists");
|
||||
throw new AlertAlreadyExistException("Execution plan already exists with name "
|
||||
+ executionPlanName);
|
||||
}
|
||||
} catch (AxisFault axisFault) {
|
||||
updateRegistry(getRegistryPath(alertType, identifier, alert.getQueryName()), identifier, content,
|
||||
|
||||
@ -32,7 +32,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
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.GeoLocationBasedServiceException;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExist;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException;
|
||||
import org.wso2.carbon.device.mgt.core.TestDeviceManagementService;
|
||||
import org.wso2.carbon.device.mgt.core.common.TestDataHolder;
|
||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||
@ -67,42 +67,42 @@ public class GeoLocationProviderServiceTest {
|
||||
}
|
||||
|
||||
@Test (description = "Create a sample geo exit-alert with relevant details.")
|
||||
public void createGeoExitAlert() throws GeoLocationBasedServiceException, AlertAlreadyExist {
|
||||
public void createGeoExitAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
|
||||
Boolean result = geoLocationProviderServiceImpl.
|
||||
createGeoAlert(getExitAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_EXIT);
|
||||
Assert.assertEquals(result, Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test (description = "Create a sample geo within-alert with relevant details.")
|
||||
public void createGeoWithinAlert() throws GeoLocationBasedServiceException, AlertAlreadyExist {
|
||||
public void createGeoWithinAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
|
||||
Boolean result = geoLocationProviderServiceImpl.
|
||||
createGeoAlert(getWithinAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_WITHIN);
|
||||
Assert.assertEquals(result, Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test (description = "Create a sample geo proximity-alert with relevant details.")
|
||||
public void createGeoProximityAlert() throws GeoLocationBasedServiceException, AlertAlreadyExist {
|
||||
public void createGeoProximityAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
|
||||
Boolean result = geoLocationProviderServiceImpl.
|
||||
createGeoAlert(getProximityAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_PROXIMITY);
|
||||
Assert.assertEquals(result, Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test (description = "Create a sample geo speed-alert with relevant details.")
|
||||
public void createGeoSpeedAlert() throws GeoLocationBasedServiceException, AlertAlreadyExist {
|
||||
public void createGeoSpeedAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
|
||||
Boolean result = geoLocationProviderServiceImpl.
|
||||
createGeoAlert(getSpeedAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_SPEED);
|
||||
Assert.assertEquals(result, Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test (description = "Create a sample geo stationary-alert with relevant details.")
|
||||
public void createGeoStationaryAlert() throws GeoLocationBasedServiceException, AlertAlreadyExist {
|
||||
public void createGeoStationaryAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
|
||||
Boolean result = geoLocationProviderServiceImpl.
|
||||
createGeoAlert(getStationaryAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_STATIONARY);
|
||||
Assert.assertEquals(result, Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test (description = "Create a sample geo traffic-alert with relevant details.")
|
||||
public void createGeoTrafficAlert() throws GeoLocationBasedServiceException, AlertAlreadyExist {
|
||||
public void createGeoTrafficAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
|
||||
Boolean result = geoLocationProviderServiceImpl.
|
||||
createGeoAlert(getTrafficAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_TRAFFIC);
|
||||
Assert.assertEquals(result, Boolean.TRUE);
|
||||
|
||||
@ -178,7 +178,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
|
||||
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();
|
||||
} catch (AlertAlreadyExist e) {
|
||||
} catch (AlertAlreadyExistException e) {
|
||||
String error = "A geo alert with this name already exists.";
|
||||
log.error(error,e);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
|
||||
@ -215,7 +215,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
|
||||
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();
|
||||
} catch (AlertAlreadyExist e) {
|
||||
} catch (AlertAlreadyExistException e) {
|
||||
String error = "A geo alert with this name already exists.";
|
||||
log.error(error,e);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user