From 726a70052857c0bf7ba78ee75ff5a3c81c97e850 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 30 May 2016 11:45:02 +0530 Subject: [PATCH] Improving error handling in checking for monitoring frquency --- .../mgt/jaxrs/service/impl/ConfigurationServiceImpl.java | 3 ++- .../wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ConfigurationServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ConfigurationServiceImpl.java index 067b0c42690..177f87c9d08 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ConfigurationServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ConfigurationServiceImpl.java @@ -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.util.DeviceMgtAPIUtils; 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 javax.ws.rs.GET; @@ -59,7 +60,7 @@ public class ConfigurationServiceImpl implements ConfigurationManagementService configList.add(configurationEntry); config.setConfiguration(configList); return Response.status(Response.Status.OK).entity(config).build(); - } catch (ConfigurationManagementException e) { + } catch (ConfigurationManagementException | PolicyManagementException e) { msg = "ErrorResponse occurred while retrieving the configurations."; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java index c4ff1d8db89..b233ed85528 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java @@ -196,7 +196,7 @@ public class PolicyManagerUtil { } - public static int getMonitoringFequency() { + public static int getMonitoringFequency() throws PolicyManagementException { PlatformConfigurationManagementService configMgtService = new TenantConfigurationManagementServiceImpl(); PlatformConfiguration tenantConfiguration; @@ -209,7 +209,8 @@ public class PolicyManagerUtil { for (ConfigurationEntry cEntry : configuration) { if (cEntry.getName().equalsIgnoreCase(MONITORING_FREQUENCY)) { 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()); }