Fix invalid DAO factory handling & invalid event revoke payload

feature/traccar-sync
Pahansith Gunathilake 3 years ago
parent 02e0129d25
commit 27303cf12b

@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.event.config.EventConfig; import org.wso2.carbon.device.mgt.common.event.config.EventConfig;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.EventManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.EventManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.EventManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.impl.AbstractEventConfigDAO; import org.wso2.carbon.device.mgt.core.dao.impl.AbstractEventConfigDAO;
import java.sql.Connection; import java.sql.Connection;
@ -75,6 +76,6 @@ public class H2EventConfigDAOImpl extends AbstractEventConfigDAO {
} }
private Connection getConnection() throws SQLException { private Connection getConnection() throws SQLException {
return DeviceManagementDAOFactory.getConnection(); return EventManagementDAOFactory.getConnection();
} }
} }

@ -132,7 +132,10 @@ public class EventOperationExecutor implements Runnable {
EventRevokeOperation eventRevokeOperation = new EventRevokeOperation(); EventRevokeOperation eventRevokeOperation = new EventRevokeOperation();
eventRevokeOperation.setEventSource(eventSource); eventRevokeOperation.setEventSource(eventSource);
eventRevokeOperation.setId(geoFenceMeta.getId()); eventRevokeOperation.setId(geoFenceMeta.getId());
operation.setPayLoad(new Gson().toJson(eventRevokeOperation));
List<EventRevokeOperation> eventOperationsRevoke = new ArrayList<>();
eventOperationsRevoke.add(eventRevokeOperation);
operation.setPayLoad(new Gson().toJson(eventOperationsRevoke));
} }
@Override @Override

@ -1507,7 +1507,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
geofenceDAO.deleteGeofenceGroupMapping(groupIdsOfGeoFence, fenceId); geofenceDAO.deleteGeofenceGroupMapping(groupIdsOfGeoFence, fenceId);
} }
geofenceDAO.deleteGeofenceById(fenceId); geofenceDAO.deleteGeofenceById(fenceId);
DeviceManagementDAOFactory.commitTransaction(); EventManagementDAOFactory.commitTransaction();
GeoCacheManagerImpl.getInstance().removeFenceFromCache(fenceId, tenantId); GeoCacheManagerImpl.getInstance().removeFenceFromCache(fenceId, tenantId);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
EventManagementDAOFactory.rollbackTransaction(); EventManagementDAOFactory.rollbackTransaction();
@ -1571,7 +1571,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.closeConnection(); EventManagementDAOFactory.closeConnection();
} }
return true; return true;
} }
@ -1772,12 +1772,9 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
DeviceManagementConstants.EventServices.GEOFENCE, new GeoFenceEventMeta(geofenceData), DeviceManagementConstants.EventServices.GEOFENCE, new GeoFenceEventMeta(geofenceData),
tenantId, geofenceData.getGroupIds()); tenantId, geofenceData.getGroupIds());
} catch (EventConfigurationException e) { } catch (EventConfigurationException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Failed to delete Geofence event configurations"; String msg = "Failed to delete Geofence event configurations";
log.error(msg, e); log.error(msg, e);
throw new GeoLocationBasedServiceException(msg, e); throw new GeoLocationBasedServiceException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
} }
} }
} }

Loading…
Cancel
Save