revert-70aa11f8
charitha 8 years ago
commit e6c4053135

@ -162,7 +162,7 @@
<artifactId>swagger-core</artifactId> <artifactId>swagger-core</artifactId>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>

@ -106,9 +106,14 @@ public class CertificateManagementServiceComponent {
private void setupDeviceManagementSchema(DataSourceConfig config) throws CertificateManagementException { private void setupDeviceManagementSchema(DataSourceConfig config) throws CertificateManagementException {
CertificateMgtSchemaInitializer initializer = new CertificateMgtSchemaInitializer(config); CertificateMgtSchemaInitializer initializer = new CertificateMgtSchemaInitializer(config);
log.info("Initializing Certificate management repository database schema"); String checkSql = "select * from DM_DEVICE_CERTIFICATE";
try { try {
initializer.createRegistryDatabase(); if (!initializer.isDatabaseStructureCreated(checkSql)) {
log.info("Initializing Certificate management repository database schema");
initializer.createRegistryDatabase();
} else {
log.info("Certificate management repository database already exists. Not creating a new database.");
}
} catch (Exception e) { } catch (Exception e) {
throw new CertificateManagementException( throw new CertificateManagementException(
"Error occurred while initializing Certificate Management database schema", e); "Error occurred while initializing Certificate Management database schema", e);
@ -117,6 +122,4 @@ public class CertificateManagementServiceComponent {
log.debug("Certificate management metadata repository schema has been successfully initialized"); log.debug("Certificate management metadata repository schema has been successfully initialized");
} }
} }
} }

@ -231,7 +231,7 @@
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
@ -249,7 +249,7 @@
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
@ -270,7 +270,7 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
</dependency> </dependency>
<dependency> <dependency>

@ -66,7 +66,7 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
</dependency> </dependency>
<dependency> <dependency>

