|
|
|
@ -27,8 +27,12 @@ import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationProviderService;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.geo.service.*;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.core.cache.impl.GeoCacheManagerImpl;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory;
|
|
|
|
@ -134,7 +138,8 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<GeoFence> getWithinAlerts(DeviceIdentifier identifier, String owner) throws GeoLocationBasedServiceException {
|
|
|
|
|
public List<GeoFence> getWithinAlerts(DeviceIdentifier identifier, String owner) throws
|
|
|
|
|
GeoLocationBasedServiceException, MetadataManagementException {
|
|
|
|
|
|
|
|
|
|
Registry registry = getGovernanceRegistry();
|
|
|
|
|
String registryPath = GeoServices.REGISTRY_PATH_FOR_ALERTS +
|
|
|
|
@ -147,9 +152,22 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MetadataManagementService metadataManagementService = DeviceManagementDataHolder.getInstance().getMetadataManagementService();
|
|
|
|
|
Metadata metaData = metadataManagementService.retrieveMetadata(registryPath);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
List<GeoFence> fences = new ArrayList<>();
|
|
|
|
|
if (resource != null) {
|
|
|
|
|
if (metaData != null) {
|
|
|
|
|
String[] metaValues = metaData.getMetaValue().split(":");
|
|
|
|
|
|
|
|
|
|
for (String res : metaValues) {
|
|
|
|
|
Metadata childMeta = metadataManagementService.retrieveMetadata(registryPath);
|
|
|
|
|
|
|
|
|
|
GeoFence geoFence = new GeoFence();
|
|
|
|
|
|
|
|
|
|
fences.add(geoFence);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Object contentObj = resource.getContent();
|
|
|
|
|
if (contentObj instanceof String[]) {
|
|
|
|
|
String[] content = (String[]) contentObj;
|
|
|
|
@ -1135,6 +1153,21 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
|
"Error occurred while setting the Within Alert for " + identifier.getType() + " with id: " +
|
|
|
|
|
identifier.getId(), e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Metadata metaData = new Metadata();
|
|
|
|
|
// metaData.setMetaKey(identifier);
|
|
|
|
|
String metaValue = path;
|
|
|
|
|
metaData.setMetaValue(metaValue);
|
|
|
|
|
|
|
|
|
|
MetadataManagementService metadataManagementService = DeviceManagementDataHolder.getInstance().getMetadataManagementService();
|
|
|
|
|
try {
|
|
|
|
|
metadataManagementService.updateMetadata(metaData);
|
|
|
|
|
} catch (MetadataManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating meta data for meta key: " + path;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new GeoLocationBasedServiceException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateRegistry(String path, Object content, Map<String, String> options)
|
|
|
|
|