mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Improving error handling in checking for monitoring frquency
This commit is contained in:
parent
6e5148a374
commit
726a700528
@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration
|
|||||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.ConfigurationManagementService;
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.ConfigurationManagementService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.MDMAppConstants;
|
import org.wso2.carbon.device.mgt.jaxrs.util.MDMAppConstants;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;
|
import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;
|
||||||
|
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
@ -59,7 +60,7 @@ public class ConfigurationServiceImpl implements ConfigurationManagementService
|
|||||||
configList.add(configurationEntry);
|
configList.add(configurationEntry);
|
||||||
config.setConfiguration(configList);
|
config.setConfiguration(configList);
|
||||||
return Response.status(Response.Status.OK).entity(config).build();
|
return Response.status(Response.Status.OK).entity(config).build();
|
||||||
} catch (ConfigurationManagementException e) {
|
} catch (ConfigurationManagementException | PolicyManagementException e) {
|
||||||
msg = "ErrorResponse occurred while retrieving the configurations.";
|
msg = "ErrorResponse occurred while retrieving the configurations.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
|
|||||||
@ -196,7 +196,7 @@ public class PolicyManagerUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int getMonitoringFequency() {
|
public static int getMonitoringFequency() throws PolicyManagementException {
|
||||||
|
|
||||||
PlatformConfigurationManagementService configMgtService = new TenantConfigurationManagementServiceImpl();
|
PlatformConfigurationManagementService configMgtService = new TenantConfigurationManagementServiceImpl();
|
||||||
PlatformConfiguration tenantConfiguration;
|
PlatformConfiguration tenantConfiguration;
|
||||||
@ -209,7 +209,8 @@ public class PolicyManagerUtil {
|
|||||||
for (ConfigurationEntry cEntry : configuration) {
|
for (ConfigurationEntry cEntry : configuration) {
|
||||||
if (cEntry.getName().equalsIgnoreCase(MONITORING_FREQUENCY)) {
|
if (cEntry.getName().equalsIgnoreCase(MONITORING_FREQUENCY)) {
|
||||||
if (cEntry.getValue() == null) {
|
if (cEntry.getValue() == null) {
|
||||||
throw new PolicyManagementException("Invalid ")
|
throw new PolicyManagementException("Invalid value, i.e. '" + cEntry.getValue() +
|
||||||
|
"', is configured as the monitoring frequency");
|
||||||
}
|
}
|
||||||
monitoringFrequency = Integer.parseInt(cEntry.getValue().toString());
|
monitoringFrequency = Integer.parseInt(cEntry.getValue().toString());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user