forked from community/device-mgt-core
Merge branch 'master' of https://github.com/wso2/carbon-device-mgt
commit
61e7324f41
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics.dashboard</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - Device Management Dashboard Analytics</name>
|
||||
<description>WSO2 Carbon - Device Management Dashboard Analytics</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||
<Bundle-Description>Device Management Dashboard Analytics Bundle</Bundle-Description>
|
||||
<Private-Package>
|
||||
org.wso2.carbon.device.mgt.analytics.dashboard.dao,
|
||||
org.wso2.carbon.device.mgt.analytics.dashboard.internal
|
||||
</Private-Package>
|
||||
<Export-Package>
|
||||
org.wso2.carbon.device.mgt.analytics.dashboard
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.apache.commons.logging.*,
|
||||
javax.sql,
|
||||
org.wso2.carbon.context,
|
||||
org.wso2.carbon.device.mgt.common.*,
|
||||
org.wso2.carbon.device.mgt.core.*,
|
||||
org.wso2.carbon.ndatasource.core.*;
|
||||
</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* To be updated...
|
||||
*/
|
||||
public interface GadgetDataService {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int getTotalDeviceCount();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int getActiveDeviceCount();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int getInactiveDeviceCount();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int getRemovedDeviceCount();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int getNonCompliantDeviceCount();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int getUnmonitoredDeviceCount();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int getDeviceCount(Map<String, Object> filters);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, Map<String, Object> filters);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map<String, Integer> getDeviceCountsByPlatforms(Map<String, Object> filters);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map<String, Integer> getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode,
|
||||
Map<String, Object> filters);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map<String, Integer> getDeviceCountsByOwnershipTypes(Map<String, Object> filters);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map<String, Integer> getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode,
|
||||
Map<String, Object> filters);
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GadgetDataServiceDAO {
|
||||
|
||||
/**
|
||||
* Method to get total filtered device count from a particular tenant.
|
||||
*
|
||||
* @return Total filtered device count.
|
||||
*/
|
||||
int getTotalDeviceCount() throws GadgetDataServiceDAOException;
|
||||
|
||||
int getActiveDeviceCount() throws GadgetDataServiceDAOException;
|
||||
|
||||
int getInactiveDeviceCount() throws GadgetDataServiceDAOException;
|
||||
|
||||
int getRemovedDeviceCount() throws GadgetDataServiceDAOException;
|
||||
|
||||
/**
|
||||
* Method to get non-compliant device count.
|
||||
*
|
||||
* @return Non-compliant device count.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
int getNonCompliantDeviceCount() throws GadgetDataServiceDAOException;
|
||||
|
||||
/**
|
||||
* Method to get unmonitored device count.
|
||||
*
|
||||
* @return Unmonitored device count.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
int getUnmonitoredDeviceCount() throws GadgetDataServiceDAOException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest) throws GadgetDataServiceDAOException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int getDeviceCount(Map<String, Object> filters) throws GadgetDataServiceDAOException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode,
|
||||
Map<String, Object> filters) throws GadgetDataServiceDAOException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map<String, Integer> getDeviceCountsByPlatforms(Map<String, Object> filters) throws GadgetDataServiceDAOException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map<String, Integer> getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode,
|
||||
Map<String, Object> filters) throws GadgetDataServiceDAOException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map<String, Integer> getDeviceCountsByOwnershipTypes(Map<String, Object> filters)
|
||||
throws GadgetDataServiceDAOException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map<String, Integer> getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode,
|
||||
Map<String, Object> filters) throws GadgetDataServiceDAOException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
List<Map<String, Object>> getDevicesWithDetails(Map<String, Object> filters) throws GadgetDataServiceDAOException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
List<Map<String, Object>> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
|
||||
Map<String, Object> filters) throws GadgetDataServiceDAOException;
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.dao;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
/**
|
||||
* Custom exception class for data access related exceptions.
|
||||
*/
|
||||
public class GadgetDataServiceDAOException extends Exception {
|
||||
private String errorMessage;
|
||||
private static final long serialVersionUID = 2021891706072918864L;
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specific error message and nested exception.
|
||||
*
|
||||
* @param errorMessage specific error message.
|
||||
* @param nestedException Nested exception.
|
||||
*/
|
||||
public GadgetDataServiceDAOException(String errorMessage, Exception nestedException) {
|
||||
super(errorMessage, nestedException);
|
||||
setErrorMessage(errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specific error message and cause.
|
||||
*
|
||||
* @param errorMessage Specific error message.
|
||||
* @param cause Cause of this exception.
|
||||
*/
|
||||
public GadgetDataServiceDAOException(String errorMessage, Throwable cause) {
|
||||
super(errorMessage, cause);
|
||||
setErrorMessage(errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specific error message.
|
||||
*
|
||||
* @param errorMessage Specific error message.
|
||||
*/
|
||||
public GadgetDataServiceDAOException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
setErrorMessage(errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specific error message and cause.
|
||||
*
|
||||
* @param cause Cause of this exception.
|
||||
*/
|
||||
public GadgetDataServiceDAOException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
/*
|
||||
* 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.dao;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.IllegalTransactionStateException;
|
||||
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
|
||||
import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition;
|
||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class GadgetDataServiceDAOFactory {
|
||||
private static final Log log = LogFactory.getLog(GadgetDataServiceDAOFactory.class);
|
||||
private static DataSource dataSource;
|
||||
private static String databaseEngine;
|
||||
private static ThreadLocal<Connection> currentConnection = new ThreadLocal<>();
|
||||
|
||||
public static GadgetDataServiceDAO getGadgetDataServiceDAO() {
|
||||
return new GadgetDataServiceDAOImpl();
|
||||
}
|
||||
|
||||
public static void init(DataSourceConfig config) {
|
||||
dataSource = resolveDataSource(config);
|
||||
try {
|
||||
databaseEngine = dataSource.getConnection().getMetaData().getDatabaseProductName();
|
||||
} catch (SQLException e) {
|
||||
log.error("Error occurred while retrieving config.datasource connection", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(DataSource dtSource) {
|
||||
dataSource = dtSource;
|
||||
try {
|
||||
databaseEngine = dataSource.getConnection().getMetaData().getDatabaseProductName();
|
||||
} catch (SQLException e) {
|
||||
log.error("Error occurred while retrieving config.datasource connection", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void openConnection() throws SQLException {
|
||||
Connection conn = currentConnection.get();
|
||||
if (conn != null) {
|
||||
throw new IllegalTransactionStateException("A transaction is already active within the context of " +
|
||||
"this particular thread. Therefore, calling 'beginTransaction/openConnection' while another " +
|
||||
"transaction is already active is a sign of improper transaction handling");
|
||||
}
|
||||
conn = dataSource.getConnection();
|
||||
currentConnection.set(conn);
|
||||
}
|
||||
|
||||
public static Connection getConnection() throws SQLException {
|
||||
Connection conn = currentConnection.get();
|
||||
if (conn == null) {
|
||||
throw new IllegalTransactionStateException("No connection is associated with the current transaction. " +
|
||||
"This might have ideally been caused by not properly initiating the transaction via " +
|
||||
"'beginTransaction'/'openConnection' methods");
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
public static void closeConnection() {
|
||||
Connection conn = currentConnection.get();
|
||||
if (conn == null) {
|
||||
throw new IllegalTransactionStateException("No connection is associated with the current transaction. " +
|
||||
"This might have ideally been caused by not properly initiating the transaction via " +
|
||||
"'beginTransaction'/'openConnection' methods");
|
||||
}
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
log.warn("Error occurred while close the connection");
|
||||
}
|
||||
currentConnection.remove();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolve data source from the data source definition
|
||||
*
|
||||
* @param config data source configuration
|
||||
* @return data source resolved from the data source definition
|
||||
*/
|
||||
private static DataSource resolveDataSource(DataSourceConfig config) {
|
||||
DataSource dataSource = null;
|
||||
if (config == null) {
|
||||
throw new RuntimeException(
|
||||
"Device Management Repository data source configuration " + "is null and " +
|
||||
"thus, is not initialized");
|
||||
}
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
|
||||
if (jndiConfig != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||
"Lookup Definition");
|
||||
}
|
||||
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList = jndiConfig.getJndiProperties();
|
||||
if (jndiPropertyList != null) {
|
||||
Hashtable<Object, Object> jndiProperties = new Hashtable<>();
|
||||
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||
jndiProperties.put(prop.getName(), prop.getValue());
|
||||
}
|
||||
dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
||||
} else {
|
||||
dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||
}
|
||||
}
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,513 @@
|
||||
/*
|
||||
* 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.dao;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
|
||||
@SuppressWarnings("unused")
|
||||
private static final Log log = LogFactory.getLog(GadgetDataServiceDAOImpl.class);
|
||||
|
||||
@Override
|
||||
public int getTotalDeviceCount() throws GadgetDataServiceDAOException {
|
||||
return this.getDeviceCount(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveDeviceCount() throws GadgetDataServiceDAOException {
|
||||
Map<String, Object> filters = new HashMap<>();
|
||||
filters.put("CONNECTIVITY_STATUS", "ACTIVE");
|
||||
return this.getDeviceCount(filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInactiveDeviceCount() throws GadgetDataServiceDAOException {
|
||||
Map<String, Object> filters = new HashMap<>();
|
||||
filters.put("CONNECTIVITY_STATUS", "INACTIVE");
|
||||
return this.getDeviceCount(filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemovedDeviceCount() throws GadgetDataServiceDAOException {
|
||||
Map<String, Object> filters = new HashMap<>();
|
||||
filters.put("CONNECTIVITY_STATUS", "REMOVED");
|
||||
return this.getDeviceCount(filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNonCompliantDeviceCount() throws GadgetDataServiceDAOException {
|
||||
Map<String, Object> filters = new HashMap<>();
|
||||
filters.put("IS_COMPLIANT", 0);
|
||||
return this.getDeviceCount(filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest) throws GadgetDataServiceDAOException {
|
||||
Connection con;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
List<Map<String, Object>> filteredNonCompliantDeviceCountsByFeatures = new ArrayList<>();
|
||||
int totalRecordsCount = 0;
|
||||
try {
|
||||
con = this.getConnection();
|
||||
String sql = "SELECT FEATURE_CODE, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_2 " +
|
||||
"WHERE TENANT_ID = ? GROUP BY FEATURE_CODE ORDER BY DEVICE_COUNT DESC LIMIT ?, ?";
|
||||
stmt = con.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
stmt.setInt(2, paginationRequest.getStartIndex());
|
||||
stmt.setInt(3, paginationRequest.getRowCount());
|
||||
|
||||
// executing query
|
||||
rs = stmt.executeQuery();
|
||||
// fetching query results
|
||||
Map<String, Object> filteredNonCompliantDeviceCountByFeature;
|
||||
while (rs.next()) {
|
||||
filteredNonCompliantDeviceCountByFeature = new HashMap<>();
|
||||
filteredNonCompliantDeviceCountByFeature.put("FEATURE_CODE", rs.getString("FEATURE_CODE"));
|
||||
filteredNonCompliantDeviceCountByFeature.put("DEVICE_COUNT", rs.getInt("DEVICE_COUNT"));
|
||||
filteredNonCompliantDeviceCountsByFeatures.add(filteredNonCompliantDeviceCountByFeature);
|
||||
}
|
||||
// fetching total records count
|
||||
sql = "SELECT COUNT(FEATURE_CODE) AS NON_COMPLIANT_FEATURE_COUNT FROM " +
|
||||
"(SELECT DISTINCT FEATURE_CODE FROM DEVICES_VIEW_2 WHERE TENANT_ID = ?)";
|
||||
|
||||
stmt = con.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
|
||||
// executing query
|
||||
rs = stmt.executeQuery();
|
||||
// fetching query results
|
||||
while (rs.next()) {
|
||||
totalRecordsCount = rs.getInt("NON_COMPLIANT_FEATURE_COUNT");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
||||
} finally {
|
||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
PaginationResult paginationResult = new PaginationResult();
|
||||
paginationResult.setData(filteredNonCompliantDeviceCountsByFeatures);
|
||||
paginationResult.setRecordsTotal(totalRecordsCount);
|
||||
return paginationResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnmonitoredDeviceCount() throws GadgetDataServiceDAOException {
|
||||
Map<String, Object> filters = new HashMap<>();
|
||||
filters.put("POLICY_ID", -1);
|
||||
return this.getDeviceCount(filters);
|
||||
}
|
||||
|
||||
public int getDeviceCount(Map<String, Object> filters) throws GadgetDataServiceDAOException {
|
||||
Connection con;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
int filteredDeviceCount = 0;
|
||||
try {
|
||||
con = this.getConnection();
|
||||
String sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_1 WHERE TENANT_ID = ?";
|
||||
// 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 + " = ?";
|
||||
}
|
||||
}
|
||||
stmt = con.prepareStatement(sql);
|
||||
// [2] appending filter column values, if exist
|
||||
stmt.setInt(1, tenantId);
|
||||
if (filters != null && filters.values().size() > 0) {
|
||||
int i = 2;
|
||||
for (Object value : filters.values()) {
|
||||
if (value instanceof Integer) {
|
||||
stmt.setInt(i, (Integer) value);
|
||||
} else if (value instanceof String) {
|
||||
stmt.setString(i, (String) value);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// executing query
|
||||
rs = stmt.executeQuery();
|
||||
// fetching query results
|
||||
while (rs.next()) {
|
||||
filteredDeviceCount = rs.getInt("DEVICE_COUNT");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
||||
} finally {
|
||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return filteredDeviceCount;
|
||||
}
|
||||
|
||||
public int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, Map<String, Object> filters) throws GadgetDataServiceDAOException {
|
||||
Connection con;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
int filteredDeviceCount = 0;
|
||||
try {
|
||||
con = this.getConnection();
|
||||
String sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_2 WHERE TENANT_ID = ? AND FEATURE_CODE = ?";
|
||||
// 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 + " = ?";
|
||||
}
|
||||
}
|
||||
stmt = con.prepareStatement(sql);
|
||||
// [2] appending filter column values, if exist
|
||||
stmt.setInt(1, tenantId);
|
||||
stmt.setString(2, nonCompliantFeatureCode);
|
||||
if (filters != null && filters.values().size() > 0) {
|
||||
int i = 3;
|
||||
for (Object value : filters.values()) {
|
||||
if (value instanceof Integer) {
|
||||
stmt.setInt(i, (Integer) value);
|
||||
} else if (value instanceof String) {
|
||||
stmt.setString(i, (String) value);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// executing query
|
||||
rs = stmt.executeQuery();
|
||||
// fetching query results
|
||||
while (rs.next()) {
|
||||
filteredDeviceCount = rs.getInt("DEVICE_COUNT");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
||||
} finally {
|
||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return filteredDeviceCount;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getDeviceCountsByPlatforms(Map<String, Object> filters) throws GadgetDataServiceDAOException {
|
||||
Connection con;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
Map<String, Integer> filteredDeviceCountsByPlatforms = new HashMap<>();
|
||||
try {
|
||||
con = this.getConnection();
|
||||
String sql, advancedSqlFiltering = "";
|
||||
// appending filters if exist, to support advanced filtering options
|
||||
// [1] appending filter columns, if exist
|
||||
if (filters != null && filters.size() > 0) {
|
||||
for (String column : filters.keySet()) {
|
||||
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
|
||||
}
|
||||
}
|
||||
sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_1 WHERE TENANT_ID = ? " +
|
||||
advancedSqlFiltering + "GROUP BY PLATFORM";
|
||||
stmt = con.prepareStatement(sql);
|
||||
// [2] appending filter column values, if exist
|
||||
stmt.setInt(1, tenantId);
|
||||
if (filters != null && filters.values().size() > 0) {
|
||||
int i = 2;
|
||||
for (Object value : filters.values()) {
|
||||
if (value instanceof Integer) {
|
||||
stmt.setInt(i, (Integer) value);
|
||||
} else if (value instanceof String) {
|
||||
stmt.setString(i, (String) value);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// executing query
|
||||
rs = stmt.executeQuery();
|
||||
// fetching query results
|
||||
while (rs.next()) {
|
||||
filteredDeviceCountsByPlatforms.put(rs.getString("PLATFORM"), rs.getInt("DEVICE_COUNT"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
||||
} finally {
|
||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return filteredDeviceCountsByPlatforms;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode, Map<String, Object> filters) throws GadgetDataServiceDAOException {
|
||||
Connection con;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
Map<String, Integer> filteredDeviceCountsByPlatforms = new HashMap<>();
|
||||
try {
|
||||
con = this.getConnection();
|
||||
String sql, advancedSqlFiltering = "";
|
||||
// appending filters if exist, to support advanced filtering options
|
||||
// [1] appending filter columns, if exist
|
||||
if (filters != null && filters.size() > 0) {
|
||||
for (String column : filters.keySet()) {
|
||||
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
|
||||
}
|
||||
}
|
||||
sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_2 WHERE TENANT_ID = ? " +
|
||||
"AND FEATURE_CODE = ? " + advancedSqlFiltering + "GROUP BY PLATFORM";
|
||||
stmt = con.prepareStatement(sql);
|
||||
// [2] appending filter column values, if exist
|
||||
stmt.setInt(1, tenantId);
|
||||
stmt.setString(2, nonCompliantFeatureCode);
|
||||
if (filters != null && filters.values().size() > 0) {
|
||||
int i = 3;
|
||||
for (Object value : filters.values()) {
|
||||
if (value instanceof Integer) {
|
||||
stmt.setInt(i, (Integer) value);
|
||||
} else if (value instanceof String) {
|
||||
stmt.setString(i, (String) value);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// executing query
|
||||
rs = stmt.executeQuery();
|
||||
// fetching query results
|
||||
while (rs.next()) {
|
||||
filteredDeviceCountsByPlatforms.put(rs.getString("PLATFORM"), rs.getInt("DEVICE_COUNT"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
||||
} finally {
|
||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return filteredDeviceCountsByPlatforms;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getDeviceCountsByOwnershipTypes(Map<String, Object> filters) throws GadgetDataServiceDAOException {
|
||||
Connection con;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
Map<String, Integer> filteredDeviceCountsByOwnershipTypes = new HashMap<>();
|
||||
try {
|
||||
con = this.getConnection();
|
||||
String sql, advancedSqlFiltering = "";
|
||||
// appending filters if exist, to support advanced filtering options
|
||||
// [1] appending filter columns, if exist
|
||||
if (filters != null && filters.size() > 0) {
|
||||
for (String column : filters.keySet()) {
|
||||
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
|
||||
}
|
||||
}
|
||||
sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_1 WHERE TENANT_ID = ? " +
|
||||
advancedSqlFiltering + "GROUP BY OWNERSHIP";
|
||||
stmt = con.prepareStatement(sql);
|
||||
// [2] appending filter column values, if exist
|
||||
stmt.setInt(1, tenantId);
|
||||
if (filters != null && filters.values().size() > 0) {
|
||||
int i = 2;
|
||||
for (Object value : filters.values()) {
|
||||
if (value instanceof Integer) {
|
||||
stmt.setInt(i, (Integer) value);
|
||||
} else if (value instanceof String) {
|
||||
stmt.setString(i, (String) value);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// executing query
|
||||
rs = stmt.executeQuery();
|
||||
// fetching query results
|
||||
while (rs.next()) {
|
||||
filteredDeviceCountsByOwnershipTypes.put(rs.getString("OWNERSHIP"), rs.getInt("DEVICE_COUNT"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
||||
} finally {
|
||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return filteredDeviceCountsByOwnershipTypes;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode, Map<String, Object> filters) throws GadgetDataServiceDAOException {
|
||||
Connection con;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
Map<String, Integer> filteredDeviceCountsByOwnershipTypes = new HashMap<>();
|
||||
try {
|
||||
con = this.getConnection();
|
||||
String sql, advancedSqlFiltering = "";
|
||||
// appending filters if exist, to support advanced filtering options
|
||||
// [1] appending filter columns, if exist
|
||||
if (filters != null && filters.size() > 0) {
|
||||
for (String column : filters.keySet()) {
|
||||
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
|
||||
}
|
||||
}
|
||||
sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_2 WHERE TENANT_ID = ? " +
|
||||
"AND FEATURE_CODE = ? " + advancedSqlFiltering + "GROUP BY OWNERSHIP";
|
||||
stmt = con.prepareStatement(sql);
|
||||
// [2] appending filter column values, if exist
|
||||
stmt.setInt(1, tenantId);
|
||||
stmt.setString(2, nonCompliantFeatureCode);
|
||||
if (filters != null && filters.values().size() > 0) {
|
||||
int i = 3;
|
||||
for (Object value : filters.values()) {
|
||||
if (value instanceof Integer) {
|
||||
stmt.setInt(i, (Integer) value);
|
||||
} else if (value instanceof String) {
|
||||
stmt.setString(i, (String) value);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// executing query
|
||||
rs = stmt.executeQuery();
|
||||
// fetching query results
|
||||
while (rs.next()) {
|
||||
filteredDeviceCountsByOwnershipTypes.put(rs.getString("OWNERSHIP"), rs.getInt("DEVICE_COUNT"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
||||
} finally {
|
||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return filteredDeviceCountsByOwnershipTypes;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getDevicesWithDetails(Map<String, Object> filters) throws GadgetDataServiceDAOException {
|
||||
Connection con;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
Map<String, Object> filteredDeviceWithDetails = new HashMap<>();
|
||||
List<Map<String, Object>> filteredDevicesWithDetails = new ArrayList<>();
|
||||
try {
|
||||
con = this.getConnection();
|
||||
String sql;
|
||||
sql = "SELECT DEVICE_ID, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM DEVICES_VIEW_1 WHERE TENANT_ID = ?";
|
||||
// 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 + " = ?";
|
||||
}
|
||||
}
|
||||
stmt = con.prepareStatement(sql);
|
||||
// [2] appending filter column values, if exist
|
||||
stmt.setInt(1, tenantId);
|
||||
if (filters != null && filters.values().size() > 0) {
|
||||
int i = 2;
|
||||
for (Object value : filters.values()) {
|
||||
if (value instanceof Integer) {
|
||||
stmt.setInt(i, (Integer) value);
|
||||
} else if (value instanceof String) {
|
||||
stmt.setString(i, (String) value);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// executing query
|
||||
rs = stmt.executeQuery();
|
||||
// fetching query results
|
||||
while (rs.next()) {
|
||||
filteredDeviceWithDetails.put("device-id", rs.getInt("DEVICE_ID"));
|
||||
filteredDeviceWithDetails.put("platform", rs.getString("PLATFORM"));
|
||||
filteredDeviceWithDetails.put("ownership", rs.getString("OWNERSHIP"));
|
||||
filteredDeviceWithDetails.put("connectivity-details", rs.getString("CONNECTIVITY_STATUS"));
|
||||
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
||||
} finally {
|
||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return filteredDevicesWithDetails;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, Map<String, Object> filters) throws GadgetDataServiceDAOException {
|
||||
Connection con;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
Map<String, Object> filteredDeviceWithDetails = new HashMap<>();
|
||||
List<Map<String, Object>> filteredDevicesWithDetails = new ArrayList<>();
|
||||
try {
|
||||
con = this.getConnection();
|
||||
String sql;
|
||||
sql = "SELECT DEVICE_ID, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM DEVICES_VIEW_2 " +
|
||||
"WHERE TENANT_ID = ? AND FEATURE_CODE = ?";
|
||||
// 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 + " = ?";
|
||||
}
|
||||
}
|
||||
stmt = con.prepareStatement(sql);
|
||||
// [2] appending filter column values, if exist
|
||||
stmt.setInt(1, tenantId);
|
||||
stmt.setString(2, nonCompliantFeatureCode);
|
||||
if (filters != null && filters.values().size() > 0) {
|
||||
int i = 3;
|
||||
for (Object value : filters.values()) {
|
||||
if (value instanceof Integer) {
|
||||
stmt.setInt(i, (Integer) value);
|
||||
} else if (value instanceof String) {
|
||||
stmt.setString(i, (String) value);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// executing query
|
||||
rs = stmt.executeQuery();
|
||||
// fetching query results
|
||||
while (rs.next()) {
|
||||
filteredDeviceWithDetails.put("device-id", rs.getInt("DEVICE_ID"));
|
||||
filteredDeviceWithDetails.put("platform", rs.getString("PLATFORM"));
|
||||
filteredDeviceWithDetails.put("ownership", rs.getString("OWNERSHIP"));
|
||||
filteredDeviceWithDetails.put("connectivity-details", rs.getString("CONNECTIVITY_STATUS"));
|
||||
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
||||
} finally {
|
||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return filteredDevicesWithDetails;
|
||||
}
|
||||
|
||||
private Connection getConnection() throws SQLException {
|
||||
return GadgetDataServiceDAOFactory.getConnection();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataService;
|
||||
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOFactory;
|
||||
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
||||
import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
|
||||
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
|
||||
import org.wso2.carbon.ndatasource.core.DataSourceService;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
/**
|
||||
* @scr.component name="org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataService" immediate="true"
|
||||
* @scr.reference name="org.wso2.carbon.ndatasource"
|
||||
* interface="org.wso2.carbon.ndatasource.core.DataSourceService"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setDataSourceService"
|
||||
* unbind="unsetDataSourceService"
|
||||
*/
|
||||
public class GadgetDataServiceComponent {
|
||||
private static final Log log = LogFactory.getLog(GadgetDataServiceComponent.class);
|
||||
|
||||
protected void activate(ComponentContext componentContext) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Starting Device Management Dashboard Analytics Bundle...");
|
||||
}
|
||||
try {
|
||||
DeviceConfigurationManager.getInstance().initConfig();
|
||||
DeviceManagementConfig config =
|
||||
DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
|
||||
|
||||
DataSourceConfig dsConfig = config.getDeviceManagementConfigRepository().getDataSourceConfig();
|
||||
GadgetDataServiceDAOFactory.init(dsConfig);
|
||||
//Register GadgetDataService to expose corresponding data to external parties.
|
||||
componentContext.getBundleContext().
|
||||
registerService(GadgetDataService.class.getName(), new GadgetDataServiceImpl(), null);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Device Management Dashboard Analytics Bundle has been started successfully");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("Error occurred while initializing the bundle", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void deactivate(ComponentContext componentContext) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Deactivating Device Management Dashboard Analytics Bundle...");
|
||||
}
|
||||
//do nothing
|
||||
}
|
||||
|
||||
public void setDataSourceService(DataSourceService dataSourceService){
|
||||
|
||||
}
|
||||
|
||||
public void unsetDataSourceService(DataSourceService dataSourceService){
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,239 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
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.dao.GadgetDataServiceDAOException;
|
||||
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOFactory;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* To be updated...
|
||||
*/
|
||||
class GadgetDataServiceImpl implements GadgetDataService {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final Log log = LogFactory.getLog(GadgetDataServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public int getTotalDeviceCount() {
|
||||
int totalDeviceCount;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
totalDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getTotalDeviceCount();
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
totalDeviceCount = -1;
|
||||
return totalDeviceCount;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return totalDeviceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveDeviceCount() {
|
||||
int activeDeviceCount;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
activeDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getActiveDeviceCount();
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
activeDeviceCount = -1;
|
||||
return activeDeviceCount;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return activeDeviceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInactiveDeviceCount() {
|
||||
int inactiveDeviceCount;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
inactiveDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getInactiveDeviceCount();
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
inactiveDeviceCount = -1;
|
||||
return inactiveDeviceCount;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return inactiveDeviceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemovedDeviceCount() {
|
||||
int removedDeviceCount;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
removedDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getRemovedDeviceCount();
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
removedDeviceCount = -1;
|
||||
return removedDeviceCount;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return removedDeviceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNonCompliantDeviceCount() {
|
||||
int nonCompliantDeviceCount;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
nonCompliantDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getNonCompliantDeviceCount();
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
nonCompliantDeviceCount = -1;
|
||||
return nonCompliantDeviceCount;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return nonCompliantDeviceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnmonitoredDeviceCount() {
|
||||
int unmonitoredDeviceCount;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
unmonitoredDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getUnmonitoredDeviceCount();
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
unmonitoredDeviceCount = -1;
|
||||
return unmonitoredDeviceCount;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return unmonitoredDeviceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest) {
|
||||
PaginationResult paginationResult = null;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
|
||||
getNonCompliantDeviceCountsByFeatures(paginationRequest);
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
return null;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return paginationResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDeviceCount(Map<String, Object> filters) {
|
||||
int deviceCount;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
deviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getDeviceCount(filters);
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
deviceCount = -1;
|
||||
return deviceCount;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return deviceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, Map<String, Object> filters) {
|
||||
int featureNonCompliantDeviceCount;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
featureNonCompliantDeviceCount = GadgetDataServiceDAOFactory.
|
||||
getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCount(nonCompliantFeatureCode, filters);
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
featureNonCompliantDeviceCount = -1;
|
||||
return featureNonCompliantDeviceCount;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return featureNonCompliantDeviceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> getDeviceCountsByPlatforms(Map<String, Object> filters) {
|
||||
Map<String, Integer> deviceCountsByPlatforms = null;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
deviceCountsByPlatforms = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
|
||||
getDeviceCountsByPlatforms(filters);
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
return null;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return deviceCountsByPlatforms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode,
|
||||
Map<String, Object> filters) {
|
||||
Map<String, Integer> featureNonCompliantDeviceCountsByPlatforms = null;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
featureNonCompliantDeviceCountsByPlatforms = GadgetDataServiceDAOFactory.
|
||||
getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCountsByPlatforms(nonCompliantFeatureCode, filters);
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
return null;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return featureNonCompliantDeviceCountsByPlatforms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> getDeviceCountsByOwnershipTypes(Map<String, Object> filters) {
|
||||
Map<String, Integer> deviceCountsByOwnershipTypes = null;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
deviceCountsByOwnershipTypes = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
|
||||
getDeviceCountsByOwnershipTypes(filters);
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
return null;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return deviceCountsByOwnershipTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode,
|
||||
Map<String, Object> filters) {
|
||||
Map<String, Integer> featureNonCompliantDeviceCountsByOwnershipTypes = null;
|
||||
try {
|
||||
GadgetDataServiceDAOFactory.openConnection();
|
||||
featureNonCompliantDeviceCountsByOwnershipTypes =
|
||||
GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
|
||||
getFeatureNonCompliantDeviceCountsByOwnershipTypes(nonCompliantFeatureCode, filters);
|
||||
} catch (GadgetDataServiceDAOException | SQLException e) {
|
||||
return null;
|
||||
} finally {
|
||||
GadgetDataServiceDAOFactory.closeConnection();
|
||||
}
|
||||
return featureNonCompliantDeviceCountsByOwnershipTypes;
|
||||
}
|
||||
|
||||
}
|
@ -1,20 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* 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.
|
||||
* 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.mdm.api.util;
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.api.util;
|
||||
|
||||
/**
|
||||
* This class holds all the constants used for IOS and Android.
|
@ -1,23 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
* 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.mdm.beans;
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import java.util.List;
|
@ -1,22 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
* 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
|
||||
* 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
|
||||
* "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.mdm.beans;
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
public class PriorityUpdatedPolicyWrapper {
|
||||
|
@ -1,22 +1,22 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.beans;
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
|
||||
|
@ -1,26 +1,25 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.beans;
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class ProfileFeature implements Serializable {
|
||||
|
@ -1,24 +1,25 @@
|
||||
package org.wso2.carbon.mdm.beans;
|
||||
|
||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
* 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
|
||||
* 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
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
||||
|
||||
public class RoleWrapper {
|
||||
private String roleName;
|
||||
private String[] permissions;
|
@ -1,22 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
* 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
|
||||
* 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
|
||||
* "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.mdm.beans;
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
public class UserCredentialWrapper {
|
||||
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans.android;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the Appstore Application information.
|
||||
*/
|
||||
public class AppStoreApplication implements Serializable {
|
||||
|
||||
private String type;
|
||||
private String appIdentifier;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMAPIException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans.android;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the Enterprise Application information.
|
||||
*/
|
||||
public class EnterpriseApplication implements Serializable {
|
||||
|
||||
private String type;
|
||||
private String url;
|
||||
private String appIdentifier;
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMAPIException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans.android;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the Web Application information.
|
||||
*/
|
||||
public class WebApplication implements Serializable {
|
||||
|
||||
private String name;
|
||||
private String url;
|
||||
private String type;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMAPIException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -1,8 +1,25 @@
|
||||
package org.wso2.carbon.mdm.beans.ios;
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans.ios;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.carbon.mdm.api.common.MDMAPIException;
|
||||
import java.io.IOException;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
|
||||
|
||||
public class WebClip {
|
||||
|
@ -1,23 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
* 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.mdm.common;
|
||||
package org.wso2.carbon.device.mgt.jaxrs.common;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed 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.mdm.beans.android;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.carbon.mdm.api.common.MDMAPIException;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the Appstore Application information.
|
||||
*/
|
||||
public class AppStoreApplication implements Serializable {
|
||||
|
||||
private String type;
|
||||
private String appIdentifier;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMAPIException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed 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.mdm.beans.android;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.carbon.mdm.api.common.MDMAPIException;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the Enterprise Application information.
|
||||
*/
|
||||
public class EnterpriseApplication implements Serializable {
|
||||
|
||||
private String type;
|
||||
private String url;
|
||||
private String appIdentifier;
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMAPIException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed 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.mdm.beans.android;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.carbon.mdm.api.common.MDMAPIException;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the Web Application information.
|
||||
*/
|
||||
public class WebApplication implements Serializable {
|
||||
|
||||
private String name;
|
||||
private String url;
|
||||
private String type;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMAPIException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package org.wso2.carbon.mdm.beans.ios;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.wso2.carbon.mdm.api.common.MDMAPIException;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class RemoveApplication implements Serializable {
|
||||
|
||||
private String bundleId;
|
||||
|
||||
public String getBundleId() {
|
||||
return bundleId;
|
||||
}
|
||||
|
||||
public void setBundleId(String bundleId) {
|
||||
this.bundleId = bundleId;
|
||||
}
|
||||
|
||||
public String toJSON() throws MDMAPIException {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.common;
|
||||
|
||||
public class ProvisioningConfig {
|
||||
|
||||
private String providerTenantDomain;
|
||||
private boolean isSharedWithAllTenants;
|
||||
|
||||
public ProvisioningConfig(String providerTenantDomain, boolean sharedWithAllTenants) {
|
||||
this.providerTenantDomain = providerTenantDomain;
|
||||
isSharedWithAllTenants = sharedWithAllTenants;
|
||||
}
|
||||
|
||||
public String getProviderTenantDomain() {
|
||||
return providerTenantDomain;
|
||||
}
|
||||
|
||||
public boolean isSharedWithAllTenants() {
|
||||
return isSharedWithAllTenants;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.common.push.notification;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class PushNotificationConfig {
|
||||
|
||||
private String type;
|
||||
private Set<String> properties;
|
||||
|
||||
public PushNotificationConfig(String type, Set<String> properties) {
|
||||
this.type = type;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Set<String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
@ -1,133 +0,0 @@
|
||||
<%
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
var uri = request.getRequestURI();
|
||||
var uriMatcher = new URIMatcher(String(uri));
|
||||
|
||||
var log = new Log("apis/group-api.jag");
|
||||
|
||||
var constants = require("/app/modules/constants.js");
|
||||
|
||||
var utility = require("/app/modules/utility.js").utility;
|
||||
var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
|
||||
var responseProcessor = require('utils').response;
|
||||
|
||||
var deviceCloudService = devicemgtProps["httpsURL"] + "/common/group_manager";
|
||||
|
||||
var user = session.get(constants.USER_SESSION_KEY);
|
||||
|
||||
var groupModule = require("/app/modules/group.js").groupModule;
|
||||
|
||||
var result, endPoint, data, groupId, group, role;
|
||||
|
||||
if (!user) {
|
||||
response = responseProcessor.buildErrorResponse(response, 401, "Unauthorized");
|
||||
} else {
|
||||
|
||||
if (uriMatcher.match("/{context}/api/group/add")) {
|
||||
group = request.getContent();
|
||||
result = groupModule.addGroup(group);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/update")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
group = request.getContent();
|
||||
result = groupModule.updateGroup(groupId, group);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/remove")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
result = groupModule.removeGroup(groupId);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
result = groupModule.getGroup(groupId);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/name/{groupName}")) {
|
||||
var groupName = uriMatcher.elements().groupName;
|
||||
result = groupModule.findGroups(groupName);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/all")) {
|
||||
result = groupModule.getGroups();
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/all/count")) {
|
||||
result = groupModule.getGroupCount();
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/share")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
var shareUser = request.getContent()["shareUser"];
|
||||
role = request.getContent()["role"];
|
||||
result = groupModule.shareGroup(groupId, shareUser, role);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/unshare")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
var unShareUser = request.getContent()["unShareUser"];
|
||||
role = request.getContent()["role"];
|
||||
result = groupModule.unshareGroup(groupId, unShareUser, role);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/add")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
var permissions = request.getContent()["permissions"];
|
||||
role = request.getContent()["role"];
|
||||
result = groupModule.addRole(groupId, role, permissions);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/delete")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
role = request.getContent()["role"];
|
||||
endPoint = deviceCloudService + "/group/id/" + groupId + "/role/" + role;
|
||||
result = groupModule.deleteRole(groupId, role);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/all")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
result = groupModule.getGroupRoles(groupId);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/{userId}/role/all")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
var userId = uriMatcher.elements().userId;
|
||||
result = groupModule.getUserRoles(groupId, userId);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/{userId}/rolemapping")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
userId = uriMatcher.elements().userId;
|
||||
result = groupModule.getRoleMapping(groupId, userId);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/{userId}/roleupdate")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
userId = uriMatcher.elements().userId;
|
||||
var roleMap = request.getContent();
|
||||
result = groupModule.setRoleMapping(groupId, userId, roleMap);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/user/all")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
result = groupModule.getUsers(groupId);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/device/all")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
result = groupModule.getDevices(groupId);
|
||||
|
||||
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/assign")) {
|
||||
groupId = uriMatcher.elements().groupId;
|
||||
var deviceId = request.getContent()["deviceId"];
|
||||
var deviceType = request.getContent()["deviceType"];
|
||||
result = groupModule.assignDevice(groupId, deviceId, deviceType);
|
||||
}
|
||||
}
|
||||
// returning the result.
|
||||
if (result) {
|
||||
print(result);
|
||||
}
|
||||
%>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue