merge-requests/1/head
Pasindu 8 years ago
commit e015f8ae9b

@ -22,13 +22,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Annotations</name> <name>WSO2 Carbon - API Management Annotations</name>
<description>WSO2 Carbon - API Management Custom Annotation Module</description> <description>WSO2 Carbon - API Management Custom Annotation Module</description>

@ -21,12 +21,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<name>WSO2 Carbon - API Application Management API</name> <name>WSO2 Carbon - API Application Management API</name>

@ -22,12 +22,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Application Management</name> <name>WSO2 Carbon - API Application Management</name>

@ -84,109 +84,118 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
String keyType, String username, String keyType, String username,
boolean isAllowedAllDomains, String validityTime) boolean isAllowedAllDomains, String validityTime)
throws APIManagerException { throws APIManagerException {
StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() StoreClient storeClient =
.getStoreClient(); APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
.getStoreClient();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext() String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getTenantDomain(); .getTenantDomain();
try {
ApplicationList applicationList = storeClient.getApplications()
.applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null);
Application application;
if (applicationList == null || applicationList.getList() == null || applicationList.getList().size() == 0) {
//create application;
application = new Application();
application.setName(applicationName);
application.setSubscriber(username);
application.setDescription("");
application.setThrottlingTier(ApiApplicationConstants.DEFAULT_TIER);
application.setGroupId("");
application = storeClient.getIndividualApplication().applicationsPost(application, CONTENT_TYPE);
} else {
ApplicationInfo applicationInfo = applicationList.getList().get(0);
application = storeClient.getIndividualApplication()
.applicationsApplicationIdGet(applicationInfo.getApplicationId(), CONTENT_TYPE, null, null);
}
if (application == null) {
throw new APIManagerException(
"Api application creation failed for " + applicationName + " to the user " + username);
}
ApplicationList applicationList = storeClient.getApplications() SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet
.applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); (null, application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null);
Application application; List<Subscription> needToSubscribe = new ArrayList<>();
if (applicationList == null || applicationList.getList() == null || applicationList.getList().size() == 0) { // subscribe to apis.
//create application; if (tags != null && tags.length > 0) {
application = new Application(); for (String tag : tags) {
application.setName(applicationName); APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, tenantDomain, "tag:" + tag
application.setSubscriber(username); , CONTENT_TYPE, null);
application.setDescription(""); if (apiList.getList() == null || apiList.getList().size() == 0) {
application.setThrottlingTier(ApiApplicationConstants.DEFAULT_TIER); apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0
application.setGroupId(""); , MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null);
application = storeClient.getIndividualApplication().applicationsPost(application, CONTENT_TYPE); }
} else {
ApplicationInfo applicationInfo = applicationList.getList().get(0);
application = storeClient.getIndividualApplication()
.applicationsApplicationIdGet(applicationInfo.getApplicationId(), CONTENT_TYPE, null, null);
}
if (application == null) {
throw new APIManagerException (
"Api application creation failed for " + applicationName + " to the user " + username);
}
SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet
(null, application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null);
List<Subscription> needToSubscribe = new ArrayList<>();
// subscribe to apis.
if (tags != null && tags.length > 0) {
for (String tag: tags) {
APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, tenantDomain, "tag:" + tag
, CONTENT_TYPE, null);
if (apiList.getList() == null || apiList.getList().size() == 0) {
apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0
, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null);
}
if (apiList.getList() != null && apiList.getList().size() > 0) { if (apiList.getList() != null && apiList.getList().size() > 0) {
for (APIInfo apiInfo : apiList.getList()) { for (APIInfo apiInfo : apiList.getList()) {
String id = apiInfo.getProvider().replace("@", "-AT-") String id = apiInfo.getProvider().replace("@", "-AT-")
+ "-" + apiInfo.getName()+ "-" + apiInfo.getVersion(); + "-" + apiInfo.getName() + "-" + apiInfo.getVersion();
boolean subscriptionExist = false; boolean subscriptionExist = false;
if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) { if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) {
for (Subscription subs : subscriptionList.getList()) { for (Subscription subs : subscriptionList.getList()) {
if (subs.getApiIdentifier().equals(id)) { if (subs.getApiIdentifier().equals(id)) {
subscriptionExist = true; subscriptionExist = true;
break; break;
}
} }
} }
} if (!subscriptionExist) {
if (!subscriptionExist) { Subscription subscription = new Subscription();
Subscription subscription = new Subscription(); //fix for APIMANAGER-5566 admin-AT-tenant1.com-Tenant1API1-1.0.0
//fix for APIMANAGER-5566 admin-AT-tenant1.com-Tenant1API1-1.0.0
subscription.setApiIdentifier(id);
subscription.setApiIdentifier(id); subscription.setApplicationId(application.getApplicationId());
subscription.setApplicationId(application.getApplicationId()); subscription.tier(ApiApplicationConstants.DEFAULT_TIER);
subscription.tier(ApiApplicationConstants.DEFAULT_TIER); if (!needToSubscribe.contains(subscription)) {
if (!needToSubscribe.contains(subscription)){ needToSubscribe.add(subscription);
needToSubscribe.add(subscription); }
} }
} }
} }
} }
} }
} if (!needToSubscribe.isEmpty()) {
if (!needToSubscribe.isEmpty()) { storeClient.getSubscriptionMultitpleApi().subscriptionsMultiplePost(needToSubscribe, CONTENT_TYPE);
storeClient.getSubscriptionMultitpleApi().subscriptionsMultiplePost(needToSubscribe, CONTENT_TYPE); }
} //end of subscription
//end of subscription
List<ApplicationKey> applicationKeys = application.getKeys();
List<ApplicationKey> applicationKeys = application.getKeys(); if (applicationKeys != null) {
if (applicationKeys != null) { for (ApplicationKey applicationKey : applicationKeys) {
for (ApplicationKey applicationKey : applicationKeys) { if (keyType.equals(applicationKey.getKeyType().toString())) {
if (keyType.equals(applicationKey.getKeyType().toString())) { if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret());
return apiApplicationKey; return apiApplicationKey;
}
}
} }
} }
}
ApplicationKeyGenerateRequest applicationKeyGenerateRequest = new ApplicationKeyGenerateRequest(); ApplicationKeyGenerateRequest applicationKeyGenerateRequest = new ApplicationKeyGenerateRequest();
List<String> allowedDomains = new ArrayList<>(); List<String> allowedDomains = new ArrayList<>();
if (isAllowedAllDomains) { if (isAllowedAllDomains) {
allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS);
} else { } else {
allowedDomains.add(APIManagerUtil.getTenantDomain()); allowedDomains.add(APIManagerUtil.getTenantDomain());
}
applicationKeyGenerateRequest.setAccessAllowDomains(allowedDomains);
applicationKeyGenerateRequest.setCallbackUrl("");
applicationKeyGenerateRequest.setKeyType(ApplicationKeyGenerateRequest.KeyTypeEnum.PRODUCTION);
applicationKeyGenerateRequest.setValidityTime(validityTime);
ApplicationKey applicationKey = storeClient.getIndividualApplication().applicationsGenerateKeysPost(
application.getApplicationId(), applicationKeyGenerateRequest, CONTENT_TYPE, null, null);
if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret());
return apiApplicationKey;
}
throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain);
} catch (FeignException e) {
throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e);
} }
applicationKeyGenerateRequest.setAccessAllowDomains(allowedDomains);
applicationKeyGenerateRequest.setCallbackUrl("");
applicationKeyGenerateRequest.setKeyType(ApplicationKeyGenerateRequest.KeyTypeEnum.PRODUCTION);
applicationKeyGenerateRequest.setValidityTime(validityTime);
ApplicationKey applicationKey = storeClient.getIndividualApplication().applicationsGenerateKeysPost(
application.getApplicationId(), applicationKeyGenerateRequest, CONTENT_TYPE, null, null);
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret());
return apiApplicationKey;
} }
} }

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId> <artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Security Handler Component</name> <name>WSO2 Carbon - API Security Handler Component</name>
<description>WSO2 Carbon - API Management Security Handler Module</description> <description>WSO2 Carbon - API Management Security Handler Module</description>

@ -13,13 +13,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Client</name> <name>WSO2 Carbon - API Management Integration Client</name>
<description>WSO2 Carbon - API Management Integration Client</description> <description>WSO2 Carbon - API Management Integration Client</description>

@ -13,13 +13,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Generated Client</name> <name>WSO2 Carbon - API Management Integration Generated Client</name>
<description>WSO2 Carbon - API Management Integration Client</description> <description>WSO2 Carbon - API Management Integration Client</description>

@ -22,13 +22,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId> <artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Webapp Publisher</name> <name>WSO2 Carbon - API Management Webapp Publisher</name>
<description>WSO2 Carbon - API Management Webapp Publisher</description> <description>WSO2 Carbon - API Management Webapp Publisher</description>