@ -265,9 +265,14 @@ public class DeviceManagementServiceComponent {
private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException { private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException {
DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config); DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config);
log.info("Initializing device management repository database schema"); String checkSql = "select * from DM_DEVICE_TYPE";
try { try {
initializer.createRegistryDatabase(); if (!initializer.isDatabaseStructureCreated(checkSql)) {
log.info("Initializing device management repository database schema");
initializer.createRegistryDatabase();
} else {
log.info("Device management database already exists. Not creating a new database.");
}
} catch (Exception e) { } catch (Exception e) {
throw new DeviceManagementException( throw new DeviceManagementException(
"Error occurred while initializing Device Management database schema", e); "Error occurred while initializing Device Management database schema", e);

@ -85,14 +85,14 @@ public class OracleNotificationDAOImpl extends AbstractNotificationDAOImpl {
List<Notification> notifications = null; List<Notification> notifications = null;
try { try {
conn = NotificationManagementDAOFactory.getConnection(); conn = NotificationManagementDAOFactory.getConnection();
String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," + String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS,"
" n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM " + + " n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, d.NAME as DEVICE_NAME, t.NAME AS DEVICE_TYPE FROM "
"DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " + + "DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, "
"OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + + "OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE "
"TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " + + "TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID "
"AND TENANT_ID = ?"; + "AND TENANT_ID = ?";
sql = sql + " OFFSET >= ? AND ROWNUM <= ?"; sql = sql + " ORDER BY n1.NOTIFICATION_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setInt(1, tenantId); stmt.setInt(1, tenantId);

@ -76,32 +76,69 @@ deviceModule = function () {
function (backendResponse) { function (backendResponse) {
var response = {}; var response = {};
if (backendResponse.status == 200 && backendResponse.responseText) { if (backendResponse.status == 200 && backendResponse.responseText) {
response["status"] = "success";
var device = parse(backendResponse.responseText); var device = parse(backendResponse.responseText);
var propertiesList = device["properties"];
var properties = {}; var filteredDeviceData = {};
for (var i = 0; i < propertiesList.length; i++) { if (device["deviceIdentifier"]) {
properties[propertiesList[i]["name"]] = filteredDeviceData["deviceIdentifier"] = device["deviceIdentifier"];
propertiesList[i]["value"];
} }
var deviceObject = {}; if (device["type"]) {
deviceObject[constants["DEVICE_IDENTIFIER"]] = device["deviceIdentifier"]; filteredDeviceData["type"] = device["type"];
deviceObject[constants["DEVICE_NAME"]] = device["name"];
deviceObject[constants["DEVICE_OWNERSHIP"]] = device["enrolmentInfo"]["ownership"];
deviceObject[constants["DEVICE_OWNER"]] = device["enrolmentInfo"]["owner"];
deviceObject[constants["DEVICE_STATUS"]] = device["enrolmentInfo"]["status"];
deviceObject[constants["DEVICE_TYPE"]] = device["type"];
if (device["type"] == constants["PLATFORM_IOS"]) {
properties[constants["DEVICE_MODEL"]] = properties[constants["DEVICE_PRODUCT"]];
delete properties[constants["DEVICE_PRODUCT"]];
properties[constants["DEVICE_VENDOR"]] = constants["VENDOR_APPLE"];
} }
deviceObject[constants["DEVICE_PROPERTIES"]] = properties; if (device["name"]) {
if (device["deviceInfo"]) { filteredDeviceData["name"] = device["name"];
deviceObject[constants["DEVICE_INFO"]] = device["deviceInfo"]; }
if (device["enrolmentInfo"]) {
var enrolmentInfo = {};
if (device["enrolmentInfo"]["status"]) {
enrolmentInfo["status"] = device["enrolmentInfo"]["status"];
}
if (device["enrolmentInfo"]["owner"]) {
enrolmentInfo["owner"] = device["enrolmentInfo"]["owner"];
}
if (device["enrolmentInfo"]["ownership"]) {
enrolmentInfo["ownership"] = device["enrolmentInfo"]["ownership"];
}
filteredDeviceData["enrolmentInfo"] = enrolmentInfo;
}
if (device["properties"] && device["properties"].length > 0) {
var propertiesList = device["properties"];
var properties = {};
for (var i = 0; i < propertiesList.length; i++) {
if (propertiesList[i]["value"]) {
properties[propertiesList[i]["name"]] =
propertiesList[i]["value"];
}
}
filteredDeviceData["initialDeviceInfo"] = properties;
if (properties["DEVICE_INFO"]) {
var initialDeviceInfoList = parse(properties["DEVICE_INFO"]);
var initialDeviceInfo = {};
for (var j = 0; j < initialDeviceInfoList.length; j++) {
if (initialDeviceInfoList[j]["value"]) {
initialDeviceInfo[initialDeviceInfoList[j]["name"]] =
initialDeviceInfoList[j]["value"];
}
}
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"] = initialDeviceInfo;
}
} }
response["content"] = deviceObject; if (filteredDeviceData["type"]) {
if (filteredDeviceData["type"] == constants["PLATFORM_IOS"]) {
if (filteredDeviceData["properties"]) {
filteredDeviceData["properties"]["VENDOR"] = "Apple";
}
}
}
if (device["deviceInfo"]) {
filteredDeviceData["latestDeviceInfo"] = device["deviceInfo"];
}
response["content"] = filteredDeviceData;
response["status"] = "success";
return response; return response;
} else if (backendResponse.status == 401) { } else if (backendResponse.status == 401) {
response["status"] = "unauthorized"; response["status"] = "unauthorized";

@ -5,4 +5,16 @@ CREATE TABLE DM_DEVICE_CERTIFICATE (
TENANT_ID NUMBER(10) DEFAULT 0, TENANT_ID NUMBER(10) DEFAULT 0,
USERNAME VARCHAR2(500) DEFAULT NULL, USERNAME VARCHAR2(500) DEFAULT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
) )
/
-- Generate ID using sequence and trigger
CREATE SEQUENCE DM_DEVICE_CERTIFICATE_seq START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER DM_DEVICE_CERTIFICATE_seq_tr
BEFORE INSERT ON DM_DEVICE_CERTIFICATE FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT DM_DEVICE_CERTIFICATE_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/

@ -125,7 +125,7 @@
org.wso2.carbon.identity:org.wso2.carbon.identity.oauth.stub:${identity.inbound.auth.oauth.version} org.wso2.carbon.identity:org.wso2.carbon.identity.oauth.stub:${identity.inbound.auth.oauth.version}
</bundleDef> </bundleDef>
<bundleDef> <bundleDef>
com.fasterxml.jackson.core:jackson-annotations:${jackson-annotations.version} org.wso2.orbit.com.fasterxml.jackson.core:jackson-annotations:${jackson-annotations.version}
</bundleDef> </bundleDef>
<!-- Below should be bundled with the email verification --> <!-- Below should be bundled with the email verification -->
</bundles> </bundles>

@ -3,7 +3,8 @@ CREATE TABLE DM_DEVICE_TYPE (
NAME VARCHAR2(300) DEFAULT NULL, NAME VARCHAR2(300) DEFAULT NULL,
PROVIDER_TENANT_ID INTEGER DEFAULT 0, PROVIDER_TENANT_ID INTEGER DEFAULT 0,
SHARED_WITH_ALL_TENANTS NUMBER(1) DEFAULT 0 NOT NULL, SHARED_WITH_ALL_TENANTS NUMBER(1) DEFAULT 0 NOT NULL,
CONSTRAINT PK_DM_DEVICE_TYPE PRIMARY KEY (ID) CONSTRAINT PK_DM_DEVICE_TYPE PRIMARY KEY (ID),
UNIQUE (NAME)
) )
/ /
-- Generate ID using sequence and trigger -- Generate ID using sequence and trigger
@ -44,16 +45,6 @@ WHEN (NEW.ID IS NULL)
SELECT DM_GROUP_seq.NEXTVAL INTO :NEW.ID FROM DUAL; SELECT DM_GROUP_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
END; END;
/ /
-- Generate ID using sequence and trigger
CREATE SEQUENCE DM_DEVICE_CERTIFICATE_seq START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER DM_DEVICE_CERTIFICATE_seq_tr
BEFORE INSERT ON DM_DEVICE_CERTIFICATE FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT DM_DEVICE_CERTIFICATE_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/
CREATE TABLE DM_DEVICE ( CREATE TABLE DM_DEVICE (
ID NUMBER(10) NOT NULL, ID NUMBER(10) NOT NULL,
@ -436,7 +427,7 @@ CREATE TABLE DM_DEVICE_POLICY_APPLIED (
POLICY_ID NUMBER(10) NOT NULL , POLICY_ID NUMBER(10) NOT NULL ,
POLICY_CONTENT BLOB NULL , POLICY_CONTENT BLOB NULL ,
TENANT_ID NUMBER(10) NOT NULL, TENANT_ID NUMBER(10) NOT NULL,
APPLIED BOOLEAN NULL , APPLIED NUMBER(1) DEFAULT 0,
CREATED_TIME TIMESTAMP(0) NULL , CREATED_TIME TIMESTAMP(0) NULL ,
UPDATED_TIME TIMESTAMP(0) NULL , UPDATED_TIME TIMESTAMP(0) NULL ,
APPLIED_TIME TIMESTAMP(0) NULL , APPLIED_TIME TIMESTAMP(0) NULL ,
@ -860,8 +851,8 @@ POLICY_ID,
STATUS AS IS_COMPLIANT STATUS AS IS_COMPLIANT
FROM DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO FROM DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO
ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID
ORDER BY DEVICE_INFO.DEVICE_ID;
/ /
CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS
SELECT SELECT
DM_DEVICE.ID AS DEVICE_ID, DM_DEVICE.ID AS DEVICE_ID,
@ -885,7 +876,7 @@ DM_POLICY_COMPLIANCE_STATUS.ENROLMENT_ID = DM_ENROLMENT.ID AND
DM_POLICY_COMPLIANCE_STATUS.DEVICE_ID = DM_DEVICE.ID AND DM_POLICY_COMPLIANCE_STATUS.DEVICE_ID = DM_DEVICE.ID AND
DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND
DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID
ORDER BY TENANT_ID, DEVICE_ID; /
-- END OF DASHBOARD RELATED VIEWS -- -- END OF DASHBOARD RELATED VIEWS --

@ -1501,7 +1501,7 @@
<version>${carbon.device.mgt.version}</version> <version>${carbon.device.mgt.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
<version>${jackson-annotations.version}</version> <version>${jackson-annotations.version}</version>
</dependency> </dependency>
@ -1893,7 +1893,7 @@
<!--JWT grant type extension feature--> <!--JWT grant type extension feature-->
<identity.jwt.extension.version>1.0.2</identity.jwt.extension.version> <identity.jwt.extension.version>1.0.2</identity.jwt.extension.version>
<jackson-annotations.version>2.7.4</jackson-annotations.version> <jackson-annotations.version>2.6.1.wso2v1</jackson-annotations.version>
<owasp.encoder.version>1.2.0.wso2v1</owasp.encoder.version> <owasp.encoder.version>1.2.0.wso2v1</owasp.encoder.version>
<hibernate-validator.version>5.0.2.Final</hibernate-validator.version> <hibernate-validator.version>5.0.2.Final</hibernate-validator.version>

Loading…
Cancel
Save