From 45bfadb657a492817af7cecb7e21b2873538860e Mon Sep 17 00:00:00 2001 From: inoshperera Date: Thu, 30 Apr 2020 07:17:50 +0530 Subject: [PATCH] Adding missed error throwing --- .../impl/util/RequestValidationUtil.java | 24 ++++++++++++++----- .../mgt/common/PolicyPayloadValidator.java | 18 ++++++++++++++ .../policy/mgt/common/ProfileFeature.java | 5 ++-- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java index cc027fc5a8..ca60d6fa61 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java @@ -316,14 +316,26 @@ public class RequestValidationUtil { log.error("No policy validator found for device type " + deviceType); } } catch (InstantiationException e) { - log.error("Error when creating an instance of validator related to deviceType " + - deviceType); + String msg = "Error when creating an instance of validator related to deviceType " + + deviceType; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(msg).build + ()); } catch (IllegalAccessException e) { - log.error("Error when accessing an instance of validator related to deviceType " + - deviceType); + String msg = "Error when accessing an instance of validator related to deviceType " + + deviceType; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(msg).build + ()); } catch (ClassNotFoundException e) { - log.error("Error when loading an instance of validator related to deviceType " + - deviceType); + String msg ="Error when loading an instance of validator related to deviceType " + + deviceType; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(msg).build + ()); } return null; } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyPayloadValidator.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyPayloadValidator.java index 45b91c9b05..37ba5a3eaf 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyPayloadValidator.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyPayloadValidator.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ package org.wso2.carbon.policy.mgt.common; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/ProfileFeature.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/ProfileFeature.java index 1040e8b771..bf7c1f7063 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/ProfileFeature.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/ProfileFeature.java @@ -1,7 +1,7 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at @@ -14,6 +14,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ package org.wso2.carbon.policy.mgt.common;