Fix code review comments

geo-eventRevoke-fix
Waruni Sandareka 2 months ago
parent a0451f1f49
commit dcb4ccb87f

@ -1,30 +0,0 @@
<!--
~ Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
~
~ Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>maven-snapshots</id>
<username>${env.MAVEN_REPO_USER}</username>
<password>${env.MAVEN_REPO_PASS}</password>
</server>
</servers>
</settings>

@ -72,13 +72,6 @@ public interface EventConfigurationProviderService {
*/
void deleteEvents(List<EventConfig> eventList) throws EventConfigurationException;
/**
*
* @param groupIdsToDelete group list to be deleted
* @throws EventConfigurationException error thrown while deleting group records
*/
void deleteGroups(List<Integer> groupIdsToDelete) throws EventConfigurationException;
/**
* Create event operation and add them into the corresponding devices
* @param eventType EVENT_REVOKE / EVENT_CONFIG

@ -239,27 +239,6 @@ public class EventConfigurationProviderServiceImpl implements EventConfiguration
throw new EventConfigurationException(msg, e);
}
}
@Override
public void deleteGroups(List<Integer> groupIdsToDelete) throws EventConfigurationException {
try {
EventManagementDAOFactory.beginTransaction();
if (!groupIdsToDelete.isEmpty()) {
eventConfigDAO.deleteEventGroupMappingRecordsByGroupIds(groupIdsToDelete);
}
EventManagementDAOFactory.commitTransaction();
} catch (TransactionManagementException e) {
String msg = "Failed to start/open transaction to delete device event configurations";
log.error(msg, e);
throw new EventConfigurationException(msg, e);
} catch (EventManagementDAOException e) {
EventManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while deleting event records";
log.error(msg, e);
throw new EventConfigurationException(msg, e);
}
}
@Override
public void createEventOperationTask(String eventType, String eventCode, EventMetaData eventMeta, int tenantId,

@ -1529,6 +1529,9 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
public boolean updateGeofence(GeofenceData geofenceData, int fenceId)
throws GeoLocationBasedServiceException {
EventConfigurationProviderService eventConfigService;
eventConfigService = DeviceManagementDataHolder.getInstance().getEventConfigurationService();
int tenantId;
List<Integer> groupIdsToDelete = new ArrayList<>();
List<Integer> groupIdsToAdd = new ArrayList<>();
@ -1560,6 +1563,18 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
geofenceDAO.deleteGeofenceGroupMapping(groupIdsToDelete, fenceId);
geofenceDAO.createGeofenceGroupMapping(geofenceData, groupIdsToAdd);
EventManagementDAOFactory.commitTransaction();
try {
if (!groupIdsToDelete.isEmpty()) {
eventConfigService.createEventOperationTask(OperationMgtConstants.OperationCodes.EVENT_REVOKE,
DeviceManagementConstants.EventServices.GEOFENCE,
new GeoFenceEventMeta(geofenceData), tenantId, groupIdsToDelete);
}
} catch (EventConfigurationException e) {
String msg = "Failed while creating EVENT_REVOKE operation creation task entry while updating geo fence "
+ geofenceData.getFenceName() + " of the tenant " + tenantId;
log.error(msg, e);
throw new GeoLocationBasedServiceException(msg, e);
}
if (updatedRowCount > 0) {
GeoCacheManagerImpl.getInstance().updateGeoFenceInCache(geofenceData, fenceId, tenantId);
}
@ -1575,10 +1590,6 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
} finally {
EventManagementDAOFactory.closeConnection();
}
if (!groupIdsToDelete.isEmpty()) {
this.deleteGeoFenceGroups(geofenceData, groupIdsToDelete);
}
return true;
}
@ -1809,37 +1820,4 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
throw new GeoLocationBasedServiceException(msg, e);
}
}
/**
*
* @param geofenceData
* @param groupIdsToDelete
* @throws GeoLocationBasedServiceException
*/
private void deleteGeoFenceGroups(GeofenceData geofenceData, List<Integer> groupIdsToDelete)
throws GeoLocationBasedServiceException {
int tenantId;
try {
tenantId = DeviceManagementDAOUtil.getTenantId();
} catch (DeviceManagementDAOException e) {
String msg = "Error occurred while retrieving tenant id while get geofence data";
log.error(msg, e);
throw new GeoLocationBasedServiceException(msg, e);
}
try {
EventConfigurationProviderService eventConfigService = DeviceManagementDataHolder
.getInstance().getEventConfigurationService();
eventConfigService.deleteGroups(groupIdsToDelete);
eventConfigService.createEventOperationTask(OperationMgtConstants.OperationCodes.EVENT_REVOKE,
DeviceManagementConstants.EventServices.GEOFENCE, new GeoFenceEventMeta(geofenceData),
tenantId, groupIdsToDelete);
} catch (EventConfigurationException e) {
String msg = "Failed to delete Geofence event configurations";
log.error(msg, e);
throw new GeoLocationBasedServiceException(msg, e);
}
}
}

Loading…
Cancel
Save