Merge branch 'master' of https://github.com/wso2/carbon-device-mgt into cloud-3.1.0

revert-70aa11f8
geethkokila 8 years ago
commit 275f413652

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -3,7 +3,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId>
<version>2.0.12-SNAPSHOT</version>
<version>2.0.15-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -62,6 +62,7 @@
</Private-Package>
<Export-Package>
org.wso2.carbon.device.mgt.analytics.dashboard,
org.wso2.carbon.device.mgt.analytics.dashboard.util,
org.wso2.carbon.device.mgt.analytics.dashboard.exception,
org.wso2.carbon.device.mgt.analytics.dashboard.bean
</Export-Package>

@ -47,7 +47,7 @@ public interface GadgetDataService {
* executing SQL query and retrieving data.
*/
@SuppressWarnings("unused")
DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet)
DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException;
/**
@ -64,7 +64,7 @@ public interface GadgetDataService {
* executing SQL query and retrieving data.
*/
@SuppressWarnings("unused")
DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet)
DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet, String userName)
throws InvalidFeatureCodeValueException, DataAccessLayerException;
/**
@ -74,7 +74,7 @@ public interface GadgetDataService {
* executing SQL query and retrieving data.
*/
@SuppressWarnings("unused")
DeviceCountByGroup getTotalDeviceCount() throws DataAccessLayerException;
DeviceCountByGroup getTotalDeviceCount(String userName) throws DataAccessLayerException;
/**
* This method is used to get device counts classified by connectivity statuses.
@ -83,7 +83,7 @@ public interface GadgetDataService {
* executing SQL query and retrieving data.
*/
@SuppressWarnings("unused")
List<DeviceCountByGroup> getDeviceCountsByConnectivityStatuses() throws DataAccessLayerException;
List<DeviceCountByGroup> getDeviceCountsByConnectivityStatuses(String userName) throws DataAccessLayerException;
/**
* This method is used to get device counts classified by potential vulnerabilities.
@ -92,7 +92,7 @@ public interface GadgetDataService {
* executing SQL query and retrieving data.
*/
@SuppressWarnings("unused")
List<DeviceCountByGroup> getDeviceCountsByPotentialVulnerabilities() throws DataAccessLayerException;
List<DeviceCountByGroup> getDeviceCountsByPotentialVulnerabilities(String userName) throws DataAccessLayerException;
/**
* This method is used to get non-compliant device counts classified by individual features.
@ -105,7 +105,7 @@ public interface GadgetDataService {
* executing SQL query and retrieving data.
*/
@SuppressWarnings("unused")
PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) throws
PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName) throws
InvalidStartIndexValueException, InvalidResultCountValueException, DataAccessLayerException;
/**
@ -122,7 +122,7 @@ public interface GadgetDataService {
* executing SQL query and retrieving data.
*/
@SuppressWarnings("unused")
List<DeviceCountByGroup> getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet)
List<DeviceCountByGroup> getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException;
/**
@ -139,7 +139,7 @@ public interface GadgetDataService {
*/
@SuppressWarnings("unused")
List<DeviceCountByGroup> getFeatureNonCompliantDeviceCountsByPlatforms(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException,
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException,
DataAccessLayerException;
/**
@ -156,7 +156,7 @@ public interface GadgetDataService {
* executing SQL query and retrieving data.
*/
@SuppressWarnings("unused")
List<DeviceCountByGroup> getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet)
List<DeviceCountByGroup> getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException;
/**
@ -174,7 +174,7 @@ public interface GadgetDataService {
*/
@SuppressWarnings("unused")
List<DeviceCountByGroup> getFeatureNonCompliantDeviceCountsByOwnershipTypes(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException,
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException,
DataAccessLayerException;
/**
@ -196,7 +196,7 @@ public interface GadgetDataService {
* @throws InvalidResultCountValueException This can occur if resultCount value is lesser than its minimum (5).
*/
@SuppressWarnings("unused")
PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount)
PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName)
throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException,
InvalidStartIndexValueException, InvalidResultCountValueException;
@ -220,7 +220,7 @@ public interface GadgetDataService {
*/
@SuppressWarnings("unused")
PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, BasicFilterSet basicFilterSet,
int startIndex, int resultCount) throws InvalidFeatureCodeValueException,
int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException,
DataAccessLayerException, InvalidStartIndexValueException,
InvalidResultCountValueException;
@ -238,7 +238,7 @@ public interface GadgetDataService {
* executing SQL query and retrieving data.
*/
@SuppressWarnings("unused")
List<DeviceWithDetails> getDevicesWithDetails(ExtendedFilterSet extendedFilterSet)
List<DeviceWithDetails> getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException;
/**
@ -255,7 +255,7 @@ public interface GadgetDataService {
*/
@SuppressWarnings("unused")
List<DeviceWithDetails> getFeatureNonCompliantDevicesWithDetails(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException,
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException,
DataAccessLayerException;
}

@ -18,13 +18,16 @@
package org.wso2.carbon.device.mgt.analytics.dashboard.dao;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.BasicFilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceWithDetails;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.ExtendedFilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.exception.InvalidFeatureCodeValueException;
import org.wso2.carbon.device.mgt.analytics.dashboard.exception.InvalidPotentialVulnerabilityValueException;
import org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import java.sql.Connection;
@ -36,40 +39,39 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil.getAuthenticatedUser;
import static org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil.getAuthenticatedUserTenantDomainId;
public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceDAO {
private static final Log log = LogFactory.getLog(AbstractGadgetDataServiceDAO.class);
@Override
public DeviceCountByGroup getTotalDeviceCount() throws SQLException {
public DeviceCountByGroup getTotalDeviceCount(String userName) throws SQLException {
int totalDeviceCount;
try {
totalDeviceCount = this.getFilteredDeviceCount(null);
totalDeviceCount = this.getFilteredDeviceCount(null, userName);
} catch (InvalidPotentialVulnerabilityValueException e) {
throw new AssertionError(e);
}
DeviceCountByGroup deviceCountByGroup = new DeviceCountByGroup();
deviceCountByGroup.setGroup("total");
deviceCountByGroup.setDisplayNameForGroup("Total");
deviceCountByGroup.setDeviceCount(totalDeviceCount);
return deviceCountByGroup;
}
@Override
public DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet)
public DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, SQLException {
int filteredDeviceCount = this.getFilteredDeviceCount(extendedFilterSet);
int filteredDeviceCount = this.getFilteredDeviceCount(extendedFilterSet, userName);
DeviceCountByGroup deviceCountByGroup = new DeviceCountByGroup();
deviceCountByGroup.setGroup("filtered");
deviceCountByGroup.setDisplayNameForGroup("Filtered");
deviceCountByGroup.setDeviceCount(filteredDeviceCount);
return deviceCountByGroup;
}
private int getFilteredDeviceCount(ExtendedFilterSet extendedFilterSet)
private int getFilteredDeviceCount(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, SQLException {
Map<String, Object> filters = this.extractDatabaseFiltersFromBean(extendedFilterSet);
@ -77,24 +79,37 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
int filteredDeviceCount = 0;
try {
String sql;
con = this.getConnection();
String sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ?";
if (APIUtil.isDeviceAdminUser()) {
sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO WHERE TENANT_ID = ?";
} else {
sql = "SELECT COUNT(POLICY__INFO.DEVICE_ID) AS DEVICE_COUNT FROM "
+ GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO INNER JOIN" +
" DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND " +
" POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? ";
}
// appending filters to support advanced filtering options
// [1] appending filter columns
if (filters != null && filters.size() > 0) {
for (String column : filters.keySet()) {
sql = sql + " AND " + column + " = ?";
sql = sql + " AND POLICY__INFO." + column + " = ? ";
}
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt = con.prepareStatement(sql);
stmt.setInt(1, tenantId);
int index = 2;
if (!APIUtil.isDeviceAdminUser()) {
stmt.setString(2, userName);
index = 3;
}
if (filters != null && filters.values().size() > 0) {
int i = 2;
int i = index;
for (Object value : filters.values()) {
if (value instanceof Integer) {
stmt.setInt(i, (Integer) value);
@ -110,6 +125,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
while (rs.next()) {
filteredDeviceCount = rs.getInt("DEVICE_COUNT");
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -118,7 +136,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException {
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException {
if (featureCode == null || featureCode.isEmpty()) {
throw new InvalidFeatureCodeValueException("Feature code should not be either null or empty.");
@ -129,25 +147,39 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
int filteredDeviceCount = 0;
try {
String sql;
con = this.getConnection();
String sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? AND FEATURE_CODE = ?";
if (APIUtil.isDeviceAdminUser()) {
sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO WHERE TENANT_ID =" +
" ? AND FEATURE_CODE = ?";
} else {
sql = "SELECT COUNT(FEATURE_INFO.DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO INNER JOIN " +
"DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID AND " +
"FEATURE_INFO.TENANT_ID = ? AND FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? ";
}
// appending filters to support advanced filtering options
// [1] appending filter columns
if (filters != null && filters.size() > 0) {
for (String column : filters.keySet()) {
sql = sql + " AND " + column + " = ?";
sql = sql + " AND FEATURE_INFO." + column + " = ?";
}
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt.setInt(1, tenantId);
stmt.setString(2, featureCode);
int index = 3;
if (!APIUtil.isDeviceAdminUser()) {
stmt.setString(3, userName);
index = 4;
}
if (filters != null && filters.values().size() > 0) {
int i = 3;
int i = index;
for (Object value : filters.values()) {
if (value instanceof Integer) {
stmt.setInt(i, (Integer) value);
@ -163,6 +195,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
while (rs.next()) {
filteredDeviceCount = rs.getInt("DEVICE_COUNT");
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -176,20 +211,32 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
}
@Override
public List<DeviceCountByGroup> getDeviceCountsByConnectivityStatuses() throws SQLException {
public List<DeviceCountByGroup> getDeviceCountsByConnectivityStatuses(String userName) throws SQLException {
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
List<DeviceCountByGroup> deviceCountsByConnectivityStatuses = new ArrayList<>();
try {
String sql;
con = this.getConnection();
String sql = "SELECT CONNECTIVITY_STATUS, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 +
" WHERE TENANT_ID = ? GROUP BY CONNECTIVITY_STATUS";
if (APIUtil.isDeviceAdminUser()) {
sql = "SELECT CONNECTIVITY_STATUS, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 +
" WHERE TENANT_ID = ? GROUP BY CONNECTIVITY_STATUS";
} else {
sql = "SELECT POLICY__INFO.CONNECTIVITY_STATUS AS CONNECTIVITY_STATUS, " +
"COUNT(POLICY__INFO.DEVICE_ID) AS DEVICE_COUNT FROM "
+ GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO " +
"INNER JOIN DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID " +
" AND POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? GROUP BY POLICY__INFO.CONNECTIVITY_STATUS";
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt.setInt(1, tenantId);
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(2, userName);
}
// executing query
rs = stmt.executeQuery();
// fetching query results
@ -201,6 +248,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
deviceCountByConnectivityStatus.setDeviceCount(rs.getInt("DEVICE_COUNT"));
deviceCountsByConnectivityStatuses.add(deviceCountByConnectivityStatus);
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -208,7 +258,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
}
@Override
public List<DeviceCountByGroup> getDeviceCountsByPotentialVulnerabilities() throws SQLException {
public List<DeviceCountByGroup> getDeviceCountsByPotentialVulnerabilities(String userName) throws SQLException {
// getting non-compliant device count
DeviceCountByGroup nonCompliantDeviceCount = new DeviceCountByGroup();
nonCompliantDeviceCount.setGroup(GadgetDataServiceDAOConstants.PotentialVulnerability.NON_COMPLIANT);
@ -230,10 +280,10 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
private int getNonCompliantDeviceCount() throws SQLException {
ExtendedFilterSet extendedFilterSet = new ExtendedFilterSet();
extendedFilterSet.setPotentialVulnerability(GadgetDataServiceDAOConstants.
PotentialVulnerability.NON_COMPLIANT);
extendedFilterSet.setPotentialVulnerability(GadgetDataServiceDAOConstants.PotentialVulnerability.NON_COMPLIANT);
try {
return this.getFilteredDeviceCount(extendedFilterSet);
String userName = getAuthenticatedUser();
return this.getFilteredDeviceCount(extendedFilterSet, userName);
} catch (InvalidPotentialVulnerabilityValueException e) {
throw new AssertionError(e);
}
@ -244,14 +294,15 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
extendedFilterSet.setPotentialVulnerability(GadgetDataServiceDAOConstants.
PotentialVulnerability.UNMONITORED);
try {
return this.getFilteredDeviceCount(extendedFilterSet);
String userName = getAuthenticatedUser();
return this.getFilteredDeviceCount(extendedFilterSet, userName);
} catch (InvalidPotentialVulnerabilityValueException e) {
throw new AssertionError(e);
}
}
@Override
public List<DeviceCountByGroup> getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet)
public List<DeviceCountByGroup> getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, SQLException {
Map<String, Object> filters = this.extractDatabaseFiltersFromBean(extendedFilterSet);
@ -259,7 +310,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
List<DeviceCountByGroup> filteredDeviceCountsByPlatforms = new ArrayList<>();
try {
con = this.getConnection();
@ -268,16 +319,30 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
// [1] appending filter columns, if exist
if (filters != null && filters.size() > 0) {
for (String column : filters.keySet()) {
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
advancedSqlFiltering = advancedSqlFiltering + " AND POLICY__INFO." + column + " = ? ";
}
}
sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ? " + advancedSqlFiltering + "GROUP BY PLATFORM";
if (APIUtil.isDeviceAdminUser()) {
sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO WHERE TENANT_ID = ? " + advancedSqlFiltering +
" GROUP BY PLATFORM";
} else {
sql = "SELECT POLICY__INFO.PLATFORM, COUNT(POLICY__INFO.DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO INNER JOIN " +
"DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND " +
"POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? " + advancedSqlFiltering + " GROUP BY " +
"POLICY__INFO.PLATFORM";
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt.setInt(1, tenantId);
int index = 2;
if (!APIUtil.isDeviceAdminUser()) {
stmt.setString(2, userName);
index = 3;
}
if (filters != null && filters.values().size() > 0) {
int i = 2;
int i = index;
for (Object value : filters.values()) {
if (value instanceof Integer) {
stmt.setInt(i, (Integer) value);
@ -298,6 +363,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceCountByPlatform.setDeviceCount(rs.getInt("DEVICE_COUNT"));
filteredDeviceCountsByPlatforms.add(filteredDeviceCountByPlatform);
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -307,7 +375,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public List<DeviceCountByGroup>
getFeatureNonCompliantDeviceCountsByPlatforms(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException {
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException {
if (featureCode == null || featureCode.isEmpty()) {
throw new InvalidFeatureCodeValueException("Feature code should not be either null or empty.");
@ -318,7 +386,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
List<DeviceCountByGroup> filteredDeviceCountsByPlatforms = new ArrayList<>();
try {
con = this.getConnection();
@ -327,18 +395,32 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
// [1] appending filter columns, if exist
if (filters != null && filters.size() > 0) {
for (String column : filters.keySet()) {
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
advancedSqlFiltering = advancedSqlFiltering + " AND FEATURE_INFO." + column + " = ? ";
}
}
sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? AND FEATURE_CODE = ? " +
advancedSqlFiltering + "GROUP BY PLATFORM";
if (APIUtil.isDeviceAdminUser()) {
sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO WHERE TENANT_ID = ? AND FEATURE_CODE = ? " +
advancedSqlFiltering + " GROUP BY PLATFORM";
} else {
sql = "SELECT FEATURE_INFO.PLATFORM, COUNT(FEATURE_INFO.DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO INNER JOIN " +
"DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID " +
" AND FEATURE_INFO.TENANT_ID = ? AND FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? " +
advancedSqlFiltering + " GROUP BY FEATURE_INFO.PLATFORM";
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt.setInt(1, tenantId);
stmt.setString(2, featureCode);
int index = 3;
if (!APIUtil.isDeviceAdminUser()) {
stmt.setString(3, userName);
index = 4;
}
if (filters != null && filters.values().size() > 0) {
int i = 3;
int i = index;
for (Object value : filters.values()) {
if (value instanceof Integer) {
stmt.setInt(i, (Integer) value);
@ -359,6 +441,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceCountByPlatform.setDeviceCount(rs.getInt("DEVICE_COUNT"));
filteredDeviceCountsByPlatforms.add(filteredDeviceCountByPlatform);
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -366,7 +451,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
}
@Override
public List<DeviceCountByGroup> getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet)
public List<DeviceCountByGroup> getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, SQLException {
Map<String, Object> filters = this.extractDatabaseFiltersFromBean(extendedFilterSet);
@ -374,7 +459,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
List<DeviceCountByGroup> filteredDeviceCountsByOwnershipTypes = new ArrayList<>();
try {
con = this.getConnection();
@ -383,17 +468,29 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
// [1] appending filter columns, if exist
if (filters != null && filters.size() > 0) {
for (String column : filters.keySet()) {
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
advancedSqlFiltering = advancedSqlFiltering + " AND POLICY__INFO." + column + " = ? ";
}
}
sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ? " +
advancedSqlFiltering + "GROUP BY OWNERSHIP";
if(APIUtil.isDeviceAdminUser()){
sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO WHERE TENANT_ID = ? " +
advancedSqlFiltering + "GROUP BY OWNERSHIP";
}else{
sql = "SELECT POLICY__INFO.OWNERSHIP, COUNT(POLICY__INFO.DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO INNER JOIN " +
"DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND POLICY__INFO.TENANT_ID" +
" = ? AND ENR_DB.OWNER = ? " + advancedSqlFiltering + " GROUP BY POLICY__INFO.OWNERSHIP";
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt.setInt(1, tenantId);
int index = 2;
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(2, userName);
index = 3;
}
if (filters != null && filters.values().size() > 0) {
int i = 2;
int i = index;
for (Object value : filters.values()) {
if (value instanceof Integer) {
stmt.setInt(i, (Integer) value);
@ -414,6 +511,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceCountByOwnershipType.setDeviceCount(rs.getInt("DEVICE_COUNT"));
filteredDeviceCountsByOwnershipTypes.add(filteredDeviceCountByOwnershipType);
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -423,7 +523,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public List<DeviceCountByGroup>
getFeatureNonCompliantDeviceCountsByOwnershipTypes(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException {
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException {
if (featureCode == null || featureCode.isEmpty()) {
throw new InvalidFeatureCodeValueException("Feature code should not be either null or empty.");
@ -434,7 +534,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
List<DeviceCountByGroup> filteredDeviceCountsByOwnershipTypes = new ArrayList<>();
try {
con = this.getConnection();
@ -443,18 +543,31 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
// [1] appending filter columns, if exist
if (filters != null && filters.size() > 0) {
for (String column : filters.keySet()) {
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
advancedSqlFiltering = advancedSqlFiltering + " AND FEATURE_INFO." + column + " = ? ";
}
}
sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? AND FEATURE_CODE = ? " +
advancedSqlFiltering + "GROUP BY OWNERSHIP";
if(APIUtil.isDeviceAdminUser()){
sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO WHERE TENANT_ID = ? AND FEATURE_CODE = ? " +
advancedSqlFiltering + "GROUP BY OWNERSHIP";
}else{
sql = "SELECT FEATURE_INFO.OWNERSHIP, COUNT(FEATURE_INFO.DEVICE_ID) AS DEVICE_COUNT FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO INNER JOIN " +
"DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID AND FEATURE_INFO.TENANT_ID " +
"= ? AND FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? " + advancedSqlFiltering
+ " GROUP BY FEATURE_INFO.OWNERSHIP";
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt.setInt(1, tenantId);
stmt.setString(2, featureCode);
int index = 3;
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(3, userName);
index = 4;
}
if (filters != null && filters.values().size() > 0) {
int i = 3;
int i = index;
for (Object value : filters.values()) {
if (value instanceof Integer) {
stmt.setInt(i, (Integer) value);
@ -475,6 +588,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceCountByOwnershipType.setDeviceCount(rs.getInt("DEVICE_COUNT"));
filteredDeviceCountsByOwnershipTypes.add(filteredDeviceCountByOwnershipType);
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -482,7 +598,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
}
@Override
public List<DeviceWithDetails> getDevicesWithDetails(ExtendedFilterSet extendedFilterSet)
public List<DeviceWithDetails> getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, SQLException {
Map<String, Object> filters = this.extractDatabaseFiltersFromBean(extendedFilterSet);
@ -490,25 +606,38 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
List<DeviceWithDetails> filteredDevicesWithDetails = new ArrayList<>();
try {
con = this.getConnection();
String sql;
sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ?";
if(APIUtil.isDeviceAdminUser()){
sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO WHERE TENANT_ID = ?";
}else{
sql = "SELECT POLICY__INFO.DEVICE_ID, POLICY__INFO.DEVICE_IDENTIFICATION, POLICY__INFO.PLATFORM," +
" POLICY__INFO.OWNERSHIP, POLICY__INFO.CONNECTIVITY_STATUS FROM "+
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1+" POLICY__INFO INNER JOIN " +
"DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND " +
"POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ?";
}
// appending filters to support advanced filtering options
// [1] appending filter columns, if exist
if (filters != null && filters.size() > 0) {
for (String column : filters.keySet()) {
sql = sql + " AND " + column + " = ?";
sql = sql + " AND POLICY__INFO." + column + " = ?";
}
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt.setInt(1, tenantId);
int index = 2;
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(2, userName);
index = 3;
}
if (filters != null && filters.values().size() > 0) {
int i = 2;
int i = index;
for (Object value : filters.values()) {
if (value instanceof Integer) {
stmt.setInt(i, (Integer) value);
@ -531,6 +660,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceWithDetails.setConnectivityStatus(rs.getString("CONNECTIVITY_STATUS"));
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -539,7 +671,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public List<DeviceWithDetails> getFeatureNonCompliantDevicesWithDetails(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException {
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException {
if (featureCode == null || featureCode.isEmpty()) {
throw new InvalidFeatureCodeValueException("Feature code should not be either null or empty.");
@ -550,27 +682,40 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
List<DeviceWithDetails> filteredDevicesWithDetails = new ArrayList<>();
try {
con = this.getConnection();
String sql;
sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 +
" WHERE TENANT_ID = ? AND FEATURE_CODE = ?";
if(APIUtil.isDeviceAdminUser()){
sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 +
" WHERE TENANT_ID = ? AND FEATURE_CODE = ?";
}else{
sql = "SELECT FEATURE_INFO.DEVICE_ID, FEATURE_INFO.DEVICE_IDENTIFICATION, FEATURE_INFO.PLATFORM, " +
"FEATURE_INFO.OWNERSHIP, FEATURE_INFO.CONNECTIVITY_STATUS FROM "+
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2+" FEATURE_INFO INNER JOIN " +
"DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID AND FEATURE_INFO.TENANT_ID" +
" = ? AND FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? ";
}
// appending filters to support advanced filtering options
// [1] appending filter columns, if exist
if (filters != null && filters.size() > 0) {
for (String column : filters.keySet()) {
sql = sql + " AND " + column + " = ?";
sql = sql + " AND FEATURE_INFO." + column + " = ?";
}
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt.setInt(1, tenantId);
stmt.setString(2, featureCode);
int index = 3;
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(3, userName);
index = 4;
}
if (filters != null && filters.values().size() > 0) {
int i = 3;
int i = index;
for (Object value : filters.values()) {
if (value instanceof Integer) {
stmt.setInt(i, (Integer) value);
@ -593,6 +738,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceWithDetails.setConnectivityStatus(rs.getString("CONNECTIVITY_STATUS"));
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}

@ -30,45 +30,45 @@ import java.util.List;
public interface GadgetDataServiceDAO {
DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet)
DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, SQLException;
DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet)
DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet, String userName)
throws InvalidFeatureCodeValueException, SQLException;
DeviceCountByGroup getTotalDeviceCount() throws SQLException;
DeviceCountByGroup getTotalDeviceCount(String userName) throws SQLException;
List<DeviceCountByGroup> getDeviceCountsByConnectivityStatuses() throws SQLException;
List<DeviceCountByGroup> getDeviceCountsByConnectivityStatuses(String userName) throws SQLException;
List<DeviceCountByGroup> getDeviceCountsByPotentialVulnerabilities() throws SQLException;
List<DeviceCountByGroup> getDeviceCountsByPotentialVulnerabilities(String userName) throws SQLException;
PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) throws
PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName) throws
InvalidStartIndexValueException, InvalidResultCountValueException, SQLException;
List<DeviceCountByGroup> getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet)
List<DeviceCountByGroup> getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, SQLException;
List<DeviceCountByGroup> getFeatureNonCompliantDeviceCountsByPlatforms(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException;
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException;
List<DeviceCountByGroup> getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet)
List<DeviceCountByGroup> getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, SQLException;
List<DeviceCountByGroup> getFeatureNonCompliantDeviceCountsByOwnershipTypes(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException;
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException;
PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount)
PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName)
throws InvalidPotentialVulnerabilityValueException,
InvalidStartIndexValueException, InvalidResultCountValueException, SQLException;
PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, BasicFilterSet basicFilterSet,
int startIndex, int resultCount) throws InvalidFeatureCodeValueException,
int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException,
InvalidStartIndexValueException, InvalidResultCountValueException, SQLException;
List<DeviceWithDetails> getDevicesWithDetails(ExtendedFilterSet extendedFilterSet)
List<DeviceWithDetails> getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, SQLException;
List<DeviceWithDetails> getFeatureNonCompliantDevicesWithDetails(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException;
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException;
}

@ -18,7 +18,8 @@
package org.wso2.carbon.device.mgt.analytics.dashboard.dao.impl;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceWithDetails;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.BasicFilterSet;
@ -26,7 +27,9 @@ import org.wso2.carbon.device.mgt.analytics.dashboard.bean.ExtendedFilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.AbstractGadgetDataServiceDAO;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOConstants;
import org.wso2.carbon.device.mgt.analytics.dashboard.exception.*;
import org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import java.sql.Connection;
@ -37,10 +40,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil.getAuthenticatedUserTenantDomainId;
public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO {
private static final Log log = LogFactory.getLog(GenericGadgetDataServiceDAOImpl.class);
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName)
throws InvalidStartIndexValueException, InvalidResultCountValueException, SQLException {
if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) {
@ -56,19 +63,33 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
List<DeviceCountByGroup> filteredNonCompliantDeviceCountsByFeatures = new ArrayList<>();
int totalRecordsCount = 0;
try {
String sql;
con = this.getConnection();
String sql = "SELECT FEATURE_CODE, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? GROUP BY FEATURE_CODE " +
"ORDER BY DEVICE_COUNT DESC LIMIT ?, ?";
if(APIUtil.isDeviceAdminUser()){
sql = "SELECT FEATURE_CODE, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? GROUP BY FEATURE_CODE " +
"ORDER BY DEVICE_COUNT DESC LIMIT ?, ?";
}else{
sql = "SELECT FEATURE_INFO.FEATURE_CODE, COUNT(FEATURE_INFO.DEVICE_ID) AS DEVICE_COUNT " +
"FROM "+GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2+" FEATURE_INFO INNER JOIN " +
"DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID AND " +
"FEATURE_INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? GROUP BY FEATURE_INFO.FEATURE_CODE ORDER BY" +
" DEVICE_COUNT DESC LIMIT ?, ?";
}
stmt = con.prepareStatement(sql);
stmt.setInt(1, tenantId);
stmt.setInt(2, startIndex);
stmt.setInt(3, resultCount);
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(2, userName);
stmt.setInt(3, startIndex);
stmt.setInt(4, resultCount);
}else{
stmt.setInt(2, startIndex);
stmt.setInt(3, resultCount);
}
// executing query
rs = stmt.executeQuery();
// fetching query results
@ -81,19 +102,30 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
filteredNonCompliantDeviceCountsByFeatures.add(filteredNonCompliantDeviceCountByFeature);
}
// fetching total records count
sql = "SELECT COUNT(FEATURE_CODE) AS NON_COMPLIANT_FEATURE_COUNT FROM (SELECT DISTINCT FEATURE_CODE FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ?) " +
"NON_COMPLIANT_FEATURE_CODE";
if(APIUtil.isDeviceAdminUser()){
sql = "SELECT COUNT(FEATURE_CODE) AS NON_COMPLIANT_FEATURE_COUNT FROM (SELECT DISTINCT FEATURE_CODE FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ?) " +
"NON_COMPLIANT_FEATURE_CODE";
}else{
sql = "SELECT COUNT(FEATURE_CODE) AS NON_COMPLIANT_FEATURE_COUNT FROM (SELECT DISTINCT " +
"FEATURE_INFO.FEATURE_CODE FROM "+GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2
+" FEATURE_INFO INNER JOIN DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID " +
"AND FEATURE_INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? ) NON_COMPLIANT_FEATURE_CODE";
}
stmt = con.prepareStatement(sql);
stmt.setInt(1, tenantId);
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(2, userName);
}
// executing query
rs = stmt.executeQuery();
// fetching query results
while (rs.next()) {
totalRecordsCount = rs.getInt("NON_COMPLIANT_FEATURE_COUNT");
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -105,7 +137,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
@Override
public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex,
int resultCount) throws InvalidPotentialVulnerabilityValueException,
int resultCount, String userName) throws InvalidPotentialVulnerabilityValueException,
InvalidStartIndexValueException, InvalidResultCountValueException, SQLException {
if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) {
@ -123,7 +155,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
List<DeviceWithDetails> filteredDevicesWithDetails = new ArrayList<>();
int totalRecordsCount = 0;
try {
@ -133,17 +165,31 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
// [1] appending filter columns, if exist
if (filters != null && filters.size() > 0) {
for (String column : filters.keySet()) {
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
advancedSqlFiltering = advancedSqlFiltering + " AND POLICY__INFO." + column + " = ? ";
}
}
sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ? " +
advancedSqlFiltering + "ORDER BY DEVICE_ID ASC LIMIT ?, ?";
if(APIUtil.isDeviceAdminUser()){
sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO WHERE TENANT_ID = ? " +
advancedSqlFiltering + "ORDER BY DEVICE_ID ASC LIMIT ?, ?";
}else{
sql = "SELECT POLICY__INFO.DEVICE_ID, POLICY__INFO.DEVICE_IDENTIFICATION, POLICY__INFO.PLATFORM, " +
"POLICY__INFO.OWNERSHIP, POLICY__INFO.CONNECTIVITY_STATUS FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO INNER JOIN DM_ENROLMENT " +
"ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND " +
"POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? " + advancedSqlFiltering + " ORDER BY " +
"POLICY__INFO.DEVICE_ID ASC LIMIT ?,?";
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt.setInt(1, tenantId);
int index = 2;
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(2, userName);
index = 3;
}
if (filters != null && filters.values().size() > 0) {
int i = 2;
int i = index;
for (Object value : filters.values()) {
if (value instanceof Integer) {
stmt.setInt(i, (Integer) value);
@ -155,8 +201,8 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
stmt.setInt(i, startIndex);
stmt.setInt(++i, resultCount);
} else {
stmt.setInt(2, startIndex);
stmt.setInt(3, resultCount);
stmt.setInt(3, startIndex);
stmt.setInt(4, resultCount);
}
// executing query
rs = stmt.executeQuery();
@ -171,20 +217,28 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
filteredDeviceWithDetails.setConnectivityStatus(rs.getString("CONNECTIVITY_STATUS"));
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
}
// fetching total records count
sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ?";
if(APIUtil.isDeviceAdminUser()){
sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ?";
}else{
sql = "SELECT COUNT(POLICY__INFO.DEVICE_ID) AS DEVICE_COUNT FROM "+GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_1+" POLICY__INFO INNER JOIN DM_ENROLMENT ENR_DB ON " +
"ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? ";
}
stmt = con.prepareStatement(sql);
stmt.setInt(1, tenantId);
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(2, userName);
}
// executing query
rs = stmt.executeQuery();
// fetching query results
while (rs.next()) {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -196,7 +250,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode,
BasicFilterSet basicFilterSet, int startIndex, int resultCount)
BasicFilterSet basicFilterSet, int startIndex, int resultCount, String userName)
throws InvalidFeatureCodeValueException, InvalidStartIndexValueException,
InvalidResultCountValueException, SQLException {
@ -219,7 +273,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int tenantId = getAuthenticatedUserTenantDomainId();
List<DeviceWithDetails> filteredDevicesWithDetails = new ArrayList<>();
int totalRecordsCount = 0;
try {
@ -229,19 +283,34 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
// [1] appending filter columns, if exist
if (filters != null && filters.size() > 0) {
for (String column : filters.keySet()) {
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
advancedSqlFiltering = advancedSqlFiltering + "AND FEATURE_INFO." + column + " = ? ";
}
}
sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " +
if(APIUtil.isDeviceAdminUser()){
sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 +
" WHERE TENANT_ID = ? AND FEATURE_CODE = ? " + advancedSqlFiltering +
" FEATURE_INFO WHERE TENANT_ID = ? AND FEATURE_CODE = ? " + advancedSqlFiltering +
"ORDER BY DEVICE_ID ASC LIMIT ?, ?";
}else{
sql = "SELECT FEATURE_INFO.DEVICE_ID, FEATURE_INFO.DEVICE_IDENTIFICATION, FEATURE_INFO.PLATFORM, " +
"FEATURE_INFO.OWNERSHIP, FEATURE_INFO.CONNECTIVITY_STATUS FROM " +
GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO INNER JOIN DM_ENROLMENT " +
"ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID " +
" AND FEATURE_INFO.TENANT_ID = ? AND FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? " +
advancedSqlFiltering + " ORDER BY DEVICE_ID ASC LIMIT ?,?";
}
stmt = con.prepareStatement(sql);
// [2] appending filter column values, if exist
stmt.setInt(1, tenantId);
stmt.setString(2, featureCode);
int index = 3;
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(3, userName);
index = 4;
}
if (filters != null && filters.values().size() > 0) {
int i = 3;
int i = index;
for (Object value : filters.values()) {
if (value instanceof Integer) {
stmt.setInt(i, (Integer) value);
@ -253,8 +322,8 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
stmt.setInt(i, startIndex);
stmt.setInt(++i, resultCount);
} else {
stmt.setInt(3, startIndex);
stmt.setInt(4, resultCount);
stmt.setInt(index, startIndex);
stmt.setInt(++index, resultCount);
}
// executing query
rs = stmt.executeQuery();
@ -269,21 +338,30 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
filteredDeviceWithDetails.setConnectivityStatus(rs.getString("CONNECTIVITY_STATUS"));
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
}
// fetching total records count
sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? AND FEATURE_CODE = ?";
if(APIUtil.isDeviceAdminUser()){
sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? AND FEATURE_CODE = ?";
}else{
sql = "SELECT COUNT(FEATURE_INFO.DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants.
DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO INNER JOIN DM_ENROLMENT ENR_DB ON " +
"ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID AND FEATURE_INFO.TENANT_ID = ? AND " +
"FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? ";
}
stmt = con.prepareStatement(sql);
stmt.setInt(1, tenantId);
stmt.setString(2, featureCode);
if(!APIUtil.isDeviceAdminUser()){
stmt.setString(3, userName);
}
// executing query
rs = stmt.executeQuery();
// fetching query results
while (rs.next()) {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while checking device access authorization";
log.error(msg, e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}

@ -40,7 +40,7 @@ import java.util.Map;
public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO {
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName)
throws InvalidStartIndexValueException, InvalidResultCountValueException, SQLException {
if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) {
@ -104,7 +104,7 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
}
@Override
public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount)
public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName)
throws InvalidPotentialVulnerabilityValueException,
InvalidStartIndexValueException,
InvalidResultCountValueException,
@ -198,7 +198,7 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode,
BasicFilterSet basicFilterSet, int startIndex, int resultCount)
BasicFilterSet basicFilterSet, int startIndex, int resultCount, String userName)
throws InvalidFeatureCodeValueException, InvalidStartIndexValueException,
InvalidResultCountValueException, SQLException {

@ -40,7 +40,7 @@ import java.util.Map;
public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO {
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName)
throws InvalidStartIndexValueException, InvalidResultCountValueException, SQLException {
if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) {
@ -105,7 +105,7 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
}
@Override
public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount)
public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName)
throws InvalidPotentialVulnerabilityValueException, InvalidStartIndexValueException,
InvalidResultCountValueException, SQLException {
@ -197,7 +197,7 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, BasicFilterSet basicFilterSet,
int startIndex, int resultCount) throws InvalidFeatureCodeValueException,
int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException,
InvalidStartIndexValueException, InvalidResultCountValueException, SQLException {
if (featureCode == null || featureCode.isEmpty()) {

@ -40,7 +40,7 @@ import java.util.Map;
public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO {
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName)
throws InvalidStartIndexValueException, InvalidResultCountValueException, SQLException {
if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) {
@ -105,7 +105,7 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic
}
@Override
public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount)
public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName)
throws InvalidPotentialVulnerabilityValueException, InvalidStartIndexValueException,
InvalidResultCountValueException, SQLException {
@ -198,7 +198,7 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, BasicFilterSet basicFilterSet,
int startIndex, int resultCount) throws InvalidFeatureCodeValueException,
int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException,
InvalidStartIndexValueException, InvalidResultCountValueException, SQLException {
if (featureCode == null || featureCode.isEmpty()) {

@ -36,13 +36,14 @@ import java.util.List;
public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet)
public DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException {
DeviceCountByGroup filteredDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
filteredDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDeviceCount(extendedFilterSet);
getDeviceCount(extendedFilterSet, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -53,13 +54,13 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet)
public DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet, String userName)
throws InvalidFeatureCodeValueException, DataAccessLayerException {
DeviceCountByGroup featureNonCompliantDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDeviceCount = GadgetDataServiceDAOFactory.
getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCount(featureCode, basicFilterSet);
getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCount(featureCode, basicFilterSet, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -70,11 +71,11 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public DeviceCountByGroup getTotalDeviceCount() throws DataAccessLayerException {
public DeviceCountByGroup getTotalDeviceCount(String userName) throws DataAccessLayerException {
DeviceCountByGroup totalDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
totalDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getTotalDeviceCount();
totalDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getTotalDeviceCount(userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -85,12 +86,12 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public List<DeviceCountByGroup> getDeviceCountsByConnectivityStatuses() throws DataAccessLayerException {
public List<DeviceCountByGroup> getDeviceCountsByConnectivityStatuses(String userName) throws DataAccessLayerException {
List<DeviceCountByGroup> deviceCountsByConnectivityStatuses;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCountsByConnectivityStatuses = GadgetDataServiceDAOFactory.
getGadgetDataServiceDAO().getDeviceCountsByConnectivityStatuses();
getGadgetDataServiceDAO().getDeviceCountsByConnectivityStatuses(userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -101,12 +102,12 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public List<DeviceCountByGroup> getDeviceCountsByPotentialVulnerabilities() throws DataAccessLayerException {
public List<DeviceCountByGroup> getDeviceCountsByPotentialVulnerabilities(String userName) throws DataAccessLayerException {
List<DeviceCountByGroup> deviceCountsByPotentialVulnerabilities;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCountsByPotentialVulnerabilities = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDeviceCountsByPotentialVulnerabilities();
getDeviceCountsByPotentialVulnerabilities(userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -117,14 +118,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName)
throws InvalidStartIndexValueException, InvalidResultCountValueException,
DataAccessLayerException {
PaginationResult paginationResult;
try {
GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getNonCompliantDeviceCountsByFeatures(startIndex, resultCount);
getNonCompliantDeviceCountsByFeatures(startIndex, resultCount, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -135,13 +136,13 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public List<DeviceCountByGroup> getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet)
public List<DeviceCountByGroup> getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException {
List<DeviceCountByGroup> deviceCountsByPlatforms;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCountsByPlatforms = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDeviceCountsByPlatforms(extendedFilterSet);
getDeviceCountsByPlatforms(extendedFilterSet, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -153,13 +154,13 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public List<DeviceCountByGroup> getFeatureNonCompliantDeviceCountsByPlatforms(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException,
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException,
DataAccessLayerException {
List<DeviceCountByGroup> featureNonCompliantDeviceCountsByPlatforms;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDeviceCountsByPlatforms = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDeviceCountsByPlatforms(featureCode, basicFilterSet);
getFeatureNonCompliantDeviceCountsByPlatforms(featureCode, basicFilterSet, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -170,14 +171,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public List<DeviceCountByGroup> getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet)
public List<DeviceCountByGroup> getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException,
DataAccessLayerException {
List<DeviceCountByGroup> deviceCountsByOwnershipTypes;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCountsByOwnershipTypes = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDeviceCountsByOwnershipTypes(extendedFilterSet);
getDeviceCountsByOwnershipTypes(extendedFilterSet, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -189,13 +190,13 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public List<DeviceCountByGroup>
getFeatureNonCompliantDeviceCountsByOwnershipTypes(String featureCode, BasicFilterSet basicFilterSet)
getFeatureNonCompliantDeviceCountsByOwnershipTypes(String featureCode, BasicFilterSet basicFilterSet, String userName)
throws InvalidFeatureCodeValueException, DataAccessLayerException {
List<DeviceCountByGroup> featureNonCompliantDeviceCountsByOwnershipTypes;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDeviceCountsByOwnershipTypes = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDeviceCountsByOwnershipTypes(featureCode, basicFilterSet);
getFeatureNonCompliantDeviceCountsByOwnershipTypes(featureCode, basicFilterSet, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -206,14 +207,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount)
public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName)
throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException,
InvalidStartIndexValueException, InvalidResultCountValueException {
PaginationResult paginationResult;
try {
GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDevicesWithDetails(extendedFilterSet, startIndex, resultCount);
getDevicesWithDetails(extendedFilterSet, startIndex, resultCount, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -225,14 +226,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, BasicFilterSet basicFilterSet,
int startIndex, int resultCount) throws InvalidFeatureCodeValueException,
int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException,
DataAccessLayerException, InvalidStartIndexValueException,
InvalidResultCountValueException {
PaginationResult paginationResult;
try {
GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDevicesWithDetails(featureCode, basicFilterSet, startIndex, resultCount);
getFeatureNonCompliantDevicesWithDetails(featureCode, basicFilterSet, startIndex, resultCount, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -243,13 +244,13 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public List<DeviceWithDetails> getDevicesWithDetails(ExtendedFilterSet extendedFilterSet)
public List<DeviceWithDetails> getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, String userName)
throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException {
List<DeviceWithDetails> devicesWithDetails;
try {
GadgetDataServiceDAOFactory.openConnection();
devicesWithDetails = GadgetDataServiceDAOFactory.
getGadgetDataServiceDAO().getDevicesWithDetails(extendedFilterSet);
getGadgetDataServiceDAO().getDevicesWithDetails(extendedFilterSet, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);
@ -261,13 +262,13 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public List<DeviceWithDetails> getFeatureNonCompliantDevicesWithDetails(String featureCode,
BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException,
BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException,
DataAccessLayerException {
List<DeviceWithDetails> featureNonCompliantDevicesWithDetails;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDevicesWithDetails = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDevicesWithDetails(featureCode, basicFilterSet);
getFeatureNonCompliantDevicesWithDetails(featureCode, basicFilterSet, userName);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either opening a database connection or " +
"accessing the database to fetch corresponding results.", e);

@ -0,0 +1,70 @@
/*
* 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.analytics.dashboard.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.user.api.UserStoreException;
import java.net.SocketException;
/**
* This class provides utility functions used by REST-API.
*/
public class APIUtil {
private static Log log = LogFactory.getLog(APIUtil.class);
public static String getAuthenticatedUser() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String username = threadLocalCarbonContext.getUsername();
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
if (username.endsWith(tenantDomain)) {
return username.substring(0, username.lastIndexOf("@"));
}
return username;
}
public static int getAuthenticatedUserTenantDomainId() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
return threadLocalCarbonContext.getTenantId();
}
public static boolean isDeviceAdminUser() throws DeviceAccessAuthorizationException {
return getDeviceAccessAuthorizationService().isDeviceAdminUser();
}
private static DeviceAccessAuthorizationService getDeviceAccessAuthorizationService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
DeviceAccessAuthorizationService deviceAccessAuthorizationService =
(DeviceAccessAuthorizationService) ctx.getOSGiService(DeviceAccessAuthorizationService.class, null);
if (deviceAccessAuthorizationService == null) {
String msg = "DeviceAccessAuthorization service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return deviceAccessAuthorizationService;
}
}

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

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

@ -1,841 +0,0 @@
package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup;
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardGadgetDataWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardPaginationGadgetDataWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
* Device Analytics Dashboard related REST-APIs. This can be used to obtain device related analytics.
*/
@SwaggerDefinition(
info = @Info(
version = "1.0.0",
title = "",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = "name", value = "DeviceAnalyticsDashboard"),
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/dashboard"),
})
}
),
tags = {
@Tag(name = "device_management", description = "Device Analytics Dashboard related APIs.")
}
)
@Scopes(
scopes = {
@Scope(
name = "Device Count Overview",
description = "Device Count Overview",
key = "perm:dashboard:count-overview",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Device Counts by Potential Vulnerabilities",
description = "Device Counts by Potential Vulnerabilities",
key = "perm:dashboard:vulnerabilities",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get the number of devices that have not complied to a policy",
description = "Get the number of devices that have not complied to a policy",
key = "perm:dashboard:non-compliant",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get the number of devices for a given device type, such as connectivity status, "
+ "potential vulnerability, platform, and ownership",
description = "Get the number of devices for a given device type, such as connectivity status, "
+ "potential vulnerability, platform, and ownership",
key = "perm:dashboard:by-groups",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get the number of devices that have not complied to a given policy based on a particular",
description = "Get the number of devices that have not complied to a given policy based on a particular",
key = "perm:dashboard:device-counts",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get the number of devices that have not complied to a given policy based on a particular"
+ " device type.",
description = "Get the number of devices that have not complied to a given policy based on a " +
"particular device type.",
key = "perm:dashboard:filtered-count",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get the number of devices that have not complied to a given policy over the total"
+ " number of devices registered with WSO2 EMM.\n",
description = "Get the number of devices that have not complied to a given policy over the total"
+ " number of devices registered with WSO2 EMM.\n",
key = "perm:dashboard:non-compliant-count",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get device details of devices based on a particular device type.",
description = "Get device details of devices based on a particular device type.",
key = "perm:dashboard:details",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get device details of non-compliant devices which do not comply to a given policy.",
description = "Get device details of non-compliant devices which do not comply to a given policy.",
key = "perm:dashboard:feature-non-compliant",
permissions = {"/device-mgt/dashboard/view"}
)
}
)
@Path("/dashboard")
@Api(value = "Device Analytics Dashboard",
description = "Device Analytics Dashboard related information APIs are described here.")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface Dashboard {
String CONNECTIVITY_STATUS = "connectivity-status";
String POTENTIAL_VULNERABILITY = "potential-vulnerability";
String NON_COMPLIANT_FEATURE_CODE = "non-compliant-feature-code";
String PLATFORM = "platform";
String OWNERSHIP = "ownership";
// Constants related to pagination
String PAGINATION_ENABLED = "pagination-enabled";
String START_INDEX = "start";
String RESULT_COUNT = "length";
@GET
@Path("device-count-overview")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the details of registered devices in WSO2 IoT.",
notes = "Get the details of active, inactive, removed and total number of registered devices in"
+ " WSO2 IoT.",
tags = "Dashboard",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:count-overview")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = DashboardGadgetDataWrapper.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class)
})
Response getOverviewDeviceCounts();
@GET
@Path("device-counts-by-potential-vulnerabilities")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the number of unmonitored and non-compliant devices in WSO2 IoT.",
tags = "Dashboard",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:vulnerabilities")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = DashboardGadgetDataWrapper.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching activity data.",
response = ErrorResponse.class)
})
Response getDeviceCountsByPotentialVulnerabilities();
@GET
@Path("non-compliant-device-counts-by-features")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the number of devices that have not complied to a policy that was enforced on a "
+ "device.",
tags = "Dashboard",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:non-compliant")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = DashboardPaginationGadgetDataWrapper.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found. \n",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class)
})
Response getNonCompliantDeviceCountsByFeatures(
@ApiParam(
name = "start",
value = "Provide the starting pagination index. Example 10",
required = true)
@QueryParam(START_INDEX) int startIndex,
@ApiParam(
name = "length",
value = "Provide how many policy details you require from the starting pagination index."
+ " For example if you require the non-compliant policy details from the 10th "
+ "pagination index to the 15th, you must define 10 as the value for start and "
+ "5 as the value for length.",
required = true)
@QueryParam(RESULT_COUNT) int resultCount);
@GET
@Path("device-counts-by-groups")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the number of devices for a given device type, such as connectivity status, "
+ "potential vulnerability, platform, and ownership.\n",
tags = "Dashboard",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:by-groups")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = DeviceCountByGroup.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request.",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class)
})
Response getDeviceCountsByGroups(
@ApiParam(
name = "connectivity-status",
value = "Provide the connectivity status of the device. The following values can be assigned:\n"
+ "active: The devices that are registered with WSO2 IoT and are actively "
+ "communicating with the server.\n"
+ "inactive: The devices that are registered with WSO2 IoT but unable to "
+ "actively communicate with the server.\n"
+ "removed: The devices that have unregistered from WSO2 IoT",
required = true)
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@ApiParam(
name = "potential-vulnerability",
value = "Provide details of the potential vulnerabilities of the device. The following "
+ "values can be assigned:\n"
+ "non-compliant: Devices that have not complied to the policies enforced on the "
+ "device by WSO2 IoT.\n"
+ "unmonitored: Devices that have no policy assigned to them.",
required = true)
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@ApiParam(
name = "platform",
value = "Provide the platform that the device is running on. The following values can "
+ "be assigned:\n"
+ "iOS\n" + "Android\n" + "Windows",
required = true)
@QueryParam(PLATFORM) String platform,
@ApiParam(
name = "ownership",
value = "Provide the ownership status of the device. The following values can be assigned:\n"
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
required = true)
@QueryParam(OWNERSHIP) String ownership);
@GET
@Path("feature-non-compliant-device-counts-by-groups")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the number of devices that have not complied to a given policy based on a particular"
+ " device type.",
tags = "Dashboard",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:device-counts")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = DeviceCountByGroup.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request.",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class)
})
Response getFeatureNonCompliantDeviceCountsByGroups(
@ApiParam(
name = "non-compliant-feature-code",
value = "As the value for this parameter, the policy feature code or ID can be used. Some"
+ " examples for feature codes are: PASSCODE_POLICY,CAMERA and WIFI.",
required = true)
@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
@ApiParam(
name = "platform",
value = "Provide the platform that the device is running on. The following values can "
+ "be assigned:\n"
+ "iOS\n" + "Android\n" + "Windows",
required = false)
@QueryParam(PLATFORM) String platform,
@ApiParam(
name = "ownership",
value = "Provide the ownership status of the device. The following values can be assigned:\n"
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
required = false)
@QueryParam(OWNERSHIP) String ownership);
@GET
@Path("filtered-device-count-over-total")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the number of devices that are registered with WSO2 IoT filtered by one of the "
+ "following attributes:\n"
+ "Connectivity status of the device, such as active, inactive or removed.\n"
+ "The device ownership type, such as BYOD or COPE.\n" + "The device platform.\n"
+ "The potential vulnerabilities faced by the devices.",
tags = "Dashboard",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:filtered-count")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = DashboardGadgetDataWrapper.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request.",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class)
})
Response getFilteredDeviceCountOverTotal(
@ApiParam(
name = "connectivity-status",
value = "Provide the connectivity status of the device. You can assign any of the values "
+ "given below:\n"
+ "Total: All the devices that have registered with WSO2 IoT.\n"
+ "active: The devices that are registered with WSO2 IoT and are actively "
+ "communicating with the server.\n"
+ "inactive: The devices that are registered with WSO2 IoT but unable to actively"
+ " communicate with the server.\n"
+ "removed: The devices that have unregistered from WSO2 IoT.",
required = true)
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@ApiParam(
name = "potential-vulnerability",
value = "Provide details of the potential vulnerabilities of the device. You can assign"
+ " any of the values given below:\n"
+ "non-compliant: Devices that have not complied to the policies enforced on the "
+ "device by WSO2 IoT.\n"
+ "unmonitored: Devices that have no policy assigned to them.",
required = true)
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@ApiParam(
name = "platform",
value = "Provide the platform that the device is running on. You can assign any of the "
+ "values given below:\n"
+ "iOS\n" + "Android\n" + "Windows",
required = true)
@QueryParam(PLATFORM) String platform,
@ApiParam(
name = "ownership",
value = "Provide the ownership status of the device. You can assign any of the values "
+ "given below:\n"
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
required = true)
@QueryParam(OWNERSHIP) String ownership);
@GET
@Path("feature-non-compliant-device-count-over-total")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the number of devices that have not complied to a given policy over the total"
+ " number of devices registered with WSO2 IoT.\n",
tags = "Dashboard",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:non-compliant-count")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = DashboardGadgetDataWrapper.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request.",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class)
})
Response getFeatureNonCompliantDeviceCountOverTotal(
@ApiParam(
name = "non-compliant-feature-code",
value = "Provide the feature code or ID of the policy. Some examples for feature codes "
+ "are: WIFI, PASSCODE_POLICY, CAMERA and ENCRYPT_STORAGE.",
required = true)
@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
@ApiParam(
name = "platform",
value = "Provide the platform that the device is running on. You can assign the values "
+ "given below:\n"
+ "iOS\n" + "Android\n" + "Windows",
required = true)
@QueryParam(PLATFORM) String platform,
@ApiParam(
name = "ownership",
value = "Provide the ownership status of the device. You can assign the values given below:\n"
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
required = true)
@QueryParam(OWNERSHIP) String ownership);
@GET
@Path("devices-with-details")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get device details of devices based on a particular device type.",
tags = "Dashboard",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:details")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = DashboardPaginationGadgetDataWrapper.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request.",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class)
})
Response getDevicesWithDetails(
@ApiParam(
name = "connectivity-status",
value = "Provide the connectivity status of the device. This can be one of the following:\n"
+ "Total: All the devices that have registered with WSO2 IoT.\n"
+ "active: The devices that are registered with WSO2 IoT and are actively "
+ "communicating with the server.\n"
+ "inactive: The devices that are registered with WSO2 IoT but unable to actively"
+ " communicate with the server.\n"
+ "removed: The devices that have unregistered from WSO2 IoT.",
required = true)
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@ApiParam(
name = "potential-vulnerability",
value = "Provide details of the potential vulnerabilities of the device. This can be:\n"
+ "non-compliant: Devices that have not complied to the policies enforced on "
+ "the device by WSO2 IoT.\n"
+ "unmonitored: Devices that have no policy assigned to them. ",
required = true)
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@ApiParam(
name = "platform",
value = "Provide the platform that the device is running on. This can be one of the following:\n"
+ "iOS\n" + "Android\n" + "Windows",
required = true)
@QueryParam(PLATFORM) String platform,
@ApiParam(
name = "ownership",
value = "Provide the ownership status of the device. This can be one of the following:\n"
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
required = true)
@QueryParam(OWNERSHIP) String ownership,
@ApiParam(
name = "pagination-enabled",
value = "To enable/disable pagination set the value as true or false",
required = true)
@QueryParam(PAGINATION_ENABLED) String paginationEnabled,
@ApiParam(
name = "start",
value = "Provide the starting pagination index.",
required = true)
@QueryParam(START_INDEX) int startIndex,
@ApiParam(
name = "length",
value = "Provide how many policy details you require from the starting pagination index.",
required = true)
@QueryParam(RESULT_COUNT) int resultCount);
@GET
@Path("feature-non-compliant-devices-with-details")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get device details of non-compliant devices which do not comply to a given policy.",
tags = "Dashboard",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:feature-non-compliant")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = DashboardPaginationGadgetDataWrapper.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request.",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class)
})
Response getFeatureNonCompliantDevicesWithDetails(
@ApiParam(
name = "non-compliant-feature-code",
value = "Provide the code specific to the feature "
+ "(examples for feature codes are: WIFI,PASSCODE_POLICY, CAMERA and ENCRYPT_STORAGE.)",
required = true)
@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
@ApiParam(
name = "platform",
value = "Provide the platform that the device is running on. This can be one of the following:\n"
+ "iOS\n" + "Android\n" + "Windows",
required = true)
@QueryParam(PLATFORM) String platform,
@ApiParam(
name = "ownership",
value = "Provide the ownership status of the device. This can be one of the following:\n"
+ "BYOD: Bring Your Own Device\n" + "COPE: Corporate-Owned, Personally-Enabled",
required = true)
@QueryParam(OWNERSHIP) String ownership,
@ApiParam(
name = "pagination-enabled",
value = "To enable/disable pagination set the value as true or false",
required = true)
@QueryParam(PAGINATION_ENABLED) String paginationEnabled,
@ApiParam(
name = "start",
value = "Provide the starting pagination index.",
required = true)
@QueryParam(START_INDEX) int startIndex,
@ApiParam(
name = "length",
value = "Provide how many policy details you require from the starting pagination index.",
required = true)
@QueryParam(RESULT_COUNT) int resultCount);
}

@ -18,32 +18,40 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Info;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
import org.wso2.carbon.device.mgt.common.search.SearchContext;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
import javax.validation.constraints.Size;
import javax.ws.rs.*;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@ -141,7 +149,7 @@ public interface DeviceManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Details of Registered Devices",
notes = "Provides details of all the devices enrolled with WSO2 EMM.",
notes = "Provides details of all the devices enrolled with WSO2 IoT Server.",
tags = "Device Management",
extensions = {
@Extension(properties = {
@ -205,6 +213,13 @@ public interface DeviceManagementService {
required = false)
@QueryParam("user")
String user,
@ApiParam(
name = "role",
value = "A role of device owners. Ex : store-admin",
required = false)
@QueryParam("role")
@Size(max = 45)
String role,
@ApiParam(
name = "ownership",
allowableValues = "BYOD, COPE",
@ -259,6 +274,71 @@ public interface DeviceManagementService {
@QueryParam("limit")
int limit);
@GET
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Details of Registered Devices owned by authenticated user",
notes = "Provides details of devices enrolled by authenticated user.",
tags = "Device Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
})
}
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of devices.",
response = DeviceList.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client already has the latest version of " +
"the requested resource.\n"),
@ApiResponse(
code = 400,
message = "The incoming request has more than one selection criteria defined via the query parameters.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "The search criteria did not match any device registered with the server.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the device list.",
response = ErrorResponse.class)
})
@Path("/user-devices")
Response getDeviceByUser(
@ApiParam(
name = "offset",
value = "The starting pagination index for the complete list of qualified items.",
required = false,
defaultValue = "0")
@QueryParam("offset")
int offset,
@ApiParam(
name = "limit",
value = "Provide how many device details you require from the starting pagination index/offset.",
required = false,
defaultValue = "5")
@QueryParam("limit")
int limit);
@GET
@Path("/{type}/{id}")
@ -314,9 +394,8 @@ public interface DeviceManagementService {
Response getDevice(
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true,
allowableValues = "android, ios, windows")
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("type")
@Size(max = 45)
String type,
@ -549,9 +628,8 @@ public interface DeviceManagementService {
Response getFeaturesOfDevice(
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true,
allowableValues = "android, ios, windows")
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("type")
@Size(max = 45)
String type,
@ -716,9 +794,8 @@ public interface DeviceManagementService {
Response getInstalledApplications(
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true,
allowableValues = "android, ios, windows")
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("type")
@Size(max = 45)
String type,
@ -818,9 +895,8 @@ public interface DeviceManagementService {
Response getDeviceOperations(
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true,
allowableValues = "android, ios, windows")
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("type")
@Size(max = 45)
String type,
@ -929,9 +1005,8 @@ public interface DeviceManagementService {
Response getEffectivePolicyOfDevice(
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true,
allowableValues = "android, ios, windows")
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("type")
@Size(max = 45)
String type,

@ -192,9 +192,8 @@ public interface DeviceTypeManagementService {
Response getFeatures(
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true,
allowableValues = "android, ios, windows")
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("type")
@Size(max = 45)
String type,

@ -204,10 +204,6 @@ public interface GroupManagementService {
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 404,
message = "No groups found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported."),
@ -219,19 +215,25 @@ public interface GroupManagementService {
Response getGroups(@ApiParam(
name = "name",
value = "Name of the group.")
@QueryParam("name") String name,
@QueryParam("name")
String name,
@ApiParam(
name = "owner",
value = "Owner of the group.")
@QueryParam("owner") String owner,
@QueryParam("owner")
String owner,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.")
@QueryParam("offset") int offset,
value = "The starting pagination index for the complete list of qualified items.",
defaultValue = "0")
@QueryParam("offset")
int offset,
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.")
@QueryParam("limit") int limit);
value = "Provide how many device details you require from the starting pagination index/offset.",
defaultValue = "5")
@QueryParam("limit")
int limit);
@Path("/count")
@GET
@ -268,10 +270,6 @@ public interface GroupManagementService {
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 404,
message = "No groups found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported."),
@ -383,7 +381,7 @@ public interface GroupManagementService {
"the requested resource."),
@ApiResponse(
code = 404,
message = "No groups found.",
message = "Group found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
@ -435,7 +433,7 @@ public interface GroupManagementService {
"the requested resource."),
@ApiResponse(
code = 404,
message = "No groups found.",
message = "Group not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
@ -492,7 +490,7 @@ public interface GroupManagementService {
"the requested resource."),
@ApiResponse(
code = 404,
message = "No groups found.",
message = "Group not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
@ -544,7 +542,7 @@ public interface GroupManagementService {
"the requested resource."),
@ApiResponse(
code = 404,
message = "No groups found.",
message = "Group not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
@ -601,7 +599,7 @@ public interface GroupManagementService {
"the requested resource."),
@ApiResponse(
code = 404,
message = "No groups found.",
message = "Group not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
@ -653,7 +651,7 @@ public interface GroupManagementService {
"the requested resource."),
@ApiResponse(
code = 404,
message = "No groups found.",
message = "Group not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
@ -667,15 +665,20 @@ public interface GroupManagementService {
name = "groupId",
value = "ID of the group.",
required = true)
@PathParam("groupId") int groupId,
@PathParam("groupId")
int groupId,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.")
@QueryParam("offset") int offset,
value = "The starting pagination index for the complete list of qualified items.",
defaultValue = "0")
@QueryParam("offset")
int offset,
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.")
@QueryParam("limit") int limit);
value = "Provide how many device details you require from the starting pagination index/offset.",
defaultValue = "5")
@QueryParam("limit")
int limit);
@Path("/id/{groupId}/devices/count")
@GET
@ -926,10 +929,6 @@ public interface GroupManagementService {
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 404,
message = "No groups found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported."),
@ -941,11 +940,15 @@ public interface GroupManagementService {
Response getGroups(
@ApiParam(
name = "deviceId",
value = "Id of the device.")
@QueryParam("deviceId") String deviceId,
value = "Id of the device.",
required = true)
@QueryParam("deviceId")
String deviceId,
@ApiParam(
name = "deviceType",
value = "Type of the device.")
@QueryParam("deviceType") String deviceType);
value = "Type of the device.",
required = true)
@QueryParam("deviceType")
String deviceType);
}

@ -672,9 +672,8 @@ public interface PolicyManagementService {
Response getEffectivePolicy(
@ApiParam(
name = "deviceType",
value = "The device type, such as ios, android or windows.",
required = true,
allowableValues = "android, ios, windows")
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("deviceType")
@Size(max = 45)
String deviceType,

@ -136,9 +136,8 @@ public interface DeviceManagementAdminService {
String name,
@ApiParam(
name = "type",
value = "The type of the device, such as android, ios or windows.",
required = true,
allowableValues = "android, ios, windows")
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@QueryParam("type")
@Size(min = 2, max = 45)
String type,

@ -113,10 +113,6 @@ public interface GroupManagementAdminService {
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 404,
message = "No groups found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported."),
@ -128,19 +124,25 @@ public interface GroupManagementAdminService {
Response getGroups(@ApiParam(
name = "name",
value = "Name of the group.")
@QueryParam("name") String name,
@QueryParam("name")
String name,
@ApiParam(
name = "owner",
value = "Owner of the group.")
@QueryParam("owner") String owner,
@QueryParam("owner")
String owner,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.")
@QueryParam("offset") int offset,
value = "The starting pagination index for the complete list of qualified items.",
defaultValue = "0")
@QueryParam("offset")
int offset,
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.")
@QueryParam("limit") int limit);
value = "Provide how many device details you require from the starting pagination index/offset.",
defaultValue = "5")
@QueryParam("limit")
int limit);
@Path("/count")
@GET

@ -1,688 +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.service.impl;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataService;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.BasicFilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceWithDetails;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.ExtendedFilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.exception.*;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardGadgetDataWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardPaginationGadgetDataWrapper;
import org.wso2.carbon.device.mgt.jaxrs.service.api.Dashboard;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
/**
* This class consists of dashboard related REST APIs
* to be consumed by individual client gadgets such as
* [1] Overview of Devices,
* [2] Potential Vulnerabilities,
* [3] Non-compliant Devices by Features,
* [4] Device Groupings and etc.
*/
@Consumes({"application/json"})
@Produces({"application/json"})
@SuppressWarnings("NonJaxWsWebServices")
public class DashboardImpl implements Dashboard {
private static Log log = LogFactory.getLog(DashboardImpl.class);
private static final String FLAG_TRUE = "true";
private static final String FLAG_FALSE = "false";
// Constants related to common error-response messages
private static final String INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY = "Received an invalid value for " +
"query parameter : " + POTENTIAL_VULNERABILITY + ", Should be either NON_COMPLIANT or UNMONITORED.";
private static final String INVALID_QUERY_PARAM_VALUE_START_INDEX = "Received an invalid value for " +
"query parameter : " + START_INDEX + ", Should not be lesser than 0.";
private static final String INVALID_QUERY_PARAM_VALUE_RESULT_COUNT = "Received an invalid value for " +
"query parameter : " + RESULT_COUNT + ", Should not be lesser than 5.";
private static final String INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED = "Received an invalid value for " +
"query parameter : " + PAGINATION_ENABLED + ", Should be either true or false.";
private static final String REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE = "Missing required query " +
"parameter : " + NON_COMPLIANT_FEATURE_CODE;
private static final String REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED = "Missing required query " +
"parameter : " + PAGINATION_ENABLED;
private static final String ERROR_IN_RETRIEVING_REQUESTED_DATA = "ErrorResponse in retrieving requested data.";
@GET
@Path("device-count-overview")
public Response getOverviewDeviceCounts() {
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
DashboardGadgetDataWrapper dashboardGadgetDataWrapper1 = new DashboardGadgetDataWrapper();
// getting total device count
DeviceCountByGroup totalDeviceCount;
try {
totalDeviceCount = gadgetDataService.getTotalDeviceCount();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve total device count.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
List<DeviceCountByGroup> totalDeviceCountInListEntry = new ArrayList<>();
totalDeviceCountInListEntry.add(totalDeviceCount);
dashboardGadgetDataWrapper1.setContext("Total-device-count");
dashboardGadgetDataWrapper1.setGroupingAttribute(null);
dashboardGadgetDataWrapper1.setData(totalDeviceCountInListEntry);
// getting device counts by connectivity statuses
List<DeviceCountByGroup> deviceCountsByConnectivityStatuses;
try {
deviceCountsByConnectivityStatuses = gadgetDataService.getDeviceCountsByConnectivityStatuses();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve device counts by connectivity statuses.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
DashboardGadgetDataWrapper dashboardGadgetDataWrapper2 = new DashboardGadgetDataWrapper();
dashboardGadgetDataWrapper2.setContext("Device-counts-by-connectivity-statuses");
dashboardGadgetDataWrapper2.setGroupingAttribute(CONNECTIVITY_STATUS);
dashboardGadgetDataWrapper2.setData(deviceCountsByConnectivityStatuses);
List<DashboardGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardGadgetDataWrapper1);
responsePayload.add(dashboardGadgetDataWrapper2);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
}
@GET
@Path("device-counts-by-potential-vulnerabilities")
public Response getDeviceCountsByPotentialVulnerabilities() {
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
List<DeviceCountByGroup> deviceCountsByPotentialVulnerabilities;
try {
deviceCountsByPotentialVulnerabilities = gadgetDataService.getDeviceCountsByPotentialVulnerabilities();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve device counts by potential vulnerabilities.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper();
dashboardGadgetDataWrapper.setContext("Device-counts-by-potential-vulnerabilities");
dashboardGadgetDataWrapper.setGroupingAttribute(POTENTIAL_VULNERABILITY);
dashboardGadgetDataWrapper.setData(deviceCountsByPotentialVulnerabilities);
List<DashboardGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardGadgetDataWrapper);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
}
@GET
@Path("non-compliant-device-counts-by-features")
public Response getNonCompliantDeviceCountsByFeatures(@QueryParam(START_INDEX) int startIndex,
@QueryParam(RESULT_COUNT) int resultCount) {
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
DashboardPaginationGadgetDataWrapper
dashboardPaginationGadgetDataWrapper = new DashboardPaginationGadgetDataWrapper();
PaginationResult paginationResult;
try {
paginationResult = gadgetDataService.
getNonCompliantDeviceCountsByFeatures(startIndex, resultCount);
} catch (InvalidStartIndexValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a non-compliant set " +
"of device counts by features.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).entity(INVALID_QUERY_PARAM_VALUE_START_INDEX).build();
} catch (InvalidResultCountValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a non-compliant set " +
"of device counts by features.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).entity(INVALID_QUERY_PARAM_VALUE_RESULT_COUNT).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a non-compliant set of device counts by features.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
dashboardPaginationGadgetDataWrapper.setContext("Non-compliant-device-counts-by-features");
dashboardPaginationGadgetDataWrapper.setGroupingAttribute(NON_COMPLIANT_FEATURE_CODE);
dashboardPaginationGadgetDataWrapper.setData(paginationResult.getData());
dashboardPaginationGadgetDataWrapper.setTotalRecordCount(paginationResult.getRecordsTotal());
List<DashboardPaginationGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardPaginationGadgetDataWrapper);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
}
@GET
@Path("device-counts-by-groups")
public Response getDeviceCountsByGroups(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@QueryParam(PLATFORM) String platform,
@QueryParam(OWNERSHIP) String ownership) {
// getting gadget data service
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
// constructing filter set
ExtendedFilterSet filterSet = new ExtendedFilterSet();
filterSet.setConnectivityStatus(connectivityStatus);
filterSet.setPotentialVulnerability(potentialVulnerability);
filterSet.setPlatform(platform);
filterSet.setOwnership(ownership);
// creating device-Counts-by-platforms Data Wrapper
List<DeviceCountByGroup> deviceCountsByPlatforms;
try {
deviceCountsByPlatforms = gadgetDataService.getDeviceCountsByPlatforms(filterSet);
} catch (InvalidPotentialVulnerabilityValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of device counts by platforms.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a filtered set of device counts by platforms.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
DashboardGadgetDataWrapper dashboardGadgetDataWrapper1 = new DashboardGadgetDataWrapper();
dashboardGadgetDataWrapper1.setContext("Device-counts-by-platforms");
dashboardGadgetDataWrapper1.setGroupingAttribute(PLATFORM);
dashboardGadgetDataWrapper1.setData(deviceCountsByPlatforms);
// creating device-Counts-by-ownership-types Data Wrapper
List<DeviceCountByGroup> deviceCountsByOwnerships;
try {
deviceCountsByOwnerships = gadgetDataService.getDeviceCountsByOwnershipTypes(filterSet);
} catch (InvalidPotentialVulnerabilityValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of device counts by ownerships.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a filtered set of device counts by ownerships.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
DashboardGadgetDataWrapper dashboardGadgetDataWrapper2 = new DashboardGadgetDataWrapper();
dashboardGadgetDataWrapper2.setContext("Device-counts-by-ownerships");
dashboardGadgetDataWrapper2.setGroupingAttribute(OWNERSHIP);
dashboardGadgetDataWrapper2.setData(deviceCountsByOwnerships);
List<DashboardGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardGadgetDataWrapper1);
responsePayload.add(dashboardGadgetDataWrapper2);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
}
@GET
@Path("feature-non-compliant-device-counts-by-groups")
public Response getFeatureNonCompliantDeviceCountsByGroups(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
@QueryParam(PLATFORM) String platform,
@QueryParam(OWNERSHIP) String ownership) {
// getting gadget data service
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
// constructing filter set
BasicFilterSet filterSet = new BasicFilterSet();
filterSet.setPlatform(platform);
filterSet.setOwnership(ownership);
// creating feature-non-compliant-device-Counts-by-platforms Data Wrapper
List<DeviceCountByGroup> featureNonCompliantDeviceCountsByPlatforms;
try {
featureNonCompliantDeviceCountsByPlatforms = gadgetDataService.
getFeatureNonCompliantDeviceCountsByPlatforms(nonCompliantFeatureCode, filterSet);
} catch (InvalidFeatureCodeValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of feature " +
"non-compliant device counts by platforms.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a filtered set of feature non-compliant " +
"device counts by platforms.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
DashboardGadgetDataWrapper dashboardGadgetDataWrapper1 = new DashboardGadgetDataWrapper();
dashboardGadgetDataWrapper1.setContext("Feature-non-compliant-device-counts-by-platforms");
dashboardGadgetDataWrapper1.setGroupingAttribute(PLATFORM);
dashboardGadgetDataWrapper1.setData(featureNonCompliantDeviceCountsByPlatforms);
// creating feature-non-compliant-device-Counts-by-ownership-types Data Wrapper
List<DeviceCountByGroup> featureNonCompliantDeviceCountsByOwnerships;
try {
featureNonCompliantDeviceCountsByOwnerships = gadgetDataService.
getFeatureNonCompliantDeviceCountsByOwnershipTypes(nonCompliantFeatureCode, filterSet);
} catch (InvalidFeatureCodeValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a filtered set of feature " +
"non-compliant device counts by ownerships.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a filtered set of feature non-compliant " +
"device counts by ownerships.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
DashboardGadgetDataWrapper dashboardGadgetDataWrapper2 = new DashboardGadgetDataWrapper();
dashboardGadgetDataWrapper2.setContext("Feature-non-compliant-device-counts-by-ownerships");
dashboardGadgetDataWrapper2.setGroupingAttribute(OWNERSHIP);
dashboardGadgetDataWrapper2.setData(featureNonCompliantDeviceCountsByOwnerships);
List<DashboardGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardGadgetDataWrapper1);
responsePayload.add(dashboardGadgetDataWrapper2);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
}
@GET
@Path("filtered-device-count-over-total")
public Response getFilteredDeviceCountOverTotal(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@QueryParam(PLATFORM) String platform,
@QueryParam(OWNERSHIP) String ownership) {
// getting gadget data service
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
// constructing filter set
ExtendedFilterSet filterSet = new ExtendedFilterSet();
filterSet.setConnectivityStatus(connectivityStatus);
filterSet.setPotentialVulnerability(potentialVulnerability);
filterSet.setPlatform(platform);
filterSet.setOwnership(ownership);
// creating filteredDeviceCount Data Wrapper
DeviceCountByGroup filteredDeviceCount;
try {
filteredDeviceCount = gadgetDataService.getDeviceCount(filterSet);
} catch (InvalidPotentialVulnerabilityValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered device count over the total.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a filtered device count over the total.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
// creating TotalDeviceCount Data Wrapper
DeviceCountByGroup totalDeviceCount;
try {
totalDeviceCount = gadgetDataService.getTotalDeviceCount();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve the total device count over filtered.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
List<Object> filteredDeviceCountOverTotalDataWrapper = new ArrayList<>();
filteredDeviceCountOverTotalDataWrapper.add(filteredDeviceCount);
filteredDeviceCountOverTotalDataWrapper.add(totalDeviceCount);
DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper();
dashboardGadgetDataWrapper.setContext("Filtered-device-count-over-total");
dashboardGadgetDataWrapper.setGroupingAttribute(null);
dashboardGadgetDataWrapper.setData(filteredDeviceCountOverTotalDataWrapper);
List<DashboardGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardGadgetDataWrapper);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
}
@GET
@Path("feature-non-compliant-device-count-over-total")
public Response getFeatureNonCompliantDeviceCountOverTotal(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
@QueryParam(PLATFORM) String platform,
@QueryParam(OWNERSHIP) String ownership) {
// getting gadget data service
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
// constructing filter set
BasicFilterSet filterSet = new BasicFilterSet();
filterSet.setPlatform(platform);
filterSet.setOwnership(ownership);
// creating featureNonCompliantDeviceCount Data Wrapper
DeviceCountByGroup featureNonCompliantDeviceCount;
try {
featureNonCompliantDeviceCount = gadgetDataService.
getFeatureNonCompliantDeviceCount(nonCompliantFeatureCode, filterSet);
} catch (InvalidFeatureCodeValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a feature non-compliant device count over the total.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a feature non-compliant device count over the total.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
// creating TotalDeviceCount Data Wrapper
DeviceCountByGroup totalDeviceCount;
try {
totalDeviceCount = gadgetDataService.getTotalDeviceCount();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve the total device count over filtered feature non-compliant.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
List<Object> featureNonCompliantDeviceCountOverTotalDataWrapper = new ArrayList<>();
featureNonCompliantDeviceCountOverTotalDataWrapper.add(featureNonCompliantDeviceCount);
featureNonCompliantDeviceCountOverTotalDataWrapper.add(totalDeviceCount);
DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper();
dashboardGadgetDataWrapper.setContext("Feature-non-compliant-device-count-over-total");
dashboardGadgetDataWrapper.setGroupingAttribute(null);
dashboardGadgetDataWrapper.setData(featureNonCompliantDeviceCountOverTotalDataWrapper);
List<DashboardGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardGadgetDataWrapper);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
}
@GET
@Path("devices-with-details")
public Response getDevicesWithDetails(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@QueryParam(PLATFORM) String platform,
@QueryParam(OWNERSHIP) String ownership,
@QueryParam(PAGINATION_ENABLED) String paginationEnabled,
@QueryParam(START_INDEX) int startIndex,
@QueryParam(RESULT_COUNT) int resultCount) {
if (paginationEnabled == null) {
log.error("Bad request on retrieving a filtered set of devices with details @ " +
"Dashboard API layer. " + REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build();
} else if (FLAG_TRUE.equals(paginationEnabled)) {
// getting gadget data service
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
// constructing filter set
ExtendedFilterSet filterSet = new ExtendedFilterSet();
filterSet.setConnectivityStatus(connectivityStatus);
filterSet.setPotentialVulnerability(potentialVulnerability);
filterSet.setPlatform(platform);
filterSet.setOwnership(ownership);
PaginationResult paginationResult;
try {
paginationResult = gadgetDataService.
getDevicesWithDetails(filterSet, startIndex, resultCount);
} catch (InvalidPotentialVulnerabilityValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of devices with details.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build();
} catch (InvalidStartIndexValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of devices with details.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_START_INDEX).build();
} catch (InvalidResultCountValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of devices with details.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_RESULT_COUNT).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a filtered set of devices with details.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
DashboardPaginationGadgetDataWrapper
dashboardPaginationGadgetDataWrapper = new DashboardPaginationGadgetDataWrapper();
dashboardPaginationGadgetDataWrapper.setContext("Filtered-and-paginated-devices-with-details");
dashboardPaginationGadgetDataWrapper.setGroupingAttribute(null);
dashboardPaginationGadgetDataWrapper.setData(paginationResult.getData());
dashboardPaginationGadgetDataWrapper.setTotalRecordCount(paginationResult.getRecordsTotal());
List<DashboardPaginationGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardPaginationGadgetDataWrapper);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
} else if (FLAG_FALSE.equals(paginationEnabled)) {
// getting gadget data service
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
// constructing filter set
ExtendedFilterSet filterSet = new ExtendedFilterSet();
filterSet.setConnectivityStatus(connectivityStatus);
filterSet.setPotentialVulnerability(potentialVulnerability);
filterSet.setPlatform(platform);
filterSet.setOwnership(ownership);
List<DeviceWithDetails> devicesWithDetails;
try {
devicesWithDetails = gadgetDataService.getDevicesWithDetails(filterSet);
} catch (InvalidPotentialVulnerabilityValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of devices with details.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a filtered set of devices with details.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper();
dashboardGadgetDataWrapper.setContext("Filtered-devices-with-details");
dashboardGadgetDataWrapper.setGroupingAttribute(null);
dashboardGadgetDataWrapper.setData(devicesWithDetails);
List<DashboardGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardGadgetDataWrapper);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
} else {
log.error("Bad request on retrieving a filtered set of devices with details @ " +
"Dashboard API layer. " + INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build();
}
}
@GET
@Path("feature-non-compliant-devices-with-details")
public Response getFeatureNonCompliantDevicesWithDetails(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode,
@QueryParam(PLATFORM) String platform,
@QueryParam(OWNERSHIP) String ownership,
@QueryParam(PAGINATION_ENABLED) String paginationEnabled,
@QueryParam(START_INDEX) int startIndex,
@QueryParam(RESULT_COUNT) int resultCount) {
if (paginationEnabled == null) {
log.error("Bad request on retrieving a filtered set of feature non-compliant devices with " +
"details @ Dashboard API layer. " + REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build();
} else if (FLAG_TRUE.equals(paginationEnabled)) {
// getting gadget data service
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
// constructing filter set
BasicFilterSet filterSet = new BasicFilterSet();
filterSet.setPlatform(platform);
filterSet.setOwnership(ownership);
PaginationResult paginationResult;
try {
paginationResult = gadgetDataService.
getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode,
filterSet, startIndex, resultCount);
} catch (InvalidFeatureCodeValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of " +
"feature non-compliant devices with details.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build();
} catch (InvalidStartIndexValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of " +
"feature non-compliant devices with details.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_START_INDEX).build();
} catch (InvalidResultCountValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of " +
"feature non-compliant devices with details.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_RESULT_COUNT).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a filtered set of feature " +
"non-compliant devices with details.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
DashboardPaginationGadgetDataWrapper
dashboardPaginationGadgetDataWrapper = new DashboardPaginationGadgetDataWrapper();
dashboardPaginationGadgetDataWrapper.
setContext("Filtered-and-paginated-feature-non-compliant-devices-with-details");
dashboardPaginationGadgetDataWrapper.setGroupingAttribute(null);
dashboardPaginationGadgetDataWrapper.setData(paginationResult.getData());
dashboardPaginationGadgetDataWrapper.setTotalRecordCount(paginationResult.getRecordsTotal());
List<DashboardPaginationGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardPaginationGadgetDataWrapper);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
} else if (FLAG_FALSE.equals(paginationEnabled)) {
// getting gadget data service
GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService();
// constructing filter set
BasicFilterSet filterSet = new BasicFilterSet();
filterSet.setPlatform(platform);
filterSet.setOwnership(ownership);
List<DeviceWithDetails> featureNonCompliantDevicesWithDetails;
try {
featureNonCompliantDevicesWithDetails = gadgetDataService.
getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filterSet);
} catch (InvalidFeatureCodeValueException e) {
log.error("Bad request and error occurred @ Gadget Data Service layer due to " +
"invalid (query) parameter value. This was while trying to execute relevant data service " +
"function @ Dashboard API layer to retrieve a filtered set of " +
"feature non-compliant devices with details.", e);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build();
} catch (DataAccessLayerException e) {
log.error("An internal error occurred while trying to execute relevant data service function " +
"@ Dashboard API layer to retrieve a filtered set of feature " +
"non-compliant devices with details.", e);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).
entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build();
}
DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper();
dashboardGadgetDataWrapper.setContext("Filtered-feature-non-compliant-devices-with-details");
dashboardGadgetDataWrapper.setGroupingAttribute(null);
dashboardGadgetDataWrapper.setData(featureNonCompliantDevicesWithDetails);
List<DashboardGadgetDataWrapper> responsePayload = new ArrayList<>();
responsePayload.add(dashboardGadgetDataWrapper);
return Response.status(HttpStatus.SC_OK).entity(responsePayload).build();
} else {
log.error("Bad request on retrieving a filtered set of feature non-compliant devices with " +
"details @ Dashboard API layer. " + INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED);
return Response.status(HttpStatus.SC_BAD_REQUEST).
entity(INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build();
}
}
}

@ -18,6 +18,7 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
@ -84,6 +85,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@QueryParam("name") String name,
@QueryParam("type") String type,
@QueryParam("user") String user,
@QueryParam("role") String role,
@QueryParam("ownership") String ownership,
@QueryParam("status") String status,
@QueryParam("groupId") int groupId,
@ -92,6 +94,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
try {
if (!StringUtils.isEmpty(name) && !StringUtils.isEmpty(role)) {
return Response.status(Response.Status.BAD_REQUEST).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("Request contains both name and role " +
"parameters. Only one is allowed " +
"at once.").build()).build();
}
// RequestValidationUtil.validateSelectionCriteria(type, user, roleName, ownership, status);
RequestValidationUtil.validatePaginationParameters(offset, limit);
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
@ -126,6 +134,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
if (groupId != 0 ) {
request.setGroupId(groupId);
}
if (role != null && !role.isEmpty()) {
request.setOwnerRole(role);
}
// this is the user who initiates the request
String authorizedUser = MultitenantUtils.getTenantAwareUsername(CarbonContext.getThreadLocalCarbonContext().getUsername());
@ -210,6 +221,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
}
@GET
@Override
@Path("/user-devices")
public Response getDeviceByUser(@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {

@ -65,14 +65,15 @@ public class GroupManagementServiceImpl implements GroupManagementService {
request.setOwner(owner);
PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService()
.getGroups(currentUser, request);
DeviceGroupList deviceGroupList = new DeviceGroupList();
if (deviceGroupsResult.getData() != null && deviceGroupsResult.getRecordsTotal() > 0) {
DeviceGroupList deviceGroupList = new DeviceGroupList();
deviceGroupList.setList(deviceGroupsResult.getData());
deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal());
return Response.status(Response.Status.OK).entity(deviceGroupList).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
deviceGroupList.setList(new ArrayList<>());
deviceGroupList.setCount(0);
}
return Response.status(Response.Status.OK).entity(deviceGroupList).build();
} catch (GroupManagementException e) {
String error = "Error occurred while getting the groups.";
log.error(error, e);
@ -184,15 +185,15 @@ public class GroupManagementServiceImpl implements GroupManagementService {
public Response getRolesOfGroup(int groupId) {
try {
List<String> groupRoles = DeviceMgtAPIUtils.getGroupManagementProviderService().getRoles(groupId);
if(groupRoles != null && groupRoles.size() > 0) {
RoleList deviceGroupRolesList = new RoleList();
RoleList deviceGroupRolesList = new RoleList();
if(groupRoles != null) {
deviceGroupRolesList.setList(groupRoles);
deviceGroupRolesList.setCount(groupRoles.size());
return Response.status(Response.Status.OK).entity(deviceGroupRolesList).build();
} else {
return Response.status(Response.Status.OK).entity(EMPTY_RESULT).build();
deviceGroupRolesList.setList(new ArrayList<String>());
deviceGroupRolesList.setCount(0);
}
return Response.status(Response.Status.OK).entity(deviceGroupRolesList).build();
} catch (GroupManagementException e) {
String msg = "Error occurred while getting roles of the group.";
log.error(msg, e);
@ -205,14 +206,15 @@ public class GroupManagementServiceImpl implements GroupManagementService {
try {
GroupManagementProviderService service = DeviceMgtAPIUtils.getGroupManagementProviderService();
List<Device> deviceList = service.getDevices(groupId, offset, limit);
if (deviceList != null && deviceList.size() > 0) {
DeviceList deviceListWrapper = new DeviceList();
int deviceCount = service.getDeviceCount(groupId);
DeviceList deviceListWrapper = new DeviceList();
if (deviceList != null) {
deviceListWrapper.setList(deviceList);
deviceListWrapper.setCount(service.getDeviceCount(groupId));
return Response.status(Response.Status.OK).entity(deviceListWrapper).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
deviceListWrapper.setList(new ArrayList<Device>());
}
deviceListWrapper.setCount(deviceCount);
return Response.status(Response.Status.OK).entity(deviceListWrapper).build();
} catch (GroupManagementException e) {
String msg = "Error occurred while getting devices the group.";
log.error(msg, e);
@ -295,7 +297,7 @@ public class GroupManagementServiceImpl implements GroupManagementService {
List<DeviceGroup> deviceGroups = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroups(deviceIdentifier);
return Response.status(Response.Status.OK).entity(deviceGroups).build();
} catch (GroupManagementException e) {
String msg = "Error occurred while removing devices from group.";
String msg = "Error occurred while getting groups of device.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}

@ -65,9 +65,10 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem
if (applicationWrapper.getDeviceIdentifiers() != null) {
for (DeviceIdentifier deviceIdentifier : applicationWrapper.getDeviceIdentifiers()) {
if (Platform.ANDROID.toString().equals(deviceIdentifier.getType())) {
String deviceType = deviceIdentifier.getType().toUpperCase();
if (Platform.ANDROID.toString().equals(deviceType)) {
operation = MDMAndroidOperationUtil.createInstallAppOperation(mobileApp);
} else if (Platform.IOS.toString().equals(deviceIdentifier.getType())) {
} else if (Platform.IOS.toString().equals(deviceType)) {
operation = MDMIOSOperationUtil.createInstallAppOperation(mobileApp);
}
}
@ -114,9 +115,10 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem
if (applicationWrapper.getDeviceIdentifiers() != null) {
for (DeviceIdentifier deviceIdentifier : applicationWrapper.getDeviceIdentifiers()) {
if (Platform.ANDROID.toString().equals(deviceIdentifier.getType())) {
String deviceType = deviceIdentifier.getType().toUpperCase();
if (Platform.ANDROID.toString().equals(deviceType)) {
operation = MDMAndroidOperationUtil.createAppUninstallOperation(mobileApp);
} else if (deviceIdentifier.getType().equals(Platform.IOS.toString())) {
} else if (deviceType.equals(Platform.IOS.toString())) {
operation = MDMIOSOperationUtil.createAppUninstallOperation(mobileApp);
}
}

@ -32,6 +32,7 @@ import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
public class GroupManagementAdminServiceImpl implements GroupManagementAdminService {
@ -47,14 +48,15 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ
request.setOwner(owner);
PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService()
.getGroups(request);
if (deviceGroupsResult.getData() != null && deviceGroupsResult.getRecordsTotal() > 0) {
DeviceGroupList deviceGroupList = new DeviceGroupList();
DeviceGroupList deviceGroupList = new DeviceGroupList();
if (deviceGroupsResult.getData() != null) {
deviceGroupList.setList(deviceGroupsResult.getData());
deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal());
return Response.status(Response.Status.OK).entity(deviceGroupList).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
deviceGroupList.setList(new ArrayList<>());
deviceGroupList.setCount(0);
}
return Response.status(Response.Status.OK).entity(deviceGroupList).build();
} catch (GroupManagementException e) {
String msg = "ErrorResponse occurred while retrieving all groups.";
log.error(msg, e);

@ -39,7 +39,6 @@
<ref bean="groupManagementAdminService"/>
<ref bean="applicationManagementAdminService"/>
<ref bean="deviceTypeManagementAdminService"/>
<ref bean="dashboardServiceBean"/>
<ref bean="swaggerResource"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
@ -79,7 +78,6 @@
<bean id="applicationManagementAdminService" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.admin.ApplicationManagementAdminServiceImpl"/>
<bean id="groupManagementAdminService" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.admin.GroupManagementAdminServiceImpl"/>
<bean id="userManagementAdminService" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.admin.UserManagementAdminServiceImpl"/>
<bean id="dashboardServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.DashboardImpl"/>
<bean id="deviceTypeManagementAdminService" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.DeviceTypeManagementServiceImpl"/>
<bean id="deviceAccessAuthorizationAdminService" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.admin.DeviceAccessAuthorizationAdminServiceImpl"/>
<bean id="jsonProvider" class="org.wso2.carbon.device.mgt.jaxrs.common.GsonMessageBodyHandler"/>

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

@ -33,6 +33,7 @@ public class PaginationRequest {
private String deviceType;
private String deviceName;
private String ownership;
private String ownerRole;
private Date since;
public PaginationRequest(int start, int rowCount) {
@ -112,4 +113,11 @@ public class PaginationRequest {
this.since = since;
}
public String getOwnerRole() {
return ownerRole;
}
public void setOwnerRole(String ownerRole) {
this.ownerRole = ownerRole;
}
}

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

@ -17,6 +17,7 @@
*/
package org.wso2.carbon.device.mgt.core.service;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.CarbonConstants;
@ -607,12 +608,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override
public PaginationResult getAllDevices(PaginationRequest request) throws DeviceManagementException {
List<Device> devicesForRoles = null;
PaginationResult paginationResult = new PaginationResult();
List<Device> devices = new ArrayList<>();
List<Device> allDevices = new ArrayList<>();
int count = 0;
int tenantId = this.getTenantId();
request = DeviceManagerUtil.validateDeviceListPageSize(request);
if (!StringUtils.isEmpty(request.getOwnerRole())) {
devicesForRoles = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
.getAllDevicesOfRole(request.getOwnerRole());
}
try {
DeviceManagementDAOFactory.openConnection();
allDevices = deviceDAO.getDevices(request, tenantId);
@ -625,6 +631,20 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} finally {
DeviceManagementDAOFactory.closeConnection();
}
devices = processDevices(devices, allDevices);
if (devicesForRoles != null) {
count += devicesForRoles.size();
devices = processDevices(devices, devicesForRoles);
}
paginationResult.setData(devices);
paginationResult.setRecordsFiltered(count);
paginationResult.setRecordsTotal(count);
return paginationResult;
}
private List<Device> processDevices(List<Device> devices, List<Device> allDevices) throws DeviceManagementException {
for (Device device : allDevices) {
DeviceInfo info = null;
try {
@ -637,7 +657,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
device.setDeviceInfo(info);
} catch (DeviceDetailsMgtDAOException e) {
log.error("Error occurred while retrieving advance info of '" + device.getType() +
"' that carries the id '" + device.getDeviceIdentifier() + "'");
"' that carries the id '" + device.getDeviceIdentifier() + "'");
} catch (SQLException e) {
log.error("Error occurred while opening a connection to the data source", e);
} finally {
@ -651,7 +671,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
device.setApplications(applications);
} catch (DeviceManagementDAOException e) {
log.error("Error occurred while retrieving the application list of '" + device.getType() + "', " +
"which carries the id '" + device.getId() + "'", e);
"which carries the id '" + device.getId() + "'", e);
} catch (SQLException e) {
log.error("Error occurred while opening a connection to the data source", e);
} finally {
@ -662,7 +682,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
if (deviceManager == null) {
if (log.isDebugEnabled()) {
log.debug("Device Manager associated with the device type '" + device.getType() + "' is null. " +
"Therefore, not attempting method 'isEnrolled'");
"Therefore, not attempting method 'isEnrolled'");
}
devices.add(device);
continue;
@ -675,12 +695,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
devices.add(device);
}
paginationResult.setData(devices);
paginationResult.setRecordsFiltered(count);
paginationResult.setRecordsTotal(count);
return paginationResult;
return devices;
}
@Override
public List<Device> getAllDevices(String deviceType) throws DeviceManagementException {
List<Device> devices = new ArrayList<>();

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

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

@ -1,5 +1,6 @@
{
"appContext": "/devicemgt/",
"isCloud": false,
"httpsURL" : "https://%iot.gateway.host%:%iot.gateway.https.port%",
"httpURL" : "http://%iot.gateway.host%:%iot.gateway.http.port",
"wssURL" : "https://%iot.analytics.host%:%iot.analytics.https.port%",

@ -125,6 +125,13 @@ batchProviders = function () {
result = connector.getRecordsByRange(loggedInUser, tablename, from, to, 0, limit, null).getMessage();
}
// error handling ----
var resultString = result.toString();
if (resultString.contains("Failed to get records from table")) {
return null;
}
result = JSON.parse(result);
var data = [];
for (var i = 0; i < result.length; i++) {

@ -71,7 +71,7 @@ deviceModule = function () {
var userName = carbonUser.username + "@" + carbonUser.domain;
var locationDataSet = [];
switch(deviceType) {
switch (deviceType) {
case 'android':
locationDataSet = batchProvider.getData(userName, deviceId, deviceType);
break;
@ -80,24 +80,24 @@ deviceModule = function () {
break;
}
var locationData = [];
var locationTimeData = [];
for (var i = 0 ; i < locationDataSet.length; i++) {
var gpsReading = {};
var gpsReadingTimes = {};
gpsReading.lat = locationDataSet[i].latitude;
gpsReading.lng = locationDataSet[i].longitude;
if (deviceType == "android") {
gpsReadingTimes.time = locationDataSet[i].timeStamp;
} else {
gpsReadingTimes.time = locationDataSet[i].meta_timestamp;
if (locationDataSet != null) {
for (var i = 0; i < locationDataSet.length; i++) {
var gpsReading = {};
var gpsReadingTimes = {};
gpsReading.lat = locationDataSet[i].latitude;
gpsReading.lng = locationDataSet[i].longitude;
if (deviceType == "android") {
gpsReadingTimes.time = locationDataSet[i].timeStamp;
} else {
gpsReadingTimes.time = locationDataSet[i].meta_timestamp;
}
locationData.push(gpsReading);
locationTimeData.push(gpsReadingTimes);
}
locationData.push(gpsReading);
locationTimeData.push(gpsReadingTimes);
}
var utility = require('/app/modules/utility.js')["utility"];
try {
utility.startTenantFlow(carbonUser);

@ -127,14 +127,7 @@
<p class="page-sub-title">User was added successfully.</p>
<p>
An invitation mail will be sent to this user to initiate device enrollment.
Below QR code can also be used to enroll a device.
</p>
<div class="panel panel-default">
<div id="qr-code-modal" class="hidden" data-enrollment-url="{{enrollmentURL}}"></div>
<div class="panel-body">
<div class="qr-code col-lg-5 col-md-6 col-centered"></div>
</div>
</div>
<br>Please click <b>"Add Another User"</b>, if you wish to add another user or click
<b>"View User List"</b> to complete the process and go back to the user list.

@ -0,0 +1,219 @@
{{!
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.
}}
<ul class="nav navbar-right float-remove-xs text-center-xs">
<li class="visible-inline-block">
<a href="#" target="_self" title="kachiex">
<span class="icon fw-stack fw-lg">
<i class="fw fw-organization fw-stack-1x" title=" {{@user.domain}}"></i>
</span>
<span class="hidden-xs">
{{@user.domain}}
</span>
</a>
</li>
<li class="visible-inline-block">
<a href="#" target="_blank" class="dropdown" data-toggle="dropdown" title="Account">
<span class="icon fw-stack fw-lg" style="color: red">
<i class="fw fw-resource fw-stack-1x" title="Account"></i>
</span>
<span class="hidden-xs" style="color: red">
Trial 14 days to upgrade
</span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu dropdown-menu-right float-remove-xs position-static-xs text-center-xs remove-margin-xs slideInDown"
role="menu">
<li>
<a title="Upgrade Now"
href="https://cloudmgt.clouddev.wso2.com/cloudmgt/site/pages/payment-plans.jag?cloud-type=device_cloud"
target="_self">
<i class="fw fw-export" title="Upgrade Now"></i> Upgrade Now
</a>
</li>
<li>
<a title="Monetization"
href="https://cloudmgt.clouddev.wso2.com/cloudmgt/site/pages/monetization-dashboard.jag"
target="_self">
<i class="fa fa-money fa-lg" title="Monetization"></i> Monetization
</a>
</li>
<li>
<a title="Request Extension"
href="https://cloudmgt.clouddev.wso2.com/cloudmgt/site/pages/contact-us.jag?cloud-type=device_cloud&amp;request-extension=true"
target="_blank">
<i class="fw fw-mail" title="Request Extension"></i> Request Extension
</a>
</li>
</ul>
</li>
<li class="visible-inline-block">
<a href="#" target="null" class="dropdown" data-toggle="dropdown" title="Configure">
<span class="icon fw-stack fw-lg">
<i class="fw fw-settings fw-stack-1x" title="Configure"></i>
</span>
<span class="hidden-xs">
Configure
</span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu dropdown-menu-right float-remove-xs position-static-xs text-center-xs remove-margin-xs slideInDown"
role="menu">
</ul>
</li>
<li class="visible-inline-block">
<a href="https://cloudmgt.clouddev.wso2.com/cloudmgt/site/pages/contact-us.jag" target="_self" title="Support">
<span class="icon fw-stack fw-lg" style="color: #ff8c27;">
<i class="fw fw-mail fw-stack-1x" title="Support"></i>
</span>
<span class="hidden-xs" style="color: #ff8c27;">
Support
</span>
</a>
</li>
<li class="visible-inline-block">
<a href="#" target="null" class="dropdown" data-toggle="dropdown" title="Documentation">
<span class="icon fw-stack fw-lg">
<i class="fw fw-document fw-stack-1x" title="Documentation"></i>
</span>
<span class="hidden-xs">
Documentation
</span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu dropdown-menu-right float-remove-xs position-static-xs text-center-xs remove-margin-xs slideInDown"
role="menu">
<li>
<a title="API Cloud" href="https://docs.wso2.com/display/APICloud/WSO2+API+Cloud+Documentation"
target="_blank">
<i class="fw fw-api" title="API Cloud"></i> API Cloud
</a>
</li>
<li>
<a title="App Cloud" href="https://docs.wso2.com/display/AppCloud/WSO2+App+Cloud+Documentation"
target="_blank">
<i class="fw fw-application" title="App Cloud"></i> App Cloud
</a>
</li>
<li>
<a title="App Cloud" href="https://docs.wso2.com/display/AppCloud/WSO2+Device+Cloud+Documentation"
target="_blank">
<i class="fw fw-application" title="App Cloud"></i> Device Cloud
</a>
</li>
<li>
<a title="API Cloud Walkthrough" href="https://api.clouddev.wso2.com/publisher?interactiveTutorial=true"
target="_self">
<i class="fw fw-document" title="API Cloud Walkthrough"></i> API Cloud Walkthrough
</a>
</li>
</ul>
</li>
<li class="visible-inline-block">
<a title="Mobile App Publisher" href="https://devicemgt.clouddev.wso2.com/publisher" target="_self">
<i class="fw fw-user" title="Mobilr App Publisher"></i> App Publisher
</a>
</li>
<li class="visible-inline-block">
<a title="App Store " href="https://devicemgt.clouddev.wso2.com/store"
target="_self">
<i class="fw fw-store" title="App Store"></i> App Store
</a>
</li>
<li class="visible-inline-block">
<a href="#" class="dropdown" data-toggle="dropdown" title="user">
<span class="icon fw-stack fw-lg">
<i class="fw fw-circle-outline fw-stack-2x" title="User"></i>
<i class="fw fw-user fw-stack-1x" title="User"></i>
</span>
<span class="hidden-xs">
{{#if isSuperTenant }}
{{@user.username}}</span><span class="caret"></span>
{{else}}
{{@user.username}}@{{@user.domain}}</span><span class="caret"></span>
{{/if}}
</a>
<ul class="dropdown-menu dropdown-menu-right float-remove-xs position-static-xs text-center-xs remove-margin-xs slideInDown"
role="menu">
<li>
<a title="Profile" href="https://cloudmgt.clouddev.wso2.com/cloudmgt/site/pages/user-profile.jag"
target="_self">
<i class="fw fw-user" title="Profile"></i> Profile
</a>
</li>
<li>
<a title="Change Password"
href="https://cloudmgt.clouddev.wso2.com/cloudmgt/site/pages/change-password.jag" target="_self">
<i class="fw fw-lock" title="Change Password"></i> Change Password
</a>
</li>
<li>
<a title="Logout" href="https://api.clouddev.wso2.com/publisher/site/pages/logout.jag" target="_self">
<i class="fw fw-sign-out" title="Logout"></i> Logout
</a>
</li>
</ul>
</li>
<li class="visible-inline-block cloud-menu">
<a href="#" id="cloud-menu-popover">
<span class="icon fw-stack fw-lg">
<i class="fw fw-tiles fw-stack-1x" data-toggle="popover" data-placement="bottom"
data-original-title="" title=""></i>
</span>
<span class="hidden-xs">
</span>
</a>
</li>
</ul>

@ -0,0 +1,30 @@
/*
* Copyright (c) 2015, 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.
*/
function onRequest(context) {
var constants = require("/app/modules/constants.js");
var user = context.user;
var isSuperTenant = false;
if (user.tenantId == -1234){
isSuperTenant = true;
}
var viewModal = {};
viewModal.isSuperTenant = isSuperTenant;
viewModal.USER_SESSION_KEY = session.get(constants["USER_SESSION_KEY"]);
return viewModal;
}

@ -0,0 +1,123 @@
{{!
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.
}}
<ul class="nav navbar-right float-remove-xs text-center-xs">
<li class="visible-inline-block">
<a href="#" class="dropdown" data-toggle="dropdown">
<i class="fw fw-user fw-lg fw-helper fw-helper-inverse fw-helper-circle"></i>
<span class="hidden-xs add-padding-left-1x">
{{#if isSuperTenant }}
{{@user.username}} "SERVER" <span class="caret"></span>
{{else}}
{{@user.username}}@{{@user.domain}} <span class="caret"></span>
{{/if}}
</span>
</a>
<ul class="dropdown-menu dropdown-menu-right slideInDown"
role="menu">
<li>
<a href="javascript:void(0)" id="change-password">Change Password</a>
</li>
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/logout">Sign out</a>
</li>
<div id="change-password-window" class="hide">
<input type="hidden" id="user" value=" {{@user.username}} ">
<div class="modal-header">
<h4 class="pull-left modal-title">
<span class="fw-stack">
<i class="fw fw-user fw-stack-2x"></i>
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-circle fw-stack-2x fw-stroke text-info"></i>
<i class="fw fw-edit fw-stack-1x fw-inverse"></i>
</span>
</span>
Change password is not a option
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i></button>
</div>
<hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div id="change-password-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<h5>
Type your current password *
<br><br>
<div>
<input id="current-password" type="password" autocomplete="off" class="form-control modal-input"/>
</div>
<br><br>
Type a new password *
<br><br>
<div>
<input id="new-password" type="password" autocomplete="off" class="form-control modal-input"
placeholder="[ Password should be in minimum 5 characters long and should not include any whitespaces ]"/>
</div>
<br><br>
Reconfirm your new password *
<br><br>
<div>
<input id="retyped-new-password" type="password" autocomplete="off" class="form-control modal-input"/>
</div>
<br><br>
</h5>
</div>
<div class="modal-footer">
<div class="buttons">
<a href="#" id="change-password-yes-link" class="btn-operations">Change</a>
<a href="#" id="change-password-cancel-link" class="btn-operations">Cancel</a>
</div>
</div>
</div>
<div id="change-password-success-content" class="hide">
<div class="modal-header">
<h4 class="pull-left modal-title">
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-circle fw-stack-2x fw-stroke text-success"></i>
<i class="fw fw-check fw-stack-1x fw-inverse"></i>
</span>
Password has been successfully updated
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i></button>
</div>
<hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<h5 class="text-center">
You can now try to login using your new password.
</h5>
</div>
<div class="modal-footer">
<div class="buttons">
<a href="#" id="change-password-success-link" class="btn-operations">Ok</a>
</div>
</div>
</div>
</ul>
</li>
</ul>
{{#zone "bottomJs"}}
{{js "/js/user-menu.js"}}
{{/zone}}

@ -0,0 +1,30 @@
/*
* Copyright (c) 2015, 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.
*/
function onRequest(context) {
var constants = require("/app/modules/constants.js");
var user = context.user;
var isSuperTenant = false;
if (user.tenantId == -1234){
isSuperTenant = true;
}
var viewModal = {};
viewModal.isSuperTenant = isSuperTenant;
viewModal.USER_SESSION_KEY = session.get(constants["USER_SESSION_KEY"]);
return viewModal;
}

@ -15,110 +15,11 @@
specific language governing permissions and limitations
under the License.
}}
{{#zone "userMenu"}}
<ul class="nav navbar-right float-remove-xs text-center-xs">
<li class="visible-inline-block">
<a href="#" class="dropdown" data-toggle="dropdown">
<i class="fw fw-user fw-lg fw-helper fw-helper-inverse fw-helper-circle"></i>
<span class="hidden-xs add-padding-left-1x">
{{#if isSuperTenant }}
{{@user.username}}<span class="caret"></span>
{{else}}
{{@user.username}}@{{@user.domain}}<span class="caret"></span>
{{/if}}
</span>
</a>
<ul class="dropdown-menu dropdown-menu-right slideInDown"
role="menu">
<li>
<a href="javascript:void(0)" id="change-password">Change password</a>
</li>
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/logout">Sign out</a>
</li>
<div id="change-password-window" class="hide">
<input type="hidden" id="user" value="{{@user.username}}">
<div class="modal-header">
<h4 class="pull-left modal-title">
<span class="fw-stack">
<i class="fw fw-user fw-stack-2x"></i>
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-circle fw-stack-2x fw-stroke text-info"></i>
<i class="fw fw-edit fw-stack-1x fw-inverse"></i>
</span>
</span>
Change password
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i></button>
</div>
<hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div id="change-password-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<h5>
Type your current password *
<br><br>
<div>
<input id="current-password" type="password" autocomplete="off" class="form-control modal-input"/>
</div>
<br><br>
Type a new password *
<br><br>
<div>
<input id="new-password" type="password" autocomplete="off" class="form-control modal-input"
placeholder="[ Password should be in minimum 5 characters long and should not include any whitespaces ]"/>
</div>
<br><br>
Reconfirm your new password *
<br><br>
<div>
<input id="retyped-new-password" type="password" autocomplete="off" class="form-control modal-input"/>
</div>
<br><br>
</h5>
</div>
<div class="modal-footer">
<div class="buttons">
<a href="#" id="change-password-yes-link" class="btn-operations">Change</a>
<a href="#" id="change-password-cancel-link" class="btn-operations">Cancel</a>
</div>
</div>
</div>
<div id="change-password-success-content" class="hide">
<div class="modal-header">
<h4 class="pull-left modal-title">
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-circle fw-stack-2x fw-stroke text-success"></i>
<i class="fw fw-check fw-stack-1x fw-inverse"></i>
</span>
Password has been successfully updated
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i></button>
</div>
<hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<h5 class="text-center">
You can now try to login using your new password.
</h5>
</div>
<div class="modal-footer">
<div class="buttons">
<a href="#" id="change-password-success-link" class="btn-operations">Ok</a>
</div>
</div>
</div>
</ul>
</li>
</ul>
{{/zone}}
{{#zone "bottomJs"}}
{{js "/js/user-menu.js"}}
{{#zone "userMenu"}}
{{#if isCloud}}
{{unit "cdmf.unit.ui.header.cloud.user-menu"}}
{{else}}
{{unit "cdmf.unit.ui.header.default.user-menu"}}
{{/if}}
{{/zone}}

@ -17,14 +17,8 @@
*/
function onRequest(context) {
var constants = require("/app/modules/constants.js");
var user = context.user;
var isSuperTenant = false;
if (user.tenantId == -1234){
isSuperTenant = true;
}
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var viewModal = {};
viewModal.isSuperTenant = isSuperTenant;
viewModal.USER_SESSION_KEY = session.get(constants["USER_SESSION_KEY"]);
viewModal.isCloud = mdmProps["isCloud"];
return viewModal;
}

@ -6517,7 +6517,7 @@ select > option:hover {
}
.header .fw:before {
color: #000;
}
/* Adding style for required fields */

@ -21,6 +21,9 @@
<div class="pull-left brand">
{{defineZone "brand"}}
</div>
<div class="pull-left brand">
{{defineZone "cloudMenu"}}
</div>
<div class="pull-right auth">
{{defineZone "userMenu"}}
</div>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save