@ -22,13 +22,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Component</name> <name>WSO2 Carbon - API Management Extensions Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,13 +21,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId> <artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Certificate Management Core</name> <name>WSO2 Carbon - Certificate Management Core</name>
<description>WSO2 Carbon - Certificate Management Core</description> <description>WSO2 Carbon - Certificate Management Core</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Certificate Management Component</name> <name>WSO2 Carbon - Certificate Management Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -0,0 +1,67 @@
/*
* Copyright (c) 2017, 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.extensions.device.type.deployer.config;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "DeviceStatusTaskConfig")
public class DeviceStatusTaskConfiguration {
private boolean enabled;
private int frequency;
private int idleTimeToMarkInactive;
private int idleTimeToMarkUnreachable;
@XmlElement(name = "RequireStatusMonitoring", required = true)
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@XmlElement(name = "Frequency", required = true)
public int getFrequency() {
return frequency;
}
public void setFrequency(int frequency) {
this.frequency = frequency;
}
@XmlElement(name = "IdleTimeToMarkInactive", required = true)
public int getIdleTimeToMarkInactive() {
return idleTimeToMarkInactive;
}
public void setIdleTimeToMarkInactive(int idleTimeToMarkInactive) {
this.idleTimeToMarkInactive = idleTimeToMarkInactive;
}
@XmlElement(name = "IdleTimeToMarkUnreachable", required = true)
public int getIdleTimeToMarkUnreachable() {
return idleTimeToMarkUnreachable;
}
public void setIdleTimeToMarkUnreachable(int idleTimeToMarkUnreachable) {
this.idleTimeToMarkUnreachable = idleTimeToMarkUnreachable;
}
}

@ -18,7 +18,12 @@
*/ */
package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config;
import javax.xml.bind.annotation.*; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlAccessType;
import java.util.List; import java.util.List;
@ -40,6 +45,7 @@ import java.util.List;
* &lt;element name="DataSource" type="{}DataSource"/> * &lt;element name="DataSource" type="{}DataSource"/>
* &lt;element name="PolicyMonitoring" type="{}PolicyMonitoring"/> * &lt;element name="PolicyMonitoring" type="{}PolicyMonitoring"/>
* &lt;element name="DeviceAuthorizationConfig" type="{}DeviceAuthorizationConfig"/> * &lt;element name="DeviceAuthorizationConfig" type="{}DeviceAuthorizationConfig"/>
* &lt;element name="DeviceStatusTaskConfig" type="{}DeviceStatusTaskConfig"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" /> * &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction> * &lt;/restriction>
@ -67,6 +73,8 @@ public class DeviceTypeConfiguration {
protected DataSource dataSource; protected DataSource dataSource;
@XmlElement(name = "TaskConfiguration", required = true) @XmlElement(name = "TaskConfiguration", required = true)
private TaskConfiguration taskConfiguration; private TaskConfiguration taskConfiguration;
@XmlElement(name = "DeviceStatusTaskConfig")
private DeviceStatusTaskConfiguration deviceStatusTaskConfiguration;
@XmlElement(name = "DeviceAuthorizationConfig", required = true) @XmlElement(name = "DeviceAuthorizationConfig", required = true)
protected DeviceAuthorizationConfig deviceAuthorizationConfig; protected DeviceAuthorizationConfig deviceAuthorizationConfig;
@XmlAttribute(name = "name") @XmlAttribute(name = "name")
@ -85,9 +93,29 @@ public class DeviceTypeConfiguration {
this.operations = operations; this.operations = operations;
} }
/**
* Gets the value of the deviceStatusTaskConfiguration property.
*
* @return
* possible object is
* {@link DeviceStatusTaskConfiguration }
*
*/
public DeviceStatusTaskConfiguration getDeviceStatusTaskConfiguration() {
return deviceStatusTaskConfiguration;
}
/**
* Sets the value of the deviceStatusTaskConfiguration property.
*
* @param deviceStatusTaskConfiguration
* allowed object is
* {@link DeviceStatusTaskConfiguration }
*
*/
public void setDeviceStatusTaskConfiguration(DeviceStatusTaskConfiguration deviceStatusTaskConfiguration) {
this.deviceStatusTaskConfiguration = deviceStatusTaskConfiguration;
}
/** /**
* Gets the value of the taskConfiguration property. * Gets the value of the taskConfiguration property.
@ -313,5 +341,4 @@ public class DeviceTypeConfiguration {
public void setDeviceAuthorizationConfig(DeviceAuthorizationConfig value) { public void setDeviceAuthorizationConfig(DeviceAuthorizationConfig value) {
this.deviceAuthorizationConfig = value; this.deviceAuthorizationConfig = value;
} }
} }

@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.InitialOperationConfig; import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
import org.wso2.carbon.device.mgt.common.MonitoringOperation; import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig; import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
@ -37,6 +38,7 @@ import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceT
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Property; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Property;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.PushNotificationProvider; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.PushNotificationProvider;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.TaskConfiguration; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.TaskConfiguration;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceStatusTaskConfiguration;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.policy.mgt.DefaultPolicyMonitoringManager; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.policy.mgt.DefaultPolicyMonitoringManager;
import java.util.ArrayList; import java.util.ArrayList;
@ -60,6 +62,7 @@ public class DeviceTypeManagerService implements DeviceManagementService {
private List<MonitoringOperation> monitoringOperations; private List<MonitoringOperation> monitoringOperations;
private PolicyMonitoringManager policyMonitoringManager; private PolicyMonitoringManager policyMonitoringManager;
private InitialOperationConfig initialOperationConfig; private InitialOperationConfig initialOperationConfig;
private DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig;
public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
DeviceTypeConfiguration deviceTypeConfiguration) { DeviceTypeConfiguration deviceTypeConfiguration) {
@ -71,6 +74,8 @@ public class DeviceTypeManagerService implements DeviceManagementService {
this.setOperationMonitoringConfig(deviceTypeConfiguration); this.setOperationMonitoringConfig(deviceTypeConfiguration);
this.initialOperationConfig = new InitialOperationConfig(); this.initialOperationConfig = new InitialOperationConfig();
this.setInitialOperationConfig(deviceTypeConfiguration); this.setInitialOperationConfig(deviceTypeConfiguration);
this.deviceStatusTaskPluginConfig = new DeviceStatusTaskPluginConfig();
this.setDeviceStatusTaskPluginConfig(deviceTypeConfiguration.getDeviceStatusTaskConfiguration());
if (deviceTypeConfiguration.getPolicyMonitoring() != null ) { if (deviceTypeConfiguration.getPolicyMonitoring() != null ) {
this.policyMonitoringManager = new DefaultPolicyMonitoringManager(); this.policyMonitoringManager = new DefaultPolicyMonitoringManager();
} }
@ -174,6 +179,10 @@ public class DeviceTypeManagerService implements DeviceManagementService {
return initialOperationConfig; return initialOperationConfig;
} }
public DeviceStatusTaskPluginConfig getDeviceStatusTaskPluginConfig() {
return deviceStatusTaskPluginConfig;
}
private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) { private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) {
if (deviceTypeConfiguration.getProvisioningConfig() != null) { if (deviceTypeConfiguration.getProvisioningConfig() != null) {
boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants(); boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants();
@ -183,6 +192,15 @@ public class DeviceTypeManagerService implements DeviceManagementService {
} }
} }
private void setDeviceStatusTaskPluginConfig(DeviceStatusTaskConfiguration deviceStatusTaskConfiguration) {
if (deviceStatusTaskConfiguration != null && deviceStatusTaskConfiguration.isEnabled()) {
deviceStatusTaskPluginConfig.setRequireStatusMonitoring(deviceStatusTaskConfiguration.isEnabled());
deviceStatusTaskPluginConfig.setIdleTimeToMarkInactive(deviceStatusTaskConfiguration.getIdleTimeToMarkInactive());
deviceStatusTaskPluginConfig.setIdleTimeToMarkUnreachable(deviceStatusTaskConfiguration.getIdleTimeToMarkUnreachable());
deviceStatusTaskPluginConfig.setFrequency(deviceStatusTaskConfiguration.getFrequency());
}
}
protected void setInitialOperationConfig(DeviceTypeConfiguration deviceTypeConfiguration) { protected void setInitialOperationConfig(DeviceTypeConfiguration deviceTypeConfiguration) {
if (deviceTypeConfiguration.getOperations() != null) { if (deviceTypeConfiguration.getOperations() != null) {
List<String> ops = deviceTypeConfiguration.getOperations(); List<String> ops = deviceTypeConfiguration.getOperations();

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -0,0 +1,62 @@
/*
* Copyright (c) 2017, 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.common;
/**
* This class holds plugin specific configurations for Device Status Monitoring Task.
*/
public class DeviceStatusTaskPluginConfig {
private boolean requireStatusMonitoring;
private int frequency;
private int idleTimeToMarkInactive;
private int idleTimeToMarkUnreachable;
public int getFrequency() {
return frequency;
}
public void setFrequency(int frequency) {
this.frequency = frequency;
}
public int getIdleTimeToMarkInactive() {
return idleTimeToMarkInactive;
}
public void setIdleTimeToMarkInactive(int idleTimeToMarkInactive) {
this.idleTimeToMarkInactive = idleTimeToMarkInactive;
}
public int getIdleTimeToMarkUnreachable() {
return idleTimeToMarkUnreachable;
}
public void setIdleTimeToMarkUnreachable(int idleTimeToMarkUnreachable) {
this.idleTimeToMarkUnreachable = idleTimeToMarkUnreachable;
}
public boolean isRequireStatusMonitoring() {
return requireStatusMonitoring;
}
public void setRequireStatusMonitoring(boolean requireStatusMonitoring) {
this.requireStatusMonitoring = requireStatusMonitoring;
}
}

