revert-70aa11f8
Pasindu 8 years ago
commit d666f9ea14

@ -22,13 +22,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Security Handler Component</name>
<description>WSO2 Carbon - API Management Security Handler Module</description>

@ -13,13 +13,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Client</name>
<description>WSO2 Carbon - API Management Integration Client</description>

@ -21,24 +21,43 @@ package org.wso2.carbon.apimgt.integration.client.util;
import feign.Client;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.net.ssl.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.io.InputStream;
import java.security.*;
import java.security.cert.CertificateException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import feign.Logger;
import feign.Request;
import feign.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.base.ServerConfiguration;
public class Utils {
private static final Log log = LogFactory.getLog(Utils.class);
private static final String KEY_STORE_TYPE = "JKS";
/**
* Default truststore type of the client
*/
private static final String TRUST_STORE_TYPE = "JKS";
/**
* Default keymanager type of the client
*/
private static final String KEY_MANAGER_TYPE = "SunX509"; //Default Key Manager Type
/**
* Default trustmanager type of the client
*/
private static final String TRUST_MANAGER_TYPE = "SunX509"; //Default Trust Manager Type
private static final String SSLV3 = "SSLv3";
//This method is only used if the mb features are within DAS.
public static String replaceProperties(String text) {
String regex = "\\$\\{(.*?)\\}";
@ -55,15 +74,20 @@ public class Utils {
}
public static Client getSSLClient() {
return new Client.Default(getTrustedSSLSocketFactory(), new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
});
boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System.getProperty("org.wso2.ignoreHostnameVerification"));
if(isIgnoreHostnameVerification) {
return new Client.Default(getSimpleTrustedSSLSocketFactory(), new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
});
}else {
return new Client.Default(getTrustedSSLSocketFactory(), null);
}
}
private static SSLSocketFactory getTrustedSSLSocketFactory() {
private static SSLSocketFactory getSimpleTrustedSSLSocketFactory() {
try {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@ -86,4 +110,60 @@ public class Utils {
}
}
private static SSLSocketFactory getTrustedSSLSocketFactory() {
try {
String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password");
String keyStoreLocation = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Location");
String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty(
"Security.TrustStore.Password");
String trustStoreLocation = ServerConfiguration.getInstance().getFirstProperty(
"Security.TrustStore.Location");
KeyStore keyStore = loadKeyStore(keyStoreLocation,keyStorePassword,KEY_STORE_TYPE);
KeyStore trustStore = loadTrustStore(trustStoreLocation,trustStorePassword);
return initSSLConnection(keyStore,keyStorePassword,trustStore);
} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException
|CertificateException | IOException | UnrecoverableKeyException e) {
log.error("Error while creating the SSL socket factory due to "+e.getMessage(),e);
return null;
}
}
private static SSLSocketFactory initSSLConnection(KeyStore keyStore,String keyStorePassword,KeyStore trustStore) throws NoSuchAlgorithmException, UnrecoverableKeyException,
KeyStoreException, KeyManagementException {
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KEY_MANAGER_TYPE);
keyManagerFactory.init(keyStore, keyStorePassword.toCharArray());
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TRUST_MANAGER_TYPE);
trustManagerFactory.init(trustStore);
// Create and initialize SSLContext for HTTPS communication
SSLContext sslContext = SSLContext.getInstance(SSLV3);
sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
SSLContext.setDefault(sslContext);
return sslContext.getSocketFactory();
}
private static KeyStore loadKeyStore(String keyStorePath, String ksPassword,String type)
throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
InputStream fileInputStream = null;
try {
char[] keypassChar = ksPassword.toCharArray();
KeyStore keyStore = KeyStore.getInstance(type);
fileInputStream = new FileInputStream(keyStorePath);
keyStore.load(fileInputStream, keypassChar);
return keyStore;
} finally {
if (fileInputStream != null) {
fileInputStream.close();
}
}
}
private static KeyStore loadTrustStore(String trustStorePath, String tsPassword)
throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
return loadKeyStore(trustStorePath,tsPassword,TRUST_STORE_TYPE);
}
}

@ -13,13 +13,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Generated Client</name>
<description>WSO2 Carbon - API Management Integration Client</description>

@ -22,13 +22,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apimgt-extensions</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

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

@ -21,13 +21,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

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

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

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

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

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

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

@ -3,7 +3,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

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

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

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

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

