diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java index 21747fc774b..d0e87c6c402 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java @@ -48,6 +48,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @SwaggerDefinition( @@ -972,8 +973,7 @@ public interface GeoLocationBasedService { @DELETE @Path("/geo-fence/{fenceId}") @ApiOperation( - consumes = "application/json", - produces = "application/json", + consumes = MediaType.APPLICATION_JSON, httpMethod = "DELETE", value = "Delete Geo fence", notes = "Delete an existing geo fence", 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 c854e809584..726afa5129a 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 @@ -678,10 +678,9 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { } - @Path("/geo-fence/{fenceId}") @DELETE - @Consumes("application/json") - @Produces("application/json") + @Override + @Path("/geo-fence/{fenceId}") public Response deleteGeofence(@PathParam("fenceId") int fenceId) { try { GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java index 080e729fc23..d54818ca9c8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java @@ -1327,7 +1327,12 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic public boolean deleteGeofenceData(int fenceId) throws GeoLocationBasedServiceException { try { DeviceManagementDAOFactory.beginTransaction(); - return geofenceDAO.deleteGeofenceById(fenceId) > 0; + if (geofenceDAO.deleteGeofenceById(fenceId) > 0) { + DeviceManagementDAOFactory.commitTransaction(); + return true; + } + DeviceManagementDAOFactory.rollbackTransaction(); + return false; } catch (DeviceManagementDAOException e) { String msg = "Error occurred while deleting geofence"; log.error(msg, e); @@ -1337,7 +1342,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic log.error(msg, e); throw new GeoLocationBasedServiceException(msg, e); } finally { - DeviceManagementDAOFactory.commitTransaction(); + DeviceManagementDAOFactory.closeConnection(); } }