Rasika Perera 7 years ago
parent d8caf3baea
commit 394f45f4bd

@ -70,7 +70,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
@PathParam("deviceType") String deviceType,
@QueryParam("from") long from, @QueryParam("to") long to) {
try {
if (!DeviceManagerUtil.isPublishOperationResponseEnabled()) {
if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) {
return Response.status(Response.Status.BAD_REQUEST.getStatusCode())
.entity("Unable to retrive Geo Device stats. Geo Data publishing does not enabled.").build();
}

@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.core.config;
import org.wso2.carbon.device.mgt.core.config.archival.ArchivalConfiguration;
import org.wso2.carbon.device.mgt.core.config.cache.CertificateCacheConfiguration;
import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration;
import org.wso2.carbon.device.mgt.core.config.geo.location.OperationAnalyticsConfiguration;
import org.wso2.carbon.device.mgt.core.config.cache.DeviceCacheConfiguration;
import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations;
@ -53,6 +54,7 @@ public final class DeviceManagementConfig {
private DeviceCacheConfiguration deviceCacheConfiguration;
private CertificateCacheConfiguration certificateCacheConfiguration;
private OperationAnalyticsConfiguration operationAnalyticsConfiguration;
private GeoLocationConfiguration geoLocationConfiguration;
private String defaultGroupsConfiguration;
private RemoteSessionConfiguration remoteSessionConfiguration;
private ArchivalConfiguration archivalConfiguration;
@ -167,6 +169,15 @@ public final class DeviceManagementConfig {
this.operationAnalyticsConfiguration = operationAnalyticsConfiguration;
}
@XmlElement(name = "GeoLocationConfiguration", required = true)
public GeoLocationConfiguration getGeoLocationConfiguration() {
return geoLocationConfiguration;
}
public void setGeoLocationConfiguration(GeoLocationConfiguration geoLocationConfiguration) {
this.geoLocationConfiguration = geoLocationConfiguration;
}
@XmlElement(name = "DefaultGroupsConfiguration", required = true)
public String getDefaultGroupsConfiguration() {
return defaultGroupsConfiguration;

@ -0,0 +1,40 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* you may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.config.geo.location;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* This class represents the information related to Geo Location configuration.
*/
@XmlRootElement(name = "GeoLocationConfiguration")
public class GeoLocationConfiguration {
private boolean isEnabled;
public boolean getIsEnabled() {
return isEnabled;
}
@XmlElement(name = "isEnabled", required = true)
public void setIsEnabled(boolean isEnabled) {
this.isEnabled = isEnabled;
}
}

@ -27,24 +27,24 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "OperationAnalyticsConfiguration")
public class OperationAnalyticsConfiguration {
private boolean publishOperationResponse;
private boolean isEnabled;
private boolean publishDeviceInfoResponse;
private boolean publishLocationResponse;
public boolean getPublishOperationResponse() {
return publishOperationResponse;
public boolean getPublishDeviceInfoResponse() {
return publishDeviceInfoResponse;
}
@XmlElement(name = "PublishOperationResponse", required = true)
public void setPublishOperationResponse(boolean publishOperationResponse) {
this.publishOperationResponse = publishOperationResponse;
@XmlElement(name = "PublishDeviceInfoResponse", required = true)
public void setPublishDeviceInfoResponse(boolean publishDeviceInfoResponse) {
this.publishDeviceInfoResponse = publishDeviceInfoResponse;
}
public boolean getIsEnabled() {
return isEnabled;
public boolean getPublishLocationResponse() {
return publishLocationResponse;
}
@XmlElement(name = "isEnabled", required = true)
public void setEnabled(boolean enabled) {
isEnabled = enabled;
@XmlElement(name = "PublishLocationResponse", required = true)
public void setPublishLocationResponse(boolean publishLocationResponse) {
this.publishLocationResponse = publishLocationResponse;
}
}

@ -74,7 +74,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
deviceDetailsDAO.addDeviceProperties(deviceInfo.getDeviceDetailsMap(), device.getId());
DeviceManagementDAOFactory.commitTransaction();
if (DeviceManagerUtil.isPublishOperationResponseEnabled()) {
if (DeviceManagerUtil.isPublishDeviceInfoResponseEnabled()) {
Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
Object[] payload = new Object[]{
Calendar.getInstance().getTimeInMillis(),
@ -192,7 +192,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
deviceDetailsDAO.deleteDeviceLocation(deviceLocation.getDeviceId());
deviceDetailsDAO.addDeviceLocation(deviceLocation);
if (DeviceManagerUtil.isPublishOperationResponseEnabled()) {
if (DeviceManagerUtil.isPublishLocationResponseEnabled()) {
Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
Object[] payload = new Object[]{
deviceLocation.getUpdatedTime().getTime(),

@ -31,7 +31,6 @@ 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.device.details.DeviceInfo;
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;
@ -416,23 +415,22 @@ public final class DeviceManagerUtil {
return limit;
}
public static boolean isOperationAnalyticsEnabled() throws DeviceManagementException {
public static boolean isPublishLocationResponseEnabled() throws DeviceManagementException {
DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().
getDeviceManagementConfig();
if (deviceManagementConfig != null) {
return deviceManagementConfig.getOperationAnalyticsConfiguration().getIsEnabled();
return deviceManagementConfig.getOperationAnalyticsConfiguration().getPublishLocationResponse();
} else {
throw new DeviceManagementException("Device-Mgt configuration has not initialized. Please check the " +
"cdm-config.xml file.");
"cdm-config.xml file.");
}
}
public static boolean isPublishOperationResponseEnabled() throws DeviceManagementException {
public static boolean isPublishDeviceInfoResponseEnabled() throws DeviceManagementException {
DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().
getDeviceManagementConfig();
if (deviceManagementConfig != null) {
return isOperationAnalyticsEnabled()
&& deviceManagementConfig.getOperationAnalyticsConfiguration().getPublishOperationResponse();
return deviceManagementConfig.getOperationAnalyticsConfiguration().getPublishDeviceInfoResponse();
} else {
throw new DeviceManagementException("Device-Mgt configuration has not initialized. Please check the " +
"cdm-config.xml file.");

@ -88,9 +88,24 @@
<Enable>false</Enable>
<ExpiryTime>86400</ExpiryTime>
</CertificateCacheConfiguration>
<OperationAnalyticsConfiguration>
<GeoLocationConfiguration>
<isEnabled>false</isEnabled>
<PublishOperationResponse>false</PublishOperationResponse>
</GeoLocationConfiguration>
<OperationAnalyticsConfiguration>
<PublishLocationResponse>false</PublishLocationResponse>
<PublishDeviceInfoResponse>false</PublishDeviceInfoResponse>
<PublishOperationResponse>
<isEnabled>false</isEnabled>
<operations>
<!-- Publish specific operation responses -->
<!--
<operation>BATTERY_LEVEL</operation>
<operation>CHECK_LOCK_STATUS</operation>
-->
<!-- use wildcard '*' to publish all responses -->
<operation>*</operation>
</operations>
</PublishOperationResponse>
</OperationAnalyticsConfiguration>
<DefaultGroupsConfiguration>BYOD,COPE</DefaultGroupsConfiguration>
</DeviceMgtConfiguration>

@ -73,7 +73,7 @@ deviceModule = function () {
}
var userName = carbonUser.username + "@" + carbonUser.domain;
var locationHistory = [];
var geoServicesEnabled = devicemgtProps.serverConfig.operationAnalyticsConfiguration.isEnabled;
var geoServicesEnabled = devicemgtProps.serverConfig.geoLocationConfiguration.isEnabled;
if (geoServicesEnabled) {
try {
var fromDate = new Date();

@ -70,7 +70,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
@PathParam("deviceType") String deviceType,
@QueryParam("from") long from, @QueryParam("to") long to) {
try {
if (!DeviceManagerUtil.isPublishOperationResponseEnabled()) {
if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) {
return Response.status(Response.Status.BAD_REQUEST.getStatusCode())
.entity("Unable to retrive Geo Device stats. Geo Data publishing does not enabled.").build();
}

@ -118,9 +118,24 @@
</PurgingTask>
</ArchivalTask>
</ArchivalConfiguration>
<OperationAnalyticsConfiguration>
<GeoLocationConfiguration>
<isEnabled>false</isEnabled>
<PublishOperationResponse>false</PublishOperationResponse>
</GeoLocationConfiguration>
<OperationAnalyticsConfiguration>
<PublishLocationResponse>false</PublishLocationResponse>
<PublishDeviceInfoResponse>false</PublishDeviceInfoResponse>
<PublishOperationResponse>
<isEnabled>false</isEnabled>
<operations>
<!-- Publish specific operation responses -->
<!--
<operation>BATTERY_LEVEL</operation>
<operation>CHECK_LOCK_STATUS</operation>
-->
<!-- use wildcard '*' to publish all responses -->
<operation>*</operation>
</operations>
</PublishOperationResponse>
</OperationAnalyticsConfiguration>
<!--This configuration used to configure the options for remote device control feature -->
<RemoteSessionConfiguration>

Loading…
Cancel
Save