revert-70aa11f8
Ruwan Yatawara 7 years ago
commit c162221bb8

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

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

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

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

@ -29,7 +29,7 @@
<Password>admin</Password> <Password>admin</Password>
<!--Dynamic client registration endpoint--> <!--Dynamic client registration endpoint-->
<DynamicClientRegistrationEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.11/register</DynamicClientRegistrationEndpoint> <DynamicClientRegistrationEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register</DynamicClientRegistrationEndpoint>
<!--Oauth token endpoint--> <!--Oauth token endpoint-->
<OauthTokenEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token</OauthTokenEndpoint> <OauthTokenEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token</OauthTokenEndpoint>

@ -47,7 +47,7 @@ public class IOTServerConfigurationTest extends BaseAPIHandlerTest {
Assert.assertEquals(serverConfiguration.getUsername(), "testuser"); Assert.assertEquals(serverConfiguration.getUsername(), "testuser");
Assert.assertEquals(serverConfiguration.getPassword(), "testuserpwd"); Assert.assertEquals(serverConfiguration.getPassword(), "testuserpwd");
Assert.assertEquals(serverConfiguration.getDynamicClientRegistrationEndpoint(), Assert.assertEquals(serverConfiguration.getDynamicClientRegistrationEndpoint(),
"https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.11/register"); "https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register");
Assert.assertEquals(serverConfiguration.getOauthTokenEndpoint(), Assert.assertEquals(serverConfiguration.getOauthTokenEndpoint(),
"https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token"); "https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token");
Assert.assertEquals(serverConfiguration.getApis().size(), 1); Assert.assertEquals(serverConfiguration.getApis().size(), 1);
@ -87,7 +87,7 @@ public class IOTServerConfigurationTest extends BaseAPIHandlerTest {
Assert.assertEquals(serverConfiguration.getPassword(), "testuserpwd"); Assert.assertEquals(serverConfiguration.getPassword(), "testuserpwd");
Assert.assertEquals(serverConfiguration.getDynamicClientRegistrationEndpoint(), Assert.assertEquals(serverConfiguration.getDynamicClientRegistrationEndpoint(),
"https://" + TestUtils.IOT_KEYMANAGER_HOST + ":" + TestUtils.IOT_KEYMANAGER_PORT "https://" + TestUtils.IOT_KEYMANAGER_HOST + ":" + TestUtils.IOT_KEYMANAGER_PORT
+ "/client-registration/v0.11/register"); + "/client-registration/v0.12/register");
Assert.assertEquals(serverConfiguration.getOauthTokenEndpoint(), Assert.assertEquals(serverConfiguration.getOauthTokenEndpoint(),
"https://" + TestUtils.IOT_KEYMANAGER_HOST + ":" + TestUtils.IOT_KEYMANAGER_PORT "https://" + TestUtils.IOT_KEYMANAGER_HOST + ":" + TestUtils.IOT_KEYMANAGER_PORT
+ "/oauth2/token"); + "/oauth2/token");

@ -29,7 +29,7 @@
<Password>testuserpwd</Password> <Password>testuserpwd</Password>
<!--Dynamic client registration endpoint--> <!--Dynamic client registration endpoint-->
<DynamicClientRegistrationEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.11/register</DynamicClientRegistrationEndpoint> <DynamicClientRegistrationEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register</DynamicClientRegistrationEndpoint>
<!--Oauth token endpoint--> <!--Oauth token endpoint-->
<OauthTokenEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token</OauthTokenEndpoint> <OauthTokenEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token</OauthTokenEndpoint>

@ -29,7 +29,7 @@
<Password>testuserpwd</Password> <Password>testuserpwd</Password>
<!--Dynamic client registration endpoint--> <!--Dynamic client registration endpoint-->
<DynamicClientRegistrationEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.11/register</DynamicClientRegistrationEndpoint> <DynamicClientRegistrationEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register</DynamicClientRegistrationEndpoint>
<!--Oauth token endpoint--> <!--Oauth token endpoint-->
<OauthTokenEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token</OauthTokenEndpoint> <OauthTokenEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token</OauthTokenEndpoint>

@ -29,7 +29,7 @@
<Password>testuserpwd</Password> <Password>testuserpwd</Password>
<!--Dynamic client registration endpoint--> <!--Dynamic client registration endpoint-->
<DynamicClientRegistrationEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.11/register</DynamicClientRegistrationEndpoint> <DynamicClientRegistrationEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register</DynamicClientRegistrationEndpoint>
<!--Oauth token endpoint--> <!--Oauth token endpoint-->
<OauthTokenEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token</OauthTokenEndpoint> <OauthTokenEndpoint>https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token</OauthTokenEndpoint>

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

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

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

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

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

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

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
~ /* ~ /*
~ * Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ * ~ *
~ * WSO2 Inc. licenses this file to you under the Apache License, ~ * WSO2 Inc. licenses this file to you under the Apache License,
~ * Version 2.0 (the "License"); you may not use this file except ~ * Version 2.0 (the "License"); you may not use this file except
@ -24,7 +24,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.244-SNAPSHOT</version> <version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -1,6 +1,6 @@
/* /*
* *
* Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans; package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans; package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ -43,7 +44,6 @@ public class CertificateList extends BasePaginatedResult {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("{\n"); sb.append("{\n");
sb.append(" count: ").append(getCount()).append(",\n"); sb.append(" count: ").append(getCount()).append(",\n");
sb.append(" next: ").append(getNext()).append(",\n"); sb.append(" next: ").append(getNext()).append(",\n");
sb.append(" previous: ").append(getPrevious()).append(",\n"); sb.append(" previous: ").append(getPrevious()).append(",\n");
@ -51,5 +51,5 @@ public class CertificateList extends BasePaginatedResult {
sb.append("]}\n"); sb.append("]}\n");
return sb.toString(); return sb.toString();
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans; package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans; package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;

@ -16,7 +16,6 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans; package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans;
public class ValidationResponse { public class ValidationResponse {

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
/* /*
* *
* Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -17,6 +17,7 @@
* under the License. * under the License.
* / * /
*/ */
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.swagger.extension; package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.swagger.extension;
import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.SwaggerDefinition;

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util; package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util;
import javax.servlet.*; import javax.servlet.*;

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util; package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util;
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.ErrorResponse; import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.ErrorResponse;

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ /* ~ /*
~ * Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ * ~ *
~ * WSO2 Inc. licenses this file to you under the Apache License, ~ * WSO2 Inc. licenses this file to you under the Apache License,
~ * Version 2.0 (the "License"); you may not use this file except ~ * Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

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

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
~ /* ~ /*
~ * Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ * ~ *
~ * WSO2 Inc. licenses this file to you under the Apache License, ~ * WSO2 Inc. licenses this file to you under the Apache License,
~ * Version 2.0 (the "License"); you may not use this file except ~ * Version 2.0 (the "License"); you may not use this file except
@ -24,7 +24,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.244-SNAPSHOT</version> <version>3.1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -1,6 +1,6 @@
/* /*
* *
* Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,3 +1,21 @@
/*
* 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.
*/
package org.wso2.carbon.certificate.mgt.jaxrs.api.impl; package org.wso2.carbon.certificate.mgt.jaxrs.api.impl;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -16,6 +16,7 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.certificate.mgt.jaxrs.beans; package org.wso2.carbon.certificate.mgt.jaxrs.beans;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ -69,11 +70,9 @@ public class ErrorListItem {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("errorItem {\n"); sb.append("errorItem {\n");
sb.append(" code: ").append(code).append("\n"); sb.append(" code: ").append(code).append("\n");
sb.append(" message: ").append(message).append("\n"); sb.append(" message: ").append(message).append("\n");
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ /* ~ /*
~ * Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ * ~ *
~ * WSO2 Inc. licenses this file to you under the Apache License, ~ * WSO2 Inc. licenses this file to you under the Apache License,
~ * Version 2.0 (the "License"); you may not use this file except ~ * Version 2.0 (the "License"); you may not use this file except

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

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

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

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

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

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

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

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

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

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

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

@ -18,18 +18,11 @@
*/ */
package org.wso2.carbon.device.mgt.jaxrs.service.api.admin; package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.*;
import io.swagger.annotations.Info; import org.apache.axis2.transport.http.HTTPConstants;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
@ -61,6 +54,12 @@ import javax.ws.rs.core.Response;
description = "View Users", description = "View Users",
key = "perm:admin-users:view", key = "perm:admin-users:view",
permissions = {"/device-mgt/users/manage"} permissions = {"/device-mgt/users/manage"}
),
@Scope(
name = "Delete Users Device Information",
description = "Delete users device details",
key = "perm:admin-users:remove",
permissions = {"/device-mgt/users/manage"}
) )
} }
) )
@ -127,4 +126,131 @@ public interface UserManagementAdminService {
value = "Credential.", value = "Credential.",
required = true) PasswordResetWrapper credentials); required = true) PasswordResetWrapper credentials);
@Path("/{username}/devices")
@DELETE
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = HTTPConstants.HEADER_DELETE,
value = "Delete a users associated devices.",
notes = "If you wish to remove an device details to comply with the privacy requirements, can be done with " +
"this resource.",
tags = "Device details remove",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:admin-users:remove")
})
}
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n Users devices and details has been deleted successfully.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body."),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 404,
message = "Group not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while removing the group.",
response = ErrorResponse.class)
})
Response deleteDeviceOfUser(@ApiParam(
name = "username",
value = "Username of the users devices to be deleted.",
required = true)
@PathParam("username") String username);
//device remove request would looks like follows
//DELETE devices/type/virtual_firealarm/id/us06ww93auzp
@DELETE
@Path("/type/{device-type}/id/{device-id}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON,
httpMethod = "DELETE",
value = "Remove the information of device specified by device id",
notes = "Returns the status of the deleted device information.",
tags = "Device details remove privacy compliance",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:admin-users:remove")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully deleted the device information.",
response = Device.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest " +
"version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Found. \n No device is found under the provided type and id.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving information requested device.",
response = ErrorResponse.class)
})
Response deleteDevice(
@ApiParam(
name = "device-type",
value = "The device type, such as ios, android or windows.",
required = true)
@PathParam("device-type")
@Size(max = 45)
String deviceType,
@ApiParam(
name = "device-id",
value = "The device identifier of the device.",
required = true)
@PathParam("device-id")
@Size(max = 45)
String deviceId);
} }