@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlRootElement;
public class GeoLocationConfiguration {
private boolean publishLocationOperationResponse;
private boolean isEnabled;
public boolean getPublishLocationOperationResponse() {
return publishLocationOperationResponse;
@ -37,4 +38,13 @@ public class GeoLocationConfiguration {
public void setPublishLocationOperationResponse(boolean publishLocationOperationResponse) {
this.publishLocationOperationResponse = publishLocationOperationResponse;
}
public boolean getIsEnabled() {
return isEnabled;
}
@XmlElement(name = "isEnabled", required = true)
public void setEnabled(boolean enabled) {
isEnabled = enabled;
}
}

@ -155,7 +155,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_DETAIL dt " +
"WHERE t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? AND dt.DEVICE_ID = d.ID " +
"AND dt.UPDATE_TIMESTAMP > ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?" ;
"AND dt.UPDATE_TIMESTAMP > ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC" ;
stmt = conn.prepareStatement(sql);
int paramIdx = 1;
stmt.setString(paramIdx++, deviceIdentifier.getType());
@ -190,7 +190,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " +
"t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " +
"AND TENANT_ID = ? AND e.STATUS = ?";
"AND TENANT_ID = ? AND e.STATUS = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC";
stmt = conn.prepareStatement(sql);
stmt.setString(1, deviceIdentifier.getType());
stmt.setString(2, deviceIdentifier.getId());
@ -285,7 +285,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID, " +
"d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
"DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?) d1 " +
"WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?";
"WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, tenantId);
stmt.setInt(2, tenantId);
@ -317,7 +317,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " +
"d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
"DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND t.NAME = ? " +
"AND t.ID = d.DEVICE_TYPE_ID AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?";
"AND t.ID = d.DEVICE_TYPE_ID AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?" +
" ORDER BY e.DATE_OF_LAST_UPDATE DESC";
stmt = conn.prepareStatement(sql);
stmt.setString(1, type);
stmt.setInt(2, tenantId);
@ -350,7 +351,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
" e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.DEVICE_IDENTIFICATION, t.NAME " +
"AS DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, " +
"e.DEVICE_ID, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " +
"e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?)) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " +
"e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?) ORDER BY e.DATE_OF_LAST_UPDATE DESC) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " +
"AND t.ID = d.DEVICE_TYPE_ID";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, tenantId);
@ -383,7 +384,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
" e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.DEVICE_IDENTIFICATION, t.NAME " +
"AS DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, " +
"e.DEVICE_ID, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " +
"e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?)) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " +
"e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?) ORDER BY e.DATE_OF_LAST_UPDATE DESC) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " +
"AND t.ID = d.DEVICE_TYPE_ID AND t.NAME= ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, tenantId);

@ -200,33 +200,7 @@ public final class DeviceManagementDAOUtil {
if (deviceInfoIncluded) {
device.setDeviceInfo(loadDeviceInfo(rs));
}
if (EnrolmentInfo.Status.ACTIVE.equals(device.getEnrolmentInfo().getStatus())) {
return device;
}
deviceMap.put(device.getEnrolmentInfo().getStatus(), device);
while (rs.next()) {
device = loadDevice(rs);
if (deviceInfoIncluded) {
device.setDeviceInfo(loadDeviceInfo(rs));
}
if (EnrolmentInfo.Status.ACTIVE.equals(device.getEnrolmentInfo().getStatus())) {
return device;
}
if (device.getEnrolmentInfo() != null) {
deviceMap.put(device.getEnrolmentInfo().getStatus(), device);
}
}
if (deviceMap.containsKey(EnrolmentInfo.Status.UNREACHABLE)) {
return deviceMap.get(EnrolmentInfo.Status.UNREACHABLE);
} else if (deviceMap.containsKey(EnrolmentInfo.Status.INACTIVE)) {
return deviceMap.get(EnrolmentInfo.Status.INACTIVE);
} else if (deviceMap.containsKey(EnrolmentInfo.Status.CREATED)) {
return deviceMap.get(EnrolmentInfo.Status.CREATED);
} else if (deviceMap.containsKey(EnrolmentInfo.Status.UNCLAIMED)) {
return deviceMap.get(EnrolmentInfo.Status.UNCLAIMED);
}
return null;
return device;
}
//This method will retrieve most appropriate device information when there are multiple device enrollments for
@ -237,39 +211,6 @@ public final class DeviceManagementDAOUtil {
if (deviceInfoIncluded) {
device.setDeviceInfo(loadDeviceInfo(rs));
}
if (EnrolmentInfo.Status.ACTIVE.equals(device.getEnrolmentInfo().getStatus())) {
return device;
}
while (rs.next()) {
device = loadDevice(rs);
if (deviceInfoIncluded) {
device.setDeviceInfo(loadDeviceInfo(rs));
}
if (EnrolmentInfo.Status.ACTIVE.equals(device.getEnrolmentInfo().getStatus())) {
return device;
}
if (device.getEnrolmentInfo() != null) {
deviceMap.put(device.getEnrolmentInfo().getStatus(), device);
}
}
if (deviceMap.containsKey(EnrolmentInfo.Status.UNREACHABLE)) {
return deviceMap.get(EnrolmentInfo.Status.UNREACHABLE);
} else if (deviceMap.containsKey(EnrolmentInfo.Status.INACTIVE)) {
return deviceMap.get(EnrolmentInfo.Status.INACTIVE);
} else if (deviceMap.containsKey(EnrolmentInfo.Status.DISENROLLMENT_REQUESTED)) {
return deviceMap.get(EnrolmentInfo.Status.DISENROLLMENT_REQUESTED);
} else if (deviceMap.containsKey(EnrolmentInfo.Status.CREATED)) {
return deviceMap.get(EnrolmentInfo.Status.CREATED);
} else if (deviceMap.containsKey(EnrolmentInfo.Status.REMOVED)) {
return deviceMap.get(EnrolmentInfo.Status.REMOVED);
} else if (deviceMap.containsKey(EnrolmentInfo.Status.UNCLAIMED)) {
return deviceMap.get(EnrolmentInfo.Status.UNCLAIMED);
} else if (deviceMap.containsKey(EnrolmentInfo.Status.SUSPENDED)) {
return deviceMap.get(EnrolmentInfo.Status.SUSPENDED);
} else if (deviceMap.containsKey(EnrolmentInfo.Status.BLOCKED)) {
return deviceMap.get(EnrolmentInfo.Status.BLOCKED);
}
return device;
}

@ -18,8 +18,6 @@
package org.wso2.carbon.device.mgt.core.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeMetaDefinition;
@ -36,7 +34,6 @@ public class DeviceType implements Serializable {
@ApiModelProperty(name = "name", value = "Device type name", required = true)
private String name;
@JsonProperty("metaDefinition")
@ApiModelProperty(name = "metaDefinition", value = "Device type definition", required = true)
private DeviceTypeMetaDefinition deviceTypeMetaDefinition;
@ -47,7 +44,6 @@ public class DeviceType implements Serializable {
this.name = name;
}
@JsonIgnore
public int getId() {
return id;
}

@ -213,6 +213,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
enrolmentId = enrollmentDAO.
addEnrollment(existingDevice.getId(), newEnrolmentInfo, tenantId);
DeviceManagementDAOFactory.commitTransaction();
this.removeDeviceFromCache(deviceIdentifier);
if (log.isDebugEnabled()) {
log.debug("An enrolment is successfully added with the id '" + enrolmentId +
"' associated with " + "the device identified by key '" +

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

@ -36,7 +36,7 @@ import java.util.List;
* Implements CRUD for Devices. This holds the generic implementation. An instance of this will be created for
* each device type.
*/
public class DeviceTypePluginDAOImpl implements PluginDAO{
public class DeviceTypePluginDAOImpl implements PluginDAO {
private static final Log log = LogFactory.getLog(DeviceTypePluginDAOImpl.class);
private DeviceTypeDAOHandler deviceTypeDAOHandler;
@ -241,9 +241,11 @@ public class DeviceTypePluginDAOImpl implements PluginDAO{
}
private String getPropertString(List<Device.Property> properties, String propertyName) {
for (Device.Property property : properties) {
if (property.getName() != null && property.getName().equals(propertyName)) {
return property.getValue();
if (properties != null) {
for (Device.Property property : properties) {
if (property.getName() != null && property.getName().equals(propertyName)) {
return property.getValue();
}
}
}
return null;

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

@ -1,6 +1,7 @@
{
"appContext": "/devicemgt/",
"isCloud": false,
"isDeviceOwnerEnabled": 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%",

@ -1,112 +1,137 @@
{
"Logo": {
"name": "Cloud",
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt",
"target": "_parent"
},
"Main": {
"Domain": {
"url": "#",
"icon": "fw fw-organization",
"isAdminOnly": false,
"target": "_parent",
"dropDown": {
"Organization": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/organization.jag",
"icon": "fw fw-organization",
"dropDown": "false",
"target": "_self"
"Logo": {
"name": "Cloud",
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt",
"target": "_parent"
},
"Main": {
"Domain": {
"url": "#",
"icon": "fw fw-organization",
"isAdminOnly": false,
"target": "_parent",
"dropDown": {
"Organization": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/organization.jag",
"icon": "fw fw-organization",
"dropDown": "false",
"target": "_self"
},
"Members": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user.jag",
"icon": "fa fa-users",
"dropDown": "false",
"target": "_self"
}
}
},
"Account": {
"url": "#",
"icon": "fw fw-resource",
"isAdminOnly": false,
"billingEnabled": true,
"billingApi": {
"username": "admin",
"password": "admin"
},
"cloudMgtIndexPage": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/index.jag",
"dropDown": {
"Upgrade Now": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/payment-plans.jag?cloud-type=device_cloud",
"icon": "fw fw-export",
"dropDown": "true",
"target": "_self"
},
"Request Extension": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/contact-us.jag?cloud-type=device_cloud&request-extension=true",
"icon": "fa fa-mail",
"dropDown": "true",
"target": "_self"
}
}
},
"Support": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/contact-us.jag?cloud-type=device_cloud",
"icon": "fw fw-mail",
"isAdminOnly": false,
"target": "_self",
"dropDown": "false"
},
"Members": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user.jag",
"icon": "fa fa-users",
"dropDown": "false",
"target": "_self"
"Documentation": {
"url": "#",
"icon": "fw fw-document",
"isAdminOnly": false,
"dropDown": {
"Device Cloud": {
"id": "device_cloud",
"url": "https://docs.wso2.com/display/DeviceCloud/WSO2+Device+Cloud+Documentation",
"icon": "fw fw-mobile",
"target": "_blank"
}
}
}
}
},
"Support": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/contact-us.jag",
"icon": "fw fw-mail",
"isAdminOnly": false,
"target": "_self",
"dropDown": "false"
},
"Documentation": {
"url": "#",
"icon": "fw fw-document",
"isAdminOnly": false,
"dropDown": {
"Device Cloud": {
"id": "device_cloud",
"url": "https://docs.wso2.com/display/DeviceCloud/WSO2+Device+Cloud+Documentation",
"icon": "fw fw-mobile",
"target": "_blank"
}
}
}
},
"User": {
"url": "#",
"icon": "fw fw-user",
"dropDown": {
"Profile": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user-profile.jag",
"User": {
"url": "#",
"icon": "fw fw-user",
"dropDown": "true",
"target": "_self"
},
"Change Password": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/change-password.jag",
"icon": "fw fw-lock",
"dropDown": "true",
"target": "_self"
},
"Logout": {
"url": "https://api.cloud.wso2.com/publisher/site/pages/logout.jag",
"icon": "fw fw-sign-out",
"dropDown": "true",
"target": "_self"
}
}
},
"Expand": {
"Clouds": {
"API Cloud": {
"id": "api_cloud",
"url": "https://api.cloud.wso2.com/publisher",
"icon": "fw fw-api fw-3x",
"dropDown": "true",
"target": "_self"
},
"Integration Cloud": {
"id": "integration_cloud",
"url": "https://integration.cloud.wso2.com/appmgt",
"icon": "fw fw-service fw-3x",
"dropDown": "true",
"target": "_self"
},
"Identity Cloud": {
"id": "integration_cloud",
"url": "https://identity.cloud.wso2.com/admin",
"icon": "fw fw-security fw-3x",
"dropDown": "true",
"target": "_self"
}
"dropDown": {
"Profile": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user-profile.jag",
"icon": "fw fw-user",
"dropDown": "true",
"target": "_self"
},
"Change Password": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/change-password.jag",
"icon": "fw fw-lock",
"dropDown": "true",
"target": "_self"
},
"Logout": {
"url": "https://device.cloud.wso2.com/devicemgt/logout",
"icon": "fw fw-sign-out",
"dropDown": "true",
"target": "_self"
}
}
},
"Actions": {
"Organization": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/organization.jag",
"icon": "fw fw-organization fw-3x",
"dropDown": "true",
"target": "_self"
},
"Members": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user.jag",
"icon": "fa fa-users fa-3x",
"dropDown": "true",
"target": "_self"
}
"Expand": {
"Clouds": {
"API Cloud": {
"id": "api_cloud",
"url": "https://api.cloud.wso2.com/publisher",
"icon": "fw fw-api fw-3x",
"dropDown": "true",
"target": "_self"
},
"Integration Cloud": {
"id": "integration_cloud",
"url": "https://integration.cloud.wso2.com/appmgt",
"icon": "fw fw-service fw-3x",
"dropDown": "true",
"target": "_self"
},
"Identity Cloud": {
"id": "integration_cloud",
"url": "https://identity.cloud.wso2.com/admin",
"icon": "fw fw-security fw-3x",
"dropDown": "true",
"target": "_self"
}
},
"Actions": {
"Organization": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/organization.jag",
"icon": "fw fw-organization fw-3x",
"dropDown": "true",
"target": "_self"
},
"Members": {
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user.jag",
"icon": "fa fa-users fa-3x",
"dropDown": "true",
"target": "_self"
}
}
}
}
}

