diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index c080a7cc73..1ce7b37581 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT bundle WSO2 Carbon - API Management Annotations WSO2 Carbon - API Management Custom Annotation Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index 8275cc8d42..1a7995a0c8 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,12 +21,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml 4.0.0 - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT org.wso2.carbon.apimgt.application.extension.api war WSO2 Carbon - API Application Management API diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 5dbe6c92e5..183ce28a1a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,12 +22,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml 4.0.0 - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT org.wso2.carbon.apimgt.application.extension bundle WSO2 Carbon - API Application Management diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml index a7987b2a1a..49b79d7b31 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml @@ -21,13 +21,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handlers - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT bundle WSO2 Carbon - API Security Handler Component WSO2 Carbon - API Management Security Handler Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 31a7d46c33..8797542426 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -13,13 +13,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml index 9622461c9e..e00bf2f045 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml @@ -13,13 +13,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.generated.client - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT bundle WSO2 Carbon - API Management Integration Generated Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index 6c60024be0..e07b8ec898 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT bundle WSO2 Carbon - API Management Webapp Publisher WSO2 Carbon - API Management Webapp Publisher diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index f2f305f59d..42ed387245 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT pom WSO2 Carbon - API Management Extensions Component http://wso2.org diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index 0cee919cc9..be8b034bdf 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index df1f35f0e0..a9e7107bcc 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index f2a4e7ed31..c7efe6c02d 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -21,13 +21,13 @@ org.wso2.carbon.devicemgt certificate-mgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT bundle WSO2 Carbon - Certificate Management Core WSO2 Carbon - Certificate Management Core diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 15ae7b161b..21cac980a4 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT pom WSO2 Carbon - Certificate Management Component http://wso2.org diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index 07c4c03201..fa85915b6f 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml index b8959efa0e..93e8d2fe7b 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 6a15e4268a..c33c36cc97 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml index 0f24237a68..b83815a0ab 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 2870290b2e..c2f3e9e830 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index aa379afb63..1e0d484bfe 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index dcb87c9103..d67cdcb3a6 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml index 4463f7ecde..ac9a4272e7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt device-mgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index 89d7615020..b531934680 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 659c8a81bc..c7af113051 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml @@ -367,6 +367,11 @@ org.wso2.carbon.event.stream.persistence.stub provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.integration.client + provided + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index e134a40a17..e8272f6f88 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -562,7 +562,12 @@ public class UserManagementServiceImpl implements UserManagementService { } } catch (DeviceManagementException e) { String msg = "Error occurred while inviting user to enrol their device"; + if (e.getMessage() != null && !e.getMessage().isEmpty()) { + msg = e.getMessage(); + } log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } catch (UserStoreException e) { String msg = "Error occurred while getting claim values to invite user"; log.error(msg, e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index c1e8a801b7..eeb5f3600c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/GroupPaginationRequest.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/GroupPaginationRequest.java index a0dfb9351b..3c17ce32a9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/GroupPaginationRequest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/GroupPaginationRequest.java @@ -65,4 +65,10 @@ public class GroupPaginationRequest { this.groupName = groupName; } + @Override + public String toString() { + return "Group Name '" + this.groupName + "' num of rows: " + this.rowCount + " start index: " + this.startIndex + + " owner' " + this.owner + "'"; + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java index 3799b397ba..e71ba71773 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java @@ -129,4 +129,12 @@ public class PaginationRequest { public void setOwnerPattern(String ownerPattern) { this.ownerPattern = ownerPattern; } + + @Override + public String toString() { + return "Device type '" + this.deviceType + "' Device Name '" + this.deviceName + "' row count: " + this.rowCount + + " Owner role '" + this.ownerRole + "' owner pattern '" + this.ownerPattern + "' ownership " + + this.ownership + "' Status '" + this.status + "' owner '" + this.owner + "' groupId: " + this.groupId + + " start index: " + this.startIndex; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 72782f2e9d..37d375c7e7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index b0cc226c43..7e174ec714 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -182,16 +182,7 @@ public class GenericOperationDAOImpl implements OperationDAO { stmt.setString(3, Operation.Status.PENDING.toString()); // This will return only one result always. rs = stmt.executeQuery(); - int id = 0; if (rs.next()) { - id = rs.getInt("ID"); - } - if (id != 0) { - stmt = connection.prepareStatement( - "UPDATE DM_ENROLMENT_OP_MAPPING SET UPDATED_TIMESTAMP = ? " + "WHERE ID = ?"); - stmt.setLong(1, System.currentTimeMillis() / 1000); - stmt.setInt(2, id); - stmt.executeUpdate(); result = true; } } catch (SQLException e) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 1e09960283..a4afef2f48 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -160,6 +160,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public boolean enrollDevice(Device device) throws DeviceManagementException { + if (device == null) { + String msg = "Received empty device for device enrollment"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Enrolling the device " + device.getId() + "of type '" + device.getType() + "'"); + } boolean status = false; DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); @@ -228,9 +236,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while adding enrolment related metadata", e); + String msg = "Error occurred while adding enrolment related metadata for device: " + device.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (TransactionManagementException e) { - throw new DeviceManagementException("Error occurred while initiating transaction", e); + String msg = "Error occurred while initiating transaction to enrol device: " + device.getId(); + log.error(msg); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred while enrolling device: " + device.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -246,10 +262,18 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.commitTransaction(); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while adding metadata of '" + device.getType() + - "' device carrying the identifier '" + device.getDeviceIdentifier() + "'", e); + String msg = "Error occurred while adding metadata of '" + device.getType() + + "' device carrying the identifier '" + device.getDeviceIdentifier() + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (TransactionManagementException e) { - throw new DeviceManagementException("Error occurred while initiating transaction", e); + String msg = "Error occurred while initiating transaction"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred while enrolling device: " + device.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -266,7 +290,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (status) { addDeviceToGroups(deviceIdentifier, device.getEnrolmentInfo().getOwnership()); addInitialOperations(deviceIdentifier, device.getType()); - } return status; } @@ -274,6 +297,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public boolean modifyEnrollment(Device device) throws DeviceManagementException { + if (device == null) { + String msg = "Required values are not set to modify device enrollment"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Modifying enrollment for device: " + device.getId() + " of type '" + device.getType() + "'"); + } DeviceManager deviceManager = this.getDeviceManager(device.getType()); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); if (deviceManager == null) { @@ -301,10 +332,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv this.removeDeviceFromCache(deviceIdentifier); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while modifying the device " + - "'" + device.getId() + "'", e); + String msg = "Error occurred while modifying the device '" + device.getId() + "'"; + log.error(msg); + throw new DeviceManagementException(msg, e); } catch (TransactionManagementException e) { - throw new DeviceManagementException("Error occurred while initiating transaction", e); + String msg = "Error occurred while initiating transaction to modify device: " + device.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred while modifying device: " + device.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -313,15 +351,31 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv private List getEnrollmentsOfUser(int deviceId, String user) throws DeviceManagementException { + if (user == null || user.isEmpty()) { + String msg = "Required values are not set to getEnrollmentsOfUser"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get enrollments for user '" + user + "' device: " + deviceId); + } List enrolmentInfos = new ArrayList<>(); try { DeviceManagementDAOFactory.openConnection(); enrolmentInfos = enrollmentDAO.getEnrollmentsOfUser(deviceId, user, this.getTenantId()); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the enrollment information device for" + - "id '" + deviceId + "' and user : " + user, e); + String msg = "Error occurred while obtaining the enrollment information device for id '" + deviceId + + "' and user : " + user; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getEnrollmentsOfUser user '" + user + "' device: " + deviceId; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -330,6 +384,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + if (deviceId == null) { + String msg = "Required values are not set to dis-enroll device"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Dis-enrolling device: " + deviceId.getId() + " of type '" + deviceId.getType() + "'"); + } DeviceManager deviceManager = this.getDeviceManager(deviceId.getType()); if (deviceManager == null) { if (log.isDebugEnabled()) { @@ -351,7 +413,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (device.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.REMOVED)) { if (log.isDebugEnabled()) { - log.debug("Device has already disenrolled : " + deviceId.getId() + "'"); + log.debug("Device has already dis-enrolled : " + deviceId.getId() + "'"); } return true; } @@ -362,15 +424,22 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.beginTransaction(); enrollmentDAO.updateEnrollment(device.getId(), device.getEnrolmentInfo(), tenantId); deviceDAO.updateDevice(device, tenantId); - DeviceManagementDAOFactory.commitTransaction(); this.removeDeviceFromCache(deviceId); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while dis-enrolling '" + deviceId.getType() + - "' device with the identifier '" + deviceId.getId() + "'", e); + String msg = "Error occurred while dis-enrolling '" + deviceId.getType() + + "' device with the identifier '" + deviceId.getId() + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (TransactionManagementException e) { - throw new DeviceManagementException("Error occurred while initiating transaction", e); + String msg = "Error occurred while initiating transaction"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred while dis-enrolling device: " + deviceId.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -419,6 +488,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getAllDevices(String deviceType, boolean requireDeviceInfo) throws DeviceManagementException { + if (deviceType == null) { + String msg = "Device type is empty for method getAllDevices"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Getting all devices of type '" + deviceType + "' and requiredDeviceInfo: " + requireDeviceInfo); + } List allDevices; try { DeviceManagementDAOFactory.openConnection(); @@ -430,14 +507,21 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return null; } } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving all devices of type '" + - deviceType + "' that are being managed within the scope of current tenant", e); + String msg = "Error occurred while retrieving all devices of type '" + + deviceType + "' that are being managed within the scope of current tenant"; + log.error(msg); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred while getting all devices of device type '" + deviceType + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } - if (requireDeviceInfo) { return this.getAllDeviceInfo(allDevices); } @@ -451,15 +535,25 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getAllDevices(boolean requireDeviceInfo) throws DeviceManagementException { + if (log.isDebugEnabled()) { + log.debug("Getting all devices with requiredDeviceInfo: " + requireDeviceInfo); + } List allDevices; try { DeviceManagementDAOFactory.openConnection(); allDevices = deviceDAO.getDevices(this.getTenantId()); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving device list pertaining to " + - "the current tenant", e); + String msg = "Error occurred while retrieving device list pertaining to the current tenant"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in get all devices"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -477,15 +571,31 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getDevices(Date since, boolean requireDeviceInfo) throws DeviceManagementException { + if (since == null) { + String msg = "Given date is empty for method getDevices"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Getting all devices since date '" + since.toString() + "' and required device info: " + + requireDeviceInfo); + } List allDevices; try { DeviceManagementDAOFactory.openConnection(); allDevices = deviceDAO.getDevices(since.getTime(), this.getTenantId()); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving device list pertaining to " + - "the current tenant", e); + String msg = "Error occurred while retrieving device list pertaining to the current tenant"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred get devices since '" + since.toString() + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -503,6 +613,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public PaginationResult getDevicesByType(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException { + if (request == null) { + String msg = "Received incomplete pagination request for getDevicesByType"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get devices with pagination " + request.toString() + " and required deviceinfo: " + + requireDeviceInfo); + } PaginationResult paginationResult = new PaginationResult(); List allDevices = new ArrayList<>(); int count = 0; @@ -514,10 +633,18 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv allDevices = deviceDAO.getDevices(request, tenantId); count = deviceDAO.getDeviceCountByType(deviceType, tenantId); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving device list pertaining to " + - "the current tenant of type " + deviceType, e); + String msg = "Error occurred while retrieving device list pertaining to the current tenant of type " + + deviceType; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDeviceByType"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -540,6 +667,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public PaginationResult getAllDevices(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException { + if (request == null) { + String msg = "Received incomplete pagination request for method getAllDevices"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get devices with pagination " + request.toString() + " and requiredDeviceInfo: " + requireDeviceInfo); + } List devicesForRoles = null; PaginationResult paginationResult = new PaginationResult(); List allDevices = new ArrayList<>(); @@ -560,10 +695,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv allDevices = deviceDAO.getDevices(request, tenantId); count = deviceDAO.getDeviceCount(request, tenantId); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving device list pertaining to " + - "the current tenant", e); + String msg = "Error occurred while retrieving device list pertaining to the current tenant"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getAllDevices"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -580,6 +722,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public Device getDevice(DeviceIdentifier deviceId, boolean requireDeviceInfo) throws DeviceManagementException { + if (deviceId == null) { + String msg = "Received null device identifier for method getDevice"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get device by device id :" + deviceId.getId() + " of type '" + deviceId.getType() + + "' and requiredDeviceInfo: " + requireDeviceInfo); + } int tenantId = this.getTenantId(); Device device = this.getDeviceFromCache(deviceId); if (device == null) { @@ -596,10 +747,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } this.addDeviceToCache(deviceId, device); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the device for id " + - "'" + deviceId.getId() + "'", e); + String msg = "Error occurred while obtaining the device for '" + deviceId.getId() + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevice: " + deviceId.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -612,6 +770,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException { + if (metaInfo == null) { + String msg = "Received incomplete data to method sendEnrolmentInvitation"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Send enrollment invitation, templateName '" + templateName + "'"); + } Map, Object>> params = new HashMap<>(); Properties props = metaInfo.getProperties(); Enumeration e = props.propertyNames(); @@ -629,12 +795,26 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv metaInfo.getRecipients()).build(); DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx); } catch (EmailSendingFailedException ex) { - throw new DeviceManagementException("Error occurred while sending enrollment invitation", ex); + String msg = "Error occurred while sending enrollment invitation"; + log.error(msg, ex); + throw new DeviceManagementException(msg, ex); + } catch (Exception ex) { + String msg = "Error occurred in setEnrollmentInvitation"; + log.error(msg, ex); + throw new DeviceManagementException(msg, ex); } } @Override public void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException { + if (metaInfo == null) { + String msg = "Received incomplete request for sendRegistrationEmail"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Send registration email"); + } Map, Object>> params = new HashMap<>(); params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.FIRST_NAME, new TypedValue, Object>(String.class, metaInfo.getProperty("first-name"))); @@ -657,12 +837,27 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv metaInfo.getRecipients()).build(); DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx); } catch (EmailSendingFailedException e) { - throw new DeviceManagementException("Error occurred while sending user registration notification", e); + String msg = "Error occurred while sending user registration notification." + e.getMessage(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in sendRegistrationEmail"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } } @Override public HashMap getTenantedDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { + if (deviceIdentifier == null) { + String msg = "Received null deviceIdentifier for getTenantedDevice"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get tenanted device with id: " + deviceIdentifier.getId() + " of type '" + + deviceIdentifier.getType() + "'"); + } HashMap deviceHashMap; try { DeviceManagementDAOFactory.openConnection(); @@ -675,10 +870,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return null; } } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the device for id " + - "'" + deviceIdentifier.getId() + "'", e); + String msg = "Error occurred while obtaining the device for id '" + deviceIdentifier.getId() + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getTenantedDevice device: " + deviceIdentifier.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -692,6 +894,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public Device getDeviceWithTypeProperties(DeviceIdentifier deviceId) throws DeviceManagementException { + if (deviceId == null) { + String msg = "Received null deviceIdentifier for getDeviceWithTypeProperties"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get tenanted device with type properties, deviceId: " + deviceId.getId()); + } Device device = this.getDevice(deviceId, false); DeviceManager deviceManager = this.getDeviceManager(device.getType()); @@ -718,6 +928,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public Device getDevice(DeviceIdentifier deviceId, Date since, boolean requireDeviceInfo) throws DeviceManagementException { + if (deviceId == null || since == null) { + String msg = "Received incomplete data for getDevice"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get device since '" + since.toString() + "' with identifier: " + deviceId.getId() + + " and type '" + deviceId.getType() + "'"); + } Device device; try { DeviceManagementDAOFactory.openConnection(); @@ -730,10 +949,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return null; } } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the device for id " + - "'" + deviceId.getId() + "'", e); + String msg = "Error occurred while obtaining the device for id '" + deviceId.getId() + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevice for device: " + deviceId.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -751,6 +977,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status, boolean requireDeviceInfo) throws DeviceManagementException { + if (deviceId == null) { + String msg = "Received null deviceIdentifier for getDevice"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get device with identifier: " + deviceId.getId() + " and type '" + deviceId.getType() + "'"); + } Device device; try { DeviceManagementDAOFactory.openConnection(); @@ -763,22 +997,31 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return null; } } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the device for id " + - "'" + deviceId.getId() + "'", e); + String msg = "Error occurred while obtaining the device for id '" + deviceId.getId() + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevice for device: " + deviceId.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } if (requireDeviceInfo) { device = this.getAllDeviceInfo(device); } - return device; } @Override public List getAvailableDeviceTypes() throws DeviceManagementException { + if (log.isDebugEnabled()) { + log.debug("Get available device types"); + } List deviceTypesProvidedByTenant; List publicSharedDeviceTypesInDB; List deviceTypesResponse = new ArrayList<>(); @@ -814,9 +1057,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the device types.", e); + String msg = "Error occurred while obtaining the device types."; + log.info(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.info(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getAvailableDeviceTypes"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -825,6 +1076,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public boolean updateDeviceInfo(DeviceIdentifier deviceId, Device device) throws DeviceManagementException { + if (deviceId == null || device == null) { + String msg = "Received incomplete data for updateDeviceInfo"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Update device info of device: " + deviceId.getId()); + } DeviceManager deviceManager = this.getDeviceManager(deviceId.getType()); if (deviceManager == null) { if (log.isDebugEnabled()) { @@ -838,6 +1097,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { + if (deviceId == null) { + String msg = "Received incomplete data for setOwnership"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Set ownership of device: " + deviceId.getId() + " ownership type '" + ownershipType + "'"); + } DeviceManager deviceManager = this.getDeviceManager(deviceId.getType()); if (deviceManager == null) { if (log.isDebugEnabled()) { @@ -865,6 +1132,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public boolean setStatus(DeviceIdentifier deviceId, String currentOwner, EnrolmentInfo.Status status) throws DeviceManagementException { + if (deviceId == null) { + String msg = "Received null deviceIdentifier for setStatus"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Set status of device: " + deviceId.getId()); + } try { boolean success = false; int tenantId = this.getTenantId(); @@ -879,9 +1154,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return success; } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while setting enrollment status", e); + String msg = "Error occurred while setting enrollment status"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (TransactionManagementException e) { - throw new DeviceManagementException("Error occurred while initiating transaction", e); + String msg = "Error occurred while initiating transaction"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in setStatus for device :" + deviceId.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -890,6 +1173,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public boolean setStatus(String currentOwner, EnrolmentInfo.Status status) throws DeviceManagementException { + if (log.isDebugEnabled()) { + log.debug("Update enrollment with status"); + } try { boolean success = false; int tenantId = this.getTenantId(); @@ -899,9 +1185,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return success; } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while setting enrollment status", e); + String msg = "Error occurred while setting enrollment status"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (TransactionManagementException e) { - throw new DeviceManagementException("Error occurred while initiating transaction", e); + String msg = "Error occurred while initiating transaction"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in setStatus"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -923,6 +1217,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public License getLicense(String deviceType, String languageCode) throws DeviceManagementException { + if (deviceType == null || languageCode == null) { + String msg = "Received incomplete data for getLicence"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get the licence for device type '" + deviceType + "' languageCode '" + languageCode + "'"); + } DeviceManager deviceManager = this.getDeviceManager(deviceType); License license; if (deviceManager == null) { @@ -941,13 +1243,27 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } return license; } catch (LicenseManagementException e) { - throw new DeviceManagementException("Error occurred while retrieving license configured for " + - "device type '" + deviceType + "' and language code '" + languageCode + "'", e); + String msg = "Error occurred while retrieving license configured for " + + "device type '" + deviceType + "' and language code '" + languageCode + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getLicence for device type '" + deviceType + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } } @Override public void addLicense(String deviceType, License license) throws DeviceManagementException { + if (deviceType == null || license == null) { + String msg = "Received incomplete data for addLicence"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Add the licence for device type '" + deviceType + "'"); + } DeviceManager deviceManager = this.getDeviceManager(deviceType); if (deviceManager == null) { if (log.isDebugEnabled()) { @@ -959,8 +1275,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv try { deviceManager.addLicense(license); } catch (LicenseManagementException e) { - throw new DeviceManagementException("Error occurred while adding license for " + - "device type '" + deviceType + "'", e); + String msg = "Error occurred while adding license for device type '" + deviceType + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in addLicence for device type '" + deviceType + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } } @@ -1092,15 +1413,31 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getDevicesOfUser(String username, boolean requireDeviceInfo) throws DeviceManagementException { + if (username == null) { + String msg = "Username null in getDevicesOfUser"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get devices of user with username '" + username + "' and requiredDeviceInfo " + requireDeviceInfo); + } List userDevices; try { DeviceManagementDAOFactory.openConnection(); userDevices = deviceDAO.getDevicesOfUser(username, this.getTenantId()); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the list of devices that " + - "belong to the user '" + username + "'", e); + String msg = "Error occurred while retrieving the list of devices that " + + "belong to the user '" + username + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevicesOfUser for username '" + username + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1113,21 +1450,38 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getDevicesOfUser(String username, String deviceType) throws DeviceManagementException { - return this.getDevicesOfUser(username, deviceType, true); + return this.getDevicesOfUser(username, deviceType, true); } @Override public List getDevicesOfUser(String username, String deviceType, boolean requireDeviceInfo) throws DeviceManagementException { + if (username == null || deviceType == null) { + String msg = "Received incomplete data for getDevicesOfUser"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get '" + deviceType + "' devices of user with username '" + username + "' requiredDeviceInfo: " + + requireDeviceInfo); + } List userDevices; try { DeviceManagementDAOFactory.openConnection(); userDevices = deviceDAO.getDevicesOfUser(username, deviceType, this.getTenantId()); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the list of devices that " + - "belong to the user '" + username + "'", e); + String msg = "Error occurred while retrieving the list of devices that " + + "belong to the user '" + username + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevicesOfUser for '" + username + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1146,6 +1500,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public PaginationResult getDevicesOfUser(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException { + if (request == null) { + String msg = "Received incomplete pagination request for getDevicesOfUser"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get paginated results of devices of user " + request.toString() + " and requiredDeviceInfo: " + + requireDeviceInfo); + } PaginationResult result = new PaginationResult(); int deviceCount = 0; int tenantId = this.getTenantId(); @@ -1157,10 +1520,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv userDevices = deviceDAO.getDevicesOfUser(request, tenantId); deviceCount = deviceDAO.getDeviceCountByUser(username, tenantId); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the list of devices that " + - "belong to the user '" + username + "'", e); + String msg = "Error occurred while retrieving the list of devices that belong to the user '" + username + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevicesOfUser"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1185,6 +1555,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public PaginationResult getDevicesByOwnership(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException { + if (request == null) { + String msg = "Received incomplete data for getDevicesByOwnership"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get devices by ownership " + request.toString()); + } PaginationResult result = new PaginationResult(); List allDevices; int deviceCount = 0; @@ -1196,10 +1574,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv allDevices = deviceDAO.getDevicesByOwnership(request, tenantId); deviceCount = deviceDAO.getDeviceCountByOwnership(ownerShip, tenantId); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException( - "Error occurred while fetching the list of devices that matches to ownership : '" + ownerShip + "'", e); + String msg = "Error occurred while fetching the list of devices that matches to ownership : '" + ownerShip + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevicesByOwnership"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1221,6 +1606,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getAllDevicesOfRole(String role, boolean requireDeviceInfo) throws DeviceManagementException { + if (role == null || role.isEmpty()) { + String msg = "Received empty role for the method getAllDevicesOfRole"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get devices of role '" + role + "' and requiredDeviceInfo: " + requireDeviceInfo); + } List devices = new ArrayList<>(); String[] users; int tenantId = this.getTenantId(); @@ -1228,8 +1621,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv users = DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId) .getUserStoreManager().getUserListOfRole(role); } catch (UserStoreException e) { - throw new DeviceManagementException("Error occurred while obtaining the users, who are assigned " + - "with the role '" + role + "'", e); + String msg = "Error occurred while obtaining the users, who are assigned with the role '" + role + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getAllDevicesOfRole for role '" + role + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } List userDevices; @@ -1239,7 +1637,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.openConnection(); userDevices = deviceDAO.getDevicesOfUser(user, tenantId); } catch (DeviceManagementDAOException | SQLException e) { - log.error("Error occurred while obtaining the devices of user '" + user + "'", e); + String msg = "Error occurred while obtaining the devices of user '" + user + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred getAllDevicesOfRole for role '" + role + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1252,14 +1656,29 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public int getDeviceCount(String username) throws DeviceManagementException { + if (username == null) { + String msg = "Received empty username for getDeviceCount"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Getting device count of the user '" + username + "'"); + } try { DeviceManagementDAOFactory.openConnection(); return deviceDAO.getDeviceCount(username, this.getTenantId()); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the device count of user '" - + username + "'", e); + String msg = "Error occurred while retrieving the device count of user '" + username + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDeviceCount for username '" + username + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1267,13 +1686,24 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public int getDeviceCount() throws DeviceManagementException { + if (log.isDebugEnabled()) { + log.debug("Get devices count"); + } try { DeviceManagementDAOFactory.openConnection(); return deviceDAO.getDeviceCount(this.getTenantId()); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the device count", e); + String msg = "Error occurred while retrieving the device count"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDeviceCount"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1282,6 +1712,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getDevicesByNameAndType(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException { + if (request == null) { + String msg = "Received incomplete data for getDevicesByNameAndType"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get devices by name " + request.toString() + " and requiredDeviceInfo: " + requireDeviceInfo); + } List devices = new ArrayList<>(); List allDevices; int limit = DeviceManagerUtil.validateDeviceListPageSize(request.getRowCount()); @@ -1289,11 +1727,21 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.openConnection(); allDevices = deviceDAO.getDevicesByNameAndType(request.getDeviceName(), request.getDeviceType(), this.getTenantId(), request.getStartIndex(), limit); + List filterd = null; + filterd.get(0); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while fetching the list of devices that matches to '" - + request.getDeviceName() + "'", e); + String msg = "Error occurred while fetching the list of devices that matches to '" + + request.getDeviceName() + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevicesByNameAndType"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1312,6 +1760,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public PaginationResult getDevicesByName(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException { + if (request == null) { + String msg = "Received incomplete data for getDevicesByName"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get devices by name " + request.toString() + " requiredDeviceInfo: " + requireDeviceInfo); + } PaginationResult result = new PaginationResult(); int tenantId = this.getTenantId(); List allDevices = new ArrayList<>(); @@ -1324,10 +1780,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv result.setRecordsTotal(deviceCount); result.setRecordsFiltered(deviceCount); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while fetching the list of devices that matches to '" - + deviceName + "'", e); + String msg = "Error occurred while fetching the list of devices that matches to '" + deviceName + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevicesByName"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1342,6 +1805,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public void updateDeviceEnrolmentInfo(Device device, EnrolmentInfo.Status status) throws DeviceManagementException { try { + if (device == null || status == null) { + String msg = "Received incomplete data for updateDeviceEnrolmentInfo"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Updating enrolment for device: " + device.getId() + " of type '" + device.getType() + "'"); + } DeviceManagementDAOFactory.beginTransaction(); device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime()); device.getEnrolmentInfo().setStatus(status); @@ -1349,10 +1820,18 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.commitTransaction(); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred update device enrolment status : '" + - device.getId() + "'", e); + String msg = "Error occurred while updating device enrolment status for " + device.getDeviceIdentifier() + + " of type " + device.getType(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (TransactionManagementException e) { - throw new DeviceManagementException("Error occurred while initiating transaction", e); + String msg = "Error occurred while initiating transaction"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in updateDeviceEnrolmentInfo"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1360,21 +1839,34 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public void registerDeviceManagementService(DeviceManagementService deviceManagementService) { + if (log.isDebugEnabled()) { + log.debug("Registering device management service"); + } try { pluginRepository.addDeviceManagementProvider(deviceManagementService); } catch (DeviceManagementException e) { - log.error("Error occurred while registering device management plugin '" + - deviceManagementService.getType() + "'", e); + String msg = "Error occurred while registering device management plugin '" + + deviceManagementService.getType() + "'"; + log.error(msg, e); + } catch (Exception e) { + String msg = "Error occurred in registerDeviceManagementService"; + log.error(msg, e); } } @Override public void unregisterDeviceManagementService(DeviceManagementService deviceManagementService) { + if (log.isDebugEnabled()) { + log.debug("Unregister a device management service"); + } try { pluginRepository.removeDeviceManagementProvider(deviceManagementService); } catch (DeviceManagementException e) { log.error("Error occurred while un-registering device management plugin '" + deviceManagementService.getType() + "'", e); + } catch (Exception e) { + String msg = "Error occurred in unregisterDeviceManagementService"; + log.error(msg, e); } } @@ -1386,6 +1878,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getDevicesByStatus(EnrolmentInfo.Status status, boolean requireDeviceInfo) throws DeviceManagementException { + if (log.isDebugEnabled()) { + log.debug("get devices by status and requiredDeviceInfo: " + requireDeviceInfo); + } List allDevices; try { DeviceManagementDAOFactory.openConnection(); @@ -1394,7 +1889,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv throw new DeviceManagementException( "Error occurred while fetching the list of devices that matches to status: '" + status + "'", e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevicesByStatus"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1412,8 +1913,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public PaginationResult getDevicesByStatus(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException { + if (request == null) { + String msg = "Received incomplete data for getDevicesByStatus"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get devices by status " + request.toString() + " and requiredDeviceInfo: " + + requireDeviceInfo); + } PaginationResult result = new PaginationResult(); - List allDevices = new ArrayList<>(); + List allDevices; int tenantId = this.getTenantId(); String status = request.getStatus(); request = DeviceManagerUtil.validateDeviceListPageSize(request); @@ -1424,10 +1934,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv result.setRecordsTotal(deviceCount); result.setRecordsFiltered(deviceCount); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException( - "Error occurred while fetching the list of devices that matches to status: '" + status + "'", e); + String msg = "Error occurred while fetching the list of devices that matches to status: '" + status + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevicesByStatus"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1470,6 +1987,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public boolean changeDeviceStatus(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status newStatus) throws DeviceManagementException { + if (deviceIdentifier == null) { + String msg = "Received incomplete data for getDevicesByStatus"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Change device status of device: " + deviceIdentifier.getId() + " of type '" + + deviceIdentifier.getType() + "'"); + } boolean isDeviceUpdated = false; Device device = getDevice(deviceIdentifier, false); int deviceId = device.getId(); @@ -1494,14 +2020,24 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getDeviceEnrolledTenants() throws DeviceManagementException { + if (log.isDebugEnabled()) { + log.debug("get device enrolled tenants"); + } try { DeviceManagementDAOFactory.openConnection(); return deviceDAO.getDeviceEnrolledTenants(); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the tenants " + - "which have device enrolled.", e); + String msg = "Error occurred while retrieving the tenants which have device enrolled."; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDeviceEnrolledTenants"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1509,6 +2045,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv private boolean updateEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, int tenantId) throws DeviceManagementException { + if (log.isDebugEnabled()) { + log.debug("Update enrollment of device: " + deviceId); + } boolean isUpdatedEnrollment = false; boolean isAutoCommit = true; try { @@ -1520,10 +2059,18 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv isUpdatedEnrollment = true; } } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while updating the enrollment information device for" + - "id '" + deviceId + "' .", e); + String msg = "Error occurred while updating the enrollment information device for" + + "id '" + deviceId + "' ."; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in updateEnrollment for deviceId: " + deviceId; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { try { DeviceManagementDAOFactory.getConnection().setAutoCommit(isAutoCommit); @@ -1562,6 +2109,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv */ private void addDeviceToGroups(DeviceIdentifier deviceIdentifier, EnrolmentInfo.OwnerShip ownership) throws DeviceManagementException { + if (deviceIdentifier == null) { + String msg = "Received incomplete data for addDeviceToGroup"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Add device:" + deviceIdentifier.getId() + " to default group"); + } GroupManagementProviderService groupManagementProviderService = new GroupManagementProviderServiceImpl(); try { DeviceGroup defaultGroup = createDefaultGroup(groupManagementProviderService, ownership.toString()); @@ -1571,14 +2126,30 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv groupManagementProviderService.addDevices(defaultGroup.getGroupId(), deviceIdentifiers); } } catch (DeviceNotFoundException e) { - throw new DeviceManagementException("Unable to find the device with the id: '" + deviceIdentifier.getId(), - e); + String msg = "Unable to find the device with the id: '" + deviceIdentifier.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (GroupManagementException e) { - throw new DeviceManagementException("An error occurred when adding the device to the group.", e); + String msg = "An error occurred when adding the device to the group."; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } } private void addInitialOperations(DeviceIdentifier deviceIdentifier, String deviceType) throws DeviceManagementException { + if (deviceIdentifier == null || deviceType == null) { + String msg = "Received incomplete data for getDevicesByStatus"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Add initial operations to the device:" + deviceIdentifier.getId() + " of type '" + + deviceType + "'"); + } DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance(). getDeviceManagementProvider(); DeviceManagementService deviceManagementService = @@ -1597,11 +2168,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv try { deviceManagementProviderService.addOperation(deviceType, operation, deviceIdentifiers); } catch (OperationManagementException e) { - throw new DeviceManagementException("Unable to add the operation for the device with the id: '" - + deviceIdentifier.getId(), e); + String msg = "Unable to add the operation for the device with the id: '" + deviceIdentifier.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (InvalidDeviceException e) { - throw new DeviceManagementException("Unable to find the device with the id: '" - + deviceIdentifier.getId(), e); + String msg = "Unable to find the device with the id: '" + deviceIdentifier.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } } } @@ -1618,6 +2195,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv */ private DeviceGroup createDefaultGroup(GroupManagementProviderService service, String groupName) throws GroupManagementException { + if (service == null || groupName == null) { + String msg = "Received incomplete data for createDefaultGroup"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Create default group with name '" + groupName + "'"); + } DeviceGroup defaultGroup = service.getGroup(groupName); if (defaultGroup == null) { defaultGroup = new DeviceGroup(groupName); @@ -1628,10 +2213,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv service.createGroup(defaultGroup, DeviceGroupConstants.Roles.DEFAULT_ADMIN_ROLE, DeviceGroupConstants.Permissions.DEFAULT_ADMIN_PERMISSIONS); } catch (GroupAlreadyExistException e) { - if (log.isDebugEnabled()) { - log.debug("Default group: " + defaultGroup.getName() + " already exists. Skipping group creation.", - e); - } + String msg = "Default group: " + defaultGroup.getName() + " already exists. Skipping group creation."; + log.error(msg); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } return service.getGroup(groupName); } else { @@ -1648,14 +2236,31 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public DeviceType getDeviceType(String deviceType) throws DeviceManagementException { + if (deviceType != null) { + if (log.isDebugEnabled()) { + log.debug("Get device type '" + deviceType + "'"); + } + } else { + String msg = "Received null deviceType for getDeviceType"; + log.error(msg); + throw new DeviceManagementException(msg); + } try { DeviceManagementDAOFactory.openConnection(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); return deviceTypeDAO.getDeviceType(deviceType, tenantId); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the device type " + deviceType, e); + String msg = "Error occurred while obtaining the device type " + deviceType; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1663,15 +2268,25 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getDeviceTypes() throws DeviceManagementException { + if (log.isDebugEnabled()) { + log.debug("Get device types"); + } int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { DeviceManagementDAOFactory.openConnection(); return deviceTypeDAO.getDeviceTypes(tenantId); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the device types for tenant " - + tenantId, e); + String msg = "Error occurred while obtaining the device types for tenant " + tenantId; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDeviceTypes"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1680,28 +2295,39 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public void notifyPullNotificationSubscriber(DeviceIdentifier deviceIdentifier, Operation operation) throws PullNotificationExecutionFailedException { + if (log.isDebugEnabled()) { + log.debug("Notify pull notification subscriber"); + } DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceIdentifier.getType(), this.getTenantId()); if (dms == null) { - String message = "Device type '" + deviceIdentifier.getType() + "' does not have an associated device management " + - "plugin registered within the framework"; - if (log.isDebugEnabled()) { - log.debug(message); - } + String message = "Device type '" + deviceIdentifier.getType() + "' does not have an associated " + + "device management plugin registered within the framework"; + log.error(message); throw new PullNotificationExecutionFailedException(message); } PullNotificationSubscriber pullNotificationSubscriber = dms.getPullNotificationSubscriber(); if (pullNotificationSubscriber == null) { - throw new PullNotificationExecutionFailedException("Pull Notification Subscriber is not configured " + - "for device type" + deviceIdentifier.getType()); + String message = "Pull Notification Subscriber is not configured " + + "for device type" + deviceIdentifier.getType(); + log.error(message); + throw new PullNotificationExecutionFailedException(message); } pullNotificationSubscriber.execute(deviceIdentifier, operation); } /** - * Returns all the device-info including location of the given device. + * Returns all the device-info including location of the given device. */ - private DeviceInfo getDeviceInfo(Device device) { + private DeviceInfo getDeviceInfo(Device device) throws DeviceManagementException { + if (device == null) { + String msg = "Received incomplete data for getDeviceInfo"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get device info of device: " + device.getId() + " of type '" + device.getType() + "'"); + } DeviceInfo info = null; try { DeviceManagementDAOFactory.openConnection(); @@ -1711,10 +2337,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv info.setLocation(location); } } catch (DeviceDetailsMgtDAOException e) { - log.error("Error occurred while retrieving advance info of '" + device.getType() + - "' that carries the id '" + device.getDeviceIdentifier() + "'"); + String msg = "Error occurred while retrieving advance info of '" + device.getType() + + "' that carries the id '" + device.getDeviceIdentifier() + "'"; + log.error(msg); + throw new DeviceManagementException(msg, e); } catch (SQLException e) { - log.error("Error occurred while opening a connection to the data source", e); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDeviceInfo for device: " + device.getId(); + log.error(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1722,9 +2355,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } /** - * Returns all the installed apps of the given device. + * Returns all the installed apps of the given device. */ private List getInstalledApplications(Device device) { + if (log.isDebugEnabled()) { + log.debug("Get installed applications of device: " + device.getId() + " of type '" + device.getType() + "'"); + } List applications = new ArrayList<>(); try { DeviceManagementDAOFactory.openConnection(); @@ -1735,6 +2371,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv "which carries the id '" + device.getId() + "'", e); } catch (SQLException e) { log.error("Error occurred while opening a connection to the data source", e); + } catch (Exception e) { + String msg = "Error occurred in getInstalledApplications"; + log.error(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -1742,17 +2381,23 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } /** - * Returns all the available information (device-info, location, applications and plugin-db data) - * of the given device list. + * Returns all the available information (device-info, location, applications and plugin-db data) + * of the given device list. */ - private List getAllDeviceInfo(List allDevices) - throws DeviceManagementException { + private List getAllDeviceInfo(List allDevices) throws DeviceManagementException { + if (allDevices.size() == 0) { + String msg = "Received empty device list for getAllDeviceInfo"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get all device info of devices, num of devices: " + allDevices.size()); + } List devices = new ArrayList<>(); if (allDevices != null) { for (Device device : allDevices) { device.setDeviceInfo(this.getDeviceInfo(device)); device.setApplications(this.getInstalledApplications(device)); - DeviceManager deviceManager = this.getDeviceManager(device.getType()); if (deviceManager == null) { if (log.isDebugEnabled()) { @@ -1775,10 +2420,18 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } /** - * Returns all the available information (device-info, location, applications and plugin-db data) - * of a given device. + * Returns all the available information (device-info, location, applications and plugin-db data) + * of a given device. */ private Device getAllDeviceInfo(Device device) throws DeviceManagementException { + if (device == null) { + String msg = "Received empty device for getAllDeviceInfo"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get all device info of device: " + device.getId() + " of type '" + device.getType() + "'"); + } device.setDeviceInfo(this.getDeviceInfo(device)); device.setApplications(this.getInstalledApplications(device)); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java index ad8ecf77d1..b5a2a4f635 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -65,6 +65,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public void createGroup(DeviceGroup deviceGroup, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException { + if (deviceGroup == null) { + String msg = "Received incomplete data for createGroup"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Creating group '" + deviceGroup.getName() + "'"); + } if (deviceGroup == null) { throw new GroupManagementException("DeviceGroup cannot be null.", new NullPointerException()); } @@ -80,10 +88,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); - throw new GroupManagementException("Error occurred while adding deviceGroup " + - "'" + deviceGroup.getName() + "' to database.", e); + String msg = "Error occurred while adding deviceGroup '" + deviceGroup.getName() + "' to database."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (TransactionManagementException e) { - throw new GroupManagementException("Error occurred while initiating transaction.", e); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in creating group '" + deviceGroup.getName() + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -99,6 +114,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public void updateGroup(DeviceGroup deviceGroup, int groupId) throws GroupManagementException, GroupAlreadyExistException { + if (deviceGroup == null) { + String msg = "Received incomplete data for updateGroup"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("update group '" + deviceGroup.getName() + "'"); + } if (deviceGroup == null) { throw new GroupManagementException("DeviceGroup cannot be null.", new NullPointerException()); } @@ -114,10 +137,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); - throw new GroupManagementException("Error occurred while modifying deviceGroup " + - "'" + deviceGroup.getName() + "'.", e); + String msg = "Error occurred while modifying deviceGroup '" + deviceGroup.getName() + "'."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (TransactionManagementException e) { - throw new GroupManagementException("Error occurred while initiating transaction.", e); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in updating group '" + deviceGroup.getName() + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -128,6 +158,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid */ @Override public boolean deleteGroup(int groupId) throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Delete group: " + groupId); + } DeviceGroup deviceGroup = getGroup(groupId); if (deviceGroup == null) { return false; @@ -142,9 +175,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid return true; } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); - throw new GroupManagementException("Error occurred while removing group data.", e); + String msg = "Error occurred while removing group data."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (TransactionManagementException e) { - throw new GroupManagementException("Error occurred while initiating transaction.", e); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in deleting group: " + groupId; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -155,14 +196,25 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid */ @Override public DeviceGroup getGroup(int groupId) throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Get group by id: " + groupId); + } DeviceGroup deviceGroup; try { GroupManagementDAOFactory.openConnection(); deviceGroup = this.groupDAO.getGroup(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId()); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while obtaining group '" + groupId + "'", e); + String msg = "Error occurred while obtaining group '" + groupId + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getGroup for groupId: " + groupId; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -174,14 +226,30 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid */ @Override public DeviceGroup getGroup(String groupName) throws GroupManagementException { + if (groupName == null) { + String msg = "Received empty groupName for getGroup"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get group by name '" + groupName + "'"); + } DeviceGroup deviceGroup; try { GroupManagementDAOFactory.openConnection(); deviceGroup = this.groupDAO.getGroup(groupName, CarbonContext.getThreadLocalCarbonContext().getTenantId()); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while obtaining group with name: '" + groupName + "'", e); + String msg = "Error occurred while obtaining group with name: '" + groupName + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getGroup with name " + groupName; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -190,15 +258,26 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public List getGroups() throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Get groups"); + } List deviceGroups = new ArrayList<>(); try { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); GroupManagementDAOFactory.openConnection(); deviceGroups = this.groupDAO.getGroups(tenantId); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); + String msg = "Error occurred while retrieving all groups in tenant"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getGroups"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -207,6 +286,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public PaginationResult getGroups(GroupPaginationRequest request) throws GroupManagementException { + if (request == null) { + String msg = "Received incomplete data for getGroup"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get groups with pagination " + request.toString()); + } request = DeviceManagerUtil.validateGroupListPageSize(request); List deviceGroups = new ArrayList<>(); try { @@ -214,9 +301,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid GroupManagementDAOFactory.openConnection(); deviceGroups = this.groupDAO.getGroups(request, tenantId); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); + String msg = "Error occurred while retrieving all groups in tenant"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getGroups"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -228,6 +323,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public List getGroups(String username) throws GroupManagementException { + if (username == null || username.isEmpty()) { + String msg = "Received null user name for getGroups"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get groups of owner '" + username + "'"); + } Map groups = new HashMap<>(); UserStoreManager userStoreManager; try { @@ -245,11 +348,20 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid groups.put(deviceGroup.getGroupId(), deviceGroup); } } catch (UserStoreException e) { - throw new GroupManagementException("Error occurred while getting user store manager.", e); + String msg = "Error occurred while getting user store manager."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while retrieving all groups accessible to user.", e); + String msg = "Error occurred while retrieving all groups accessible to user."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (GroupManagementDAOException e) { + log.error(e); throw new GroupManagementException(e); + } catch (Exception e) { + String msg = "Error occurred in getGroups for " + username; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -257,6 +369,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } private List getGroupIds(String username) throws GroupManagementException { + if (username == null || username.isEmpty()) { + String msg = "Received empty user name for getGroupIds"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get groups Ids of owner '" + username + "'"); + } UserStoreManager userStoreManager; List deviceGroupIds = new ArrayList<>(); try { @@ -268,11 +388,20 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid deviceGroupIds = this.groupDAO.getOwnGroupIds(username, tenantId); deviceGroupIds.addAll(this.groupDAO.getGroupIds(roleList, tenantId)); } catch (UserStoreException e) { - throw new GroupManagementException("Error occurred while getting user store manager.", e); + String msg = "Error occurred while getting user store manager."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while retrieving all groups accessible to user.", e); + String msg = "Error occurred while retrieving all groups accessible to user."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (GroupManagementDAOException e) { + log.error(e); throw new GroupManagementException(e); + } catch (Exception e) { + String msg = "Error occurred in getGroups for username '" + username + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -282,6 +411,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public PaginationResult getGroups(String currentUser, GroupPaginationRequest request) throws GroupManagementException { + if (currentUser == null || request == null) { + String msg = "Received incomplete date for getGroups"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get all groups of user '" + currentUser + "' pagination request " + request.toString()); + } request = DeviceManagerUtil.validateGroupListPageSize(request); List allDeviceGroupIdsOfUser = getGroupIds(currentUser); List allMatchingGroups = new ArrayList<>(); @@ -290,9 +427,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid GroupManagementDAOFactory.openConnection(); allMatchingGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); + String msg = "Error occurred while retrieving all groups in tenant"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getGroups"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -304,28 +449,55 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public int getGroupCount() throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Get groups count"); + } try { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); GroupManagementDAOFactory.openConnection(); return groupDAO.getGroupCount(tenantId); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); + String msg = "Error occurred while retrieving all groups in tenant"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } } private int getGroupCount(GroupPaginationRequest request) throws GroupManagementException { + if (request == null) { + String msg = "Received empty request for getGroupCount"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get groups count, pagination request " + request.toString()); + } try { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); GroupManagementDAOFactory.openConnection(); return groupDAO.getGroupCount(request, tenantId); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); + String msg = "Error occurred while retrieving all groups in tenant"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getGroupCount"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -336,6 +508,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid */ @Override public int getGroupCount(String username) throws GroupManagementException { + if (username == null || username.isEmpty()) { + String msg = "Received empty user name for getGroupCount"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get groups count of '" + username + "'"); + } UserStoreManager userStoreManager; int count; try { @@ -348,11 +528,21 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid count += groupDAO.getGroupsCount(roleList, tenantId); return count; } catch (UserStoreException e) { - throw new GroupManagementException("Error occurred while getting user store manager.", e); + String msg = "Error occurred while getting user store manager."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while retrieving group count of user '" + username + "'", e); + String msg = "Error occurred while retrieving group count of user '" + username + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getGroupCount for username '" + username + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -364,41 +554,52 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public void manageGroupSharing(int groupId, List newRoles) throws GroupManagementException, RoleDoesNotExistException { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - UserStoreManager userStoreManager; - try { - userStoreManager = - DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm( - tenantId).getUserStoreManager(); - List currentUserRoles = getRoles(groupId); - GroupManagementDAOFactory.beginTransaction(); - if (newRoles != null) { - for (String role : newRoles) { - if (!userStoreManager.isExistingRole(role)) { - throw new RoleDoesNotExistException("Role '" + role + "' does not exists in the user store."); - } - // Removing role from current user roles of the group will return true if role exist. - // So we don't need to add it to the db again. - if (!currentUserRoles.remove(role)) { - // If group doesn't have the role, it is adding to the db. - groupDAO.addRole(groupId, role, tenantId); - } + if (log.isDebugEnabled()) { + log.debug("Manage group sharing for group: " + groupId); + } + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + UserStoreManager userStoreManager; + try { + userStoreManager = + DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm( + tenantId).getUserStoreManager(); + List currentUserRoles = getRoles(groupId); + GroupManagementDAOFactory.beginTransaction(); + if (newRoles != null) { + for (String role : newRoles) { + if (!userStoreManager.isExistingRole(role)) { + throw new RoleDoesNotExistException("Role '" + role + "' does not exists in the user store."); + } + // Removing role from current user roles of the group will return true if role exist. + // So we don't need to add it to the db again. + if (!currentUserRoles.remove(role)) { + // If group doesn't have the role, it is adding to the db. + groupDAO.addRole(groupId, role, tenantId); } } - for (String role : currentUserRoles) { - // Removing old roles from db which are not available in the new roles list. - groupDAO.removeRole(groupId, role, tenantId); - } - GroupManagementDAOFactory.commitTransaction(); - } catch (GroupManagementDAOException e) { - GroupManagementDAOFactory.rollbackTransaction(); - throw new GroupManagementException(e); - } catch (UserStoreException e) { - throw new GroupManagementException("User store error in updating sharing roles.", e); - } catch (TransactionManagementException e) { - throw new GroupManagementException(e); - } finally { - GroupManagementDAOFactory.closeConnection(); + } + for (String role : currentUserRoles) { + // Removing old roles from db which are not available in the new roles list. + groupDAO.removeRole(groupId, role, tenantId); + } + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + log.error(e); + throw new GroupManagementException(e); + } catch (UserStoreException e) { + String msg = "User store error in updating sharing roles."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (TransactionManagementException e) { + log.error(e); + throw new GroupManagementException(e); + } catch (Exception e) { + String msg = "Error occurred in manageGroupSharing for groupId: " + groupId; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); } } @@ -407,14 +608,25 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid */ @Override public List getRoles(int groupId) throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Group roles for group: " + groupId); + } try { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); GroupManagementDAOFactory.openConnection(); return groupDAO.getRoles(groupId, tenantId); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); + String msg = "Error occurred while retrieving all groups in tenant"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getRoles for groupId: " + groupId; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -426,6 +638,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public List getDevices(int groupId, int startIndex, int rowCount) throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Group devices of group: " + groupId + " start index " + startIndex + " row count " + rowCount); + } int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); List devices; try { @@ -433,11 +648,21 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid GroupManagementDAOFactory.openConnection(); devices = this.groupDAO.getDevices(groupId, startIndex, rowCount, tenantId); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while getting devices in group.", e); + String msg = "Error occurred while getting devices in group."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (DeviceManagementException e) { - throw new GroupManagementException("Error occurred while validating the limit of the devices to be returned", e); + String msg = "Error occurred while validating the limit of the devices to be returned"; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevices for groupId: " + groupId; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -449,13 +674,24 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid */ @Override public int getDeviceCount(int groupId) throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Group devices count of group: " + groupId); + } try { GroupManagementDAOFactory.openConnection(); return groupDAO.getDeviceCount(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId()); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while retrieving all groups in tenant", e); + String msg = "Error occurred while retrieving all groups in tenant"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening a connection to the data source.", e); + String msg = "Error occurred while opening a connection to the data source."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDeviceCount for groupId: " + groupId; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -467,6 +703,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public void addDevices(int groupId, List deviceIdentifiers) throws GroupManagementException, DeviceNotFoundException { + if (log.isDebugEnabled()) { + log.debug("Group devices to the group: " + groupId); + } Device device; try { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); @@ -483,12 +722,22 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } GroupManagementDAOFactory.commitTransaction(); } catch (DeviceManagementException e) { - throw new GroupManagementException("Error occurred while retrieving device.", e); + String msg = "Error occurred while retrieving device."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); - throw new GroupManagementException("Error occurred while adding device to group.", e); + String msg = "Error occurred while adding device to group."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (TransactionManagementException e) { - throw new GroupManagementException("Error occurred while initiating transaction.", e); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in addDevices for groupId " + groupId; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -500,6 +749,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public void removeDevice(int groupId, List deviceIdentifiers) throws GroupManagementException, DeviceNotFoundException { + if (log.isDebugEnabled()) { + log.debug("Remove devices from the group: " + groupId); + } Device device; try { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); @@ -514,12 +766,22 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } GroupManagementDAOFactory.commitTransaction(); } catch (DeviceManagementException e) { - throw new GroupManagementException("Error occurred while retrieving device.", e); + String msg = "Error occurred while retrieving device."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (TransactionManagementException e) { - throw new GroupManagementException("Error occurred while initiating transaction.", e); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); - throw new GroupManagementException("Error occurred while adding device to group.", e); + String msg = "Error occurred while adding device to group."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in removeDevice for groupId: " + groupId; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -530,6 +792,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid */ @Override public List getGroups(String username, String permission) throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Get groups of user '" + username + "'"); + } List deviceGroups = getGroups(username); Map permittedDeviceGroups = new HashMap<>(); UserRealm userRealm; @@ -546,13 +811,27 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } } catch (UserStoreException e) { - throw new GroupManagementException("Error occurred while getting user realm.", e); + String msg = "Error occurred while getting user realm."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getGroups for username '" + username + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } return new ArrayList<>(permittedDeviceGroups.values()); } @Override public List getGroups(DeviceIdentifier deviceIdentifier) throws GroupManagementException { + if (deviceIdentifier == null) { + String msg = "Received empty device identifier for getGroups"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get groups of device " + deviceIdentifier.getId()); + } DeviceManagementProviderService managementProviderService = new DeviceManagementProviderServiceImpl(); try { Device device = managementProviderService.getDevice(deviceIdentifier, false); @@ -560,11 +839,21 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid return groupDAO.getGroups(device.getId(), PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); } catch (DeviceManagementException e) { - throw new GroupManagementException("Error occurred while retrieving the device details.", e); + String msg = "Error occurred while retrieving the device details."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (GroupManagementDAOException e) { - throw new GroupManagementException("Error occurred while retrieving device groups.", e); + String msg = "Error occurred while retrieving device groups."; + log.error(msg, e); + throw new GroupManagementException(msg, e); } catch (SQLException e) { - throw new GroupManagementException("Error occurred while opening database connection.", e); + String msg = "Error occurred while opening database connection."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getGroups"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } @@ -575,7 +864,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid */ @Override public DeviceGroup createDefaultGroup(String groupName) throws GroupManagementException { - + if (log.isDebugEnabled()) { + log.debug("Create default group " + groupName); + } DeviceGroup defaultGroup = this.getGroup(groupName); if (defaultGroup == null) { defaultGroup = new DeviceGroup(groupName); @@ -586,10 +877,13 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid this.createGroup(defaultGroup, DeviceGroupConstants.Roles.DEFAULT_ADMIN_ROLE, DeviceGroupConstants.Permissions.DEFAULT_ADMIN_PERMISSIONS); } catch (GroupAlreadyExistException e) { - if (log.isDebugEnabled()) { - log.debug("Default group: " + defaultGroup.getName() + " already exists. Skipping group creation.", - e); - } + String msg = "Default group: " + defaultGroup.getName() + " already exists. Skipping group creation."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in createDefaultGroup for groupName '" + groupName + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); } return this.getGroup(groupName); } else { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index a350383e78..54dec0543d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml index 894ee703e1..1eb21eab09 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 3.0.82-SNAPSHOT + 3.0.95-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs index 9e6ee54a71..62cea7955e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs @@ -73,18 +73,7 @@