@ -178,6 +178,10 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
String error = "Error occurred while creating the geo alert for " + deviceType + " with id: " + deviceId; String error = "Error occurred while creating the geo alert for " + deviceType + " with id: " + deviceId;
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
} catch (AlertAlreadyExistException e) {
String error = "A geo alert with this name already exists.";
log.error(error,e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
} }
} }
@ -211,6 +215,10 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
String error = "Error occurred while creating the geo alert for " + deviceType + " with id: " + deviceId; String error = "Error occurred while creating the geo alert for " + deviceType + " with id: " + deviceId;
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
} catch (AlertAlreadyExistException e) {
String error = "A geo alert with this name already exists.";
log.error(error,e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
} }
} }

@ -18,9 +18,17 @@
*/ */
package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin; package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
import io.swagger.annotations.ApiParam;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.netbeans.lib.cvsclient.commandLine.command.log;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.PrivacyComplianceException;
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.UserManagementAdminService; import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.UserManagementAdminService;
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder; import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -32,16 +40,45 @@ import javax.ws.rs.core.Response;
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public class UserManagementAdminServiceImpl implements UserManagementAdminService { public class UserManagementAdminServiceImpl implements UserManagementAdminService {
private static final Log log = LogFactory.getLog(UserManagementAdminServiceImpl.class);
@POST @POST
@Path("/{username}/credentials") @Path("/{username}/credentials")
@Override @Override
public Response resetUserPassword(@PathParam("username") public Response resetUserPassword(@PathParam("username")
@Size(max = 45) @Size(max = 45)
String user, @QueryParam("domain") String domain, PasswordResetWrapper credentials) { String user, @QueryParam("domain") String domain, PasswordResetWrapper credentials) {
if (domain != null && !domain.isEmpty()) { if (domain != null && !domain.isEmpty()) {
user = domain + '/' + user; user = domain + '/' + user;
} }
return CredentialManagementResponseBuilder.buildResetPasswordResponse(user, credentials); return CredentialManagementResponseBuilder.buildResetPasswordResponse(user, credentials);
} }
@Override
public Response deleteDeviceOfUser(@PathParam("username") String username) {
try {
DeviceMgtAPIUtils.getPrivacyComplianceProvider().deleteDevicesOfUser(username);
return Response.status(Response.Status.OK).build();
} catch (PrivacyComplianceException e) {
String msg = "Error occurred while deleting the devices belongs to the user.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@Override
public Response deleteDevice(@PathParam("device-type") @Size(max = 45) String deviceType,
@PathParam("device-id") @Size(max = 45) String deviceId) {
try {
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType);
DeviceMgtAPIUtils.getPrivacyComplianceProvider().deleteDeviceDetails(deviceIdentifier);
return Response.status(Response.Status.OK).build();
} catch (PrivacyComplianceException e) {
String msg = "Error occurred while deleting the devices information.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
} }

@ -49,6 +49,7 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagement
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService; import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
@ -297,6 +298,19 @@ public class DeviceMgtAPIUtils {
return realmService; return realmService;
} }
public static PrivacyComplianceProvider getPrivacyComplianceProvider() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
PrivacyComplianceProvider privacyComplianceProvider =
(PrivacyComplianceProvider) ctx.getOSGiService(PrivacyComplianceProvider.class, null);
if (privacyComplianceProvider == null) {
String msg = "PrivacyComplianceProvider service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return privacyComplianceProvider;
}
public static IntegrationClientService getIntegrationClientService() { public static IntegrationClientService getIntegrationClientService() {
if (integrationClientService == null) { if (integrationClientService == null) {
synchronized (DeviceMgtAPIUtils.class) { synchronized (DeviceMgtAPIUtils.class) {

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

@ -19,6 +19,8 @@
package org.wso2.carbon.device.mgt.common; package org.wso2.carbon.device.mgt.common;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/** /**
* This class holds required parameters for a querying a paginated device response. * This class holds required parameters for a querying a paginated device response.
@ -35,6 +37,7 @@ public class PaginationRequest {
private String deviceName; private String deviceName;
private String ownership; private String ownership;
private String ownerRole; private String ownerRole;
private Map<String, Object> property = new HashMap<>();
private Date since; private Date since;
public PaginationRequest(int start, int rowCount) { public PaginationRequest(int start, int rowCount) {
@ -130,6 +133,24 @@ public class PaginationRequest {
this.ownerPattern = ownerPattern; this.ownerPattern = ownerPattern;
} }
public void setProperty(String key, Object value) {
this.property.put(key, value);
}
public void setProperties(Map<String, Object> parameters) {
this.property.putAll(parameters);
}
public void getProperty(String key) {
this.property.get(key);
}
public Map<String, Object> getProperties() {
Map<String, Object> temp = new HashMap<>();
temp.putAll(property);
return temp;
}
@Override @Override
public String toString() { public String toString() {
return "Device type '" + this.deviceType + "' Device Name '" + this.deviceName + "' row count: " + this.rowCount return "Device type '" + this.deviceType + "' Device Name '" + this.deviceName + "' row count: " + this.rowCount

@ -0,0 +1,47 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.common;
public class PrivacyComplianceException extends Exception {
private static final long serialVersionUID = -3127931192903344297L;
public PrivacyComplianceException(String msg, Exception nestedEx) {
super(msg, nestedEx);
}
public PrivacyComplianceException(String message, Throwable cause) {
super(message, cause);
}
public PrivacyComplianceException(String msg) {
super(msg);
}
public PrivacyComplianceException() {
super();
}
public PrivacyComplianceException(Throwable cause) {
super(cause);
}
}

@ -0,0 +1,41 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* you may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.common.geo.service;
/**
* Custom exception class for geo alert definition operations.
*/
public class AlertAlreadyExistException extends Exception {
private static final long serialVersionUID = 4709355511911265093L;
private String errorMessage;
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public AlertAlreadyExistException(String msg) {
super(msg);
setErrorMessage(msg);
}
}

@ -33,10 +33,10 @@ public interface GeoLocationProviderService {
List<GeoFence> getExitAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException; List<GeoFence> getExitAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException;
boolean createGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType) boolean createGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
throws GeoLocationBasedServiceException; throws GeoLocationBasedServiceException, AlertAlreadyExistException;
boolean updateGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType) boolean updateGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
throws GeoLocationBasedServiceException; throws GeoLocationBasedServiceException, AlertAlreadyExistException;
boolean removeGeoAlert(String alertType, DeviceIdentifier identifier, String queryName) boolean removeGeoAlert(String alertType, DeviceIdentifier identifier, String queryName)
throws GeoLocationBasedServiceException; throws GeoLocationBasedServiceException;

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

@ -222,7 +222,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
} }
} }
DeviceManagementDAOFactory.beginTransaction(); DeviceManagementDAOFactory.beginTransaction();
applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove, tenantId); applicationMappingDAO.removeApplicationMapping(device.getId(), device.getEnrolmentInfo().getId(),
appIdsToRemove, tenantId);
Application installedApp; Application installedApp;
List<Integer> applicationIds = new ArrayList<>(); List<Integer> applicationIds = new ArrayList<>();
List<Application> applicationsToMap = new ArrayList<>(); List<Application> applicationsToMap = new ArrayList<>();
@ -263,7 +264,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("num of app Ids:" + applicationIds.size()); log.debug("num of app Ids:" + applicationIds.size());
} }
applicationMappingDAO.addApplicationMappingsWithApps(device.getId(), applicationsToMap, tenantId); applicationMappingDAO.addApplicationMappingsWithApps(device.getId(), device.getEnrolmentInfo().getId(),
applicationsToMap, tenantId);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("num of remove app Ids:" + appIdsToRemove.size()); log.debug("num of remove app Ids:" + appIdsToRemove.size());
@ -312,7 +314,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
} }
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
return applicationDAO.getInstalledApplications(device.getId()); return applicationDAO.getInstalledApplications(device.getId(), device.getEnrolmentInfo().getId());
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
String msg = "Error occurred while fetching the Application List of device " + deviceId.toString(); String msg = "Error occurred while fetching the Application List of device " + deviceId.toString();
log.error(msg, e); log.error(msg, e);

