From f3393080badafefb97c43b142d9bcaeea5403f50 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 6 Jun 2017 11:00:59 +0530 Subject: [PATCH] fixed few issues after testing --- .../PullNotificationSubscriberImpl.java | 8 +- .../service/impl/DeviceAgentServiceImpl.java | 2 +- .../DeviceEventManagementServiceImpl.java | 98 +++++++++---------- .../impl/DeviceManagementServiceImpl.java | 32 +++++- .../DeviceTypeManagementAdminServiceImpl.java | 4 +- .../mgt/DeviceTypeDefinitionProvider.java | 2 +- .../DeviceManagementPluginRepository.java | 6 +- .../DeviceManagementProviderService.java | 4 +- .../DeviceManagementProviderServiceImpl.java | 2 +- .../HTTPDeviceTypeManagerService.java | 6 +- .../public/js/bottomJs.js | 3 +- 11 files changed, 90 insertions(+), 77 deletions(-) diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java index 3ee6cb5c4c..bcf8dece8a 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java @@ -87,13 +87,7 @@ public class PullNotificationSubscriberImpl implements PullNotificationSubscribe return null; } // Parsing json string to get compliance features. - JsonElement jsonElement; - if (compliancePayloadString instanceof String) { - jsonElement = new JsonParser().parse(compliancePayloadString); - } else { - throw new PolicyComplianceException("Invalid policy compliance payload"); - } - + JsonElement jsonElement = new JsonParser().parse(compliancePayloadString); JsonArray jsonArray = jsonElement.getAsJsonArray(); Gson gson = new Gson(); ComplianceFeature complianceFeature; 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 0813ee50dc..1926a3ef87 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 @@ -245,7 +245,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService { } if (payload.size() != attributes.size()) { - String msg = "payload does not match the stream definition"; + String msg = "payload does not match with the stream definition"; return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } eventAttributeList = new EventAttributeList(); 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 0e804eb95d..d74a98a871 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 @@ -16,10 +16,8 @@ import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceA import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable; import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord; import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; @@ -34,7 +32,6 @@ import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.event.publisher.stub.EventPublisherAdminServiceCallbackHandler; import org.wso2.carbon.event.publisher.stub.EventPublisherAdminServiceStub; -import org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto; import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceCallbackHandler; import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceStub; import org.wso2.carbon.event.receiver.stub.types.BasicInputAdapterPropertyDto; @@ -42,17 +39,10 @@ import org.wso2.carbon.event.receiver.stub.types.EventReceiverConfigurationDto; import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub; import org.wso2.carbon.event.stream.stub.types.EventStreamAttributeDto; import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto; -import org.wso2.carbon.identity.jwt.client.extension.JWTClient; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManagerFactory; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.security.cert.CertificateException; import javax.validation.Valid; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -64,10 +54,9 @@ import javax.ws.rs.core.Response; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.List; -import java.util.UUID; /** - * This is used for simple analytics purpose, to create streams and receiver dynamically and a common endpoint + * This is used for device type integration with DAS, to create streams and receiver dynamically and a common endpoint * to retrieve data. */ @Path("/events") @@ -85,7 +74,12 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe private static final String MQTT_CONTENT_TRANSFORMER_TYPE = "contentTransformer"; private static final String MQTT_CONTENT_VALIDATOR_TYPE = "contentValidator"; private static final String MQTT_CONTENT_VALIDATOR = "default"; + private static final String TIMESTAMP_FIELD_NAME = "_timestamp"; + /** + * Retrieves the stream definition from das for the given device type. + * @return dynamic event attribute list + */ @GET @Path("/{type}") @Override @@ -159,7 +153,6 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe TransportType transportType = deviceTypeEvent.getTransportType(); EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList(); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - boolean superTenantMode = false; try { if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 || deviceType == null || transportType == null || @@ -174,15 +167,17 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, deviceType); publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes); publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType); - superTenantMode = true; - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( - MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); - if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { - publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); - publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, deviceType); + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( + MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); + if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { + publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); + publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, deviceType); + } + } finally { + PrivilegedCarbonContext.endTenantFlow(); } - DeviceMgtAPIUtils.getDynamicEventCache().remove(deviceType); return Response.ok().build(); } catch (AxisFault e) { log.error("failed to create event definitions for tenantDomain:" + tenantDomain, e); @@ -203,19 +198,17 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } finally { - if (superTenantMode) { - PrivilegedCarbonContext.endTenantFlow(); - } } } + /** + * Delete device type specific artifacts from DAS. + */ @DELETE @Path("/{type}") @Override public Response deleteDeviceTypeEventDefinitions(@PathParam("type") String deviceType) { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - boolean superTenantMode = false; EventReceiverAdminServiceStub eventReceiverAdminServiceStub = null; EventPublisherAdminServiceStub eventPublisherAdminServiceStub = null; EventStreamAdminServiceStub eventStreamAdminServiceStub = null; @@ -253,18 +246,24 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe eventPublisherAdminServiceStub.startundeployInactiveEventPublisherConfiguration(eventPublisherName , eventPublisherAdminServiceCallbackHandler); - superTenantMode = true; - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( - MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); - if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { - tenantBasedEventReceiverAdminServiceStub = DeviceMgtAPIUtils.getEventReceiverAdminServiceStub(); - tenantBasedEventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub(); - tenantBasedEventStreamAdminServiceStub.removeEventStreamDefinition(streamName, - Constants.DEFAULT_STREAM_VERSION); - tenantBasedEventReceiverAdminServiceStub.startundeployInactiveEventReceiverConfiguration( - eventReceiverName, eventReceiverAdminServiceCallbackHandler); + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( + MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); + if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { + tenantBasedEventReceiverAdminServiceStub = DeviceMgtAPIUtils.getEventReceiverAdminServiceStub(); + tenantBasedEventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub(); + tenantBasedEventStreamAdminServiceStub.removeEventStreamDefinition(streamName, + Constants.DEFAULT_STREAM_VERSION); + + tenantBasedEventReceiverAdminServiceStub.startundeployInactiveEventReceiverConfiguration( + eventReceiverName, eventReceiverAdminServiceCallbackHandler); + } + } finally { + cleanup(tenantBasedEventReceiverAdminServiceStub); + cleanup(tenantBasedEventStreamAdminServiceStub); + PrivilegedCarbonContext.endTenantFlow(); } return Response.ok().build(); } catch (AxisFault e) { @@ -283,19 +282,17 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } finally { - if (superTenantMode) { - PrivilegedCarbonContext.endTenantFlow(); - } cleanup(eventStreamAdminServiceStub); cleanup(eventPublisherAdminServiceStub); cleanup(eventReceiverAdminServiceStub); cleanup(eventReceiverAdminServiceStub); cleanup(eventStreamAdminServiceStub); - cleanup(tenantBasedEventReceiverAdminServiceStub); - cleanup(tenantBasedEventStreamAdminServiceStub); } } + /** + * Returns device specific data for the give period of time. + */ @GET @Path("/{type}/{deviceId}") @Override @@ -324,7 +321,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); } List sortByFields = new ArrayList<>(); - SortByField sortByField = new SortByField("_timestamp", SortType.DESC); + SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); sortByFields.add(sortByField); EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, offset, limit); return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); @@ -342,6 +339,9 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe } } + /** + * Returns the last know data point of the device type. + */ @GET @Path("/last-known/{type}/{deviceId}") @Override @@ -361,7 +361,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); } List sortByFields = new ArrayList<>(); - SortByField sortByField = new SortByField("_timestamp", SortType.DESC); + SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); sortByFields.add(sortByField); EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1); return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); @@ -531,12 +531,6 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe return basicInputAdapterPropertyDto; } - private static String generateUUID() { - UUID uuid = UUID.randomUUID(); - long l = ByteBuffer.wrap(uuid.toString().getBytes(StandardCharsets.UTF_8)).getLong(); - return Long.toString(l, Character.MAX_RADIX); - } - private String getTableName(String streamName) { return streamName.toUpperCase().replace('.', '_'); } @@ -545,7 +539,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe return deviceType.replace(" ", "_").trim() + "-" + tenantDomain + "-" + transportType.toString() + "-receiver"; } - public static AnalyticsDataAPI getAnalyticsDataAPI() { + private static AnalyticsDataAPI getAnalyticsDataAPI() { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); AnalyticsDataAPI analyticsDataAPI = (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null); @@ -557,7 +551,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe return analyticsDataAPI; } - protected static EventRecords getAllEventsForDevice(String tableName, String query, List sortByFields + private static EventRecords getAllEventsForDevice(String tableName, String query, List sortByFields , int offset, int limit) throws AnalyticsException { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI(); 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 b025e3eee1..a3b0a8186b 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 @@ -47,6 +47,8 @@ import org.wso2.carbon.device.mgt.common.search.SearchContext; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; +import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; +import org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; @@ -62,6 +64,7 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; +import javax.security.auth.login.Configuration; import javax.validation.Valid; import javax.validation.constraints.Size; import javax.ws.rs.Consumes; @@ -88,6 +91,7 @@ import java.util.List; public class DeviceManagementServiceImpl implements DeviceManagementService { private static final Log log = LogFactory.getLog(DeviceManagementServiceImpl.class); + public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; @GET @Path("/{type}/{id}/status") @@ -100,7 +104,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { if (result) { return Response.status(Response.Status.OK).build(); } else { - return Response.status(Response.Status.NOT_FOUND).build(); + return Response.status(Response.Status.NO_CONTENT).build(); } } catch (DeviceManagementException e) { String msg = "Error occurred while checking enrollment status of the device."; @@ -558,7 +562,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { RequestValidationUtil.validateDeviceIdentifier(type, id); PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService(); Policy policy; - NonComplianceData complianceData = null; + NonComplianceData complianceData; DeviceCompliance deviceCompliance = new DeviceCompliance(); try { @@ -650,8 +654,28 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { deviceIdentifier.setType(type); deviceIdentifiers.add(deviceIdentifier); } - Activity activity = DeviceMgtAPIUtils.getDeviceManagementService().addOperation(type - , operationRequest.getOperation(), deviceIdentifiers); + Operation operation; + if (operationType == Operation.Type.COMMAND) { + Operation commandOperation = operationRequest.getOperation(); + operation = new CommandOperation(); + operation.setType(Operation.Type.COMMAND); + operation.setCode(commandOperation.getCode()); + operation.setEnabled(commandOperation.isEnabled()); + operation.setStatus(commandOperation.getStatus()); + + } else { + Operation configOperation = operationRequest.getOperation(); + operation = new ConfigOperation(); + operation.setType(Operation.Type.CONFIG); + operation.setCode(configOperation.getCode()); + operation.setEnabled(configOperation.isEnabled()); + operation.setPayLoad(configOperation.getPayLoad()); + operation.setStatus(configOperation.getStatus()); + } + String date = new SimpleDateFormat(DATE_FORMAT_NOW).format(new Date()); + operation.setCreatedTimeStamp(date); + Activity activity = DeviceMgtAPIUtils.getDeviceManagementService().addOperation(type, operation, + deviceIdentifiers); return Response.status(Response.Status.CREATED).entity(activity).build(); } else { String message = "Only Command and Config operation is supported through this api"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypeManagementAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypeManagementAdminServiceImpl.java index d573414ea0..51520e4ddd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypeManagementAdminServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypeManagementAdminServiceImpl.java @@ -74,7 +74,7 @@ public class DeviceTypeManagementAdminServiceImpl implements DeviceTypeManagemen DeviceMgtAPIUtils.getDeviceManagementService().registerDeviceType(httpDeviceTypeManagerService); return Response.status(Response.Status.OK).build(); } catch (DeviceManagementException e) { - String msg = "Error occurred at server side while fetching device list."; + String msg = "Error occurred at server side while adding a device type."; log.error(msg, e); return Response.serverError().entity(msg).build(); } @@ -97,7 +97,7 @@ public class DeviceTypeManagementAdminServiceImpl implements DeviceTypeManagemen DeviceMgtAPIUtils.getDeviceManagementService().registerDeviceType(httpDeviceTypeManagerService); return Response.status(Response.Status.OK).build(); } catch (DeviceManagementException e) { - String msg = "Error occurred at server side while fetching device list."; + String msg = "Error occurred at server side while updating the device type."; log.error(msg, e); return Response.serverError().entity(msg).build(); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeDefinitionProvider.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeDefinitionProvider.java index 76320b6612..fab714fd5b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeDefinitionProvider.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeDefinitionProvider.java @@ -20,6 +20,6 @@ package org.wso2.carbon.device.mgt.common.type.mgt; public interface DeviceTypeDefinitionProvider { - DeviceTypeMetaDefinition getDeviceTypeMeta(); + DeviceTypeMetaDefinition getDeviceTypeMetaDefinition(); } 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 56d26f0ead..bc685415bf 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 @@ -89,7 +89,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis DeviceTypeServiceIdentifier deviceTypeIdentifier = new DeviceTypeServiceIdentifier( provider.getType()); DeviceManagementServiceHolder existingProvider = providers.get(deviceTypeIdentifier); - deviceTypeDefinition = ((DeviceTypeDefinitionProvider) provider).getDeviceTypeMeta(); + deviceTypeDefinition = ((DeviceTypeDefinitionProvider) provider).getDeviceTypeMetaDefinition(); if (existingProvider != null && !(existingProvider.getDeviceManagementService() instanceof DeviceTypeDefinitionProvider)) { throw new DeviceManagementException("Definition of device type " + provider.getType() @@ -207,7 +207,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis Gson gson = new Gson(); String dbStoredDefinition = gson.toJson(deviceTypeMetaDefinition); deviceTypeMetaDefinition = ((DeviceTypeDefinitionProvider) - provider.getDeviceManagementService()).getDeviceTypeMeta(); + provider.getDeviceManagementService()).getDeviceTypeMetaDefinition(); String cachedDefinition = gson.toJson(deviceTypeMetaDefinition); if (!cachedDefinition.equals(dbStoredDefinition)) { HTTPDeviceTypeManagerService deviceTypeManagerService = new HTTPDeviceTypeManagerService @@ -378,7 +378,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis int tenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain()); DeviceTypeMetaDefinition deviceTypeDefinition = null; if (provider instanceof DeviceTypeDefinitionProvider) { - deviceTypeDefinition = ((DeviceTypeDefinitionProvider) provider).getDeviceTypeMeta(); + deviceTypeDefinition = ((DeviceTypeDefinitionProvider) provider).getDeviceTypeMetaDefinition(); DeviceTypeServiceIdentifier deviceTypeIdentifier = new DeviceTypeServiceIdentifier( provider.getType(), tenantId); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index 0f5500a0e8..a931332042 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -352,9 +352,9 @@ public interface DeviceManagementProviderService { List getDeviceTypes() throws DeviceManagementException; /** - * This retrieves the device pull notification payload and passes to device type executor. + * This retrieves the device pull notification payload and passes to device type pull notification subscriber. * @throws PullNotificationExecutionFailedException */ - void updatePullNotificationOperation(DeviceIdentifier deviceIdentifier, Operation operation) + void notifyPullNotificationSubscriber(DeviceIdentifier deviceIdentifier, Operation operation) throws PullNotificationExecutionFailedException; } 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 5cf672ea6c..ac4b4f0550 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 @@ -2211,7 +2211,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public void updatePullNotificationOperation(DeviceIdentifier deviceIdentifier, Operation operation) + public void notifyPullNotificationSubscriber(DeviceIdentifier deviceIdentifier, Operation operation) throws PullNotificationExecutionFailedException { DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceIdentifier.getType(), this.getTenantId()); 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 d5e340bf8f..c05da78f3c 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 @@ -42,8 +42,8 @@ import java.util.List; import java.util.Map; /** - * This is the template for device type manager service. This will create and instance of device management service - * through the json payload. + * This inherits the capabiliy that is provided through the file based device type manager service. + * This will create and instance of device management service through a json payload. */ public class HTTPDeviceTypeManagerService extends DeviceTypeManagerService implements DeviceTypeDefinitionProvider { @@ -174,7 +174,7 @@ public class HTTPDeviceTypeManagerService extends DeviceTypeManagerService imple } @Override - public DeviceTypeMetaDefinition getDeviceTypeMeta() { + public DeviceTypeMetaDefinition getDeviceTypeMetaDefinition() { return deviceTypeMetaDefinition; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.create/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.create/public/js/bottomJs.js index 1adc246527..941729dc0e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.create/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.create/public/js/bottomJs.js @@ -202,11 +202,12 @@ $(document).ready(function () { $('div[name^="deviceFeature"]').each(function() { var featureName = $(this).find("#feature-name").val(); var featureCode = $(this).find("#feature-code").val(); + var featureDescription = $(this).find("#feature-description").val(); if (featureName && featureName.trim() != "" && featureCode && featureCode.trim() != "") { var feature = {}; feature.name = featureName.trim(); feature.code = featureCode.trim(); - feature.description = $("#feature-description").val(); + feature.description = featureDescription.trim(); features.push(feature); } });