diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index bad909f4878..ecb5c435526 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - API Management Annotations WSO2 Carbon - API Management Custom Annotation Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index cf9d783de09..1a951226ec3 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,12 +21,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT org.wso2.carbon.apimgt.application.extension.api war WSO2 Carbon - API Application Management API diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 62b2dce65f7..bee95700eed 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,12 +22,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT org.wso2.carbon.apimgt.application.extension bundle WSO2 Carbon - API Application Management diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml index 2ab2c9afcc6..a219d50173e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml @@ -21,13 +21,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handlers - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - API Security Handler Component WSO2 Carbon - API Management Security Handler Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index f5f590f873f..faaeec3fecd 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -13,13 +13,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml index 696c39dfc59..50de0206f26 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml @@ -13,13 +13,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.generated.client - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - API Management Integration Generated Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index b2eccb801ec..de6bca2ef15 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - API Management Webapp Publisher WSO2 Carbon - API Management Webapp Publisher diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index f8d1708d4e0..ab32ee8afe9 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - API Management Extensions Component http://wso2.org diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index 25f70de58cb..0dd8d73e3bf 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index 4fb4d649899..91f37cd5a35 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index 83c7b5a89e2..0d23d871db7 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -21,13 +21,13 @@ org.wso2.carbon.devicemgt certificate-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - Certificate Management Core WSO2 Carbon - Certificate Management Core diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 46a6340da44..4c04d1b26c4 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Certificate Management Component http://wso2.org diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index c30be78776c..0453f346065 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml index 47434b8ea56..7f6e86b1165 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 8264037f673..a3167b5db8b 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 0b0b0a401ef..8b4db4831ee 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 950a6a55ce7..cbe62f5659a 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index a1fa842e76a..081983603c4 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml index bba5bfce052..821e60a06fa 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt device-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index 1147f2fe3c2..e60ba6cc8dc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 11cf483dc87..39f42e330a1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/EventBeanWrapper.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/EventBeanWrapper.java deleted file mode 100644 index ef90991655f..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/EventBeanWrapper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016, 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.jaxrs.beans; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import javax.validation.constraints.Size; -import java.util.Map; - -/** - * This class is used to wrap the events which receive from the agent application. - */ -@ApiModel(value = "EventBeanWrapper", - description = "agent's event related Information.") -public class EventBeanWrapper { - - @ApiModelProperty(name = "payloadData", value = "Event payload payload.", required = true) - Map payloadData; - - public Map getPayloadData() { - return payloadData; - } - - public void setPayloadData(Map payloadData) { - this.payloadData = payloadData; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceAgentService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceAgentService.java index 3f66cd7e517..a490197960f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceAgentService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceAgentService.java @@ -34,7 +34,6 @@ import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; -import org.wso2.carbon.device.mgt.jaxrs.beans.EventBeanWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.OperationList; import org.wso2.carbon.device.mgt.jaxrs.util.Constants; @@ -50,6 +49,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.util.Map; @SwaggerDefinition( info = @Info( @@ -296,10 +296,10 @@ public interface DeviceAgentService { }) Response publishEvents( @ApiParam( - name = "eventBeanWrapper", + name = "payloadData", value = "Information of the agent event to be published on DAS.") @Valid - EventBeanWrapper eventBeanWrapper, + Map payloadData, @ApiParam( name = "type", value = "name of the device type") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java index c8c583fd521..3bd3f853297 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java @@ -33,7 +33,6 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; -import org.wso2.carbon.device.mgt.jaxrs.beans.EventBeanWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.OperationList; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Attribute; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AttributeType; @@ -203,12 +202,13 @@ public class DeviceAgentServiceImpl implements DeviceAgentService { @POST @Path("/events/publish/{type}/{deviceId}") @Override - public Response publishEvents(@Valid EventBeanWrapper eventBeanWrapper, @PathParam("type") String type + public Response publishEvents(@Valid Map payload, @PathParam("type") String type , @PathParam("deviceId") String deviceId) { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + EventStreamAdminServiceStub eventStreamAdminServiceStub = null; try { - if (eventBeanWrapper == null) { + if (payload == null) { String msg = "invalid payload structure"; return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } else { @@ -224,8 +224,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService { EventAttributeList eventAttributeList = DeviceMgtAPIUtils.getDynamicEventCache().get(type); if (eventAttributeList == null) { String streamName = DeviceMgtAPIUtils.getStreamDefinition(type, tenantDomain); - EventStreamAdminServiceStub eventStreamAdminServiceStub = - DeviceMgtAPIUtils.getEventStreamAdminServiceStub(); + eventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub(); EventStreamDefinitionDto eventStreamDefinitionDto = eventStreamAdminServiceStub.getStreamDefinitionDto( streamName + ":" + Constants.DEFAULT_STREAM_VERSION); if (eventStreamDefinitionDto == null) { @@ -238,7 +237,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService { , AttributeType.valueOf(eventStreamAttributeDto.getAttributeType().toUpperCase()))); } - if (eventBeanWrapper.getPayloadData().size() != attributes.size()) { + if (payload.size() != attributes.size()) { String msg = "payload does not match the stream definition"; return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } @@ -247,7 +246,6 @@ public class DeviceAgentServiceImpl implements DeviceAgentService { DeviceMgtAPIUtils.getDynamicEventCache().put(type, eventAttributeList); } } - Map payload = eventBeanWrapper.getPayloadData(); int i = 0; Object[] payloadData = new Object[eventAttributeList.getList().size()]; for (Attribute attribute : eventAttributeList.getList()) { @@ -260,7 +258,6 @@ public class DeviceAgentServiceImpl implements DeviceAgentService { } i++; } - eventBeanWrapper.setPayloadData(payload); if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()) @@ -291,7 +288,14 @@ public class DeviceAgentServiceImpl implements DeviceAgentService { } catch (UserStoreException e) { log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - + } finally { + if (eventStreamAdminServiceStub != null) { + try { + eventStreamAdminServiceStub.cleanup(); + } catch (AxisFault axisFault) { + log.warn("Failed to clean eventStreamAdminServiceStub"); + } + } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java index 5f412675098..dacca0749e1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java @@ -596,7 +596,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe try { stub.cleanup(); } catch (AxisFault axisFault) { - // do nothing + log.warn("Failed to clean the stub " + stub.getClass()); } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index dfe0432a85f..b025e3eee12 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -629,7 +629,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @Path("/{type}/operations") public Response addOperation(@PathParam("type") String type, @Valid OperationRequest operationRequest) { try { - if (operationRequest == null || operationRequest.getDeviceIdentifiers() == null) { + if (operationRequest == null || operationRequest.getDeviceIdentifiers() == null + || operationRequest.getOperation() == null) { String errorMessage = "Device identifier list is empty"; log.error(errorMessage); return Response.status(Response.Status.BAD_REQUEST).build(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index 3258583fbe3..d6bdd402128 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceStatusTaskPluginConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceStatusTaskPluginConfig.java new file mode 100644 index 00000000000..9a4a4e36ddd --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceStatusTaskPluginConfig.java @@ -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; + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java index 1f3c134f592..8cbe0492458 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java @@ -50,4 +50,6 @@ public interface DeviceManagementService { PullNotificationSubscriber getPullNotificationSubscriber(); + DeviceStatusTaskPluginConfig getDeviceStatusTaskPluginConfig(); + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 75f2d059bfb..de8588da8fb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java index 3d4288e7e33..56d26f0ead5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java @@ -27,6 +27,7 @@ import org.wso2.carbon.device.mgt.core.dto.DeviceManagementServiceHolder; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; 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.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; @@ -34,6 +35,8 @@ import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvi import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeDefinitionProvider; import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; +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.DeviceManagementServiceComponent; @@ -41,6 +44,9 @@ 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.operation.mgt.OperationManagerImpl; 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.DeviceTaskManagerService; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; @@ -53,7 +59,7 @@ import java.util.Map; public class DeviceManagementPluginRepository implements DeviceManagerStartupListener { private Map providers; - private boolean isInited; + private boolean isInitiated; private static final Log log = LogFactory.getLog(DeviceManagementPluginRepository.class); private OperationManagerRepository operationManagerRepository; private static final long DEFAULT_UPDATE_TIMESTAMP = 900000L; @@ -66,48 +72,47 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis public void addDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException { String deviceType = provider.getType(); - ProvisioningConfig provisioningConfig = provider.getProvisioningConfig(); String tenantDomain = provisioningConfig.getProviderTenantDomain(); + DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); boolean isSharedWithAllTenants = provisioningConfig.isSharedWithAllTenants(); int tenantId = DeviceManagerUtil.getTenantId(tenantDomain); if (tenantId == -1) { throw new DeviceManagementException("No tenant available for tenant domain " + tenantDomain); } synchronized (providers) { - try { - if (isInited) { - /* Initializing Device Management Service Provider */ - provider.init(); - DeviceTypeMetaDefinition deviceTypeDefinition = null; - if (provider instanceof DeviceTypeDefinitionProvider) { - DeviceTypeServiceIdentifier deviceTypeIdentifier = new DeviceTypeServiceIdentifier( - provider.getType()); - DeviceManagementServiceHolder existingProvider = providers.get(deviceTypeIdentifier); - deviceTypeDefinition = ((DeviceTypeDefinitionProvider) provider).getDeviceTypeMeta(); - if (existingProvider != null && !(existingProvider.getDeviceManagementService() - instanceof DeviceTypeDefinitionProvider)) { - throw new DeviceManagementException("Definition of device type " + provider.getType() - + " is already available through sharing."); - } + if (isInitiated) { + /* Initializing Device Management Service Provider */ + provider.init(); + DeviceTypeMetaDefinition deviceTypeDefinition = null; + if (provider instanceof DeviceTypeDefinitionProvider) { + DeviceTypeServiceIdentifier deviceTypeIdentifier = new DeviceTypeServiceIdentifier( + provider.getType()); + DeviceManagementServiceHolder existingProvider = providers.get(deviceTypeIdentifier); + deviceTypeDefinition = ((DeviceTypeDefinitionProvider) provider).getDeviceTypeMeta(); + if (existingProvider != null && !(existingProvider.getDeviceManagementService() + instanceof DeviceTypeDefinitionProvider)) { + throw new DeviceManagementException("Definition of device type " + provider.getType() + + " is already available through sharing."); + } - deviceTypeIdentifier = new DeviceTypeServiceIdentifier(provider.getType(), tenantId); - existingProvider = providers.get(deviceTypeIdentifier); - if (existingProvider != null) { - removeDeviceManagementProvider(provider); - } + deviceTypeIdentifier = new DeviceTypeServiceIdentifier(provider.getType(), tenantId); + existingProvider = providers.get(deviceTypeIdentifier); + if (existingProvider != null) { + removeDeviceManagementProvider(provider); } + } - DeviceManagerUtil.registerDeviceType(deviceType, tenantId, isSharedWithAllTenants, deviceTypeDefinition); - DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(deviceType, - provider.getDeviceManager() - .requireDeviceAuthorization()); - registerPushNotificationStrategy(provider); - registerMonitoringTask(provider); + DeviceManagerUtil.registerDeviceType(deviceType, tenantId, isSharedWithAllTenants, deviceTypeDefinition); + DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(deviceType, + provider.getDeviceManager() + .requireDeviceAuthorization()); + registerPushNotificationStrategy(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); } DeviceManagementServiceHolder deviceManagementServiceHolder = new DeviceManagementServiceHolder(provider); if (isSharedWithAllTenants) { @@ -123,6 +128,8 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis public void removeDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException { String deviceTypeName = provider.getType(); + DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance() + .getDeviceManagementConfig(); DeviceTypeServiceIdentifier deviceTypeIdentifier; ProvisioningConfig provisioningConfig = provider.getProvisioningConfig(); if (provisioningConfig.isSharedWithAllTenants()) { @@ -138,6 +145,11 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis providers.remove(deviceTypeIdentifier); unregisterPushNotificationStrategy(deviceTypeIdentifier); unregisterMonitoringTask(provider); + if (deviceManagementConfig != null && deviceManagementConfig.getDeviceStatusTaskConfig().isEnabled()) { + DeviceType deviceTypeObj = DeviceManagerUtil.getDeviceType(deviceTypeIdentifier.getDeviceType(), + deviceTypeIdentifier.getTenantId()); + unregisterDeviceStatusMonitoringTask(deviceTypeObj, provider); + } } private void unregisterPushNotificationStrategy(DeviceTypeServiceIdentifier deviceTypeIdentifier) { @@ -234,30 +246,30 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( deviceManagementService.getProvisioningConfig().getProviderTenantDomain(), true); try { - boolean isSharedWithAllTenants = deviceManagementService.getProvisioningConfig().isSharedWithAllTenants(); - DeviceTypeServiceIdentifier deviceTypeIdentifier; - if (isSharedWithAllTenants) { - deviceTypeIdentifier = new DeviceTypeServiceIdentifier(deviceManagementService.getType()); - } else { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - deviceTypeIdentifier = new DeviceTypeServiceIdentifier(deviceManagementService.getType(), tenantId); - } + boolean isSharedWithAllTenants = deviceManagementService.getProvisioningConfig().isSharedWithAllTenants(); + DeviceTypeServiceIdentifier deviceTypeIdentifier; + if (isSharedWithAllTenants) { + deviceTypeIdentifier = new DeviceTypeServiceIdentifier(deviceManagementService.getType()); + } else { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + deviceTypeIdentifier = new DeviceTypeServiceIdentifier(deviceManagementService.getType(), tenantId); + } - if (pushNoteConfig != null) { - PushNotificationProvider provider = DeviceManagementDataHolder.getInstance() - .getPushNotificationProviderRepository().getProvider(pushNoteConfig.getType()); - if (provider == null) { - throw new DeviceManagementException( - "No registered push notification provider found for the type: '" + - pushNoteConfig.getType() + "'."); + if (pushNoteConfig != null) { + PushNotificationProvider provider = DeviceManagementDataHolder.getInstance() + .getPushNotificationProviderRepository().getProvider(pushNoteConfig.getType()); + if (provider == null) { + throw new DeviceManagementException( + "No registered push notification provider found for the type: '" + + 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 { PrivilegedCarbonContext.endTenantFlow(); } @@ -266,12 +278,10 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis private void registerMonitoringTask(DeviceManagementService deviceManagementService) throws DeviceManagementException { try { - DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance() - .getDeviceTaskManagerService(); - - OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementService - .getOperationMonitoringConfig(); - + DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance(). + getDeviceTaskManagerService(); + OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementService. + getOperationMonitoringConfig(); if (operationMonitoringTaskConfig != null && operationMonitoringTaskConfig.isEnabled()) { if (deviceTaskManagerService == null) { @@ -291,10 +301,10 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis private void unregisterMonitoringTask(DeviceManagementService deviceManagementService) throws DeviceManagementException { try { - DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance() - .getDeviceTaskManagerService(); - OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementService - .getOperationMonitoringConfig(); + DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance(). + getDeviceTaskManagerService(); + OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementService. + getOperationMonitoringConfig(); if (operationMonitoringTaskConfig != null) { deviceTaskManagerService.stopTask(deviceManagementService.getType(), deviceManagementService.getOperationMonitoringConfig()); @@ -305,6 +315,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) { //Priority need to be given to the tenant before public. DeviceTypeServiceIdentifier deviceTypeIdentifier = new DeviceTypeServiceIdentifier(deviceType, tenantId); @@ -345,22 +391,23 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis , provisioningConfig.isSharedWithAllTenants(), deviceTypeDefinition); registerPushNotificationStrategy(provider); registerMonitoringTask(provider); + //TODO: //This is a temporory fix. //windows and IOS cannot resolve user info by extracting certs //until fix that, use following variable to enable and disable of checking user authorization. DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(provider.getType(), - provider.getDeviceManager() - .requireDeviceAuthorization()); + provider.getDeviceManager() + .requireDeviceAuthorization()); } catch (Throwable e) { /* 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 */ log.error("Error occurred while initializing device management provider '" + - provider.getType() + "'", e); + provider.getType() + "'", e); } } - this.isInited = true; + this.isInitiated = true; } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java index 331ac3ea1a5..b84ee539a36 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java @@ -22,6 +22,7 @@ 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.pull.notification.PullNotificationConfiguration; 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 javax.xml.bind.annotation.XmlElement; @@ -41,6 +42,7 @@ public final class DeviceManagementConfig { private PaginationConfiguration paginationConfiguration; private PushNotificationConfiguration pushNotificationConfiguration; private PullNotificationConfiguration pullNotificationConfiguration; + private DeviceStatusTaskConfig deviceStatusTaskConfig; @XmlElement(name = "ManagementRepository", required = true) @@ -106,5 +108,14 @@ public final class DeviceManagementConfig { public void setPullNotificationConfiguration(PullNotificationConfiguration pullNotificationConfiguration) { this.pullNotificationConfiguration = pullNotificationConfiguration; } + + @XmlElement(name = "DeviceStatusTaskConfig", required = true) + public DeviceStatusTaskConfig getDeviceStatusTaskConfig() { + return deviceStatusTaskConfig; + } + + public void setDeviceStatusTaskConfig(DeviceStatusTaskConfig deviceStatusTaskConfig) { + this.deviceStatusTaskConfig = deviceStatusTaskConfig; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/status/task/DeviceStatusTaskConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/status/task/DeviceStatusTaskConfig.java new file mode 100644 index 00000000000..03cf0643a1c --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/status/task/DeviceStatusTaskConfig.java @@ -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; + } + +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/EnrollmentDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/EnrollmentDAO.java index d59d5733f4e..28095433684 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/EnrollmentDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/EnrollmentDAO.java @@ -32,11 +32,15 @@ public interface EnrollmentDAO { int updateEnrollment(EnrolmentInfo enrolmentInfo) throws DeviceManagementDAOException; + boolean updateEnrollmentStatus(List enrolmentInfos) throws DeviceManagementDAOException; + int removeEnrollment(int deviceId, String currentOwner, int tenantId) throws DeviceManagementDAOException; boolean setStatus(int enrolmentId, String currentOwner, Status status, int tenantId) throws DeviceManagementDAOException; + boolean setStatus(int enrolmentId, Status status, int tenantId) throws DeviceManagementDAOException; + Status getStatus(int deviceId, String currentOwner, int tenantId) throws DeviceManagementDAOException; EnrolmentInfo getEnrollment(int deviceId, String currentUser, int tenantId) throws DeviceManagementDAOException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java index 9e8bd4680a2..bba8424dc03 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java @@ -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.EnrollmentDAO; 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.util.ArrayList; @@ -115,6 +116,42 @@ public class EnrollmentDAOImpl implements EnrollmentDAO { } } + @Override + public boolean updateEnrollmentStatus(List 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 public int removeEnrollment(int deviceId, String currentOwner, @@ -166,6 +203,26 @@ public class EnrollmentDAOImpl implements EnrollmentDAO { 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 public EnrolmentInfo.Status getStatus(int deviceId, String currentOwner, int tenantId) throws DeviceManagementDAOException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index f7e8e0a177d..6e61a2ceb37 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.core.internal; +import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig; 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.authorization.DeviceAccessAuthorizationService; @@ -25,9 +26,12 @@ 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.core.app.mgt.config.AppManagementConfig; 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.dto.DeviceTypeServiceIdentifier; 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.GroupManagementProviderService; +import org.wso2.carbon.device.mgt.core.status.task.DeviceStatusTaskManagerService; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService; import org.wso2.carbon.email.sender.core.service.EmailSenderService; 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.utils.ConfigurationContextService; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -59,6 +64,9 @@ public class DeviceManagementDataHolder { private EmailSenderService emailSenderService; private PushNotificationProviderRepository pushNotificationProviderRepository; private DeviceTaskManagerService deviceTaskManagerService; + private DeviceStatusTaskManagerService deviceStatusTaskManagerService; + private Map deviceStatusTaskPluginConfigs = Collections.synchronizedMap( + new HashMap()); private Map map = new HashMap<>(); @@ -191,7 +199,6 @@ public class DeviceManagementDataHolder { this.deviceAccessAuthorizationService = deviceAccessAuthorizationService; } - public TaskService getTaskService() { return taskService; } @@ -224,4 +231,28 @@ public class DeviceManagementDataHolder { public void setDeviceTaskManagerService(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(DeviceTypeServiceIdentifier deviceType) { + return this.deviceStatusTaskPluginConfigs.get(deviceType); + } + + public Map getDeviceStatusTaskPluginConfigs() { + return this.deviceStatusTaskPluginConfigs; + } + + public void removeDeviceStatusTaskPluginConfig(DeviceType deviceType) { + this.deviceStatusTaskPluginConfigs.remove(deviceType); + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java index 344d567f0f8..ae39c831097 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java @@ -22,11 +22,18 @@ package org.wso2.carbon.device.mgt.core.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; 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.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.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.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.DeviceTaskManagerService; import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl; @@ -47,24 +54,21 @@ import java.util.Map; public class DeviceTaskManagerServiceComponent { - private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class); - - + private static Log log = LogFactory.getLog(DeviceTaskManagerServiceComponent.class); @SuppressWarnings("unused") protected void activate(ComponentContext componentContext) { try { 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); + //Start the DeviceStatusMonitoringTask for registered DeviceTypes + DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance(). + getDeviceManagementConfig(); + if (deviceManagementConfig != null && deviceManagementConfig.getDeviceStatusTaskConfig().isEnabled()) { + startDeviceStatusMonitoringTask(); + } componentContext.getBundleContext().registerService(DeviceInformationManager.class, new DeviceInformationManagerImpl(), null); @@ -72,29 +76,38 @@ public class DeviceTaskManagerServiceComponent { componentContext.getBundleContext().registerService(SearchManagerService.class, new SearchManagerServiceImpl(), null); } 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) throws DeviceMgtTaskException { - DeviceTaskManagerService deviceTaskManagerService = new DeviceTaskManagerServiceImpl(); - DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(deviceTaskManagerService); - componentContext.getBundleContext().registerService(DeviceTaskManagerService.class, deviceTaskManagerService, null); - Map deviceConfigMap = DeviceMonitoringOperationDataHolder .getInstance().getOperationMonitoringConfigFromMap(); - for (String platformType : new ArrayList<>(deviceConfigMap.keySet())) { deviceTaskManagerService.startTask(platformType, deviceConfigMap.get(platformType)); deviceConfigMap.remove(platformType); } } + private void startDeviceStatusMonitoringTask() { + DeviceStatusTaskManagerService deviceStatusTaskManagerService = new DeviceStatusTaskManagerServiceImpl(); + Map 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") protected void deactivate(ComponentContext componentContext) { try { @@ -105,7 +118,6 @@ public class DeviceTaskManagerServiceComponent { } } - protected void setTaskService(TaskService taskService) { if (log.isDebugEnabled()) { log.debug("Setting the task service."); @@ -119,7 +131,4 @@ public class DeviceTaskManagerServiceComponent { } DeviceManagementDataHolder.getInstance().setTaskService(null); } - -} - - +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationEnrolmentMapping.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationEnrolmentMapping.java new file mode 100644 index 00000000000..4bccaaca929 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationEnrolmentMapping.java @@ -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; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index fc89089e489..99b53fe39d6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -420,12 +420,8 @@ public class OperationManagerImpl implements OperationManager { int enrolmentId = enrolmentInfo.getId(); //Changing the enrollment status & attempt count if the device is marked as inactive or unreachable switch (enrolmentInfo.getStatus()) { - case ACTIVE: - this.resetAttemptCount(enrolmentId); - break; case INACTIVE: case UNREACHABLE: - this.resetAttemptCount(enrolmentId); this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); break; } @@ -481,12 +477,8 @@ public class OperationManagerImpl implements OperationManager { int enrolmentId = enrolmentInfo.getId(); //Changing the enrollment status & attempt count if the device is marked as inactive or unreachable switch (enrolmentInfo.getStatus()) { - case ACTIVE: - this.resetAttemptCount(enrolmentId); - break; case INACTIVE: case UNREACHABLE: - this.resetAttemptCount(enrolmentId); this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); break; } @@ -1042,24 +1034,6 @@ public class OperationManagerImpl implements OperationManager { 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 deviceIds) { DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance(). getDeviceManagementProvider(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationMappingDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationMappingDAO.java index 72d02ec9bc6..b28b773d7bf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationMappingDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationMappingDAO.java @@ -18,10 +18,12 @@ */ 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.operation.mgt.OperationEnrolmentMapping; +import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMapping; import java.util.List; +import java.util.Map; public interface OperationMappingDAO { @@ -34,4 +36,30 @@ public interface OperationMappingDAO { void updateOperationMapping(List operationMappingList) throws 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 - List of OperationEnrolmentMapping objects containing required data + * @throws OperationManagementDAOException + */ + List 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 - List of OperationEnrolmentMapping objects containing required data + * @throws OperationManagementDAOException + */ + Map getLastConnectedTimeForActiveEnrolments(long timeStamp, int deviceTypeId) + throws OperationManagementDAOException; + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java index c1fb5bd8f01..82f2cd66e75 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java @@ -18,7 +18,9 @@ */ 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.operation.mgt.OperationEnrolmentMapping; 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.OperationManagementDAOFactory; @@ -27,8 +29,12 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationMappingDAO; import java.sql.Connection; import java.sql.PreparedStatement; +import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class OperationMappingDAOImpl implements OperationMappingDAO { @@ -129,4 +135,82 @@ public class OperationMappingDAOImpl implements OperationMappingDAO { OperationManagementDAOUtil.cleanupResources(stmt, null); } } + + @Override + public List getFirstPendingOperationMappingsForActiveEnrolments(long minDuration, + long maxDuration, int deviceTypeId) throws OperationManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs = null; + List 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 getLastConnectedTimeForActiveEnrolments(long timeStamp, int deviceTypeId) throws OperationManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs = null; + Map 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; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index cb3d1e24ad7..5cf672ea6c7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -353,8 +353,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } return false; } - DeviceType deviceType = deviceTypeDAO.getDeviceType(device.getType(), tenantId); - device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime()); device.getEnrolmentInfo().setStatus(EnrolmentInfo.Status.REMOVED); enrollmentDAO.updateEnrollment(device.getId(), device.getEnrolmentInfo(), tenantId); @@ -1118,15 +1116,16 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override + @Deprecated public void notifyOperationToDevices(Operation operation, List deviceIds) throws DeviceManagementException { - for (DeviceIdentifier deviceId : deviceIds) { - DeviceManagementService dms = - pluginRepository.getDeviceManagementService(deviceId.getType(), this.getTenantId()); - //TODO FIX THIS WITH PUSH NOTIFICATIONS - //dms.notifyOperationToDevices(operation, deviceIds); - } +// for (DeviceIdentifier deviceId : deviceIds) { +// DeviceManagementService dms = +// pluginRepository.getDeviceManagementService(deviceId.getType(), this.getTenantId()); +// //TODO FIX THIS WITH PUSH NOTIFICATIONS +// //dms.notifyOperationToDevices(operation, deviceIds); +// } } @@ -1557,9 +1556,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } finally { DeviceManagementDAOFactory.closeConnection(); } - - Device dmsDevice = this.getDeviceManager(device.getType()). - getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); + DeviceManager deviceManager = this.getDeviceManager(device.getType()); + if (deviceManager == null) { + throw new DeviceManagementException("Failed to retrieve device type definition for " + + device.getType()); + } + Device dmsDevice = deviceManager.getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), + device.getType())); if (dmsDevice != null) { device.setFeatures(dmsDevice.getFeatures()); device.setProperties(dmsDevice.getProperties()); @@ -1627,9 +1630,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } finally { DeviceManagementDAOFactory.closeConnection(); } - - Device dmsDevice = this.getDeviceManager(device.getType()). - getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); + DeviceManager deviceManager = this.getDeviceManager(device.getType()); + if (deviceManager == null) { + continue; + } + Device dmsDevice = deviceManager.getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), + device.getType())); if (dmsDevice != null) { device.setFeatures(dmsDevice.getFeatures()); device.setProperties(dmsDevice.getProperties()); @@ -1716,8 +1722,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } finally { DeviceManagementDAOFactory.closeConnection(); } - - Device dmsDevice = this.getDeviceManager(device.getType()). + DeviceManager deviceManager = this.getDeviceManager(device.getType()); + if (deviceManager == null) { + throw new DeviceManagementException("Failed to retrieve device type definition for " + + device.getType()); + } + Device dmsDevice = deviceManager. getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); if (dmsDevice != null) { device.setFeatures(dmsDevice.getFeatures()); @@ -1782,8 +1792,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } finally { DeviceManagementDAOFactory.closeConnection(); } - - Device dmsDevice = this.getDeviceManager(device.getType()). + DeviceManager deviceManager = this.getDeviceManager(device.getType()); + if (deviceManager == null) { + continue; + } + Device dmsDevice = deviceManager. getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); if (dmsDevice != null) { device.setFeatures(dmsDevice.getFeatures()); @@ -1879,8 +1892,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } finally { DeviceManagementDAOFactory.closeConnection(); } - - Device dmsDevice = this.getDeviceManager(device.getType()). + DeviceManager deviceManager = this.getDeviceManager(device.getType()); + if (deviceManager == null) { + continue; + } + Device dmsDevice = deviceManager. getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); if (dmsDevice != null) { device.setFeatures(dmsDevice.getFeatures()); @@ -1945,8 +1961,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } finally { DeviceManagementDAOFactory.closeConnection(); } - - Device dmsDevice = this.getDeviceManager(device.getType()). + DeviceManager deviceManager = this.getDeviceManager(device.getType()); + if (deviceManager == null) { + continue; + } + Device dmsDevice = deviceManager. getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); if (dmsDevice != null) { device.setFeatures(dmsDevice.getFeatures()); @@ -1999,7 +2018,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public boolean changeDeviceStatus(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status newStatus) throws DeviceManagementException { - boolean isDeviceUpdated = false; + boolean isDeviceUpdated; Device device = getDevice(deviceIdentifier); int deviceId = device.getId(); EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo(); @@ -2054,21 +2073,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv 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) { - DeviceManagementService deviceManagementService = pluginRepository.getDeviceManagementService(deviceType, this.getTenantId()); if (deviceManagementService == null) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/DeviceStatusTaskException.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/DeviceStatusTaskException.java new file mode 100644 index 00000000000..76db9731bb6 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/DeviceStatusTaskException.java @@ -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); + } + +} + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/DeviceStatusTaskManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/DeviceStatusTaskManagerService.java new file mode 100644 index 00000000000..5cab3012ef8 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/DeviceStatusTaskManagerService.java @@ -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; +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java new file mode 100644 index 00000000000..6bc51da2bac --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java @@ -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 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 operationEnrolmentMappings = null; + List enrolmentInfoTobeUpdated = new ArrayList<>(); + Map 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 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 getOperationEnrolmentMappings() throws DeviceStatusTaskException { + List 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 getLastDeviceActivities() throws DeviceStatusTaskException { + Map 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; + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java new file mode 100644 index 00000000000..988be3f4d0c --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java @@ -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 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 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); + } + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/DeviceTaskManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/DeviceTaskManager.java index 46128a37aa5..c4db7c3531a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/DeviceTaskManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/DeviceTaskManager.java @@ -45,7 +45,7 @@ public interface DeviceTaskManager { // 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 * @throws DeviceMgtTaskException */ @@ -67,7 +67,7 @@ public interface DeviceTaskManager { // List 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 * @return - true or false * @throws DeviceMgtTaskException diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index 08715c479fa..5b5f6706427 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -21,7 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; 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.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; @@ -50,7 +56,11 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; import java.sql.SQLException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; public final class DeviceManagerUtil { @@ -146,29 +156,28 @@ public final class DeviceManagerUtil { } /** - * Adds a new device type to the database if it does not exists. + * Get the DeviceType information from Database. * * @param typeName device type * @param tenantId provider tenant Id - * @return device type. + * @return DeviceType which contains info about the device-type. */ - public static DeviceType getDeviceType(String typeName, int tenantId) - throws DeviceManagementException { + public static DeviceType getDeviceType(String typeName, int tenantId) throws DeviceManagementException { + DeviceType deviceType = null; try { DeviceManagementDAOFactory.openConnection(); DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); - return deviceTypeDAO.getDeviceType(typeName, tenantId); - + deviceType = deviceTypeDAO.getDeviceType(typeName, tenantId); } catch (DeviceManagementDAOException e) { - DeviceManagementDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while retrieving the device type '" - + typeName + "'", e); + throw new DeviceManagementException("Error occurred while fetching the device type '" + + typeName + "'", e); } catch (SQLException e) { - throw new DeviceManagementException("SQL occurred while retrieving the device type '" - + typeName + "'", e); + throw new DeviceManagementException("SQL Error occurred while fetching the device type '" + + typeName + "'", e); } finally { DeviceManagementDAOFactory.closeConnection(); } + return deviceType; } /** diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java index c2b469a0f49..d555de0b417 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java @@ -83,4 +83,8 @@ public class TestDeviceManagementService implements DeviceManagementService { return null; } + @Override + public DeviceStatusTaskPluginConfig getDeviceStatusTaskPluginConfig() { + return null; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 0dfbf92d5bb..3395c825970 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java index 82ab717e071..9ff760b4c9e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java @@ -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.MonitoringOperation; 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.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; @@ -34,9 +35,12 @@ import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationSubsc import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.ConfigProperties; +import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceStatusTaskConfiguration; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceTypeConfiguration; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Feature; +import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PolicyMonitoring; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Property; +import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PullNotificationSubscriberConfig; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PushNotificationProvider; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.TaskConfiguration; import org.wso2.carbon.device.mgt.extensions.device.type.template.policy.mgt.DefaultPolicyMonitoringManager; @@ -64,6 +68,7 @@ public class DeviceTypeManagerService implements DeviceManagementService { private PolicyMonitoringManager policyMonitoringManager; private InitialOperationConfig initialOperationConfig; private PullNotificationSubscriber pullNotificationSubscriber; + private DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig; public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, DeviceTypeConfiguration deviceTypeConfiguration) { @@ -75,19 +80,10 @@ public class DeviceTypeManagerService implements DeviceManagementService { this.setOperationMonitoringConfig(deviceTypeConfiguration); this.initialOperationConfig = new InitialOperationConfig(); this.setInitialOperationConfig(deviceTypeConfiguration); - if (deviceTypeConfiguration.getPolicyMonitoring() != null - && deviceTypeConfiguration.getPolicyMonitoring().isEnabled()) { - this.policyMonitoringManager = new DefaultPolicyMonitoringManager(); - } - - if (deviceTypeConfiguration.getPullNotificationSubscriber() != null) { - String className = deviceTypeConfiguration.getPullNotificationSubscriber().getClassName(); - if (className != null && !className.isEmpty()) { - PullNotificationSubscriberLoader pullNotificationSubscriberLoader = new PullNotificationSubscriberLoader(className - , deviceTypeConfiguration.getPullNotificationSubscriber().getConfigProperties()); - this.pullNotificationSubscriber = pullNotificationSubscriberLoader.getPullNotificationSubscriber(); - } - } + this.deviceStatusTaskPluginConfig = new DeviceStatusTaskPluginConfig(); + this.setDeviceStatusTaskPluginConfig(deviceTypeConfiguration.getDeviceStatusTaskConfiguration()); + this.setPolicyMonitoringManager(deviceTypeConfiguration.getPolicyMonitoring()); + this.setPullNotificationSubscriber(deviceTypeConfiguration.getPullNotificationSubscriberConfig()); } @Override @@ -193,6 +189,10 @@ public class DeviceTypeManagerService implements DeviceManagementService { return pullNotificationSubscriber; } + public DeviceStatusTaskPluginConfig getDeviceStatusTaskPluginConfig() { + return deviceStatusTaskPluginConfig; + } + private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) { if (deviceTypeConfiguration.getProvisioningConfig() != null) { boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants(); @@ -202,6 +202,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) { if (deviceTypeConfiguration.getOperations() != null) { List ops = deviceTypeConfiguration.getOperations(); @@ -238,4 +247,21 @@ public class DeviceTypeManagerService implements DeviceManagementService { } return propertMap; } + + private void setPolicyMonitoringManager(PolicyMonitoring policyMonitoring) { + if (policyMonitoring != null && policyMonitoring.isEnabled()) { + this.policyMonitoringManager = new DefaultPolicyMonitoringManager(); + } + } + + private void setPullNotificationSubscriber(PullNotificationSubscriberConfig pullNotificationSubscriberConfig) { + if (pullNotificationSubscriberConfig != null) { + String className = pullNotificationSubscriberConfig.getClassName(); + if (className != null && !className.isEmpty()) { + PullNotificationSubscriberLoader pullNotificationSubscriberLoader = new PullNotificationSubscriberLoader + (className, pullNotificationSubscriberConfig.getConfigProperties()); + this.pullNotificationSubscriber = pullNotificationSubscriberLoader.getPullNotificationSubscriber(); + } + } + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java index 86637223634..d5e340bf8f2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java @@ -21,8 +21,6 @@ package org.wso2.carbon.device.mgt.extensions.device.type.template; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.InitialOperationConfig; -import org.wso2.carbon.device.mgt.common.MonitoringOperation; -import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeDefinitionProvider; import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; @@ -36,9 +34,8 @@ import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PolicyM import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Properties; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Property; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.ProvisioningConfig; -import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PullNotificationSubscriber; +import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PullNotificationSubscriberConfig; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PushNotificationProvider; -import org.wso2.carbon.device.mgt.extensions.device.type.template.config.TaskConfiguration; import java.util.ArrayList; import java.util.List; @@ -51,7 +48,7 @@ import java.util.Map; public class HTTPDeviceTypeManagerService extends DeviceTypeManagerService implements DeviceTypeDefinitionProvider { private DeviceTypeMetaDefinition deviceTypeMetaDefinition; - private static final String DEFAULT_PULL_NOTIFICATION_CLASS_NAME = "org.wso2.carbon.device.mgt.extensions.pull.notification"; + private static final String DEFAULT_PULL_NOTIFICATION_CLASS_NAME = "org.wso2.carbon.device.mgt.extensions.pull.notification.PullNotificationSubscriberImpl"; public HTTPDeviceTypeManagerService(String deviceTypeName, DeviceTypeMetaDefinition deviceTypeMetaDefinition) { super(getDeviceTypeConfigIdentifier(deviceTypeName), getDeviceTypeConfiguration( @@ -165,9 +162,9 @@ public class HTTPDeviceTypeManagerService extends DeviceTypeManagerService imple deviceTypeConfiguration.setOperations(initialOperationConfig.getOperations()); } } - PullNotificationSubscriber pullNotificationSubscriber = new PullNotificationSubscriber(); + PullNotificationSubscriberConfig pullNotificationSubscriber = new PullNotificationSubscriberConfig(); pullNotificationSubscriber.setClassName(DEFAULT_PULL_NOTIFICATION_CLASS_NAME); - deviceTypeConfiguration.setPullNotificationSubscriber(pullNotificationSubscriber); + deviceTypeConfiguration.setPullNotificationSubscriberConfig(pullNotificationSubscriber); return deviceTypeConfiguration; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceStatusTaskConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceStatusTaskConfiguration.java new file mode 100644 index 00000000000..588bd4a1ec8 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceStatusTaskConfiguration.java @@ -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.template.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; + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java index d1dd854fbb9..ed958dd66b9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java @@ -18,7 +18,12 @@ */ package org.wso2.carbon.device.mgt.extensions.device.type.template.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; @@ -40,6 +45,7 @@ import java.util.List; * <element name="DataSource" type="{}DataSource"/> * <element name="PolicyMonitoring" type="{}PolicyMonitoring"/> * <element name="DeviceAuthorizationConfig" type="{}DeviceAuthorizationConfig"/> + * <element name="DeviceStatusTaskConfig" type="{}DeviceStatusTaskConfig"/> * </sequence> * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" /> * </restriction> @@ -59,16 +65,18 @@ public class DeviceTypeConfiguration { protected Features features; @XmlElement(name = "ProvisioningConfig", required = true) protected ProvisioningConfig provisioningConfig; - @XmlElement(name = "PushNotificationProvider", required = true) + @XmlElement(name = "PushNotificationProviderConfig", required = true) protected PushNotificationProvider pushNotificationProvider; - @XmlElement(name = "PullNotificationSubscriber", required = true) - protected PullNotificationSubscriber pullNotificationSubscriber; + @XmlElement(name = "PullNotificationSubscriberConfig", required = true) + protected PullNotificationSubscriberConfig pullNotificationSubscriberConfig; @XmlElement(name = "License", required = true) protected License license; @XmlElement(name = "DataSource", required = true) protected DataSource dataSource; @XmlElement(name = "TaskConfiguration", required = true) private TaskConfiguration taskConfiguration; + @XmlElement(name = "DeviceStatusTaskConfig") + private DeviceStatusTaskConfiguration deviceStatusTaskConfiguration; @XmlElement(name = "DeviceAuthorizationConfig", required = true) protected DeviceAuthorizationConfig deviceAuthorizationConfig; @XmlAttribute(name = "name") @@ -87,6 +95,30 @@ public class DeviceTypeConfiguration { 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. * @@ -233,23 +265,23 @@ public class DeviceTypeConfiguration { } /** - * Gets the value of the PullNotificationSubscriber property. + * Gets the value of the PullNotificationSubscriberConfig property. * * @return possible object is - * {@link PullNotificationSubscriber } + * {@link PullNotificationSubscriberConfig } */ - public PullNotificationSubscriber getPullNotificationSubscriber() { - return pullNotificationSubscriber; + public PullNotificationSubscriberConfig getPullNotificationSubscriberConfig() { + return pullNotificationSubscriberConfig; } /** - * Sets the value of the PullNotificationSubscriber property. + * Sets the value of the PullNotificationSubscriberConfig property. * * @param value allowed object is - * {@link PullNotificationSubscriber } + * {@link PullNotificationSubscriberConfig } */ - public void setPullNotificationSubscriber(PullNotificationSubscriber value) { - this.pullNotificationSubscriber = value; + public void setPullNotificationSubscriberConfig(PullNotificationSubscriberConfig value) { + this.pullNotificationSubscriberConfig = value; } /** @@ -331,5 +363,4 @@ public class DeviceTypeConfiguration { public void setDeviceAuthorizationConfig(DeviceAuthorizationConfig value) { this.deviceAuthorizationConfig = value; } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PullNotificationSubscriber.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PullNotificationSubscriberConfig.java similarity index 92% rename from components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PullNotificationSubscriber.java rename to components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PullNotificationSubscriberConfig.java index fbf26b00709..b559637d4cd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PullNotificationSubscriber.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PullNotificationSubscriberConfig.java @@ -26,12 +26,12 @@ import javax.xml.bind.annotation.XmlType; /** - *