@ -47,6 +47,6 @@ public interface DeviceManagementService {
InitialOperationConfig getInitialOperationConfig(); InitialOperationConfig getInitialOperationConfig();
DeviceStatusTaskPluginConfig getDeviceStatusTaskPluginConfig();
} }

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -24,17 +24,24 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceTypeIdentifier; import org.wso2.carbon.device.mgt.common.DeviceTypeIdentifier;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig; import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagerStartupListener; import org.wso2.carbon.device.mgt.core.internal.DeviceManagerStartupListener;
import org.wso2.carbon.device.mgt.core.internal.DeviceMonitoringOperationDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceMonitoringOperationDataHolder;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerRepository; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerRepository;
import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskException;
import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskManagerService;
import org.wso2.carbon.device.mgt.core.status.task.impl.DeviceStatusTaskManagerServiceImpl;
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException; import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
@ -46,7 +53,7 @@ import java.util.Map;
public class DeviceManagementPluginRepository implements DeviceManagerStartupListener { public class DeviceManagementPluginRepository implements DeviceManagerStartupListener {
private Map<DeviceTypeIdentifier, DeviceManagementService> providers; private Map<DeviceTypeIdentifier, DeviceManagementService> providers;
private boolean isInited; private boolean isInitiated;
private static final Log log = LogFactory.getLog(DeviceManagementPluginRepository.class); private static final Log log = LogFactory.getLog(DeviceManagementPluginRepository.class);
private OperationManagerRepository operationManagerRepository; private OperationManagerRepository operationManagerRepository;
@ -58,29 +65,28 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
public void addDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException { public void addDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException {
String deviceType = provider.getType().toLowerCase(); String deviceType = provider.getType().toLowerCase();
ProvisioningConfig provisioningConfig = provider.getProvisioningConfig(); ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
String tenantDomain = provisioningConfig.getProviderTenantDomain(); String tenantDomain = provisioningConfig.getProviderTenantDomain();
DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
boolean isSharedWithAllTenants = provisioningConfig.isSharedWithAllTenants(); boolean isSharedWithAllTenants = provisioningConfig.isSharedWithAllTenants();
int tenantId = DeviceManagerUtil.getTenantId(tenantDomain); int tenantId = DeviceManagerUtil.getTenantId(tenantDomain);
if (tenantId == -1) { if (tenantId == -1) {
throw new DeviceManagementException("No tenant available for tenant domain " + tenantDomain); throw new DeviceManagementException("No tenant available for tenant domain " + tenantDomain);
} }
synchronized (providers) { synchronized (providers) {
try { if (isInitiated) {
if (isInited) { /* Initializing Device Management Service Provider */
/* Initializing Device Management Service Provider */ provider.init();
provider.init(); DeviceManagerUtil.registerDeviceType(deviceType, tenantId, isSharedWithAllTenants);
DeviceManagerUtil.registerDeviceType(deviceType, tenantId, isSharedWithAllTenants); DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(deviceType,
DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(deviceType, provider.getDeviceManager().
provider.getDeviceManager() requireDeviceAuthorization());
.requireDeviceAuthorization()); registerPushNotificationStrategy(provider);
registerPushNotificationStrategy(provider); registerMonitoringTask(provider);
registerMonitoringTask(provider); if (deviceManagementConfig != null && deviceManagementConfig.getDeviceStatusTaskConfig().isEnabled()) {
DeviceType deviceTypeObj = DeviceManagerUtil.getDeviceType(deviceType, tenantId);
registerDeviceStatusMonitoringTask(deviceTypeObj, provider);
} }
} catch (DeviceManagementException e) {
throw new DeviceManagementException("Error occurred while adding device management provider '" +
deviceType + "'", e);
} }
if (isSharedWithAllTenants) { if (isSharedWithAllTenants) {
DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType); DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType);
@ -94,19 +100,25 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
public void removeDeviceManagementProvider(DeviceManagementService provider) public void removeDeviceManagementProvider(DeviceManagementService provider)
throws DeviceManagementException { throws DeviceManagementException {
String deviceTypeName = provider.getType().toLowerCase(); String deviceTypeName = provider.getType().toLowerCase();
DeviceTypeIdentifier deviceTypeIdentifier; DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
ProvisioningConfig provisioningConfig = provider.getProvisioningConfig(); DeviceTypeIdentifier deviceTypeIdentifier;
if (provisioningConfig.isSharedWithAllTenants()) { ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
deviceTypeIdentifier = new DeviceTypeIdentifier(deviceTypeName); if (provisioningConfig.isSharedWithAllTenants()) {
providers.remove(deviceTypeIdentifier); deviceTypeIdentifier = new DeviceTypeIdentifier(deviceTypeName);
} else { providers.remove(deviceTypeIdentifier);
int providerTenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain()); } else {
deviceTypeIdentifier = new DeviceTypeIdentifier(deviceTypeName, providerTenantId); int providerTenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain());
providers.remove(deviceTypeIdentifier); deviceTypeIdentifier = new DeviceTypeIdentifier(deviceTypeName, providerTenantId);
} providers.remove(deviceTypeIdentifier);
unregisterPushNotificationStrategy(deviceTypeIdentifier); }
unregisterMonitoringTask(provider); unregisterPushNotificationStrategy(deviceTypeIdentifier);
unregisterMonitoringTask(provider);
if (deviceManagementConfig != null && deviceManagementConfig.getDeviceStatusTaskConfig().isEnabled()) {
DeviceType deviceTypeObj = DeviceManagerUtil.getDeviceType(deviceTypeIdentifier.getDeviceType(),
deviceTypeIdentifier.getTenantId());
unregisterDeviceStatusMonitoringTask(deviceTypeObj, provider);
}
} }
private void unregisterPushNotificationStrategy(DeviceTypeIdentifier deviceTypeIdentifier) { private void unregisterPushNotificationStrategy(DeviceTypeIdentifier deviceTypeIdentifier) {
@ -149,30 +161,30 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
deviceManagementService.getProvisioningConfig().getProviderTenantDomain(), true); deviceManagementService.getProvisioningConfig().getProviderTenantDomain(), true);
try { try {
boolean isSharedWithAllTenants = deviceManagementService.getProvisioningConfig().isSharedWithAllTenants(); boolean isSharedWithAllTenants = deviceManagementService.getProvisioningConfig().isSharedWithAllTenants();
DeviceTypeIdentifier deviceTypeIdentifier; DeviceTypeIdentifier deviceTypeIdentifier;
if (isSharedWithAllTenants) { if (isSharedWithAllTenants) {
deviceTypeIdentifier = new DeviceTypeIdentifier(deviceManagementService.getType()); deviceTypeIdentifier = new DeviceTypeIdentifier(deviceManagementService.getType());
} else { } else {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
deviceTypeIdentifier = new DeviceTypeIdentifier(deviceManagementService.getType(), tenantId); deviceTypeIdentifier = new DeviceTypeIdentifier(deviceManagementService.getType(), tenantId);
} }
if (pushNoteConfig != null) { if (pushNoteConfig != null) {
PushNotificationProvider provider = DeviceManagementDataHolder.getInstance() PushNotificationProvider provider = DeviceManagementDataHolder.getInstance()
.getPushNotificationProviderRepository().getProvider(pushNoteConfig.getType()); .getPushNotificationProviderRepository().getProvider(pushNoteConfig.getType());
if (provider == null) { if (provider == null) {
throw new DeviceManagementException( throw new DeviceManagementException(
"No registered push notification provider found for the type: '" + "No registered push notification provider found for the type: '" +
pushNoteConfig.getType() + "'."); pushNoteConfig.getType() + "'.");
}
NotificationStrategy notificationStrategy = provider.getNotificationStrategy(pushNoteConfig);
operationManagerRepository.addOperationManager(deviceTypeIdentifier,
new OperationManagerImpl(deviceTypeIdentifier.getDeviceType(), notificationStrategy));
} else {
operationManagerRepository.addOperationManager(deviceTypeIdentifier,
new OperationManagerImpl(deviceTypeIdentifier.getDeviceType()));
} }
NotificationStrategy notificationStrategy = provider.getNotificationStrategy(pushNoteConfig);
operationManagerRepository.addOperationManager(deviceTypeIdentifier,
new OperationManagerImpl(deviceTypeIdentifier.getDeviceType(), notificationStrategy));
} else {
operationManagerRepository.addOperationManager(deviceTypeIdentifier,
new OperationManagerImpl(deviceTypeIdentifier.getDeviceType()));
}
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
@ -181,12 +193,10 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
private void registerMonitoringTask(DeviceManagementService deviceManagementService) private void registerMonitoringTask(DeviceManagementService deviceManagementService)
throws DeviceManagementException { throws DeviceManagementException {
try { try {
DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance() DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance().
.getDeviceTaskManagerService(); getDeviceTaskManagerService();
OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementService.
OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementService getOperationMonitoringConfig();
.getOperationMonitoringConfig();
if (operationMonitoringTaskConfig != null && operationMonitoringTaskConfig.isEnabled()) { if (operationMonitoringTaskConfig != null && operationMonitoringTaskConfig.isEnabled()) {
if (deviceTaskManagerService == null) { if (deviceTaskManagerService == null) {
@ -206,10 +216,10 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
private void unregisterMonitoringTask(DeviceManagementService deviceManagementService) private void unregisterMonitoringTask(DeviceManagementService deviceManagementService)
throws DeviceManagementException { throws DeviceManagementException {
try { try {
DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance() DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance().
.getDeviceTaskManagerService(); getDeviceTaskManagerService();
OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementService OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementService.
.getOperationMonitoringConfig(); getOperationMonitoringConfig();
if (operationMonitoringTaskConfig != null) { if (operationMonitoringTaskConfig != null) {
deviceTaskManagerService.stopTask(deviceManagementService.getType(), deviceTaskManagerService.stopTask(deviceManagementService.getType(),
deviceManagementService.getOperationMonitoringConfig()); deviceManagementService.getOperationMonitoringConfig());
@ -220,6 +230,42 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
} }
} }
private void registerDeviceStatusMonitoringTask(DeviceType deviceType, DeviceManagementService deviceManagementService) throws
DeviceManagementException {
DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance().
getDeviceTaskManagerService();
DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig = deviceManagementService.getDeviceStatusTaskPluginConfig();
if (deviceStatusTaskPluginConfig != null && deviceStatusTaskPluginConfig.isRequireStatusMonitoring()) {
if (deviceTaskManagerService == null) {
DeviceManagementDataHolder.getInstance().addDeviceStatusTaskPluginConfig(deviceType,
deviceStatusTaskPluginConfig);
} else {
try {
new DeviceStatusTaskManagerServiceImpl().startTask(deviceType, deviceStatusTaskPluginConfig);
} catch (DeviceStatusTaskException e) {
throw new DeviceManagementException("Error occurred while adding Device Status task service for '" +
deviceManagementService.getType() + "'", e);
}
}
}
}
private void unregisterDeviceStatusMonitoringTask(DeviceType deviceType, DeviceManagementService deviceManagementService) throws
DeviceManagementException {
DeviceStatusTaskManagerService deviceStatusTaskManagerService = DeviceManagementDataHolder.getInstance().
getDeviceStatusTaskManagerService();
DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig = deviceManagementService.getDeviceStatusTaskPluginConfig();
if (deviceStatusTaskPluginConfig != null && deviceStatusTaskPluginConfig.isRequireStatusMonitoring()) {
try {
DeviceManagementDataHolder.getInstance().removeDeviceStatusTaskPluginConfig(deviceType);
deviceStatusTaskManagerService.stopTask(deviceType, deviceStatusTaskPluginConfig);
} catch (DeviceStatusTaskException e) {
throw new DeviceManagementException("Error occurred while stopping Device Status task service for '" +
deviceManagementService.getType() + "'", e);
}
}
}
public OperationManager getOperationManager(String deviceType, int tenantId) { public OperationManager getOperationManager(String deviceType, int tenantId) {
//Priority need to be given to the tenant before public. //Priority need to be given to the tenant before public.
DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType.toLowerCase(), tenantId); DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType.toLowerCase(), tenantId);
@ -242,25 +288,26 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
ProvisioningConfig provisioningConfig = provider.getProvisioningConfig(); ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
int tenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain()); int tenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain());
DeviceManagerUtil.registerDeviceType(deviceTypeName, tenantId, DeviceManagerUtil.registerDeviceType(deviceTypeName, tenantId,
provisioningConfig.isSharedWithAllTenants()); provisioningConfig.isSharedWithAllTenants());
registerPushNotificationStrategy(provider); registerPushNotificationStrategy(provider);
registerMonitoringTask(provider); registerMonitoringTask(provider);
//TODO: //TODO:
//This is a temporory fix. //This is a temporory fix.
//windows and IOS cannot resolve user info by extracting certs //windows and IOS cannot resolve user info by extracting certs
//until fix that, use following variable to enable and disable of checking user authorization. //until fix that, use following variable to enable and disable of checking user authorization.
DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(provider.getType(), DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(provider.getType(),
provider.getDeviceManager() provider.getDeviceManager()
.requireDeviceAuthorization()); .requireDeviceAuthorization());
} catch (Throwable e) { } catch (Throwable e) {
/* Throwable is caught intentionally as failure of one plugin - due to invalid start up parameters, /* Throwable is caught intentionally as failure of one plugin - due to invalid start up parameters,
etc - should not block the initialization of other device management providers */ etc - should not block the initialization of other device management providers */
log.error("Error occurred while initializing device management provider '" + log.error("Error occurred while initializing device management provider '" +
provider.getType() + "'", e); provider.getType() + "'", e);
} }
} }
this.isInited = true; this.isInitiated = true;
} }
} }
} }

@ -21,6 +21,7 @@ import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations;
import org.wso2.carbon.device.mgt.core.config.pagination.PaginationConfiguration; import org.wso2.carbon.device.mgt.core.config.pagination.PaginationConfiguration;
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
import org.wso2.carbon.device.mgt.core.config.push.notification.PushNotificationConfiguration; import org.wso2.carbon.device.mgt.core.config.push.notification.PushNotificationConfiguration;
import org.wso2.carbon.device.mgt.core.config.status.task.DeviceStatusTaskConfig;
import org.wso2.carbon.device.mgt.core.config.task.TaskConfiguration; import org.wso2.carbon.device.mgt.core.config.task.TaskConfiguration;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ -41,6 +42,7 @@ public final class DeviceManagementConfig {
private PolicyConfiguration policyConfiguration; private PolicyConfiguration policyConfiguration;
private PaginationConfiguration paginationConfiguration; private PaginationConfiguration paginationConfiguration;
private PushNotificationConfiguration pushNotificationConfiguration; private PushNotificationConfiguration pushNotificationConfiguration;
private DeviceStatusTaskConfig deviceStatusTaskConfig;
@XmlElement(name = "ManagementRepository", required = true) @XmlElement(name = "ManagementRepository", required = true)
@ -97,5 +99,14 @@ public final class DeviceManagementConfig {
public void setPushNotificationConfiguration(PushNotificationConfiguration pushNotificationConfiguration) { public void setPushNotificationConfiguration(PushNotificationConfiguration pushNotificationConfiguration) {
this.pushNotificationConfiguration = pushNotificationConfiguration; this.pushNotificationConfiguration = pushNotificationConfiguration;
} }
@XmlElement(name = "DeviceStatusTaskConfig", required = true)
public DeviceStatusTaskConfig getDeviceStatusTaskConfig() {
return deviceStatusTaskConfig;
}
public void setDeviceStatusTaskConfig(DeviceStatusTaskConfig deviceStatusTaskConfig) {
this.deviceStatusTaskConfig = deviceStatusTaskConfig;
}
} }

@ -0,0 +1,38 @@
/*
* Copyright (c) 2017, 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.core.config.status.task;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "DeviceStatusTaskConfig")
public class DeviceStatusTaskConfig {
private boolean enabled;
@XmlElement(name = "Enable", required = true)
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}

@ -32,11 +32,15 @@ public interface EnrollmentDAO {
int updateEnrollment(EnrolmentInfo enrolmentInfo) throws DeviceManagementDAOException; int updateEnrollment(EnrolmentInfo enrolmentInfo) throws DeviceManagementDAOException;
boolean updateEnrollmentStatus(List<EnrolmentInfo> enrolmentInfos) throws DeviceManagementDAOException;
int removeEnrollment(int deviceId, String currentOwner, int tenantId) throws DeviceManagementDAOException; int removeEnrollment(int deviceId, String currentOwner, int tenantId) throws DeviceManagementDAOException;
boolean setStatus(int enrolmentId, String currentOwner, Status status, boolean setStatus(int enrolmentId, String currentOwner, Status status,
int tenantId) throws DeviceManagementDAOException; int tenantId) throws DeviceManagementDAOException;
boolean setStatus(int enrolmentId, Status status, int tenantId) throws DeviceManagementDAOException;
Status getStatus(int deviceId, String currentOwner, int tenantId) throws DeviceManagementDAOException; Status getStatus(int deviceId, String currentOwner, int tenantId) throws DeviceManagementDAOException;
EnrolmentInfo getEnrollment(int deviceId, String currentUser, int tenantId) throws DeviceManagementDAOException; EnrolmentInfo getEnrollment(int deviceId, String currentUser, int tenantId) throws DeviceManagementDAOException;

@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.EnrollmentDAO; import org.wso2.carbon.device.mgt.core.dao.EnrollmentDAO;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMapping;
import java.sql.*; import java.sql.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -115,6 +116,42 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
} }
} }
@Override
public boolean updateEnrollmentStatus(List<EnrolmentInfo> enrolmentInfos) throws DeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
boolean status = false;
int updateStatus = -1;
try {
conn = this.getConnection();
String sql = "UPDATE DM_ENROLMENT SET STATUS = ? WHERE ID = ?";
stmt = conn.prepareStatement(sql);
if (conn.getMetaData().supportsBatchUpdates()) {
for (EnrolmentInfo enrolmentInfo : enrolmentInfos) {
stmt.setString(1, enrolmentInfo.getStatus().toString());
stmt.setInt(2, enrolmentInfo.getId());
stmt.addBatch();
}
updateStatus = stmt.executeBatch().length;
} else {
for (EnrolmentInfo enrolmentInfo : enrolmentInfos) {
stmt.setString(1, enrolmentInfo.getStatus().toString());
stmt.setInt(2, enrolmentInfo.getId());
updateStatus = stmt.executeUpdate();
}
}
if (updateStatus > 0) {
status = true;
}
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while updating enrolment status of given device-list.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
return status;
}
@Override @Override
public int removeEnrollment(int deviceId, String currentOwner, public int removeEnrollment(int deviceId, String currentOwner,
@ -166,6 +203,26 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
return true; return true;
} }
@Override
public boolean setStatus(int enrolmentID, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "UPDATE DM_ENROLMENT SET STATUS = ? WHERE ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, status.toString());
stmt.setInt(2, enrolmentID);
stmt.setInt(3, tenantId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
return true;
}
@Override @Override
public EnrolmentInfo.Status getStatus(int deviceId, String currentOwner, public EnrolmentInfo.Status getStatus(int deviceId, String currentOwner,
int tenantId) throws DeviceManagementDAOException { int tenantId) throws DeviceManagementDAOException {

@ -18,6 +18,8 @@
package org.wso2.carbon.device.mgt.core.internal; package org.wso2.carbon.device.mgt.core.internal;
import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig;
import org.wso2.carbon.device.mgt.common.DeviceTypeIdentifier;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
@ -25,9 +27,11 @@ import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig; import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository; import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskManagerService;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.email.sender.core.service.EmailSenderService; import org.wso2.carbon.email.sender.core.service.EmailSenderService;
import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.ntask.core.service.TaskService;
@ -36,6 +40,7 @@ import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.user.core.tenant.TenantManager; import org.wso2.carbon.user.core.tenant.TenantManager;
import org.wso2.carbon.utils.ConfigurationContextService; import org.wso2.carbon.utils.ConfigurationContextService;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -59,6 +64,9 @@ public class DeviceManagementDataHolder {
private EmailSenderService emailSenderService; private EmailSenderService emailSenderService;
private PushNotificationProviderRepository pushNotificationProviderRepository; private PushNotificationProviderRepository pushNotificationProviderRepository;
private DeviceTaskManagerService deviceTaskManagerService; private DeviceTaskManagerService deviceTaskManagerService;
private DeviceStatusTaskManagerService deviceStatusTaskManagerService;
private Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = Collections.synchronizedMap(
new HashMap<DeviceType, DeviceStatusTaskPluginConfig>());
private Map<String, OperationMonitoringTaskConfig> map = new HashMap<>(); private Map<String, OperationMonitoringTaskConfig> map = new HashMap<>();
@ -191,7 +199,6 @@ public class DeviceManagementDataHolder {
this.deviceAccessAuthorizationService = deviceAccessAuthorizationService; this.deviceAccessAuthorizationService = deviceAccessAuthorizationService;
} }
public TaskService getTaskService() { public TaskService getTaskService() {
return taskService; return taskService;
} }
@ -224,4 +231,28 @@ public class DeviceManagementDataHolder {
public void setDeviceTaskManagerService(DeviceTaskManagerService deviceTaskManagerService) { public void setDeviceTaskManagerService(DeviceTaskManagerService deviceTaskManagerService) {
this.deviceTaskManagerService = deviceTaskManagerService; this.deviceTaskManagerService = deviceTaskManagerService;
} }
public DeviceStatusTaskManagerService getDeviceStatusTaskManagerService() {
return deviceStatusTaskManagerService;
}
public void setDeviceStatusTaskManagerService(DeviceStatusTaskManagerService deviceStatusTaskManagerService) {
this.deviceStatusTaskManagerService = deviceStatusTaskManagerService;
}
public void addDeviceStatusTaskPluginConfig(DeviceType deviceType, DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig) {
this.deviceStatusTaskPluginConfigs.put(deviceType, deviceStatusTaskPluginConfig);
}
public DeviceStatusTaskPluginConfig getDeviceStatusTaskPluginConfig(DeviceTypeIdentifier deviceType) {
return this.deviceStatusTaskPluginConfigs.get(deviceType);
}
public Map<DeviceType, DeviceStatusTaskPluginConfig> getDeviceStatusTaskPluginConfigs() {
return this.deviceStatusTaskPluginConfigs;
}
public void removeDeviceStatusTaskPluginConfig(DeviceType deviceType) {
this.deviceStatusTaskPluginConfigs.remove(deviceType);
}
} }

@ -22,11 +22,18 @@ package org.wso2.carbon.device.mgt.core.internal;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
import org.wso2.carbon.device.mgt.core.device.details.mgt.impl.DeviceInformationManagerImpl; import org.wso2.carbon.device.mgt.core.device.details.mgt.impl.DeviceInformationManagerImpl;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
import org.wso2.carbon.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl; import org.wso2.carbon.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl;
import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskException;
import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskManagerService;
import org.wso2.carbon.device.mgt.core.status.task.impl.DeviceStatusTaskManagerServiceImpl;
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException; import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl; import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl;
@ -47,24 +54,21 @@ import java.util.Map;
public class DeviceTaskManagerServiceComponent { public class DeviceTaskManagerServiceComponent {
private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class); private static Log log = LogFactory.getLog(DeviceTaskManagerServiceComponent.class);
@SuppressWarnings("unused") @SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) { protected void activate(ComponentContext componentContext) {
try { try {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Initializing device details retrieving task manager bundle."); log.debug("Initializing device task manager bundle.");
} }
// This will start the device details retrieving task.
// DeviceTaskManagerService deviceTaskManagerService = new DeviceTaskManagerServiceImpl();
// DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(
// deviceTaskManagerService);
// componentContext.getBundleContext().registerService(DeviceTaskManagerService.class,
// deviceTaskManagerService, null);
getDeviceOperationMonitoringConfig(componentContext); getDeviceOperationMonitoringConfig(componentContext);
//Start the DeviceStatusMonitoringTask for registered DeviceTypes
DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().
getDeviceManagementConfig();
if (deviceManagementConfig != null && deviceManagementConfig.getDeviceStatusTaskConfig().isEnabled()) {
startDeviceStatusMonitoringTask();
}
componentContext.getBundleContext().registerService(DeviceInformationManager.class, componentContext.getBundleContext().registerService(DeviceInformationManager.class,
new DeviceInformationManagerImpl(), null); new DeviceInformationManagerImpl(), null);
@ -72,29 +76,38 @@ public class DeviceTaskManagerServiceComponent {
componentContext.getBundleContext().registerService(SearchManagerService.class, componentContext.getBundleContext().registerService(SearchManagerService.class,
new SearchManagerServiceImpl(), null); new SearchManagerServiceImpl(), null);
} catch (Throwable e) { } catch (Throwable e) {
log.error("Error occurred while initializing device details retrieving task manager service.", e); log.error("Error occurred while initializing device task manager service.", e);
} }
} }
private void getDeviceOperationMonitoringConfig(ComponentContext componentContext) private void getDeviceOperationMonitoringConfig(ComponentContext componentContext)
throws DeviceMgtTaskException { throws DeviceMgtTaskException {
DeviceTaskManagerService deviceTaskManagerService = new DeviceTaskManagerServiceImpl(); DeviceTaskManagerService deviceTaskManagerService = new DeviceTaskManagerServiceImpl();
DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(deviceTaskManagerService); DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(deviceTaskManagerService);
componentContext.getBundleContext().registerService(DeviceTaskManagerService.class, componentContext.getBundleContext().registerService(DeviceTaskManagerService.class,
deviceTaskManagerService, null); deviceTaskManagerService, null);
Map<String, OperationMonitoringTaskConfig> deviceConfigMap = DeviceMonitoringOperationDataHolder Map<String, OperationMonitoringTaskConfig> deviceConfigMap = DeviceMonitoringOperationDataHolder
.getInstance().getOperationMonitoringConfigFromMap(); .getInstance().getOperationMonitoringConfigFromMap();
for (String platformType : new ArrayList<>(deviceConfigMap.keySet())) { for (String platformType : new ArrayList<>(deviceConfigMap.keySet())) {
deviceTaskManagerService.startTask(platformType, deviceConfigMap.get(platformType)); deviceTaskManagerService.startTask(platformType, deviceConfigMap.get(platformType));
deviceConfigMap.remove(platformType); deviceConfigMap.remove(platformType);
} }
} }
private void startDeviceStatusMonitoringTask() {
DeviceStatusTaskManagerService deviceStatusTaskManagerService = new DeviceStatusTaskManagerServiceImpl();
Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = DeviceManagementDataHolder.
getInstance().getDeviceStatusTaskPluginConfigs();
for (DeviceType deviceType : new ArrayList<>(deviceStatusTaskPluginConfigs.keySet())) {
try {
deviceStatusTaskManagerService.startTask(deviceType, deviceStatusTaskPluginConfigs.get(deviceType));
} catch (DeviceStatusTaskException e) {
log.error("Exception occurred while starting the DeviceStatusMonitoring Task for deviceType '" +
deviceType + "'", e);
}
}
}
@SuppressWarnings("unused") @SuppressWarnings("unused")
protected void deactivate(ComponentContext componentContext) { protected void deactivate(ComponentContext componentContext) {
try { try {
@ -105,7 +118,6 @@ public class DeviceTaskManagerServiceComponent {
} }
} }
protected void setTaskService(TaskService taskService) { protected void setTaskService(TaskService taskService) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Setting the task service."); log.debug("Setting the task service.");
@ -119,7 +131,4 @@ public class DeviceTaskManagerServiceComponent {
} }
DeviceManagementDataHolder.getInstance().setTaskService(null); DeviceManagementDataHolder.getInstance().setTaskService(null);
} }
} }

@ -0,0 +1,82 @@
/*
* Copyright (c) 2017, 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.core.operation.mgt;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
/**
* This holds results of Pending-operations to enrolment mappings.
*/
public class OperationEnrolmentMapping {
int enrolmentId;
int tenantId;
long createdTime;
String deviceType;
String deviceId;
EnrolmentInfo.Status deviceStatus;
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
public int getEnrolmentId() {
return enrolmentId;
}
public void setEnrolmentId(int enrolmentId) {
this.enrolmentId = enrolmentId;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public long getCreatedTime() {
return createdTime;
}
public void setCreatedTime(long createdTime) {
this.createdTime = createdTime;
}
public EnrolmentInfo.Status getDeviceStatus() {
return deviceStatus;
}
public void setDeviceStatus(String deviceStatus) {
this.deviceStatus = EnrolmentInfo.Status.valueOf(deviceStatus);
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
}

@ -418,12 +418,8 @@ public class OperationManagerImpl implements OperationManager {
int enrolmentId = enrolmentInfo.getId(); int enrolmentId = enrolmentInfo.getId();
//Changing the enrollment status & attempt count if the device is marked as inactive or unreachable //Changing the enrollment status & attempt count if the device is marked as inactive or unreachable
switch (enrolmentInfo.getStatus()) { switch (enrolmentInfo.getStatus()) {
case ACTIVE:
this.resetAttemptCount(enrolmentId);
break;
case INACTIVE: case INACTIVE:
case UNREACHABLE: case UNREACHABLE:
this.resetAttemptCount(enrolmentId);
this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE);
break; break;
} }
@ -479,12 +475,8 @@ public class OperationManagerImpl implements OperationManager {
int enrolmentId = enrolmentInfo.getId(); int enrolmentId = enrolmentInfo.getId();
//Changing the enrollment status & attempt count if the device is marked as inactive or unreachable //Changing the enrollment status & attempt count if the device is marked as inactive or unreachable
switch (enrolmentInfo.getStatus()) { switch (enrolmentInfo.getStatus()) {
case ACTIVE:
this.resetAttemptCount(enrolmentId);
break;
case INACTIVE: case INACTIVE:
case UNREACHABLE: case UNREACHABLE:
this.resetAttemptCount(enrolmentId);
this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE);
break; break;
} }
@ -1040,24 +1032,6 @@ public class OperationManagerImpl implements OperationManager {
return updateStatus; return updateStatus;
} }
private boolean resetAttemptCount(int enrolmentId) throws OperationManagementException {
boolean resetStatus;
try {
OperationManagementDAOFactory.beginTransaction();
resetStatus = operationDAO.resetAttemptCount(enrolmentId);
OperationManagementDAOFactory.commitTransaction();
} catch (OperationManagementDAOException e) {
OperationManagementDAOFactory.rollbackTransaction();
throw new OperationManagementException("Error occurred while resetting attempt count of device id : '" +
enrolmentId + "'", e);
} catch (TransactionManagementException e) {
throw new OperationManagementException("Error occurred while initiating a transaction", e);
} finally {
OperationManagementDAOFactory.closeConnection();
}
return resetStatus;
}
private boolean isTaskScheduledOperation(Operation operation, List<DeviceIdentifier> deviceIds) { private boolean isTaskScheduledOperation(Operation operation, List<DeviceIdentifier> deviceIds) {
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance(). DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
getDeviceManagementProvider(); getDeviceManagementProvider();

@ -18,10 +18,12 @@
*/ */
package org.wso2.carbon.device.mgt.core.operation.mgt.dao; package org.wso2.carbon.device.mgt.core.operation.mgt.dao;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMapping;
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation; import org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationEnrolmentMapping;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMapping;
import java.util.List; import java.util.List;
import java.util.Map;
public interface OperationMappingDAO { public interface OperationMappingDAO {
@ -34,4 +36,30 @@ public interface OperationMappingDAO {
void updateOperationMapping(List<OperationMapping> operationMappingList) throws void updateOperationMapping(List<OperationMapping> operationMappingList) throws
OperationManagementDAOException; OperationManagementDAOException;
/**
* This method returns first pending/repeated operation available for each active enrolment of given device-type
* where the operation was created after the given timestamp.
*
* @param minDuration - Upper limit of Operation created time
* @param maxDuration - Lower limit of Operation created time
* @param deviceTypeId - Device Type Id of required devices
* @return List<OperationEnrolmentMapping> - List of OperationEnrolmentMapping objects containing required data
* @throws OperationManagementDAOException
*/
List<OperationEnrolmentMapping> getFirstPendingOperationMappingsForActiveEnrolments(long minDuration,
long maxDuration, int deviceTypeId)
throws OperationManagementDAOException;
/**
* This method returns the timestamp of last completed Operation for each active enrolment of given device-type
* where the operation was completed after the given timestamp.
*
* @param timeStamp - Timestamp of considered time-interval
* @param deviceTypeId - Device Type of required devices
* @return List<OperationEnrolmentMapping> - List of OperationEnrolmentMapping objects containing required data
* @throws OperationManagementDAOException
*/
Map<Integer, Long> getLastConnectedTimeForActiveEnrolments(long timeStamp, int deviceTypeId)
throws OperationManagementDAOException;
} }

@ -18,7 +18,9 @@
*/ */
package org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl; package org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation; import org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationEnrolmentMapping;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMapping; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMapping;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
@ -27,8 +29,12 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationMappingDAO;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class OperationMappingDAOImpl implements OperationMappingDAO { public class OperationMappingDAOImpl implements OperationMappingDAO {
@ -129,4 +135,82 @@ public class OperationMappingDAOImpl implements OperationMappingDAO {
OperationManagementDAOUtil.cleanupResources(stmt, null); OperationManagementDAOUtil.cleanupResources(stmt, null);
} }
} }
@Override
public List<OperationEnrolmentMapping> getFirstPendingOperationMappingsForActiveEnrolments(long minDuration,
long maxDuration, int deviceTypeId) throws OperationManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
List<OperationEnrolmentMapping> enrolmentOperationMappingList = null;
try {
Connection conn = OperationManagementDAOFactory.getConnection();
//We are specifically looking for operation mappings in 'Pending' & 'Repeated' states. Further we want
//devices to be active at that moment. Hence filtering by 'ACTIVE' & 'UNREACHABLE' device states.
String sql = "SELECT ENROLMENT_ID, D.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFIER, MIN(CREATED_TIMESTAMP) " +
"AS CREATED_TIMESTAMP, E.STATUS AS ENROLMENT_STATUS, E.TENANT_ID FROM " +
"DM_ENROLMENT_OP_MAPPING AS OP INNER JOIN DM_ENROLMENT E ON OP.ENROLMENT_ID = E.ID INNER JOIN " +
"DM_DEVICE D ON E.DEVICE_ID = D.ID WHERE " +
"OP.STATUS IN ('"+ Operation.Status.PENDING.name() + "','" + Operation.Status.REPEATED.name() + "') " +
"AND OP.CREATED_TIMESTAMP BETWEEN ? AND ? AND E.STATUS IN ('" + EnrolmentInfo.Status.ACTIVE.name() +
"','" + EnrolmentInfo.Status.UNREACHABLE.name() + "') AND D.DEVICE_TYPE_ID = ? GROUP BY ENROLMENT_ID";
stmt = conn.prepareStatement(sql);
stmt.setLong(1, maxDuration);
stmt.setLong(2, minDuration);
stmt.setInt(3, deviceTypeId);
rs = stmt.executeQuery();
enrolmentOperationMappingList = new ArrayList<>();
while (rs.next()) {
OperationEnrolmentMapping enrolmentOperationMapping = this.getEnrolmentOpMapping(rs);
enrolmentOperationMappingList.add(enrolmentOperationMapping);
}
} catch (SQLException e) {
throw new OperationManagementDAOException("Error occurred while fetching pending operation mappings for " +
"active devices of type '" + deviceTypeId + "'", e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt, rs);
}
return enrolmentOperationMappingList;
}
@Override
public Map<Integer, Long> getLastConnectedTimeForActiveEnrolments(long timeStamp, int deviceTypeId) throws OperationManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
Map<Integer, Long> lastConnectedTimeMap = null;
try {
Connection conn = OperationManagementDAOFactory.getConnection();
//We are specifically looking for operation mappings in 'Pending' & 'Repeated' states. Further we want
//devices to be active at that moment. Hence filtering by 'ACTIVE' & 'UNREACHABLE' device states.
String sql = "SELECT OP.ENROLMENT_ID AS EID, MAX(OP.UPDATED_TIMESTAMP) AS LAST_CONNECTED_TIME FROM " +
"DM_ENROLMENT_OP_MAPPING AS OP INNER JOIN DM_ENROLMENT E ON OP.ENROLMENT_ID = E.ID INNER JOIN " +
"DM_DEVICE D ON E.DEVICE_ID = D.ID WHERE " +
"OP.STATUS = '" + Operation.Status.COMPLETED.name() + "'" +
"AND OP.UPDATED_TIMESTAMP >= ? AND E.STATUS IN ('" + EnrolmentInfo.Status.ACTIVE.name() +
"','" + EnrolmentInfo.Status.UNREACHABLE.name() + "') AND D.DEVICE_TYPE_ID = ? GROUP BY ENROLMENT_ID";
stmt = conn.prepareStatement(sql);
stmt.setLong(1, timeStamp);
stmt.setInt(2, deviceTypeId);
rs = stmt.executeQuery();
lastConnectedTimeMap = new HashMap<>();
while (rs.next()) {
lastConnectedTimeMap.put(rs.getInt("EID"), rs.getLong("LAST_CONNECTED_TIME"));
}
} catch (SQLException e) {
throw new OperationManagementDAOException("Error occurred while fetching last connected time for " +
"active devices of type '" + deviceTypeId + "'", e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt, rs);
}
return lastConnectedTimeMap;
}
private OperationEnrolmentMapping getEnrolmentOpMapping(ResultSet rs) throws SQLException {
OperationEnrolmentMapping enrolmentOperationMapping = new OperationEnrolmentMapping();
enrolmentOperationMapping.setEnrolmentId(rs.getInt("ENROLMENT_ID"));
enrolmentOperationMapping.setDeviceId(rs.getString("DEVICE_IDENTIFIER"));
enrolmentOperationMapping.setTenantId(rs.getInt("TENANT_ID"));
enrolmentOperationMapping.setCreatedTime(rs.getLong("CREATED_TIMESTAMP"));
enrolmentOperationMapping.setDeviceStatus(rs.getString("ENROLMENT_STATUS"));
return enrolmentOperationMapping;
}
} }

@ -351,8 +351,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} }
return false; return false;
} }
DeviceType deviceType = deviceTypeDAO.getDeviceType(device.getType(), tenantId);
device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime()); device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime());
device.getEnrolmentInfo().setStatus(EnrolmentInfo.Status.REMOVED); device.getEnrolmentInfo().setStatus(EnrolmentInfo.Status.REMOVED);
enrollmentDAO.updateEnrollment(device.getId(), device.getEnrolmentInfo(), tenantId); enrollmentDAO.updateEnrollment(device.getId(), device.getEnrolmentInfo(), tenantId);
@ -2052,21 +2050,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return CarbonContext.getThreadLocalCarbonContext().getTenantId(); return CarbonContext.getThreadLocalCarbonContext().getTenantId();
} }
// private int getTenantId(String tenantDomain) throws DeviceManagementException {
// RealmService realmService =
// (RealmService) PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(RealmService.class, null);
// if (realmService == null) {
// throw new IllegalStateException("");
// }
// try {
// return realmService.getTenantManager().getTenantId(tenantDomain);
// } catch (UserStoreException e) {
// throw new DeviceManagementException("");
// }
// }
private DeviceManager getDeviceManager(String deviceType) { private DeviceManager getDeviceManager(String deviceType) {
DeviceManagementService deviceManagementService = DeviceManagementService deviceManagementService =
pluginRepository.getDeviceManagementService(deviceType, this.getTenantId()); pluginRepository.getDeviceManagementService(deviceType, this.getTenantId());
if (deviceManagementService == null) { if (deviceManagementService == null) {

@ -0,0 +1,63 @@
/*
* Copyright (c) 2017, 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.core.status.task;
/**
* This exception class defines the custom exceptions thrown by the DeviceStatusMonitoringTask related components.
*/
public class DeviceStatusTaskException extends Exception {
private static final long serialVersionUID = -31222242646464497L;
private String errorMessage;
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public DeviceStatusTaskException(String msg, Exception nestedEx) {
super(msg, nestedEx);
setErrorMessage(msg);
}
public DeviceStatusTaskException(String message, Throwable cause) {
super(message, cause);
setErrorMessage(message);
}
public DeviceStatusTaskException(String msg) {
super(msg);
setErrorMessage(msg);
}
public DeviceStatusTaskException() {
super();
}
public DeviceStatusTaskException(Throwable cause) {
super(cause);
}
}

@ -0,0 +1,66 @@
/*
* Copyright (c) 2017, 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.core.status.task;
import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
/**
* This interface defines the methods that should be implemented by the management service of
* DeviceStatusMonitoringTask.
*/
public interface DeviceStatusTaskManagerService {
/**
* This method will start the task.
*
* @param deviceType - DeviceType
* @param deviceStatusTaskConfig - DeviceStatusTaskConfig
* @throws DeviceStatusTaskException
*/
void startTask(DeviceType deviceType, DeviceStatusTaskPluginConfig deviceStatusTaskConfig)
throws DeviceStatusTaskException;
/**
* This method will stop the task.
*
* @param deviceType - DeviceType
* @param deviceStatusTaskConfig - DeviceStatusTaskConfig
* @throws DeviceStatusTaskException
*/
void stopTask(DeviceType deviceType, DeviceStatusTaskPluginConfig deviceStatusTaskConfig)
throws DeviceStatusTaskException;
/**
* This will update the task frequency which it runs.
*
* @param deviceType
* @param deviceStatusTaskConfig - DeviceStatusTaskConfig
* @throws DeviceStatusTaskException
*/
void updateTask(DeviceType deviceType, DeviceStatusTaskPluginConfig deviceStatusTaskConfig)
throws DeviceStatusTaskException;
/**
* This will check weather the task is scheduled.
* @param deviceType - Device Type
* @throws DeviceStatusTaskException
*/
boolean isTaskScheduled(DeviceType deviceType) throws DeviceStatusTaskException;
}

@ -0,0 +1,186 @@
/*
* Copyright (c) 2017, 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.core.status.task.impl;
import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationEnrolmentMapping;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskException;
import org.wso2.carbon.ntask.core.Task;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* This implements the Task service which monitors the device activity periodically & update the device-status if
* necessary.
*/
public class DeviceStatusMonitoringTask implements Task {
private static final Log log = LogFactory.getLog(DeviceStatusMonitoringTask.class);
private String deviceType;
private DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig;
private int deviceTypeId = -1;
@Override
public void setProperties(Map<String, String> properties) {
deviceType = properties.get(DeviceStatusTaskManagerServiceImpl.DEVICE_TYPE);
deviceTypeId = Integer.parseInt(properties.get(DeviceStatusTaskManagerServiceImpl.DEVICE_TYPE_ID));
String deviceStatusTaskConfigStr = properties.get(DeviceStatusTaskManagerServiceImpl.DEVICE_STATUS_TASK_CONFIG);
Gson gson = new Gson();
deviceStatusTaskPluginConfig = gson.fromJson(deviceStatusTaskConfigStr, DeviceStatusTaskPluginConfig.class);
}
@Override
public void init() {
}
@Override
public void execute() {
List<OperationEnrolmentMapping> operationEnrolmentMappings = null;
List<EnrolmentInfo> enrolmentInfoTobeUpdated = new ArrayList<>();
Map<Integer, Long> lastActivities = null;
EnrolmentInfo enrolmentInfo;
try {
operationEnrolmentMappings = this.getOperationEnrolmentMappings();
if (operationEnrolmentMappings != null && operationEnrolmentMappings.size() > 0) {
lastActivities = this.getLastDeviceActivities();
}
} catch (DeviceStatusTaskException e) {
log.error("Error occurred while fetching OperationEnrolment mappings of deviceType '" + deviceType + "'", e);
}
for (OperationEnrolmentMapping mapping:operationEnrolmentMappings) {
long lastActivity = -1;
if (lastActivities != null && lastActivities.containsKey(mapping.getEnrolmentId())) {
lastActivity = lastActivities.get(mapping.getEnrolmentId());
}
EnrolmentInfo.Status newStatus = this.determineDeviceStatus(mapping, lastActivity);
if (newStatus != mapping.getDeviceStatus()) {
enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setId(mapping.getEnrolmentId());
enrolmentInfo.setStatus(newStatus);
enrolmentInfoTobeUpdated.add(enrolmentInfo);
}
}
if (enrolmentInfoTobeUpdated.size() > 0) {
try {
this.updateDeviceStatus(enrolmentInfoTobeUpdated);
} catch (DeviceStatusTaskException e) {
log.error("Error occurred while updating non-responsive device-status of devices of type '" + deviceType + "'",e);
}
}
}
private EnrolmentInfo.Status determineDeviceStatus(OperationEnrolmentMapping opMapping, long lastActivityTime) {
long lastPendingOpBefore = (System.currentTimeMillis()/1000) - opMapping.getCreatedTime();
EnrolmentInfo.Status newStatus = null;
if (lastPendingOpBefore >= this.deviceStatusTaskPluginConfig.getIdleTimeToMarkInactive()) {
newStatus = EnrolmentInfo.Status.INACTIVE;
} else if (lastPendingOpBefore >= this.deviceStatusTaskPluginConfig.getIdleTimeToMarkUnreachable()) {
newStatus = EnrolmentInfo.Status.UNREACHABLE;
}
if (lastActivityTime != -1) {
long lastActivityBefore = (System.currentTimeMillis()/1000) - lastActivityTime;
if (lastActivityBefore < lastPendingOpBefore) {
return opMapping.getDeviceStatus();
}
}
return newStatus;
}
private long getMinTimeWindow() {
return (System.currentTimeMillis()/1000) - this.deviceStatusTaskPluginConfig.getIdleTimeToMarkUnreachable();
}
private long getMaxTimeWindow() {
//Need to consider the frequency of the task as well
return (System.currentTimeMillis()/1000) - this.deviceStatusTaskPluginConfig.getIdleTimeToMarkInactive() -
this.deviceStatusTaskPluginConfig.getFrequency();
}
private boolean updateDeviceStatus(List<EnrolmentInfo> enrolmentInfos) throws
DeviceStatusTaskException {
boolean updateStatus;
try {
DeviceManagementDAOFactory.beginTransaction();
updateStatus = DeviceManagementDAOFactory.getEnrollmentDAO().updateEnrollmentStatus(enrolmentInfos);
DeviceManagementDAOFactory.commitTransaction();
} catch (DeviceManagementDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceStatusTaskException("Error occurred while updating enrollment status of devices of type '"
+ deviceType + "'", e);
} catch (TransactionManagementException e) {
throw new DeviceStatusTaskException("Error occurred while initiating a transaction for updating the device " +
"status of type '" + deviceType +"'", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
return updateStatus;
}
private List<OperationEnrolmentMapping> getOperationEnrolmentMappings() throws DeviceStatusTaskException {
List<OperationEnrolmentMapping> operationEnrolmentMappings = null;
try {
OperationManagementDAOFactory.openConnection();
operationEnrolmentMappings = OperationManagementDAOFactory.
getOperationMappingDAO().getFirstPendingOperationMappingsForActiveEnrolments(this.getMinTimeWindow(),
this.getMaxTimeWindow(), this.deviceTypeId);
} catch (SQLException e) {
throw new DeviceStatusTaskException("Error occurred while getting Enrolment operation mappings for " +
"determining device status of deviceType '" + deviceType + "'", e);
} catch (OperationManagementDAOException e) {
throw new DeviceStatusTaskException("Error occurred obtaining a DB connection for fetching " +
"operation-enrolment mappings for status monitoring of deviceType '" + deviceType + "'", e);
} finally {
OperationManagementDAOFactory.closeConnection();
}
return operationEnrolmentMappings;
}
private Map<Integer, Long> getLastDeviceActivities() throws DeviceStatusTaskException {
Map<Integer, Long> lastActivities = null;
try {
OperationManagementDAOFactory.openConnection();
lastActivities = OperationManagementDAOFactory.
getOperationMappingDAO().getLastConnectedTimeForActiveEnrolments(this.getMaxTimeWindow(),
this.deviceTypeId);
} catch (SQLException e) {
throw new DeviceStatusTaskException("Error occurred while getting last activities for " +
"determining device status of deviceType '" + deviceType + "'", e);
} catch (OperationManagementDAOException e) {
throw new DeviceStatusTaskException("Error occurred obtaining a DB connection for fetching " +
"last activities for status monitoring of deviceType '" + deviceType + "'", e);
} finally {
OperationManagementDAOFactory.closeConnection();
}
return lastActivities;
}
}

@ -0,0 +1,163 @@
/*
* Copyright (c) 2017, 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.core.status.task.impl;
import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskException;
import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskManagerService;
import org.wso2.carbon.ntask.common.TaskException;
import org.wso2.carbon.ntask.core.TaskInfo;
import org.wso2.carbon.ntask.core.TaskManager;
import org.wso2.carbon.ntask.core.service.TaskService;
import java.util.HashMap;
import java.util.Map;
/**
* Implementation of DeviceStatusTaskManagerService.
*/
public class DeviceStatusTaskManagerServiceImpl implements DeviceStatusTaskManagerService {
private static final Log log = LogFactory.getLog(DeviceStatusTaskManagerServiceImpl.class);
public static final String DEVICE_STATUS_MONITORING_TASK_TYPE = "DEVICE_STATUS_MONITORING";
static final String DEVICE_TYPE = "DEVICE_TYPE";
static final String DEVICE_TYPE_ID = "DEVICE_TYPE_ID";
static final String DEVICE_STATUS_TASK_CONFIG = "DEVICE_STATUS_TASK_CONFIG";
private static final String TASK_CLASS = DeviceStatusMonitoringTask.class.getName();
@Override
public void startTask(DeviceType deviceType, DeviceStatusTaskPluginConfig deviceStatusTaskConfig)
throws DeviceStatusTaskException {
log.info("Device Status monitoring Task adding for " + deviceType.getName());
try {
TaskService taskService = DeviceManagementDataHolder.getInstance().getTaskService();
taskService.registerTaskType(DEVICE_STATUS_MONITORING_TASK_TYPE);
if (log.isDebugEnabled()) {
log.debug("Device Status monitoring task is started for the device type " + deviceType.getName());
log.debug(
"Device Status monitoring task is at frequency of : " + deviceStatusTaskConfig.getFrequency());
}
TaskManager taskManager = taskService.getTaskManager(DEVICE_STATUS_MONITORING_TASK_TYPE);
TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
//Convert to milli seconds
triggerInfo.setIntervalMillis(deviceStatusTaskConfig.getFrequency()*1000);
triggerInfo.setRepeatCount(-1);
Gson gson = new Gson();
String deviceStatusTaskConfigs = gson.toJson(deviceStatusTaskConfig);
Map<String, String> properties = new HashMap<>();
properties.put(DEVICE_TYPE, deviceType.getName());
properties.put(DEVICE_TYPE_ID, deviceType.getId() + "");
properties.put(DEVICE_STATUS_TASK_CONFIG, deviceStatusTaskConfigs);
String taskName = DEVICE_STATUS_MONITORING_TASK_TYPE + "_" + deviceType.getName() + "_" + deviceType.getId();
if (!taskManager.isTaskScheduled(taskName)) {
TaskInfo taskInfo = new TaskInfo(taskName, TASK_CLASS, properties, triggerInfo);
taskManager.registerTask(taskInfo);
taskManager.rescheduleTask(taskInfo.getName());
} else {
throw new DeviceStatusTaskException(
"Device Status monitoring task is already started for this device-type : " + deviceType.getName());
}
} catch (TaskException e) {
throw new DeviceStatusTaskException("Error occurred while creating the Device Status monitoring task " +
"for device-type : " + deviceType.getName(), e);
}
}
@Override
public void stopTask(DeviceType deviceType, DeviceStatusTaskPluginConfig deviceStatusTaskConfig)
throws DeviceStatusTaskException {
try {
TaskService taskService = DeviceManagementDataHolder.getInstance().getTaskService();
String taskName = DEVICE_STATUS_MONITORING_TASK_TYPE + "_" + deviceType.getName() + "_" + deviceType.getId();
if (taskService.isServerInit()) {
TaskManager taskManager = taskService.getTaskManager(DEVICE_STATUS_MONITORING_TASK_TYPE);
taskManager.deleteTask(taskName);
}
} catch (TaskException e) {
throw new DeviceStatusTaskException("Error occurred while deleting the Device Status monitoring task " +
"for device-type : " + deviceType.getName(), e);
}
}
@Override
public void updateTask(DeviceType deviceType, DeviceStatusTaskPluginConfig deviceStatusTaskConfig)
throws DeviceStatusTaskException {
try {
TaskService taskService = DeviceManagementDataHolder.getInstance().getTaskService();
TaskManager taskManager = taskService.getTaskManager(DEVICE_STATUS_MONITORING_TASK_TYPE);
String taskName = DEVICE_STATUS_MONITORING_TASK_TYPE + "_" + deviceType + "_" + deviceType.getId();
if (taskManager.isTaskScheduled(taskName)) {
taskManager.deleteTask(taskName);
TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
triggerInfo.setIntervalMillis(deviceStatusTaskConfig.getFrequency());
triggerInfo.setRepeatCount(-1);
Map<String, String> properties = new HashMap<>();
properties.put(DEVICE_TYPE, deviceType.getName());
properties.put(DEVICE_TYPE_ID, deviceType.getId() + "");
Gson gson = new Gson();
String deviceStatusTaskConfigs = gson.toJson(deviceStatusTaskConfig);
properties.put(DEVICE_STATUS_TASK_CONFIG, deviceStatusTaskConfigs);
TaskInfo taskInfo = new TaskInfo(taskName, TASK_CLASS, properties, triggerInfo);
taskManager.registerTask(taskInfo);
taskManager.rescheduleTask(taskInfo.getName());
} else {
throw new DeviceStatusTaskException(
"Device details retrieving Device Status monitoring task has not been started for this device-type " +
deviceType.getName() + ". Please start the task first.");
}
} catch (TaskException e) {
throw new DeviceStatusTaskException("Error occurred while updating the Device Status monitoring " +
"task for device-type : " + deviceType.getName(), e);
}
}
@Override
public boolean isTaskScheduled(DeviceType deviceType) throws DeviceStatusTaskException {
String taskName = DEVICE_STATUS_MONITORING_TASK_TYPE + "_" + deviceType.getName() + "_" + deviceType.getId();
TaskService taskService = DeviceManagementDataHolder.getInstance().getTaskService();
TaskManager taskManager;
try {
taskManager = taskService.getTaskManager(DEVICE_STATUS_MONITORING_TASK_TYPE);
return taskManager.isTaskScheduled(taskName);
} catch (TaskException e) {
throw new DeviceStatusTaskException("Error occurred while checking Device Status monitoring task for device-type : " +
deviceType.getName(), e);
}
}
}

@ -45,7 +45,7 @@ public interface DeviceTaskManager {
// String getTaskImplementedClazz() throws DeviceMgtTaskException; // String getTaskImplementedClazz() throws DeviceMgtTaskException;
/** /**
* This method checks wheather task is enabled in config file. * This method checks whether task is enabled in config file.
* @return - return true or false * @return - return true or false
* @throws DeviceMgtTaskException * @throws DeviceMgtTaskException
*/ */
@ -67,7 +67,7 @@ public interface DeviceTaskManager {
// List<String> getValidOperationNames(String deviceType) throws DeviceMgtTaskException; // List<String> getValidOperationNames(String deviceType) throws DeviceMgtTaskException;
/** /**
* This method will check wheather give operation is added by the task. * This method will check whether given operation is added by the task.
* @param opName - Operation name * @param opName - Operation name
* @return - true or false * @return - true or false
* @throws DeviceMgtTaskException * @throws DeviceMgtTaskException

@ -21,7 +21,13 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.GroupPaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
@ -48,7 +54,12 @@ import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File; import java.io.File;
import java.util.*; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
public final class DeviceManagerUtil { public final class DeviceManagerUtil {
@ -136,6 +147,31 @@ public final class DeviceManagerUtil {
return status; return status;
} }
/**
* Get the DeviceType information from Database.
*
* @param typeName device type
* @param tenantId provider tenant Id
* @return DeviceType which contains info about the device-type.
*/
public static DeviceType getDeviceType(String typeName, int tenantId) throws DeviceManagementException {
DeviceType deviceType = null;
try {
DeviceManagementDAOFactory.openConnection();
DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
deviceType = deviceTypeDAO.getDeviceType(typeName, tenantId);
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while fetching the device type '"
+ typeName + "'", e);
} catch (SQLException e) {
throw new DeviceManagementException("Error occurred while fetching the device type '"
+ typeName + "'", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
return deviceType;
}
/** /**
* Un-registers an existing device type from the device management metadata repository. * Un-registers an existing device type from the device management metadata repository.
* *

@ -77,4 +77,7 @@ public class TestDeviceManagementService implements DeviceManagementService {
return null; return null;
} }
public DeviceStatusTaskPluginConfig getDeviceStatusTaskPluginConfig() {
return null;
}
} }

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -23,6 +23,7 @@ var utils = function () {
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var carbon = require("carbon"); var carbon = require("carbon");
var authModule = require("/lib/modules/auth/auth.js").module; var authModule = require("/lib/modules/auth/auth.js").module;
var utility = require('/app/modules/utility.js').utility;
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
var Base64 = Packages.org.apache.commons.codec.binary.Base64; var Base64 = Packages.org.apache.commons.codec.binary.Base64;
@ -297,11 +298,17 @@ var utils = function () {
// returning access token by JWT grant type // returning access token by JWT grant type
var tokenInfo = jwtClient.getAccessToken(encodedClientAppCredentials, var tokenInfo = jwtClient.getAccessToken(encodedClientAppCredentials,
endUsername, scopes); endUsername, scopes);
var tokenData = {}; if (tokenInfo) {
tokenData["accessToken"] = tokenInfo.getAccessToken(); var tokenData = {};
tokenData["refreshToken"] = tokenInfo.getRefreshToken(); tokenData["accessToken"] = tokenInfo.getAccessToken();
tokenData["scopes"] = tokenInfo.getScopes(); tokenData["refreshToken"] = tokenInfo.getRefreshToken();
return tokenData; tokenData["scopes"] = tokenInfo.getScopes();
return tokenData;
} else {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token " +
"by jwt grant type - getTokenPairAndScopesByJWTGrantType()");
return null;
}
} }
}; };
@ -378,5 +385,24 @@ var utils = function () {
} }
}; };
publicMethods["removeClientAppCredentials"] = function (tenantDomain) {
var cachedTenantBasedClientAppCredentialsMap = application.get(constants["CACHED_CREDENTIALS"]);
if (cachedTenantBasedClientAppCredentialsMap) {
if (cachedTenantBasedClientAppCredentialsMap[tenantDomain]) {
delete cachedTenantBasedClientAppCredentialsMap[tenantDomain];
}
}
};
publicMethods["getUniqueBrowserScope"] = function () {
var deviceScope = "device_" + utility.md5(request.getHeader("User-Agent") + "::" + request.getRemoteAddr());
deviceScope = deviceScope + " ";
log.error("device scope");
log.error(deviceScope);
return deviceScope;
};
return publicMethods; return publicMethods;
}(); }();

@ -51,7 +51,7 @@ var handlers = function () {
// tokenPair will include current access token as well as current refresh token // tokenPair will include current access token as well as current refresh token
var arrayOfScopes = devicemgtProps["scopes"]; var arrayOfScopes = devicemgtProps["scopes"];
arrayOfScopes = arrayOfScopes.concat(utility.getDeviceTypesScopesList()); arrayOfScopes = arrayOfScopes.concat(utility.getDeviceTypesScopesList());
var stringOfScopes = ""; var stringOfScopes = tokenUtil.getUniqueBrowserScope();
arrayOfScopes.forEach(function (entry) { arrayOfScopes.forEach(function (entry) {
stringOfScopes += entry + " "; stringOfScopes += entry + " ";
}); });
@ -94,7 +94,7 @@ var handlers = function () {
var tokenData; var tokenData;
var arrayOfScopes = devicemgtProps["scopes"]; var arrayOfScopes = devicemgtProps["scopes"];
arrayOfScopes = arrayOfScopes.concat(utility.getDeviceTypesScopesList()); arrayOfScopes = arrayOfScopes.concat(utility.getDeviceTypesScopesList());
var stringOfScopes = ""; var stringOfScopes = tokenUtil.getUniqueBrowserScope();
arrayOfScopes.forEach(function (entry) { arrayOfScopes.forEach(function (entry) {
stringOfScopes += entry + " "; stringOfScopes += entry + " ";
}); });
@ -139,7 +139,7 @@ var handlers = function () {
var tokenData; var tokenData;
var arrayOfScopes = devicemgtProps["scopes"]; var arrayOfScopes = devicemgtProps["scopes"];
arrayOfScopes = arrayOfScopes.concat(utility.getDeviceTypesScopesList()); arrayOfScopes = arrayOfScopes.concat(utility.getDeviceTypesScopesList());
var stringOfScopes = ""; var stringOfScopes = tokenUtil.getUniqueBrowserScope();
arrayOfScopes.forEach(function (entry) { arrayOfScopes.forEach(function (entry) {
stringOfScopes += entry + " "; stringOfScopes += entry + " ";
}); });
@ -148,8 +148,7 @@ var handlers = function () {
tokenData = tokenUtil. tokenData = tokenUtil.
getTokenPairAndScopesByJWTGrantType(samlToken, encodedClientAppCredentials, stringOfScopes); getTokenPairAndScopesByJWTGrantType(samlToken, encodedClientAppCredentials, stringOfScopes);
if (!tokenData) { if (!tokenData) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up token " + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up token. Error in token " +
"pair by password grant type. Error in token " +
"retrieval - setupTokenPairBySamlGrantType(x, y)"); "retrieval - setupTokenPairBySamlGrantType(x, y)");
} else { } else {
var tokenPair = {}; var tokenPair = {};
@ -180,6 +179,9 @@ var handlers = function () {
if (!newTokenPair) { if (!newTokenPair) {
log.error("{/app/modules/oauth/token-handlers.js} Error in refreshing token pair. " + log.error("{/app/modules/oauth/token-handlers.js} Error in refreshing token pair. " +
"Unable to update session context with new access token pair - refreshTokenPair()"); "Unable to update session context with new access token pair - refreshTokenPair()");
userModule.logout(function () {
response.sendRedirect(devicemgtProps["appContext"] + "login");
});
} else { } else {
session.put(constants["TOKEN_PAIR"], stringify(newTokenPair)); session.put(constants["TOKEN_PAIR"], stringify(newTokenPair));
} }
@ -263,5 +265,18 @@ var handlers = function () {
} }
}; };
publicMethods["removeClientDetails"] = function () {
var user = session.get(constants.USER_SESSION_KEY);
if (!user) {
log.error("User object was not found in the session");
throw constants.ERRORS.USER_NOT_FOUND;
}
tokenUtil.removeClientAppCredentials(user.domain);
session.remove(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"]);
session.remove(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
session.remove(constants["TOKEN_PAIR"]);
session.remove(constants["ALLOWED_SCOPES"]);
};
return publicMethods; return publicMethods;
}(); }();

@ -122,7 +122,12 @@ var invokers = function () {
xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) { xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) {
tokenUtil.refreshTokenPair(); tokenUtil.refreshTokenPair();
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers); return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers);
} else if (privateMethods.isInvalidCredential(xmlHttpRequest.responseText)) { } else if (privateMethods.isInvalidClientCredential(xmlHttpRequest.responseText)) {
log.error("API application has been removed.");
tokenUtil.removeClientDetails();
session.invalidate();
response.sendRedirect(devicemgtProps["appContext"] + "login");
} else if (privateMethods.isInvalidCredential(xmlHttpRequest.responseText)) {
tokenUtil.refreshTokenPair(); tokenUtil.refreshTokenPair();
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers); return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers);
} }
@ -143,11 +148,11 @@ var invokers = function () {
if (responsePayload) { if (responsePayload) {
try { try {
payload = parse(responsePayload); payload = parse(responsePayload);
if (payload["fault"]["code"] == 900901) { if (payload["fault"]["code"] == 900901) {
log.debug("Access token is invalid: " + payload["fault"]["code"]); log.debug("Access token is invalid: " + payload["fault"]["code"]);
log.debug(payload["fault"]["description"]); log.debug(payload["fault"]["description"]);
return true; return true;
} }
} catch (err) { } catch (err) {
// do nothing // do nothing
} }
@ -155,6 +160,27 @@ var invokers = function () {
return false; return false;
}; };
/**
* This method verify whether the client credential is removed/blocked using response payload.
* This is required when using API gateway.
* @param responsePayload response payload.
* return true if it is invalid otherwise false.
*/
privateMethods["isInvalidClientCredential"] =
function (responsePayload) {
if (responsePayload) {
try {
payload = parse(responsePayload);
if (payload["fault"]["message"] == "Invalid Credentials") {
return true;
}
} catch (err) {
// do nothing
}
}
return false;
};
/** /**
* This method add Oauth authentication header to outgoing XML-HTTP Requests if Oauth authentication is enabled. * This method add Oauth authentication header to outgoing XML-HTTP Requests if Oauth authentication is enabled.
* @param httpMethod HTTP request type. * @param httpMethod HTTP request type.

@ -180,5 +180,211 @@ utility = function () {
} }
}; };
publicMethods.md5 = function (s) {
function L(k, d) {
return (k << d) | (k >>> (32 - d))
}
function K(G, k) {
var I, d, F, H, x;
F = (G & 2147483648);
H = (k & 2147483648);
I = (G & 1073741824);
d = (k & 1073741824);
x = (G & 1073741823) + (k & 1073741823);
if (I & d) {
return (x ^ 2147483648 ^ F ^ H)
}
if (I | d) {
if (x & 1073741824) {
return (x ^ 3221225472 ^ F ^ H)
} else {
return (x ^ 1073741824 ^ F ^ H)
}
} else {
return (x ^ F ^ H)
}
}
function r(d, F, k) {
return (d & F) | ((~d) & k)
}
function q(d, F, k) {
return (d & k) | (F & (~k))
}
function p(d, F, k) {
return (d ^ F ^ k)
}
function n(d, F, k) {
return (F ^ (d | (~k)))
}
function u(G, F, aa, Z, k, H, I) {
G = K(G, K(K(r(F, aa, Z), k), I));
return K(L(G, H), F)
}
function f(G, F, aa, Z, k, H, I) {
G = K(G, K(K(q(F, aa, Z), k), I));
return K(L(G, H), F)
}
function D(G, F, aa, Z, k, H, I) {
G = K(G, K(K(p(F, aa, Z), k), I));
return K(L(G, H), F)
}
function t(G, F, aa, Z, k, H, I) {
G = K(G, K(K(n(F, aa, Z), k), I));
return K(L(G, H), F)
}
function e(G) {
var Z;
var F = G.length;
var x = F + 8;
var k = (x - (x % 64)) / 64;
var I = (k + 1) * 16;
var aa = Array(I - 1);
var d = 0;
var H = 0;
while (H < F) {
Z = (H - (H % 4)) / 4;
d = (H % 4) * 8;
aa[Z] = (aa[Z] | (G.charCodeAt(H) << d));
H++
}
Z = (H - (H % 4)) / 4;
d = (H % 4) * 8;
aa[Z] = aa[Z] | (128 << d);
aa[I - 2] = F << 3;
aa[I - 1] = F >>> 29;
return aa
}
function B(x) {
var k = "", F = "", G, d;
for (d = 0; d <= 3; d++) {
G = (x >>> (d * 8)) & 255;
F = "0" + G.toString(16);
k = k + F.substr(F.length - 2, 2)
}
return k
}
function J(k) {
k = k.replace(/rn/g, "n");
var d = "";
for (var F = 0; F < k.length; F++) {
var x = k.charCodeAt(F);
if (x < 128) {
d += String.fromCharCode(x)
} else {
if ((x > 127) && (x < 2048)) {
d += String.fromCharCode((x >> 6) | 192);
d += String.fromCharCode((x & 63) | 128)
} else {
d += String.fromCharCode((x >> 12) | 224);
d += String.fromCharCode(((x >> 6) & 63) | 128);
d += String.fromCharCode((x & 63) | 128)
}
}
}
return d
}
var C = Array();
var P, h, E, v, g, Y, X, W, V;
var S = 7, Q = 12, N = 17, M = 22;
var A = 5, z = 9, y = 14, w = 20;
var o = 4, m = 11, l = 16, j = 23;
var U = 6, T = 10, R = 15, O = 21;
s = J(s);
C = e(s);
Y = 1732584193;
X = 4023233417;
W = 2562383102;
V = 271733878;
for (P = 0; P < C.length; P += 16) {
h = Y;
E = X;
v = W;
g = V;
Y = u(Y, X, W, V, C[P + 0], S, 3614090360);
V = u(V, Y, X, W, C[P + 1], Q, 3905402710);
W = u(W, V, Y, X, C[P + 2], N, 606105819);
X = u(X, W, V, Y, C[P + 3], M, 3250441966);
Y = u(Y, X, W, V, C[P + 4], S, 4118548399);
V = u(V, Y, X, W, C[P + 5], Q, 1200080426);
W = u(W, V, Y, X, C[P + 6], N, 2821735955);
X = u(X, W, V, Y, C[P + 7], M, 4249261313);
Y = u(Y, X, W, V, C[P + 8], S, 1770035416);
V = u(V, Y, X, W, C[P + 9], Q, 2336552879);
W = u(W, V, Y, X, C[P + 10], N, 4294925233);
X = u(X, W, V, Y, C[P + 11], M, 2304563134);
Y = u(Y, X, W, V, C[P + 12], S, 1804603682);
V = u(V, Y, X, W, C[P + 13], Q, 4254626195);
W = u(W, V, Y, X, C[P + 14], N, 2792965006);
X = u(X, W, V, Y, C[P + 15], M, 1236535329);
Y = f(Y, X, W, V, C[P + 1], A, 4129170786);
V = f(V, Y, X, W, C[P + 6], z, 3225465664);
W = f(W, V, Y, X, C[P + 11], y, 643717713);
X = f(X, W, V, Y, C[P + 0], w, 3921069994);
Y = f(Y, X, W, V, C[P + 5], A, 3593408605);
V = f(V, Y, X, W, C[P + 10], z, 38016083);
W = f(W, V, Y, X, C[P + 15], y, 3634488961);
X = f(X, W, V, Y, C[P + 4], w, 3889429448);
Y = f(Y, X, W, V, C[P + 9], A, 568446438);
V = f(V, Y, X, W, C[P + 14], z, 3275163606);
W = f(W, V, Y, X, C[P + 3], y, 4107603335);
X = f(X, W, V, Y, C[P + 8], w, 1163531501);
Y = f(Y, X, W, V, C[P + 13], A, 2850285829);
V = f(V, Y, X, W, C[P + 2], z, 4243563512);
W = f(W, V, Y, X, C[P + 7], y, 1735328473);
X = f(X, W, V, Y, C[P + 12], w, 2368359562);
Y = D(Y, X, W, V, C[P + 5], o, 4294588738);
V = D(V, Y, X, W, C[P + 8], m, 2272392833);
W = D(W, V, Y, X, C[P + 11], l, 1839030562);
X = D(X, W, V, Y, C[P + 14], j, 4259657740);
Y = D(Y, X, W, V, C[P + 1], o, 2763975236);
V = D(V, Y, X, W, C[P + 4], m, 1272893353);
W = D(W, V, Y, X, C[P + 7], l, 4139469664);
X = D(X, W, V, Y, C[P + 10], j, 3200236656);
Y = D(Y, X, W, V, C[P + 13], o, 681279174);
V = D(V, Y, X, W, C[P + 0], m, 3936430074);
W = D(W, V, Y, X, C[P + 3], l, 3572445317);
X = D(X, W, V, Y, C[P + 6], j, 76029189);
Y = D(Y, X, W, V, C[P + 9], o, 3654602809);
V = D(V, Y, X, W, C[P + 12], m, 3873151461);
W = D(W, V, Y, X, C[P + 15], l, 530742520);
X = D(X, W, V, Y, C[P + 2], j, 3299628645);
Y = t(Y, X, W, V, C[P + 0], U, 4096336452);
V = t(V, Y, X, W, C[P + 7], T, 1126891415);
W = t(W, V, Y, X, C[P + 14], R, 2878612391);
X = t(X, W, V, Y, C[P + 5], O, 4237533241);
Y = t(Y, X, W, V, C[P + 12], U, 1700485571);
V = t(V, Y, X, W, C[P + 3], T, 2399980690);
W = t(W, V, Y, X, C[P + 10], R, 4293915773);
X = t(X, W, V, Y, C[P + 1], O, 2240044497);
Y = t(Y, X, W, V, C[P + 8], U, 1873313359);
V = t(V, Y, X, W, C[P + 15], T, 4264355552);
W = t(W, V, Y, X, C[P + 6], R, 2734768916);
X = t(X, W, V, Y, C[P + 13], O, 1309151649);
Y = t(Y, X, W, V, C[P + 4], U, 4149444226);
V = t(V, Y, X, W, C[P + 11], T, 3174756917);
W = t(W, V, Y, X, C[P + 2], R, 718787259);
X = t(X, W, V, Y, C[P + 9], O, 3951481745);
Y = K(Y, h);
X = K(X, E);
W = K(W, v);
V = K(V, g)
}
var i = B(Y) + B(X) + B(W) + B(V);
return i.toLowerCase()
};
return publicMethods; return publicMethods;
}(); }();

@ -23,7 +23,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>email-sender</artifactId> <artifactId>email-sender</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.registration</artifactId> <artifactId>org.wso2.carbon.dynamic.client.registration</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client registration service</name> <name>WSO2 Carbon - Dynamic client registration service</name>
<description>WSO2 Carbon - Dynamic Client Registration Service</description> <description>WSO2 Carbon - Dynamic Client Registration Service</description>

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.web.app.registration</artifactId> <artifactId>org.wso2.carbon.dynamic.client.web.app.registration</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client web app registration</name> <name>WSO2 Carbon - Dynamic client web app registration</name>
<description>WSO2 Carbon - Dynamic Client Web-app Registration Service</description> <description>WSO2 Carbon - Dynamic Client Web-app Registration Service</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Dynamic client registration</name> <name>WSO2 Carbon - Dynamic client registration</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,13 +22,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId> <artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - OAuth Extensions</name> <name>WSO2 Carbon - OAuth Extensions</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId> <artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name> <name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description> <description>WSO2 Carbon - Policy Decision Point</description>

@ -3,14 +3,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.decision.point</artifactId> <artifactId>org.wso2.carbon.policy.decision.point</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name> <name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description> <description>WSO2 Carbon - Policy Decision Point</description>

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.information.point</artifactId> <artifactId>org.wso2.carbon.policy.information.point</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Information Point</name> <name>WSO2 Carbon - Policy Information Point</name>
<description>WSO2 Carbon - Policy Information Point</description> <description>WSO2 Carbon - Policy Information Point</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId> <artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Common</name> <name>WSO2 Carbon - Policy Management Common</name>
<description>WSO2 Carbon - Policy Management Common</description> <description>WSO2 Carbon - Policy Management Common</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId> <artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Core</name> <name>WSO2 Carbon - Policy Management Core</name>
<description>WSO2 Carbon - Policy Management Core</description> <description>WSO2 Carbon - Policy Management Core</description>

@ -59,8 +59,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
private static final Log log = LogFactory.getLog(MonitoringManagerImpl.class); private static final Log log = LogFactory.getLog(MonitoringManagerImpl.class);
private static final String OPERATION_MONITOR = "MONITOR"; private static final String OPERATION_MONITOR = "MONITOR";
private static final String OPERATION_INFO = "DEVICE_INFO";
private static final String OPERATION_APP_LIST = "APPLICATION_LIST";
public MonitoringManagerImpl() { public MonitoringManagerImpl() {
this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO(); this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO();
@ -273,9 +272,6 @@ public class MonitoringManagerImpl implements MonitoringManager {
Map<Integer, Device> deviceIdsToAddOperation = new HashMap<>(); Map<Integer, Device> deviceIdsToAddOperation = new HashMap<>();
Map<Integer, Device> deviceIdsWithExistingOperation = new HashMap<>(); Map<Integer, Device> deviceIdsWithExistingOperation = new HashMap<>();
Map<Integer, Device> inactiveDeviceIds = new HashMap<>();
Map<Integer, Device> devicesToMarkUnreachable = new HashMap<>();
//Map<Integer, Integer> firstTimeDeviceIdsWithPolicyIds = new HashMap<>();
List<PolicyDeviceWrapper> firstTimeDevices = new ArrayList<>(); List<PolicyDeviceWrapper> firstTimeDevices = new ArrayList<>();
@ -293,14 +289,6 @@ public class MonitoringManagerImpl implements MonitoringManager {
} else { } else {
deviceIdsWithExistingOperation.put(complianceData.getDeviceId(), deviceIdsWithExistingOperation.put(complianceData.getDeviceId(),
deviceIds.get(complianceData.getDeviceId())); deviceIds.get(complianceData.getDeviceId()));
if (complianceData.getAttempts() >= policyConfiguration.getMinRetriesToMarkUnreachable()) {
devicesToMarkUnreachable.put(complianceData.getDeviceId(),
deviceIds.get(complianceData.getDeviceId()));
}
}
if (complianceData.getAttempts() >= policyConfiguration.getMinRetriesToMarkInactive()) {
inactiveDeviceIds.put(complianceData.getDeviceId(),
deviceIds.get(complianceData.getDeviceId()));
} }
} }
} }
@ -360,22 +348,6 @@ public class MonitoringManagerImpl implements MonitoringManager {
throw new PolicyComplianceException("Error occurred while adding monitoring operation to devices", e); throw new PolicyComplianceException("Error occurred while adding monitoring operation to devices", e);
} }
} }
// TODO : This should be uncommented, this is to mark the device as unreachable, But given the current
// implementation we are not able to do so.
if (!devicesToMarkUnreachable.isEmpty()) {
ComplianceDecisionPoint decisionPoint = new ComplianceDecisionPointImpl();
decisionPoint.setDevicesAsUnreachable(this.getDeviceIdentifiersFromDevices(
new ArrayList<>(devicesToMarkUnreachable.values())));
}
if (!inactiveDeviceIds.isEmpty()) {
ComplianceDecisionPoint decisionPoint = new ComplianceDecisionPointImpl();
decisionPoint.setDevicesAsInactive(this.getDeviceIdentifiersFromDevices(
new ArrayList<>(inactiveDeviceIds.values())));
}
} }
@Override @Override

@ -23,13 +23,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Policy Management Component</name> <name>WSO2 Carbon - Policy Management Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId> <artifactId>webapp-authenticator-framework</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId> <artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Web Application Authenticator Framework Bundle</name> <name>WSO2 Carbon - Web Application Authenticator Framework Bundle</name>
<description>WSO2 Carbon - Web Application Authenticator Framework Bundle</description> <description>WSO2 Carbon - Web Application Authenticator Framework Bundle</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId> <artifactId>webapp-authenticator-framework</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Webapp Authenticator Framework</name> <name>WSO2 Carbon - Webapp Authenticator Framework</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.application.extension.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Application Extension Feature</name> <name>WSO2 Carbon - API Management Application Extension Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains an implementation of a api application registration, which takes care of subscription <description>This feature contains an implementation of a api application registration, which takes care of subscription

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handler.server.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.handler.server.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management - APIM handler Server Feature</name> <name>WSO2 Carbon - Device Management - APIM handler Server Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains the handler for the api authentications <description>This feature contains the handler for the api authentications

@ -21,13 +21,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.client.feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - APIM Integration Client Feature</name> <name>WSO2 Carbon - APIM Integration Client Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.webapp.publisher.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Webapp Publisher Feature</name> <name>WSO2 Carbon - API Management Webapp Publisher Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing <description>This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Feature</name> <name>WSO2 Carbon - API Management Extensions Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.server.feature</artifactId> <artifactId>org.wso2.carbon.certificate.mgt.server.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - Certificate Management Server Feature</name> <name>WSO2 Carbon - Certificate Management Server Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains the core bundles required for back-end Certificate Management functionality <description>This feature contains the core bundles required for back-end Certificate Management functionality

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Certificate Management Feature</name> <name>WSO2 Carbon - Certificate Management Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - Device Type Deployer Feature</name> <name>WSO2 Carbon - Device Type Deployer Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>WSO2 Carbon - Device Type Deployer Feature</description> <description>WSO2 Carbon - Device Type Deployer Feature</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - FCM Based Push Notification Provider Feature</name> <name>WSO2 Carbon - FCM Based Push Notification Provider Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description> <description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - MQTT Based Push Notification Provider Feature</name> <name>WSO2 Carbon - MQTT Based Push Notification Provider Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description> <description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - XMPP Based Push Notification Provider Feature</name> <name>WSO2 Carbon - XMPP Based Push Notification Provider Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>WSO2 Carbon - XMPP Based Push Notification Provider Feature</description> <description>WSO2 Carbon - XMPP Based Push Notification Provider Feature</description>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -3,13 +3,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.analytics.dashboard.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.analytics.dashboard.feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Device Management Dashboard Analytics Feature</name> <name>WSO2 Carbon - Device Management Dashboard Analytics Feature</name>
<description>WSO2 Carbon - Device Management Dashboard Analytics Feature</description> <description>WSO2 Carbon - Device Management Dashboard Analytics Feature</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management Server Feature</name> <name>WSO2 Carbon - Device Management Server Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains bundles related to device analytics data publisher</description> <description>This feature contains bundles related to device analytics data publisher</description>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -4,14 +4,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management Extensions Feature</name> <name>WSO2 Carbon - Device Management Extensions Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains common extensions used by key device management functionalities <description>This feature contains common extensions used by key device management functionalities

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.server.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.server.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management Server Feature</name> <name>WSO2 Carbon - Device Management Server Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains the core bundles required for Back-end Device Management functionality <description>This feature contains the core bundles required for Back-end Device Management functionality

@ -66,5 +66,8 @@
<ActivityListPageSize>20</ActivityListPageSize> <ActivityListPageSize>20</ActivityListPageSize>
<OperationListPageSize>20</OperationListPageSize> <OperationListPageSize>20</OperationListPageSize>
</PaginationConfiguration> </PaginationConfiguration>
<DeviceStatusTaskConfig>
<Enable>true</Enable>
</DeviceStatusTaskConfig>
</DeviceMgtConfiguration> </DeviceMgtConfiguration>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -23,14 +23,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-registration-feature</artifactId> <artifactId>dynamic-client-registration-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.registration.server.feature</artifactId> <artifactId>org.wso2.carbon.dynamic.client.registration.server.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - Dynamic Client Registration Server Feature</name> <name>WSO2 Carbon - Dynamic Client Registration Server Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains dynamic client registration features</description> <description>This feature contains dynamic client registration features</description>

@ -23,14 +23,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-registration-feature</artifactId> <artifactId>dynamic-client-registration-feature</artifactId>
<version>2.0.70-SNAPSHOT</version> <version>2.0.72-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Dynamic Client Registration Feature</name> <name>WSO2 Carbon - Dynamic Client Registration Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save