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 01ea40d9da..0fd0804917 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 3.1.34-SNAPSHOT + 3.1.40-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 c6969f29b1..b8a95d4d44 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 - 3.1.34-SNAPSHOT + 3.1.40-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 2194b0ae8a..c6f6ac6df0 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT org.wso2.carbon.apimgt.application.extension bundle WSO2 Carbon - API Application Management diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index 487177ed61..aaa3cb87c1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -26,6 +26,7 @@ import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil; +import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; import org.wso2.carbon.apimgt.integration.client.store.*; import org.wso2.carbon.apimgt.integration.generated.client.store.model.*; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -58,8 +59,19 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe tenantDomain, CONTENT_TYPE, null, null); return true; } catch (FeignException e) { - return false; - } + if (e.status() == 401) { + OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + oAuthRequestInterceptor.removeToken(username, tenantDomain); + try { + storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, + APP_TIER_TYPE,tenantDomain, CONTENT_TYPE, null, null); + } catch (FeignException ex) { + log.error("Invalid Attempt : " + ex); + return false; + } + } } + return false; } @Override 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 aa8d4afcd2..ac33013a80 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handlers - 3.1.34-SNAPSHOT + 3.1.40-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 7fb37938ed..d3f8d3d2ae 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml index c76eff7838..eb528f5669 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.generated.client - 3.1.34-SNAPSHOT + 3.1.40-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 51bb5ed886..40a49e9b70 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 3.1.34-SNAPSHOT + 3.1.40-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 06747b5384..f5e1623791 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 3.1.34-SNAPSHOT + 3.1.40-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 8906702085..721d500b62 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.1.34-SNAPSHOT + 3.1.40-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 a9b3d9bd2f..f65f0428f1 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.v09.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.v09.api/pom.xml index ba0d7533c9..ea10e11948 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.v09.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.v09.api/pom.xml @@ -24,7 +24,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 3.1.34-SNAPSHOT + 3.1.40-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 e3e8a51866..a9679046ed 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT bundle WSO2 Carbon - Certificate Management Core WSO2 Carbon - Certificate Management Core diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.v09.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.v09.api/pom.xml index ff336875bb..a4205aafd6 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.v09.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.v09.api/pom.xml @@ -24,7 +24,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 07ec8f8208..5347bdaf42 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 3.1.34-SNAPSHOT + 3.1.40-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 3482bd1002..3c8242ddf8 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.1.34-SNAPSHOT + 3.1.40-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 bcc88b8135..4d7c55ff18 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.1.34-SNAPSHOT + 3.1.40-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 4fda8ced24..2a2022a5b7 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java index 83a9289442..7c1700c210 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java @@ -64,7 +64,9 @@ public class FCMNotificationStrategy implements NotificationStrategy { if (NOTIFIER_TYPE_FCM.equals(config.getType())) { Device device = FCMDataHolder.getInstance().getDeviceManagementProviderService() .getDeviceWithTypeProperties(ctx.getDeviceId()); - this.sendWakeUpCall(ctx.getOperation().getCode(), device); + if(getFCMToken(device.getProperties()) != null) { + this.sendWakeUpCall(ctx.getOperation().getCode(), device); + } } else { if (log.isDebugEnabled()) { log.debug("Not using FCM notifier as notifier type is set to " + config.getType() + 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 68182482bb..987e978b6c 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.1.34-SNAPSHOT + 3.1.40-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 d64997df98..8e137e6769 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.1.34-SNAPSHOT + 3.1.40-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 4dae1edd0d..8856d0b074 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 230f122bae..3557236080 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.1.34-SNAPSHOT + 3.1.40-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 b8530ce1ca..f188721527 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherUtil.java index a86b38ee1d..1d65b3092e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherUtil.java @@ -18,17 +18,24 @@ */ package org.wso2.carbon.device.mgt.analytics.data.publisher; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; -import org.wso2.carbon.databridge.agent.DataPublisher; +import org.wso2.carbon.databridge.agent.exception.DataEndpointConfigurationException; import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class DataPublisherUtil { + private static final Log log = LogFactory.getLog(DataPublisherUtil.class); + private DataPublisherUtil(){ } @@ -46,4 +53,72 @@ public class DataPublisherUtil { } } + public static ArrayList getEndpointGroups(String urlSet) { + ArrayList urlGroups = new ArrayList<>(); + Pattern regex = Pattern.compile("\\{.*?\\}"); + Matcher regexMatcher = regex.matcher(urlSet); + + while(regexMatcher.find()) { + urlGroups.add(regexMatcher.group().replace("{", "").replace("}", "")); + } + + if (urlGroups.size() == 0) { + urlGroups.add(urlSet.replace("{", "").replace("}", "")); + } + return urlGroups; + } + + public static String[] getEndpoints(String aURLGroup) throws DataEndpointConfigurationException { + boolean isLBURL = false; + boolean isFailOverURL = false; + if (aURLGroup.contains(",")) { + isLBURL = true; + } + + if (aURLGroup.contains("|")) { + isFailOverURL = true; + } + + if (isLBURL && isFailOverURL) { + String msg = "Invalid data endpoints URL set provided : " + aURLGroup + + ", a URL group can be configured as failover OR load balancing endpoints."; + log.error(msg); + throw new DataEndpointConfigurationException(msg); + } else { + String[] urls; + if (isLBURL) { + urls = aURLGroup.split(","); + } else if (isFailOverURL) { + urls = aURLGroup.split("\\|"); + } else { + urls = new String[]{aURLGroup}; + } + return urls; + } + } + + public static int obtainHashId(String deviceId, int urlGroupsCount) { + byte[] chars = deviceId.getBytes(); + int sum = 0; + for (byte b : chars) { + sum += b; + } + return sum % urlGroupsCount; + } + + @SuppressWarnings("Duplicates") + public static String replaceProperty(String urlWithPlaceholders) { + String regex = "\\$\\{(.*?)\\}"; + Pattern pattern = Pattern.compile(regex); + Matcher matchPattern = pattern.matcher(urlWithPlaceholders); + while (matchPattern.find()) { + String sysPropertyName = matchPattern.group(1); + String sysPropertyValue = System.getProperty(sysPropertyName); + if (sysPropertyValue != null && !sysPropertyName.isEmpty()) { + urlWithPlaceholders = urlWithPlaceholders.replaceAll("\\$\\{(" + sysPropertyName + ")\\}", sysPropertyValue); + } + } + return urlWithPlaceholders; + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java index 8753dc2af7..18d5be4287 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java @@ -18,6 +18,8 @@ */ package org.wso2.carbon.device.mgt.analytics.data.publisher; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.databridge.agent.DataPublisher; import org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException; import org.wso2.carbon.databridge.agent.exception.DataEndpointAuthenticationException; @@ -26,15 +28,25 @@ import org.wso2.carbon.databridge.agent.exception.DataEndpointException; import org.wso2.carbon.databridge.commons.exception.TransportException; import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfiguration; import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; +import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherServiceImpl; + +import java.util.HashMap; +import java.util.Map; /** * This is used to manage data publisher per tenant. */ public class DeviceDataPublisher { - private DataPublisher dataPublisher; + private static Log log = LogFactory.getLog(EventsPublisherServiceImpl.class); + + private Map dataPublishers; private static DeviceDataPublisher deviceDataPublisher; + private DeviceDataPublisher() { + dataPublishers = new HashMap<>(); + } + public static DeviceDataPublisher getInstance() { if (deviceDataPublisher == null) { synchronized (DeviceDataPublisher.class) { @@ -47,45 +59,52 @@ public class DeviceDataPublisher { } /** - * this return the data publisher for the tenant. + * This returns the data publisher for the tenant based on the analytics node id. * + * @param analyticsConfig Analytics configurations + * @param receiverURLSet Data receiver URL set as string * @return instance of data publisher - * @throws DataPublisherConfigurationException - * + * @throws DataPublisherConfigurationException on exception */ - public DataPublisher getDataPublisher() throws DataPublisherConfigurationException { - if (this.dataPublisher == null) { - synchronized (this) { - if (this.dataPublisher == null) { - AnalyticsConfiguration analyticsConfig = AnalyticsConfiguration.getInstance(); - if (!analyticsConfig.isEnable()) { - return null; - } - String analyticsServerUrlGroups = analyticsConfig.getReceiverServerUrl(); - String analyticsServerUsername = analyticsConfig.getAdminUsername(); - String analyticsServerPassword = analyticsConfig.getAdminPassword(); - try { - this.dataPublisher = new DataPublisher(analyticsServerUrlGroups, analyticsServerUsername, - analyticsServerPassword); - } catch (DataEndpointAgentConfigurationException e) { - throw new DataPublisherConfigurationException("Configuration Exception on data publisher for " + - "ReceiverGroup = " + analyticsServerUrlGroups + " for username " + analyticsServerUsername, e); - } catch (DataEndpointException e) { - throw new DataPublisherConfigurationException("Invalid ReceiverGroup = " + analyticsServerUrlGroups, e); - } catch (DataEndpointConfigurationException e) { - throw new DataPublisherConfigurationException("Invalid Data endpoint configuration.", e); - } catch (DataEndpointAuthenticationException e) { - throw new DataPublisherConfigurationException("Authentication Failed for user " + - analyticsServerUsername, e); - } catch (TransportException e) { - throw new DataPublisherConfigurationException("Error occurred while retrieving data publisher", e); - } - } else { - return this.dataPublisher; + public DataPublisher getDataPublisher(AnalyticsConfiguration analyticsConfig, String receiverURLSet) + throws DataPublisherConfigurationException { + synchronized (this) { + if (this.dataPublishers.containsKey(receiverURLSet)) { + return this.dataPublishers.get(receiverURLSet); + } else { + String analyticsServerUrlGroups = analyticsConfig.getReceiverServerUrl(); + String analyticsServerUsername = analyticsConfig.getAdminUsername(); + String analyticsServerPassword = analyticsConfig.getAdminPassword(); + + try { + DataPublisher dataPublisher = new DataPublisher(receiverURLSet, analyticsServerUsername, + analyticsServerPassword); + this.dataPublishers.put(receiverURLSet, dataPublisher); + return dataPublisher; + } catch (DataEndpointAgentConfigurationException e) { + String msg = "Configuration Exception on data publisher for " + + "ReceiverGroup = " + analyticsServerUrlGroups + " for username " + analyticsServerUsername; + log.error(msg, e); + throw new DataPublisherConfigurationException(msg, e); + } catch (DataEndpointException e) { + String msg = "Invalid ReceiverGroup = " + analyticsServerUrlGroups; + log.error(msg, e); + throw new DataPublisherConfigurationException(msg, e); + } catch (DataEndpointConfigurationException e) { + String msg = "Invalid Data endpoint configuration."; + log.error(msg, e); + throw new DataPublisherConfigurationException(msg, e); + } catch (DataEndpointAuthenticationException e) { + String msg = "Authentication Failed for user " + analyticsServerUsername; + log.error(msg, e); + throw new DataPublisherConfigurationException(msg, e); + } catch (TransportException e) { + String msg = "Error occurred while retrieving data publisher"; + log.error(msg, e); + throw new DataPublisherConfigurationException(msg, e); } } } - return this.dataPublisher; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/AnalyticsConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/AnalyticsConfiguration.java index b758d4cf1c..67a8c36333 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/AnalyticsConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/AnalyticsConfiguration.java @@ -39,6 +39,7 @@ import java.io.File; public class AnalyticsConfiguration { private String receiverServerUrl; + private String analyticsPublisherUrl; private String adminUsername; private String adminPassword; private boolean enable; @@ -81,13 +82,22 @@ public class AnalyticsConfiguration { @XmlElement(name = "ReceiverServerUrl", required = true) public String getReceiverServerUrl() { - return receiverServerUrl; + return DataPublisherUtil.replaceProperty(receiverServerUrl); } public void setReceiverServerUrl(String receiverServerUrl) { this.receiverServerUrl = receiverServerUrl; } + @XmlElement(name = "AnalyticsPublisherUrl", required = true) + public String getAnalyticsPublisherUrl() { + return DataPublisherUtil.replaceProperty(analyticsPublisherUrl); + } + + public void setAnalyticsPublisherUrl(String analyticsPublisherUrl) { + this.analyticsPublisherUrl = analyticsPublisherUrl; + } + @XmlElement(name = "Enabled", required = true) public boolean isEnable() { return enable; @@ -102,8 +112,14 @@ public class AnalyticsConfiguration { } public static void init(String analyticsConfigPath) throws DataPublisherConfigurationException { + File authConfig = new File(analyticsConfigPath); + if (!authConfig.exists()) { + log.warn(DEVICE_ANALYTICS_CONFIG_PATH + " does not exist. Disabling AnalyticsConfiguration."); + config = new AnalyticsConfiguration(); + config.setEnable(false); + return; + } try { - File authConfig = new File(analyticsConfigPath); Document doc = DataPublisherUtil.convertToDocument(authConfig); /* Un-marshaling device analytics configuration */ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherService.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherService.java index 7be1ac574b..f75496d0e2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherService.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.analytics.data.publisher.service; import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; /** - * This service can be used to publish and retreive data from the Analytics Server. + * This service can be used to publish and retrieve data from the Analytics Server. */ public interface EventsPublisherService { @@ -32,8 +32,8 @@ public interface EventsPublisherService { * @param metaDataArray - meta data that needs to pushed * @param correlationDataArray - correlation data that needs to be pushed * @param payloadDataArray - payload data that needs to be pushed - * @return - * @throws DataPublisherConfigurationException + * @return if success returns true + * @throws DataPublisherConfigurationException on exception */ boolean publishEvent(String streamName, String version, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray) throws DataPublisherConfigurationException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherServiceImpl.java index 4c039221c8..6b7b81aa36 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherServiceImpl.java @@ -24,44 +24,67 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.databridge.agent.DataPublisher; import org.wso2.carbon.databridge.commons.utils.DataBridgeCommonsUtils; +import org.wso2.carbon.device.mgt.analytics.data.publisher.DataPublisherUtil; import org.wso2.carbon.device.mgt.analytics.data.publisher.DeviceDataPublisher; +import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfiguration; import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; +import java.util.ArrayList; + /** * This is the implementation of Osgi Service which can be used to publish and retireved * event/records. */ public class EventsPublisherServiceImpl implements EventsPublisherService { + private static Log log = LogFactory.getLog(EventsPublisherServiceImpl.class); /** * @param streamName is the name of the stream that the data needs to pushed * @param version is the version of the stream - * @param metaDataArray - meta data that needs to pushed - * @param correlationDataArray - correlation data that needs to be pushed - * @param payloadDataArray - payload data that needs to be pushed + * @param metaDataArray meta data that needs to pushed + * @param correlationDataArray correlation data that needs to be pushed + * @param payloadDataArray payload data that needs to be pushed * @return if success returns true - * @throws DataPublisherConfigurationException + * @throws DataPublisherConfigurationException on exception */ @Override public boolean publishEvent(String streamName, String version, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray) throws DataPublisherConfigurationException { + AnalyticsConfiguration analyticsConfig = AnalyticsConfiguration.getInstance(); + if (!analyticsConfig.isEnable()) { + log.warn("Analytics data publishing not enabled."); + return false; + } + + if (metaDataArray == null || metaDataArray.length == 0) { + String msg = "meta data[0] must have the device Id field"; + log.error(msg); + throw new DataPublisherConfigurationException(msg); + } + + ArrayList receiverURLGroups = DataPublisherUtil.getEndpointGroups(analyticsConfig.getReceiverServerUrl()); + int hashId = DataPublisherUtil.obtainHashId(metaDataArray[0].toString(), receiverURLGroups.size()); + if (receiverURLGroups.size() <= hashId) { + String msg = "Invalid receiver url group size. Expected to be higher than: " + hashId + " Actual: " + + receiverURLGroups.size(); + log.error(msg); + throw new DataPublisherConfigurationException(msg); + } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { - if (metaDataArray == null || metaDataArray.length == 0) { - throw new DataPublisherConfigurationException("meta data[0] should have the device Id field"); - } else { - metaDataArray[0] = tenantDomain + "@" + metaDataArray[0]; - } + metaDataArray[0] = tenantDomain + "@" + metaDataArray[0]; } PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext() .setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); try { - DataPublisher dataPublisher = DeviceDataPublisher.getInstance().getDataPublisher(); + DataPublisher dataPublisher = DeviceDataPublisher.getInstance() + .getDataPublisher(analyticsConfig, receiverURLGroups.get(hashId)); if (dataPublisher != null) { String streamId = DataBridgeCommonsUtils.generateStreamId(streamName, version); return dataPublisher.tryPublish(streamId, System.currentTimeMillis(), metaDataArray, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml new file mode 100644 index 0000000000..4ca94f1c85 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml @@ -0,0 +1,80 @@ + + + + + device-mgt + org.wso2.carbon.devicemgt + 3.1.40-SNAPSHOT + + 4.0.0 + + org.wso2.carbon.device.mgt.analytics.wsproxy + war + WSO2 - Webapp for Web Socket Proxy + http://wso2.org + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.analytics.data.publisher + provided + + + javax.ws.rs + javax.ws.rs-api + + + org.apache.cxf + cxf-rt-frontend-jaxrs + + + + + secured-websocket-proxy + + + org.jacoco + jacoco-maven-plugin + + ${basedir}/target/coverage-reports/jacoco-unit.exec + + + + jacoco-initialize + + prepare-agent + + + + jacoco-site + test + + report + + + ${basedir}/target/coverage-reports/jacoco-unit.exec + ${basedir}/target/coverage-reports/site + + + + + + + + \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/exception/WSProxyException.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/exception/WSProxyException.java new file mode 100644 index 0000000000..7937ada371 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/exception/WSProxyException.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.analytics.wsproxy.exception; + +/** + * Indicates an error with deployment tinkerer + * + * @since 1.0.0 + */ +public class WSProxyException extends Exception { + + /** + * Constructs a new exception with the message provided and the cause. + * + * @param message the detailed message of the exception + * @param cause the cause of the exception + */ + public WSProxyException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SubscriptionEndpoint.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SubscriptionEndpoint.java new file mode 100644 index 0000000000..14db789fa9 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SubscriptionEndpoint.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.analytics.wsproxy.inbound; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.carbon.device.mgt.analytics.data.publisher.DataPublisherUtil; +import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfiguration; +import org.wso2.carbon.device.mgt.analytics.wsproxy.exception.WSProxyException; +import org.wso2.carbon.device.mgt.analytics.wsproxy.outbound.AnalyticsClient; + +import javax.websocket.CloseReason; +import javax.websocket.Session; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Interface for subscription and un-subscription for web socket + */ + +public class SubscriptionEndpoint { + + private static final Log log = LogFactory.getLog(SubscriptionEndpoint.class); + private Map> analyticsClientsMap = new HashMap<>(); + + /** + * Web socket onOpen - When client sends a message + * + * @param session - Users registered session. + */ + public void onOpen(Session session) { + if (log.isDebugEnabled()) { + log.debug("WebSocket opened, for Session id: " + session.getId()); + } + + AnalyticsConfiguration analyticsConfig = AnalyticsConfiguration.getInstance(); + ArrayList publisherGroups = + DataPublisherUtil.getEndpointGroups(analyticsConfig.getAnalyticsPublisherUrl()); + List analyticsClients = new ArrayList<>(); + for (String publisherURLGroup : publisherGroups) { + try { + String[] endpoints = DataPublisherUtil.getEndpoints(publisherURLGroup); + for (String endpoint : endpoints) { + try { + endpoint = endpoint.trim(); + if (!endpoint.endsWith("/")) { + endpoint += "/"; + } + endpoint += session.getRequestURI().getSchemeSpecificPart().replace("secured-websocket-proxy",""); + AnalyticsClient analyticsClient = new AnalyticsClient(session); + analyticsClient.connectClient(new URI(endpoint)); + analyticsClients.add(analyticsClient); + } catch (URISyntaxException e) { + log.error("Unable to create URL from: " + endpoint, e); + } catch (WSProxyException e) { + log.error("Unable to create WS client for: " + endpoint, e); + } + } + } catch (DataEndpointConfigurationException e) { + log.error("Unable to obtain endpoints from receiverURLGroup: " + publisherURLGroup, e); + } + } + if (log.isDebugEnabled()) { + log.debug("Configured " + analyticsClients.size() + " analytics clients for Session id: " + + session.getId()); + } + analyticsClientsMap.put(session.getId(), analyticsClients); + } + + /** + * Web socket onClose - Remove the registered sessions + * + * @param session - Users registered session. + * @param reason - Status code for web-socket close. + * @param streamName - StreamName extracted from the ws url. + * @param version - Version extracted from the ws url. + * @param tenantDomain - Domain of the tenant. + */ + public void onClose(Session session, CloseReason reason, String streamName, String version, String tenantDomain) { + if (log.isDebugEnabled()) { + log.debug("Closing a WebSocket due to " + reason.getReasonPhrase() + ", for session ID:" + + session.getId() + ", for request URI - " + session.getRequestURI()); + } + for (AnalyticsClient analyticsClient : analyticsClientsMap.get(session.getId())) { + if (analyticsClient != null) { + try { + analyticsClient.closeConnection(reason); + } catch (WSProxyException e) { + log.error("Error occurred while closing ws connection due to " + reason.getReasonPhrase() + + ", for session ID:" + session.getId() + ", for request URI - " + session.getRequestURI(), e); + } + } + } + analyticsClientsMap.remove(session.getId()); + } + + /** + * Web socket onMessage - When client sens a message + * + * @param session - Users registered session. + * @param message - Status code for web-socket close. + */ + public void onMessage(Session session, String message) { + for (AnalyticsClient analyticsClient : analyticsClientsMap.get(session.getId())) { + if (analyticsClient != null) { + analyticsClient.sendMessage(message); + } + } + } + + /** + * Web socket onError + * + * @param session - Users registered session. + * @param throwable - Status code for web-socket close. + * @param streamName - StreamName extracted from the ws url. + * @param version - Version extracted from the ws url. + * @param tenantDomain - Domain of the tenant. + */ + public void onError(Session session, Throwable throwable, String streamName, String version, String tenantDomain) { + log.error("Error occurred in session ID: " + session.getId() + ", for request URI - " + + session.getRequestURI() + ", " + throwable.getMessage(), throwable); + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SuperTenantSubscriptionEndpoint.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SuperTenantSubscriptionEndpoint.java new file mode 100644 index 0000000000..0e4bc3684d --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SuperTenantSubscriptionEndpoint.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.analytics.wsproxy.inbound; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; + +import javax.websocket.CloseReason; +import javax.websocket.EndpointConfig; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; + +/** + * Connect to web socket with Super tenant + */ + +@ServerEndpoint(value = "/{destination}/{streamname}/{version}") +public class SuperTenantSubscriptionEndpoint extends SubscriptionEndpoint { + + private static final Log log = LogFactory.getLog(SuperTenantSubscriptionEndpoint.class); + + /** + * Web socket onOpen - When client sends a message + * + * @param session - Users registered session. + * @param streamName - StreamName extracted from the ws url. + * @param version - Version extracted from the ws url. + */ + @OnOpen + public void onOpen(Session session, EndpointConfig config, @PathParam("streamname") String streamName, + @PathParam("version") String version) { + if (log.isDebugEnabled()) { + log.debug("WebSocket opened, for Session id: " + session.getId() + ", for the Stream:" + streamName); + } + super.onOpen(session); + } + + /** + * Web socket onMessage - When client sens a message + * + * @param session - Users registered session. + * @param message - Status code for web-socket close. + * @param streamName - StreamName extracted from the ws url. + */ + @OnMessage + public void onMessage(Session session, String message, @PathParam("streamname") String streamName) { + if (log.isDebugEnabled()) { + log.debug("Received message from client. Message: " + message + ", " + + "for Session id: " + session.getId() + ", for the Stream:" + streamName); + } + super.onMessage(session, message); + } + + /** + * Web socket onClose - Remove the registered sessions + * + * @param session - Users registered session. + * @param reason - Status code for web-socket close. + * @param streamName - StreamName extracted from the ws url. + * @param version - Version extracted from the ws url. + */ + @OnClose + public void onClose(Session session, CloseReason reason, @PathParam("streamname") String streamName, + @PathParam("version") String version) { + super.onClose(session, reason, streamName, version, MultitenantConstants.SUPER_TENANT_NAME); + } + + /** + * Web socket onError - Remove the registered sessions + * + * @param session - Users registered session. + * @param throwable - Status code for web-socket close. + * @param streamName - StreamName extracted from the ws url. + * @param version - Version extracted from the ws url. + */ + @OnError + public void onError(Session session, Throwable throwable, @PathParam("streamname") String streamName, + @PathParam("version") String version) { + super.onError(session, throwable, streamName, version, MultitenantConstants.SUPER_TENANT_NAME); + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/TenantSubscriptionEndpoint.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/TenantSubscriptionEndpoint.java new file mode 100644 index 0000000000..02e55cfed6 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/TenantSubscriptionEndpoint.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.analytics.wsproxy.inbound; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.websocket.CloseReason; +import javax.websocket.EndpointConfig; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; + +/** + * Connect to web socket with a tenant + */ + +@ServerEndpoint(value = "/{destination}/t/{tdomain}/{streamname}/{version}") +public class TenantSubscriptionEndpoint extends SubscriptionEndpoint { + + private static final Log log = LogFactory.getLog(TenantSubscriptionEndpoint.class); + + /** + * Web socket onOpen - When client sends a message + * + * @param session - Users registered session. + * @param streamName - StreamName extracted from the ws url. + * @param version - Version extracted from the ws url. + * @param tdomain - Tenant domain extracted from ws url. + */ + @OnOpen + public void onOpen(Session session, EndpointConfig config, @PathParam("streamname") String streamName, + @PathParam("version") String version, @PathParam("tdomain") String tdomain) { + if (log.isDebugEnabled()) { + log.debug("WebSocket opened, for Session id: " + session.getId() + ", for the Stream:" + streamName); + } + super.onOpen(session); + } + + /** + * Web socket onMessage - When client sens a message + * + * @param session - Users registered session. + * @param message - Status code for web-socket close. + * @param streamName - StreamName extracted from the ws url. + */ + @OnMessage + public void onMessage(Session session, String message, @PathParam("streamname") String streamName, @PathParam("tdomain") String tdomain) { + if (log.isDebugEnabled()) { + log.debug("Received message from client. Message: " + message + ", for Session id: " + + session.getId() + ", for tenant domain" + tdomain + ", for the Adaptor:" + streamName); + } + super.onMessage(session, message); + } + + /** + * Web socket onClose - Remove the registered sessions + * + * @param session - Users registered session. + * @param reason - Status code for web-socket close. + * @param streamName - StreamName extracted from the ws url. + * @param version - Version extracted from the ws url. + */ + @OnClose + public void onClose(Session session, CloseReason reason, @PathParam("streamname") String streamName, + @PathParam("version") String version, @PathParam("tdomain") String tdomain) { + super.onClose(session, reason, streamName, version, tdomain); + } + + /** + * Web socket onError - Remove the registered sessions + * + * @param session - Users registered session. + * @param throwable - Status code for web-socket close. + * @param streamName - StreamName extracted from the ws url. + * @param version - Version extracted from the ws url. + */ + @OnError + public void onError(Session session, Throwable throwable, @PathParam("streamname") String streamName, + @PathParam("version") String version, @PathParam("tdomain") String tdomain) { + super.onError(session, throwable, streamName, version, tdomain); + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/outbound/AnalyticsClient.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/outbound/AnalyticsClient.java new file mode 100644 index 0000000000..7bfd480288 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/outbound/AnalyticsClient.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.analytics.wsproxy.outbound; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.analytics.wsproxy.exception.WSProxyException; + +import javax.websocket.CloseReason; +import javax.websocket.ContainerProvider; +import javax.websocket.DeploymentException; +import javax.websocket.OnClose; +import javax.websocket.OnMessage; +import javax.websocket.Session; +import javax.websocket.WebSocketContainer; +import java.io.IOException; +import java.net.URI; + +/** + * This class holds web socket client implementation + * + * @since 1.0.0 + */ +@javax.websocket.ClientEndpoint +public class AnalyticsClient { + + private static final Log log = LogFactory.getLog(AnalyticsClient.class); + + private WebSocketContainer container; + private Session analyticsSession = null; + private Session clientSession; + + /** + * Create {@link AnalyticsClient} instance. + */ + public AnalyticsClient(Session clientSession) { + container = ContainerProvider.getWebSocketContainer(); + this.clientSession = clientSession; + } + + /** + * Create web socket client connection using {@link WebSocketContainer}. + */ + public void connectClient(URI endpointURI) throws WSProxyException { + try { + analyticsSession = container.connectToServer(this, endpointURI); + } catch (DeploymentException | IOException e) { + String msg = "Error occurred while connecting to remote endpoint " + endpointURI.toString(); + log.error(msg, e); + throw new WSProxyException(msg, e); + } + } + + /** + * Callback hook for Connection close events. + * + * @param userSession the analyticsSession which is getting closed. + * @param reason the reason for connection close + */ + @OnClose + public void onClose(Session userSession, CloseReason reason) { + if (log.isDebugEnabled()) { + log.debug("Closing web socket session: '" + userSession.getId() + "'. Code: " + + reason.getCloseCode().toString() + " Reason: " + reason.getReasonPhrase()); + } + this.analyticsSession = null; + } + + /** + * Callback hook for Message Events. + * + *

This method will be invoked when a client send a message. + * + * @param message The text message. + */ + @OnMessage + public void onMessage(String message) { + this.clientSession.getAsyncRemote().sendText(message); + } + + /** + * Send a message. + * + * @param message the message which is going to send. + */ + public void sendMessage(String message) { + this.analyticsSession.getAsyncRemote().sendText(message); + } + + /** + * Close current connection. + */ + public void closeConnection(CloseReason closeReason) throws WSProxyException { + if (this.analyticsSession != null) { + try { + this.analyticsSession.close(closeReason); + } catch (IOException e) { + String msg = "Error on closing WS connection."; + log.error(msg, e); + throw new WSProxyException(msg, e); + } + } + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/webapp/WEB-INF/web.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..bf625c9256 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,46 @@ + + + + + Output WebSocket Proxy + + + ContentTypeBasedCachePreventionFilter + org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter + + patterns + text/html" ,application/json" ,text/plain + + + filterAction + enforce + + + httpHeaders + Cache-Control: no-store, no-cache, must-revalidate, private + + + + + ContentTypeBasedCachePreventionFilter + /* + + 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 d58eef3345..33e2346852 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java index b1c84d4842..ec72dc6d16 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java @@ -429,6 +429,12 @@ public interface ActivityInfoProviderService { "Example: Mon, 05 Jan 2014 15:10:00 +0200", required = false) @QueryParam("since") String since, + @ApiParam( + name = "initiatedBy", + value = "The user, who initiated the operation. If is done by the task, the SYSTEM will be returned." + + " And if a user adds the operation, username is returned", + required = false) + @QueryParam("initiatedBy") String initiatedBy, @ApiParam( name = "offset", value = "The starting pagination index for the complete list of qualified items.", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ActivityProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ActivityProviderServiceImpl.java index 45ad77ee78..d115659e18 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ActivityProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ActivityProviderServiceImpl.java @@ -216,8 +216,8 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService @GET @Override - public Response getActivities(@QueryParam("since") String since, @QueryParam("offset") int offset, - @QueryParam("limit") int limit, + public Response getActivities(@QueryParam("since") String since, @QueryParam("initiatedBy")String initiatedBy, + @QueryParam("offset") int offset, @QueryParam("limit") int limit, @HeaderParam("If-Modified-Since") String ifModifiedSince) { long ifModifiedSinceTimestamp; @@ -267,6 +267,7 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService Response response = validateAdminUser(); if (response == null) { List activities; + int count = 0; ActivityList activityList = new ActivityList(); DeviceManagementProviderService dmService; try { @@ -274,15 +275,28 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService log.debug("Calling database to get activities."); } dmService = DeviceMgtAPIUtils.getDeviceManagementService(); - activities = dmService.getActivitiesUpdatedAfter(timestamp, limit, offset); - activityList.setList(activities); - if (log.isDebugEnabled()) { - log.debug("Calling database to get activity count."); - } - int count = dmService.getActivityCountUpdatedAfter(timestamp); - if (log.isDebugEnabled()) { - log.debug("Activity count: " + count); + if (initiatedBy == null || initiatedBy.isEmpty()) { + activities = dmService.getActivitiesUpdatedAfter(timestamp, limit, offset); + + if (log.isDebugEnabled()) { + log.debug("Calling database to get activity count with timestamp."); + } + count = dmService.getActivityCountUpdatedAfter(timestamp); + if (log.isDebugEnabled()) { + log.debug("Activity count: " + count); + } + } else { + activities = dmService.getActivitiesUpdatedAfterByUser(timestamp, initiatedBy, limit, offset); + + if (log.isDebugEnabled()) { + log.debug("Calling database to get activity count with timestamp and user."); + } + count = dmService.getActivityCountUpdatedAfterByUser(timestamp, initiatedBy); + if (log.isDebugEnabled()) { + log.debug("Activity count: " + count); + } } + activityList.setList(activities); activityList.setCount(count); if (activities == null || activities.size() == 0) { if (isIfModifiedSinceSet) { 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 ac98ec15b7..8144231142 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java index 6dc9d55305..567cc1a1d6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java @@ -22,6 +22,8 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationResult; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; + import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import java.util.List; @@ -44,6 +46,10 @@ public interface OperationManager { Activity addOperation(Operation operation, List devices) throws OperationManagementException, InvalidDeviceException; + + void addOperationsForPolicyRevoke(Policy policy, List devices) throws OperationManagementException, + InvalidDeviceException; + /** * Method to retrieve the list of all operations to a device. * @@ -102,12 +108,16 @@ public interface OperationManager { int getTotalCountOfFilteredActivities(String operationCode) throws OperationManagementException; + List getActivitiesUpdatedAfterByUser(long timestamp, String user, int limit, int offset) throws OperationManagementException; + int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementException; + int getActivityCountUpdatedAfterByUser(long timestamp, String user) throws OperationManagementException; + /** * retrive the push notification strategy. * @return NotificationStrategy */ NotificationStrategy getNotificationStrategy(); -} \ No newline at end of file +} 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 2ac107ef43..5b7ce8b77c 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index 78d393b048..88d5e291f3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -38,6 +38,8 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.ActivityStatus; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; @@ -64,13 +66,7 @@ import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerImpl; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * This class implements all the functionality exposed as part of the OperationManager. Any transaction initiated @@ -161,8 +157,8 @@ public class OperationManagerImpl implements OperationManager { List validDeviceIds = deviceValidationResult.getValidDeviceIDList(); if (validDeviceIds.size() > 0) { DeviceIDHolder deviceAuthorizationResult = this.authorizeDevices(operation, validDeviceIds); - List authorizedDeviceList = deviceAuthorizationResult.getValidDeviceIDList(); - if (authorizedDeviceList.size() <= 0) { + List authorizedDeviceIds = deviceAuthorizationResult.getValidDeviceIDList(); + if (authorizedDeviceIds.size() <= 0) { log.warn("User : " + getUser() + " is not authorized to perform operations on given device-list."); Activity activity = new Activity(); //Send the operation statuses only for admin triggered operations @@ -189,86 +185,71 @@ public class OperationManagerImpl implements OperationManager { OperationManagementDAOFactory.beginTransaction(); org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto = OperationDAOUtil.convertOperation(operation); + int enrolmentId; + String operationCode = operationDto.getCode(); + + List authorizedDevices = new ArrayList<>(); + List ignoredDevices = new ArrayList<>(); + for (DeviceIdentifier deviceId : authorizedDeviceIds) { + Device device = getDevice(deviceId); + authorizedDevices.add(device); + } + + if (operationDto.getControl() == + org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT) { + int existingOperationID; + for (Device device : authorizedDevices) { + enrolmentId = device.getEnrolmentInfo().getId(); + existingOperationID = operationDAO.getExistingOperationID(enrolmentId, operationCode); + if (existingOperationID > 0) { + ignoredDevices.add(device); + operation.setId(existingOperationID); + this.sendNotification(operation, device); + } + } + } + + if (ignoredDevices.size() > 0) { + if (authorizedDevices.size() == ignoredDevices.size()) { + if (log.isDebugEnabled()) { + log.debug("All the devices contain a pending operation for the Operation Code: " + + operationCode); + } + Activity activity = new Activity(); + //Send the operation statuses only for admin triggered operations + String deviceType = validDeviceIds.get(0).getType(); + activity.setActivityStatus(this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult, + deviceType)); + return activity; + } else { + authorizedDevices.removeAll(ignoredDevices); + } + } + int operationId = this.lookupOperationDAO(operation).addOperation(operationDto); - boolean isNotRepeated = false; + boolean isScheduled = false; NotificationStrategy notificationStrategy = getNotificationStrategy(); // check whether device list is greater than batch size notification strategy has enable to send push // notification using scheduler task if (DeviceConfigurationManager.getInstance().getDeviceManagementConfig(). - getPushNotificationConfiguration().getSchedulerBatchSize() <= authorizedDeviceList.size() && + getPushNotificationConfiguration().getSchedulerBatchSize() <= authorizedDeviceIds.size() && notificationStrategy != null) { isScheduled = notificationStrategy.getConfig().isScheduled(); } - boolean hasExistingTaskOperation; - int enrolmentId; - List devices = new ArrayList<>(); - if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT == operationDto. - getControl()) { - isNotRepeated = true; - } - //TODO have to create a sql to load device details from deviceDAO using single query. - String operationCode = operationDto.getCode(); - for (DeviceIdentifier deviceId : authorizedDeviceList) { - Device device = getDevice(deviceId); - devices.add(device); + for (Device device : authorizedDevices) { enrolmentId = device.getEnrolmentInfo().getId(); //Do not repeat the task operations - if (isScheduledOperation) { - hasExistingTaskOperation = operationDAO.updateTaskOperation(enrolmentId, operationCode); - if (!hasExistingTaskOperation) { - operationMappingDAO.addOperationMapping(operationId, enrolmentId, isScheduled); - } - } else if (isNotRepeated) { - operationDAO.updateEnrollmentOperationsStatus(enrolmentId, operationCode, - org.wso2.carbon.device.mgt.core.dto.operation.mgt. - Operation.Status.PENDING, - org.wso2.carbon.device.mgt.core.dto.operation.mgt. - Operation.Status.REPEATED); - operationMappingDAO.addOperationMapping(operationId, enrolmentId, isScheduled); - } else { - operationMappingDAO.addOperationMapping(operationId, enrolmentId, isScheduled); - } + operationMappingDAO.addOperationMapping(operationId, enrolmentId, isScheduled); } OperationManagementDAOFactory.commitTransaction(); - /* - If notification strategy has not enable to send push notification using scheduler task we will send - notification immediately. This is done in separate loop inorder to prevent overlap with DB insert - operations with the possible db update operations trigger followed by pending operation call. - Otherwise device may call pending operation while DB is locked for write and deadlock can occur. - */ - if (notificationStrategy != null && !isScheduled) { - for (Device device : devices) { - DeviceIdentifier deviceId = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); - if (log.isDebugEnabled()) { - log.debug("Sending push notification to " + deviceId + " from add operation method."); - } - operation.setId(operationId); - operation.setActivityId(DeviceManagementConstants.OperationAttributes.ACTIVITY + operationId); - try { - notificationStrategy.execute(new NotificationContext(deviceId, operation)); - } catch (PushNotificationExecutionFailedException e) { - log.error("Error occurred while sending push notifications to " + deviceId.getType() + - " device carrying id '" + deviceId + "'", e); - /* - Reschedule if push notification failed. Doing db transactions in atomic way to prevent - deadlocks. - */ - enrolmentId = device.getEnrolmentInfo().getId(); - try { - operationMappingDAO.updateOperationMapping(operationId, enrolmentId, org.wso2.carbon - .device.mgt.core.dto.operation.mgt.Operation.PushNotificationStatus.SCHEDULED); - OperationManagementDAOFactory.commitTransaction(); - } catch (OperationManagementDAOException ex) { - // Not throwing this exception in order to keep sending remaining notifications if any. - log.error("Error occurred while setting push notification status to SCHEDULED.", ex); - OperationManagementDAOFactory.rollbackTransaction(); - } - } + if (isScheduled) { + for (Device device : authorizedDevices) { + this.sendNotification(operation, device); } } @@ -298,6 +279,195 @@ public class OperationManagerImpl implements OperationManager { } } + private Operation getPolicyRevokeOperation() { + CommandOperation policyRevokeOperation = new CommandOperation(); + policyRevokeOperation.setEnabled(true); + policyRevokeOperation.setCode(OperationMgtConstants.OperationCodes.POLICY_REVOKE); + policyRevokeOperation.setType(Operation.Type.COMMAND); + return policyRevokeOperation; + } + private Operation transformPolicy(Policy policy) { + List effectiveFeatures = policy.getProfile().getProfileFeaturesList(); + List profileOperationList = new ArrayList(); + PolicyOperation policyOperation = new PolicyOperation(); + policyOperation.setEnabled(true); + policyOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.POLICY); + policyOperation.setCode(PolicyOperation.POLICY_OPERATION_CODE); + for (ProfileFeature feature : effectiveFeatures) { + ProfileOperation profileOperation = new ProfileOperation(); + profileOperation.setCode(feature.getFeatureCode()); + profileOperation.setEnabled(true); + profileOperation.setStatus(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Status.PENDING); + profileOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.PROFILE); + profileOperation.setPayLoad(feature.getContent()); + profileOperationList.add(profileOperation); + } + policyOperation.setProfileOperations(profileOperationList); + policyOperation.setPayLoad(policyOperation.getProfileOperations()); + return policyOperation; + } + @Override + public void addOperationsForPolicyRevoke(Policy policy, List deviceIds) + throws OperationManagementException, InvalidDeviceException { + Operation revokeOperation = getPolicyRevokeOperation(); + Operation operation = transformPolicy(policy); + if (log.isDebugEnabled()) { + log.debug("operation:[" + operation.toString() + "]"); + for (DeviceIdentifier deviceIdentifier : deviceIds) { + log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" + + deviceIdentifier.getType() + "]"); + } + } + try { + DeviceIDHolder deviceValidationResult = DeviceManagerUtil.validateDeviceIdentifiers(deviceIds); + List validDeviceIds = deviceValidationResult.getValidDeviceIDList(); + if (validDeviceIds.size() > 0) { + DeviceIDHolder deviceAuthorizationResult = this.authorizeDevices(operation, validDeviceIds); + List authorizedDeviceList = deviceAuthorizationResult.getValidDeviceIDList(); + OperationManagementDAOFactory.beginTransaction(); + org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation policyOperationDto = + OperationDAOUtil.convertOperation(operation); + org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation revokeOperationDto = + OperationDAOUtil.convertOperation(revokeOperation); + boolean isScheduledOperation = this.isTaskScheduledOperation(operation); + boolean isNotRepeated = false; + boolean isScheduled = false; + NotificationStrategy notificationStrategy = getNotificationStrategy(); + // check whether device list is greater than batch size notification strategy has enable to send push + // notification using scheduler task + if (DeviceConfigurationManager.getInstance().getDeviceManagementConfig(). + getPushNotificationConfiguration().getSchedulerBatchSize() <= authorizedDeviceList.size() && + notificationStrategy != null) { + isScheduled = notificationStrategy.getConfig().isScheduled(); + } + List operationList = new LinkedList(); + operationList.add(revokeOperationDto); + operationList.add(policyOperationDto); + List operationIds = this.lookupOperationDAO(operation).addOperations(operationList); + List devices = new ArrayList<>(); + if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT == policyOperationDto. + getControl()) { + isNotRepeated = true; + } + //Need to happen for both revoke and new policy operation + addOperationMappings(authorizedDeviceList, revokeOperationDto, operationIds.get(0), isScheduledOperation, + isNotRepeated, isScheduled, devices); + sendPushNotifications(revokeOperation, operationIds.get(0), isScheduled, notificationStrategy, devices); + //Need to happen for both revoke and new policy operation + addOperationMappings(authorizedDeviceList, policyOperationDto, operationIds.get(1), isScheduledOperation, + isNotRepeated, isScheduled, devices); + sendPushNotifications(operation, operationIds.get(1), isScheduled, notificationStrategy, devices); + OperationManagementDAOFactory.commitTransaction(); + } else { + throw new InvalidDeviceException("Invalid device Identifiers found."); + } + } catch (OperationManagementDAOException e) { + OperationManagementDAOFactory.rollbackTransaction(); + throw new OperationManagementException("Error occurred while adding operation", e); + } catch (TransactionManagementException e) { + throw new OperationManagementException("Error occurred while initiating the transaction", e); + } finally { + OperationManagementDAOFactory.closeConnection(); + } + } + private String addOperationMappings(List authorizedDeviceList, org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto, int operationId, boolean isScheduledOperation, boolean isNotRepeated, boolean isScheduled, List devices) throws OperationManagementException, OperationManagementDAOException { + int enrolmentId; + int existingTaskOperationId;//TODO have to create a sql to load device details from deviceDAO using single query. + String operationCode = operationDto.getCode(); + for (DeviceIdentifier deviceId : authorizedDeviceList) { + Device device = getDevice(deviceId); + devices.add(device); + enrolmentId = device.getEnrolmentInfo().getId(); + //Do not repeat the task operations + if (isScheduledOperation) { + existingTaskOperationId = operationDAO.getExistingOperationID(enrolmentId, operationCode); + if (existingTaskOperationId != -1) { + operationMappingDAO.addOperationMapping(operationId, enrolmentId, isScheduled); + } + } else if (isNotRepeated) { + operationDAO.updateEnrollmentOperationsStatus(enrolmentId, operationCode, + org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING, + org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.REPEATED); + operationMappingDAO.addOperationMapping(operationId, enrolmentId, isScheduled); + } else { + operationMappingDAO.addOperationMapping(operationId, enrolmentId, isScheduled); + } + } + return operationCode; + } + /* + * If notification strategy has not enable to send push notification using scheduler task we will send + * notification immediately. This is done in separate loop inorder to prevent overlap with DB insert + * operations with the possible db update operations trigger followed by pending operation call. + * Otherwise device may call pending operation while DB is locked for write and deadlock can occur. + */ + private void sendPushNotifications(Operation operation, int operationId, boolean isScheduled, NotificationStrategy notificationStrategy, List devices) { + int enrolmentId; + if (notificationStrategy != null && !isScheduled) { + for (Device device : devices) { + DeviceIdentifier deviceId = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + if (log.isDebugEnabled()) { + log.debug("Sending push notification to " + deviceId + " from add operation method."); + } + operation.setId(operationId); + operation.setActivityId(DeviceManagementConstants.OperationAttributes.ACTIVITY + operationId); + try { + notificationStrategy.execute(new NotificationContext(deviceId, operation)); + } catch (PushNotificationExecutionFailedException e) { + log.error("Error occurred while sending push notifications to " + deviceId.getType() + + " device carrying id '" + deviceId + "'", e); + /* + Reschedule if push notification failed. Doing db transactions in atomic way to prevent + deadlocks. + */ + enrolmentId = device.getEnrolmentInfo().getId(); + try { + operationMappingDAO.updateOperationMapping(operationId, enrolmentId, org.wso2.carbon + .device.mgt.core.dto.operation.mgt.Operation.PushNotificationStatus.SCHEDULED); + } catch (OperationManagementDAOException ex) { + // Not throwing this exception in order to keep sending remaining notifications if any. + log.error("Error occurred while setting push notification status to SCHEDULED.", ex); + } + } + } + } + } + + private void sendNotification(Operation operation, Device device) { + NotificationStrategy notificationStrategy = getNotificationStrategy(); + /* + * If notification strategy has not enable to send push notification using scheduler task we will send + * notification immediately. This is done in separate loop inorder to prevent overlap with DB insert + * operations with the possible db update operations trigger followed by pending operation call. + * Otherwise device may call pending operation while DB is locked for write and deadlock can occur. + */ + if (notificationStrategy != null) { + if (log.isDebugEnabled()) { + log.debug("Sending push notification to " + device.getDeviceIdentifier() + " from add operation method."); + } + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + try { + notificationStrategy.execute(new NotificationContext(deviceIdentifier, operation)); + } catch (PushNotificationExecutionFailedException e) { + log.error("Error occurred while sending push notifications to " + device.getType() + + " device carrying id '" + device.getDeviceIdentifier() + "'", e); + /* + * Reschedule if push notification failed. Doing db transactions in atomic way to prevent + * deadlocks. + */ + try { + operationMappingDAO.updateOperationMapping(operation.getId(), device.getEnrolmentInfo().getId(), org.wso2.carbon + .device.mgt.core.dto.operation.mgt.Operation.PushNotificationStatus.SCHEDULED); + OperationManagementDAOFactory.commitTransaction(); + } catch (OperationManagementDAOException ex) { + // Not throwing this exception in order to keep sending remaining notifications if any. + log.error("Error occurred while setting push notification status to SCHEDULED.", ex); + OperationManagementDAOFactory.rollbackTransaction(); + } + } + } + } + private List getActivityStatus(DeviceIDHolder deviceIdValidationResult, DeviceIDHolder deviceAuthResult, String deviceType) { List activityStatuses = new ArrayList<>(); @@ -906,6 +1076,22 @@ public class OperationManagerImpl implements OperationManager { } } + @Override + public List getActivitiesUpdatedAfterByUser(long timestamp, String user, int limit, int offset) + throws OperationManagementException { + try { + OperationManagementDAOFactory.openConnection(); + return operationDAO.getActivitiesUpdatedAfterByUser(timestamp, user, limit, offset); + } catch (SQLException e) { + throw new OperationManagementException("Error occurred while opening a connection to the data source.", e); + } catch (OperationManagementDAOException e) { + throw new OperationManagementException("Error occurred while getting the activity list changed after a " + + "given time which are added by user : " + user, e); + } finally { + OperationManagementDAOFactory.closeConnection(); + } + } + @Override public int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementException { try { @@ -921,6 +1107,21 @@ public class OperationManagerImpl implements OperationManager { } } + @Override + public int getActivityCountUpdatedAfterByUser(long timestamp, String user) throws OperationManagementException { + try { + OperationManagementDAOFactory.openConnection(); + return operationDAO.getActivityCountUpdatedAfterByUser(timestamp, user); + } catch (SQLException e) { + throw new OperationManagementException("Error occurred while opening a connection to the data source.", e); + } catch (OperationManagementDAOException e) { + throw new OperationManagementException("Error occurred while getting the activity count changed after a " + + "given time which are added by user :" + user, e); + } finally { + OperationManagementDAOFactory.closeConnection(); + } + } + private OperationDAO lookupOperationDAO(Operation operation) { if (operation instanceof CommandOperation) { @@ -1065,4 +1266,4 @@ public class OperationManagerImpl implements OperationManager { private boolean isSameUser(String user, String owner) { return user.equalsIgnoreCase(owner); } -} \ No newline at end of file +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java index 908068b394..a40c0c5e8f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java @@ -30,6 +30,8 @@ public interface OperationDAO { int addOperation(Operation operation) throws OperationManagementDAOException; + List addOperations(List operations) throws OperationManagementDAOException; + Operation getOperation(int operationId) throws OperationManagementDAOException; Operation getOperationByDeviceAndId(int enrolmentId, int operationId) throws OperationManagementDAOException; @@ -54,7 +56,7 @@ public interface OperationDAO { void updateEnrollmentOperationsStatus(int enrolmentId, String operationCode, Operation.Status existingStatus, Operation.Status newStatus) throws OperationManagementDAOException; - boolean updateTaskOperation(int enrolmentId, String operationCode) throws OperationManagementDAOException; + int getExistingOperationID(int enrolmentId, String operationCode) throws OperationManagementDAOException; void addOperationResponse(int enrolmentId, int operationId, Object operationResponse) throws OperationManagementDAOException; @@ -71,8 +73,12 @@ public interface OperationDAO { int getTotalCountOfFilteredActivities(String operationCode) throws OperationManagementDAOException; + List getActivitiesUpdatedAfterByUser(long timestamp, String user, int limit, int offset) throws OperationManagementDAOException; + int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementDAOException; + int getActivityCountUpdatedAfterByUser(long timestamp, String user) throws OperationManagementDAOException; + /** * This method provides operation mappings for given status * @param opStatus Operation status @@ -84,4 +90,4 @@ public interface OperationDAO { Map> getOperationMappingsByStatus(Operation.Status opStatus, Operation.PushNotificationStatus pushNotificationStatus, int limit) throws OperationManagementDAOException; -} \ No newline at end of file +} 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 0078ce11d7..3ea9ba1f5e 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 @@ -86,6 +86,37 @@ public class GenericOperationDAOImpl implements OperationDAO { } } + //This implementation has been done this way due to H2 not supporting batch inserts properly. + //Even though records are added in batch mode, only the id of the last added record will be returned, which is a problem. + public List addOperations(List operations) throws OperationManagementDAOException { + List ids = new LinkedList(); + for (Operation operation : operations) { + PreparedStatement stmt = null; + ResultSet rs = null; + try { + Connection connection = OperationManagementDAOFactory.getConnection(); + String sql = "INSERT INTO DM_OPERATION(TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE) " + + "VALUES (?, ?, ?, ?)"; + stmt = connection.prepareStatement(sql, new String[]{"id"}); + stmt.setString(1, operation.getType().toString()); + stmt.setTimestamp(2, new Timestamp(new Date().getTime())); + stmt.setTimestamp(3, null); + stmt.setString(4, operation.getCode()); + stmt.executeUpdate(); + rs = stmt.getGeneratedKeys(); + int id = -1; + if (rs.next()) { + ids.add(rs.getInt(1)); + } + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while adding operation metadata", e); + } finally { + OperationManagementDAOUtil.cleanupResources(stmt, rs); + } + } + return ids; + } + public boolean updateOperationStatus(int enrolmentId, int operationId, Operation.Status status) throws OperationManagementDAOException { PreparedStatement stmt = null; @@ -150,14 +181,14 @@ public class GenericOperationDAOImpl implements OperationDAO { } @Override - public boolean updateTaskOperation(int enrolmentId, String operationCode) + public int getExistingOperationID(int enrolmentId, String operationCode) throws OperationManagementDAOException { PreparedStatement stmt = null; ResultSet rs = null; - boolean result = false; + int result = -1; try { Connection connection = OperationManagementDAOFactory.getConnection(); - String query = "SELECT EOM.ID FROM DM_ENROLMENT_OP_MAPPING EOM INNER JOIN DM_OPERATION DM " + String query = "SELECT DM.ID FROM DM_ENROLMENT_OP_MAPPING EOM INNER JOIN DM_OPERATION DM " + "ON DM.ID = EOM.OPERATION_ID WHERE EOM.ENROLMENT_ID = ? AND DM.OPERATION_CODE = ? AND " + "EOM.STATUS = ?"; stmt = connection.prepareStatement(query); @@ -167,7 +198,7 @@ public class GenericOperationDAOImpl implements OperationDAO { // This will return only one result always. rs = stmt.executeQuery(); if (rs.next()) { - result = true; + result = rs.getInt("ID"); } } catch (SQLException e) { throw new OperationManagementDAOException( @@ -705,6 +736,171 @@ public class GenericOperationDAOImpl implements OperationDAO { return 0; } + @Override + public List getActivitiesUpdatedAfterByUser(long timestamp, String user, int limit, int offset) + throws OperationManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs = null; + List activities = new ArrayList<>(); + try { + Connection conn = OperationManagementDAOFactory.getConnection(); + + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String sql = "SELECT " + + " opr.ENROLMENT_ID, " + + " opr.CREATED_TIMESTAMP, " + + " opr.UPDATED_TIMESTAMP, " + + " opr.OPERATION_ID, " + + " opr.OPERATION_CODE, " + + " opr.OPERATION_TYPE, " + + " opr.STATUS, " + + " opr.DEVICE_ID, " + + " opr.DEVICE_IDENTIFICATION, " + + " opr.DEVICE_TYPE, " + + " ops.RECEIVED_TIMESTAMP, " + + " ops.ID OP_RES_ID, " + + " ops.OPERATION_RESPONSE , " + + " opr.INITIATED_BY " + + " FROM " + + " (SELECT " + + " opm.ID MAPPING_ID, " + + " opm.ENROLMENT_ID, " + + " opm.CREATED_TIMESTAMP, " + + " opm.UPDATED_TIMESTAMP, " + + " opm.OPERATION_ID, " + + " op.OPERATION_CODE, " + + " op.INITIATED_BY, " + + " op.TYPE OPERATION_TYPE, " + + " opm.STATUS, " + + " en.DEVICE_ID, " + + " de.DEVICE_IDENTIFICATION, " + + " dt.NAME DEVICE_TYPE, " + + " de.TENANT_ID " + + " FROM" + + " DM_ENROLMENT_OP_MAPPING opm " + + " INNER JOIN DM_OPERATION op ON opm.OPERATION_ID = op.ID " + + " INNER JOIN DM_ENROLMENT en ON opm.ENROLMENT_ID = en.ID " + + " INNER JOIN DM_DEVICE de ON en.DEVICE_ID = de.ID " + + " INNER JOIN DM_DEVICE_TYPE dt ON dt.ID = de.DEVICE_TYPE_ID " + + " WHERE " + + " opm.UPDATED_TIMESTAMP > ? AND op.INITIATED_BY = ?" + + " AND de.TENANT_ID = ? " + + " ORDER BY opm.UPDATED_TIMESTAMP " + + " LIMIT ? OFFSET ?) opr " + + " LEFT JOIN DM_DEVICE_OPERATION_RESPONSE ops ON opr.MAPPING_ID = ops.EN_OP_MAP_ID " + + " WHERE " + + " opr.UPDATED_TIMESTAMP > ? AND opr.INITIATED_BY = ?" + + " AND opr.TENANT_ID = ? "; + + stmt = conn.prepareStatement(sql); + + stmt.setLong(1, timestamp); + stmt.setString(2, user); + stmt.setInt(3, tenantId); + stmt.setInt(4, limit); + stmt.setInt(5, offset); + stmt.setLong(6, timestamp); + stmt.setString(7, user); + stmt.setInt(8, tenantId); + + rs = stmt.executeQuery(); + + int operationId = 0; + int enrolmentId = 0; + int responseId = 0; + Activity activity = null; + ActivityStatus activityStatus = null; + while (rs.next()) { + + if (operationId != rs.getInt("OPERATION_ID")) { + activity = new Activity(); + activities.add(activity); + List statusList = new ArrayList<>(); + activityStatus = new ActivityStatus(); + + operationId = rs.getInt("OPERATION_ID"); + enrolmentId = rs.getInt("ENROLMENT_ID"); + + activity.setType(Activity.Type.valueOf(rs.getString("OPERATION_TYPE"))); + activity.setCreatedTimeStamp(new java.util.Date(rs.getLong(("CREATED_TIMESTAMP")) * 1000).toString()); + activity.setCode(rs.getString("OPERATION_CODE")); + activity.setInitiatedBy(rs.getString("INITIATED_BY")); + + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION")); + deviceIdentifier.setType(rs.getString("DEVICE_TYPE")); + activityStatus.setDeviceIdentifier(deviceIdentifier); + + activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS"))); + + List operationResponses = new ArrayList<>(); + if (rs.getInt("UPDATED_TIMESTAMP") != 0) { + activityStatus.setUpdatedTimestamp(new java.util.Date( + rs.getLong(("UPDATED_TIMESTAMP")) * 1000).toString()); + + } + if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { + operationResponses.add(OperationDAOUtil.getOperationResponse(rs)); + responseId = rs.getInt("OP_RES_ID"); + } + activityStatus.setResponses(operationResponses); + statusList.add(activityStatus); + activity.setActivityStatus(statusList); + activity.setActivityId(OperationDAOUtil.getActivityId(rs.getInt("OPERATION_ID"))); + + } + + if (operationId == rs.getInt("OPERATION_ID") && enrolmentId != rs.getInt("ENROLMENT_ID")) { + activityStatus = new ActivityStatus(); + + activity.setType(Activity.Type.valueOf(rs.getString("OPERATION_TYPE"))); + activity.setCreatedTimeStamp(new java.util.Date(rs.getLong(("CREATED_TIMESTAMP")) * 1000).toString()); + activity.setCode(rs.getString("OPERATION_CODE")); + + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION")); + deviceIdentifier.setType(rs.getString("DEVICE_TYPE")); + activityStatus.setDeviceIdentifier(deviceIdentifier); + + activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS"))); + + List operationResponses = new ArrayList<>(); + if (rs.getInt("UPDATED_TIMESTAMP") != 0) { + activityStatus.setUpdatedTimestamp(new java.util.Date( + rs.getLong(("UPDATED_TIMESTAMP")) * 1000).toString()); + } + if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { + operationResponses.add(OperationDAOUtil.getOperationResponse(rs)); + responseId = rs.getInt("OP_RES_ID"); + } + activityStatus.setResponses(operationResponses); + activity.getActivityStatus().add(activityStatus); + + enrolmentId = rs.getInt("ENROLMENT_ID"); + } + + if (rs.getInt("OP_RES_ID") != 0 && responseId != rs.getInt("OP_RES_ID")) { + if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { + activityStatus.getResponses().add(OperationDAOUtil.getOperationResponse(rs)); + responseId = rs.getInt("OP_RES_ID"); + } + } + } + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while getting the operation details from " + + "the database.", e); + } catch (ClassNotFoundException e) { + throw new OperationManagementDAOException("Error occurred while converting the operation response to string.", e); + } catch (IOException e) { + throw new OperationManagementDAOException("IO exception occurred while converting the operations responses.", e); + } finally { + OperationManagementDAOUtil.cleanupResources(stmt, rs); + } + + return activities; + + } + @Override public List getActivitiesUpdatedAfter(long timestamp, int limit, @@ -888,6 +1084,40 @@ public class GenericOperationDAOImpl implements OperationDAO { return 0; } + @Override + public int getActivityCountUpdatedAfterByUser(long timestamp, String user) throws OperationManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs = null; + try { + Connection conn = OperationManagementDAOFactory.getConnection(); + String sql = "SELECT \n" + + " COUNT(*) AS COUNT\n" + + "FROM\n" + + " DM_ENROLMENT_OP_MAPPING AS m\n" + + " INNER JOIN\n" + + " DM_ENROLMENT AS d ON m.ENROLMENT_ID = d.ID\n" + + " INNER JOIN \n" + + " DM_OPERATION dp ON dp.ID = m.OPERATION_ID \n" + + "WHERE\n" + + " m.UPDATED_TIMESTAMP > ? AND dp.INITIATED_BY = ?\n" + + " AND d.TENANT_ID = ?"; + stmt = conn.prepareStatement(sql); + stmt.setLong(1, timestamp); + stmt.setString(2, user); + stmt.setInt(3, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + rs = stmt.executeQuery(); + if (rs.next()) { + return rs.getInt("COUNT"); + } + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while getting the activity count from " + + "the database.", e); + } finally { + OperationManagementDAOUtil.cleanupResources(stmt, rs); + } + return 0; + } + @Override public Operation getOperation(int id) throws OperationManagementDAOException { PreparedStatement stmt = null; 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/PolicyOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java index 7f142b7d04..15bf7cbe65 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation; import org.wso2.carbon.device.mgt.core.dto.operation.mgt.PolicyOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; @@ -46,7 +47,6 @@ public class PolicyOperationDAOImpl extends GenericOperationDAOImpl { operation.setCreatedTimeStamp(new Timestamp(new java.util.Date().getTime()).toString()); operation.setId(operationId); operation.setEnabled(true); - PolicyOperation policyOperation = (PolicyOperation) operation; Connection conn = OperationManagementDAOFactory.getConnection(); stmt = conn.prepareStatement("INSERT INTO DM_POLICY_OPERATION(OPERATION_ID, OPERATION_DETAILS) " + "VALUES(?, ?)"); @@ -82,6 +82,79 @@ public class PolicyOperationDAOImpl extends GenericOperationDAOImpl { return operationId; } + + private int addCommandOperation(int operationId, Operation operation) throws OperationManagementDAOException { + CommandOperation commandOp = (CommandOperation) operation; + PreparedStatement stmt = null; + try { + Connection conn = OperationManagementDAOFactory.getConnection(); + stmt = conn.prepareStatement("INSERT INTO DM_COMMAND_OPERATION(OPERATION_ID, ENABLED) VALUES(?, ?)"); + stmt.setInt(1, operationId); + stmt.setBoolean(2, commandOp.isEnabled()); + stmt.executeUpdate(); + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while adding command operation", e); + } finally { + OperationManagementDAOUtil.cleanupResources(stmt); + } + return operationId; + } + @Override + public List addOperations(List operations) throws OperationManagementDAOException { + List operationIds; + int counter = 0; + operationIds = super.addOperations(operations); + for(Operation operation : operations) { + if(operation.getType().equals(Operation.Type.COMMAND)){ + addCommandOperation(operationIds.get(counter), operation); + } else if(operation.getType().equals(Operation.Type.POLICY)){ + addPolicyOperation(operationIds.get(counter), operation); + } + counter++; + } + return operationIds; + } + private void addPolicyOperation(int operationId, Operation operation) throws OperationManagementDAOException { + PreparedStatement stmt = null; + ByteArrayOutputStream bao = null; + ObjectOutputStream oos = null; + try { + operation.setCreatedTimeStamp(new Timestamp(new java.util.Date().getTime()).toString()); + operation.setId(operationId); + operation.setEnabled(true); + Connection conn = OperationManagementDAOFactory.getConnection(); + stmt = conn.prepareStatement("INSERT INTO DM_POLICY_OPERATION(OPERATION_ID, OPERATION_DETAILS) " + + "VALUES(?, ?)"); + bao = new ByteArrayOutputStream(); + oos = new ObjectOutputStream(bao); + oos.writeObject(operation); + stmt.setInt(1, operationId); + stmt.setBytes(2, bao.toByteArray()); + stmt.executeUpdate(); + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while adding policy operation", e); + } catch (IOException e) { + throw new OperationManagementDAOException("Error occurred while serializing policy operation object", e); + } finally { + if (bao != null) { + try { + bao.close(); + } catch (IOException e) { + log.warn("Error occurred while closing ByteArrayOutputStream", e); + } + } + if (oos != null) { + try { + oos.close(); + } catch (IOException e) { + log.warn("Error occurred while closing ObjectOutputStream", e); + } + } + OperationManagementDAOUtil.cleanupResources(stmt); + } + } + + @Override public Operation getOperation(int operationId) throws OperationManagementDAOException { PreparedStatement stmt = null; 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/operation/MySQLOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java index 23377c695c..0aa25c8c84 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java @@ -375,6 +375,170 @@ public class MySQLOperationDAOImpl extends GenericOperationDAOImpl { return activities; } + @Override + public List getActivitiesUpdatedAfterByUser(long timestamp, String user, int limit, int offset) + throws OperationManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs = null; + List activities = new ArrayList<>(); + try { + Connection conn = OperationManagementDAOFactory.getConnection(); + + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String sql = "SELECT " + + " opr.ENROLMENT_ID, " + + " opr.CREATED_TIMESTAMP, " + + " opr.UPDATED_TIMESTAMP, " + + " opr.OPERATION_ID, " + + " opr.OPERATION_CODE, " + + " opr.INITIATED_BY, " + + " opr.OPERATION_TYPE, " + + " opr.STATUS, " + + " opr.DEVICE_ID, " + + " opr.DEVICE_IDENTIFICATION, " + + " opr.DEVICE_TYPE, " + + " ops.RECEIVED_TIMESTAMP, " + + " ops.ID OP_RES_ID, " + + " ops.OPERATION_RESPONSE " + + " FROM " + + " (SELECT " + + " opm.ID MAPPING_ID, " + + " opm.ENROLMENT_ID, " + + " opm.CREATED_TIMESTAMP, " + + " opm.UPDATED_TIMESTAMP, " + + " opm.OPERATION_ID, " + + " op.OPERATION_CODE, " + + " op.INITIATED_BY, " + + " op.TYPE OPERATION_TYPE, " + + " opm.STATUS, " + + " en.DEVICE_ID, " + + " de.DEVICE_IDENTIFICATION, " + + " dt.NAME DEVICE_TYPE, " + + " de.TENANT_ID " + + " FROM" + + " DM_ENROLMENT_OP_MAPPING opm FORCE INDEX (IDX_ENROLMENT_OP_MAPPING) " + + " INNER JOIN DM_OPERATION op ON opm.OPERATION_ID = op.ID " + + " INNER JOIN DM_ENROLMENT en ON opm.ENROLMENT_ID = en.ID " + + " INNER JOIN DM_DEVICE de ON en.DEVICE_ID = de.ID " + + " INNER JOIN DM_DEVICE_TYPE dt ON dt.ID = de.DEVICE_TYPE_ID " + + " WHERE" + + " opm.UPDATED_TIMESTAMP > ? AND op.INITIATED_BY = ?" + + " AND de.TENANT_ID = ? " + + " ORDER BY opm.UPDATED_TIMESTAMP " + + " LIMIT ? OFFSET ?) opr " + + " LEFT JOIN DM_DEVICE_OPERATION_RESPONSE ops ON opr.MAPPING_ID = ops.EN_OP_MAP_ID " + + " WHERE " + + " opr.UPDATED_TIMESTAMP > ? AND opr.INITIATED_BY = ? " + + " AND opr.TENANT_ID = ? "; + + stmt = conn.prepareStatement(sql); + + stmt.setLong(1, timestamp); + stmt.setString(2, user); + stmt.setInt(3, tenantId); + stmt.setInt(4, limit); + stmt.setInt(5, offset); + stmt.setLong(6, timestamp); + stmt.setString(7, user); + stmt.setInt(8, tenantId); + + rs = stmt.executeQuery(); + + int operationId = 0; + int enrolmentId = 0; + int responseId = 0; + Activity activity = null; + ActivityStatus activityStatus = null; + while (rs.next()) { + + if (operationId != rs.getInt("OPERATION_ID")) { + activity = new Activity(); + activities.add(activity); + List statusList = new ArrayList<>(); + activityStatus = new ActivityStatus(); + + operationId = rs.getInt("OPERATION_ID"); + enrolmentId = rs.getInt("ENROLMENT_ID"); + + activity.setType(Activity.Type.valueOf(rs.getString("OPERATION_TYPE"))); + activity.setCreatedTimeStamp(new java.util.Date(rs.getLong(("CREATED_TIMESTAMP")) * 1000).toString()); + activity.setCode(rs.getString("OPERATION_CODE")); + activity.setInitiatedBy(rs.getString("INITIATED_BY")); + + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION")); + deviceIdentifier.setType(rs.getString("DEVICE_TYPE")); + activityStatus.setDeviceIdentifier(deviceIdentifier); + + activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS"))); + + List operationResponses = new ArrayList<>(); + if (rs.getInt("UPDATED_TIMESTAMP") != 0) { + activityStatus.setUpdatedTimestamp(new java.util.Date( + rs.getLong(("UPDATED_TIMESTAMP")) * 1000).toString()); + + } + if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { + operationResponses.add(OperationDAOUtil.getOperationResponse(rs)); + responseId = rs.getInt("OP_RES_ID"); + } + activityStatus.setResponses(operationResponses); + statusList.add(activityStatus); + activity.setActivityStatus(statusList); + activity.setActivityId(OperationDAOUtil.getActivityId(rs.getInt("OPERATION_ID"))); + + } + + if (operationId == rs.getInt("OPERATION_ID") && enrolmentId != rs.getInt("ENROLMENT_ID")) { + activityStatus = new ActivityStatus(); + + activity.setType(Activity.Type.valueOf(rs.getString("OPERATION_TYPE"))); + activity.setCreatedTimeStamp(new java.util.Date(rs.getLong(("CREATED_TIMESTAMP")) * 1000).toString()); + activity.setCode(rs.getString("OPERATION_CODE")); + activity.setInitiatedBy(rs.getString("INITIATED_BY")); + + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION")); + deviceIdentifier.setType(rs.getString("DEVICE_TYPE")); + activityStatus.setDeviceIdentifier(deviceIdentifier); + + activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS"))); + + List operationResponses = new ArrayList<>(); + if (rs.getInt("UPDATED_TIMESTAMP") != 0) { + activityStatus.setUpdatedTimestamp(new java.util.Date( + rs.getLong(("UPDATED_TIMESTAMP")) * 1000).toString()); + } + if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { + operationResponses.add(OperationDAOUtil.getOperationResponse(rs)); + responseId = rs.getInt("OP_RES_ID"); + } + activityStatus.setResponses(operationResponses); + activity.getActivityStatus().add(activityStatus); + + enrolmentId = rs.getInt("ENROLMENT_ID"); + } + + if (rs.getInt("OP_RES_ID") != 0 && responseId != rs.getInt("OP_RES_ID")) { + if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { + activityStatus.getResponses().add(OperationDAOUtil.getOperationResponse(rs)); + responseId = rs.getInt("OP_RES_ID"); + } + } + } + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while getting the operation details from " + + "the database.", e); + } catch (ClassNotFoundException e) { + throw new OperationManagementDAOException("Error occurred while converting the operation response to string.", e); + } catch (IOException e) { + throw new OperationManagementDAOException("IO exception occurred while converting the operations responses.", e); + } finally { + OperationManagementDAOUtil.cleanupResources(stmt, rs); + } + return activities; + } + private Integer[] getIntArrayOfActivityIds(List activityIds) { Integer[] arr = new Integer[activityIds.size()]; int x = 0; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index 96967441d0..4c27f08efd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -33,6 +33,7 @@ import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; @@ -542,6 +543,10 @@ public interface DeviceManagementProviderService { Activity addOperation(String type, Operation operation, List devices) throws OperationManagementException, InvalidDeviceException; + void addPolicyOperations(String type, Policy policy, + List devices) throws OperationManagementException, InvalidDeviceException; + + List getOperations(DeviceIdentifier deviceId) throws OperationManagementException; PaginationResult getOperations(DeviceIdentifier deviceId, @@ -577,8 +582,12 @@ public interface DeviceManagementProviderService { int getTotalCountOfFilteredActivities(String operationCode) throws OperationManagementException; + List getActivitiesUpdatedAfterByUser(long timestamp, String user, int limit, int offset) throws OperationManagementException; + int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementException; + int getActivityCountUpdatedAfterByUser(long timestamp, String user) throws OperationManagementException; + List getMonitoringOperationList(String deviceType); int getDeviceMonitoringFrequency(String deviceType); 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 b9e309b54b..d5170a620d 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 @@ -58,6 +58,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException; import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationSubscriber; @@ -1430,6 +1431,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return pluginRepository.getOperationManager(type, this.getTenantId()).addOperation(operation, devices); } + @Override + public void addPolicyOperations(String type, Policy policy, + List devices) throws OperationManagementException, InvalidDeviceException { + pluginRepository.getOperationManager(type, this.getTenantId()).addOperationsForPolicyRevoke(policy, devices); + } + @Override public List getOperations(DeviceIdentifier deviceId) throws OperationManagementException { return pluginRepository.getOperationManager(deviceId.getType(), this.getTenantId()).getOperations(deviceId); @@ -1563,11 +1570,22 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return DeviceManagementDataHolder.getInstance().getOperationManager().getTotalCountOfFilteredActivities(operationCode); } + @Override + public List getActivitiesUpdatedAfterByUser(long timestamp, String user, int limit, int offset) throws OperationManagementException { + limit = DeviceManagerUtil.validateActivityListPageSize(limit); + return DeviceManagementDataHolder.getInstance().getOperationManager().getActivitiesUpdatedAfterByUser(timestamp, user, limit, offset); + } + @Override public int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementException { return DeviceManagementDataHolder.getInstance().getOperationManager().getActivityCountUpdatedAfter(timestamp); } + @Override + public int getActivityCountUpdatedAfterByUser(long timestamp, String user) throws OperationManagementException { + return DeviceManagementDataHolder.getInstance().getOperationManager().getActivityCountUpdatedAfterByUser(timestamp, user); + } + @Override public List getMonitoringOperationList(String deviceType) { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); 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 eab1586373..2d2c40b3b4 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.1.34-SNAPSHOT + 3.1.40-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 136d8c91f9..8aec5fcc0d 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 6a59e99d0f..406dde9f3a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -5,8 +5,8 @@ "managerHTTPSURL": "https://%iot.manager.host%:%iot.manager.https.port%", "httpsURL": "https://%iot.gateway.host%:%iot.gateway.https.port%", "httpURL": "http://%iot.gateway.host%:%iot.gateway.http.port%", - "wssURL": "https://%iot.analytics.host%:%iot.analytics.https.port%", - "remoteSessionWSURL": "https://%iot.core.host%:%iot.core.https.port%", + "wssURL": "https://%iot.core.host%:%iot.core.https.port%", + "remoteSessionWSURL": "https://%iot.manager.host%:%iot.manager.https.port%", "portalURL": "https://%iot.analytics.host%:%iot.analytics.https.port%", "dashboardServerURL": "%https.ip%", "androidAgentDownloadURL": "%https.ip%/devicemgt/public/cdmf.unit.device.type.android.type-view/assets/android-agent.apk", @@ -56,7 +56,7 @@ "roleNameHelpMsg": "should be in minimum 3 characters long and do not include any whitespaces." }, "generalConfig": { - "host": "%http.ip%", + "host": "https://%iot.manager.host%:%iot.manager.https.port%", "companyName": "WSO2 Carbon Device Manager", "browserTitle": "WSO2 Device Manager", "copyrightPrefix": "\u00A9 %date-year%, ", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.js index cfefa850e0..a13b87502f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.js @@ -43,14 +43,14 @@ function onRequest(context) { if (tokenPair) { token = tokenPair.accessToken; } - websocketEndpoint = websocketEndpoint + "/secured-websocket/iot.per.device.stream." + tenantDomain + "." + device.type + "/1.0.0?" + websocketEndpoint = websocketEndpoint + "/secured-websocket-proxy/secured-websocket/iot.per.device.stream." + tenantDomain + "." + device.type + "/1.0.0?" + "deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type + "&websocketToken=" + token; } else { var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username + "@" + tenantDomain,"default", {}); if (tokenPair) { token = tokenPair.accessToken; } - websocketEndpoint = websocketEndpoint + "/secured-websocket" + "/t/" + tenantDomain + "/iot.per.device.stream." + tenantDomain + websocketEndpoint = websocketEndpoint + "/secured-websocket-proxy/secured-websocket/t/" + tenantDomain + "/iot.per.device.stream." + tenantDomain + "." + device.type + "/1.0.0?" + "deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type + "&websocketToken=" + token; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.footer/footer.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.footer/footer.hbs index 2a6e296cc4..5dc662d3db 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.footer/footer.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.footer/footer.hbs @@ -17,8 +17,8 @@ }} {{#zone "footer"}}

- - WSO2 IoT Server{{#unless isCloud}} 3.2.0{{/unless}} | © , + + WSO2 IoT Server{{#unless isCloud}} 3.3.1{{/unless}} | © , Inc. All Rights Reserved.

{{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.js index de15fc40e4..b44eb2be49 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.js @@ -37,14 +37,14 @@ function onRequest(context) { tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default", {}); if (tokenPair) { token = tokenPair.accessToken; - wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket/"; + wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket-proxy/secured-websocket/"; } } else { tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username + "@" + context.user.domain, "default", {}); if (tokenPair) { token = tokenPair.accessToken; - wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket/t/" + + wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket-proxy/secured-websocket/t/" + context.user.domain + "/"; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/application_options.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/application_options.js index cd1915e67a..8b18b96158 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/application_options.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/application_options.js @@ -32,7 +32,7 @@ var ApplicationOptions = { CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'iot.per.device.stream.geo.FusedSpatialEvent', CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'org.wso2.geo.AlertsNotifications', CEP_Traffic_STREAM_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'DefaultWebsocketOutputAdaptorOnTrafficStream', - CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME: 'secured-websocket', + CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME: 'secured-websocket-proxy', TENANT_INDEX: 't', COLON : ':', PATH_SEPARATOR : '/', diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-devices/geo-devices.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-devices/geo-devices.js index eddb14ea91..9db76cedad 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-devices/geo-devices.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-devices/geo-devices.js @@ -38,13 +38,13 @@ function onRequest(context) { tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default", {}); if (tokenPair) { token = tokenPair.accessToken; - wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket/"; + wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket-proxy/secured-websocket/"; } } else { tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username + "@" + context.user.domain,"default", {}); if (tokenPair) { token = tokenPair.accessToken; - wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket/t/"+context.user.domain+"/"; + wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket-proxy/secured-websocket/t/"+context.user.domain+"/"; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-devices/public/js/application_options.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-devices/public/js/application_options.js index 2ca6536b45..bba55e2700 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-devices/public/js/application_options.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-devices/public/js/application_options.js @@ -32,7 +32,7 @@ var ApplicationOptions = { CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'iot.per.device.stream.geo.FusedSpatialEvent', CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'org.wso2.geo.AlertsNotifications', CEP_Traffic_STREAM_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'DefaultWebsocketOutputAdaptorOnTrafficStream', - CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME: 'secured-websocket', + CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME: 'secured-websocket-proxy', TENANT_INDEX: 't', COLON : ':', PATH_SEPARATOR : '/', diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.footer/footer.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.footer/footer.hbs index a5127d5622..f981d80ffc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.footer/footer.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.footer/footer.hbs @@ -17,8 +17,8 @@ }} {{#zone "footer"}}

- - WSO2 IoT Server 3.2.0 | © , + + WSO2 IoT Server 3.3.1 | © , Inc. All Rights Reserved.

{{/zone}} \ No newline at end of file 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 bd7ff13ac4..efce704909 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/pom.xml index 5b18baf745..4db9aba109 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 7ec456690f..956cecaab0 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml @@ -41,6 +41,7 @@ org.wso2.carbon.device.mgt.v09.api org.wso2.carbon.device.mgt.analytics.data.publisher org.wso2.carbon.device.mgt.url.printer + org.wso2.carbon.device.mgt.analytics.wsproxy 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 165a003136..6b0cf581e5 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/email-sender/pom.xml b/components/email-sender/pom.xml index 3128e1d535..71457804e7 100644 --- a/components/email-sender/pom.xml +++ b/components/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-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 11a8a6b89e..64740b93fb 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.oauth.extensions - 3.1.34-SNAPSHOT + 3.1.40-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 f4398939c9..f31f23be36 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.1.34-SNAPSHOT + 3.1.40-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 a3bfc5c39e..f226f70e1f 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 1978500c00..f8df563ab3 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-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 fa505e75f5..ade03b5551 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.complex.policy.decision.point - 3.1.34-SNAPSHOT + 3.1.40-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 df4a1d4e53..4af9ff5723 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.decision.point - 3.1.34-SNAPSHOT + 3.1.40-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 b0420139bd..1f664458e5 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.information.point - 3.1.34-SNAPSHOT + 3.1.40-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 4e2f3e5780..6b117fe421 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.common - 3.1.34-SNAPSHOT + 3.1.40-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 53436fc959..d0e55b8c06 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.core - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT bundle WSO2 Carbon - Policy Management Core WSO2 Carbon - Policy Management Core diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegator.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegator.java index aac07ce600..c603be7d84 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegator.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegator.java @@ -33,4 +33,7 @@ public interface PolicyEnforcementDelegator { void addPolicyRevokeOperation(List deviceIdentifiers) throws PolicyDelegationException; + void revokePolicyOperation(List deviceIdentifiers, Policy policy) throws PolicyDelegationException; + + } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java index fa02314460..7471b7ae9f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java @@ -81,8 +81,7 @@ public class PolicyEnforcementDelegatorImpl implements PolicyEnforcementDelegato */ if (devicePolicy == null || devicePolicy.getId() != policy.getId() || updatedPolicyIds.contains (policy.getId())) { - this.addPolicyRevokeOperation(deviceIdentifiers); - this.addPolicyOperation(deviceIdentifiers, policy); + this.revokePolicyOperation(deviceIdentifiers, policy); } } else { //This means all the applicable policies have been removed from device. Hence calling a policy revoke. @@ -167,6 +166,27 @@ public class PolicyEnforcementDelegatorImpl implements PolicyEnforcementDelegato return policyRevokeOperation; } + @Override + public void revokePolicyOperation(List deviceIdentifiers, Policy policy) throws + PolicyDelegationException { + try { + String type = null; + if (deviceIdentifiers.size() > 0) { + type = deviceIdentifiers.get(0).getType(); + } + PolicyManagementDataHolder.getInstance().getDeviceManagementService().addPolicyOperations(type, policy, + deviceIdentifiers); + } catch (InvalidDeviceException e) { + String msg = "Invalid DeviceIdentifiers found."; + log.error(msg, e); + throw new PolicyDelegationException(msg, e); + } catch (OperationManagementException e) { + String msg = "Error occurred while adding the operation to device."; + log.error(msg, e); + throw new PolicyDelegationException(msg, e); + } + } + /** * Provides the applied policy for give device * diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index d10a353cb0..fe86127fcc 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 policy-mgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT pom WSO2 Carbon - Policy Management Component http://wso2.org diff --git a/components/test-coverage/pom.xml b/components/test-coverage/pom.xml index 27f904b310..bdd3c31c12 100644 --- a/components/test-coverage/pom.xml +++ b/components/test-coverage/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 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 3c4bc0c3be..2abd6ce664 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.webapp.authenticator.framework - 3.1.34-SNAPSHOT + 3.1.40-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 16429f6b03..84b26e6ff9 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt webapp-authenticator-framework - 3.1.34-SNAPSHOT + 3.1.40-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 ef9ee953df..c274e075f4 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.application.extension.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 020e7e4131..1c6417c2fc 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handler.server.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 a2a856c92c..e840d193cf 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client.feature - 3.1.34-SNAPSHOT + 3.1.40-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 d58b098ed8..166063800f 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 43cc7ec3bc..745a2a13c1 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt apimgt-extensions-feature - 3.1.34-SNAPSHOT + 3.1.40-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 86ce3dd5c1..47566f02fd 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.1.34-SNAPSHOT + 3.1.40-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 30fd9d28b9..5bd2da78e2 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.1.34-SNAPSHOT + 3.1.40-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 bdc83d82ba..a33d6301bf 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.server.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 abd1046616..53270854fb 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt-feature - 3.1.34-SNAPSHOT + 3.1.40-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 970d029acf..1345a8c893 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 c61b38a934..ab9703cad2 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 ddd5573447..e5d2eaf644 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 6f782cc2c0..1e045ac88a 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 299d02fa11..391d971aa8 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 8275b908b3..a6d152ad1d 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/src/main/resources/p2.inf b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/src/main/resources/p2.inf deleted file mode 100644 index 70f1acd33f..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,2 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.analytics.data.publisher_${feature.version}/conf/device-analytics-config.xml,target:${installFolder}/../../conf/etc/device-analytics-config.xml,overwrite:true);\ \ No newline at end of file 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.feature/pom.xml similarity index 74% rename from features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml rename to features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml index f59d768e6c..ada5e76748 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.feature/pom.xml @@ -1,6 +1,6 @@ + true - false - tcp://localhost:7612 + tcp://${iot.analytics.host}:${iot.analytics.thrift.port} + + wss://${iot.analytics.host}:${iot.analytics.https.port} admin admin diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/p2.inf b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/p2.inf new file mode 100644 index 0000000000..a0a1b3d005 --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/p2.inf @@ -0,0 +1,4 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.analytics_${feature.version}/conf/device-analytics-config.xml,target:${installFolder}/../../conf/etc/device-analytics-config.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.analytics_${feature.version}/webapps/secured-websocket-proxy.war,target:${installFolder}/../../deployment/server/webapps/secured-websocket-proxy.war,overwrite:true);\ \ No newline at end of file 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 b34626ff57..8866f6a624 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml index bf9b2075ac..fce238a85b 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 3.1.34-SNAPSHOT + 3.1.40-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 cb9ec56f1e..d022f0a089 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 0d730bc030..2cb920b096 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.1.34-SNAPSHOT + 3.1.40-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 1a565a139b..6ce6a14b88 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.server.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 bf0aae0b0b..411739ea50 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index fe70581b8a..9c13ebb88f 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml @@ -39,7 +39,7 @@ org.wso2.carbon.device.mgt.api.feature org.wso2.carbon.device.mgt.feature org.wso2.carbon.device.mgt.extensions.feature - org.wso2.carbon.device.mgt.analytics.data.publisher.feature + org.wso2.carbon.device.mgt.analytics.feature 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 7b373067dd..d2306d35f5 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.email.sender.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 8dc9237d46..27a19920d6 100644 --- a/features/email-sender/pom.xml +++ b/features/email-sender/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt email-sender-feature - 3.1.34-SNAPSHOT + 3.1.40-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 9136c38f14..3bb5043ccb 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.identity.jwt.client.extension.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 d8c03de017..79c53c0d2f 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 jwt-client-feature - 3.1.34-SNAPSHOT + 3.1.40-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 d71e5f9c69..2b06e5c5ff 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.oauth.extensions.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 ae22ee1ad6..d183fe0bb4 100644 --- a/features/oauth-extensions/pom.xml +++ b/features/oauth-extensions/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt oauth-extensions-feature - 3.1.34-SNAPSHOT + 3.1.40-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 e7cff33fdb..d7f2aff01b 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.policy.mgt.server.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 2f137eadd9..2c940317d6 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt policy-mgt-feature - 3.1.34-SNAPSHOT + 3.1.40-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 fc474d0f18..1d0bd6a4a0 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.webapp.authenticator.framework.server.feature pom - 3.1.34-SNAPSHOT + 3.1.40-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 07762e66fa..eca35681ec 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.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT pom WSO2 Carbon - Webapp Authenticator Framework Feature http://wso2.org diff --git a/pom.xml b/pom.xml index 43e2268bf2..b142d1fefc 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt pom - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -277,6 +277,11 @@ org.wso2.carbon.device.mgt.analytics.data.publisher ${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.analytics.wsproxy + ${carbon.device.mgt.version} + org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.server.feature @@ -1385,11 +1390,11 @@ provided - + mysql mysql-connector-java - ${tomcat.version} + ${mysql.connector.version} test @@ -1735,6 +1740,18 @@ apk-parser ${net.dongliu.version} + + + javax.websocket + javax.websocket-api + ${javax.websocket.version} + + + org.apache.tomcat + tomcat-websocket-api + ${tomcat.websocket.version} + provided + @@ -1997,8 +2014,8 @@ 1.2.140.wso2v3 - 7.0.59.wso2v1 - 7.0.59.wso2v1 + 7.0.85.wso2v1 + 7.0.85.wso2v1 7.0.34.wso2v2 @@ -2028,7 +2045,7 @@ 1.2.11.wso2v10 - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT 4.6.21 @@ -2106,8 +2123,8 @@ (3.2.0, 3.3.0] 1.8 - - 5.1.34 + + 5.1.34 3.0.4.wso2v1 @@ -2179,6 +2196,11 @@ 1.8 2.4.2 + + + 7.0.85 + 1.0 + 1.13.1