Improving error handling in checking for monitoring frquency

4.x.x
prabathabey 9 years ago
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.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();

@ -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());
}

Loading…
Cancel
Save