Fix geo fence deleting issue

corrective-policy
tcdlpds@gmail.com 4 years ago
parent 1736a6372a
commit a0b882f755

@ -48,6 +48,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@SwaggerDefinition( @SwaggerDefinition(
@ -972,8 +973,7 @@ public interface GeoLocationBasedService {
@DELETE @DELETE
@Path("/geo-fence/{fenceId}") @Path("/geo-fence/{fenceId}")
@ApiOperation( @ApiOperation(
consumes = "application/json", consumes = MediaType.APPLICATION_JSON,
produces = "application/json",
httpMethod = "DELETE", httpMethod = "DELETE",
value = "Delete Geo fence", value = "Delete Geo fence",
notes = "Delete an existing geo fence", notes = "Delete an existing geo fence",

@ -678,10 +678,9 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
} }
@Path("/geo-fence/{fenceId}")
@DELETE @DELETE
@Consumes("application/json") @Override
@Produces("application/json") @Path("/geo-fence/{fenceId}")
public Response deleteGeofence(@PathParam("fenceId") int fenceId) { public Response deleteGeofence(@PathParam("fenceId") int fenceId) {
try { try {
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();

@ -1327,7 +1327,12 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
public boolean deleteGeofenceData(int fenceId) throws GeoLocationBasedServiceException { public boolean deleteGeofenceData(int fenceId) throws GeoLocationBasedServiceException {
try { try {
DeviceManagementDAOFactory.beginTransaction(); DeviceManagementDAOFactory.beginTransaction();
return geofenceDAO.deleteGeofenceById(fenceId) > 0; if (geofenceDAO.deleteGeofenceById(fenceId) > 0) {
DeviceManagementDAOFactory.commitTransaction();
return true;
}
DeviceManagementDAOFactory.rollbackTransaction();
return false;
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
String msg = "Error occurred while deleting geofence"; String msg = "Error occurred while deleting geofence";
log.error(msg, e); log.error(msg, e);
@ -1337,7 +1342,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
log.error(msg, e); log.error(msg, e);
throw new GeoLocationBasedServiceException(msg, e); throw new GeoLocationBasedServiceException(msg, e);
} finally { } finally {
DeviceManagementDAOFactory.commitTransaction(); DeviceManagementDAOFactory.closeConnection();
} }
} }

Loading…
Cancel
Save