From 0c43338f5db1923eae12c7ad373275024ee9fb2d Mon Sep 17 00:00:00 2001 From: mharindu Date: Wed, 2 Sep 2015 16:16:18 +0530 Subject: [PATCH] Added runtime exception to DCA --- .../carbon/device/mgt/common/EnrolmentInfo.java | 13 ++++++------- .../extension/DynamicClientRegistrationUtil.java | 6 +++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EnrolmentInfo.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EnrolmentInfo.java index a21aa44b91..7b3ff89d1f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EnrolmentInfo.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EnrolmentInfo.java @@ -20,7 +20,7 @@ package org.wso2.carbon.device.mgt.common; import java.io.Serializable; -public class EnrolmentInfo implements Serializable{ +public class EnrolmentInfo implements Serializable { private static final long serialVersionUID = 1998101712L; @@ -40,7 +40,8 @@ public class EnrolmentInfo implements Serializable{ private Status status; private String owner; - public EnrolmentInfo() {} + public EnrolmentInfo() { + } public EnrolmentInfo(Device device, String owner, OwnerShip ownership, Status status) { this.device = device; @@ -109,11 +110,9 @@ public class EnrolmentInfo implements Serializable{ public boolean equals(Object obj) { if (obj instanceof EnrolmentInfo) { EnrolmentInfo tempInfo = (EnrolmentInfo) obj; - if (owner != null && ownership != null) { - if (tempInfo.getOwner() != null && tempInfo.getOwnership() != null) { - if (owner.equals(tempInfo.getOwner()) && ownership.equals(tempInfo.getOwnership())) { - return true; - } + if (this.owner != null && this.ownership != null) { + if (this.owner.equals(tempInfo.getOwner()) && this.ownership.equals(tempInfo.getOwnership())) { + return true; } } } diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java index 0a7698217a..c823323364 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java +++ b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java @@ -128,6 +128,10 @@ public class DynamicClientRegistrationUtil { serviceProvider.setDescription("Service Provider for application " + applicationName); ApplicationManagementService appMgtService = ApplicationManagementService.getInstance(); + if (appMgtService == null) { + throw new IllegalStateException("Error occurred while retrieving Application Management" + + "Service"); + } appMgtService.createApplication(serviceProvider); ServiceProvider createdServiceProvider = appMgtService.getApplication(applicationName); @@ -230,7 +234,7 @@ public class DynamicClientRegistrationUtil { ApplicationManagementService appMgtService = ApplicationManagementService.getInstance(); if (appMgtService == null) { - throw new APIManagementException("Error occurred while retrieving Application Management" + + throw new IllegalStateException("Error occurred while retrieving Application Management" + "Service"); } ServiceProvider createdServiceProvider = appMgtService.getApplication(applicationName);