diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml
index 1fa0ea7543..f3a79a1d98 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml
@@ -22,13 +22,13 @@
apimgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.apimgt.annotations
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTbundleWSO2 Carbon - API Management AnnotationsWSO2 Carbon - API Management Custom Annotation Module
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml
index 18eb04e9da..b4e8b76e8f 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml
@@ -21,12 +21,12 @@
apimgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTorg.wso2.carbon.apimgt.application.extension.apiwarWSO2 Carbon - API Application Management API
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml
index ad8dbd0cbb..400548e774 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml
@@ -22,12 +22,12 @@
apimgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTorg.wso2.carbon.apimgt.application.extensionbundleWSO2 Carbon - API Application Management
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml
index 5af8f8a3d2..f51212966d 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml
@@ -21,13 +21,13 @@
apimgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.apimgt.handlers
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTbundleWSO2 Carbon - API Security Handler ComponentWSO2 Carbon - API Management Security Handler Module
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml
index 07359793a8..79c74feb99 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml
@@ -13,13 +13,13 @@
apimgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.apimgt.integration.client
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTbundleWSO2 Carbon - API Management Integration ClientWSO2 Carbon - API Management Integration Client
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml
index 58e4ec1cc3..6ca2b20d5e 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml
@@ -13,13 +13,13 @@
apimgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.apimgt.integration.generated.client
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTbundleWSO2 Carbon - API Management Integration Generated ClientWSO2 Carbon - API Management Integration Client
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml
index 6b4df465de..432ea5ec56 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml
@@ -22,13 +22,13 @@
apimgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.apimgt.webapp.publisher
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTbundleWSO2 Carbon - API Management Webapp PublisherWSO2 Carbon - API Management Webapp Publisher
diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml
index 723f9e0326..1a82489815 100644
--- a/components/apimgt-extensions/pom.xml
+++ b/components/apimgt-extensions/pom.xml
@@ -22,13 +22,13 @@
org.wso2.carbon.devicemgtcarbon-devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../../pom.xml4.0.0apimgt-extensions
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTpomWSO2 Carbon - API Management Extensions Componenthttp://wso2.org
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml
index 1349821980..163fc9d04a 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml
@@ -5,12 +5,12 @@
application-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT4.0.0org.wso2.carbon.device.application.mgt.addons
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTWSO2 Carbon - Application Management Add-OnsWSO2 Carbon - Application Management Add-Onshttp://wso2.org
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml
index 5ff64e65da..14d1366133 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml
@@ -22,13 +22,13 @@
application-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.device.application.mgt.api
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTwarWSO2 Carbon - Application Management APIWSO2 Carbon - Application Management API
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java
index f6d221792b..816b96c62b 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java
@@ -57,7 +57,7 @@ import javax.ws.rs.core.Response;
public interface ArtifactDownloadAPI {
@GET
- @Path("/{uuid}/{fileName}")
+ @Path("/{uuid}/{folderName}/{fileName}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@ApiOperation(
produces = MediaType.APPLICATION_OCTET_STREAM,
@@ -86,6 +86,11 @@ public interface ArtifactDownloadAPI {
value = "UUID of the application release.",
required = true)
@PathParam("uuid") String uuid,
+ @ApiParam(
+ name = "folderName",
+ value = "Name of the folder where the artifact store.",
+ required = true)
+ @PathParam("folderName") String folderName,
@ApiParam(
name = "fileName",
value = "Name of the artifact",
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java
index 23fd133f59..c603b85161 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java
@@ -47,12 +47,14 @@ public class ArtifactDownloadAPIImpl implements ArtifactDownloadAPI {
@GET
@Override
@Produces(MediaType.APPLICATION_OCTET_STREAM)
- @Path("/{uuid}/{fileName}")
- public Response getArtifact(@PathParam("uuid") String uuid,
+ @Path("/{uuid}/{folderName}/{fileName}")
+ public Response getArtifact(
+ @PathParam("uuid") String uuid,
+ @PathParam("folderName") String folderName,
@PathParam("fileName") String fileName) {
AppmDataHandler dataHandler = APIUtil.getDataHandler();
try {
- InputStream fileInputStream = dataHandler.getArtifactStream(uuid, fileName);
+ InputStream fileInputStream = dataHandler.getArtifactStream(uuid, folderName, fileName);
Response.ResponseBuilder response = Response
.ok(fileInputStream, MediaType.APPLICATION_OCTET_STREAM);
response.status(Response.Status.OK);
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml
index d19e0a6778..6699a9b31e 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml
@@ -21,13 +21,13 @@
org.wso2.carbon.devicemgtapplication-mgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.device.application.mgt.common
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTbundleWSO2 Carbon - Application Management CommonWSO2 Carbon - Application Management Common
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/MDMConfig.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/MDMConfig.java
new file mode 100644
index 0000000000..1f478f8481
--- /dev/null
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/MDMConfig.java
@@ -0,0 +1,40 @@
+/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.application.mgt.common.config;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class MDMConfig {
+
+ private String artifactDownloadProtocol;
+ private String artifactDownloadEndpoint;
+
+ @XmlElement(name = "ArtifactDownloadProtocol", required=true)
+ public String getArtifactDownloadProtocol() { return artifactDownloadProtocol; }
+
+ public void setArtifactDownloadProtocol(String artifactDownloadProtocol) {
+ this.artifactDownloadProtocol = artifactDownloadProtocol;
+ }
+
+ @XmlElement(name = "ArtifactDownloadEndpoint", required=true)
+ public String getArtifactDownloadEndpoint() { return artifactDownloadEndpoint; }
+
+ public void setArtifactDownloadEndpoint(String artifactDownloadEndpoint) {
+ this.artifactDownloadEndpoint = artifactDownloadEndpoint;
+ }
+}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java
index 5e86145584..fd93372178 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java
@@ -72,7 +72,7 @@ public interface ApplicationStorageManager {
*
* @throws ApplicationStorageManagementException Not Found Exception.
*/
- void deleteAppReleaseArtifact(String appReleaseHashVal, String fileName) throws ApplicationStorageManagementException;
+ void deleteAppReleaseArtifact(String appReleaseHashVal, String folderName, String fileName) throws ApplicationStorageManagementException;
/**
* To delete all release artifacts related with particular ApplicationDTO Release.
@@ -84,9 +84,9 @@ public interface ApplicationStorageManager {
/***
* Get the InputStream of the file which is located in filePath
- * @param path file path
+ * @param hashVal Hash Value of the application release.
* @return {@link InputStream}
* @throws ApplicationStorageManagementException throws if an error occurs when accessing the file.
*/
- InputStream getFileSttream(String path) throws ApplicationStorageManagementException;
+ InputStream getFileStream(String hashVal, String folderName, String fileName) throws ApplicationStorageManagementException;
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java
index 960196389a..7e4cb13a82 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java
@@ -35,5 +35,6 @@ public interface AppmDataHandler {
Map getLifecycleConfiguration() throws LifecycleManagementException;
- InputStream getArtifactStream(String uuid, String artifactName) throws ApplicationManagementException;
+ InputStream getArtifactStream(String uuid, String folderName, String artifactName)
+ throws ApplicationManagementException;
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml
index 8cbc2a877c..d3aa277f61 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml
@@ -21,13 +21,13 @@
org.wso2.carbon.devicemgtapplication-mgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.device.application.mgt.core
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTbundleWSO2 Carbon - Application Management CoreWSO2 Carbon - Application Management Core
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/app/Test Android App b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/app/Test Android App
new file mode 100644
index 0000000000..10dfe26209
Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/app/Test Android App differ
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/banner/My First Banner b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/banner/My First Banner
new file mode 100644
index 0000000000..e8c57421c2
Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/banner/My First Banner differ
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/icon/My First Icon b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/icon/My First Icon
new file mode 100644
index 0000000000..df25ec4e45
Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/icon/My First Icon differ
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/screenshot1/shot1 b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/screenshot1/shot1
new file mode 100644
index 0000000000..df25ec4e45
Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/screenshot1/shot1 differ
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/screenshot2/shot3 b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/screenshot2/shot3
new file mode 100644
index 0000000000..df25ec4e45
Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/screenshot2/shot3 differ
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/screenshot3/shot2 b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/screenshot3/shot2
new file mode 100644
index 0000000000..df25ec4e45
Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/repository/resources/apps/d46b34e7ba08f0d45056e77b9c70f528/screenshot3/shot2 differ
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/Configuration.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/Configuration.java
index bc4b706fed..9b395b1a8c 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/Configuration.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/Configuration.java
@@ -18,6 +18,7 @@
*/
package org.wso2.carbon.device.application.mgt.core.config;
+import org.wso2.carbon.device.application.mgt.common.config.MDMConfig;
import org.wso2.carbon.device.application.mgt.common.config.RatingConfiguration;
import org.wso2.carbon.device.application.mgt.common.config.UIConfiguration;
import org.wso2.carbon.device.application.mgt.common.config.LifecycleState;
@@ -37,20 +38,16 @@ public class Configuration {
private List extensions;
- private Artifacts artifacts;
-
- private PaginationConfiguration paginationConfiguration;
-
private List lifecycleStates;
private UIConfiguration uiConfiguration;
private List appCategories;
- private String artifactDownloadEndpoint;
-
private RatingConfiguration ratingConfiguration;
+ private MDMConfig mdmConfig;
+
@XmlElement(name = "DatasourceName", required = true)
public String getDatasourceName() {
return datasourceName;
@@ -70,11 +67,6 @@ public class Configuration {
this.extensions = extensions;
}
- @XmlElement(name = "PaginationConfiguration", required = true)
- public PaginationConfiguration getPaginationConfiguration() {
- return paginationConfiguration;
- }
-
@XmlElementWrapper(name = "LifecycleStates")
@XmlElement(name = "LifecycleState")
public List getLifecycleStates() {
@@ -100,15 +92,6 @@ public class Configuration {
public void setRatingConfiguration(
RatingConfiguration ratingConfiguration) { this.ratingConfiguration = ratingConfiguration; }
- @XmlElement(name = "ArtifactDownloadEndpoint", required = true)
- public String getArtifactDownloadEndpoint() {
- return artifactDownloadEndpoint;
- }
-
- public void setArtifactDownloadEndpoint(String artifactDownloadEndpoint) {
- this.artifactDownloadEndpoint = artifactDownloadEndpoint;
- }
-
@XmlElementWrapper(name = "AppCategories")
@XmlElement(name = "Category")
public List getAppCategories() {
@@ -118,5 +101,12 @@ public class Configuration {
public void setAppCategories(List appCategories) {
this.appCategories = appCategories;
}
+
+ @XmlElement(name = "MDMConfig", required = true)
+ public MDMConfig getMdmConfig() { return mdmConfig; }
+
+ public void setMdmConfig(MDMConfig mdmConfig) {
+ this.mdmConfig = mdmConfig;
+ }
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java
index c41dda76d7..469ee44030 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java
@@ -77,7 +77,8 @@ public interface SubscriptionDAO {
void updateSubscriptions(int tenantId, String updateBy, List paramList,
int releaseId, String subType, String action) throws ApplicationManagementDAOException;
- List getSubscribedDeviceIds(List deviceIds, int tenantId) throws ApplicationManagementDAOException;
+ List getSubscribedDeviceIds(List deviceIds, int applicationReleaseId, int tenantId)
+ throws ApplicationManagementDAOException;
List getDeviceSubIdsForOperation (int operationId, int tenantId) throws ApplicationManagementDAOException;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java
index 9eabccb38c..cc6938c934 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java
@@ -533,7 +533,8 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
@Override
- public List getSubscribedDeviceIds(List deviceIds, int tenantId)
+ public List getSubscribedDeviceIds(List deviceIds, int applicationReleaseId,
+ int tenantId)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received to DAO Layer to get already subscribed dvice Ids for given list of device Ids.");
@@ -545,14 +546,15 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
StringJoiner joiner = new StringJoiner(",",
"SELECT DS.DM_DEVICE_ID "
+ "FROM AP_DEVICE_SUBSCRIPTION DS "
- + "WHERE DS.DM_DEVICE_ID IN (", ") AND TENANT_ID = ?");
+ + "WHERE DS.DM_DEVICE_ID IN (", ") AND AP_APP_RELEASE_ID = ? AND TENANT_ID = ?");
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString();
try (PreparedStatement ps = conn.prepareStatement(query)) {
for (Integer deviceId : deviceIds) {
ps.setObject(index++, deviceId);
}
- ps.setInt(index, tenantId);
+ ps.setInt(index++, tenantId);
+ ps.setInt(index, applicationReleaseId);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
subscribedDevices.add(rs.getInt("DM_DEVICE_ID"));
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java
index e2647cef16..783438564c 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java
@@ -32,6 +32,7 @@ import org.wso2.carbon.device.application.mgt.common.ApplicationInstaller;
import org.wso2.carbon.device.application.mgt.common.DeviceTypes;
import org.wso2.carbon.device.application.mgt.common.LifecycleChanger;
import org.wso2.carbon.device.application.mgt.common.Pagination;
+import org.wso2.carbon.device.application.mgt.common.config.MDMConfig;
import org.wso2.carbon.device.application.mgt.common.config.RatingConfiguration;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
@@ -451,13 +452,15 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
if (!StringUtils.isEmpty(applicationArtifact.getIconName())) {
- applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(),
- applicationReleaseDTO.getIconName());
+ applicationStorageManager
+ .deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), Constants.ICON_ARTIFACT,
+ applicationReleaseDTO.getIconName());
applicationReleaseDTO.setIconName(applicationArtifact.getIconName());
}
if (!StringUtils.isEmpty(applicationArtifact.getBannerName())){
- applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(),
- applicationReleaseDTO.getBannerName());
+ applicationStorageManager
+ .deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), Constants.BANNER_ARTIFACT,
+ applicationReleaseDTO.getBannerName());
applicationReleaseDTO.setBannerName(applicationArtifact.getBannerName());
}
@@ -470,17 +473,21 @@ public class ApplicationManagerImpl implements ApplicationManager {
int counter = 1;
for (String scName : screenshotNames) {
+ String folderPath = Constants.SCREENSHOT_ARTIFACT + counter;
if (counter == 1) {
- applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(),
- applicationReleaseDTO.getScreenshotName1());
+ applicationStorageManager
+ .deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath,
+ applicationReleaseDTO.getScreenshotName1());
applicationReleaseDTO.setScreenshotName1(scName);
} else if (counter == 2) {
- applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(),
- applicationReleaseDTO.getScreenshotName2());
+ applicationStorageManager
+ .deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath,
+ applicationReleaseDTO.getScreenshotName2());
applicationReleaseDTO.setScreenshotName2(scName);
} else if (counter == 3) {
- applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(),
- applicationReleaseDTO.getScreenshotName3());
+ applicationStorageManager
+ .deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath,
+ applicationReleaseDTO.getScreenshotName3());
applicationReleaseDTO.setScreenshotName3(scName);
}
counter++;
@@ -583,12 +590,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg);
throw new ApplicationManagementException(msg, e);
} catch (UserStoreException e) {
- throw new ApplicationManagementException(
- "User-store exception while checking whether the user " + userName + " of tenant " + tenantId
- + " has the publisher permission", e);
+ String msg = "User-store exception while checking whether the user " + userName + " of tenant " + tenantId
+ + " has the publisher permission";
+ log.error(msg);
+ throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
- throw new ApplicationManagementException(
- "DAO exception while getting applications for the user " + userName + " of tenant " + tenantId, e);
+ String msg = "DAO exception while getting applications for the user " + userName + " of tenant " + tenantId;
+ log.error(msg);
+ throw new ApplicationManagementException(msg, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
@@ -792,23 +801,26 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.commitDBTransaction();
return applicationRelease;
} catch (TransactionManagementException e) {
- throw new ApplicationManagementException(
- "Error occurred while staring application release creating transaction for application Id: "
- + applicationId, e);
+ String msg = "Error occurred while staring application release creating transaction for application Id: "
+ + applicationId;
+ log.error(msg);
+ throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {
- throw new ApplicationManagementException(
- "Error occurred while adding application release into IoTS app management ApplicationDTO id of the "
- + "application release: " + applicationId, e);
-
+ String msg = "Error occurred while adding application release into IoTS app management ApplicationDTO id of"
+ + " the application release: " + applicationId;
+ log.error(msg);
+ throw new ApplicationManagementException(msg, e);
} catch (LifeCycleManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
- throw new ApplicationManagementException(
- "Error occurred while adding new application release lifecycle state to the application release: "
- + applicationId, e);
+ String msg = "Error occurred while adding new application release lifecycle state to the application"
+ + " release: " + applicationId;
+ log.error(msg);
+ throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
- throw new ApplicationManagementException(
- "Error occurred while adding new application release for application " + applicationId, e);
+ String msg = "Error occurred while adding new application release for application " + applicationId;
+ log.error(msg);
+ throw new ApplicationManagementException(msg, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
@@ -2857,14 +2869,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new NotFoundException(msg);
}
ApplicationReleaseDTO applicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0);
- String host = System.getProperty(Constants.IOT_HOST_PROPERTY);
- String port = System.getProperty(Constants.IOT_PORT_PROPERTY);
- String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration()
- .getArtifactDownloadEndpoint();
- String artifactDownloadURL =
- Constants.ARTIFACT_DOWNLOAD_PROTOCOL + "://" + host + ":" + port + artifactDownloadEndpoint
- + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid() + Constants.FORWARD_SLASH
- + applicationReleaseDTO.getInstallerName();
+ String artifactDownloadURL = APIUtil.getArtifactDownloadBaseURL() + applicationReleaseDTO.getUuid()
+ + Constants.FORWARD_SLASH + applicationReleaseDTO.getInstallerName();
String plistContent = "<!DOCTYPE plist PUBLIC "-//Apple//DTDPLIST1.0//EN" "" +
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="" +
"1.0"><dict><key>items</key><array><dict><" +
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java
index 243fd1bc75..4a41f16cd2 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java
@@ -30,6 +30,7 @@ import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagemen
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.core.exception.ParsingException;
import org.wso2.carbon.device.application.mgt.core.util.ArtifactsParser;
+import org.wso2.carbon.device.application.mgt.core.util.Constants;
import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil;
import java.io.*;
@@ -60,21 +61,24 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
public ApplicationReleaseDTO uploadImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO,
InputStream iconFileStream, InputStream bannerFileStream, List screenShotStreams)
throws ResourceManagementException {
- String artifactDirectoryPath;
String iconStoredLocation;
String bannerStoredLocation;
String scStoredLocation = null;
try {
- artifactDirectoryPath = storagePath + applicationReleaseDTO.getAppHashValue();
- StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath);
+ String artifactStoringBaseDirPath = storagePath + applicationReleaseDTO.getAppHashValue();
+ StorageManagementUtil.createArtifactDirectory(artifactStoringBaseDirPath);
if (iconFileStream != null) {
- iconStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getIconName();
+ String iconStoringDir = artifactStoringBaseDirPath + File.separator + Constants.ICON_ARTIFACT;
+ StorageManagementUtil.createArtifactDirectory(iconStoringDir);
+ iconStoredLocation = iconStoringDir + File.separator + applicationReleaseDTO.getIconName();
saveFile(iconFileStream, iconStoredLocation);
}
if (bannerFileStream != null) {
- bannerStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getBannerName();
+ String bannerStoringDir = artifactStoringBaseDirPath + File.separator + Constants.BANNER_ARTIFACT;
+ StorageManagementUtil.createArtifactDirectory(bannerStoringDir);
+ bannerStoredLocation = bannerStoringDir + File.separator + applicationReleaseDTO.getBannerName();
saveFile(bannerFileStream, bannerStoredLocation);
}
if (!screenShotStreams.isEmpty()) {
@@ -86,14 +90,16 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
}
int count = 1;
for (InputStream screenshotStream : screenShotStreams) {
+ String scStoringDir = artifactStoringBaseDirPath + File.separator + Constants.SCREENSHOT_ARTIFACT + count;
+ StorageManagementUtil.createArtifactDirectory(scStoringDir);
if (count == 1) {
- scStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getScreenshotName1();
+ scStoredLocation = scStoringDir + File.separator + applicationReleaseDTO.getScreenshotName1();
}
if (count == 2) {
- scStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getScreenshotName2();
+ scStoredLocation = scStoringDir + File.separator + applicationReleaseDTO.getScreenshotName2();
}
if (count == 3) {
- scStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getScreenshotName3();
+ scStoredLocation = scStoringDir + File.separator + applicationReleaseDTO.getScreenshotName3();
}
saveFile(screenshotStream, scStoredLocation);
count++;
@@ -101,8 +107,10 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
}
return applicationReleaseDTO;
} catch (IOException e) {
- throw new ApplicationStorageManagementException("IO Exception while saving the screens hots for " +
- "the application " + applicationReleaseDTO.getUuid(), e);
+ String msg = "IO Exception occurred while saving application artifacts for the application which has UUID "
+ + applicationReleaseDTO.getUuid();
+ log.error(msg);
+ throw new ApplicationStorageManagementException(msg, e);
}
}
@@ -142,7 +150,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
String artifactPath;
byte [] content = IOUtils.toByteArray(binaryFile);
- artifactDirectoryPath = storagePath + applicationReleaseDTO.getAppHashValue();
+ artifactDirectoryPath =
+ storagePath + applicationReleaseDTO.getAppHashValue() + File.separator + Constants.APP_ARTIFACT;
StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath);
artifactPath = artifactDirectoryPath + File.separator + applicationReleaseDTO.getInstallerName();
saveFile(new ByteArrayInputStream(content), artifactPath);
@@ -168,24 +177,38 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
String screenshot3 = applicationReleaseDTO.getScreenshotName3();
if (bannerName != null) {
- StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + bannerName,
- storagePath + appHashValue + File.separator + bannerName);
+ StorageManagementUtil
+ .copy(storagePath + deletingAppHashValue + File.separator + Constants.BANNER_ARTIFACT
+ + File.separator + bannerName,
+ storagePath + appHashValue + File.separator + Constants.BANNER_ARTIFACT + File.separator
+ + bannerName);
}
if (iconName != null) {
- StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + iconName,
- storagePath + appHashValue + File.separator + iconName);
+ StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + Constants.ICON_ARTIFACT
+ + File.separator + iconName,
+ storagePath + appHashValue + File.separator + Constants.ICON_ARTIFACT + File.separator
+ + iconName);
}
if (screenshot1 != null) {
- StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + screenshot1,
- storagePath + appHashValue + File.separator + screenshot1);
+ StorageManagementUtil
+ .copy(storagePath + deletingAppHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 1
+ + File.separator + screenshot1,
+ storagePath + appHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 1
+ + File.separator + screenshot1);
}
if (screenshot2 != null) {
- StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + screenshot2,
- storagePath + appHashValue + File.separator + screenshot2);
+ StorageManagementUtil
+ .copy(storagePath + deletingAppHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 2
+ + File.separator + screenshot2,
+ storagePath + appHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 2
+ + File.separator + screenshot2);
}
if (screenshot3 != null) {
- StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + screenshot3,
- storagePath + appHashValue + File.separator + screenshot3);
+ StorageManagementUtil
+ .copy(storagePath + deletingAppHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 3
+ + File.separator + screenshot3,
+ storagePath + appHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 3
+ + File.separator + screenshot3);
}
deleteAppReleaseArtifact( storagePath + deletingAppHashValue);
} catch (IOException e) {
@@ -198,8 +221,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
@Override
- public void deleteAppReleaseArtifact(String appReleaseHashVal, String fileName) throws ApplicationStorageManagementException {
- String artifactPath = storagePath + appReleaseHashVal + File.separator + fileName;
+ public void deleteAppReleaseArtifact(String appReleaseHashVal, String folderName, String fileName)
+ throws ApplicationStorageManagementException {
+ String artifactPath = storagePath + appReleaseHashVal + File.separator + folderName + File.separator + fileName;
deleteAppReleaseArtifact(artifactPath);
}
@@ -212,8 +236,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
}
@Override
- public InputStream getFileSttream (String path) throws ApplicationStorageManagementException {
- String filePath = storagePath + path;
+ public InputStream getFileStream(String hashVal, String folderName, String fileName)
+ throws ApplicationStorageManagementException {
+ String filePath = storagePath + hashVal + File.separator + folderName + File.separator + fileName;
try {
return StorageManagementUtil.getInputStream(filePath);
} catch (IOException e) {
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java
index d480dde109..1d8c0d4ecf 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java
@@ -64,12 +64,11 @@ public class AppmDataHandlerImpl implements AppmDataHandler {
return lifecycleStateManager.getLifecycleConfig();
}
- @Override
- public InputStream getArtifactStream(String uuid, String artifactName) throws ApplicationManagementException {
+ @Override public InputStream getArtifactStream(String uuid, String folderName, String artifactName)
+ throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO();
- String artifactPath;
String appReleaseHashValue;
try {
ConnectionManagerUtil.openDBConnection();
@@ -79,10 +78,10 @@ public class AppmDataHandlerImpl implements AppmDataHandler {
log.error(msg);
throw new NotFoundException(msg);
}
- artifactPath = appReleaseHashValue + Constants.FORWARD_SLASH + artifactName;
- InputStream inputStream = applicationStorageManager.getFileSttream(artifactPath);
+ InputStream inputStream = applicationStorageManager
+ .getFileStream(appReleaseHashValue, folderName, artifactName);
if (inputStream == null) {
- String msg = "Couldn't file the file in the file system. File path: " + artifactPath;
+ String msg = "Couldn't file the file in the file system.";
log.error(msg);
throw new ApplicationManagementException(msg);
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java
index bee2aad2af..141fd576e2 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java
@@ -27,6 +27,7 @@ import org.wso2.carbon.device.application.mgt.common.DeviceTypes;
import org.wso2.carbon.device.application.mgt.common.SubAction;
import org.wso2.carbon.device.application.mgt.common.SubsciptionType;
import org.wso2.carbon.device.application.mgt.common.SubscribingDeviceIdHolder;
+import org.wso2.carbon.device.application.mgt.common.config.MDMConfig;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
import org.wso2.carbon.device.application.mgt.common.dto.DeviceSubscriptionDTO;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
@@ -335,36 +336,38 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
ConnectionManagerUtil.beginDBTransaction();
List deviceSubIds = new ArrayList<>();
- List subscribedEntities = new ArrayList<>();
if (SubsciptionType.USER.toString().equalsIgnoreCase(subType)) {
- subscribedEntities = subscriptionDAO.getSubscribedUserNames(params, tenantId);
+ List subscribedEntities = subscriptionDAO.getSubscribedUserNames(params, tenantId);
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
params.removeAll(subscribedEntities);
subscriptionDAO.addUserSubscriptions(tenantId, username, params, applicationReleaseId);
}
+ subscriptionDAO.updateSubscriptions(tenantId, username, subscribedEntities, applicationReleaseId, subType,
+ action);
} else if (SubsciptionType.ROLE.toString().equalsIgnoreCase(subType)) {
- subscribedEntities = subscriptionDAO.getSubscribedRoleNames(params, tenantId);
+ List subscribedEntities = subscriptionDAO.getSubscribedRoleNames(params, tenantId);
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
params.removeAll(subscribedEntities);
subscriptionDAO.addRoleSubscriptions(tenantId, username, params, applicationReleaseId);
-
}
+ subscriptionDAO.updateSubscriptions(tenantId, username, subscribedEntities, applicationReleaseId, subType,
+ action);
} else if (SubsciptionType.GROUP.toString().equalsIgnoreCase(subType)) {
- subscribedEntities = subscriptionDAO.getSubscribedGroupNames(params, tenantId);
+ List subscribedEntities = subscriptionDAO.getSubscribedGroupNames(params, tenantId);
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
params.removeAll(subscribedEntities);
subscriptionDAO.addGroupSubscriptions(tenantId, username, params, applicationReleaseId);
}
+ subscriptionDAO.updateSubscriptions(tenantId, username, subscribedEntities, applicationReleaseId, subType,
+ action);
}
- subscriptionDAO.updateSubscriptions(tenantId, username, subscribedEntities, applicationReleaseId, subType,
- action);
for (Activity activity : activities) {
int operationId = Integer.parseInt(activity.getActivityId().split("ACTIVITY_")[1]);
List operationAddedDeviceIds = getOperationAddedDeviceIds(activity,
subscribingDeviceIdHolder.getSubscribableDevices());
List alreadySubscribedDevices = subscriptionDAO
- .getSubscribedDeviceIds(operationAddedDeviceIds, tenantId);
+ .getSubscribedDeviceIds(operationAddedDeviceIds, applicationReleaseId, tenantId);
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
if (!alreadySubscribedDevices.isEmpty()) {
List deviceResubscribingIds = subscriptionDAO
@@ -478,14 +481,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
} else if (DeviceTypes.IOS.toString().equalsIgnoreCase(deviceType)) {
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
- String host = System.getProperty(Constants.IOT_HOST_PROPERTY);
- String port = System.getProperty(Constants.IOT_PORT_PROPERTY);
- String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration()
- .getArtifactDownloadEndpoint();
- String plistDownloadEndpoint =
- Constants.ARTIFACT_DOWNLOAD_PROTOCOL + "://" + host + ":" + port + artifactDownloadEndpoint
- + Constants.FORWARD_SLASH + MDMAppConstants.IOSConstants.PLIST
- + Constants.FORWARD_SLASH + application.getApplicationReleases().get(0).getUuid();
+ String plistDownloadEndpoint = APIUtil.getArtifactDownloadBaseURL()
+ + MDMAppConstants.IOSConstants.PLIST + Constants.FORWARD_SLASH
+ + application.getApplicationReleases().get(0).getUuid();
mobileApp.setType(mobileAppType);
mobileApp.setLocation(plistDownloadEndpoint);
Properties properties = new Properties();
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java
index 5cb4062643..ff74bda97a 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java
@@ -24,8 +24,10 @@ import org.apache.commons.logging.LogFactory;
import org.apache.commons.validator.routines.UrlValidator;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.application.mgt.common.ApplicationType;
+import org.wso2.carbon.device.application.mgt.common.config.MDMConfig;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO;
+import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.response.Application;
import org.wso2.carbon.device.application.mgt.common.response.ApplicationRelease;
import org.wso2.carbon.device.application.mgt.common.services.*;
@@ -306,8 +308,7 @@ public class APIUtil {
return applicationReleaseDTO;
}
- public static Application appDtoToAppResponse(ApplicationDTO applicationDTO)
- throws BadRequestException, UnexpectedServerErrorException {
+ public static Application appDtoToAppResponse(ApplicationDTO applicationDTO) throws ApplicationManagementException {
Application application = new Application();
if (!ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType())) {
@@ -326,19 +327,18 @@ public class APIUtil {
application.setTags(applicationDTO.getTags());
application.setUnrestrictedRoles(applicationDTO.getUnrestrictedRoles());
application.setRating(applicationDTO.getAppRating());
- List applicationReleases = applicationDTO.getApplicationReleaseDTOs()
- .stream().map(APIUtil::releaseDtoToRelease).collect(Collectors.toList());
+ List applicationReleases = new ArrayList<>();
+ for (ApplicationReleaseDTO applicationReleaseDTO : applicationDTO.getApplicationReleaseDTOs()) {
+ ApplicationRelease applicationRelease = releaseDtoToRelease(applicationReleaseDTO);
+ applicationReleases.add(applicationRelease);
+ }
application.setApplicationReleases(applicationReleases);
return application;
}
- public static ApplicationRelease releaseDtoToRelease(ApplicationReleaseDTO applicationReleaseDTO){
- String host = System.getProperty(Constants.IOT_HOST_PROPERTY);
- String port = System.getProperty(Constants.IOT_PORT_PROPERTY);
- String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration()
- .getArtifactDownloadEndpoint();
- String basePath = Constants.ARTIFACT_DOWNLOAD_PROTOCOL + "://" + host + ":" + port + artifactDownloadEndpoint
- + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid()
+ public static ApplicationRelease releaseDtoToRelease(ApplicationReleaseDTO applicationReleaseDTO)
+ throws ApplicationManagementException {
+ String basePath = getArtifactDownloadBaseURL() + applicationReleaseDTO.getUuid()
+ Constants.FORWARD_SLASH;
List screenshotPaths = new ArrayList<>();
@@ -356,31 +356,58 @@ public class APIUtil {
applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants());
applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions());
applicationRelease.setRating(applicationReleaseDTO.getRating());
- applicationRelease.setIconPath(basePath + applicationReleaseDTO.getIconName());
+ applicationRelease.setIconPath(
+ basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName());
if (!StringUtils.isEmpty(applicationReleaseDTO.getBannerName())){
- applicationRelease.setBannerPath(basePath + applicationReleaseDTO.getBannerName());
+ applicationRelease.setBannerPath(
+ basePath + Constants.BANNER_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO
+ .getBannerName());
}
- if (urlValidator.isValid(applicationReleaseDTO.getInstallerName())){
- applicationRelease
- .setInstallerPath(applicationReleaseDTO.getInstallerName());
+ if (urlValidator.isValid(applicationReleaseDTO.getInstallerName())) {
+ applicationRelease.setInstallerPath(applicationReleaseDTO.getInstallerName());
} else {
- applicationRelease
- .setInstallerPath(basePath + applicationReleaseDTO.getInstallerName());
+ applicationRelease.setInstallerPath(
+ basePath + Constants.APP_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO
+ .getInstallerName());
}
if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName1())) {
- screenshotPaths.add(basePath + applicationReleaseDTO.getScreenshotName1());
+ screenshotPaths
+ .add(basePath + Constants.SCREENSHOT_ARTIFACT + 1 + Constants.FORWARD_SLASH + applicationReleaseDTO
+ .getScreenshotName1());
}
if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName2())) {
- screenshotPaths.add(basePath + applicationReleaseDTO.getScreenshotName2());
+ screenshotPaths
+ .add(basePath + Constants.SCREENSHOT_ARTIFACT + 2 + Constants.FORWARD_SLASH + applicationReleaseDTO
+ .getScreenshotName2());
}
if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName3())) {
- screenshotPaths.add(basePath + applicationReleaseDTO.getScreenshotName3());
+ screenshotPaths
+ .add(basePath + Constants.SCREENSHOT_ARTIFACT + 3 + Constants.FORWARD_SLASH + applicationReleaseDTO
+ .getScreenshotName3());
}
applicationRelease.setScreenshots(screenshotPaths);
return applicationRelease;
}
+ public static String getArtifactDownloadBaseURL() throws ApplicationManagementException {
+ String host = System.getProperty(Constants.IOT_HOST_PROPERTY);
+ MDMConfig mdmConfig = ConfigurationManager.getInstance().getConfiguration().getMdmConfig();
+ String port;
+ if (Constants.HTTP_PROTOCOL.equals(mdmConfig.getArtifactDownloadProtocol())){
+ port = System.getProperty(Constants.IOT_HTTP_PORT_PROPERTY);
+ } else if( Constants.HTTPS_PROTOCOL.equals(mdmConfig.getArtifactDownloadProtocol())){
+ port = System.getProperty(Constants.IOT_HTTPS_PORT_PROPERTY);
+ } else {
+ String msg = "In order to download application artifacts invalid protocols are defined.";
+ log.error(msg);
+ throw new ApplicationManagementException(msg);
+ }
+ String artifactDownloadEndpoint = mdmConfig.getArtifactDownloadEndpoint();
+ return mdmConfig.getArtifactDownloadProtocol() + "://" + host + ":" + port
+ + artifactDownloadEndpoint + Constants.FORWARD_SLASH;
+ }
+
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java
index 783e19bd08..3de99585db 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java
@@ -37,8 +37,10 @@ public class Constants {
public static final String CF_BUNDLE_VERSION = "CFBundleVersion";
public static final String APP_EXTENSION = ".app";
public static final String IOT_HOST_PROPERTY = "iot.core.host";
- public static final String IOT_PORT_PROPERTY = "iot.core.http.port";
- public static final String ARTIFACT_DOWNLOAD_PROTOCOL = "http";
+ public static final String IOT_HTTP_PORT_PROPERTY = "iot.core.http.port";
+ public static final String IOT_HTTPS_PORT_PROPERTY = "iot.core.https.port";
+ public static final String HTTPS_PROTOCOL = "https";
+ public static final String HTTP_PROTOCOL = "http";
public static final String FORWARD_SLASH = "/";
public static final String ANY = "ANY";
@@ -61,16 +63,25 @@ public class Constants {
public static final String DB_TYPE_POSTGRESQL = "PostgreSQL";
}
+ /**
+ * Directory name of the icon artifact that are saved in the file system.
+ */
+ public static final String ICON_ARTIFACT = "icon";
+
+ /**
+ * Directory name of the banner artifact that are saved in the file system.
+ */
+ public static final String BANNER_ARTIFACT = "banner";
/**
- * Name of the image artifacts that are saved in the file system.
+ * Common directory name of the screenshot artifact that are saved in the file system.
*/
- public static final String[] IMAGE_ARTIFACTS = {"icon", "banner", "screenshot"};
+ public static final String SCREENSHOT_ARTIFACT = "screenshot";
/**
- * Directory name of the release artifacts that are saved in the file system.
+ * Naming directory name of the application artifact that are saved in the file system.
*/
- public static final String RELEASE_ARTIFACT = "artifact";
+ public static final String APP_ARTIFACT = "app";
public static final int REVIEW_PARENT_ID = -1;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java
index a9de4b1922..25dbacd6c2 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java
@@ -23,17 +23,13 @@ import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
-import org.wso2.carbon.device.application.mgt.common.PaginationRequest;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO;
import org.wso2.carbon.device.application.mgt.common.dto.DeviceSubscriptionDTO;
import org.wso2.carbon.device.application.mgt.common.dto.ReviewDTO;
-import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
-import org.wso2.carbon.device.application.mgt.core.config.Configuration;
-import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
import org.wso2.carbon.device.application.mgt.core.exception.UnexpectedServerErrorException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
@@ -264,21 +260,6 @@ public class DAOUtil {
}
}
- public static PaginationRequest validateCommentListPageSize(PaginationRequest paginationRequest) throws
- ReviewManagementException {
- if (paginationRequest.getLimit() == 0) {
- Configuration commentManagementConfig = ConfigurationManager.getInstance().getConfiguration();
- if (commentManagementConfig != null) {
- paginationRequest.setLimit(
- commentManagementConfig.getPaginationConfiguration().getCommentListPageSize());
- } else {
- throw new ReviewManagementException(
- "ApplicationDTO Management configuration has not initialized. Please check the application-mgt.xml file.");
- }
- }
- return paginationRequest;
- }
-
private static ApplicationManager applicationManager;
private static ApplicationStorageManager applicationStorageManager;
private static SubscriptionManager subscriptionManager;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/dao/ApplicationManagementDAOTest.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/dao/ApplicationManagementDAOTest.java
index 6d07b0c688..fc2cfc8606 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/dao/ApplicationManagementDAOTest.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/dao/ApplicationManagementDAOTest.java
@@ -6,6 +6,7 @@ import org.apache.commons.logging.LogFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.device.application.mgt.core.BaseTestCase;
+import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
import org.wso2.carbon.device.application.mgt.core.dto.ApplicationsDTO;
import org.wso2.carbon.device.application.mgt.core.dto.DeviceTypeCreator;
@@ -22,12 +23,12 @@ public class ApplicationManagementDAOTest extends BaseTestCase {
@BeforeClass
public void initialize() throws Exception {
log.info("Initializing ApplicationManagementDAOTest tests");
+ ConfigurationManager configurationManager = ConfigurationManager.getInstance();
// super.initializeServices();
}
@Test
public void testAddApplication() throws Exception {
-
ApplicationDAO applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO();
ConnectionManagerUtil.beginDBTransaction();
applicationDAO.createApplication(ApplicationsDTO.getApp1(), -1234);
@@ -52,6 +53,4 @@ public class ApplicationManagementDAOTest extends BaseTestCase {
DeviceManagementDAOFactory.closeConnection();
}
}
-
-
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml
index 5af3ccc567..203e987a3c 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml
@@ -18,7 +18,7 @@
-->
-
+
jdbc/APPM_DS
@@ -135,7 +135,6 @@
truefalse
- falseapplication_management
@@ -150,23 +149,42 @@
perm:app:review:updateperm:app:publisher:viewperm:app:publisher:update
+ perm:app:store:view
+ perm:app:subscription:install
+ perm:app:subscription:uninstall
+ perm:admin:app:review:update
+ perm:admin:app:review:view
+ perm:admin:app:publisher:update
+ perm:admin:app:review:updateapp-mgt
-
- /application-mgt
-
- /pages/error/client-errors/400
- /pages/error/client-errors/401
- /pages/error/client-errors/403
- /pages/error/client-errors/404
- /pages/error/client-errors/405
- /pages/error/client-errors/406
- /pages/error/client-errors/415
- /pages/error/server-errors/500
- /pages/error/default
-
-
+
+ /pages/error/client-errors/400
+ /pages/error/client-errors/401
+ /pages/error/client-errors/403
+ /pages/error/client-errors/404
+ /pages/error/client-errors/405
+ /pages/error/client-errors/406
+ /pages/error/client-errors/415
+ /pages/error/server-errors/500
+ /pages/error/default
+
+
+
+ EMM
+ IoT
+
+
+
+ 1
+ 10
+
+
+
+ https
+ /api/application-mgt/v1.0/artifact
+
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/carbon-home/repository/conf/application-mgt.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/carbon-home/repository/conf/application-mgt.xml
index fa7c40bbc5..203e987a3c 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/carbon-home/repository/conf/application-mgt.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/carbon-home/repository/conf/application-mgt.xml
@@ -37,7 +37,7 @@
org.wso2.carbon.device.application.mgt.core.impl.ApplicationStorageManagerImpl
- /tmp/apps/
+ repository/resources/apps/6
@@ -135,7 +135,6 @@
truefalse
- falseapplication_management
@@ -151,27 +150,29 @@
perm:app:publisher:viewperm:app:publisher:updateperm:app:store:view
+ perm:app:subscription:install
+ perm:app:subscription:uninstall
+ perm:admin:app:review:update
+ perm:admin:app:review:view
+ perm:admin:app:publisher:update
+ perm:admin:app:review:updateapp-mgt
-
- /apps
-
- /pages/error/client-errors/400
- /pages/error/client-errors/401
- /pages/error/client-errors/403
- /pages/error/client-errors/404
- /pages/error/client-errors/405
- /pages/error/client-errors/406
- /pages/error/client-errors/415
- /pages/error/server-errors/500
- /pages/error/default
-
-
+
+ /pages/error/client-errors/400
+ /pages/error/client-errors/401
+ /pages/error/client-errors/403
+ /pages/error/client-errors/404
+ /pages/error/client-errors/405
+ /pages/error/client-errors/406
+ /pages/error/client-errors/415
+ /pages/error/server-errors/500
+ /pages/error/default
+
- https://localhost:9443/api/application-mgt/v1.0/artifactEMMIoT
@@ -181,4 +182,9 @@
110
+
+
+ https
+ /api/application-mgt/v1.0/artifact
+
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml
index 1e4ea6cb12..eda02c7b01 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml
@@ -22,13 +22,13 @@
application-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.device.application.mgt.publisher.api
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTwarWSO2 Carbon - Application Management Publisher APIWSO2 Carbon - Application Management Publisher API
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml
index d7d9590996..1bd68c685b 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml
@@ -24,10 +24,10 @@
org.wso2.carbon.devicemgtapplication-mgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTorg.wso2.carbon.device.application.mgt.publisher.ui
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTwarWSO2 Carbon - Application Management Publisher UI Componenthttp://wso2.org
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml
index 01c65ff444..f0e215f944 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml
@@ -22,13 +22,13 @@
application-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.device.application.mgt.store.api
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTwarWSO2 Carbon - Application Management Store APIWSO2 Carbon - Application Management Store API
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java
index dbb41fb34a..ebe2112ee1 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java
@@ -82,7 +82,7 @@ public interface SubscriptionManagementAPI {
String SCOPE = "scope";
@POST
- @Path("/install/{uuid}/devices/{action}")
+ @Path("/{uuid}/devices/{action}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(
@@ -124,7 +124,7 @@ public interface SubscriptionManagementAPI {
);
@POST
- @Path("/install/{uuid}/{subType}/{action}")
+ @Path("/{uuid}/{subType}/{action}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java
index 047b05ad3f..6dd826bd6d 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java
@@ -49,7 +49,7 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
@Override
@POST
- @Path("/install/{uuid}/devices/{action}")
+ @Path("/{uuid}/devices/{action}")
public Response performAppOperationForDevices(
@PathParam("uuid") String uuid,
@PathParam("action") String action,
@@ -83,7 +83,7 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
@Override
@POST
- @Path("/install/{uuid}/{subType}/{action}")
+ @Path("/{uuid}/{subType}/{action}")
public Response performBulkAppOperation(
@PathParam("uuid") String uuid,
@PathParam("subType") String subType,
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml
index 882a94e2ae..7bac04a171 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml
@@ -24,10 +24,10 @@
org.wso2.carbon.devicemgtapplication-mgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTorg.wso2.carbon.device.application.mgt.store.ui
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTwarWSO2 Carbon - Application Management Store UI Componenthttp://wso2.org
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppInstallModal.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppInstallModal.js
index c6bd55d9fb..7ce22fecfd 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppInstallModal.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppInstallModal.js
@@ -1,5 +1,5 @@
import React from "react";
-import {Button, Modal, Tabs} from "antd";
+import {Modal, Tabs} from "antd";
import UserInstall from "./UserInstall";
import GroupInstall from "./GroupInstall";
import RoleInstall from "./RoleInstall";
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js
index b1c13a6919..a26c7c9a08 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js
@@ -131,7 +131,8 @@ class DeviceInstall extends React.Component {
//send request to the invoker
axios.get(
- window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/devices?" + encodedExtraParams,
+ window.location.origin+
+ + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/devices?" + encodedExtraParams,
).then(res => {
if (res.status === 200) {
@@ -186,15 +187,17 @@ class DeviceInstall extends React.Component {
type: device.type
});
});
- this.props.onInstall("device", payload);
+ this.props.onInstall("devices", payload);
};
-
render() {
const {data,pagination,loading,selectedRows} = this.state;
return (
- Start installing the application for one or more users by entering the corresponding user name. Select install to automatically start downloading the application for the respective user/users.
+
+ Start installing the application for one or more users by entering the corresponding user name.
+ Select install to automatically start downloading the application for the respective user/users.
+
-
+
);
diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml
index dd201be3c4..397dfb91f8 100644
--- a/components/application-mgt/pom.xml
+++ b/components/application-mgt/pom.xml
@@ -22,13 +22,13 @@
org.wso2.carbon.devicemgtcarbon-devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../../pom.xml4.0.0application-mgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTpomWSO2 Carbon - Application Management ComponentWSO2 Carbon - Application Management Component
diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml
index 72625b7289..cc7194d28b 100644
--- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml
+++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml
@@ -22,7 +22,7 @@
certificate-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml
index 8918b450c9..fc6cdb7064 100644
--- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml
+++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml
@@ -22,7 +22,7 @@
certificate-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml
index 3e0b196ca9..2cc1097fa0 100644
--- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml
+++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml
@@ -21,13 +21,13 @@
org.wso2.carbon.devicemgtcertificate-mgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.certificate.mgt.core
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTbundleWSO2 Carbon - Certificate Management CoreWSO2 Carbon - Certificate Management Core
diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml
index 425da20c44..59e3242fb1 100644
--- a/components/certificate-mgt/pom.xml
+++ b/components/certificate-mgt/pom.xml
@@ -22,14 +22,14 @@
org.wso2.carbon.devicemgtcarbon-devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../../pom.xml4.0.0org.wso2.carbon.devicemgtcertificate-mgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOTpomWSO2 Carbon - Certificate Management Componenthttp://wso2.org
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml
index 77677a89c9..e552c57c59 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml
index 04450cd561..ff9eca7c0f 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml
index 86e14bdc9f..d9d8745b09 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml
index 4e287a95ff..4213761388 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml
index 3b542f6a9b..81fcbf86cb 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml
index afd98109ef..d5c1bb117c 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensionsorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml
index 930601b9a2..69999e3b67 100644
--- a/components/device-mgt-extensions/pom.xml
+++ b/components/device-mgt-extensions/pom.xml
@@ -22,7 +22,7 @@
carbon-devicemgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml
index 6c6ac9970a..4f095ccb11 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgtdevice-mgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml
index de6356c6f1..ed2e6719de 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml
@@ -20,7 +20,7 @@
device-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT4.0.0
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml
index 4fe7dae9e2..f349b331ab 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml
@@ -22,7 +22,7 @@
device-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
index 96991ed2ce..4cf332c0b8 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
@@ -58,6 +58,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
+import org.wso2.carbon.device.mgt.common.search.PropertyMap;
import org.wso2.carbon.device.mgt.common.search.SearchContext;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
@@ -79,6 +80,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
+import java.util.Map;
/**
* Device related REST-API. This can be used to manipulated device related details.
@@ -1074,6 +1076,84 @@ public interface DeviceManagementService {
required = true)
SearchContext searchContext);
+ @POST
+ @Path("/query-devices")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ consumes = MediaType.APPLICATION_JSON,
+ httpMethod = "POST",
+ value = "Property based Search for Devices",
+ notes = "Search for devices based on properties",
+ tags = "Device Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:search")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully retrieved the device information.",
+ response = DeviceList.class,
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource was last modified. \n" +
+ "Used by caches, or in conditional requests.")}),
+ @ApiResponse(
+ code = 304,
+ message = "Not Modified. \n " +
+ "Empty body because the client already has the latest version of the requested resource.\n"),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Acceptable.\n The existing device did not match the values specified in the device search.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 406,
+ message = "Not Acceptable.\n The requested media type is not supported"),
+ @ApiResponse(
+ code = 415,
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while getting the device details.",
+ response = ErrorResponse.class)
+ })
+ Response queryDevicesByProperties(
+ @ApiParam(
+ name = "offset",
+ value = "The starting pagination index for the complete list of qualified items.",
+ required = false,
+ defaultValue = "0")
+ @QueryParam("offset")
+ int offset,
+ @ApiParam(
+ name = "limit",
+ value = "Provide how many activity details you require from the starting pagination index/offset.",
+ required = false,
+ defaultValue = "5")
+ @QueryParam("limit")
+ int limit,
+ @ApiParam(
+ name = "device property map",
+ value = "properties by which devices need filtered",
+ required = true)
+ PropertyMap map);
+
@GET
@Path("/{type}/{id}/applications")
@ApiOperation(
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
index 311c02b79d..d87bfcd19a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
@@ -63,6 +63,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
+import org.wso2.carbon.device.mgt.common.search.PropertyMap;
import org.wso2.carbon.device.mgt.common.search.SearchContext;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
@@ -104,6 +105,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Map;
@Path("/devices")
@Produces(MediaType.APPLICATION_JSON)
@@ -652,6 +654,30 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.OK).entity(deviceList).build();
}
+ @POST
+ @Path("/query-devices")
+ @Override
+ public Response queryDevicesByProperties(@QueryParam("offset") int offset,
+ @QueryParam("limit") int limit, PropertyMap map) {
+ List devices;
+ DeviceList deviceList = new DeviceList();
+ try {
+ DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
+ devices = dms.getDevicesBasedOnProperties(map.getProperties());
+ if(devices == null || devices.isEmpty()){
+ return Response.status(Response.Status.OK).entity("No device found matching query criteria.").build();
+ }
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while searching for devices that matches the provided device properties";
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+ deviceList.setList(devices);
+ deviceList.setCount(devices.size());
+ return Response.status(Response.Status.OK).entity(deviceList).build();
+ }
+
@GET
@Path("/{type}/{id}/applications")
@Override
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml
index 50535a1df9..c56de855be 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml
@@ -21,7 +21,7 @@
device-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java
index 6c8bf5dc0d..09e84c26b9 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java
@@ -14,6 +14,23 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
+ *
+ * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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;
@@ -80,6 +97,15 @@ public interface DeviceManager {
*/
boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
+ /**
+ * Method to delete a particular device from CDM.
+ *
+ * @param deviceId Fully qualified device identifier
+ * @return A boolean indicating the status of the operation.
+ * @throws DeviceManagementException If some unusual behaviour is observed while deleting a device
+ */
+ boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException;
+
/**
* Method to retrieve the status of the registration process of a particular device.
*
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/search/PropertyMap.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/search/PropertyMap.java
new file mode 100644
index 0000000000..68df7c7bdc
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/search/PropertyMap.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.wso2.carbon.device.mgt.common.search;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Map;
+
+
+@ApiModel(value = "PropertyMap", description = "Search properties based on which devices need to be found.")
+public class PropertyMap {
+
+ @ApiModelProperty(name = "properties", value = "Contains the properties for search.",
+ required = true)
+ private Map properties;
+
+ public Map getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Map properties) {
+ this.properties = properties;
+ }
+}
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
index ffb620fd46..5a4eafe577 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgtdevice-mgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java
index b089477f06..5ea2a87b5b 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java
@@ -47,6 +47,7 @@ import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* This class represents the key operations associated with persisting device related information.
@@ -180,6 +181,26 @@ public interface DeviceDAO {
Device getDevice(DeviceIdentifier deviceIdentifier, Date ifModifiedSince, int tenantId) throws
DeviceManagementDAOException;
+ /**
+ * Retrieves a list of devices based on a given criteria of properties
+ * @param deviceProps properties by which devices need to be filtered
+ * @param tenantId tenant id
+ * @return list of devices with properties
+ * @throws DeviceManagementDAOException
+ */
+ List getDeviceBasedOnDeviceProperties(Map deviceProps, int tenantId) throws DeviceManagementDAOException;
+
+
+ /**
+ * Retrieves properties of given device identifier
+ *
+ * @param deviceId identifier of device that need to be retrieved
+ * @param tenantId tenant ID
+ * @return list of devices with properties
+ * @throws DeviceManagementDAOException
+ */
+ Device getDeviceProps(String deviceId, int tenantId) throws DeviceManagementDAOException;
+
/**
* This method is used to retrieve a device of a given device-identifier and tenant-id which modified
* later than the ifModifiedSince param.
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java
index aa07aba8b4..1cd83aa794 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java
@@ -56,15 +56,22 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.StringJoiner;
public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
private static final org.apache.commons.logging.Log log = LogFactory.getLog(AbstractDeviceDAOImpl.class);
+ private static final String PROPERTY_KEY_COLUMN_NAME = "PROPERTY_NAME";
+ private static final String PROPERTY_VALUE_COLUMN_NAME = "PROPERTY_VALUE";
+ private static final String PROPERTY_DEVICE_TYPE_NAME = "DEVICE_TYPE_NAME";
+ private static final String PROPERTY_DEVICE_IDENTIFICATION = "DEVICE_IDENTIFICATION";
+
@Override
public int addDevice(int typeId, Device device, int tenantId) throws DeviceManagementDAOException {
Connection conn;
@@ -282,6 +289,103 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
return device;
}
+ @Override
+ public List getDeviceBasedOnDeviceProperties(Map deviceProps, int tenantId)
+ throws DeviceManagementDAOException {
+ Connection conn = null;
+ PreparedStatement stmt = null;
+ ResultSet resultSet = null;
+ List devices = new ArrayList<>();
+ try {
+ List> outputLists = new ArrayList<>();
+ List deviceList = null;
+ conn = this.getConnection();
+ for (Map.Entry entry : deviceProps.entrySet()) {
+
+ stmt = conn.prepareStatement("SELECT DEVICE_IDENTIFICATION FROM DM_DEVICE_PROPERTIES " +
+ "WHERE (PROPERTY_NAME , PROPERTY_VALUE) IN " +
+ "((? , ?)) AND TENANT_ID = ?");
+ stmt.setString(1, entry.getKey());
+ stmt.setString(2, entry.getValue());
+ stmt.setInt(3, tenantId);
+ resultSet = stmt.executeQuery();
+
+ deviceList = new ArrayList<>();
+ while (resultSet.next()) {
+ deviceList.add(resultSet.getString(PROPERTY_DEVICE_IDENTIFICATION));
+ }
+ outputLists.add(deviceList);
+ }
+ List deviceIds = findIntersection(outputLists);
+ for(String deviceId : deviceIds){
+ devices.add(getDeviceProps(deviceId, tenantId));
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while fetching devices against criteria : '" + deviceProps;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ } finally {
+ DeviceManagementDAOUtil.cleanupResources(stmt, resultSet);
+ }
+ return devices;
+ }
+
+ @Override
+ public Device getDeviceProps(String deviceId, int tenantId) throws DeviceManagementDAOException {
+ Connection conn = null;
+ PreparedStatement stmt = null;
+ Device device = null;
+ ResultSet resultSet = null;
+ String deviceType = null;
+ try {
+ conn = this.getConnection();
+ stmt = conn.prepareStatement(
+ "SELECT * FROM DM_DEVICE_PROPERTIES WHERE DEVICE_IDENTIFICATION = ? AND TENANT_ID = ?");
+ stmt.setString(1, deviceId);
+ stmt.setInt(2, tenantId);
+ resultSet = stmt.executeQuery();
+ List properties = new ArrayList<>();
+ while (resultSet.next()) {
+ Device.Property property = new Device.Property();
+ property.setName(resultSet.getString(PROPERTY_KEY_COLUMN_NAME));
+ property.setValue(resultSet.getString(PROPERTY_VALUE_COLUMN_NAME));
+ properties.add(property);
+ //We are repeatedly assigning device type here. Yes. This was done intentionally, as there would be
+ //No other efficient/simple/inexpensive way of retrieving device type of a particular device from the database
+ //Note that device-identification will be unique across device types
+ deviceType = resultSet.getString(PROPERTY_DEVICE_TYPE_NAME);
+ }
+ device = new Device();
+ device.setDeviceIdentifier(deviceId);
+ device.setType(deviceType);
+ device.setProperties(properties);
+
+ } catch (SQLException e) {
+ String msg = "Error occurred while fetching properties for device : '" + deviceId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ } finally {
+ DeviceManagementDAOUtil.cleanupResources(stmt, resultSet);
+ }
+
+ return device;
+ }
+
+ private List findIntersection(List> collections) {
+ boolean first = true;
+ List intersectedResult = new ArrayList<>();
+ for (Collection collection : collections) {
+ if (first) {
+ intersectedResult.addAll(collection);
+ first = false;
+ } else {
+ intersectedResult.retainAll(collection);
+ }
+ }
+ return intersectedResult;
+ }
+
+
@Override
public Device getDevice(String deviceIdentifier, Date since, int tenantId)
throws DeviceManagementDAOException {
@@ -1409,91 +1513,97 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
}
public void deleteDevice(DeviceIdentifier deviceIdentifier, int tenantId) throws DeviceManagementDAOException {
+ String deviceIdentifierId = deviceIdentifier.getId();
+ String deviceType = deviceIdentifier.getType();
Connection conn;
try {
conn = this.getConnection();
int deviceId = getDeviceId(conn, deviceIdentifier, tenantId);
if (deviceId == -1) {
- String msg = "Device " + deviceIdentifier.getId() + " of type " + deviceIdentifier.getType() +
- " is not found";
+ String msg = "Device " + deviceIdentifierId + " of type " + deviceType + " is not found";
log.error(msg);
throw new DeviceManagementDAOException(msg);
} else {
- int enrollmentId = getEnrollmentId(conn, deviceId, tenantId);
- if (enrollmentId == -1) {
- String msg = "Enrollment not found for the device " + deviceIdentifier.getId() + " of type " +
- deviceIdentifier.getType();
+ List enrollmentIds = getEnrollmentIds(conn, deviceId, tenantId);
+ if (enrollmentIds == null || enrollmentIds.isEmpty()) {
+ String msg = "Enrollments not found for the device " + deviceIdentifierId + " of type "
+ + deviceType;
log.error(msg);
throw new DeviceManagementDAOException(msg);
} else {
removeDeviceDetail(conn, deviceId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed device detail data");
+ log.debug("Successfully removed device detail data of device " + deviceIdentifierId
+ + " of type " + deviceType);
}
removeDeviceLocation(conn, deviceId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed device location data");
+ log.debug("Successfully removed device location data of device " + deviceIdentifierId
+ + " of type " + deviceType);
}
removeDeviceInfo(conn, deviceId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed device info data");
+ log.debug("Successfully removed device info data of device " + deviceIdentifierId
+ + " of type " + deviceType);
}
removeDeviceNotification(conn, deviceId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed device notification data");
+ log.debug("Successfully removed device notification data of device " + deviceIdentifierId
+ + " of type " + deviceType);
}
removeDeviceApplicationMapping(conn, deviceId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed device application mapping data");
+ log.debug("Successfully removed device application mapping data of device "
+ + deviceIdentifierId + " of type " + deviceType);
}
removeDevicePolicyApplied(conn, deviceId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed device applied policy data");
+ log.debug("Successfully removed device applied policy data of device " + deviceIdentifierId
+ + " of type " + deviceType);
}
removeDevicePolicy(conn, deviceId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed device policy data");
- }
- removeEnrollmentDeviceDetail(conn, enrollmentId);
- if (log.isDebugEnabled()) {
- log.debug("Successfully removed enrollment device detail data");
+ log.debug("Successfully removed device policy data of device " + deviceIdentifierId
+ + " of type " + deviceType);
}
- removeEnrollmentDeviceLocation(conn, enrollmentId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed enrollment device location data");
+ log.debug("Starting to remove " + enrollmentIds.size() + " enrollment data of device "
+ + deviceIdentifierId + " of type " + deviceType);
}
- removeEnrollmentDeviceInfo(conn, enrollmentId);
- if (log.isDebugEnabled()) {
- log.debug("Successfully removed enrollment device info data");
- }
- removeEnrollmentDeviceApplicationMapping(conn, enrollmentId);
- if (log.isDebugEnabled()) {
- log.debug("Successfully removed enrollment device application mapping data");
+ for (Integer enrollmentId : enrollmentIds) {
+ removeEnrollmentDeviceDetail(conn, enrollmentId);
+ removeEnrollmentDeviceLocation(conn, enrollmentId);
+ removeEnrollmentDeviceInfo(conn, enrollmentId);
+ removeEnrollmentDeviceApplicationMapping(conn, enrollmentId);
+ removeDeviceOperationResponse(conn, enrollmentId);
+ removeEnrollmentOperationMapping(conn, enrollmentId);
}
- removeDeviceOperationResponse(conn, enrollmentId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed device operation response data");
- }
- removeEnrollmentOperationMapping(conn, enrollmentId);
- if (log.isDebugEnabled()) {
- log.debug("Successfully removed enrollment operation mapping data");
+ log.debug("Successfully removed enrollment device details, enrollment device location, " +
+ "enrollment device info, enrollment device application mapping, " +
+ "enrollment device operation response, enrollment operation mapping data of device "
+ + deviceIdentifierId + " of type " + deviceType);
}
removeDeviceEnrollment(conn, deviceId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed device enrollment data");
+ log.debug("Successfully removed device enrollment data of device " + deviceIdentifierId
+ + " of type " + deviceType);
}
removeDeviceGroupMapping(conn, deviceId);
if (log.isDebugEnabled()) {
- log.debug("Successfully removed device group mapping data");
+ log.debug("Successfully removed device group mapping data of device " + deviceIdentifierId
+ + " of type " + deviceType);
}
removeDevice(conn, deviceId);
if (log.isDebugEnabled()) {
- log.debug("Successfully permanently deleted the device");
+ log.debug("Successfully permanently deleted the device of device " + deviceIdentifierId
+ + " of type " + deviceType);
}
}
}
} catch (SQLException e) {
- throw new DeviceManagementDAOException("Error occurred while deleting the device", e);
+ throw new DeviceManagementDAOException("Error occurred while deleting the device " + deviceIdentifierId
+ + " of type " + deviceType, e);
}
}
@@ -1519,30 +1629,29 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
return deviceId;
}
- private int getEnrollmentId(Connection conn, int deviceId, int tenantId) throws DeviceManagementDAOException {
+ private List getEnrollmentIds(Connection conn, int deviceId, int tenantId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
- int enrollmentId = -1;
+ List enrollmentIds = new ArrayList<>();
try {
String sql = "SELECT ID FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
rs = stmt.executeQuery();
- if (rs.next()) {
- enrollmentId = rs.getInt("ID");
+ while (rs.next()) {
+ enrollmentIds.add(rs.getInt("ID"));
}
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while retrieving enrollment id of the device", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
- return enrollmentId;
+ return enrollmentIds;
}
private void removeDeviceDetail(Connection conn, int deviceId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1551,13 +1660,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device detail", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeDeviceLocation(Connection conn, int deviceId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1566,13 +1674,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device location", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeDeviceInfo(Connection conn, int deviceId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1581,13 +1688,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device info", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeDeviceNotification(Connection conn, int deviceId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_NOTIFICATION WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1596,13 +1702,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device notification", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeDeviceApplicationMapping(Connection conn, int deviceId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1611,13 +1716,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device application mapping", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeDevicePolicyApplied(Connection conn, int deviceId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_POLICY_APPLIED WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1626,13 +1730,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device policy applied", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeDevicePolicy(Connection conn, int deviceId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_POLICY WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1641,13 +1744,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device policy", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeEnrollmentDeviceDetail(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1656,13 +1758,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing enrollment device detail", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeEnrollmentDeviceLocation(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1671,13 +1772,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing enrollment device location", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeEnrollmentDeviceInfo(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_INFO WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1686,14 +1786,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing enrollment device info", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeEnrollmentDeviceApplicationMapping(Connection conn, int enrollmentId)
throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1703,13 +1802,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
throw new DeviceManagementDAOException("Error occurred while removing enrollment device application " +
"mapping", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeDeviceOperationResponse(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1718,14 +1816,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device operation response", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeEnrollmentOperationMapping(Connection conn, int enrollmentId)
throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_ENROLMENT_OP_MAPPING WHERE ENROLMENT_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1734,13 +1831,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing enrollment operation mapping", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeDeviceEnrollment(Connection conn, int deviceId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1749,13 +1845,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device enrollment", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeDeviceGroupMapping(Connection conn, int deviceId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE_GROUP_MAP WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1764,13 +1859,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device group mapping", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
private void removeDevice(Connection conn, int deviceId) throws DeviceManagementDAOException {
PreparedStatement stmt = null;
- ResultSet rs = null;
try {
String sql = "DELETE FROM DM_DEVICE WHERE ID = ?";
stmt = conn.prepareStatement(sql);
@@ -1779,7 +1873,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while removing device", e);
} finally {
- DeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
index 60725520e7..ddcad309e5 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
@@ -66,6 +66,7 @@ import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* Proxy class for all Device Management related operations that take the corresponding plugin type in
@@ -255,6 +256,15 @@ public interface DeviceManagementProviderService {
*/
Device getDevice(DeviceIdentifier deviceId, Date since, boolean requireDeviceInfo) throws DeviceManagementException;
+ /**
+ * Retrieves a list of devices based on a given criteria of properties
+ *
+ * @param deviceProps properties by which devices need to be drawn
+ * @return list of devices
+ * @throws DeviceManagementException
+ */
+ List getDevicesBasedOnProperties(Map deviceProps) throws DeviceManagementException;
+
/**
* Returns the device of specified id.
*
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
index 5212e4bf7f..d9d34f5fd4 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
@@ -14,23 +14,23 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
-/*
- * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
- * Entgra (pvt) Ltd. 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
+ * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.
+ * 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.service;
@@ -553,6 +553,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
try {
DeviceManagementDAOFactory.beginTransaction();
deviceDAO.deleteDevice(deviceId, tenantId);
+ try {
+ deviceManager.deleteDevice(deviceId, device);
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while permanently deleting '" + deviceId.getType() +
+ "' device with the identifier '" + deviceId.getId() + "' in plugin.";
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
DeviceManagementDAOFactory.commitTransaction();
this.removeDeviceFromCache(deviceId);
} catch (DeviceManagementDAOException e) {
@@ -1201,6 +1209,46 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return device;
}
+
+ @Override
+ public List getDevicesBasedOnProperties(Map deviceProps) throws DeviceManagementException {
+ if (deviceProps == null || deviceProps.isEmpty()) {
+ String msg = "Devices retrieval criteria cannot be null or empty.";
+ log.error(msg);
+ throw new DeviceManagementException(msg);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Attempting to get devices based on criteria : " + deviceProps);
+ }
+ List devices;
+ try {
+ int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
+ DeviceManagementDAOFactory.openConnection();
+ devices = deviceDAO.getDeviceBasedOnDeviceProperties(deviceProps, tenantId);
+ if (devices == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("No device is found against criteria : " + deviceProps + " and tenantId "+ tenantId);
+ }
+ return null;
+ }
+ } catch (DeviceManagementDAOException e) {
+ String msg = "Error occurred while obtaining devices based on criteria : " + deviceProps;
+ log.error(msg, e);
+ throw new DeviceManagementException(msg, e);
+ } catch (SQLException 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) {
+ String msg = "Error occurred while obtaining devices based on criteria : " + deviceProps;
+ log.error(msg, e);
+ throw new DeviceManagementException(msg, e);
+ } finally {
+ DeviceManagementDAOFactory.closeConnection();
+ }
+ return devices;
+ }
+
@Override
public Device getDevice(String deviceId, Date since, boolean requireDeviceInfo) throws DeviceManagementException {
if (deviceId == null || since == null) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java
index 72c23ee643..b87a7ea5a6 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java
@@ -60,6 +60,11 @@ public class TestDeviceManager implements DeviceManager {
return true;
}
+ @Override
+ public boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException {
+ return true;
+ }
+
@Override
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
index 4478ee5176..3e77a56e72 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
@@ -22,7 +22,7 @@
device-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManager.java
index e5879db164..edcb4f76e5 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManager.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManager.java
@@ -15,6 +15,22 @@
* specific language governing permissions and limitations
* under the License.
*
+ *
+ * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.extensions.device.type.template;
@@ -568,4 +584,35 @@ public class DeviceTypeManager implements DeviceManager {
return null;
}
+ @Override
+ public boolean deleteDevice(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
+ if (propertiesExist) {
+ boolean status;
+ Device existingDevice = this.getDevice(deviceIdentifier);
+ if (existingDevice == null) {
+ return false;
+ }
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Deleting the details of " + deviceType + " device : " + device.getDeviceIdentifier());
+ }
+ deviceTypePluginDAOManager.getDeviceTypeDAOHandler().beginTransaction();
+ status = deviceTypePluginDAOManager.getDeviceDAO().deleteDevice(existingDevice);
+ deviceTypePluginDAOManager.getDeviceTypeDAOHandler().commitTransaction();
+ } catch (DeviceTypeMgtPluginException e) {
+ try {
+ deviceTypePluginDAOManager.getDeviceTypeDAOHandler().rollbackTransaction();
+ } catch (DeviceTypeMgtPluginException e1) {
+ log.warn("Error occurred while roll back the delete device info transaction : '" +
+ device.toString() + "'", e1);
+ }
+ throw new DeviceManagementException(
+ "Error occurred while deleting the " + deviceType + " device: '" +
+ device.getDeviceIdentifier() + "'", e);
+ }
+ return status;
+ }
+ return true;
+ }
+
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/DeviceTypePluginDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/DeviceTypePluginDAOImpl.java
index 755cb0397b..00c9e4ff40 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/DeviceTypePluginDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/DeviceTypePluginDAOImpl.java
@@ -14,6 +14,23 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
+ *
+ * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.extensions.device.type.template.dao;
@@ -45,6 +62,7 @@ public class DeviceTypePluginDAOImpl implements PluginDAO {
private String createDBqueryForAddDevice;
private String updateDBQueryForUpdateDevice;
private String selectDBQueryToGetAllDevice;
+ private String deleteDBQueryForDeleteDevice;
public DeviceTypePluginDAOImpl(DeviceDAODefinition deviceDAODefinition,
DeviceTypeDAOHandler deviceTypeDAOHandler) {
@@ -196,6 +214,33 @@ public class DeviceTypePluginDAOImpl implements PluginDAO {
}
}
+ @Override
+ public boolean deleteDevice(Device device) throws DeviceTypeMgtPluginException {
+ boolean status = false;
+ Connection conn;
+ PreparedStatement stmt = null;
+ try {
+ conn = deviceTypeDAOHandler.getConnection();
+ stmt = conn.prepareStatement(deleteDBQueryForDeleteDevice);
+ stmt.setString(1, device.getDeviceIdentifier());
+ int rows = stmt.executeUpdate();
+ if (rows > 0) {
+ status = true;
+ if (log.isDebugEnabled()) {
+ log.debug("Device " + device.getDeviceIdentifier() + " data has been deleted.");
+ }
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting the device '" + device.getDeviceIdentifier() + "' data in "
+ + deviceDAODefinition.getDeviceTableName();
+ log.error(msg, e);
+ throw new DeviceTypeMgtPluginException(msg, e);
+ } finally {
+ DeviceTypeUtils.cleanupResources(stmt, null);
+ }
+ return status;
+ }
+
private String getDeviceTableColumnNames() {
return StringUtils.join(deviceDAODefinition.getColumnNames(), ", ");
}
@@ -239,5 +284,8 @@ public class DeviceTypePluginDAOImpl implements PluginDAO {
selectDBQueryToGetAllDevice =
"SELECT " + getDeviceTableColumnNames() + "," + deviceDAODefinition.getPrimaryKey() + " FROM "
+ deviceDAODefinition.getDeviceTableName();
+
+ deleteDBQueryForDeleteDevice = "DELETE FROM " + deviceDAODefinition.getDeviceTableName() + " WHERE "
+ + deviceDAODefinition.getPrimaryKey() + " = ?";
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PluginDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PluginDAO.java
index 47606fe6a6..a6bdbb79df 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PluginDAO.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PluginDAO.java
@@ -14,12 +14,30 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
+ *
+ * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.extensions.device.type.template.dao;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.extensions.device.type.template.exception.DeviceTypeMgtPluginException;
+
import java.util.List;
public interface PluginDAO {
@@ -31,4 +49,6 @@ public interface PluginDAO {
boolean updateDevice(Device device) throws DeviceTypeMgtPluginException;
List getAllDevices() throws DeviceTypeMgtPluginException;
+
+ boolean deleteDevice(Device device) throws DeviceTypeMgtPluginException;
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PropertyBasedPluginDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PropertyBasedPluginDAOImpl.java
index ac90fb1052..9b01e290d3 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PropertyBasedPluginDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PropertyBasedPluginDAOImpl.java
@@ -14,6 +14,23 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
+ *
+ * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.extensions.device.type.template.dao;
@@ -31,7 +48,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -201,6 +217,27 @@ public class PropertyBasedPluginDAOImpl implements PluginDAO {
}
}
+ @Override
+ public boolean deleteDevice(Device device) throws DeviceTypeMgtPluginException {
+ Connection conn;
+ PreparedStatement stmt = null;
+ try {
+ conn = deviceTypeDAOHandler.getConnection();
+ stmt = conn.prepareStatement("DELETE FROM DM_DEVICE_PROPERTIES WHERE DEVICE_IDENTIFICATION = ?");
+ stmt.setString(1, device.getDeviceIdentifier());
+ stmt.executeUpdate();
+ return true;
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting the device '" + device.getDeviceIdentifier() + "' data on"
+ + deviceType;
+ log.error(msg, e);
+ throw new DeviceTypeMgtPluginException(msg, e);
+ } finally {
+ DeviceTypeUtils.cleanupResources(stmt, null);
+ }
+ }
+
+
private String getPropertyValue(List properties, String propertyName) {
for (Device.Property property : properties) {
if (property.getName() != null && property.getName().equals(propertyName)) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
index fb22f36fee..607dc3b391 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
@@ -22,7 +22,7 @@
device-mgtorg.wso2.carbon.devicemgt
- 3.2.7-SNAPSHOT
+ 3.2.9-SNAPSHOT../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.cookie-policy/cookie-policy.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.cookie-policy/cookie-policy.hbs
index 9a2df65f5e..645ef3fb45 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.cookie-policy/cookie-policy.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.cookie-policy/cookie-policy.hbs
@@ -26,14 +26,14 @@
About Entgra IoT Server
-
Entgra IoT Server 3.5.0 is a complete solution that enables device manufacturers and enterprises to
+
Entgra IoT Server 3.6.0 is a complete solution that enables device manufacturers and enterprises to
connect and manage their devices, build apps, manage events, secure devices and data, and visualize
sensor data in a scalable manner.
It also offers a complete and secure Enterprise Mobility Management (EMM/MDM) solution that aims to
address mobile computing challenges faced by enterprises today. Supporting iOS, Android, and Windows
devices, it helps organizations deal with both Corporate Owned, Personally Enabled (COPE) and
employee-owned devices with the Bring Your Own Device (BYOD) concept.
-
Entgra IoT Server 3.5.0 comes with advanced analytics, enabling users to analyze speed, proximity, and
+
Entgra IoT Server 3.6.0 comes with advanced analytics, enabling users to analyze speed, proximity, and
geo-fencing information of devices including details of those in motion and stationary state.
Cookie Policy
@@ -45,12 +45,12 @@
apps remember things about you. Other technologies, including Web storage and identifiers associated
with your device, may be used for similar purposes. In this policy, we use the term “cookies” to
discuss all of these technologies.
-
How does Entgra IoT Server 3.5.0 process cookies?
-
Entgra IoT Server 3.5.0 uses cookies to store and retrieve information on your browser. This
+
How does Entgra IoT Server 3.6.0 process cookies?
+
Entgra IoT Server 3.6.0 uses cookies to store and retrieve information on your browser. This
information is used to provide a better user experience. Some cookies serve the purpose of allowing a
user to log in to the system, maintain sessions, and keep track of activities within the login
session.
-
Some cookies in Entgra IoT Server 3.5.0 are used to personally identify you. However, the cookie
+
Some cookies in Entgra IoT Server 3.6.0 are used to personally identify you. However, the cookie
lifetime ends once your session ends, i.e., after you log-out, or after the session expiry time has
elapsed.
Some cookies are simply used to give you a more personalised web experience, and these cannot be used
@@ -58,42 +58,42 @@
This Cookie Policy is part of the IoT Server Privacy Policy.
What does Entgra IoT Server 3.0.0 use cookies for?
-
Cookies are used for two purposes in Entgra IoT Server 3.5.0.
+
Cookies are used for two purposes in Entgra IoT Server 3.6.0.
To identify you and provide security
To provide a satisfying user experience.
Preferences
-
Entgra IoT Server 3.5.0 uses cookies to remember your settings and preferences and to auto-fill the
+
Entgra IoT Server 3.6.0 uses cookies to remember your settings and preferences and to auto-fill the
fields to make your interactions with the site easier.
These cookies can not be used to personally identify you.
Security
-
Entgra IoT Server 3.5.0 uses selected cookies to identify and prevent security risks. For example,
- Entgra IoT Server 3.5.0 may use cookies to store your session information to prevent others from
+
Entgra IoT Server 3.6.0 uses selected cookies to identify and prevent security risks. For example,
+ Entgra IoT Server 3.6.0 may use cookies to store your session information to prevent others from
changing your password without your username and password.
-
Entgra IoT Server 3.5.0 uses session cookie to maintain your active session.
-
Entgra IoT Server 3.5.0 may use a temporary cookie when performing multi-factor authentication and
+
Entgra IoT Server 3.6.0 uses session cookie to maintain your active session.
+
Entgra IoT Server 3.6.0 may use a temporary cookie when performing multi-factor authentication and
federated authentication.
-
Entgra IoT Server 3.5.0 may use permanent cookies to detect the devices you have logged in
+
Entgra IoT Server 3.6.0 may use permanent cookies to detect the devices you have logged in
previously. This is to to calculate the risk level associated with your current login
attempt. Using these cookies protects you and your account from possible attacks.
Performance
-
Entgra IoT Server 3.5.0 may use cookies to allow Remember Me functionalities.
+
Entgra IoT Server 3.6.0 may use cookies to allow Remember Me functionalities.
Analytics
-
Entgra IoT Server 3.5.0 as a product does not use cookies for analytical purposes.
+
Entgra IoT Server 3.6.0 as a product does not use cookies for analytical purposes.
Third party cookies
-
Using Entgra IoT Server 3.5.0 may cause third-party cookie to be set in your browser. Entgra IoT Server
- 3.5.0 has no control over how any of them operate. The third-party cookies that maybe set
+
Using Entgra IoT Server 3.6.0 may cause third-party cookie to be set in your browser. Entgra IoT Server
+ 3.6.0 has no control over how any of them operate. The third-party cookies that maybe set
include:
-
Any social login sites. For example, third-party cookies may be set when Entgra IoT Server 3.5.0
+
Any social login sites. For example, third-party cookies may be set when Entgra IoT Server 3.6.0
is configured to use “social” or “federated” login, and you opt to login with your “Social
Account”.
@@ -101,11 +101,11 @@
Entgra strongly advises you to refer the respective cookie policies of such sites carefully as Entgra has
no knowledge or use on these cookies.
-
What type of cookies does Entgra IoT Server 3.5.0 use?
-
Entgra IoT Server 3.5.0 uses persistent cookies and session cookies. A persistent cookie helps Entgra IS
- 3.5.0 to recognize you as an existing user so that it is easier to return to Entgra or interact with
- Entgra IS 3.5.0 without signing in again. After you sign in, a persistent cookie stays in your browser
- and will be read by Entgra IoT Server 3.5.0 when you return to Entgra IoT Server 3.5.0.
+
What type of cookies does Entgra IoT Server 3.6.0 use?
+
Entgra IoT Server 3.6.0 uses persistent cookies and session cookies. A persistent cookie helps Entgra IS
+ 3.6.0 to recognize you as an existing user so that it is easier to return to Entgra or interact with
+ Entgra IS 3.6.0 without signing in again. After you sign in, a persistent cookie stays in your browser
+ and will be read by Entgra IoT Server 3.6.0 when you return to Entgra IoT Server 3.6.0.
A session cookie is a cookie that is erased when the user closes the Web browser. The session cookie
is stored in temporarily and is not retained after the browser is closed. Session cookies do not
collect information from the user’s computer.
@@ -114,9 +114,9 @@
for websites to set cookies, you may worsen your overall user experience since it will no longer be
personalized to you. It may also stop you from saving customized settings like login information.
Most likely, disabling cookies will make it unable for you to use authentication and authorization
- functionalities offered by Entgra IoT Server 3.5.0.
+ functionalities offered by Entgra IoT Server 3.6.0.
If you have any questions or concerns regarding the use of cookies, please contact the entity or
- individuals (or their data protection officer, if applicable) running this Entgra IoT Server 3.5.0
+ individuals (or their data protection officer, if applicable) running this Entgra IoT Server 3.6.0
instance.
What are the cookies used?
@@ -150,17 +150,17 @@
Disclaimer
-
This cookie policy is only for illustrative purposes of the product Entgra IoT Server 3.5.0. The
+
This cookie policy is only for illustrative purposes of the product Entgra IoT Server 3.6.0. The
content in the policy is technically correct at the time of the product shipment. The
- entity,organization or individual that runs this Entgra IoT Server 3.5.0 instance has full authority
+ entity,organization or individual that runs this Entgra IoT Server 3.6.0 instance has full authority
and responsibility with regard to the effective Cookie Policy. Entgra, its employees, partners, and
affiliates do not have access to and do not require, store, process or control any of the data,
- including personal data contained in Entgra IoT Server 3.5.0. All data, including personal data is
- controlled and processed by the entity, organization or individual running Entgra IoT Server 3.5.0.
+ including personal data contained in Entgra IoT Server 3.6.0. All data, including personal data is
+ controlled and processed by the entity, organization or individual running Entgra IoT Server 3.6.0.
Entgra, its employees partners and affiliates are not a data processor or a data controller within the
meaning of any data privacy regulations. Entgra does not provide any warranties or undertake any
responsibility or liability in connection with the lawfulness or the manner and purposes for which
- Entgra IoT Server 3.5.0 is used by such entities, organizations or persons.
+ Entgra IoT Server 3.6.0 is used by such entities, organizations or persons.
Entgra IoT Server comes with advanced analytics, enabling users to analyze speed, proximity, and
geo-fencing information of devices including details of those in motion and stationary state.
Privacy Policy
-
This policy describes how Entgra IoT Server 3.5.0 captures your personal information, the purposes of
+
This policy describes how Entgra IoT Server 3.6.0 captures your personal information, the purposes of
collection, and information about the retention of your personal information.
Please note that this policy is for reference only, and is applicable for the software as a product.
Entgra and its developers have no access to the information held within Entgra IoT Server
- 3.5.0.Please see the Disclaimer section for more information. Entities, organisations or individuals
- controlling the use and administration of Entgra IoT Server 3.5.0 should create their own privacy
+ 3.6.0.Please see the Disclaimer section for more information. Entities, organisations or individuals
+ controlling the use and administration of Entgra IoT Server 3.6.0 should create their own privacy
policies setting out the manner in which data is controlled or processed by the respective entity,
organisation or individual.
What is personal information?
-
Entgra IoT Server 3.5.0 considers anything related to you and by which you may be identified as your
+
Entgra IoT Server 3.6.0 considers anything related to you and by which you may be identified as your
personal information.
-
Signing in to Entgra IoT Server 3.5.0
+
Signing in to Entgra IoT Server 3.6.0
Your user name (except in cases where the user name created by your employer is under
contract)
@@ -55,7 +55,7 @@
IP address used to log in
Email address
-
Enrolling a device with Entgra IoT Server 3.5.0
+
Enrolling a device with Entgra IoT Server 3.6.0
Your device ID (e.g., phone or tablet), mobile number, IMEI number, and IMSI number
Your device’s location
@@ -64,7 +64,7 @@
memory usage
-
However, Entgra IoT Server 3.5.0 also collects the following information that is not considered
+
However, Entgra IoT Server 3.6.0 also collects the following information that is not considered
personal information, but is used only for statistical purposes. The reason for this is that
this information can not be used to track you.
@@ -74,17 +74,17 @@
Operating system and generic browser information
Collection of personal information
-
Entgra IoT Server 3.5.0 collects your information only to serve your access requirements. For example:
+
Entgra IoT Server 3.6.0 collects your information only to serve your access requirements. For example:
-
Entgra IoT Server 3.5.0 uses your IP address to detect any suspicious login attempts to your
+
Entgra IoT Server 3.6.0 uses your IP address to detect any suspicious login attempts to your
account.
-
Entgra IoT Server 3.5.0 uses attributes like your first name, last name, etc., to provide a rich
+
Entgra IoT Server 3.6.0 uses attributes like your first name, last name, etc., to provide a rich
and personalized user experience.
-
Entgra IoT Server 3.5.0 uses your security questions and answers only to allow account recovery.
+
Entgra IoT Server 3.6.0 uses your security questions and answers only to allow account recovery.
Tracking Technologies
-
Entgra IoT Server 3.5.0 collects your information by:
+
Entgra IoT Server 3.6.0 collects your information by:
Collecting information from the user profile page where you enter your personal data.
Tracking your IP address with HTTP request, HTTP headers, and TCP/IP.
@@ -95,15 +95,15 @@
Use of personal information
-
Entgra IoT Server 3.5.0 will only use your personal information for the purposes for which it was
+
Entgra IoT Server 3.6.0 will only use your personal information for the purposes for which it was
collected (or for a use identified as consistent with that purpose).
-
Entgra IoT Server 3.5.0 uses your personal information only for the following purposes.
+
Entgra IoT Server 3.6.0 uses your personal information only for the following purposes.
-
To provide you with a personalized user experience. Entgra IoT Server 3.5.0 uses your name and
+
To provide you with a personalized user experience. Entgra IoT Server 3.6.0 uses your name and
uploaded profile pictures for this purpose.
To protect your account from unauthorized access or potential hacking attempts. Entgra IoT Server
- 3.5.0 uses HTTP or TCP/IP Headers for this purpose.
+ 3.6.0 uses HTTP or TCP/IP Headers for this purpose.
This includes:
@@ -114,10 +114,10 @@
Derive statistical data for analytical purposes on system performance improvements. Entgra IoT
- Server 3.5.0 will not keep any personal information after statistical calculations. Therefore,
+ Server 3.6.0 will not keep any personal information after statistical calculations. Therefore,
the statistical report has no means of identifying an individual person.
-
Entgra IoT Server 3.5.0 may use:
+
Entgra IoT Server 3.6.0 may use:
IP Address to derive geographic information
@@ -126,28 +126,28 @@
Disclosure of personal information
-
Entgra IoT Server 3.5.0 only discloses personal information to the relevant applications (also known as
- “Service Providers”) that are registered with Entgra IoT Server 3.5.0. These applications are
+
Entgra IoT Server 3.6.0 only discloses personal information to the relevant applications (also known as
+ “Service Providers”) that are registered with Entgra IoT Server 3.6.0. These applications are
registered by the identity administrator of your entity or organization. Personal information is
disclosed only for the purposes for which it was collected (or for a use identified as consistent
with that purpose) as controlled by such Service Providers, unless you have consented otherwise or
where it is required by law.
Legal process
-
Please note that the organisation, entity or individual running Entgra IoT Server 3.5.0 may be
+
Please note that the organisation, entity or individual running Entgra IoT Server 3.6.0 may be
compelled to disclose your personal information with or without your consent when it is required by
law following due and lawful process.
Storage of personal information
Where your personal information is stored
-
Entgra IoT Server 3.5.0 stores your personal information in secured databases. Entgra IoT Server 3.5.0
+
Entgra IoT Server 3.6.0 stores your personal information in secured databases. Entgra IoT Server 3.6.0
exercises proper industry accepted security measures to protect the database where your personal
- information is held.Entgra IoT Server 3.5.0 as a product does not transfer or share your data with any
+ information is held.Entgra IoT Server 3.6.0 as a product does not transfer or share your data with any
third parties or locations.
-
Entgra IoT Server 3.5.0 may use encryption to keep your personal data with an added level of
+
Entgra IoT Server 3.6.0 may use encryption to keep your personal data with an added level of
security.
How long your personal information is retained
-
Entgra IoT Server 3.5.0 retains your personal data as long as you are an active user of our system. You
+
Entgra IoT Server 3.6.0 retains your personal data as long as you are an active user of our system. You
can update your personal data at any time using the given self-care user portals.
-
Entgra IoT Server 3.5.0 may keep hashed secrets to provide you with an added level of security. This
+
Entgra IoT Server 3.6.0 may keep hashed secrets to provide you with an added level of security. This
includes:
Current password
@@ -157,15 +157,15 @@
You can request the administrator to delete your account. The administrator is the administrator of
the tenant you are registered under, or the super-administrator if you do not use the tenant
feature.
-
Additionally, you can request to anonymize all traces of your activities that Entgra IoT Server 3.5.0
+
Additionally, you can request to anonymize all traces of your activities that Entgra IoT Server 3.6.0
may have retained in logs, databases or analytical storage.
More information
Changes to this policy
-
Upgraded versions of Entgra IoT Server 3.5.0 may contain changes to this policy. Revisions to this
+
Upgraded versions of Entgra IoT Server 3.6.0 may contain changes to this policy. Revisions to this
policy will be packaged within such upgrades and would only apply to users who choose to use upgraded
versions.
Your choices
-
If you are already have an user account within Entgra IoT Server 3.5.0 ; you have the right to
+
If you are already have an user account within Entgra IoT Server 3.6.0 ; you have the right to
deactivate your account if you find that this privacy policy is unacceptable to you.
If you do not have an account and you do not agree with our privacy policy, you can chose not to
create one.
Entgra, its employees, partners, and affiliates do not have access to and do not require, store,
- process or control any of the data, including personal data contained in Entgra IoT Server 3.5.0. All
+ process or control any of the data, including personal data contained in Entgra IoT Server 3.6.0. All
data, including personal data is controlled and processed by the entity or individual running Entgra
- IoT Server 3.5.0. Entgra, its employees partners and affiliates are not a data processor or a data
+ IoT Server 3.6.0. Entgra, its employees partners and affiliates are not a data processor or a data
controller within the meaning of any data privacy regulations. Entgra does not provide any warranties
or undertake any responsibility or liability in connection with the lawfulness or the manner and
- purposes for which Entgra IoT Server 3.5.0 is used by such entities or persons.
+ purposes for which Entgra IoT Server 3.6.0 is used by such entities or persons.
This privacy policy is for the informational purposes of the entity or persons running Entgra IoT
- Server 3.5.0 and sets out the processes and functionality contained within Entgra IoT Server 3.5.0
+ Server 3.6.0 and sets out the processes and functionality contained within Entgra IoT Server 3.6.0
regarding personal data protection. It is the responsibility of entities and persons running Entgra IoT
- Server 3.5.0 to create and administer its own rules and processes governing users’ personal data,
+ Server 3.6.0 to create and administer its own rules and processes governing users’ personal data,
Please note that the creation of such rules and processes may change the use, storage and disclosure
policies contained herein. Therefore users should consult the entity or persons running Entgra IoT
- Server 3.5.0 for its own privacy policy for details governing users’ personal data.
+ Server 3.6.0 for its own privacy policy for details governing users’ personal data.
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.footer/footer.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.footer/footer.hbs
index 5d639f1191..341753d2c4 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.footer/footer.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.footer/footer.hbs
@@ -17,8 +17,8 @@
}}
{{#zone "footer"}}