Java class for PullNotificationSubscriber complex type. + *

Java class for PullNotificationSubscriberConfig complex type. * *

The following schema fragment specifies the expected content contained within this class. * *

- * <complexType name="PullNotificationSubscriber">
+ * <complexType name="PullNotificationSubscriberConfig">
  *   <complexContent>
  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
  *       <sequence>
@@ -46,10 +46,10 @@ import javax.xml.bind.annotation.XmlType;
  * 
  */
 @XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "PullNotificationSubscriber", propOrder = {
+@XmlType(name = "PullNotificationSubscriberConfig", propOrder = {
     "configProperties"
 })
-public class PullNotificationSubscriber {
+public class PullNotificationSubscriberConfig {
     @XmlElement(name = "ConfigProperties", required = true)
     protected ConfigProperties configProperties;
     @XmlAttribute(name = "className")
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/resources/sample.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/resources/sample.xml
index 5fa3001f38d..127999a5f35 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/resources/sample.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/resources/sample.xml
@@ -92,12 +92,11 @@
 		
 	
 
-	
+	
 		
-			sample.mqtt.adapter
-			admin
+			admin
 		
-	
+	
 
 	
 
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
index 475f1578d7e..110b1dc8c29 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
@@ -22,7 +22,7 @@
     
         device-mgt
         org.wso2.carbon.devicemgt
-        2.0.71-SNAPSHOT
+        2.0.72-SNAPSHOT
         ../pom.xml
     
 
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js
index 72f7739966a..7a0eeba191c 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js
@@ -397,8 +397,6 @@ var utils = function () {
 	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;
 	};
 
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.hbs
index fea3ef63c3e..26af50aff78 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.hbs
@@ -230,7 +230,7 @@
              curl -k -X POST {{httpsGateway}}/api/device-mgt/v1.0/device/agent/events/publish/{{deviceType}}/%deviceId%
                    -H 'authorization: Bearer %accessToken%'
                    -H 'content-type: application/json'
-                   -d '{"payloadData": [{{sampleValue}}]}'
+                   -d '{{eventSample}}'
             
 
         {{/if_eq}}
@@ -277,8 +277,7 @@
         
Update operation: curl -k -X PUT {{httpsGateway}}/api/device-mgt/v1.0/device/agent/operations/{{deviceType}}/deviceId - -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json' -d '{"enabled": true,"code": "alarm","type": "COMMAND","id": 1,"status": "COMPLETED", - "isEnabled": false,"activityId": "ACTIVITY_1"}' + -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json' -d '{"id": 1,"status": "COMPLETED", "payload": "this is my response"}' {{/if}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.js index 92a85e1ccaf..0f3563bad17 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.type-view/type-view.js @@ -56,8 +56,6 @@ function onRequest(context) { displayData.event = typeData; var sampleValue = ""; if (typeData.eventAttributes && typeData.eventAttributes.attributes) { - var sample = {}; - sample.event = {}; var eventExample = {}; for (var i = 0; i < typeData.eventAttributes.attributes.length; i++) { var attribute = typeData.eventAttributes.attributes[i]; @@ -90,10 +88,7 @@ function onRequest(context) { } } - var metaEventExample = {}; - metaEventExample.deviceId = "deviceIdentifier"; - sample.event.payloadData = eventExample; - sample.event.metaData = metaEventExample; + var sample = eventExample; if (sampleValue && sampleValue.length > 2) { displayData.sampleValue = sampleValue.substring(0, sampleValue.length - 2); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml index da02b2acb0e..b120bd8d13e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index f64a0d92d6a..90507411948 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml diff --git a/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml b/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml index b97d01c7c76..d765509e984 100644 --- a/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml +++ b/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/email-sender/pom.xml b/components/email-sender/pom.xml index 94aad7911cf..f9d4af2b82d 100644 --- a/components/email-sender/pom.xml +++ b/components/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml index 15cb07233da..8bee9f283cd 100644 --- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml @@ -21,7 +21,7 @@ dynamic-client-registration org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml index cf952e21f3a..94ec69b1cfb 100644 --- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml @@ -21,7 +21,7 @@ dynamic-client-registration org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml index 3c6af14df39..52398ff0408 100644 --- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml @@ -21,13 +21,13 @@ dynamic-client-registration org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.dynamic.client.registration - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - Dynamic client registration service WSO2 Carbon - Dynamic Client Registration Service diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml index 1e7d1feb537..f8bd39fd2a0 100644 --- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml @@ -21,13 +21,13 @@ dynamic-client-registration org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.dynamic.client.web.app.registration - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - Dynamic client web app registration WSO2 Carbon - Dynamic Client Web-app Registration Service diff --git a/components/identity-extensions/dynamic-client-registration/pom.xml b/components/identity-extensions/dynamic-client-registration/pom.xml index a77e04cc093..5fc92ad4c78 100644 --- a/components/identity-extensions/dynamic-client-registration/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt identity-extensions - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt dynamic-client-registration - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Dynamic client registration http://wso2.org diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index 9997b17e95f..2546ec47132 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt identity-extensions - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.oauth.extensions - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - OAuth Extensions http://wso2.org diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml index d6e5d1a2e9a..3be089a6958 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml @@ -21,7 +21,7 @@ identity-extensions org.wso2.carbon.devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT 4.0.0 diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index 092b0efd5a2..e8f19d1032d 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 621e5960c4f..3040eb7d934 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml index 93356e85fc7..1081b222ba6 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt policy-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.complex.policy.decision.point - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - Policy Decision Point WSO2 Carbon - Policy Decision Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml index 00151576abe..a3609d012f6 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml @@ -3,14 +3,14 @@ org.wso2.carbon.devicemgt policy-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.decision.point - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - Policy Decision Point WSO2 Carbon - Policy Decision Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml index 0f25a843a47..bd59f7da979 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.information.point - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - Policy Information Point WSO2 Carbon - Policy Information Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index df2d4241486..b24c140cfa6 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt policy-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.common - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - Policy Management Common WSO2 Carbon - Policy Management Common diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index ac1ee252935..a025447895e 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt policy-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.core - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - Policy Management Core WSO2 Carbon - Policy Management Core diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java index edab86d1ce3..9fade918e13 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java @@ -59,8 +59,7 @@ public class MonitoringManagerImpl implements MonitoringManager { private static final Log log = LogFactory.getLog(MonitoringManagerImpl.class); 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() { this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO(); @@ -273,9 +272,6 @@ public class MonitoringManagerImpl implements MonitoringManager { Map deviceIdsToAddOperation = new HashMap<>(); Map deviceIdsWithExistingOperation = new HashMap<>(); - Map inactiveDeviceIds = new HashMap<>(); - Map devicesToMarkUnreachable = new HashMap<>(); - //Map firstTimeDeviceIdsWithPolicyIds = new HashMap<>(); List firstTimeDevices = new ArrayList<>(); @@ -293,14 +289,6 @@ public class MonitoringManagerImpl implements MonitoringManager { } else { deviceIdsWithExistingOperation.put(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); } } - - // 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 diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 3c40c38554d..431c1719162 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 policy-mgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Policy Management Component http://wso2.org diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 6c3761f229c..877c80d672a 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -21,14 +21,14 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.webapp.authenticator.framework - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT bundle WSO2 Carbon - Web Application Authenticator Framework Bundle WSO2 Carbon - Web Application Authenticator Framework Bundle diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 57753a431eb..ece31dfc59d 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt webapp-authenticator-framework - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Webapp Authenticator Framework http://wso2.org diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml index c3db18527e3..caba6dcd6ab 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml @@ -21,14 +21,14 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.application.extension.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - API Management Application Extension Feature http://wso2.org This feature contains an implementation of a api application registration, which takes care of subscription diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml index f8c2921631f..a407404e895 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handler.server.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Device Management - APIM handler Server Feature http://wso2.org This feature contains the handler for the api authentications diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index cf36091e8d3..ff5c8469d88 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -21,13 +21,13 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client.feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - APIM Integration Client Feature http://wso2.org diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml index 4e8aa79d896..8c7b805fe5a 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml @@ -21,14 +21,14 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - API Management Webapp Publisher Feature http://wso2.org This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 6d6e78b2f7c..2f4406afdaf 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - API Management Extensions Feature http://wso2.org diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml index 37eeec0d43a..8b5a21fdec9 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml index de3d2d5e514..edb9fcc4971 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml index 74739533d86..55bcba11d35 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.server.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Certificate Management Server Feature http://wso2.org This feature contains the core bundles required for back-end Certificate Management functionality diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 5389b6fcc22..94b3ede331f 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Certificate Management Feature http://wso2.org diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml index 3e8491aaf26..c505021b07b 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Device Type Deployer Feature http://wso2.org WSO2 Carbon - Device Type Deployer Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index ef373826bad..654261f4459 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - FCM Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 44dfd4479fb..6a9e0aefeff 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - MQTT Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index ce0595c7f58..15ba7cf297c 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - XMPP Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - XMPP Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index d4187ee6dc5..9f4ff818f49 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml index 45cba00a87b..4788d3facdd 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml @@ -3,13 +3,13 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.analytics.dashboard.feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Device Management Dashboard Analytics Feature WSO2 Carbon - Device Management Dashboard Analytics Feature diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml index 6f60ed8c235..6dae0ed9992 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.analytics.data.publisher.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Device Management Server Feature http://wso2.org This feature contains bundles related to device analytics data publisher diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml index d2b08754c9a..38801c59ddd 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml index 6a286eba0fe..82cc17317f8 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml @@ -4,14 +4,14 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Device Management Extensions Feature http://wso2.org This feature contains common extensions used by key device management functionalities diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index 1c6ed2bc6a5..41eb39eca49 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml index 50a5b43489b..d4fa513103d 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.server.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Device Management Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml index 186f068de26..a05dff92568 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml @@ -69,5 +69,8 @@ 20 20 + + true + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml index 085951ff97b..1e51aa3a389 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 1a066ee6d29..454cb2303f5 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml diff --git a/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml b/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml index 3452bd6c26e..1596d08bd01 100644 --- a/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml +++ b/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt dynamic-client-registration-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.dynamic.client.registration.server.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Dynamic Client Registration Server Feature http://wso2.org This feature contains dynamic client registration features diff --git a/features/dynamic-client-registration/pom.xml b/features/dynamic-client-registration/pom.xml index d08194af0ce..5e568a5ff8e 100644 --- a/features/dynamic-client-registration/pom.xml +++ b/features/dynamic-client-registration/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt dynamic-client-registration-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Dynamic Client Registration Feature http://wso2.org diff --git a/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml b/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml index 274ea9de572..7cfdfd3a7a3 100644 --- a/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml +++ b/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt email-sender-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.email.sender.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Email Sender Feature http://wso2.org This feature contains the core bundles required for email sender related functionality diff --git a/features/email-sender/pom.xml b/features/email-sender/pom.xml index c2b6648144b..49978eed475 100644 --- a/features/email-sender/pom.xml +++ b/features/email-sender/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt email-sender-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Email Sender Feature http://wso2.org diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml index fc9b86b3bae..c72164bec93 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt jwt-client-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.identity.jwt.client.extension.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - JWT Client Feature http://wso2.org This feature contains jwt client implementation from which we can get a access token using the jwt diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index b1151326e8a..350e5ea844a 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 jwt-client-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Dynamic Client Registration Feature http://wso2.org diff --git a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml index 1e85453b1ed..a41e8458240 100644 --- a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml +++ b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt oauth-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.oauth.extensions.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Device Mgt OAuth Extensions Feature http://wso2.org This feature contains devicemgt related OAuth extensions diff --git a/features/oauth-extensions/pom.xml b/features/oauth-extensions/pom.xml index b9ed5b89478..c123b225f1b 100644 --- a/features/oauth-extensions/pom.xml +++ b/features/oauth-extensions/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt oauth-extensions-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Device Management OAuth Extensions Feature http://wso2.org diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index a7d7d2be2a3..b38a6e72bfa 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt policy-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.policy.mgt.server.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Policy Management Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 16ec3ab0c2a..37e04a944ad 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt policy-mgt-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Policy Management Feature http://wso2.org diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml index 161e761ea9a..9ed16e47b2e 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.webapp.authenticator.framework.server.feature pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Webapp Authenticator Framework Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 888ab763666..a128c1e7d60 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT pom WSO2 Carbon - Webapp Authenticator Framework Feature http://wso2.org diff --git a/pom.xml b/pom.xml index 9d45442d371..5b60aa868fc 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt pom - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1853,7 +1853,7 @@ 1.2.11.wso2v10 - 2.0.71-SNAPSHOT + 2.0.72-SNAPSHOT 4.4.8