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 bae7d9e84aa..01c4ef7d005 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
@@ -363,11 +363,11 @@
${carbon.identity.framework.version}
provided
-
- org.wso2.carbon.analytics
- org.wso2.carbon.analytics.dataservice.commons
- provided
-
+
+
+
+
+
org.wso2.carbon.analytics-common
org.wso2.carbon.event.receiver.stub
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java
index bafe13d742e..2207957a2ac 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java
@@ -27,12 +27,12 @@ import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpStatus;
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
-import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
-import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
-import org.wso2.carbon.analytics.dataservice.commons.SortByField;
-import org.wso2.carbon.analytics.dataservice.commons.SortType;
-import org.wso2.carbon.analytics.datasource.commons.Record;
-import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
+//import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
+//import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
+//import org.wso2.carbon.analytics.dataservice.commons.SortByField;
+//import org.wso2.carbon.analytics.dataservice.commons.SortType;
+//import org.wso2.carbon.analytics.datasource.commons.Record;
+//import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
@@ -120,40 +120,40 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
if (from != 0 || to != 0) {
query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]";
}
- try {
- if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
- new DeviceIdentifier(deviceId, deviceType),
- DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) {
- return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
- }
- List sortByFields = new ArrayList<>();
- SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
- sortByFields.add(sortByField);
+// try {
+// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
+// new DeviceIdentifier(deviceId, deviceType),
+// DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) {
+// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
+// }
+// List sortByFields = new ArrayList<>();
+// SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
+// sortByFields.add(sortByField);
// this is the user who initiates the request
- String authorizedUser = MultitenantUtils.getTenantAwareUsername(
- CarbonContext.getThreadLocalCarbonContext().getUsername());
+// String authorizedUser = MultitenantUtils.getTenantAwareUsername(
+// CarbonContext.getThreadLocalCarbonContext().getUsername());
- try {
- String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
- int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
+// try {
+// String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
- List searchResults = analyticsDataAPI.search(tenantId, tableName, query,
- 0,
- 100,
- sortByFields);
- List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(),
- searchResults);
- return Response.ok().entity(events).build();
- } catch (AnalyticsException | UserStoreException e) {
- log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
- throw DeviceMgtUtil.buildBadRequestException(
- Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
- }
- } catch (DeviceAccessAuthorizationException e) {
- log.error(e.getErrorMessage());
+// List searchResults = analyticsDataAPI.search(tenantId, tableName, query,
+// 0,
+// 100,
+// sortByFields);
+// List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(),
+// searchResults);
+// return Response.ok().entity(events).build();
+// } catch (AnalyticsException | UserStoreException e) {
+// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
+// throw DeviceMgtUtil.buildBadRequestException(
+// Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
+// }
+// } catch (DeviceAccessAuthorizationException e) {
+// log.error(e.getErrorMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
- }
+// }
}
@Path("stats/device-locations")
@@ -559,40 +559,40 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
if (from != 0 || to != 0) {
query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]";
}
- try {
- if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
- new DeviceIdentifier(deviceId, deviceType),
- DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) {
- return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
- }
- List sortByFields = new ArrayList<>();
- SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
- sortByFields.add(sortByField);
+// try {
+// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
+// new DeviceIdentifier(deviceId, deviceType),
+// DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) {
+// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
+// }
+// List sortByFields = new ArrayList<>();
+// SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
+// sortByFields.add(sortByField);
// this is the user who initiates the request
- String authorizedUser = MultitenantUtils.getTenantAwareUsername(
- CarbonContext.getThreadLocalCarbonContext().getUsername());
-
- try {
- String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
- int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
- AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
- List searchResults = analyticsDataAPI.search(tenantId, tableName, query,
- 0,
- 100,
- sortByFields);
- List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(),
- searchResults);
- return Response.ok().entity(events).build();
- } catch (AnalyticsException | UserStoreException e) {
- log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
- throw DeviceMgtUtil.buildBadRequestException(
- Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
- }
- } catch (DeviceAccessAuthorizationException e) {
- log.error(e.getErrorMessage());
+// String authorizedUser = MultitenantUtils.getTenantAwareUsername(
+// CarbonContext.getThreadLocalCarbonContext().getUsername());
+
+// try {
+// String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
+// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
+// AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
+// List searchResults = analyticsDataAPI.search(tenantId, tableName, query,
+// 0,
+// 100,
+// sortByFields);
+// List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(),
+// searchResults);
+// return Response.ok().entity(events).build();
+// } catch (AnalyticsException | UserStoreException e) {
+// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
+// throw DeviceMgtUtil.buildBadRequestException(
+// Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
+// }
+// } catch (DeviceAccessAuthorizationException e) {
+// log.error(e.getErrorMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
- }
+// }
}
@Path("alerts/history")
@@ -607,80 +607,80 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
if (from != 0 || to != 0) {
query = "timeStamp : [" + fromDate + " TO " + toDate + "]";
}
- try {
- List sortByFields = new ArrayList<>();
- SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
- sortByFields.add(sortByField);
-
- // this is the user who initiates the request
- String authorizedUser = MultitenantUtils.getTenantAwareUsername(
- CarbonContext.getThreadLocalCarbonContext().getUsername());
-
- String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
- int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
- AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
- List searchResults = analyticsDataAPI.search(tenantId, tableName, query,
- 0,
- 100,
- sortByFields);
- List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(),
- searchResults);
- return Response.ok().entity(events).build();
-
- } catch (AnalyticsException | UserStoreException e) {
- log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
+// try {
+// List sortByFields = new ArrayList<>();
+// SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
+// sortByFields.add(sortByField);
+//
+// // this is the user who initiates the request
+// String authorizedUser = MultitenantUtils.getTenantAwareUsername(
+// CarbonContext.getThreadLocalCarbonContext().getUsername());
+//
+// String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
+// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
+// AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
+// List searchResults = analyticsDataAPI.search(tenantId, tableName, query,
+// 0,
+// 100,
+// sortByFields);
+// List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(),
+// searchResults);
+// return Response.ok().entity(events).build();
+//
+// } catch (AnalyticsException | UserStoreException e) {
+// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
throw DeviceMgtUtil.buildBadRequestException(
Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
- }
- }
-
- private List getEventBeans(AnalyticsDataAPI analyticsDataAPI, int tenantId, String tableName,
- List columns,
- List searchResults) throws AnalyticsException {
- List ids = getIds(searchResults);
- List requiredColumns = (columns == null || columns.isEmpty()) ? null : columns;
- AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, requiredColumns, ids);
- List records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
- Map eventBeanMap = getEventBeanKeyedWithIds(records);
- return getSortedEventBeans(eventBeanMap, searchResults);
- }
-
- private List getSortedEventBeans(Map eventBeanMap,
- List searchResults) {
- List sortedRecords = new ArrayList<>();
- for (SearchResultEntry entry : searchResults) {
- sortedRecords.add(eventBeanMap.get(entry.getId()));
- }
- return sortedRecords;
+// }
}
- private Map getEventBeanKeyedWithIds(List records) {
- Map eventBeanMap = new HashMap<>();
- for (Record record : records) {
- Event event = getEventBean(record);
- eventBeanMap.put(event.getId(), event);
- }
- return eventBeanMap;
- }
-
- private List getIds(List searchResults) {
- List ids = new ArrayList<>();
- if (searchResults != null) {
- for (SearchResultEntry resultEntry : searchResults) {
- ids.add(resultEntry.getId());
- }
- }
- return ids;
- }
-
- private static Event getEventBean(Record record) {
- Event eventBean = new Event();
- eventBean.setId(record.getId());
- eventBean.setTableName(record.getTableName());
- eventBean.setTimestamp(record.getTimestamp());
- eventBean.setValues(record.getValues());
- return eventBean;
- }
+// private List getEventBeans(AnalyticsDataAPI analyticsDataAPI, int tenantId, String tableName,
+// List columns,
+// List searchResults) throws AnalyticsException {
+// List ids = getIds(searchResults);
+// List requiredColumns = (columns == null || columns.isEmpty()) ? null : columns;
+// AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, requiredColumns, ids);
+// List records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
+// Map eventBeanMap = getEventBeanKeyedWithIds(records);
+// return getSortedEventBeans(eventBeanMap, searchResults);
+// }
+//
+// private List getSortedEventBeans(Map eventBeanMap,
+// List searchResults) {
+// List sortedRecords = new ArrayList<>();
+// for (SearchResultEntry entry : searchResults) {
+// sortedRecords.add(eventBeanMap.get(entry.getId()));
+// }
+// return sortedRecords;
+// }
+//
+// private Map getEventBeanKeyedWithIds(List records) {
+// Map eventBeanMap = new HashMap<>();
+// for (Record record : records) {
+// Event event = getEventBean(record);
+// eventBeanMap.put(event.getId(), event);
+// }
+// return eventBeanMap;
+// }
+//
+// private List getIds(List searchResults) {
+// List ids = new ArrayList<>();
+// if (searchResults != null) {
+// for (SearchResultEntry resultEntry : searchResults) {
+// ids.add(resultEntry.getId());
+// }
+// }
+// return ids;
+// }
+//
+// private static Event getEventBean(Record record) {
+// Event eventBean = new Event();
+// eventBean.setId(record.getId());
+// eventBean.setTableName(record.getTableName());
+// eventBean.setTimestamp(record.getTimestamp());
+// eventBean.setValues(record.getValues());
+// return eventBean;
+// }
@Path("/geo-fence")
@POST