@ -34,7 +34,8 @@ public interface ApplicationDAO {
Application getApplication(String identifier, String version,int tenantId) throws DeviceManagementDAOException; Application getApplication(String identifier, String version,int tenantId) throws DeviceManagementDAOException;
Application getApplication(String identifier, String version, int deviceId, int tenantId) throws DeviceManagementDAOException; Application getApplication(String identifier, String version, int deviceId, int enrolmentId, int tenantId)
throws DeviceManagementDAOException;
List<Application> getInstalledApplications(int deviceId) throws DeviceManagementDAOException; List<Application> getInstalledApplications(int deviceId, int enrolmentId) throws DeviceManagementDAOException;
} }

@ -29,9 +29,9 @@ public interface ApplicationMappingDAO {
void addApplicationMappings(int deviceId, List<Integer> applicationIds, int tenantId) void addApplicationMappings(int deviceId, List<Integer> applicationIds, int tenantId)
throws DeviceManagementDAOException; throws DeviceManagementDAOException;
void addApplicationMappingsWithApps(int deviceId, List<Application> applications, int tenantId) void addApplicationMappingsWithApps(int deviceId, int enrolmentId, List<Application> applications, int tenantId)
throws DeviceManagementDAOException; throws DeviceManagementDAOException;
void removeApplicationMapping(int deviceId, List<Integer> appIdList, int tenantId) void removeApplicationMapping(int deviceId, int enrolmentId, List<Integer> appIdList, int tenantId)
throws DeviceManagementDAOException; throws DeviceManagementDAOException;
} }

