Merge branch 'corrective-policy' into 'corrective-policy'

Fix geo fence deleting issue

See merge request entgra/carbon-device-mgt!659
corrective-policy
Dharmakeerthi Lasantha 4 years ago
commit c67b041fb2

@ -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",

@ -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();

@ -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();
}
}

Loading…
Cancel
Save