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 e7760616c9..2cab7a46e1 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 3.0.89-SNAPSHOT + 3.0.101-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 94d3e00b28..d51b75ae35 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 - 3.0.89-SNAPSHOT + 3.0.101-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 5b72c4d911..7ba14b455c 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 - 3.0.89-SNAPSHOT + 3.0.101-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 0ab1e7e2fe..613a5a9365 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handlers - 3.0.89-SNAPSHOT + 3.0.101-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 6ca21a382e..9e43b7e159 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 3.0.89-SNAPSHOT + 3.0.101-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.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java index 94c6f7e87c..6341dc7a22 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java @@ -22,22 +22,35 @@ import feign.RequestInterceptor; import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.apimgt.integration.client.store.StoreClient; -import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; - -import java.util.HashMap; -import java.util.Map; public class IntegrationClientServiceImpl implements IntegrationClientService { - private static StoreClient storeClient; - private static PublisherClient publisherClient; - private static Map tenantUserTokenMap = new HashMap<>(); + private static IntegrationClientServiceImpl instance; + private StoreClient storeClient; + private PublisherClient publisherClient; + private OAuthRequestInterceptor oAuthRequestInterceptor; - public IntegrationClientServiceImpl() { - RequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); + private IntegrationClientServiceImpl() { + oAuthRequestInterceptor = new OAuthRequestInterceptor(); storeClient = new StoreClient(oAuthRequestInterceptor); publisherClient = new PublisherClient(oAuthRequestInterceptor); } + + public static IntegrationClientServiceImpl getInstance() { + if (instance == null) { + synchronized (IntegrationClientService.class) { + if (instance == null) { + instance = new IntegrationClientServiceImpl(); + } + } + } + return instance; + } + + public void resetUserInfo(String userName, String tenantDomain) { + oAuthRequestInterceptor.removeToken(userName, tenantDomain); + } + @Override public StoreClient getStoreClient() { return storeClient; @@ -47,8 +60,4 @@ public class IntegrationClientServiceImpl implements IntegrationClientService { public PublisherClient getPublisherClient() { return publisherClient; } - - public static Map getTenantUserTokenMap() { - return tenantUserTokenMap; - } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java index b78f258c27..b4bc910686 100755 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java @@ -40,6 +40,7 @@ import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientExceptio import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; /** * This is a request interceptor to add oauth token header. @@ -55,6 +56,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { private static final long DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS = 100000; private DCRClient dcrClient; private static OAuthApplication oAuthApplication; + private static Map tenantUserTokenMap = new ConcurrentHashMap<>(); private static final Log log = LogFactory.getLog(OAuthRequestInterceptor.class); /** @@ -88,7 +90,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { username = username + "@" + tenantDomain; } - AccessTokenInfo tenantBasedAccessTokenInfo = IntegrationClientServiceImpl.getTenantUserTokenMap().get(username); + AccessTokenInfo tenantBasedAccessTokenInfo = tenantUserTokenMap.get(username); if ((tenantBasedAccessTokenInfo == null || ((System.currentTimeMillis() + DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS) > tenantBasedAccessTokenInfo.getExpiresIn()))) { @@ -96,8 +98,8 @@ public class OAuthRequestInterceptor implements RequestInterceptor { JWTClient jwtClient = APIIntegrationClientDataHolder.getInstance().getJwtClientManagerService() .getJWTClient(); tenantBasedAccessTokenInfo = jwtClient.getAccessToken(oAuthApplication.getClientId(), - oAuthApplication.getClientSecret(), username, - REQUIRED_SCOPE); + oAuthApplication.getClientSecret(), username, + REQUIRED_SCOPE); tenantBasedAccessTokenInfo.setExpiresIn( System.currentTimeMillis() + (tenantBasedAccessTokenInfo.getExpiresIn() * 1000)); if (tenantBasedAccessTokenInfo.getScopes() == null) { @@ -105,7 +107,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { } if (tenantBasedAccessTokenInfo.getScopes().contains(APIM_SUBSCRIBE_SCOPE)) { - IntegrationClientServiceImpl.getTenantUserTokenMap().put(username, tenantBasedAccessTokenInfo); + tenantUserTokenMap.put(username, tenantBasedAccessTokenInfo); } } @@ -118,4 +120,11 @@ public class OAuthRequestInterceptor implements RequestInterceptor { } } + public void removeToken(String username, String tenantDomain) { + if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + username = username + "@" + tenantDomain; + } + tenantUserTokenMap.remove(username); + } + } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java index aaf178b718..4e09da489f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java @@ -49,7 +49,7 @@ public class APIIntegrationClientServiceComponent { /* Initializing webapp publisher configuration */ APIMConfigReader.init(); BundleContext bundleContext = componentContext.getBundleContext(); - bundleContext.registerService(IntegrationClientService.class.getName(), new IntegrationClientServiceImpl(), null); + bundleContext.registerService(IntegrationClientService.class.getName(), IntegrationClientServiceImpl.getInstance(), null); if (log.isDebugEnabled()) { log.debug("apimgt client bundle has been successfully initialized"); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java index 0ac7e4616f..a98571ef4f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java @@ -26,6 +26,9 @@ import org.wso2.carbon.apimgt.integration.client.store.StoreClient; */ public interface IntegrationClientService { + + void resetUserInfo(String username, String tenantDomain); + /** * * @return API Store 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 53ea95da89..7d5dab2df1 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.generated.client - 3.0.89-SNAPSHOT + 3.0.101-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 d270c1ce9a..74f58200d1 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 3.0.89-SNAPSHOT + 3.0.101-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 3cdb1a0196..9ca7a768b1 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 3.0.89-SNAPSHOT + 3.0.101-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 9a71296ada..5ff46b2f4a 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.89-SNAPSHOT + 3.0.101-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 9a975c8fa9..7e8626673a 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.89-SNAPSHOT + 3.0.101-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 abb3e5e07e..9cd6fed547 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 3.0.89-SNAPSHOT + 3.0.101-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 bb4b5aa23a..ad86585aae 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 3.0.89-SNAPSHOT + 3.0.101-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 4e1f1ae38a..912f94781e 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.89-SNAPSHOT + 3.0.101-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 8e9a729ed0..69823adad6 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.89-SNAPSHOT + 3.0.101-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 92391bd23f..12bf240500 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.89-SNAPSHOT + 3.0.101-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 98f49d9ee6..5025780a5b 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.89-SNAPSHOT + 3.0.101-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 a433345d3e..9938dded44 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.89-SNAPSHOT + 3.0.101-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 173151daeb..fa6f258fcc 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 55847b4c27..ad6b11685e 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.89-SNAPSHOT + 3.0.101-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 83cb191e50..2d7f2ecee1 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.89-SNAPSHOT + 3.0.101-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 d62b1aa4f3..4296f52c99 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.89-SNAPSHOT + 3.0.101-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 eae40032d2..994c4f2d26 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml @@ -177,6 +177,11 @@ org.wso2.carbon.device.mgt.extensions provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.integration.client + provided + org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.core diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java index d396237df4..978b449885 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -30,6 +30,7 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList; import org.wso2.carbon.device.mgt.jaxrs.service.api.RoleManagementService; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; +import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.device.mgt.jaxrs.util.SetReferenceTransformer; import org.wso2.carbon.registry.api.Registry; @@ -68,6 +69,9 @@ public class RoleManagementServiceImpl implements RoleManagementService { @HeaderParam("If-Modified-Since") String ifModifiedSince, @QueryParam("offset") int offset, @QueryParam("limit") int limit) { RequestValidationUtil.validatePaginationParameters(offset, limit); + if (limit == 0){ + limit = Constants.DEFAULT_PAGE_LIMIT; + } List filteredRoles; RoleList targetRoles = new RoleList(); 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..831c279c27 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 @@ -88,12 +88,12 @@ public class UserManagementServiceImpl implements UserManagementService { // Permissions that are given for a normal device user. private static final Permission[] PERMISSIONS_FOR_DEVICE_USER = { - new Permission("/permission/admin/Login", "ui.execute"), - new Permission("/permission/admin/device-mgt/device/api/subscribe", "ui.execute"), - new Permission("/permission/admin/device-mgt/devices/enroll", "ui.execute"), - new Permission("/permission/admin/device-mgt/devices/disenroll", "ui.execute"), - new Permission("/permission/admin/device-mgt/devices/owning-device/view", "ui.execute"), - new Permission("/permission/admin/manage/portal", "ui.execute") + new Permission("/permission/admin/Login", "ui.execute"), + new Permission("/permission/admin/device-mgt/device/api/subscribe", "ui.execute"), + new Permission("/permission/admin/device-mgt/devices/enroll", "ui.execute"), + new Permission("/permission/admin/device-mgt/devices/disenroll", "ui.execute"), + new Permission("/permission/admin/device-mgt/devices/owning-device/view", "ui.execute"), + new Permission("/permission/admin/manage/portal", "ui.execute") }; @POST @@ -134,7 +134,7 @@ public class UserManagementServiceImpl implements UserManagementService { } userStoreManager.addUser(userInfo.getUsername(), initialUserPassword, - roles, defaultUserClaims, null); + roles, defaultUserClaims, null); // Outputting debug message upon successful addition of user if (log.isDebugEnabled()) { log.debug("User '" + userInfo.getUsername() + "' has successfully been added."); @@ -158,7 +158,7 @@ public class UserManagementServiceImpl implements UserManagementService { dms.sendRegistrationEmail(metaInfo); return Response.created(new URI(API_BASE_PATH + "/" + URIEncoder.encode(userInfo.getUsername(), "UTF-8"))) .entity( - createdUserInfo).build(); + createdUserInfo).build(); } catch (UserStoreException e) { String msg = "Error occurred while trying to add user '" + userInfo.getUsername() + "' to the " + "underlying user management system"; @@ -227,11 +227,11 @@ public class UserManagementServiceImpl implements UserManagementService { if (!userStoreManager.isExistingUser(username)) { if (log.isDebugEnabled()) { log.debug("User by username: " + username + - " doesn't exists. Therefore, request made to update user was refused."); + " doesn't exists. Therefore, request made to update user was refused."); } return Response.status(Response.Status.NOT_FOUND).entity( new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " + - username + " doesn't exist.").build()).build(); + username + " doesn't exist.").build()).build(); } Map defaultUserClaims = @@ -240,7 +240,7 @@ public class UserManagementServiceImpl implements UserManagementService { if (StringUtils.isNotEmpty(userInfo.getPassword())) { // Decoding Base64 encoded password userStoreManager.updateCredentialByAdmin(username, - userInfo.getPassword()); + userInfo.getPassword()); log.debug("User credential of username: " + username + " has been changed"); } List currentRoles = this.getFilteredRoles(userStoreManager, username); @@ -259,8 +259,8 @@ public class UserManagementServiceImpl implements UserManagementService { rolesToDelete.remove(ROLE_EVERYONE); rolesToAdd.remove(ROLE_EVERYONE); userStoreManager.updateRoleListOfUser(username, - rolesToDelete.toArray(new String[rolesToDelete.size()]), - rolesToAdd.toArray(new String[rolesToAdd.size()])); + rolesToDelete.toArray(new String[rolesToDelete.size()]), + rolesToAdd.toArray(new String[rolesToAdd.size()])); userStoreManager.setUserClaimValues(username, defaultUserClaims, null); // Outputting debug message upon successful addition of user if (log.isDebugEnabled()) { @@ -363,7 +363,9 @@ public class UserManagementServiceImpl implements UserManagementService { } RequestValidationUtil.validatePaginationParameters(offset, limit); - + if (limit == 0) { + limit = Constants.DEFAULT_PAGE_LIMIT; + } List userList, offsetList; String appliedFilter = ((filter == null) || filter.isEmpty() ? "*" : filter + "*"); // to get whole set of users, appliedLimit is set to -1 @@ -420,7 +422,7 @@ public class UserManagementServiceImpl implements UserManagementService { UserStoreCountRetriever userStoreCountRetrieverService = DeviceMgtAPIUtils.getUserStoreCountRetrieverService(); RealmConfiguration secondaryRealmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm(). getRealmConfiguration().getSecondaryRealmConfig(); - + if (secondaryRealmConfiguration != null) { if (!secondaryRealmConfiguration.isPrimary() && !Constants.JDBC_USERSTOREMANAGER. equals(secondaryRealmConfiguration.getUserStoreClass().getClass())) { @@ -473,7 +475,8 @@ public class UserManagementServiceImpl implements UserManagementService { @GET @Path("/checkUser") - @Override public Response isUserExists(@QueryParam("username") String userName) { + @Override + public Response isUserExists(@QueryParam("username") String userName) { try { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); boolean userExists = false; @@ -494,7 +497,7 @@ public class UserManagementServiceImpl implements UserManagementService { @Path("/search/usernames") @Override public Response getUserNames(@QueryParam("filter") String filter, @QueryParam("domain") String domain, - @HeaderParam("If-Modified-Since") String timestamp, + @HeaderParam("If-Modified-Since") String timestamp, @QueryParam("offset") int offset, @QueryParam("limit") int limit) { if (log.isDebugEnabled()) { log.debug("Getting the list of users with all user-related information using the filter : " + filter); @@ -503,21 +506,23 @@ public class UserManagementServiceImpl implements UserManagementService { if (domain != null && !domain.isEmpty()) { userStoreDomain = domain; } + if (limit == 0){ + //If there is no limit is passed, then return all. + limit = -1; + } List userList; try { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); - String[] users = userStoreManager.listUsers(userStoreDomain + "/*", -1); + String[] users = userStoreManager.listUsers(userStoreDomain + "/" + filter + "*", limit); userList = new ArrayList<>(); UserInfo user; for (String username : users) { - if (username.contains(filter)) { - user = new UserInfo(); - user.setUsername(username); - user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS)); - user.setFirstname(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME)); - user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME)); - userList.add(user); - } + user = new UserInfo(); + user.setUsername(username); + user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS)); + user.setFirstname(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME)); + user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME)); + userList.add(user); } return Response.status(Response.Status.OK).entity(userList).build(); } catch (UserStoreException e) { @@ -558,11 +563,16 @@ public class UserManagementServiceImpl implements UserManagementService { EmailMetaInfo metaInfo = new EmailMetaInfo(recipient, props); dms.sendEnrolmentInvitation(DeviceManagementConstants.EmailAttributes.USER_ENROLLMENT_TEMPLATE, - metaInfo); + metaInfo); } } 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); @@ -655,8 +665,8 @@ public class UserManagementServiceImpl implements UserManagementService { private String getEnrollmentTemplateName(String deviceType) { String templateName = deviceType + "-enrollment-invitation"; File template = new File(CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator - + "resources" + File.separator + "email-templates" + File.separator + templateName - + ".vm"); + + "resources" + File.separator + "email-templates" + File.separator + templateName + + ".vm"); if (template.exists()) { return templateName; } else { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java index 55dd398e18..728c461c7b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/Constants.java @@ -30,6 +30,7 @@ public class Constants { public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; + public static final int DEFAULT_PAGE_LIMIT = 50; public final class ErrorMessages { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java index a44444aa3d..d326802c2a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java @@ -20,8 +20,6 @@ package org.wso2.carbon.device.mgt.jaxrs.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.integration.client.IntegrationClientServiceImpl; -import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; @@ -56,7 +54,7 @@ public class CredentialManagementResponseBuilder { RequestValidationUtil.validateCredentials(credentials); if (!validateCredential(credentials.getNewPassword())) { String errorMsg = DeviceMgtAPIUtils.getRealmService().getBootstrapRealmConfiguration() - .getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG); + .getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG); return Response.status(Response.Status.BAD_REQUEST).entity( new ErrorResponse.ErrorResponseBuilder().setMessage(errorMsg).build()).build(); } @@ -66,9 +64,8 @@ public class CredentialManagementResponseBuilder { username = CarbonContext.getThreadLocalCarbonContext().getUsername(); userStoreManager.updateCredential(username, credentials.getNewPassword(), credentials.getOldPassword()); - IntegrationClientServiceImpl integrationClientService = (IntegrationClientServiceImpl) PrivilegedCarbonContext. - getThreadLocalCarbonContext().getOSGiService(IntegrationClientService.class, null); - integrationClientService.getTenantUserTokenMap().remove(username); + DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username, + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); return Response.status(Response.Status.OK).entity("UserImpl password by username: " + username + " was successfully changed.").build(); } catch (UserStoreException e) { @@ -111,6 +108,8 @@ public class CredentialManagementResponseBuilder { new ErrorResponse.ErrorResponseBuilder().setMessage(errorMsg).build()).build(); } userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword()); + DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username, + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); return Response.status(Response.Status.OK).entity("UserImpl password by username: " + username + " was successfully changed.").build(); } catch (UserStoreException e) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index 8b12b4a285..7ff6953a1d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -29,6 +29,7 @@ import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; +import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.analytics.api.AnalyticsDataAPI; import org.wso2.carbon.context.CarbonContext; @@ -128,6 +129,8 @@ public class DeviceMgtAPIUtils { private static KeyStore trustStore; private static char[] keyStorePassword; + private static IntegrationClientService integrationClientService; + static { String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty( @@ -297,6 +300,23 @@ public class DeviceMgtAPIUtils { return realmService; } + public static IntegrationClientService getIntegrationClientService() { + if (integrationClientService == null) { + synchronized (DeviceMgtAPIUtils.class) { + if (integrationClientService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + integrationClientService = (IntegrationClientService) ctx.getOSGiService(IntegrationClientService.class, null); + if (integrationClientService == null) { + String msg = "IntegrationClientService is not initialized"; + log.error(msg); + throw new IllegalStateException(msg); + } + } + } + } + return integrationClientService; + } + public static RegistryService getRegistryService() { RegistryService registryService; PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -459,7 +479,7 @@ public class DeviceMgtAPIUtils { return realmService.getTenantManager().getTenantId(tenantDomain); } catch (UserStoreException e) { throw new DeviceManagementException("Error occured while trying to " + - "obtain tenant id of currently logged in user"); + "obtain tenant id of currently logged in user"); } } @@ -513,8 +533,8 @@ public class DeviceMgtAPIUtils { streamOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); streamOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER , new Protocol(DEFAULT_HTTP_PROTOCOL - , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) - , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); + , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) + , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); eventStreamAdminServiceStub._getServiceClient().setOptions(streamOptions); return eventStreamAdminServiceStub; } @@ -544,8 +564,8 @@ public class DeviceMgtAPIUtils { eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER , new Protocol(DEFAULT_HTTP_PROTOCOL - , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) - , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); + , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) + , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); receiverAdminServiceStub._getServiceClient().setOptions(eventReciverOptions); return receiverAdminServiceStub; @@ -576,8 +596,8 @@ public class DeviceMgtAPIUtils { eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER , new Protocol(DEFAULT_HTTP_PROTOCOL - , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) - , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); + , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) + , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); eventPublisherAdminServiceStub._getServiceClient().setOptions(eventReciverOptions); return eventPublisherAdminServiceStub; } @@ -608,8 +628,8 @@ public class DeviceMgtAPIUtils { eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER , new Protocol(DEFAULT_HTTP_PROTOCOL - , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) - , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); + , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) + , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); eventStreamPersistenceAdminServiceStub._getServiceClient().setOptions(eventReciverOptions); return eventStreamPersistenceAdminServiceStub; @@ -617,6 +637,7 @@ public class DeviceMgtAPIUtils { /** * This method is used to create the Cache that holds the event definition of the device type.. + * * @return Cachemanager */ public static synchronized Cache getDynamicEventCache() { @@ -669,7 +690,7 @@ public class DeviceMgtAPIUtils { * Initializes the SSL Context */ private static void initSSLConnection() throws NoSuchAlgorithmException, UnrecoverableKeyException, - KeyStoreException, KeyManagementException { + KeyStoreException, KeyManagementException { KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KEY_MANAGER_TYPE); keyManagerFactory.init(keyStore, keyStorePassword); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TRUST_MANAGER_TYPE); 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 62e9bb0c98..04edd04a30 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.89-SNAPSHOT + 3.0.101-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 15244bd601..0915695dab 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java index 7a3b487121..4c06d507ca 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java @@ -350,7 +350,9 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis if (deviceStatusTaskPluginConfig != null && deviceStatusTaskPluginConfig.isRequireStatusMonitoring()) { try { DeviceManagementDataHolder.getInstance().removeDeviceStatusTaskPluginConfig(deviceType); - deviceStatusTaskManagerService.stopTask(deviceType, deviceStatusTaskPluginConfig); + if (deviceStatusTaskManagerService != null) { + deviceStatusTaskManagerService.stopTask(deviceType, deviceStatusTaskPluginConfig); + } } catch (DeviceStatusTaskException e) { throw new DeviceManagementException("Error occurred while stopping Device Status task service for '" + deviceManagementService.getType() + "'", e); 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..24eeb42b01 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,7 +1712,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getDevicesByNameAndType(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException { - List devices = new ArrayList<>(); + 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 allDevices; int limit = DeviceManagerUtil.validateDeviceListPageSize(request.getRowCount()); try { @@ -1290,10 +1727,18 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv allDevices = deviceDAO.getDevicesByNameAndType(request.getDeviceName(), request.getDeviceType(), this.getTenantId(), request.getStartIndex(), limit); } 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 +1757,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 +1777,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 +1802,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 +1817,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 +1836,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 +1875,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 +1886,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 +1910,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 +1931,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 +1984,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 +2017,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 +2042,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 +2056,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 +2106,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 +2123,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 +2165,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 +2192,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 +2210,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 +2233,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 +2265,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,41 +2292,65 @@ 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(); info = deviceInfoDAO.getDeviceInformation(device.getId()); DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId()); - if (info != null) { - info.setLocation(location); + if (location != null) { + //There are some cases where the device-info is not updated properly. Hence returning a null value. + if (info != null) { + info.setLocation(location); + } else { + info = new DeviceInfo(); + 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 +2358,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 +2374,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 +2384,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 +2423,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 ed9bbc7a61..bea5b0bdb4 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.89-SNAPSHOT + 3.0.101-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 0154e8fac1..6ef879b889 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.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 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 c1acb8e9f2..fa2eaffb6e 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 @@ -150,6 +150,8 @@ function loadRoles() { var innerhtml = ''; + var isAdminRole = $("#role-table").data("role") === data.name; + var editLink = '
    '; - if (!isCloud) { + if (!isCloud && !isAdminRole) { innerhtml = editLink + editPermissionLink + removeLink; } return innerhtml; 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..f16ea8db7c 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 @@ -18,8 +18,6 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var username = request.getParameter("username"); - var user = userModule.getUser(username)["content"]; var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var isExsistingUser = false; var userName = request.getParameter("username"); @@ -48,7 +46,14 @@ function onRequest(context) { canView = true; } + var canEdit = false; + if (userModule.isAuthorized("/permission/admin/device-mgt/users/edit") && + userName !== deviceMgtProps['adminUser'].split("@")[0]) { + 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.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/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 76fc116776..428f1b8414 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 @@ -19,68 +19,80 @@
    -
    -
    -

    Edit Role

    -

    Please note that * sign represents required fields of data.

    -
    -
    -
    - - -
    - -
    - -
    - - {{#if isCloud}} -
    - - devicemgt - - - {{else}} -
    - - {{/if}} + {{#if isAdminRole}} +
    +
    +

    Attention!

    +
    +
    This is an prohibited action. +
    +
    + {{else}} +
    +
    +

    Edit Role

    +

    Please note that * sign represents required fields of data.

    +
    +
    +
    + + +
    + +
    + +
    + + {{#if isCloud}} +
    + + devicemgt + +
    + {{else}} +
    + +
    + {{/if}} + minimum 3 characters long and do not + include any whitespaces. + +
    + + + + +
    -
    -
    - -
    -
    - - - -
    + {{/if}}
    - - {{#zone "bottomJs"}} - {{js "js/bottomJs.js"}} - {{/zone}} +
    + +{{#zone "bottomJs"}} + {{js "js/bottomJs.js"}} +{{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js index d5c363ef1f..86ff656737 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js @@ -31,6 +31,8 @@ function onRequest(context) { var userStore; context.isCloud = deviceMgtProps.isCloud; + var isAdminRole = deviceMgtProps["adminRole"] === roleName; + if (roleName) { if (roleName.indexOf("/") > -1) { userStore = roleName.substr(0, roleName.indexOf("/")); @@ -41,6 +43,7 @@ function onRequest(context) { if (response["status"] == "success") { context["role"] = response["content"]; } + context["isAdminRole"] = isAdminRole; context["userStore"] = userStore; context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"]; context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css index 957b72af1f..404f5d170c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css @@ -293,4 +293,20 @@ ul#noty_topRight_layout_container li{ a.new-notification { text-transform: capitalize; -} \ No newline at end of file +} + +/** +* This is to fix the issue https://github.com/wso2/product-iots/issues/1354. +* Proper fix should be given for this. +*/ +.modal { + z-index: 1000; +} + +.modal-backdrop { + z-index: 999; +} + +.select2-container--default .select2-selection--multiple .select2-selection__choice { + color: #0f0f0f; +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css index ad287ccc30..6f917a9eb5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css @@ -4186,7 +4186,7 @@ a.wr-side-panel-toggle-btn.selected { .wr-help-tip { font-size: 14px; - padding: 0 10px; + padding-left: 10px; color: #666; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml index 62367a7991..1698597882 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt org.wso2.carbon.devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 37e0949b9a..2c46a107ad 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml diff --git a/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml b/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml index 360c8a2103..ec83210918 100644 --- a/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml +++ b/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml diff --git a/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java b/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java index ba21fd81fd..8e129a7ed1 100644 --- a/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java +++ b/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java @@ -65,8 +65,13 @@ public class EmailSenderServiceImpl implements EmailSenderService { for (String recipient : emailCtx.getRecipients()) { ContentProviderInfo info = emailCtx.getContentProviderInfo(); EmailData emailData; + String transportSenderName = "mailto"; try { emailData = contentProvider.getContent(info.getTemplate(), info.getParams()); + if(EmailSenderDataHolder.getInstance().getConfigurationContextService() + .getServerConfigContext().getAxisConfiguration().getTransportOut(transportSenderName) == null){ + throw new EmailSendingFailedException("Email transport is not configured."); + } } catch (ContentProcessingInterruptedException e) { throw new EmailSendingFailedException("Error occurred while retrieving email content to be " + "sent for recipient '" + recipient + "'", e); diff --git a/components/email-sender/pom.xml b/components/email-sender/pom.xml index d4f2d65cfb..4865b58690 100644 --- a/components/email-sender/pom.xml +++ b/components/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index e045b92d67..58c226e7ec 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt identity-extensions - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.oauth.extensions - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT bundle WSO2 Carbon - OAuth Extensions http://wso2.org diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml index 88f72a1502..5fd0e3cd19 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml @@ -21,7 +21,7 @@ identity-extensions org.wso2.carbon.devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT 4.0.0 diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index 5459f63b50..c9c476241d 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 0dde2dc1ac..1f30b25dd6 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml index 930e751d5d..62b3d788e3 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt policy-mgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.complex.policy.decision.point - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT bundle WSO2 Carbon - Policy Decision Point WSO2 Carbon - Policy Decision Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml index c04d9fe39c..ed70f48fe5 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml @@ -3,14 +3,14 @@ org.wso2.carbon.devicemgt policy-mgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.decision.point - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT bundle WSO2 Carbon - Policy Decision Point WSO2 Carbon - Policy Decision Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml index 78d7c0eee7..a546235f4e 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.information.point - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT bundle WSO2 Carbon - Policy Information Point WSO2 Carbon - Policy Information Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index 20797cea35..d7ccf3517f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt policy-mgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.common - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT bundle WSO2 Carbon - Policy Management Common WSO2 Carbon - Policy Management Common diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index 33b7445f1a..f2f93070c2 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt policy-mgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.core - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT bundle WSO2 Carbon - Policy Management Core WSO2 Carbon - Policy Management Core diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index d1c8abaaa7..ad62aa91fa 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 policy-mgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - Policy Management Component http://wso2.org diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 3381ce263e..7aa40c14b7 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -21,14 +21,14 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.webapp.authenticator.framework - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT bundle WSO2 Carbon - Web Application Authenticator Framework Bundle WSO2 Carbon - Web Application Authenticator Framework Bundle diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 3913337cef..7c50c5949b 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt webapp-authenticator-framework - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - Webapp Authenticator Framework http://wso2.org diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml index 24130ec8ed..2b1b8a227e 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml @@ -21,14 +21,14 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.application.extension.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - API Management Application Extension Feature http://wso2.org This feature contains an implementation of a api application registration, which takes care of subscription diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml index de6816b632..8cca707273 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handler.server.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Device Management - APIM handler Server Feature http://wso2.org This feature contains the handler for the api authentications diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index c749ff3a9d..6688ceae3f 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -21,13 +21,13 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client.feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - APIM Integration Client Feature http://wso2.org diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml index 16bd113142..693691095c 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml @@ -21,14 +21,14 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - API Management Webapp Publisher Feature http://wso2.org This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 4cec74e635..5d5aba6516 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt apimgt-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - API Management Extensions Feature http://wso2.org diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml index 1c6bc779a6..5ac50debe1 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml index 0658000213..cb7203c3d6 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml index 43992d32dd..eecd75f40f 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.server.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Certificate Management Server Feature http://wso2.org This feature contains the core bundles required for back-end Certificate Management functionality diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 47df9f7a4f..29f09637c1 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - Certificate Management Feature http://wso2.org diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml index 06e7306e20..5fdbd07301 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Device Type Deployer Feature http://wso2.org WSO2 Carbon - Device Type Deployer Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index fabd89de77..1092a9894a 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - FCM Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 2aeeb2a92d..f46340e79b 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - MQTT Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index ed46bdf033..f24d48998f 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - MQTT Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index bfdd38e8fd..2d2f2413cd 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - XMPP Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - XMPP Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index cf4ef9e9f5..2f3a4d9b40 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml index b9268cee6d..6150630f98 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml @@ -3,13 +3,13 @@ org.wso2.carbon.devicemgt device-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.analytics.dashboard.feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - Device Management Dashboard Analytics Feature WSO2 Carbon - Device Management Dashboard Analytics Feature diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml index 400c807bb0..2175147544 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.analytics.data.publisher.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Device Management Server Feature http://wso2.org This feature contains bundles related to device analytics data publisher diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml index 94d4c8aa14..7e3b18c7c6 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml index f791a549c2..6128898e86 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml @@ -4,14 +4,14 @@ org.wso2.carbon.devicemgt device-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Device Management Extensions Feature http://wso2.org This feature contains common extensions used by key device management functionalities diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index eb77408012..0f297e372c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml index 8b25bbd3c7..1736a120c9 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.server.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Device Management Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml index daf2d4c745..a0c8d5450c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 16c917270e..1f0d2da662 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml diff --git a/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml b/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml index 6d60f78b79..d72b02e9a8 100644 --- a/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml +++ b/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt email-sender-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.email.sender.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Email Sender Feature http://wso2.org This feature contains the core bundles required for email sender related functionality diff --git a/features/email-sender/pom.xml b/features/email-sender/pom.xml index 3b2804ca88..50036434e1 100644 --- a/features/email-sender/pom.xml +++ b/features/email-sender/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt email-sender-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - Email Sender Feature http://wso2.org diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml index 79aef038fa..edcf57e263 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt jwt-client-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.identity.jwt.client.extension.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - JWT Client Feature http://wso2.org This feature contains jwt client implementation from which we can get a access token using the jwt diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 4a37207db0..21747cdec0 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 jwt-client-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - JWT Client Extension Feature http://wso2.org diff --git a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml index 7ddb7fbcb7..b9a809ed10 100644 --- a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml +++ b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt oauth-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.oauth.extensions.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Device Mgt OAuth Extensions Feature http://wso2.org This feature contains devicemgt related OAuth extensions diff --git a/features/oauth-extensions/pom.xml b/features/oauth-extensions/pom.xml index e914dc940b..085f28edd4 100644 --- a/features/oauth-extensions/pom.xml +++ b/features/oauth-extensions/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt oauth-extensions-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - Device Management OAuth Extensions Feature http://wso2.org diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index 7dc3a6a1f1..a5ed3ff8c9 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt policy-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.policy.mgt.server.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Policy Management Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 788dbe61ef..54c9232dea 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt policy-mgt-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - Policy Management Feature http://wso2.org diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml index 153ad98617..6931894b7f 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.webapp.authenticator.framework.server.feature pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Webapp Authenticator Framework Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 0a506d7ad2..d536aad244 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT pom WSO2 Carbon - Webapp Authenticator Framework Feature http://wso2.org diff --git a/pom.xml b/pom.xml index b3c52897f8..9f5835f55f 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt pom - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1840,7 +1840,7 @@ 1.2.11.wso2v10 - 3.0.89-SNAPSHOT + 3.0.101-SNAPSHOT 4.4.8