@ -79,18 +79,19 @@ var operationModule = function () {
return featuresList;
};
publicMethods.getControlOperations = function (deviceType) {
publicMethods.getControlOperations = function (device) {
var deviceType = device.type;
var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation");
var features = utility.getDeviceTypeConfig(deviceType).deviceType.features;
for (var op in operations) {
var iconIdentifier = operations[op].operation;
if (features && features[iconIdentifier]) {
var icon = features[iconIdentifier].icon;
var isCloud = devicemgtProps["isCloud"];
//TODO: remove isCloud check once able to verify features from the device agent
var isDisabled = features[iconIdentifier].isDisabled;
if (isDisabled && isCloud) {
operations[op]["isDisabled"] = isDisabled;
//TODO: need improve this check to get feature availability from agent side
var filter = features[iconIdentifier].filter;
if (device && filter && filter.property && device[filter.property] !== filter.value) {
operations[op]["isDisabled"] = true;
operations[op]["disabledText"] = filter.text;
} else {
operations[op]["isDisabled"] = false;
}

@ -56,6 +56,8 @@ var conf = function () {
}
}
);
var DeviceConfigurationManager = Packages.org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
conf["serverConfig"] = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
application.put("CONF", conf);
}
return conf;

@ -209,7 +209,7 @@
data-search="{{platform}}"
data-display="{{platform}}">
</td>
<td class="remove-padding-top"
<td class="remove-padding-top hidden"
data-search="{{ownershipType}}"
data-display="{{ownershipType}}"
data-grid-label="Ownership">

@ -36,7 +36,7 @@
}
</style>
{{#each control_operations}}
<a href="javascript:operationSelect('{{operation}}')">
<a class='operation-tile' href="javascript:operationSelect('{{operation}}')">
<i class="fw fw-service"></i>
<span>{{name}}</span>
</a>
@ -93,7 +93,7 @@
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<span class="fw-stack center-block">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i id="status-icon" class="fw fw-error fw-stack-1x"></i>
</span>

@ -51,6 +51,7 @@ function submitForm(formId) {
var defaultStatusClasses = "fw fw-stack-1x";
var content = $("#operation-response-template").find(".content");
var title = content.find("#title");
title.attr("class","center-block text-center");
var statusIcon = content.find("#status-icon");
var description = content.find("#description");
var successCallBack = function (response) {

@ -35,7 +35,7 @@
}
</style>
{{#each control_operations}}
<a href="javascript:operationSelect('{{operation}}')">
<a class='operation-tile' href="javascript:operationSelect('{{operation}}')">
{{#if iconFont}}
<i class="fw {{iconFont}}"></i>
{{else}}
@ -79,6 +79,11 @@
<input type="{{type}}" id="{{name}}" placeholder="{{name}}" class="form-control" data-param-type="query" value="{{value}}" />
<br />
{{/each}}
{{#each uiParams}}
<input type="{{type}}" id="{{id}}" name="{{name}}" data-param-type="form" value="{{value}}" />
<label>{{label}}</label>
<br />
{{/each}}
<button id="btnSend" type="button" onclick="submitForm('form-{{operation}}')" class="btn btn-default">&nbsp;&nbsp;&nbsp;&nbsp;Send
to Device&nbsp;&nbsp;&nbsp;&nbsp;</button>
<label id="lblSending" class="wr-input-label hidden"><i
@ -104,7 +109,7 @@
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<span class="fw-stack center-block">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i id="status-icon" class="fw fw-error fw-stack-1x"></i>
</span>

@ -22,7 +22,7 @@ function onRequest(context) {
var device = context.unit.params.device;
var autoCompleteParams = context.unit.params.autoCompleteParams;
var encodedFeaturePayloads=context.unit.params.encodedFeaturePayloads;
var controlOperations = operationModule.getControlOperations(device.type);
var controlOperations = operationModule.getControlOperations(device);
var queryParams = [];
var formParams = [];
var pathParams = [];

@ -33,6 +33,16 @@ function submitForm(formId) {
var uriencodedQueryStr = "";
var uriencodedFormStr = "";
var payload = {};
var isItemSelected;
//setting responses callbacks
var content = $("#operation-response-template").find(".content");
var defaultStatusClasses = "fw fw-stack-1x";
var title = content.find("#title");
title.attr("class","center-block text-center");
var statusIcon = content.find("#status-icon");
var description = content.find("#description");
form.find("input").each(function () {
var input = $(this);
if (input.data("param-type") == "path") {
@ -42,14 +52,31 @@ function submitForm(formId) {
uriencodedQueryStr += prefix + input.attr("id") + "=" + input.val();
} else if (input.data("param-type") == "form") {
var prefix = (uriencodedFormStr == "") ? "" : "&";
uriencodedFormStr += prefix + input.attr("id") + "=" + input.val();
//payload[input.attr("id")] = input.val();
if (input.attr("type") == "checkbox" || input.attr("type") == "radio"){
if (isItemSelected == undefined){
isItemSelected = false;
}
if (input.is(':checked')){
isItemSelected = true;
uriencodedFormStr += prefix + input.attr("name") + "=" + input.val();
}
}else{
uriencodedFormStr += prefix + input.attr("id") + "=" + input.val();
}
}
});
if (isItemSelected === false){
title.html("Please Select One Option");
statusIcon.attr("class", defaultStatusClasses + " fw-error");
$(modalPopupContent).html(content.html());
return false;
}
uri += uriencodedQueryStr;
var httpMethod = form.attr("method").toUpperCase();
var contentType = form.attr("enctype");
console.log(payload);
var featurePayload = form.attr("data-payload");
if (featurePayload) {
contentType = "application/json";
@ -59,12 +86,7 @@ function submitForm(formId) {
contentType = "application/x-www-form-urlencoded";
payload = uriencodedFormStr;
}
//setting responses callbacks
var defaultStatusClasses = "fw fw-stack-1x";
var content = $("#operation-response-template").find(".content");
var title = content.find("#title");
var statusIcon = content.find("#status-icon");
var description = content.find("#description");
var successCallBack = function (response) {
var res = response;
try {
@ -78,7 +100,6 @@ function submitForm(formId) {
$(modalPopupContent).html(content.html());
};
var errorCallBack = function (response) {
console.log(response);
title.html("An Error Occurred!");
statusIcon.attr("class", defaultStatusClasses + " fw-error");
var reason = (response.responseText == "null")?response.statusText:response.responseText;
@ -105,9 +126,9 @@ function submitForm(formId) {
$(document).on('submit', 'form', function (e) {
e.preventDefault();
var postOperationRequest = $.ajax({
url: $(this).attr("action") + '&' + $(this).serialize(),
method: "post"
});
url: $(this).attr("action") + '&' + $(this).serialize(),
method: "post"
});
var btnSubmit = $('#btnSend', this);
btnSubmit.addClass('hidden');

@ -72,10 +72,6 @@
padding: 20px 0px;
}
#location{
height: calc(100vh - 400px);
}
.page-loader{
position: absolute;
left: 0px;

@ -140,6 +140,10 @@ function loadOperationsLog(update) {
});
$("a[data-toggle=\"tab\"]").on("shown.bs.tab", function (e) {
$("#operation-log").DataTable().columns.adjust().responsive.recalc();
});
function renderLogDetails(obj,data) {
var payload = JSON.parse(data);
var logStream = '<div class="log-data">';

@ -34,14 +34,14 @@
<div class="col-lg-9">
<div class="device-info">
{{#defineZone "device-details-header"}}
<h1 data-deviceid="{{device.deviceIdentifier}}"
<h1 class="device-id" data-deviceid="{{device.deviceIdentifier}}"
data-type="{{device.type}}"
data-ownership="{{device.ownership}}"
data-owner="{{device.owner}}">
{{#if device.viewModel.model}}
<h4>{{device.viewModel.vendor}} {{device.viewModel.model}}</h4>
{{#if device.model}}
<h4>{{device.vendor}} {{device.model}}</h4>
{{/if}}
<h4>Ownership - <strong>{{device.viewModel.ownership}}</strong></h4>
<h4>Ownership - <strong>{{device.ownership}}</strong></h4>
<h4>Device is
<strong>
{{#equal device.status "ACTIVE"}}Active{{/equal}}

@ -35,10 +35,6 @@ function onRequest(context) {
if (filteredDeviceData["type"]) {
viewModel["deviceType"] = filteredDeviceData["type"];
viewModel["type"] = filteredDeviceData["type"];
viewModel.isNotWindows = true;
if (viewModel["deviceType"] == "windows") {
viewModel.isNotWindows = false;
}
}
if (filteredDeviceData["deviceIdentifier"]) {
viewModel["deviceIdentifier"] = filteredDeviceData["deviceIdentifier"];
@ -65,138 +61,6 @@ function onRequest(context) {
viewModel["ownership"] = filteredDeviceData["enrolmentInfo"]["ownership"];
}
}
if (filteredDeviceData["initialDeviceInfo"]) {
viewModel["deviceInfoAvailable"] = true;
if (filteredDeviceData["initialDeviceInfo"]["IMEI"]) {
viewModel["imei"] = filteredDeviceData["initialDeviceInfo"]["IMEI"];
}
if (!filteredDeviceData["latestDeviceInfo"]) {
if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]) {
if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] != "0") {
viewModel["osBuildDate"] = new Date(filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] * 1000);
}
}
if (filteredDeviceData["initialDeviceInfo"]["LATITUDE"] && filteredDeviceData["initialDeviceInfo"]["LONGITUDE"]) {
viewModel["location"] = {};
viewModel["location"]["latitude"] = filteredDeviceData["initialDeviceInfo"]["LATITUDE"];
viewModel["location"]["longitude"] = filteredDeviceData["initialDeviceInfo"]["LONGITUDE"];
}
if (filteredDeviceData["initialDeviceInfo"]["VENDOR"] && filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]) {
viewModel["vendor"] = filteredDeviceData["initialDeviceInfo"]["VENDOR"];
viewModel["model"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"];
}
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]) {
if (deviceType == "android") {
viewModel["BatteryLevel"] = {};
viewModel["BatteryLevel"]["value"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BATTERY_LEVEL"];
viewModel["internalMemory"] = {};
viewModel["internalMemory"]["total"] = Math.
round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 100) / 100;
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) {
viewModel["internalMemory"]["usage"] = Math.
round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] -
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"])
/ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100;
} else {
viewModel["internalMemory"]["usage"] = 0;
}
viewModel["externalMemory"] = {};
viewModel["externalMemory"]["total"] = Math.
round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 100) / 100;
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] != 0) {
viewModel["externalMemory"]["usage"] = Math.
round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] -
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_AVAILABLE_MEMORY"])
/ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100;
} else {
viewModel["externalMemory"]["usage"] = 0;
}
} else if (deviceType == "ios") {
viewModel["BatteryLevel"] = {};
viewModel["BatteryLevel"]["value"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BatteryLevel"];
viewModel["internalMemory"] = {};
viewModel["internalMemory"]["total"] = Math.
round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 100) / 100;
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] != 0) {
viewModel["internalMemory"]["usage"] = Math.
round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] -
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["AvailableDeviceCapacity"])
/ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 10000) / 100;
} else {
viewModel["internalMemory"]["usage"] = 0;
}
}
}
}
}
if (filteredDeviceData["latestDeviceInfo"]) {
viewModel["deviceInfoAvailable"] = true;
if (filteredDeviceData["latestDeviceInfo"]["osBuildDate"]) {
if (filteredDeviceData["latestDeviceInfo"]["osBuildDate"] != "0") {
viewModel["osBuildDate"] = new Date(filteredDeviceData["latestDeviceInfo"]["osBuildDate"] * 1000);
}
}
if (filteredDeviceData["latestDeviceInfo"]["location"]["latitude"] &&
filteredDeviceData["latestDeviceInfo"]["location"]["longitude"]) {
viewModel["location"] = {};
viewModel["location"]["latitude"] = filteredDeviceData["latestDeviceInfo"]["location"]["latitude"];
viewModel["location"]["longitude"] = filteredDeviceData["latestDeviceInfo"]["location"]["longitude"];
}
if (filteredDeviceData["latestDeviceInfo"]["vendor"] && filteredDeviceData["latestDeviceInfo"]["deviceModel"]) {
viewModel["vendor"] = filteredDeviceData["latestDeviceInfo"]["vendor"];
viewModel["model"] = filteredDeviceData["latestDeviceInfo"]["deviceModel"];
}
if (filteredDeviceData["latestDeviceInfo"]["updatedTime"]) {
viewModel["lastUpdatedTime"] = filteredDeviceData["latestDeviceInfo"]["updatedTime"].
substr(0, filteredDeviceData["latestDeviceInfo"]["updatedTime"].indexOf("+"));
}
viewModel["BatteryLevel"] = {};
viewModel["BatteryLevel"]["value"] = filteredDeviceData["latestDeviceInfo"]["batteryLevel"];
viewModel["cpuUsage"] = {};
viewModel["cpuUsage"]["value"] = filteredDeviceData["latestDeviceInfo"]["cpuUsage"];
viewModel["ramUsage"] = {};
if (filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] != 0) {
viewModel["ramUsage"]["value"] = Math.
round((filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] -
filteredDeviceData["latestDeviceInfo"]["availableRAMMemory"])
/ filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] * 10000) / 100;
} else {
viewModel["ramUsage"]["value"] = 0;
}
viewModel["internalMemory"] = {};
viewModel["internalMemory"]["total"] = Math.
round(filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 100) / 100;
if (filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] != 0) {
viewModel["internalMemory"]["usage"] = Math.
round((filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] -
filteredDeviceData["latestDeviceInfo"]["internalAvailableMemory"])
/ filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 10000) / 100;
} else {
viewModel["internalMemory"]["usage"] = 0;
}
viewModel["externalMemory"] = {};
viewModel["externalMemory"]["total"] = Math.
round(filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 100) / 100;
if (filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] != 0) {
viewModel["externalMemory"]["usage"] = Math.
round((filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] -
filteredDeviceData["latestDeviceInfo"]["externalAvailableMemory"])
/ filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 10000) / 100;
} else {
viewModel["externalMemory"]["usage"] = 0;
}
}
if (!filteredDeviceData["initialDeviceInfo"] && !filteredDeviceData["latestDeviceInfo"]) {
viewModel["deviceInfoAvailable"] = false;
}
deviceViewData["device"] = viewModel;
} else if (response["status"] == "unauthorized") {
deviceViewData["deviceFound"] = true;

@ -64,6 +64,12 @@
<div id="" style="height: 63vh;">
<!-- Sidebar -->
<div id="map"></div>
{{#if geoServicesEnabled}}
<div id="ws-alerts">
<i id="ws-alert-stream" class="fw fw-circle text-muted"></i> Alerts Stream&nbsp;
<i id="ws-spatial-stream" class="fw fw-circle text-muted"></i> Spatial Stream
</div>
{{/if}}
</div>
<div id="predictionResults" style="background: darkgray;display: none;border-radius: 13px;height: 94%;padding: 0"
@ -479,11 +485,13 @@
<div class="popover-content">
<h6>Information</h6>
<p id="information" class="bg-primary" style="margin: 0px;padding: 0px;"></p>
{{#if geoServicesEnabled}}
<h6>Speed<span class="label label-primary pull-right"><span id="speed"></span> km/h</span></h6>
<h6>Heading<span id="heading" class="label label-primary pull-right"></span></h6>
<button type="button" class="btn btn-info btn-xs" onClick="toggleSpeedGraph();return false;">Speed Graph</button>
<button type="button" class="btn btn-info btn-xs" onClick="focusOnRecentHistorySpatialObject();return false;">Recent History</button>
<button type="button" class="btn btn-info btn-xs" onClick="popupDateRange();">Full History</button>
{{/if}}
</div>
</div>
@ -526,7 +534,7 @@
<div class="form-group">
<label class="text-primary" for="areaName">Fence name</label>
<input class="form-control" id="areaName" placeholder="Fence name" type="text">
<span class="help-block">Name of the selected area(i.e colombo)</span>
<span class="help-block">Name of the selected area(e.g. colombo)</span>
</div>
<div>
<div class="btn-group btn-group-sm btn-group-justified">
@ -557,7 +565,7 @@
<div class="form-group">
<label class="text-primary" for="areaName">Fence name</label>
<input class="form-control" id="areaName" placeholder="Fence name" type="text">
<span class="help-block">Name of the selected area(i.e colombo)</span>
<span class="help-block">Name of the selected area(e.g. colombo)</span>
</div>
<div>
<div class="btn-group btn-group-sm btn-group-justified">
@ -589,7 +597,7 @@
<div class="form-group">
<label class="text-primary" for="areaName">Fence name</label>
<input class="form-control" id="areaName" placeholder="Stationery name" type="text">
<span class="help-block">Name of the selected area(i.e colombo)</span>
<span class="help-block">Name of the selected area(e.g. colombo)</span>
<label class="text-primary" for="fRadius">Fluctuation radius</label>
<input class="form-control" id="fRadius" onblur="reformatRadius(this.form.fRadius.value);" placeholder="m" type="text">
@ -626,7 +634,7 @@
<div class="form-group">
<label class="text-primary" for="areaName">Fence name</label>
<input class="form-control" id="areaName" placeholder="Area Name" type="text">
<span class="help-block">Name of the selected area(i.e colombo)</span>
<span class="help-block">Name of the selected area(e.g. colombo)</span>
</div>
<div>
<div class="btn-group btn-group-sm btn-group-justified">
@ -688,11 +696,11 @@
var geoLocationLink = $(".initGeoLocationLink");
if (geoLocationLink) {
geoLocationLink.on('click', function () {
initializeGeoLocation()
initializeGeoLocation({{geoServicesEnabled}});
});
{{#if showGeoFencingTools}}
geoPublicUri = $("#geo-charts").data("geo-public-uri");
{{#if geoServicesEnabled}}
var geoToolsMenu = $('#location-action-bar');
geoPublicUri = $("#geo-charts").data("geo-public-uri");
var realtTime = createGeoToolListItem('javascript:enableRealTime()',
'Return to Real Time View', 'fw fw-undo', geoToolsMenu);
realtTime.css("display", "none");

@ -52,6 +52,6 @@ function onRequest(context) {
} else {
viewModel.lastLocation = stringify({});
}
viewModel.showGeoFencingTools = true;
viewModel.geoServicesEnabled = devicemgtProps.serverConfig.geoLocationConfiguration.isEnabled;
return viewModel;
}

@ -34,7 +34,7 @@
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<div class="col-lg-5 col-md-6 col-centered">
<h4>
Set 'Stationery' alerts
Set 'Stationary' alerts
<br>
</h4>
</div>
@ -46,8 +46,8 @@
<table class="table table-hover" id="stationary-alert-table">
<thead>
<tr>
<th>Stationery Name</th>
<th>Stationery Time</th>
<th>Stationary Name</th>
<th>Stationary Time</th>
<th>Fluctuation Radius</th>
<th>Query Name</th>
<th>Created On</th>

@ -40,38 +40,11 @@ function initialLoad() {
setTimeout(initialLoad, 500); // give everything some time to render
} else {
initializeMap();
// getTileServers();
// loadWms();
processAfterInitializationMap();
//Access gps and make zoom to server location as map center
//navigator.geolocation.getCurrentPosition(success, error);
$("#loading").hide();
}
}
//function success(position) {
// var browserLatitude = position.coords.latitude;
// var browserLongitude = position.coords.longitude;
// map.setView([browserLatitude, browserLongitude]);
// map.setZoom(14);
// $.UIkit.notify({
// message: "Map view set to browser's location",
// status: 'info',
// timeout: ApplicationOptions.constance.NOTIFY_INFO_TIMEOUT,
// pos: 'top-center'
// });
//}
//
//function error() {
// $.UIkit.notify({
// message: "Unable to find browser location!",
// status: 'warning',
// timeout: ApplicationOptions.constance.NOTIFY_WARNING_TIMEOUT,
// pos: 'top-center'
// });
//}
function initializeMap() {
if (typeof(map) !== 'undefined') {
map.remove();
@ -83,7 +56,7 @@ function initializeMap() {
map = L.map("map", {
zoom: 14,
center: [6.927078, 79.861243],
layers: [defaultOSM, defaultTFL],
layers: [defaultOSM],
zoomControl: true,
attributionControl: false,
maxZoom: 20,
@ -147,28 +120,20 @@ function processAfterInitializationMap() {
div.innerHTML = "<a href='#' onclick='$(\"#attributionModal\").modal(\"show\"); return false;'>Attribution</a>";
return div;
};
// map.addControl(attributionControl);
map.addControl(L.control.fullscreen({position: 'bottomright'}));
geoAlertsBar = L.control.geoAlerts({position: 'topright'});
map.addControl(geoAlertsBar);
//L.control.fullscreen({
// position: 'bottomright'
//}).addTo(map);
// L.control.zoom({
// position: "bottomright"
// }).addTo(map);
groupedOverlays = {
"Web Map Service layers": {}
};
layerControl = L.control.groupedLayers(baseLayers, groupedOverlays, {
collapsed: true
collapsed: true,
position: 'bottomleft'
}).addTo(map);
//L.control.layers(baseLayers).addTo(map);
//map.addLayer(defaultTFL);
}
/* Highlight search box text on click */
@ -308,35 +273,43 @@ var getProviderData = function (timeFrom, timeTo) {
deviceId = deviceDetails.data("deviceid");
deviceType = deviceDetails.data("type");
var serviceUrl = '/api/device-mgt/v1.0/geo-services/stats/' + deviceType + '/' + deviceId + '?from=' + timeFrom + '&to=' + timeTo;
invokerUtil.get(serviceUrl,
function (data) {
tableData = JSON.parse(data);
if (tableData.length === 0) {
var geoCharts = $("#geo-charts");
var location = geoCharts.data("device-location");
location.heading = 0;
location.id = deviceId;
location.values = {};
location.values.id = deviceId;
location.values.information = "Last seen " + timeSince(new Date(location.updatedTime));
location.values.notify = false;
location.values.speed = 0;
location.values.state = "NORMAL";
location.values.longitude = location.longitude;
location.values.latitude = location.latitude;
location.timestamp = location.updatedTime;
location.values.timeStamp = location.updatedTime;
location.values.type = deviceType;
location._version = "1.0.0";
tableData.push(location);
}
}, function (message) {
console.log(message);
});
if (geoFencingEnabled) {
var serviceUrl = '/api/device-mgt/v1.0/geo-services/stats/' + deviceType + '/' + deviceId + '?from=' + timeFrom + '&to=' + timeTo;
invokerUtil.get(serviceUrl,
function (data) {
tableData = JSON.parse(data);
if (tableData.length === 0) {
showCurrentLocation(tableData);
}
}, function (message) {
showCurrentLocation(tableData);
});
} else {
showCurrentLocation(tableData);
}
return tableData;
};
function showCurrentLocation(tableData){
var geoCharts = $("#geo-charts");
var location = geoCharts.data("device-location");
location.heading = 0;
location.id = deviceId;
location.values = {};
location.values.id = deviceId;
location.values.information = "Last seen " + timeSince(new Date(location.updatedTime));
location.values.notify = false;
location.values.speed = 0;
location.values.state = "NORMAL";
location.values.longitude = location.longitude;
location.values.latitude = location.latitude;
location.timestamp = location.updatedTime;
location.values.timeStamp = location.updatedTime;
location.values.type = deviceType;
location._version = "1.0.0";
tableData.push(location);
}
function timeSince(date) {
if (!date) {
@ -399,12 +372,10 @@ function enableRealTime() {
isBatchModeOn = false;
}
function InitSpatialObject() {
var geoFencingEnabled = true;
function InitSpatialObject(geoFencingIsEnabled) {
geoFencingEnabled = geoFencingIsEnabled;
var spatialObject = drawSpatialObject();
setTimeout(function () {
map.setView(spatialObject.marker.getLatLng(), spatialObject.marker.zoomLevel, {animate: true});
}, 1000
);
map.addControl(L.control.focus({position: 'bottomright', marker: spatialObject.marker, zoomLevel: zoomLevel}));
}
@ -455,13 +426,19 @@ function drawSpatialObject() {
return true;
}
map.setView(spatialObject.marker.getLatLng(), zoomLevel, {animate: true}); // TODO: check the map._layersMaxZoom and set the zoom level accordingly
if (geoFencingEnabled) {
var alertsFromDate = new Date();
alertsFromDate.setHours(alertsFromDate.getHours() - 24); //last 24 hours
getAlertsHistory(deviceType, deviceId, alertsFromDate.valueOf(), toDate.valueOf());
}
setTimeout(function () {
map.invalidateSize();
map.setView(spatialObject.marker.getLatLng(), spatialObject.marker.zoomLevel, {animate: true});
spatialObject.marker.openPopup();
spatialObject.drawPath();
}, 500);
var alertsFromDate = new Date();
alertsFromDate.setHours(alertsFromDate.getHours() - 24); //last 24 hours
getAlertsHistory(deviceType, deviceId, alertsFromDate.valueOf(), toDate.valueOf());
spatialObject.marker.openPopup();
spatialObject.drawPath();
if (speedGraphControl) {
setTimeout(function () {
createChart();

@ -34,6 +34,7 @@ function initializeExit() {
}
} else{
$(".fence-not-exist").show();
$("#exit-alert").hide();
}
$('.viewGeoFenceRow td:not(:last-child)').click(function () {
viewFence(this.parentElement,'Exit');

@ -65,17 +65,7 @@ var defaultOSM = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
maxZoom: 19
});
//var defaultTFL = L.tileLayer('https://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',{
// maxZoom: 19,
// subdomains:['mt0','mt1','mt2','mt3']
//});
var defaultTFL = L.tileLayer("", {
maxZoom: 19,
attribution: '| London Traffic and London Buses data Powered by TfL Open Data'
});
var baseLayers = {
//"Google Maps": defaultTFL,
"Open Street Maps": defaultOSM
};
@ -564,7 +554,6 @@ function getAlertsHistory(deviceType, deviceId, timeFrom, timeTo) {
}
});
}, function (message) {
console.log(message);
});
}

@ -38,6 +38,7 @@ function initStationaryAlert() {
}
} else{
$(".fence-not-exist").show();
$("#stationary-alert-table").hide();
}
$('.viewGeoFenceRow td:not(:last-child)').click(function () {
viewFence(this.parentElement,'Stationery');

@ -34,6 +34,7 @@ function initializeWithin() {
}
} else{
$(".fence-not-exist").show();
$("#within-alert").hide();
}
$('.viewGeoFenceRow td:not(:last-child)').click(function () {
viewFence(this.parentElement,'WithIn');

@ -20,7 +20,7 @@ var debugObject; // assign object and debug from browser console, this is for de
var showPathFlag = false; // Flag to hold the status of draw objects path
var currentSpatialObjects = {};
var selectedSpatialObject; // This is set when user search for an object from the search box
var websocket;
var spatialWebsocket;
var onAlertWebsocket;
var onTrafficStreamWebsocket;
var currentPredictions = {};
@ -506,36 +506,11 @@ function LocalStorageArray(id) {
};
}
var webSocketOnTrafficStreamOpen = function () {
onTrafficStreamWebsocket.set_opened();
noty({text: 'You Are Connected to Traffic Stream !!', type: 'success'});
};
var webSocketOnTrafficStreamMessage = function processMessage(message) {
var json = $.parseJSON(message.data);
if (json.messageType == "Traffic") {
processTrafficMessage(json);
} else {
console.log("Message type not supported.");
}
};
var webSocketOnTrafficStreamClose = function (e) {
if (onTrafficStreamWebsocket.get_opened()) {
noty({text: 'Connection lost with Traffic Stream Stream !!', type: 'error'});
}
waitForSocketConnection(onTrafficStreamWebsocket, initializeOnTrafficStreamWebSocket);
};
var webSocketOnTrafficStreamError = function (e) {
if (!onTrafficStreamWebsocket.get_opened()) return;
noty({text: 'Something went wrong when trying to connect to <b>' + trafficStreamWebSocketURL + '<b/>', type: 'error'});
};
var initLoading = true;
var webSocketOnAlertOpen = function () {
onAlertWebsocket.set_opened();
noty({text: 'You Are Connected to Alert Stream !!', type: 'success'});
$('#ws-alert-stream').removeClass('text-muted text-danger text-success').addClass('text-success');
};
var webSocketOnAlertMessage = function processMessage(message) {
@ -551,7 +526,7 @@ var webSocketOnAlertMessage = function processMessage(message) {
var webSocketOnAlertClose = function (e) {
if (onAlertWebsocket.get_opened()) {
noty({text: 'Connection lost with Alert Stream !!', type: 'error'});
$('#ws-alert-stream').removeClass('text-muted text-danger text-success').addClass('text-danger');
}
waitForSocketConnection(onAlertWebsocket, initializeOnAlertWebSocket);
};
@ -561,18 +536,15 @@ var webSocketOnAlertError = function (e) {
noty({text: 'Something went wrong when trying to connect to <b>' + alertWebSocketURL + '<b/>', type: 'error'});
};
var initLoading = true;
var webSocketOnOpen = function () {
websocket.set_opened();
var webSocketSpatialOnOpen = function () {
spatialWebsocket.set_opened();
if (initLoading) {
initialLoad();
InitSpatialObject();
initLoading = false;
}
noty({text: 'You Are Connected to Spatial Stream !!', type: 'success'});
$('#ws-spatial-stream').removeClass('text-muted text-danger text-success').addClass('text-success');
};
var webSocketOnMessage = function (message) {
var webSocketSpatialOnMessage = function (message) {
if (!isBatchModeOn) {
var json = $.parseJSON(message.data);
if (json.messageType == "Point") {
@ -585,15 +557,15 @@ var webSocketOnMessage = function (message) {
}
};
var webSocketOnClose = function (e) {
if (websocket.get_opened()) {
noty({text: 'Connection lost with server!!', type: 'error'});
var webSocketSpatialOnClose = function (e) {
if (spatialWebsocket.get_opened()) {
$('#ws-spatial-stream').removeClass('text-muted text-danger text-success').addClass('text-danger');
}
waitForSocketConnection(websocket, initializeWebSocket);
waitForSocketConnection(spatialWebsocket, initializeSpatialStreamWebSocket);
};
var webSocketOnError = function (err) {
if (!websocket.get_opened()) return;
var webSocketSpatialOnError = function (err) {
if (!spatialWebsocket.get_opened()) return;
noty({text: 'Something went wrong when trying to connect to <b>' + webSocketURL + '<b/>', type: 'error'});
};
@ -622,13 +594,13 @@ function waitForSocketConnection(socket, callback) {
}
function initializeWebSocket() {
if(websocket) websocket.close();
websocket = new WebSocket(webSocketURL);
websocket.onopen = webSocketOnOpen;
websocket.onmessage = webSocketOnMessage;
websocket.onclose = webSocketOnClose;
websocket.onerror = webSocketOnError;
function initializeSpatialStreamWebSocket() {
if(spatialWebsocket) spatialWebsocket.close();
spatialWebsocket = new WebSocket(webSocketURL);
spatialWebsocket.onopen = webSocketSpatialOnOpen;
spatialWebsocket.onmessage = webSocketSpatialOnMessage;
spatialWebsocket.onclose = webSocketSpatialOnClose;
spatialWebsocket.onerror = webSocketSpatialOnError;
}
function initializeOnAlertWebSocket() {
@ -640,7 +612,7 @@ function initializeOnAlertWebSocket() {
onAlertWebsocket.onopen = webSocketOnAlertOpen;
}
function initializeGeoLocation() {
function initializeGeoLocation(geoFencingEnabled) {
var deviceDetails = $(".device-id");
deviceId = deviceDetails.data("deviceid");
deviceType = deviceDetails.data("type");
@ -657,11 +629,17 @@ function initializeGeoLocation() {
alertWebSocketURL = wsEndPoint + userDomain + "/org.wso2.geo.AlertsNotifications/1.0.0?"
+ "deviceId=" + deviceId + "&deviceType=" + deviceType + "&websocketToken=" + wsToken;
$("#proximity_alert").hide();
initializeWebSocket();
initializeOnAlertWebSocket();
window.onbeforeunload = function () {
websocket.close();
onAlertWebsocket.close();
initialLoad();
InitSpatialObject(geoFencingEnabled);
if (geoFencingEnabled) {
initializeSpatialStreamWebSocket();
initializeOnAlertWebSocket();
window.onbeforeunload = function () {
spatialWebsocket.close();
onAlertWebsocket.close();
}
}
} else {
noty({text: 'Invalid Access! No device information provided to track!', type: 'error'});

@ -1,7 +1,7 @@
{{#zone "content"}}
{{#if isAuthorized}}
<span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}"
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}"></span>
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}" data-isDeviceOwnerEnabled="{{isDeviceOwnerEnabled}}"></span>
<div class="row">
<div class="col-md-12">

@ -88,13 +88,15 @@ function onRequest(context) {
}
}
var roles = userModule.getRoles();
if (roles["status"] == "success") {
types["roles"] = roles["content"];
}
types["groups"] = groupModule.getGroups();
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
types["isCloud"] = devicemgtProps.isCloud;
var roles = userModule.getRoles();
if (roles["status"] == "success") {
types["roles"] = roles["content"];
}
types["groups"] = groupModule.getGroups();
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
types["isCloud"] = devicemgtProps.isCloud;
types["isDeviceOwnerEnabled"] = devicemgtProps.isDeviceOwnerEnabled;
return types;
}

@ -66,7 +66,7 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
*/
function loadGroups(callback) {
invokerUtil.get(
"/api/device-mgt/v1.0/groups",
"/api/device-mgt/v1.0/admin/groups",
function (data) {
data = JSON.parse(data);
callback(data.deviceGroups);
@ -146,7 +146,7 @@ stepForwardFrom["policy-platform"] = function (actionButton) {
if (policyOperationsTemplateSrc) {
$.template(policyOperationsTemplateCacheKey, context + policyOperationsTemplateSrc, function (template) {
var content = template({"iscloud" : $("#logged-in-user").data("iscloud")});
var content = template({"iscloud" : $("#logged-in-user").data("iscloud"), "isDeviceOwnerEnabled" : $("#logged-in-user").data("isdeviceownerenabled")});
$("#device-type-policy-operations").html(content).removeClass("hidden");
$(".policy-platform").addClass("hidden");
});

@ -0,0 +1,24 @@
/*
* Copyright (c) 2017, 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.
*/
$(document).ready(function(){
var expireModal = $('#expire-modal-content');
modalDialog.content(expireModal.find('.modal-body'));
modalDialog.header(expireModal.find('.modal-header .modal-title'));
modalDialog.footer(expireModal.find('.modal-footer'));
modalDialog.show();
});

@ -15,6 +15,7 @@
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.ui.modal"}}
<ul class="nav navbar-right float-remove-xs text-center-xs">
{{#each Main}}
<li class="visible-inline-block">
@ -26,23 +27,35 @@
{{#if this.isDomain }}
{{@user.domain}}
{{else}}
{{@key}}
{{#if this.label}}
{{this.label}}
{{else}}
{{@key}}
{{/if}}
{{/if}}
">
<span class="icon fw-stack fw-lg" {{#if this.isSupport}} style="color: #ff8c27;" {{/if}}>
<span class="icon fw-stack fw-lg" {{#if this.isSupport}} style="color: #ff8c27;" {{/if}} {{#if this.color}} style="color: {{this.color}};" {{/if}}>
<i class="{{this.icon}} fw-stack-1x" title="
{{#if this.isDomain }}
{{@user.domain}}
{{else}}
{{@key}}
{{#if this.label}}
{{this.label}}
{{else}}
{{@key}}
{{/if}}
{{/if}}
"></i>
</span>
<span class="hidden-xs {{#if this.isDomain }} username {{/if}}">
<span class="hidden-xs {{#if this.isDomain }} username {{/if}}" {{#if this.color}} style="color: {{this.color}};" {{/if}}>
{{#if this.isDomain }}
{{@user.domain}}
{{else}}
{{@key}}
{{#if this.label}}
{{this.label}}
{{else}}
{{@key}}
{{/if}}
{{/if}}
</span>
{{#if this.dropDownVisible}}
@ -136,6 +149,42 @@
</div>
</div>
{{#if Main.Account.isExpired}}
<div id="expire-modal-content" class="hide">
<div class="modal-header">
<h3 class="pull-left modal-title">
<span>
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-alert fw-stack-1x"></i>
</span> Trial Expired
</span>
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i></button>
</div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div id="user-groups">Was it a successful trial? Your trial unfortunately expired, however it is really easy to upgrade to a paid plan and keep using WSO2 Device Cloud</div>
</div>
<div class="modal-footer">
<div class="buttons">
<a href="{{Main.Account.dropDown.[Upgrade Now].url}}" id="expire-upgrade-now-link" class="btn-operations">
Upgrade Now
</a>
<a href="{{Main.Account.dropDown.[Request Extension].url}}" id="expire-req-ext-link" class="btn-operations">
Request Exception
</a>
</div>
</div>
</div>
{{/if}}
{{#zone "bottomJs"}}
{{#if Main.Account.isExpired}}
{{js "/js/monetize.js"}}
{{/if}}
{{js "/js/user-menu.js"}}
{{/zone}}

@ -20,6 +20,10 @@ function onRequest(context) {
var constants = require("/app/modules/constants.js");
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var cloudProps = require("/app/modules/conf-reader/cloud.js")["conf"];
var log = new Log("user-menu.js");
var sqlDateFormatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
var user = context.user;
var isSuperTenant = false;
if (user.tenantId == -1234) {
@ -32,6 +36,79 @@ function onRequest(context) {
viewModal.Main.Domain.isDomain = true;
viewModal.Main.Support.isSupport = true;
//get billing info
var type = {PAID: "PAID", TRIAL: "TRIAL", FREE: "FREE"};
var status = {
ACTIVE: "ACTIVE",
INACTIVE: "INACTIVE",
EXTENDED: "EXTENDED",
PENDING_DISABLED: "PENDING_DISABLED",
DISABLED: "DISABLED"
};
var BILLING_INFO_KEY = 'BILLING_INFO_' + context.user.domain;
var BILLING_INFO_RETRY_COUNT_KEY = 'BILLING_INFO_RETRY_COUNT_' + context.user.domain;
if (viewModal.Main.Account.billingEnabled) {
if (!session.get(BILLING_INFO_KEY) || daysAfterLastCheck(session.get(BILLING_INFO_KEY).lastChecked) > 1) {
session.put(BILLING_INFO_RETRY_COUNT_KEY, 0);
getBillingData(getLoginCookie());
}
var billingInfo = session.get(BILLING_INFO_KEY);
var isExpired = false;
var isTrial = false;
var trialPeriod = 14;
var cloudMgtIndexPage = viewModal.Main.Account.cloudMgtIndexPage;
if (!billingInfo) {
log.info("Access denied for tenant: " + context.user.domain
+ " with a NULL subscription. Redirected to CloudMgt");
response.sendRedirect(cloudMgtIndexPage);
exit(0);
} else if (billingInfo.isPaidAccount && (billingInfo.billingPlanStatus === status.ACTIVE
|| billingInfo.billingPlanStatus === status.PENDING_DISABLED)) {
isExpired = false;
//change menu item name
delete viewModal.Main.Account.color;
delete viewModal.Main.Account["Request Extension"];
} else if (!billingInfo.isPaidAccount) {
var accountContent = "Account";
if (billingInfo.billingPlanStatus === status.ACTIVE || billingInfo.billingPlanStatus === status.EXTENDED) {
var currDate = new java.util.Date();
var endDate = sqlDateFormatter.parse(billingInfo.endDate);
var diff = endDate.getTime() - currDate.getTime();
isTrial = true;
if (diff > 0) {
noOfDays = java.util.concurrent.TimeUnit.MILLISECONDS.toDays(diff);
accountContent = "Trial - " + (noOfDays + 1) + " days to upgrade";
} else {
isExpired = true;
accountContent = "Trial Expired";
}
} else if (billingInfo.billingPlanStatus === status.INACTIVE) {
isExpired = false;
isTrial = true;
accountContent = "Trial " + (trialPeriod) + " days tade";
}
//change menu item name
viewModal.Main.Account.label = accountContent;
viewModal.Main.Account.isDomain = false;
viewModal.Main.Account.color = "red";
viewModal.Main.Account.isExpired = isExpired;
} else if (billingInfo.billingPlanStatus === status.DISABLED) {
log.info(
"Access denied for tenant: " + context.user.domain
+ " with a DISABLED subscription. Redirected to CloudMgt");
response.sendRedirect(cloudMgtIndexPage);
exit(0);
}
} else {
// delete viewModal.Main.Account;
viewModal.Main.Account = {"billingEnabled": false}
}
for (var key in viewModal.Main) {
var tempDropDownCheck = false;
@ -80,4 +157,63 @@ function onRequest(context) {
viewModal.USER_SESSION_KEY = session.get(constants["USER_SESSION_KEY"]);
viewModal.isCloud = mdmProps.isCloud;
return viewModal;
function getBillingData(cookie, attempt) {
serviceUrl = "https://cloudmgt.cloudstaging.wso2.com/cloudmgt/site/blocks/admin/admin.jag";
result = post(serviceUrl,
'action=getBillingStatusOfTenant&tenantDomain=' + context.user.domain + '&cloudType=device_cloud',
{"Cookie": cookie});
if (result.data) {
var billing = JSON.parse(result.data).data;
if (!billing.isPaidAccount && billing.billingPlanStatus === status.INACTIVE) {
var rv = post(serviceUrl,
'action=informFirstLogin&tenantDomain=' + context.user.domain + '&cloudType=device_cloud',
{"Cookie": cookie});
if (!attempt) attempt = 1;
var failStr = "First login capturing failed";
var successStr = "First login captured successfully";
if (rv.data.substring(0, failStr.length) === failStr && attempt < 3) {
getBillingData(cookie, ++attempt); //retry
} else if(rv.data.substring(0, successStr.length) === successStr) {
getBillingData(cookie); //get expiry details
}
} else {
session.put(BILLING_INFO_KEY, JSON.parse(result.data).data);
session.put(BILLING_INFO_RETRY_COUNT_KEY, 0);
}
}
}
function getLoginCookie(){
var retryCount = session.get(BILLING_INFO_RETRY_COUNT_KEY) || 0;
if (retryCount <= 3) {
retryCount++;
session.put(BILLING_INFO_RETRY_COUNT_KEY, retryCount);
var username = viewModal.Main.Account.billingApi.username;
var password = viewModal.Main.Account.billingApi.password;
var serviceUrl = "https://cloudmgt.cloudstaging.wso2.com/cloudmgt/site/blocks/user/authenticate/ajax/login.jag";
var result = post(serviceUrl, 'action=login&userName=' + username + '&password=' + password,
{"Content-Type": "application/x-www-form-urlencoded"});
if (result.data && result.data.trim() === "true") {
var cookieHeader = result.xhr.getResponseHeader("Set-Cookie");
if (cookieHeader) {
var cookie = cookieHeader.split(";")[0];
return cookie;
}
}
} else {
log.error("Billing info api failed after " + session.get(BILLING_INFO_RETRY_COUNT_KEY) + " attempts!");
}
}
function daysAfterLastCheck(checkedDate){
if(!checkedDate) return 0;
var currDate = new java.util.Date();
var endDate = sqlDateFormatter.parse(checkedDate);
var diff = endDate.getTime() - currDate.getTime();
if (diff > 0) {
return java.util.concurrent.TimeUnit.MILLISECONDS.toDays(diff);
}
return 0;
}
}

@ -2844,6 +2844,31 @@ a.ast-type-item:hover {
}
/* operations panel/board */
.operation-tile{
width: 88px;
height: 100px;
background-color: #ebebeb;
float: left;
margin: 0px 10px 10px 0px;
cursor: pointer;
position: relative;
}
.operation-tile i{
padding: 15px 0px 0px 0px;
display: block;
min-height: 65px;
margin: -5px !important;
font-size: 36px !important;
}
.operation-tile span{
height: 35px;
line-height: 15px;
vertical-align: middle;
display: table-cell !important;
width: inherit;
}
.wr-operations-board {
background: #fafafa;
margin-bottom: 10px;
@ -6863,6 +6888,12 @@ select > option:hover {
/*background:url('http://cdn-sg1.pgimgs.com/images/pg/close-button.png') no-repeat center center;*/
}
.device-owner-operations {
pointer-events: none;
opacity: 0.5;
background: #b6b4bb;
}
.label-bold {
font-weight: 400;
}
@ -6973,3 +7004,4 @@ header.header-default {
.header .fw-user{
color: #333 !important;
}

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

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

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

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

@ -22,13 +22,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

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

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

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Core</name>
<description>WSO2 Carbon - Policy Management Core</description>

@ -23,13 +23,18 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.policy.mgt.DeviceGroupWrapper;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyCriterion;
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMgtConstants;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
@ -37,6 +42,10 @@ import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImp
import org.wso2.carbon.policy.mgt.common.*;
import org.wso2.carbon.policy.mgt.core.cache.impl.PolicyCacheManagerImpl;
import org.wso2.carbon.policy.mgt.core.dao.*;
import org.wso2.carbon.policy.mgt.core.enforcement.PolicyDelegationException;
import org.wso2.carbon.policy.mgt.core.enforcement.PolicyEnforcementDelegator;
import org.wso2.carbon.policy.mgt.core.enforcement.PolicyEnforcementDelegatorImpl;
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager;
import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager;
import org.wso2.carbon.policy.mgt.core.mgt.bean.UpdatedPolicyDeviceListBean;
@ -317,6 +326,22 @@ public class PolicyManagerImpl implements PolicyManager {
@Override
public boolean deletePolicy(int policyId) throws PolicyManagementException {
boolean bool;
List<Policy> policies = this.getPolicies();
Policy pol = null;
for (Policy p : policies) {
if (policyId == p.getId()) {
pol = p;
}
}
String deviceType = pol.getProfile().getDeviceType();
List<Policy> deviceTypePolicyList = this.getPoliciesOfDeviceType(deviceType);
if (deviceTypePolicyList.size() == 1) {
List<Device> devices = this.getPolicyAppliedDevicesIds(policyId);
List<DeviceIdentifier> deviceIdentifiers = this.convertDevices(devices);
this.addPolicyRevokeOperation(deviceIdentifiers);
}
try {
PolicyManagementDAOFactory.beginTransaction();
@ -836,6 +861,7 @@ public class PolicyManagerImpl implements PolicyManager {
List<String> changedDeviceTypes = new ArrayList<>();
List<Policy> updatedPolicies = new ArrayList<>();
List<Integer> updatedPolicyIds = new ArrayList<>();
boolean transactionDone = false;
try {
//HashMap<Integer, Integer> map = policyDAO.getUpdatedPolicyIdandDeviceTypeId();
// List<Policy> activePolicies = new ArrayList<>();
@ -859,6 +885,7 @@ public class PolicyManagerImpl implements PolicyManager {
// }
}
PolicyManagementDAOFactory.beginTransaction();
transactionDone = true;
policyDAO.markPoliciesAsUpdated(updatedPolicyIds);
policyDAO.removeRecordsAboutUpdatedPolicies();
PolicyManagementDAOFactory.commitTransaction();
@ -866,7 +893,9 @@ public class PolicyManagerImpl implements PolicyManager {
PolicyManagementDAOFactory.rollbackTransaction();
throw new PolicyManagementException("Error occurred while applying the changes to policy operations.", e);
} finally {
PolicyManagementDAOFactory.closeConnection();
if(transactionDone) {
PolicyManagementDAOFactory.closeConnection();
}
}
return new UpdatedPolicyDeviceListBean(updatedPolicies, updatedPolicyIds, changedDeviceTypes);
}
@ -1045,4 +1074,44 @@ public class PolicyManagerImpl implements PolicyManager {
return groupWrappers;
}
private List<DeviceIdentifier> convertDevices(List<Device> devices) {
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
for (Device device : devices) {
DeviceIdentifier identifier = new DeviceIdentifier();
identifier.setId(device.getDeviceIdentifier());
identifier.setType(device.getType());
deviceIdentifiers.add(identifier);
}
return deviceIdentifiers;
}
private void addPolicyRevokeOperation(List<DeviceIdentifier> deviceIdentifiers) throws PolicyManagementException {
try {
String type = null;
if (deviceIdentifiers.size() > 0) {
type = deviceIdentifiers.get(0).getType();
}
PolicyManagementDataHolder.getInstance().getDeviceManagementService().addOperation(type,
this.getPolicyRevokeOperation(), deviceIdentifiers);
} catch (InvalidDeviceException e) {
String msg = "Invalid DeviceIdentifiers found.";
log.error(msg, e);
throw new PolicyManagementException(msg, e);
} catch (OperationManagementException e) {
String msg = "Error occurred while adding the operation to device.";
log.error(msg, e);
throw new PolicyManagementException(msg, e);
}
}
private Operation getPolicyRevokeOperation() {
CommandOperation policyRevokeOperation = new CommandOperation();
policyRevokeOperation.setEnabled(true);
policyRevokeOperation.setCode(OperationMgtConstants.OperationCodes.POLICY_REVOKE);
policyRevokeOperation.setType(Operation.Type.COMMAND);
return policyRevokeOperation;
}
}

@ -23,13 +23,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>policy-mgt</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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,13 +21,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client.feature</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - APIM Integration Client Feature</name>
<url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

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

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature</artifactId>
<packaging>pom</packaging>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<name>WSO2 Carbon - FCM 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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature</artifactId>
<packaging>pom</packaging>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -3,13 +3,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.analytics.dashboard.feature</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -4,14 +4,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId>
<version>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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>3.0.20-SNAPSHOT</version>
<version>3.0.32-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