mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Improve code
This commit is contained in:
parent
9c362eabf0
commit
206f433a9f
@ -181,23 +181,23 @@ public class PolicyManagerUtil {
|
||||
private static void transformGeoFencePolicy(List<ProfileFeature> effectiveFeatures,
|
||||
PolicyOperation policyOperation, Policy policy) throws PolicyTransformException {
|
||||
String payload = null;
|
||||
int fenceId = -1;
|
||||
for (ProfileFeature effectiveFeature : effectiveFeatures) {
|
||||
if (effectiveFeature.getFeatureCode().equals(PolicyManagementConstants.GEOFENCE_POLICY)) {
|
||||
payload = effectiveFeature.getContent().toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (payload != null) {
|
||||
for (ProfileOperation profileOperation : policyOperation.getProfileOperations()) {
|
||||
int fenceId = -1;
|
||||
try {
|
||||
if (profileOperation.getCode().equals(PolicyManagementConstants.GEOFENCE_POLICY)) {
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
if (payload != null) {
|
||||
JsonElement parsedPayload = jsonParser.parse(payload);
|
||||
JsonObject jsonPayload = parsedPayload.getAsJsonObject();
|
||||
GeoLocationProviderServiceImpl geoLocationProviderService = new GeoLocationProviderServiceImpl();
|
||||
if (jsonPayload.get("fenceId") == null) {
|
||||
String msg = "No valid fence Id found in operation payload";
|
||||
String msg = "No valid fence Id found in saved policy payload";
|
||||
log.error(msg);
|
||||
throw new PolicyTransformException(msg);
|
||||
}
|
||||
@ -216,7 +216,6 @@ public class PolicyManagerUtil {
|
||||
profileOperation.setPayLoad(operationPayload.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (GeoLocationBasedServiceException e) {
|
||||
String msg = "Error occurred while retrieving geofence with fence Id " + fenceId
|
||||
+ " for the policy with Id "+policy.getId();
|
||||
@ -224,6 +223,12 @@ public class PolicyManagerUtil {
|
||||
throw new PolicyTransformException(msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
String msg = "No Geofence feature attached with the policy " + policy.getId();
|
||||
log.debug(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user