Fix invalid DAO factory handling & invalid event revoke payload

temp
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.core.dao.DeviceManagementDAOFactory;
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 java.sql.Connection;
@ -75,6 +76,6 @@ public class H2EventConfigDAOImpl extends AbstractEventConfigDAO {
}
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.setEventSource(eventSource);
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

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

Loading…
Cancel
Save