Group was created successfully.

-
Please click "Add Another Group", if you wish to add another group or click - "View Group List" to complete the process and go back to the group list. -
- - - - - - - Add Another Group - +
You will be redirected to the Group Listing page in a moment.
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js index 85b34decd9..1684159e6d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js @@ -47,6 +47,9 @@ $(function () { if (resp.status == 201) { $("#group-create-form").addClass("hidden"); $("#group-created-msg").removeClass("hidden"); + setTimeout(function() { + window.location.href = "/devicemgt/groups"; + }, 1000); } else { displayErrors(resp.status); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs index 8f20dc3e53..7e556c556c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs @@ -87,7 +87,7 @@

-

You don't have any device group. Let's add a new device group!

+

You don't have any device groups. Let's add a new device group!

{{#if permissions.ADD_GROUP}}

@@ -236,7 +236,7 @@
-

Do you really want to remove this group from your Group List?

+

Do you really want to remove this group?

@@ -257,7 +257,7 @@
-

Group was successfully removed.

+

Successfully removed the group.

diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs index 77ec4d34a6..0e4a7840e8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs @@ -237,10 +237,12 @@ data-search="{{status}}" data-display="{{status}}"> - +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/public/js/policy-list.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/public/js/policy-list.js index 0d94332844..64be08e91b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/public/js/policy-list.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/public/js/policy-list.js @@ -385,4 +385,7 @@ $(document).ready(function () { $("#policy-listing-status").removeClass("hidden"); } $("#policy-grid").removeClass("hidden"); + + $('[data-toggle="tooltip"]').tooltip(); + }); \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.hbs index ad8f81f82a..49c4d14be1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.hbs @@ -37,6 +37,14 @@ {{/zone}} +{{#zone "navbarActions"}} + {{#if canEdit}} +
  • + +
  • + {{/if}} +{{/zone}} + {{#zone "content"}} {{unit "cdmf.unit.device.operation-mod"}} {{unit "cdmf.unit.policy.view"}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.js index 07e42077e6..0032639ca3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.view/view.js @@ -17,7 +17,14 @@ */ function onRequest(context) { + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var utility = require("/app/modules/utility.js")["utility"]; var deviceType = request.getParameter("type"); - return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, "policy-view")}; + + var canEdit = false; + if(userModule.isAuthorized("/permission/admin/device-mgt/policy/manage")) { + canEdit = true; + } + + return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, "policy-view"), "canEdit": canEdit}; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js index 516aacb7b5..c1acb8e9f2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js @@ -140,7 +140,7 @@ function loadRoles() { } }, { - class: "text-right content-fill text-left-on-grid-view no-wrap", + class: "text-right content-fill text-left-on-grid-view no-wrap tooltip-overflow-fix", data: null, render: function (data, type, row, meta) { var isCloud = false; @@ -153,7 +153,9 @@ function loadRoles() { var editLink = '
    ' + + 'data-toggle="tooltip" ' + + 'data-original-title="Edit Role"' + + 'class="btn padding-reduce-on-grid-view edit-role-link"> ' + '' + '' + '' + @@ -167,7 +169,9 @@ function loadRoles() { var editPermissionLink = '' + '' + '' + @@ -182,6 +186,8 @@ function loadRoles() { var removeLink = '' + '' + '' + @@ -272,4 +278,7 @@ $("#role-grid").on("click", ".remove-role-link", function () { $(document).ready(function () { loadRoles(); + $(function () { + $('[data-toggle="tooltip"]').tooltip() + }); }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs index e69c9d4184..183e124bfa 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs @@ -16,7 +16,7 @@ under the License. }} {{unit "cdmf.unit.ui.title" pageTitle="User Management | Add User"}} - +{{unit "cdmf.unit.ui.modal"}} {{#zone "breadcrumbs"}}
  • @@ -122,26 +122,14 @@
  • - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js index 2ecada94ad..c700b06199 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js @@ -248,6 +248,10 @@ $(document).ready(function () { // Refreshing with success message $("#user-create-form").addClass("hidden"); $("#user-created-msg").removeClass("hidden"); + setTimeout(function () { + window.location.href = "/devicemgt/users" + }, 1000); + } }, function (jqXHR) { var payload = JSON.parse(jqXHR.responseText); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.hbs index dd86421cc7..aec56d47c9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.hbs @@ -35,6 +35,21 @@ {{/zone}} +{{#zone "navbarActions"}} + {{#if canEdit}} +
  • + + + + + + Edit + +
  • + {{/if}} +{{/zone}} + {{#zone "content"}} {{#if canView}} {{#if exists}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js index 0be5dd28df..997711701c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js @@ -48,7 +48,13 @@ function onRequest(context) { canView = true; } + var canEdit = false; + if (userModule.isAuthorized("/permission/admin/device-mgt/users/edit")) { + canEdit = true; + } + var isCloud = deviceMgtProps.isCloud; - return {"exists": isExsistingUser, "user": user, "userRoles": userRoles, "devices": devices, "canView": canView, "isCloud" : isCloud}; + return {"exists": isExsistingUser, "user": user, "userRoles": userRoles, "devices": devices, "canEdit": canEdit, + "canView": canView, "isCloud" : isCloud}; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js index c3291ef592..ae15c3aea9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js @@ -89,10 +89,11 @@ $("a#invite-user-link").click(function () { modalDialog.hide(); }); }, - function () { + function (data) { + var msg = JSON.parse(data.responseText); modalDialog.header(' Unexpected Error !'); - modalDialog.content('An unexpected error occurred. Try again later.'); + modalDialog.content(msg.message); modalDialog.footer(''); $("a#invite-user-error-link").click(function () { @@ -293,7 +294,10 @@ function loadUsers() { //noinspection JSUnusedLocalSymbols var fnCreatedRow = function (nRow, aData, iDataIndex) { - $(nRow).attr('data-type', 'selectable'); + var adminUser = $("#user-table").data("user"); + if (adminUser !== aData["filter"]) { + $(nRow).attr('data-type', 'selectable'); + } $(nRow).attr('data-username', aData["filter"]); }; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs index 1bc375a190..e7caea09d2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs @@ -38,23 +38,10 @@ @@ -82,9 +69,7 @@ + and should be 1-to-30 characters long.

    @@ -285,7 +270,7 @@ {{#unless types}}

    No compatible device types have been installed. - Install device types to add policies.

    + Install device types to add policies. {{/unless}}
    diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js index ab7db6eeb4..2c8cb74a4a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js @@ -428,6 +428,10 @@ var savePolicy = function (policy, isActive, serviceURL) { $(".add-policy").addClass("hidden"); $(".policy-naming").addClass("hidden"); $(".policy-message").removeClass("hidden"); + setTimeout(function() { + window.location.href = "/devicemgt/policies"; + }, 1000); + }, function (data) { } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs index 4abf440dc3..e5822f5736 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs @@ -35,20 +35,8 @@

    Policy is successfully re-configured.

    -
    Please click "Add Another Policy", if you wish to add another policy or click - "View policy list" to complete the process and go back to the policy list. -
    - - - - - - - Add another policy - +
    You will be redirected to Policy Listing page in a moment. +
    diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js index e2a7182b6b..6242ec3a55 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js @@ -495,6 +495,9 @@ var updatePolicy = function (policy, state) { if (jqXHR.status == 200) { $(".add-policy").addClass("hidden"); $(".policy-message").removeClass("hidden"); + setTimeout(function() { + window.location.href = "/devicemgt/policies"; + }, 1000); } }, // on error @@ -513,6 +516,9 @@ var updatePolicy = function (policy, state) { $(".add-policy").addClass("hidden"); $(".policy-naming").addClass("hidden"); $(".policy-message").removeClass("hidden"); + setTimeout(function() { + window.location.href = "/devicemgt/policies"; + }, 1000); } }, // on error diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js index 73f504e81e..2f035e80c3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js @@ -66,6 +66,7 @@ var displayPolicy = function (policyPayloadObj) { $("#roles-row").addClass("hidden"); } + var policyId = policyPayloadObj["id"]; var deviceType = policy["platform"]; var policyOperations = $("#policy-operations"); var policyViewTemplateSrc = $(policyOperations).data("template"); @@ -110,6 +111,23 @@ var displayPolicy = function (policyPayloadObj) { if (!hasPolicyProfileScript) { populateGenericProfileOperations(policyPayloadObj["profile"]["profileFeaturesList"]); } + + var policyEditContent = + "" + + "" + + "" + + "" + + "" + + " Edit" + + ""; + + $("#policy-edit").html(policyEditContent); + }; /** diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.hbs index 8671888233..30317ac052 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.hbs @@ -69,19 +69,8 @@ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js index 315ab20d22..4259195bb0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js @@ -184,6 +184,9 @@ $(document).ready(function () { // Refreshing with success message $("#role-create-form").addClass("hidden"); $("#role-created-msg").removeClass("hidden"); + setTimeout(function() { + window.location.href = "/devicemgt/roles"; + }, 1000); } }, function (data) { var payload = JSON.parse(data.responseText); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.hbs index 979b5c1450..76fc116776 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.hbs @@ -73,20 +73,7 @@ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js index 6ae0e8016f..ee26b9d0b1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js @@ -210,6 +210,9 @@ $(document).ready(function () { // Refreshing with success message $("#role-create-form").addClass("hidden"); $("#role-created-msg").removeClass("hidden"); + setTimeout(function() { + window.location.href = "/devicemgt/roles"; + }, 1000); } }, function (data) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/public/js/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/public/js/user-menu.js index ecd93a8bc6..7ef1c320bc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/public/js/user-menu.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/public/js/user-menu.js @@ -86,7 +86,9 @@ $(document).ready(function () { $("#change-password-success-link").click(function () { hidePopup(); }); - window.location.href = "/devicemgt/logout"; + setTimeout(function(){ + window.location.href = "/devicemgt/logout"; + },10000); } }, function (jqXHR) { if (jqXHR.status == 400) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs index ee2ccdc968..7e0fac5d3e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs @@ -104,7 +104,7 @@