@ -39,6 +39,8 @@ import org.wso2.carbon.device.mgt.core.dao.impl.device.SQLServerDeviceDAOImpl;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO; import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO;
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.impl.DeviceDetailsDAOImpl; import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.impl.DeviceDetailsDAOImpl;
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAO;
import org.wso2.carbon.device.mgt.core.privacy.dao.impl.PrivacyComplianceDAOImpl;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.Connection; import java.sql.Connection;
@ -151,6 +153,10 @@ public class DeviceManagementDAOFactory {
return new DeviceDetailsDAOImpl(); return new DeviceDetailsDAOImpl();
} }
public static PrivacyComplianceDAO getPrivacyComplianceDAO() {
return new PrivacyComplianceDAOImpl();
}
public static void init(DataSourceConfig config) { public static void init(DataSourceConfig config) {
dataSource = resolveDataSource(config); dataSource = resolveDataSource(config);
try { try {

@ -152,8 +152,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " + stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " + "LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM " +
"AND TENANT_ID = ?"); "DM_APPLICATION WHERE APP_IDENTIFIER = ? AND TENANT_ID = ?");
stmt.setString(1, identifier); stmt.setString(1, identifier);
stmt.setInt(2, tenantId); stmt.setInt(2, tenantId);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
@ -171,7 +171,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
} }
@Override @Override
public Application getApplication(String identifier, String version, int tenantId) throws DeviceManagementDAOException { public Application getApplication(String identifier, String version, int tenantId)
throws DeviceManagementDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
@ -179,8 +180,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " + stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " + "LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM " +
"AND VERSION = ? AND TENANT_ID = ?"); "DM_APPLICATION WHERE APP_IDENTIFIER = ? AND VERSION = ? AND TENANT_ID = ?");
stmt.setString(1, identifier); stmt.setString(1, identifier);
stmt.setString(2, version); stmt.setString(2, version);
stmt.setInt(3, tenantId); stmt.setInt(3, tenantId);
@ -199,7 +200,8 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
} }
@Override @Override
public Application getApplication(String identifier, String version, int deviceId, int tenantId) throws DeviceManagementDAOException { public Application getApplication(String identifier, String version, int deviceId, int enrolmentId, int tenantId)
throws DeviceManagementDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
@ -208,14 +210,15 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
conn = this.getConnection(); conn = this.getConnection();
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " + stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
"LOCATION_URL, IMAGE_URL, appmap.APP_PROPERTIES, appmap.MEMORY_USAGE, appmap.IS_ACTIVE, TENANT_ID " + "LOCATION_URL, IMAGE_URL, appmap.APP_PROPERTIES, appmap.MEMORY_USAGE, appmap.IS_ACTIVE, TENANT_ID " +
"FROM DM_APPLICATION app INNER JOIN " + "FROM DM_APPLICATION app INNER JOIN (SELECT APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, " +
"(SELECT APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE FROM DM_DEVICE_APPLICATION_MAPPING W" + "IS_ACTIVE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?) appmap " +
"HERE DEVICE_ID = ?) appmap WHERE app.APP_IDENTIFIER = ? AND app.VERSION = ? AND " + "WHERE app.APP_IDENTIFIER = ? AND app.VERSION = ? AND " +
"appmap.APPLICATION_ID = app.id AND TENANT_ID = ?"); "appmap.APPLICATION_ID = app.id AND TENANT_ID = ?");
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setString(2, identifier); stmt.setInt(2, enrolmentId);
stmt.setString(3, version); stmt.setString(3, identifier);
stmt.setInt(4, tenantId); stmt.setString(4, version);
stmt.setInt(5, tenantId);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
if (rs.next()) { if (rs.next()) {
@ -235,7 +238,7 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
} }
@Override @Override
public List<Application> getInstalledApplications(int deviceId) throws DeviceManagementDAOException { public List<Application> getInstalledApplications(int deviceId, int enrolmentId) throws DeviceManagementDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
List<Application> applications = new ArrayList<>(); List<Application> applications = new ArrayList<>();
@ -247,11 +250,12 @@ public abstract class AbstractApplicationDAOImpl implements ApplicationDAO {
"LOCATION_URL, IMAGE_URL, APPMAP.APP_PROPERTIES, APPMAP.MEMORY_USAGE, APPMAP.IS_ACTIVE, " + "LOCATION_URL, IMAGE_URL, APPMAP.APP_PROPERTIES, APPMAP.MEMORY_USAGE, APPMAP.IS_ACTIVE, " +
"TENANT_ID From DM_APPLICATION app INNER JOIN " + "TENANT_ID From DM_APPLICATION app INNER JOIN " +
"(Select APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE" + "(Select APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE" +
" From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " + " From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=? AND ENROLMENT_ID = ?) APPMAP " +
"ON " + "ON " +
"app.ID = APPMAP.APPLICATION_ID "); "app.ID = APPMAP.APPLICATION_ID ");
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
while (rs.next()) { while (rs.next()) {

@ -97,7 +97,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
} }
@Override @Override
public void addApplicationMappingsWithApps(int deviceId, List<Application> applications, int tenantId) public void addApplicationMappingsWithApps(int deviceId, int enrolmentId, List<Application> applications, int tenantId)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
Connection conn; Connection conn;
@ -108,25 +108,26 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, APPLICATION_ID, APP_PROPERTIES, " + String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, ENROLMENT_ID, APPLICATION_ID, " +
"MEMORY_USAGE, IS_ACTIVE, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?)"; "APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?, ?)";
conn.setAutoCommit(false); conn.setAutoCommit(false);
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
for (Application application : applications) { for (Application application : applications) {
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, application.getId()); stmt.setInt(2, enrolmentId);
stmt.setInt(3, application.getId());
bao = new ByteArrayOutputStream(); bao = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bao); oos = new ObjectOutputStream(bao);
oos.writeObject(application.getAppProperties()); oos.writeObject(application.getAppProperties());
stmt.setBytes(3, bao.toByteArray()); stmt.setBytes(4, bao.toByteArray());
stmt.setInt(4, application.getMemoryUsage()); stmt.setInt(5, application.getMemoryUsage());
stmt.setBoolean(5, application.isActive()); stmt.setBoolean(6, application.isActive());
stmt.setInt(6, tenantId); stmt.setInt(7, tenantId);
stmt.addBatch(); stmt.addBatch();
} }
stmt.executeBatch(); stmt.executeBatch();
@ -155,13 +156,13 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
} }
@Override @Override
public void removeApplicationMapping(int deviceId, List<Integer> appIdList, public void removeApplicationMapping(int deviceId, int enrolmentId, List<Integer> appIdList,
int tenantId) throws DeviceManagementDAOException { int tenantId) throws DeviceManagementDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? AND " + String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? AND " +
"APPLICATION_ID = ? AND TENANT_ID = ?"; "APPLICATION_ID = ? AND TENANT_ID = ? AND ENROLMENT_ID = ?";
conn = this.getConnection(); conn = this.getConnection();
for (int appId : appIdList) { for (int appId : appIdList) {
@ -169,6 +170,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, appId); stmt.setInt(2, appId);
stmt.setInt(3, tenantId); stmt.setInt(3, tenantId);
stmt.setInt(4, enrolmentId);
stmt.execute(); stmt.execute();
} }
} catch (SQLException e) { } catch (SQLException e) {

@ -38,14 +38,15 @@ public interface DeviceDetailsDAO {
* @param deviceInfo - Device information object. * @param deviceInfo - Device information object.
* @throws DeviceDetailsMgtDAOException * @throws DeviceDetailsMgtDAOException
*/ */
void addDeviceInformation(int deviceId, DeviceInfo deviceInfo) throws DeviceDetailsMgtDAOException; void addDeviceInformation(int deviceId, int enrolmentId, DeviceInfo deviceInfo) throws DeviceDetailsMgtDAOException;
/** /**
* This method will add the device properties to the database. * This method will add the device properties to the database.
* @param propertyMap - device properties. * @param propertyMap - device properties.
* @throws DeviceDetailsMgtDAOException * @throws DeviceDetailsMgtDAOException
*/ */
void addDeviceProperties(Map<String, String> propertyMap, int deviceId) throws DeviceDetailsMgtDAOException; void addDeviceProperties(Map<String, String> propertyMap, int deviceId, int enrolmentId)
throws DeviceDetailsMgtDAOException;
/** /**
* This method will return the device information when device id is provided. * This method will return the device information when device id is provided.
@ -53,7 +54,7 @@ public interface DeviceDetailsDAO {
* @return DeviceInfo * @return DeviceInfo
* @throws DeviceDetailsMgtDAOException * @throws DeviceDetailsMgtDAOException
*/ */
DeviceInfo getDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException; DeviceInfo getDeviceInformation(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException;
/** /**
* This method will return the device properties from database. * This method will return the device properties from database.
@ -61,28 +62,28 @@ public interface DeviceDetailsDAO {
* @return - device properties map. * @return - device properties map.
* @throws DeviceDetailsMgtDAOException * @throws DeviceDetailsMgtDAOException
*/ */
Map<String, String> getDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException; Map<String, String> getDeviceProperties(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException;
/** /**
* This method will delete the device information from the database. * This method will delete the device information from the database.
* @param deviceId - Integer. * @param deviceId - Integer.
* @throws DeviceDetailsMgtDAOException * @throws DeviceDetailsMgtDAOException
*/ */
void deleteDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException; void deleteDeviceInformation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
/** /**
* This method will delete the device properties from database. * This method will delete the device properties from database.
* @param deviceId - Integer. * @param deviceId - Integer.
* @throws DeviceDetailsMgtDAOException * @throws DeviceDetailsMgtDAOException
*/ */
void deleteDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException; void deleteDeviceProperties(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
/** /**
* This method will add device location to database. * This method will add device location to database.
* @param deviceLocation - Device location with latitude and longitude. * @param deviceLocation - Device location with latitude and longitude.
* @throws DeviceDetailsMgtDAOException * @throws DeviceDetailsMgtDAOException
*/ */
void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtDAOException; void addDeviceLocation(DeviceLocation deviceLocation, int enrollmentId) throws DeviceDetailsMgtDAOException;
/** /**
* This method will return the device location object when the device id is provided. * This method will return the device location object when the device id is provided.
@ -90,14 +91,14 @@ public interface DeviceDetailsDAO {
* @return - Device location object. * @return - Device location object.
* @throws DeviceDetailsMgtDAOException * @throws DeviceDetailsMgtDAOException
*/ */
DeviceLocation getDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException; DeviceLocation getDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
/** /**
* This method will delete the device location from the database. * This method will delete the device location from the database.
* @param deviceId * @param deviceId
* @throws DeviceDetailsMgtDAOException * @throws DeviceDetailsMgtDAOException
*/ */
void deleteDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException; void deleteDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException;
// /** // /**
// * This method will add device application to database. // * This method will add device application to database.

@ -41,7 +41,8 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
private static Log log = LogFactory.getLog(DeviceDetailsDAOImpl.class); private static Log log = LogFactory.getLog(DeviceDetailsDAOImpl.class);
@Override @Override
public void addDeviceInformation(int deviceId, DeviceInfo deviceInfo) throws DeviceDetailsMgtDAOException { public void addDeviceInformation(int deviceId, int enrolmentId, DeviceInfo deviceInfo)
throws DeviceDetailsMgtDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -51,8 +52,8 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_DETAIL (DEVICE_ID, DEVICE_MODEL, " + stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_DETAIL (DEVICE_ID, DEVICE_MODEL, " +
"VENDOR, OS_VERSION, OS_BUILD_DATE, BATTERY_LEVEL, INTERNAL_TOTAL_MEMORY, INTERNAL_AVAILABLE_MEMORY, " + "VENDOR, OS_VERSION, OS_BUILD_DATE, BATTERY_LEVEL, INTERNAL_TOTAL_MEMORY, INTERNAL_AVAILABLE_MEMORY, " +
"EXTERNAL_TOTAL_MEMORY, EXTERNAL_AVAILABLE_MEMORY, CONNECTION_TYPE, " + "EXTERNAL_TOTAL_MEMORY, EXTERNAL_AVAILABLE_MEMORY, CONNECTION_TYPE, " +
"SSID, CPU_USAGE, TOTAL_RAM_MEMORY, AVAILABLE_RAM_MEMORY, PLUGGED_IN, UPDATE_TIMESTAMP) " + "SSID, CPU_USAGE, TOTAL_RAM_MEMORY, AVAILABLE_RAM_MEMORY, PLUGGED_IN, UPDATE_TIMESTAMP, ENROLMENT_ID) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setString(2, deviceInfo.getDeviceModel()); stmt.setString(2, deviceInfo.getDeviceModel());
@ -71,6 +72,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
stmt.setDouble(15, deviceInfo.getAvailableRAMMemory()); stmt.setDouble(15, deviceInfo.getAvailableRAMMemory());
stmt.setBoolean(16, deviceInfo.isPluggedIn()); stmt.setBoolean(16, deviceInfo.isPluggedIn());
stmt.setLong(17, System.currentTimeMillis()); stmt.setLong(17, System.currentTimeMillis());
stmt.setInt(18, enrolmentId);
stmt.execute(); stmt.execute();
@ -83,7 +85,8 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
} }
@Override @Override
public void addDeviceProperties(Map<String, String> propertyMap, int deviceId) throws DeviceDetailsMgtDAOException { public void addDeviceProperties(Map<String, String> propertyMap, int deviceId, int enrolmentId)
throws DeviceDetailsMgtDAOException {
if (propertyMap.isEmpty()) { if (propertyMap.isEmpty()) {
if(log.isDebugEnabled()) { if(log.isDebugEnabled()) {
@ -95,12 +98,14 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_INFO (DEVICE_ID, KEY_FIELD, VALUE_FIELD) VALUES (?, ?, ?)"); stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_INFO (DEVICE_ID, KEY_FIELD, VALUE_FIELD, ENROLMENT_ID) " +
"VALUES (?, ?, ?, ?)");
for (Map.Entry<String, String> entry : propertyMap.entrySet()) { for (Map.Entry<String, String> entry : propertyMap.entrySet()) {
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setString(2, entry.getKey()); stmt.setString(2, entry.getKey());
stmt.setString(3, entry.getValue()); stmt.setString(3, entry.getValue());
stmt.setInt(4, enrolmentId);
stmt.addBatch(); stmt.addBatch();
} }
stmt.executeBatch(); stmt.executeBatch();
@ -113,7 +118,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
} }
@Override @Override
public DeviceInfo getDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException { public DeviceInfo getDeviceInformation(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
@ -121,9 +126,10 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String sql = "SELECT * FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ?"; String sql = "SELECT * FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
if (rs.next()) { if (rs.next()) {
@ -159,7 +165,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
} }
@Override @Override
public Map<String, String> getDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException { public Map<String, String> getDeviceProperties(int deviceId, int enrolmentId) throws DeviceDetailsMgtDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -167,9 +173,10 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String sql = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID = ?"; String sql = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
while (rs.next()) { while (rs.next()) {
@ -184,15 +191,16 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
} }
@Override @Override
public void deleteDeviceInformation(int deviceId) throws DeviceDetailsMgtDAOException { public void deleteDeviceInformation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ?"; String query = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, enrollmentId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
@ -203,15 +211,16 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
} }
@Override @Override
public void deleteDeviceProperties(int deviceId) throws DeviceDetailsMgtDAOException { public void deleteDeviceProperties(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ?"; String query = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, enrollmentId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
@ -222,14 +231,15 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
} }
@Override @Override
public void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtDAOException { public void addDeviceLocation(DeviceLocation deviceLocation, int enrollmentId) throws DeviceDetailsMgtDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_LOCATION (DEVICE_ID, LATITUDE, LONGITUDE, STREET1, " + stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_LOCATION (DEVICE_ID, LATITUDE, LONGITUDE, STREET1, " +
"STREET2, CITY, ZIP, STATE, COUNTRY, GEO_HASH, UPDATE_TIMESTAMP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"); "STREET2, CITY, ZIP, STATE, COUNTRY, GEO_HASH, UPDATE_TIMESTAMP, ENROLMENT_ID) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
stmt.setInt(1, deviceLocation.getDeviceId()); stmt.setInt(1, deviceLocation.getDeviceId());
stmt.setDouble(2, deviceLocation.getLatitude()); stmt.setDouble(2, deviceLocation.getLatitude());
stmt.setDouble(3, deviceLocation.getLongitude()); stmt.setDouble(3, deviceLocation.getLongitude());
@ -241,6 +251,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
stmt.setString(9, deviceLocation.getCountry()); stmt.setString(9, deviceLocation.getCountry());
stmt.setString(10, GeoHashGenerator.encodeGeohash(deviceLocation)); stmt.setString(10, GeoHashGenerator.encodeGeohash(deviceLocation));
stmt.setLong(11, System.currentTimeMillis()); stmt.setLong(11, System.currentTimeMillis());
stmt.setInt(12, enrollmentId);
stmt.execute(); stmt.execute();
} catch (SQLException e) { } catch (SQLException e) {
throw new DeviceDetailsMgtDAOException("Error occurred while adding the device location to database.", e); throw new DeviceDetailsMgtDAOException("Error occurred while adding the device location to database.", e);
@ -250,7 +261,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
} }
@Override @Override
public DeviceLocation getDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException { public DeviceLocation getDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -258,9 +269,10 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
DeviceLocation location = new DeviceLocation(); DeviceLocation location = new DeviceLocation();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String sql = "SELECT * FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ?"; String sql = "SELECT * FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, enrollmentId);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
while (rs.next()) { while (rs.next()) {
@ -286,15 +298,16 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
} }
@Override @Override
public void deleteDeviceLocation(int deviceId) throws DeviceDetailsMgtDAOException { public void deleteDeviceLocation(int deviceId, int enrollmentId) throws DeviceDetailsMgtDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ?"; String query = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, enrollmentId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {

@ -68,12 +68,14 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
DeviceManagementDAOFactory.beginTransaction(); DeviceManagementDAOFactory.beginTransaction();
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId()); deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
deviceDetailsDAO.deleteDeviceInformation(device.getId()); deviceDetailsDAO.deleteDeviceInformation(device.getId(), device.getEnrolmentInfo().getId());
deviceDetailsDAO.deleteDeviceProperties(device.getId()); deviceDetailsDAO.deleteDeviceProperties(device.getId(), device.getEnrolmentInfo().getId());
deviceDetailsDAO.addDeviceInformation(device.getId(), deviceInfo); deviceDetailsDAO.addDeviceInformation(device.getId(), device.getEnrolmentInfo().getId(), deviceInfo);
deviceDetailsDAO.addDeviceProperties(deviceInfo.getDeviceDetailsMap(), device.getId()); deviceDetailsDAO.addDeviceProperties(deviceInfo.getDeviceDetailsMap(), device.getId(),
device.getEnrolmentInfo().getId());
DeviceManagementDAOFactory.commitTransaction(); DeviceManagementDAOFactory.commitTransaction();
//TODO :: This has to be fixed by adding the enrollment ID.
if (DeviceManagerUtil.isPublishDeviceInfoResponseEnabled()) { if (DeviceManagerUtil.isPublishDeviceInfoResponseEnabled()) {
Object[] metaData = {device.getDeviceIdentifier(), device.getType()}; Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
Object[] payload = new Object[]{ Object[] payload = new Object[]{
@ -131,8 +133,10 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
} }
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(device.getId()); DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(device.getId(),
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(device.getId())); device.getEnrolmentInfo().getId());
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(device.getId(),
device.getEnrolmentInfo().getId()));
return deviceInfo; return deviceInfo;
} catch (SQLException e) { } catch (SQLException e) {
@ -154,19 +158,21 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
identifierMap.put(identifier.getId(), identifier); identifierMap.put(identifier.getId(), identifier);
} }
try { try {
List<Integer> deviceIds = new ArrayList<>(); List<Device> deviceIds = new ArrayList<>();
List<Device> devices = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider(). List<Device> devices = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().
getAllDevices(false); getAllDevices(false);
for (Device device : devices) { for (Device device : devices) {
if (identifierMap.containsKey(device.getDeviceIdentifier()) && if (identifierMap.containsKey(device.getDeviceIdentifier()) &&
device.getType().equals(identifierMap.get(device.getDeviceIdentifier()).getType())) { device.getType().equals(identifierMap.get(device.getDeviceIdentifier()).getType())) {
deviceIds.add(device.getId()); deviceIds.add(device);
} }
} }
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
for (Integer id : deviceIds) { for (Device device : deviceIds) {
DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(id); DeviceInfo deviceInfo = deviceDetailsDAO.getDeviceInformation(device.getId(),
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(id)); device.getEnrolmentInfo().getId());
deviceInfo.setDeviceDetailsMap(deviceDetailsDAO.getDeviceProperties(device.getId(),
device.getEnrolmentInfo().getId()));
deviceInfos.add(deviceInfo); deviceInfos.add(deviceInfo);
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -190,8 +196,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
deviceLocation.setDeviceId(device.getId()); deviceLocation.setDeviceId(device.getId());
DeviceManagementDAOFactory.beginTransaction(); DeviceManagementDAOFactory.beginTransaction();
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId()); deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
deviceDetailsDAO.deleteDeviceLocation(deviceLocation.getDeviceId()); deviceDetailsDAO.deleteDeviceLocation(deviceLocation.getDeviceId(), device.getEnrolmentInfo().getId());
deviceDetailsDAO.addDeviceLocation(deviceLocation); deviceDetailsDAO.addDeviceLocation(deviceLocation, device.getEnrolmentInfo().getId());
//TODO: This has to be fixed with enrollment id or username should include in the stream def.
if (DeviceManagerUtil.isPublishLocationResponseEnabled()) { if (DeviceManagerUtil.isPublishLocationResponseEnabled()) {
Object[] metaData = {device.getDeviceIdentifier(), device.getType()}; Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
Object[] payload = new Object[]{ Object[] payload = new Object[]{
@ -233,7 +240,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
} }
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
return deviceDetailsDAO.getDeviceLocation(device.getId()); return deviceDetailsDAO.getDeviceLocation(device.getId(), device.getEnrolmentInfo().getId());
} catch (SQLException e) { } catch (SQLException e) {
throw new DeviceDetailsMgtException("SQL error occurred while retrieving device from database.", e); throw new DeviceDetailsMgtException("SQL error occurred while retrieving device from database.", e);
} catch (DeviceDetailsMgtDAOException e) { } catch (DeviceDetailsMgtDAOException e) {
@ -270,7 +277,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
List<DeviceLocation> deviceLocations = new ArrayList<>(); List<DeviceLocation> deviceLocations = new ArrayList<>();
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
for (Device device : devices) { for (Device device : devices) {
deviceLocations.add(deviceDetailsDAO.getDeviceLocation(device.getId())); deviceLocations.add(deviceDetailsDAO.getDeviceLocation(device.getId(),
device.getEnrolmentInfo().getId()));
} }
return deviceLocations; return deviceLocations;
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {

@ -41,8 +41,10 @@ import org.wso2.carbon.device.mgt.common.geo.service.Alert;
import org.wso2.carbon.device.mgt.common.geo.service.GeoFence; import org.wso2.carbon.device.mgt.common.geo.service.GeoFence;
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService;
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException;
import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub; import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub;
import org.wso2.carbon.event.processor.stub.types.ExecutionPlanConfigurationDto;
import org.wso2.carbon.identity.jwt.client.extension.JWTClient; import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
@ -207,18 +209,18 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
@Override @Override
public boolean createGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType) public boolean createGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
throws GeoLocationBasedServiceException { throws GeoLocationBasedServiceException, AlertAlreadyExistException {
return saveGeoAlert(alert, identifier, alertType, false); return saveGeoAlert(alert, identifier, alertType, false);
} }
@Override @Override
public boolean updateGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType) public boolean updateGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType)
throws GeoLocationBasedServiceException { throws GeoLocationBasedServiceException, AlertAlreadyExistException {
return saveGeoAlert(alert, identifier, alertType, true); return saveGeoAlert(alert, identifier, alertType, true);
} }
public boolean saveGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType, boolean isUpdate) public boolean saveGeoAlert(Alert alert, DeviceIdentifier identifier, String alertType, boolean isUpdate)
throws GeoLocationBasedServiceException { throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Type type = new TypeToken<Map<String, String>>() { Type type = new TypeToken<Map<String, String>>() {
}.getType(); }.getType();
@ -260,23 +262,38 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
"Unrecognized execution plan type: " + alertType + " while creating geo alert"); "Unrecognized execution plan type: " + alertType + " while creating geo alert");
} }
//persist alert in registry
updateRegistry(getRegistryPath(alertType, identifier, alert.getQueryName()), identifier, content,
options);
//deploy alert into event processor //deploy alert into event processor
EventProcessorAdminServiceStub eventprocessorStub = null; EventProcessorAdminServiceStub eventprocessorStub = null;
String action = (isUpdate ? "updating" : "creating"); String action = (isUpdate ? "updating" : "creating");
try { try {
ExecutionPlanConfigurationDto[] allActiveExecutionPlanConfigs = null;
String activeExecutionPlan = null;
String executionPlanName = getExecutionPlanName(alertType, alert.getQueryName(),
identifier.getId());
eventprocessorStub = getEventProcessorAdminServiceStub(); eventprocessorStub = getEventProcessorAdminServiceStub();
String parsedTemplate = parseTemplate(alertType, parseMap); String parsedTemplate = parseTemplate(alertType, parseMap);
String validationResponse = eventprocessorStub.validateExecutionPlan(parsedTemplate); String validationResponse = eventprocessorStub.validateExecutionPlan(parsedTemplate);
if (validationResponse.equals("success")) { if (validationResponse.equals("success")) {
allActiveExecutionPlanConfigs = eventprocessorStub.getAllActiveExecutionPlanConfigurations();
if (isUpdate) { if (isUpdate) {
String executionPlanName = getExecutionPlanName(alertType, alert.getQueryName(), for (ExecutionPlanConfigurationDto activeExectionPlanConfig:allActiveExecutionPlanConfigs) {
identifier.getId()); activeExecutionPlan = activeExectionPlanConfig.getExecutionPlan();
eventprocessorStub.editActiveExecutionPlan(parsedTemplate, executionPlanName); if (activeExecutionPlan.contains(executionPlanName)) {
eventprocessorStub.editActiveExecutionPlan(parsedTemplate, executionPlanName);
return true;
}
}
eventprocessorStub.deployExecutionPlan(parsedTemplate);
} else { } else {
for (ExecutionPlanConfigurationDto activeExectionPlanConfig:allActiveExecutionPlanConfigs) {
activeExecutionPlan = activeExectionPlanConfig.getExecutionPlan();
if (activeExecutionPlan.contains(executionPlanName)) {
throw new AlertAlreadyExistException("Execution plan already exists with name "
+ executionPlanName);
}
}
updateRegistry(getRegistryPath(alertType, identifier, alert.getQueryName()), identifier, content,
options);
eventprocessorStub.deployExecutionPlan(parsedTemplate); eventprocessorStub.deployExecutionPlan(parsedTemplate);
} }
} else { } else {
@ -344,6 +361,8 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
private String getExecutionPlanName(String alertType, String queryName, String deviceId) { private String getExecutionPlanName(String alertType, String queryName, String deviceId) {
if ("Traffic".equals(alertType)) { if ("Traffic".equals(alertType)) {
return "Geo-ExecutionPlan-Traffic_" + queryName + "_alert"; return "Geo-ExecutionPlan-Traffic_" + queryName + "_alert";
} else if ("Speed".equals(alertType)) {
return "Geo-ExecutionPlan-" + alertType + "---" + deviceId + "_alert";
} else { } else {
return "Geo-ExecutionPlan-" + alertType + "_" + queryName + "---_" + deviceId + "_alert"; return "Geo-ExecutionPlan-" + alertType + "_" + queryName + "---_" + deviceId + "_alert";
} }

@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig; import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier;
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository; import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
@ -67,6 +68,7 @@ public class DeviceManagementDataHolder {
private DeviceTaskManagerService deviceTaskManagerService; private DeviceTaskManagerService deviceTaskManagerService;
private DeviceStatusTaskManagerService deviceStatusTaskManagerService; private DeviceStatusTaskManagerService deviceStatusTaskManagerService;
private DeviceTypeGeneratorService deviceTypeGeneratorService; private DeviceTypeGeneratorService deviceTypeGeneratorService;
private PrivacyComplianceProvider privacyComplianceProvider;
private Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = Collections.synchronizedMap( private Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = Collections.synchronizedMap(
new HashMap<DeviceType, DeviceStatusTaskPluginConfig>()); new HashMap<DeviceType, DeviceStatusTaskPluginConfig>());
@ -266,4 +268,12 @@ public class DeviceManagementDataHolder {
DeviceTypeGeneratorService deviceTypeGeneratorService) { DeviceTypeGeneratorService deviceTypeGeneratorService) {
this.deviceTypeGeneratorService = deviceTypeGeneratorService; this.deviceTypeGeneratorService = deviceTypeGeneratorService;
} }
public PrivacyComplianceProvider getPrivacyComplianceProvider() {
return privacyComplianceProvider;
}
public void setPrivacyComplianceProvider(PrivacyComplianceProvider privacyComplianceProvider) {
this.privacyComplianceProvider = privacyComplianceProvider;
}
} }

@ -51,6 +51,8 @@ import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManageme
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
import org.wso2.carbon.device.mgt.core.privacy.impl.PrivacyComplianceProviderImpl;
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository; import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
import org.wso2.carbon.device.mgt.core.push.notification.mgt.task.PushNotificationSchedulerTask; import org.wso2.carbon.device.mgt.core.push.notification.mgt.task.PushNotificationSchedulerTask;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
@ -225,6 +227,12 @@ public class DeviceManagementServiceComponent {
.getPushNotificationConfiguration().getSchedulerTaskInitialDelay(), config .getPushNotificationConfiguration().getSchedulerTaskInitialDelay(), config
.getPushNotificationConfiguration().getSchedulerBatchDelayMills(), TimeUnit.MILLISECONDS); .getPushNotificationConfiguration().getSchedulerBatchDelayMills(), TimeUnit.MILLISECONDS);
} }
PrivacyComplianceProvider privacyComplianceProvider = new PrivacyComplianceProviderImpl();
DeviceManagementDataHolder.getInstance().setPrivacyComplianceProvider(privacyComplianceProvider);
componentContext.getBundleContext().registerService(PrivacyComplianceProvider.class.getName(),
privacyComplianceProvider, null);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device management core bundle has been successfully initialized"); log.debug("Device management core bundle has been successfully initialized");
} }

@ -0,0 +1,32 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.privacy;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.PrivacyComplianceException;
public interface PrivacyComplianceProvider {
void deleteDevicesOfUser(String username) throws PrivacyComplianceException;
void deleteDeviceDetails(DeviceIdentifier deviceIdentifier) throws PrivacyComplianceException;
}

@ -0,0 +1,50 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.privacy.dao;
import org.wso2.carbon.device.mgt.core.privacy.impl.DeviceEnrollmentMapping;
import java.util.List;
public interface PrivacyComplianceDAO {
List<DeviceEnrollmentMapping> getDevicesOfUser(String username, int tenantId) throws PrivacyComplianceDAOException;
void deleteDevice(int deviceId, int tenantId) throws PrivacyComplianceDAOException;
void deleteDeviceEnrollments(int deviceId, int tenantId) throws PrivacyComplianceDAOException;
void deleteDeviceEnrollments(int deviceId, int enrolmentId, int tenantId) throws PrivacyComplianceDAOException;
void deleteDeviceDetails(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException;
void deleteDeviceApplications(int deviceId, int enrolmentId, int tenantId) throws PrivacyComplianceDAOException;
void deleteDeviceProperties(int deviceId, int enrolmentId, int tenantId) throws PrivacyComplianceDAOException;
void deleteDeviceLocation(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException;
void updateDeviceOperationResponses(int enrolmentId) throws PrivacyComplianceDAOException;
void deleteDeviceOperationDetails(int enrolmentId) throws PrivacyComplianceDAOException;
void deleteOperationEnrolmentMappings(int enrolmentId) throws PrivacyComplianceDAOException;
}

@ -0,0 +1,46 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.privacy.dao;
public class PrivacyComplianceDAOException extends Exception {
private static final long serialVersionUID = -3127931192903344297L;
public PrivacyComplianceDAOException(String msg, Exception nestedEx) {
super(msg, nestedEx);
}
public PrivacyComplianceDAOException(String message, Throwable cause) {
super(message, cause);
}
public PrivacyComplianceDAOException(String msg) {
super(msg);
}
public PrivacyComplianceDAOException() {
super();
}
public PrivacyComplianceDAOException(Throwable cause) {
super(cause);
}
}

@ -0,0 +1,280 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.privacy.dao.impl;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAO;
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAOException;
import org.wso2.carbon.device.mgt.core.privacy.impl.DeviceEnrollmentMapping;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class PrivacyComplianceDAOImpl implements PrivacyComplianceDAO {
@Override
public List<DeviceEnrollmentMapping> getDevicesOfUser(String username, int tenantId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
List<DeviceEnrollmentMapping> deviceIds = new ArrayList<>();
try {
conn = this.getConnection();
String sql = "SELECT * FROM DM_ENROLMENT WHERE OWNER = ? AND TENANT_ID = ? ORDER BY DEVICE_ID";
stmt = conn.prepareStatement(sql);
stmt.setString(1, username);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
while (rs.next()) {
DeviceEnrollmentMapping mapping = new DeviceEnrollmentMapping();
mapping.setDeviceId(rs.getInt("DEVICE_ID"));
mapping.setEnrolmentId(rs.getInt("ENROLMENT_ID"));
deviceIds.add(mapping);
}
if (deviceIds.isEmpty()) {
return null;
}
return deviceIds;
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while retrieving device ids " +
"related to the given user.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
}
@Override
public void deleteDevice(int deviceId, int tenantId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE WHERE ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the devices", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceEnrollments(int deviceId, int tenantId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device enrolments", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceEnrollments(int deviceId, int enrolmentId, int tenantId)
throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
stmt.setInt(3, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device enrolments", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceDetails(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device details.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceApplications(int deviceId, int enrolmentId, int tenantId)
throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? " +
"AND ENROLMENT_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
stmt.setInt(3, tenantId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device applications.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceProperties(int deviceId, int enrolmentId, int tenantId)
throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceLocation(int deviceId, int enrolmentId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ? AND ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device location.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void updateDeviceOperationResponses(int enrolmentId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "UPDATE DM_DEVICE_OPERATION_RESPONSE SET OPERATION_RESPONSE = ? WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setNull(1, java.sql.Types.BLOB);
stmt.setInt(2, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteDeviceOperationDetails(int enrolmentId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void deleteOperationEnrolmentMappings(int enrolmentId) throws PrivacyComplianceDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "DELETE FROM DM_ENROLMENT_OP_MAPPING WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, enrolmentId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new PrivacyComplianceDAOException("Error occurred while deleting the device information.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private Connection getConnection() throws SQLException {
return DeviceManagementDAOFactory.getConnection();
}
}

@ -0,0 +1,63 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.privacy.impl;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
public class DeviceEnrollmentMapping {
private int deviceId;
private int enrolmentId;
private DeviceIdentifier deviceIdentifier;
private int tenantId;
public int getDeviceId() {
return deviceId;
}
public void setDeviceId(int deviceId) {
this.deviceId = deviceId;
}
public int getEnrolmentId() {
return enrolmentId;
}
public void setEnrolmentId(int enrolmentId) {
this.enrolmentId = enrolmentId;
}
public DeviceIdentifier getDeviceIdentifier() {
return deviceIdentifier;
}
public void setDeviceIdentifier(DeviceIdentifier deviceIdentifier) {
this.deviceIdentifier = deviceIdentifier;
}
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
}

@ -0,0 +1,146 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.privacy.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.PrivacyComplianceException;
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider;
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAO;
import org.wso2.carbon.device.mgt.core.privacy.dao.PrivacyComplianceDAOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PrivacyComplianceProviderImpl implements PrivacyComplianceProvider {
private static final Log log = LogFactory.getLog(PrivacyComplianceProviderImpl.class);
PrivacyComplianceDAO complianceDAO;
public PrivacyComplianceProviderImpl() {
complianceDAO = DeviceManagementDAOFactory.getPrivacyComplianceDAO();
}
@Override
public void deleteDevicesOfUser(String username) throws PrivacyComplianceException {
if (log.isDebugEnabled()) {
log.debug("Deleting the requested users.");
}
try {
DeviceManagementDAOFactory.beginTransaction();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
List<DeviceEnrollmentMapping> enrollmentMappings = complianceDAO.getDevicesOfUser(username, tenantId);
Map<Integer, List<Integer>> deviceMap = new HashMap<>();
int x = -1;
for (DeviceEnrollmentMapping m : enrollmentMappings) {
if (m.getDeviceId() != x) {
x = m.getDeviceId();
List<Integer> enrolments = new ArrayList<>();
enrolments.add(m.getEnrolmentId());
deviceMap.put(m.getDeviceId(), enrolments);
} else {
deviceMap.get(m.getDeviceId()).add(m.getEnrolmentId());
}
}
for (int deviceId : deviceMap.keySet()) {
List<Integer> enrollmentIds = deviceMap.get(deviceId);
for (Integer enrolmentId : enrollmentIds) {
complianceDAO.deleteDeviceOperationDetails(enrolmentId);
complianceDAO.deleteOperationEnrolmentMappings(enrolmentId);
complianceDAO.deleteDeviceApplications(deviceId, enrolmentId, tenantId);
complianceDAO.deleteDeviceDetails(deviceId, enrolmentId);
complianceDAO.deleteDeviceProperties(deviceId, enrolmentId, tenantId);
complianceDAO.deleteDeviceLocation(deviceId, enrolmentId);
complianceDAO.deleteDeviceEnrollments(deviceId, enrolmentId);
}
complianceDAO.deleteDevice(deviceId, tenantId);
}
DeviceManagementDAOFactory.commitTransaction();
} catch (PrivacyComplianceDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while deleting the devices and details of the given user";
log.error(msg, e);
throw new PrivacyComplianceException(msg, e);
} catch (TransactionManagementException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Database error occurred while deleting the devices and details of the given user";
log.error(msg, e);
throw new PrivacyComplianceException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
log.info("Requested users device has been successfully removed..!");
}
@Override
public void deleteDeviceDetails(DeviceIdentifier deviceIdentifier) throws PrivacyComplianceException {
if (log.isDebugEnabled()) {
log.debug("Deleting the requested device details.");
}
try {
Device device = this.getDevice(deviceIdentifier);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceManagementDAOFactory.beginTransaction();
complianceDAO.deleteDeviceOperationDetails(device.getEnrolmentInfo().getId());
complianceDAO.deleteOperationEnrolmentMappings(device.getEnrolmentInfo().getId());
complianceDAO.deleteDeviceApplications(device.getId(), device.getEnrolmentInfo().getId(), tenantId);
complianceDAO.deleteDeviceDetails(device.getId(), device.getEnrolmentInfo().getId());
complianceDAO.deleteDeviceProperties(device.getId(), device.getEnrolmentInfo().getId(), tenantId);
complianceDAO.deleteDeviceLocation(device.getId(), device.getEnrolmentInfo().getId());
DeviceManagementDAOFactory.commitTransaction();
} catch (TransactionManagementException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Database error occurred while deleting the device details.";
log.error(msg, e);
throw new PrivacyComplianceException(msg, e);
} catch (PrivacyComplianceDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while deleting the device details.";
log.error(msg, e);
throw new PrivacyComplianceException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
}
private Device getDevice(DeviceIdentifier deviceId) throws PrivacyComplianceException {
try {
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId, false);
} catch (DeviceManagementException e) {
throw new PrivacyComplianceException(
"Error occurred while retrieving device info.", e);
}
}
}

@ -236,7 +236,8 @@ public class ProcessorImpl implements Processor {
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
for (Device device : devices) { for (Device device : devices) {
device.setApplications(applicationDAO.getInstalledApplications(device.getId())); device.setApplications(applicationDAO.getInstalledApplications(device.getId(),
device.getEnrolmentInfo().getId()));
} }
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
throw new SearchMgtException("Error occurred while fetching the Application List of devices ", e); throw new SearchMgtException("Error occurred while fetching the Application List of devices ", e);

@ -2475,8 +2475,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
DeviceInfo info = null; DeviceInfo info = null;
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
info = deviceInfoDAO.getDeviceInformation(device.getId()); info = deviceInfoDAO.getDeviceInformation(device.getId(), device.getEnrolmentInfo().getId());
DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId()); DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId(),
device.getEnrolmentInfo().getId());
if (location != null) { if (location != null) {
//There are some cases where the device-info is not updated properly. Hence returning a null value. //There are some cases where the device-info is not updated properly. Hence returning a null value.
if (info != null) { if (info != null) {
@ -2507,23 +2508,28 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
/** /**
* Returns all the installed apps of the given device. * Returns all the installed apps of the given device.
*/ */
private List<Application> getInstalledApplications(Device device) { private List<Application> getInstalledApplications(Device device) throws DeviceManagementException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Get installed applications of device: " + device.getId() + " of type '" + device.getType() + "'"); log.debug("Get installed applications of device: " + device.getId() + " of type '" + device.getType() + "'");
} }
List<Application> applications = new ArrayList<>(); List<Application> applications = new ArrayList<>();
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
applications = applicationDAO.getInstalledApplications(device.getId()); applications = applicationDAO.getInstalledApplications(device.getId(), device.getEnrolmentInfo().getId());
device.setApplications(applications); device.setApplications(applications);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
log.error("Error occurred while retrieving the application list of '" + device.getType() + "', " + String msg = "Error occurred while retrieving the application list of '" + device.getType() + "', " +
"which carries the id '" + device.getId() + "'", e); "which carries the id '" + device.getId() + "'";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
log.error("Error occurred while opening a connection to the data source", e); String msg = "Error occurred while opening a connection to the data source";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (Exception e) { } catch (Exception e) {
String msg = "Error occurred in getInstalledApplications"; String msg = "Error occurred in getInstalledApplications";
log.error(msg, e); log.error(msg, e);
throw new DeviceManagementException(msg, e);
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }

@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.core.geo.service; package org.wso2.carbon.device.mgt.core.geo.service;
import org.apache.axis2.AxisFault;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.testng.Assert; import org.testng.Assert;
@ -31,11 +32,13 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.geo.service.Alert; import org.wso2.carbon.device.mgt.common.geo.service.Alert;
import org.wso2.carbon.device.mgt.common.geo.service.GeoFence; import org.wso2.carbon.device.mgt.common.geo.service.GeoFence;
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException;
import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException;
import org.wso2.carbon.device.mgt.core.TestDeviceManagementService; import org.wso2.carbon.device.mgt.core.TestDeviceManagementService;
import org.wso2.carbon.device.mgt.core.common.TestDataHolder; import org.wso2.carbon.device.mgt.core.common.TestDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub; import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub;
import org.wso2.carbon.event.processor.stub.types.ExecutionPlanConfigurationDto;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
@ -57,6 +60,7 @@ public class GeoLocationProviderServiceTest {
private EventProcessorAdminServiceStub mockEventProcessorAdminServiceStub; private EventProcessorAdminServiceStub mockEventProcessorAdminServiceStub;
private GeoLocationProviderServiceImpl geoLocationProviderServiceImpl; private GeoLocationProviderServiceImpl geoLocationProviderServiceImpl;
private ExecutionPlanConfigurationDto[] mockExecutionPlanConfigurationDto = new ExecutionPlanConfigurationDto[1];
@BeforeClass @BeforeClass
public void init() throws Exception { public void init() throws Exception {
@ -65,42 +69,42 @@ public class GeoLocationProviderServiceTest {
} }
@Test (description = "Create a sample geo exit-alert with relevant details.") @Test (description = "Create a sample geo exit-alert with relevant details.")
public void createGeoExitAlert() throws GeoLocationBasedServiceException { public void createGeoExitAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl. Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getExitAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_EXIT); createGeoAlert(getExitAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_EXIT);
Assert.assertEquals(result, Boolean.TRUE); Assert.assertEquals(result, Boolean.TRUE);
} }
@Test (description = "Create a sample geo within-alert with relevant details.") @Test (description = "Create a sample geo within-alert with relevant details.")
public void createGeoWithinAlert() throws GeoLocationBasedServiceException { public void createGeoWithinAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl. Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getWithinAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_WITHIN); createGeoAlert(getWithinAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_WITHIN);
Assert.assertEquals(result, Boolean.TRUE); Assert.assertEquals(result, Boolean.TRUE);
} }
@Test (description = "Create a sample geo proximity-alert with relevant details.") @Test (description = "Create a sample geo proximity-alert with relevant details.")
public void createGeoProximityAlert() throws GeoLocationBasedServiceException { public void createGeoProximityAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl. Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getProximityAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_PROXIMITY); createGeoAlert(getProximityAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_PROXIMITY);
Assert.assertEquals(result, Boolean.TRUE); Assert.assertEquals(result, Boolean.TRUE);
} }
@Test (description = "Create a sample geo speed-alert with relevant details.") @Test (description = "Create a sample geo speed-alert with relevant details.")
public void createGeoSpeedAlert() throws GeoLocationBasedServiceException { public void createGeoSpeedAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl. Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getSpeedAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_SPEED); createGeoAlert(getSpeedAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_SPEED);
Assert.assertEquals(result, Boolean.TRUE); Assert.assertEquals(result, Boolean.TRUE);
} }
@Test (description = "Create a sample geo stationary-alert with relevant details.") @Test (description = "Create a sample geo stationary-alert with relevant details.")
public void createGeoStationaryAlert() throws GeoLocationBasedServiceException { public void createGeoStationaryAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl. Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getStationaryAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_STATIONARY); createGeoAlert(getStationaryAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_STATIONARY);
Assert.assertEquals(result, Boolean.TRUE); Assert.assertEquals(result, Boolean.TRUE);
} }
@Test (description = "Create a sample geo traffic-alert with relevant details.") @Test (description = "Create a sample geo traffic-alert with relevant details.")
public void createGeoTrafficAlert() throws GeoLocationBasedServiceException { public void createGeoTrafficAlert() throws GeoLocationBasedServiceException, AlertAlreadyExistException {
Boolean result = geoLocationProviderServiceImpl. Boolean result = geoLocationProviderServiceImpl.
createGeoAlert(getTrafficAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_TRAFFIC); createGeoAlert(getTrafficAlert(), getDeviceIdentifier(), DeviceManagementConstants.GeoServices.ALERT_TYPE_TRAFFIC);
Assert.assertEquals(result, Boolean.TRUE); Assert.assertEquals(result, Boolean.TRUE);
@ -139,10 +143,14 @@ public class GeoLocationProviderServiceTest {
private void initMocks() throws JWTClientException, RemoteException { private void initMocks() throws JWTClientException, RemoteException {
mockEventProcessorAdminServiceStub = Mockito.mock(EventProcessorAdminServiceStub.class); mockEventProcessorAdminServiceStub = Mockito.mock(EventProcessorAdminServiceStub.class);
geoLocationProviderServiceImpl = Mockito.mock(GeoLocationProviderServiceImpl.class, Mockito.CALLS_REAL_METHODS); geoLocationProviderServiceImpl = Mockito.mock(GeoLocationProviderServiceImpl.class, Mockito.CALLS_REAL_METHODS);
mockExecutionPlanConfigurationDto[0] = Mockito.mock(ExecutionPlanConfigurationDto.class);
Mockito.doReturn(mockEventProcessorAdminServiceStub). Mockito.doReturn(mockEventProcessorAdminServiceStub).
when(geoLocationProviderServiceImpl).getEventProcessorAdminServiceStub(); when(geoLocationProviderServiceImpl).getEventProcessorAdminServiceStub();
Mockito.doReturn("success"). Mockito.doReturn("success").
when(mockEventProcessorAdminServiceStub).validateExecutionPlan(Mockito.anyString()); when(mockEventProcessorAdminServiceStub).validateExecutionPlan(Mockito.anyString());
Mockito.when(mockEventProcessorAdminServiceStub.getAllActiveExecutionPlanConfigurations()).
thenReturn(mockExecutionPlanConfigurationDto);
Mockito.when(mockExecutionPlanConfigurationDto[0].getExecutionPlan()).thenReturn("EXECUTION_PLAN");
} }
private DeviceIdentifier getDeviceIdentifier() { private DeviceIdentifier getDeviceIdentifier() {

@ -506,7 +506,8 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
//Device details table will be reffered when looking for last updated time //Device details table will be reffered when looking for last updated time
//This dao entry is to mimic a device info operation //This dao entry is to mimic a device info operation
deviceDetailsDAO.addDeviceInformation(initialDevice.getId(), TestDataHolder deviceDetailsDAO.addDeviceInformation(initialDevice.getId(), initialDevice.getEnrolmentInfo().getId(),
TestDataHolder
.generateDummyDeviceInfo()); .generateDummyDeviceInfo());
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();

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

Loading…
Cancel
Save