01
- Connect Android device to network.
+ Connect Android device to network.
02
- Start Android Sense app in your device.
+ Start Android Sense app in your device.
03
- Fill login form with the credentials.
- (Use server URL as [ https://<WSO2_IoT_SERVER_HOST>:<
- HTTPS_SERVER_PORT> ] and click on
+ Fill login form with the credentials.
+ (Use server URL as [ https://<WSO2_IoT_SERVER_HOST>:<
+ HTTPS_SERVER_PORT> ] and click on
Register Device button.)
@@ -169,7 +169,7 @@
04
- Once the device is enrolled, click on [+] button to
+ Once the device is enrolled, click on [+] button to
select the sensors.
@@ -178,7 +178,7 @@
@@ -206,14 +206,14 @@
- You can select any one of your connected devices for available
+ You can select any one of your connected devices for available
operations and Real-Time data monitoring.
- For historical analytics of sensor data navigate to device
+ For historical analytics of sensor data navigate to device
analytics page.
@@ -237,7 +237,7 @@
- Add your new mobile device to {{@app.conf.appName}}
+ Add your new mobile device to {{@app.conf.appName}}
diff --git a/components/iot-plugins/androidsense-plugin/pom.xml b/components/iot-plugins/androidsense-plugin/pom.xml
index 4438378f0..aab94be4a 100644
--- a/components/iot-plugins/androidsense-plugin/pom.xml
+++ b/components/iot-plugins/androidsense-plugin/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgt-pluginsiot-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
@@ -35,7 +35,6 @@
org.wso2.carbon.device.mgt.iot.androidsense.analyticsorg.wso2.carbon.device.mgt.iot.androidsense.api
- org.wso2.carbon.device.mgt.iot.androidsense.pluginorg.wso2.carbon.device.mgt.iot.androidsense.ui
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml
index 17e0fed26..fc3dce0ce 100644
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml
+++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml
@@ -21,7 +21,7 @@
arduino-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml
index 3186c36b6..f837bd6d6 100644
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml
+++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml
@@ -21,7 +21,7 @@
arduino-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
@@ -109,13 +109,6 @@
provided
-
-
- org.eclipse.paho
- org.eclipse.paho.client.mqttv3
- provided
-
-
org.apache.httpcomponents
@@ -123,16 +116,6 @@
4.1provided
-
- org.wso2.carbon.devicemgt-plugins
- org.wso2.carbon.device.mgt.iot
- provided
-
-
- org.wso2.carbon.devicemgt-plugins
- org.wso2.carbon.device.mgt.iot.arduino.plugin
- provided
-
@@ -153,19 +136,18 @@
jsr311-apiprovided
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.apimgt.webapp.publisher
- provided
- org.wso2.carbon.analyticsorg.wso2.carbon.analytics.apiprovided
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.extensions
+ provided
+
-
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java
index a2fae963b..acc6adae6 100644
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java
+++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java
@@ -34,11 +34,11 @@ import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants;
+import org.wso2.carbon.device.mgt.iot.arduino.service.impl.constants.ArduinoConstants;
import org.wso2.carbon.device.mgt.iot.arduino.service.impl.dto.SensorRecord;
import org.wso2.carbon.device.mgt.iot.arduino.service.impl.util.APIUtil;
+import org.wso2.carbon.device.mgt.iot.arduino.service.impl.util.ZipArchive;
import org.wso2.carbon.device.mgt.iot.arduino.service.impl.util.ZipUtil;
-import org.wso2.carbon.device.mgt.iot.util.ZipArchive;
import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
@@ -54,7 +54,6 @@ import java.util.*;
public class ArduinoServiceImpl implements ArduinoService {
private static Log log = LogFactory.getLog(ArduinoServiceImpl.class);
- private static Map> internalControlsQueue = new HashMap<>();
private static final String KEY_TYPE = "PRODUCTION";
private static ApiApplicationKey apiApplicationKey;
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/constants/ArduinoConstants.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java
similarity index 76%
rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/constants/ArduinoConstants.java
rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java
index 1d916e136..8a438574e 100644
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/constants/ArduinoConstants.java
+++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java
@@ -16,13 +16,10 @@
* under the License.
*/
-package org.wso2.carbon.device.mgt.iot.arduino.plugin.constants;
+package org.wso2.carbon.device.mgt.iot.arduino.service.impl.constants;
public class ArduinoConstants {
public final static String DEVICE_TYPE = "arduino";
- public final static String DEVICE_PLUGIN_DEVICE_NAME = "DEVICE_NAME";
- public final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
- public final static String DEVICE_PLUGIN_DEVICE_ID = "ARDUINO_DEVICE_ID";
public static final String URL_PREFIX = "http://";
//sensor events summerized table name
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java
index 5e48e57c9..5fe3aae32 100644
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java
+++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java
@@ -7,7 +7,7 @@ import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDrillDownRequest;
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
-import org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceUtils;
+import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
import org.wso2.carbon.analytics.datasource.commons.Record;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
@@ -81,7 +81,7 @@ public class APIUtil {
sortByFields);
List recordIds = getRecordIds(resultEntries);
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
- Map sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords(
+ Map sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords(
analyticsDataAPI, response));
List sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
return sortedSensorData;
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java
index bf9f0dcc2..4d1087345 100644
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java
+++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java
@@ -25,11 +25,9 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClients;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
-import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants;
+import org.wso2.carbon.device.mgt.iot.arduino.service.impl.constants.ArduinoConstants;
+
import javax.ws.rs.HttpMethod;
import java.io.BufferedReader;
import java.io.IOException;
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/ZipArchive.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipArchive.java
similarity index 94%
rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/ZipArchive.java
rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipArchive.java
index 31e5bf3cb..1048e8769 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/ZipArchive.java
+++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipArchive.java
@@ -16,7 +16,7 @@
* under the License.
*/
-package org.wso2.carbon.device.mgt.iot.util;
+package org.wso2.carbon.device.mgt.iot.arduino.service.impl.util;
import java.io.File;
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java
index 99b381a27..414b24847 100644
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java
+++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java
@@ -18,20 +18,38 @@
package org.wso2.carbon.device.mgt.iot.arduino.service.impl.util;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.base.MultitenantConstants;
+import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
-import org.wso2.carbon.device.mgt.iot.util.Utils;
-import org.wso2.carbon.device.mgt.iot.util.ZipArchive;
import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.NetworkUtils;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.SocketException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
/**
* This is used to create a zip file that includes the necessary configuration required for the agent.
@@ -40,6 +58,8 @@ public class ZipUtil {
private static final String HTTP_PORT_PROPERTY = "httpPort";
private static final String CONFIG_TYPE = "general";
+ private static final Log log = LogFactory.getLog(ZipUtil.class);
+ public static final String HOST_NAME = "HostName";
public ZipArchive createZipFile(String owner, String tenantDomain, String deviceType,
String deviceId, String deviceName, String token,
@@ -52,7 +72,7 @@ public class ZipUtil {
String iotServerIP;
try {
- iotServerIP = Utils.getServerUrl();
+ iotServerIP = getServerUrl();
String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY);
Map contextParams = new HashMap<>();
@@ -88,7 +108,7 @@ public class ZipUtil {
contextParams.put("DEVICE_REFRESH_TOKEN", refreshToken);
ZipArchive zipFile;
- zipFile = Utils.getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName);
+ zipFile = getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName);
return zipFile;
} catch (IOException e) {
throw new DeviceManagementException("Zip File Creation Failed", e);
@@ -96,4 +116,227 @@ public class ZipUtil {
throw new DeviceManagementException("Failed to retrieve configuration", e);
}
}
+
+ private static String getServerUrl() {
+ String hostName = ServerConfiguration.getInstance().getFirstProperty(HOST_NAME);
+ try {
+ if (hostName == null) {
+ hostName = NetworkUtils.getLocalHostname();
+ }
+ } catch (SocketException e) {
+ hostName = "localhost";
+ log.warn("Failed retrieving the hostname, therefore set to localhost", e);
+ }
+ return hostName;
+ }
+
+ private static ZipArchive getSketchArchive(String archivesPath, String templateSketchPath, Map contextParams
+ , String zipFileName)
+ throws DeviceManagementException, IOException {
+ String sketchPath = CarbonUtils.getCarbonHome() + File.separator + templateSketchPath;
+ FileUtils.deleteDirectory(new File(archivesPath));//clear directory
+ FileUtils.deleteDirectory(new File(archivesPath + ".zip"));//clear zip
+ if (!new File(archivesPath).mkdirs()) { //new dir
+ String message = "Could not create directory at path: " + archivesPath;
+ log.error(message);
+ throw new DeviceManagementException(message);
+ }
+ zipFileName = zipFileName + ".zip";
+ try {
+ Map> properties = getProperties(sketchPath + File.separator + "sketch" + ".properties");
+ List templateFiles = properties.get("templates");
+
+ for (String templateFile : templateFiles) {
+ parseTemplate(templateSketchPath + File.separator + templateFile, archivesPath + File.separator + templateFile,
+ contextParams);
+ }
+
+ templateFiles.add("sketch.properties"); // ommit copying the props file
+ copyFolder(new File(sketchPath), new File(archivesPath), templateFiles);
+ createZipArchive(archivesPath);
+ FileUtils.deleteDirectory(new File(archivesPath));
+ File zip = new File(archivesPath + ".zip");
+ return new ZipArchive(zipFileName, zip);
+ } catch (IOException ex) {
+ throw new DeviceManagementException(
+ "Error occurred when trying to read property " + "file sketch.properties", ex);
+ }
+ }
+
+ private static Map> getProperties(String propertyFilePath) throws IOException {
+ Properties prop = new Properties();
+ InputStream input = null;
+
+ try {
+ input = new FileInputStream(propertyFilePath);
+ // load a properties file
+ prop.load(input);
+ Map> properties = new HashMap>();
+
+ String templates = prop.getProperty("templates");
+ List list = new ArrayList(Arrays.asList(templates.split(",")));
+ properties.put("templates", list);
+
+ final String filename = prop.getProperty("zipfilename");
+ list = new ArrayList() {{
+ add(filename);
+ }};
+ properties.put("zipfilename", list);
+ return properties;
+
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (IOException e) {
+ log.error("Failed closing connection", e);
+ }
+ }
+ }
+ }
+
+ private static void parseTemplate(String srcFile, String dstFile, Map contextParams) throws IOException {
+ //read from file
+ FileInputStream inputStream = null;
+ FileOutputStream outputStream = null;
+ try {
+ inputStream = new FileInputStream(srcFile);
+ outputStream = new FileOutputStream(dstFile);
+ String content = IOUtils.toString(inputStream, StandardCharsets.UTF_8.toString());
+ Iterator iterator = contextParams.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry mapEntry = (Map.Entry) iterator.next();
+ content = content.replaceAll("\\$\\{" + mapEntry.getKey() + "\\}", mapEntry.getValue().toString());
+ }
+ IOUtils.write(content, outputStream, StandardCharsets.UTF_8.toString());
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ }
+ }
+
+ private static void copyFolder(File src, File dest, List excludeFileNames) throws IOException {
+
+ if (src.isDirectory()) {
+ //if directory not exists, create it
+ if (!dest.exists() && !dest.mkdirs()) {
+ String message = "Could not create directory at path: " + dest;
+ log.error(message);
+ throw new IOException(message);
+ }
+ //list all the directory contents
+ String files[] = src.list();
+
+ if (files == null) {
+ log.warn("There are no files insides the directory " + src.getAbsolutePath());
+ return;
+ }
+
+ for (String file : files) {
+ //construct the src and dest file structure
+ File srcFile = new File(src, file);
+ File destFile = new File(dest, file);
+ //recursive copy
+ copyFolder(srcFile, destFile, excludeFileNames);
+ }
+
+ } else {
+ for (String fileName : excludeFileNames) {
+ if (src.getName().equals(fileName)) {
+ return;
+ }
+ }
+ //if file, then copy it
+ //Use bytes stream to support all file types
+ InputStream in = null;
+ OutputStream out = null;
+
+ try {
+ in = new FileInputStream(src);
+ out = new FileOutputStream(dest);
+
+ byte[] buffer = new byte[1024];
+
+ int length;
+ //copy the file content in bytes
+ while ((length = in.read(buffer)) > 0) {
+ out.write(buffer, 0, length);
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+ }
+
+ private static boolean createZipArchive(String srcFolder) throws IOException {
+ BufferedInputStream origin = null;
+ ZipOutputStream out = null;
+
+ try {
+ final int BUFFER = 2048;
+ FileOutputStream dest = new FileOutputStream(new File(srcFolder + ".zip"));
+ out = new ZipOutputStream(new BufferedOutputStream(dest));
+ byte data[] = new byte[BUFFER];
+ File subDir = new File(srcFolder);
+ String subdirList[] = subDir.list();
+ if (subdirList == null) {
+ log.warn("The sub directory " + subDir.getAbsolutePath() + " is empty");
+ return false;
+ }
+ for (String sd : subdirList) {
+ // get a list of files from current directory
+ File f = new File(srcFolder + "/" + sd);
+ if (f.isDirectory()) {
+ String files[] = f.list();
+
+ if (files == null) {
+ log.warn("The current directory " + f.getAbsolutePath() + " is empty. Has no files");
+ return false;
+ }
+
+ for (int i = 0; i < files.length; i++) {
+ FileInputStream fi = new FileInputStream(srcFolder + "/" + sd + "/" + files[i]);
+ origin = new BufferedInputStream(fi, BUFFER);
+ ZipEntry entry = new ZipEntry(sd + "/" + files[i]);
+ out.putNextEntry(entry);
+ int count;
+ while ((count = origin.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ out.flush();
+ }
+
+ }
+ } else //it is just a file
+ {
+ FileInputStream fi = new FileInputStream(f);
+ origin = new BufferedInputStream(fi, BUFFER);
+ ZipEntry entry = new ZipEntry(sd);
+ out.putNextEntry(entry);
+ int count;
+ while ((count = origin.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ out.flush();
+ }
+ }
+ }
+ out.flush();
+ } finally {
+ if (origin != null) {
+ origin.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ }
+ return true;
+ }
}
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/pom.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/pom.xml
deleted file mode 100644
index 9ae3274b3..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/pom.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-
-
-
-
- arduino-plugin
- org.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
- ../pom.xml
-
-
- 4.0.0
- org.wso2.carbon.device.mgt.iot.arduino.plugin
- bundle
- WSO2 Carbon - IoT Server Arduino Management Plugin
- WSO2 Carbon - Arduino Management/Control Plugin Implementation
- http://wso2.org
-
-
-
-
- org.apache.felix
- maven-scr-plugin
-
-
- maven-compiler-plugin
-
- 1.7
- 1.7
-
- 2.3.2
-
-
- org.apache.felix
- maven-bundle-plugin
- 1.4.0
- true
-
-
- ${project.artifactId}
- ${project.artifactId}
- ${carbon.devicemgt.plugins.version}
- IoT Server Arduino Impl Bundle
- org.wso2.carbon.device.mgt.iot.arduino.plugin.internal
-
- org.osgi.framework,
- org.osgi.service.component,
- org.apache.commons.logging,
- javax.naming;resolution:=optional,
- javax.sql;resolution:=optional,
- org.wso2.carbon.device.mgt.common.*,
- org.wso2.carbon.device.mgt.common,
- org.wso2.carbon.device.mgt.iot.*,
- org.wso2.carbon.device.mgt.extensions.feature.mgt.*,
- org.wso2.carbon.utils.*,
- org.wso2.carbon.ndatasource.core,
- org.wso2.carbon.device.mgt.iot.devicetype.*
-
-
-
- !org.wso2.carbon.device.mgt.iot.arduino.plugin.internal,
- org.wso2.carbon.device.mgt.iot.arduino.plugin.*
-
-
-
-
-
-
-
-
-
- org.eclipse.osgi
- org.eclipse.osgi
-
-
- org.eclipse.osgi
- org.eclipse.osgi.services
-
-
- org.wso2.carbon
- org.wso2.carbon.logging
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.common
-
-
- org.wso2.carbon
- org.wso2.carbon.ndatasource.core
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.extensions
-
-
- org.wso2.carbon
- org.wso2.carbon.utils
-
-
- org.wso2.carbon.devicemgt-plugins
- org.wso2.carbon.device.mgt.iot
-
-
-
\ No newline at end of file
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/exception/ArduinoDeviceMgtPluginException.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/exception/ArduinoDeviceMgtPluginException.java
deleted file mode 100644
index 93dc15683..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/exception/ArduinoDeviceMgtPluginException.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.wso2.carbon.device.mgt.iot.arduino.plugin.exception;
-
-
-public class ArduinoDeviceMgtPluginException extends Exception{
-
- private String errorMessage;
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- public ArduinoDeviceMgtPluginException(String msg, Exception nestedEx) {
- super(msg, nestedEx);
- setErrorMessage(msg);
- }
-
- public ArduinoDeviceMgtPluginException(String message, Throwable cause) {
- super(message, cause);
- setErrorMessage(message);
- }
-
- public ArduinoDeviceMgtPluginException(String msg) {
- super(msg);
- setErrorMessage(msg);
- }
-
- public ArduinoDeviceMgtPluginException() {
- super();
- }
-
- public ArduinoDeviceMgtPluginException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManager.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManager.java
deleted file mode 100644
index c3d80d8d6..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManager.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.arduino.plugin.impl;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.DeviceManager;
-import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
-import org.wso2.carbon.device.mgt.common.FeatureManager;
-import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
-import org.wso2.carbon.device.mgt.common.license.mgt.License;
-import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.exception.ArduinoDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.dao.ArduinoDAOUtil;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.feature.ArduinoFeatureManager;
-import java.util.List;
-
-
-/**
- * This represents the Arduino implementation of DeviceManagerService.
- */
-public class ArduinoManager implements DeviceManager {
-
- private static final ArduinoDAOUtil arduinoDAO = new ArduinoDAOUtil();
- private static final Log log = LogFactory.getLog(ArduinoManager.class);
- private ArduinoFeatureManager arduinoFeatureManager = new ArduinoFeatureManager();
-
- @Override
- public FeatureManager getFeatureManager() {
- return arduinoFeatureManager;
- }
-
- @Override
- public boolean saveConfiguration(PlatformConfiguration PlatformConfiguration)
- throws DeviceManagementException {
- //TODO implement this
- return false;
- }
-
- @Override
- public PlatformConfiguration getConfiguration() throws DeviceManagementException {
- //TODO implement this
- return null;
- }
-
- @Override
- public boolean enrollDevice(Device device) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Enrolling a new Arduino device : " + device.getDeviceIdentifier());
- }
- ArduinoDAOUtil.beginTransaction();
- status = arduinoDAO.getDeviceDAO().addDevice(device);
- ArduinoDAOUtil.commitTransaction();
- } catch (ArduinoDeviceMgtPluginException e) {
- try {
- ArduinoDAOUtil.rollbackTransaction();
- } catch (ArduinoDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the device enrol transaction :" + device.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg = "Error while enrolling the Arduino device : " + device.getDeviceIdentifier();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean modifyEnrollment(Device device) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Modifying the Arduino device enrollment data");
- }
- ArduinoDAOUtil.beginTransaction();
- status = arduinoDAO.getDeviceDAO().updateDevice(device);
- ArduinoDAOUtil.commitTransaction();
- } catch (ArduinoDeviceMgtPluginException e) {
- try {
- ArduinoDAOUtil.rollbackTransaction();
- } catch (ArduinoDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the update device transaction :" + device.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg = "Error while updating the enrollment of the Arduino device : " +
- device.getDeviceIdentifier();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Dis-enrolling Arduino device : " + deviceId);
- }
- ArduinoDAOUtil.beginTransaction();
- status = arduinoDAO.getDeviceDAO().deleteDevice(deviceId.getId());
- ArduinoDAOUtil.commitTransaction();
- } catch (ArduinoDeviceMgtPluginException e) {
- try {
- ArduinoDAOUtil.rollbackTransaction();
- } catch (ArduinoDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg = "Error while removing the Arduino device : " + deviceId.getId();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
- boolean isEnrolled = false;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Checking the enrollment of Arduino device : " + deviceId.getId());
- }
- Device iotDevice = arduinoDAO.getDeviceDAO().getDevice(deviceId.getId());
- if (iotDevice != null) {
- isEnrolled = true;
- }
- } catch (ArduinoDeviceMgtPluginException e) {
- String msg = "Error while checking the enrollment status of Arduino device : " +
- deviceId.getId();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return isEnrolled;
- }
-
- @Override
- public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
- return true;
- }
-
- @Override
- public boolean setActive(DeviceIdentifier deviceId, boolean status)
- throws DeviceManagementException {
- return true;
- }
-
- @Override
- public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
- Device device;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Getting the details of Arduino device : " + deviceId.getId());
- }
- device = arduinoDAO.getDeviceDAO().getDevice(deviceId.getId());
- } catch (ArduinoDeviceMgtPluginException e) {
- String msg = "Error while fetching the Arduino device : " + deviceId.getId();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return device;
- }
-
- @Override
- public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
- throws DeviceManagementException {
- return true;
- }
-
- public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
- EnrolmentInfo.Status status) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public License getLicense(String s) throws LicenseManagementException {
- return null;
- }
-
- @Override
- public void addLicense(License license) throws LicenseManagementException {
-
- }
-
- @Override
- public boolean requireDeviceAuthorization() {
- return false;
- }
-
- @Override
- public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug(
- "updating the details of Arduino device : " + deviceIdentifier);
- }
- ArduinoDAOUtil.beginTransaction();
- status = arduinoDAO.getDeviceDAO().updateDevice(device);
- ArduinoDAOUtil.commitTransaction();
- } catch (ArduinoDeviceMgtPluginException e) {
- try {
- ArduinoDAOUtil.rollbackTransaction();
- } catch (ArduinoDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the update device info transaction :" + device.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg =
- "Error while updating the Arduino device : " + deviceIdentifier;
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public List getAllDevices() throws DeviceManagementException {
- List devices;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Fetching the details of all Arduino devices");
- }
- devices = arduinoDAO.getDeviceDAO().getAllDevices();
- } catch (ArduinoDeviceMgtPluginException e) {
- String msg = "Error while fetching all Arduino devices.";
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return devices;
- }
-
-}
\ No newline at end of file
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManagerService.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManagerService.java
deleted file mode 100644
index 743e9fb48..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManagerService.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.arduino.plugin.impl;
-
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.DeviceManager;
-import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
-import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
-import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
-import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants;
-
-public class ArduinoManagerService implements DeviceManagementService {
-
- private DeviceManager deviceManager;
- private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
-
- @Override
- public String getType() {
- return ArduinoConstants.DEVICE_TYPE;
- }
-
- @Override
- public void init() throws DeviceManagementException {
- deviceManager=new ArduinoManager();
-
- }
-
- @Override
- public DeviceManager getDeviceManager() {
- return deviceManager;
- }
-
- @Override
- public ApplicationManager getApplicationManager() {
- return null;
- }
-
- @Override
- public ProvisioningConfig getProvisioningConfig() {
- return new ProvisioningConfig(DEVICE_TYPE_PROVIDER_DOMAIN, false);
- }
-
- @Override
- public PushNotificationConfig getPushNotificationConfig() {
- return null;
- }
-
-}
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/ArduinoDAOUtil.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/ArduinoDAOUtil.java
deleted file mode 100644
index 2d83b966b..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/ArduinoDAOUtil.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.dao;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.exception.ArduinoDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.internal.ArduinoManagementDataHolder;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-public class ArduinoDAOUtil {
-
- private static final Log log = LogFactory.getLog(ArduinoDAOUtil.class);
- static DataSource dataSource;
- private static ThreadLocal currentConnection = new ThreadLocal();
-
- public ArduinoDAOUtil() {
- initArduinoDAO();
- }
-
- public static void initArduinoDAO() {
- DeviceManagementConfiguration deviceManagementConfiguration = ArduinoManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(ArduinoConstants.DEVICE_TYPE,
- ArduinoConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- String datasource = deviceManagementConfiguration.getDeviceManagementConfigRepository().getDataSourceConfig()
- .getJndiLookupDefinition().getJndiName();
- try {
- Context ctx = new InitialContext();
- dataSource = (DataSource) ctx.lookup(datasource);
- } catch (NamingException e) {
- log.error("Error while looking up the data source: " + datasource, e);
- }
- }
-
- public ArduinoDeviceDAO getDeviceDAO() {
- return new ArduinoDeviceDAO();
- }
-
- public static void beginTransaction() throws ArduinoDeviceMgtPluginException {
- try {
- Connection conn = dataSource.getConnection();
- conn.setAutoCommit(false);
- currentConnection.set(conn);
- } catch (SQLException e) {
- throw new ArduinoDeviceMgtPluginException("Error occurred while retrieving datasource connection", e);
- }
- }
-
- public static Connection getConnection() throws ArduinoDeviceMgtPluginException {
- if (currentConnection.get() == null) {
- try {
- currentConnection.set(dataSource.getConnection());
- } catch (SQLException e) {
- throw new ArduinoDeviceMgtPluginException("Error occurred while retrieving data source connection", e);
- }
- }
- return currentConnection.get();
- }
-
- public static void commitTransaction() throws ArduinoDeviceMgtPluginException {
- try {
- Connection conn = currentConnection.get();
- if (conn != null) {
- conn.commit();
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Datasource connection associated with the current thread is null, hence commit "
- + "has not been attempted");
- }
- }
- } catch (SQLException e) {
- throw new ArduinoDeviceMgtPluginException("Error occurred while committing the transaction", e);
- } finally {
- closeConnection();
- }
- }
-
- public static void closeConnection() throws ArduinoDeviceMgtPluginException {
-
- Connection con = currentConnection.get();
- if (con != null) {
- try {
- con.close();
- } catch (SQLException e) {
- log.error("Error occurred while close the connection");
- }
- }
- currentConnection.remove();
- }
-
- public static void rollbackTransaction() throws ArduinoDeviceMgtPluginException {
- try {
- Connection conn = currentConnection.get();
- if (conn != null) {
- conn.rollback();
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Datasource connection associated with the current thread is null, hence rollback "
- + "has not been attempted");
- }
- }
- } catch (SQLException e) {
- throw new ArduinoDeviceMgtPluginException("Error occurred while rollback the transaction", e);
- } finally {
- closeConnection();
- }
- }
-}
\ No newline at end of file
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/ArduinoDeviceDAO.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/ArduinoDeviceDAO.java
deleted file mode 100644
index 411f88e10..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/ArduinoDeviceDAO.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.dao;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.exception.ArduinoDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.util.ArduinoUtils;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Implements CRUD for arduino Devices.
- */
-public class ArduinoDeviceDAO {
-
-
- private static final Log log = LogFactory.getLog(ArduinoDeviceDAO.class);
-
- public Device getDevice(String deviceId) throws ArduinoDeviceMgtPluginException {
- Connection conn = null;
- PreparedStatement stmt = null;
- Device device = null;
- ResultSet resultSet = null;
- try {
- conn = ArduinoDAOUtil.getConnection();
- String selectDBQuery =
- "SELECT ARDUINO_DEVICE_ID, DEVICE_NAME FROM ARDUINO_DEVICE WHERE ARDUINO_DEVICE_ID = ?";
- stmt = conn.prepareStatement(selectDBQuery);
- stmt.setString(1, deviceId);
- resultSet = stmt.executeQuery();
-
- if (resultSet.next()) {
- device = new Device();
- device.setName(resultSet.getString(ArduinoConstants.DEVICE_PLUGIN_DEVICE_NAME));
- if (log.isDebugEnabled()) {
- log.debug("Arduino device " + deviceId + " data has been fetched from " +
- "Arduino database.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while fetching Arduino device : '" + deviceId + "'";
- log.error(msg, e);
- throw new ArduinoDeviceMgtPluginException(msg, e);
- } finally {
- ArduinoUtils.cleanupResources(stmt, resultSet);
- ArduinoDAOUtil.closeConnection();
- }
- return device;
- }
-
- public boolean addDevice(Device iotDevice) throws ArduinoDeviceMgtPluginException {
- boolean status = false;
- Connection conn = null;
- PreparedStatement stmt = null;
- try {
- conn = ArduinoDAOUtil.getConnection();
- String createDBQuery =
- "INSERT INTO ARDUINO_DEVICE(ARDUINO_DEVICE_ID, DEVICE_NAME) VALUES (?, ?)";
-
- stmt = conn.prepareStatement(createDBQuery);
- stmt.setString(1, iotDevice.getDeviceIdentifier());
- stmt.setString(2,iotDevice.getName());
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Arduino device " + iotDevice.getDeviceIdentifier() + " data has been" +
- " added to the Arduino database.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while adding the Arduino device '" +
- iotDevice.getDeviceIdentifier() + "' to the Arduino db.";
- log.error(msg, e);
- throw new ArduinoDeviceMgtPluginException(msg, e);
- } finally {
- ArduinoUtils.cleanupResources(stmt, null);
- }
- return status;
- }
-
- public boolean updateDevice(Device iotDevice) throws ArduinoDeviceMgtPluginException {
- boolean status = false;
- Connection conn = null;
- PreparedStatement stmt = null;
- try {
- conn = ArduinoDAOUtil.getConnection();
- String updateDBQuery =
- "UPDATE ARDUINO_DEVICE SET DEVICE_NAME = ? WHERE ARDUINO_DEVICE_ID = ?";
-
- stmt = conn.prepareStatement(updateDBQuery);
- stmt.setString(1, iotDevice.getName());
- stmt.setString(2, iotDevice.getDeviceIdentifier());
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Arduino device " + iotDevice.getDeviceIdentifier() + " data has been" +
- " modified.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while modifying the Arduino device '" + iotDevice.getDeviceIdentifier()
- + "' data.";
- log.error(msg, e);
- throw new ArduinoDeviceMgtPluginException(msg, e);
- } finally {
- ArduinoUtils.cleanupResources(stmt, null);
- }
- return status;
- }
-
- public boolean deleteDevice(String iotDeviceId) throws ArduinoDeviceMgtPluginException {
- boolean status = false;
- Connection conn = null;
- PreparedStatement stmt = null;
- try {
- conn = ArduinoDAOUtil.getConnection();
- String deleteDBQuery =
- "DELETE FROM ARDUINO_DEVICE WHERE ARDUINO_DEVICE_ID = ?";
- stmt = conn.prepareStatement(deleteDBQuery);
- stmt.setString(1, iotDeviceId);
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Arduino device " + iotDeviceId + " data has deleted" +
- " from the Arduino database.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while deleting Arduino device " + iotDeviceId;
- log.error(msg, e);
- throw new ArduinoDeviceMgtPluginException(msg, e);
- } finally {
- ArduinoUtils.cleanupResources(stmt, null);
- }
- return status;
- }
-
- public List getAllDevices() throws ArduinoDeviceMgtPluginException {
-
- Connection conn = null;
- PreparedStatement stmt = null;
- ResultSet resultSet = null;
- Device device;
- List devices = new ArrayList();
- try {
- conn = ArduinoDAOUtil.getConnection();
- String selectDBQuery =
- "SELECT ARDUINO_DEVICE_ID, DEVICE_NAME FROM ARDUINO_DEVICE";
- stmt = conn.prepareStatement(selectDBQuery);
- resultSet = stmt.executeQuery();
- while (resultSet.next()) {
- device = new Device();
- device.setDeviceIdentifier(resultSet.getString(ArduinoConstants.DEVICE_PLUGIN_DEVICE_ID));
- device.setName(resultSet.getString(ArduinoConstants.DEVICE_PLUGIN_DEVICE_NAME));
- }
- if (log.isDebugEnabled()) {
- log.debug("All Arduino device details have fetched from Arduino database.");
- }
- return devices;
- } catch (SQLException e) {
- String msg = "Error occurred while fetching all Arduino device data'";
- log.error(msg, e);
- throw new ArduinoDeviceMgtPluginException(msg, e);
- } finally {
- ArduinoUtils.cleanupResources(stmt, resultSet);
- ArduinoDAOUtil.closeConnection();
- }
- }
- }
\ No newline at end of file
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/feature/ArduinoFeatureManager.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/feature/ArduinoFeatureManager.java
deleted file mode 100644
index d693f8e5b..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/feature/ArduinoFeatureManager.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.feature;
-
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.Feature;
-import org.wso2.carbon.device.mgt.common.FeatureManager;
-import org.wso2.carbon.device.mgt.extensions.feature.mgt.GenericFeatureManager;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants;
-
-import java.util.List;
-
-public class ArduinoFeatureManager implements FeatureManager {
- @Override
- public boolean addFeature(Feature feature) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean addFeatures(List features) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public Feature getFeature(String name) throws DeviceManagementException {
- GenericFeatureManager genericFeatureManager = GenericFeatureManager.getInstance();
- return genericFeatureManager.getFeature(ArduinoConstants.DEVICE_TYPE, name);
- }
-
- @Override
- public List getFeatures() throws DeviceManagementException {
- GenericFeatureManager genericFeatureManager = GenericFeatureManager.getInstance();
- return genericFeatureManager.getFeatures(ArduinoConstants.DEVICE_TYPE);
- }
-
- @Override
- public boolean removeFeature(String name) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
- return false;
- }
-}
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/ArduinoUtils.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/ArduinoUtils.java
deleted file mode 100644
index f4207d72e..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/ArduinoUtils.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.exception.ArduinoDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.internal.ArduinoManagementDataHolder;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Contains utility methods used by Arduino plugin.
- */
-public class ArduinoUtils {
-
- private static Log log = LogFactory.getLog(ArduinoUtils.class);
-
- public static String getDeviceProperty(List deviceProperties, String propertyKey) {
- String deviceProperty = "";
- for(Device.Property property :deviceProperties){
- if(propertyKey.equals(property.getName())){
- deviceProperty = property.getValue();
- }
- }
- return deviceProperty;
- }
-
- public static Device.Property getProperty(String property, String value) {
- if (property != null) {
- Device.Property prop = new Device.Property();
- prop.setName(property);
- prop.setValue(value);
- return prop;
- }
- return null;
- }
-
- public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException e) {
- log.warn("Error occurred while closing result set", e);
- }
- }
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException e) {
- log.warn("Error occurred while closing prepared statement", e);
- }
- }
- if (conn != null) {
- try {
- conn.close();
- } catch (SQLException e) {
- log.warn("Error occurred while closing database connection", e);
- }
- }
- }
-
- public static void cleanupResources(PreparedStatement stmt, ResultSet rs) {
- cleanupResources(null, stmt, rs);
- }
-
- /**
- * Creates the device management schema.
- */
- public static void setupDeviceManagementSchema() throws ArduinoDeviceMgtPluginException {
- DeviceManagementConfiguration deviceManagementConfiguration = ArduinoManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(ArduinoConstants.DEVICE_TYPE,
- ArduinoConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- String datasource = deviceManagementConfiguration.getDeviceManagementConfigRepository().getDataSourceConfig()
- .getJndiLookupDefinition().getJndiName();
- try {
- Context ctx = new InitialContext();
- DataSource dataSource = (DataSource) ctx.lookup(datasource);
- DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
- String checkSql = "select * from ARDUINO_DEVICE";
- if (!initializer.isDatabaseStructureCreated(checkSql)) {
- log.info("Initializing device management repository database schema");
- initializer.createRegistryDatabase();
- } else {
- log.info("Device management repository database already exists. Not creating a new database.");
- }
-
- } catch (NamingException e) {
- log.error("Error while looking up the data source: " + datasource, e);
- } catch (Exception e) {
- throw new ArduinoDeviceMgtPluginException("Error occurred while initializing Iot Device " +
- "Management database schema", e);
- }
- }
-
-
-}
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/DeviceSchemaInitializer.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/DeviceSchemaInitializer.java
deleted file mode 100644
index eff15d20f..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/DeviceSchemaInitializer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.iot.arduino.plugin.impl.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
-
-import javax.sql.DataSource;
-import java.io.File;
-
-/**
- * Provides methods for initializing the database script.
- */
-public class DeviceSchemaInitializer extends DatabaseCreator{
-
- private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class);
- private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts"
- + File.separator + "cdm" + File.separator + "plugins" + File.separator + ArduinoConstants.DEVICE_TYPE
- + File.separator;
-
- public DeviceSchemaInitializer(DataSource dataSource) {
- super(dataSource);
- }
-
- @Override
- protected String getDbScriptLocation(String databaseType) {
- String scriptName = databaseType + ".sql";
- if (log.isDebugEnabled()) {
- log.debug("Loading database script from :" + scriptName);
- }
- return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName;
- }
-}
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/internal/ArduinoManagementDataHolder.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/internal/ArduinoManagementDataHolder.java
deleted file mode 100644
index 60a697f6c..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/internal/ArduinoManagementDataHolder.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * you may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.arduino.plugin.internal;
-
-import org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService;
-
-/**
- * DataHolder class of plugins component.
- */
-public class ArduinoManagementDataHolder {
-
- private DeviceTypeConfigService deviceTypeConfigService;
- private static ArduinoManagementDataHolder thisInstance = new ArduinoManagementDataHolder();
-
- private ArduinoManagementDataHolder() {
- }
-
- public static ArduinoManagementDataHolder getInstance() {
- return thisInstance;
- }
-
- public DeviceTypeConfigService getDeviceTypeConfigService() {
- return deviceTypeConfigService;
- }
-
- public void setDeviceTypeConfigService(
- DeviceTypeConfigService deviceTypeConfigService) {
- this.deviceTypeConfigService = deviceTypeConfigService;
- }
-
-}
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/internal/ArduinoManagementServiceComponent.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/internal/ArduinoManagementServiceComponent.java
deleted file mode 100644
index f78007edf..000000000
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/internal/ArduinoManagementServiceComponent.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.iot.arduino.plugin.internal;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.exception.ArduinoDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.ArduinoManagerService;
-import org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.util.ArduinoUtils;
-import org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-
-/**
- * @scr.component name="org.wso2.carbon.device.mgt.iot.arduino.internal.ArduinoManagementServiceComponent"
- * immediate="true"
- * @scr.reference name="org.wso2.carbon.ndatasource"
- * interface="org.wso2.carbon.ndatasource.core.DataSourceService"
- * cardinality="1..1"
- * policy="dynamic"
- * bind="setDataSourceService"
- * unbind="unsetDataSourceService"
- * @scr.reference name="devicetype.configuration.service"
- * interface="org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService"
- * cardinality="1..1"
- * policy="dynamic"
- * bind="setDeviceTypeConfigService"
- * unbind="unsetDeviceTypeConfigService"
- */
-public class ArduinoManagementServiceComponent {
-
- private static final Log log = LogFactory.getLog(ArduinoManagementServiceComponent.class);
- private ServiceRegistration arduinoServiceRegRef;
-
- protected void activate(ComponentContext ctx) {
- if (log.isDebugEnabled()) {
- log.debug("Activating Arduino Device Management Service Component");
- }
- try {
- BundleContext bundleContext = ctx.getBundleContext();
- arduinoServiceRegRef =
- bundleContext.registerService(DeviceManagementService.class.getName(),
- new ArduinoManagerService(), null);
- String setupOption = System.getProperty("setup");
- if (setupOption != null) {
- if (log.isDebugEnabled()) {
- log.debug(
- "-Dsetup is enabled. Iot Device management repository schema initialization is about " +
- "to begin");
- }
- try {
- ArduinoUtils.setupDeviceManagementSchema();
- } catch (ArduinoDeviceMgtPluginException e) {
- log.error("Exception occurred while initializing device management database schema", e);
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("Arduino Device Management Service Component has been successfully activated");
- }
- } catch (Throwable e) {
- log.error("Error occurred while activating Arduino Device Management Service Component", e);
- }
- }
-
- protected void deactivate(ComponentContext ctx) {
- if (log.isDebugEnabled()) {
- log.debug("De-activating Arduino Device Management Service Component");
- }
- try {
- if (arduinoServiceRegRef != null) {
- arduinoServiceRegRef.unregister();
- }
-
- if (log.isDebugEnabled()) {
- log.debug(
- "Arduino Device Management Service Component has been successfully de-activated");
- }
- } catch (Throwable e) {
- log.error("Error occurred while de-activating Arduino Device Management bundle", e);
- }
- }
-
- protected void setDataSourceService(DataSourceService dataSourceService) {
- /* This is to avoid mobile device management component getting initialized before the underlying datasources
- are registered */
- if (log.isDebugEnabled()) {
- log.debug("Data source service set to service component");
- }
- }
-
- protected void unsetDataSourceService(DataSourceService dataSourceService) {
- //do nothing
- }
-
- protected void setDeviceTypeConfigService(DeviceTypeConfigService deviceTypeConfigService) {
- ArduinoManagementDataHolder.getInstance().setDeviceTypeConfigService(deviceTypeConfigService);
- }
-
- protected void unsetDeviceTypeConfigService(DeviceTypeConfigService deviceTypeConfigService) {
- ArduinoManagementDataHolder.getInstance().setDeviceTypeConfigService(null);
- }
-}
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml
index 4fc2b5a3c..0a49c190e 100644
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml
+++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml
@@ -23,7 +23,7 @@
arduino-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.hbs b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.hbs
index 2f94c0533..f626daf84 100644
--- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.hbs
+++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.hbs
@@ -64,9 +64,9 @@
01
- You can view all your connected devices at
+ You can view all your connected devices at
[Device Management] page.
02
- Select one of connected devices and check for available control
+ Select one of connected devices and check for available control
operations and monitor Real-Time data.
03
- You can also view analytics of the data published to IoT-Server by
+ You can also view analytics of the data published to IoT-Server by
navigating to Device Analytics page.
diff --git a/components/iot-plugins/arduino-plugin/pom.xml b/components/iot-plugins/arduino-plugin/pom.xml
index 1c202c5c4..a0d11b44b 100644
--- a/components/iot-plugins/arduino-plugin/pom.xml
+++ b/components/iot-plugins/arduino-plugin/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgt-pluginsiot-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
@@ -35,7 +35,6 @@
org.wso2.carbon.device.mgt.iot.arduino.api
- org.wso2.carbon.device.mgt.iot.arduino.pluginorg.wso2.carbon.device.mgt.iot.arduino.uiorg.wso2.carbon.device.mgt.iot.arduino.analytics
diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml
index 640aeea2b..aa5bc9863 100644
--- a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml
+++ b/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml
@@ -21,7 +21,7 @@
org.wso2.carbon.devicemgt-pluginsiot-analytics
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/iot-analytics/pom.xml b/components/iot-plugins/iot-analytics/pom.xml
index 4ed9a06fd..279bf6454 100644
--- a/components/iot-plugins/iot-analytics/pom.xml
+++ b/components/iot-plugins/iot-analytics/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgt-pluginsiot-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/pom.xml
index 318a64766..cc0c3367c 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/pom.xml
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/pom.xml
@@ -20,7 +20,7 @@
iot-base-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml4.0.0
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/pom.xml
index 17707c022..99c1fcdfe 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/pom.xml
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/pom.xml
@@ -20,7 +20,7 @@
iot-base-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml4.0.0
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/pom.xml
index 7e2eea4c2..4f0213a9d 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/pom.xml
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/pom.xml
@@ -20,7 +20,7 @@
iot-base-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml4.0.0
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/pom.xml
index 085d98c8d..6db6b72c7 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/pom.xml
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/pom.xml
@@ -20,7 +20,7 @@
iot-base-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml4.0.0
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/pom.xml
index d25457a9d..9e273c163 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/pom.xml
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/pom.xml
@@ -20,7 +20,7 @@
iot-base-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml4.0.0
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/pom.xml
index 558860a88..7430d4503 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/pom.xml
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/pom.xml
@@ -22,7 +22,7 @@
iot-base-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/pom.xml
index a5c8b0d0b..c622ed3db 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/pom.xml
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/pom.xml
@@ -21,7 +21,7 @@
iot-base-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/pom.xml
index a5d1035ba..aaa34766f 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/pom.xml
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/pom.xml
@@ -20,7 +20,7 @@
iot-base-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml4.0.0
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/pom.xml
index 23f2221e5..8717fc117 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/pom.xml
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/pom.xml
@@ -23,7 +23,7 @@
iot-base-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.hbs b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.hbs
index ca52690eb..f73c15c70 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.hbs
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.hbs
@@ -74,8 +74,8 @@
{{/each}}
-
+
{{/if}}
{{#if permissions.LIST_USERS}}
@@ -165,7 +165,7 @@
- Set user(s)
+ Set user(s)
{{/if}}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/pom.xml
new file mode 100644
index 000000000..5cc24ac0e
--- /dev/null
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/pom.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+ iot-base-plugin
+ org.wso2.carbon.devicemgt-plugins
+ 2.2.6-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ org.wso2.carbon.device.mgt.iot.url.printer
+ bundle
+ WSO2 Carbon - IoT url printer
+ WSO2 Carbon - IoT url printer
+ http://wso2.org
+
+
+
+
+ org.apache.felix
+ maven-scr-plugin
+
+
+ maven-compiler-plugin
+
+ 1.7
+ 1.7
+
+ 2.3.2
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ 1.4.0
+ true
+
+
+ ${project.artifactId}
+ ${project.artifactId}
+ ${carbon.devicemgt.plugins.version}
+ IoT Server Impl Bundle
+ org.wso2.carbon.device.mgt.iot.url.printer.internal
+
+ org.osgi.framework,
+ org.osgi.service.component,
+ org.apache.commons.logging,
+ org.apache.axis2.*;version="${axis2.osgi.version.range}",
+ org.wso2.carbon.core,
+ org.wso2.carbon.utils.*,
+
+
+ !org.wso2.carbon.device.mgt.iot.url.printer.internal,
+ org.wso2.carbon.device.mgt.iot.url.printer.*;version="${project.version}"
+
+
+
+
+
+
+
+
+
+
+ org.eclipse.osgi
+ org.eclipse.osgi
+
+
+ org.eclipse.osgi
+ org.eclipse.osgi.services
+
+
+ org.wso2.carbon
+ org.wso2.carbon.core
+
+
+ org.wso2.carbon
+ org.wso2.carbon.logging
+
+
+ org.wso2.carbon
+ org.wso2.carbon.utils
+
+
+ org.apache.axis2.wso2
+ axis2
+
+
+
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/URLPrinterStartupHandler.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/URLPrinterStartupHandler.java
similarity index 88%
rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/URLPrinterStartupHandler.java
rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/URLPrinterStartupHandler.java
index d9cbc4ae7..28d1943cf 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/URLPrinterStartupHandler.java
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/URLPrinterStartupHandler.java
@@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.iot.url.printer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.core.ServerStartupObserver;
-import org.wso2.carbon.device.mgt.iot.internal.IoTDeviceManagementDataHolder;
+import org.wso2.carbon.device.mgt.iot.url.printer.internal.UrlPrinterDataHolder;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.ConfigurationContextService;
import org.wso2.carbon.utils.NetworkUtils;
@@ -35,10 +35,10 @@ public class URLPrinterStartupHandler implements ServerStartupObserver {
@Override
public void completedServerStartup() {
- log.info("IoT Console URL : " + this.getIoTUrl());
+ log.info("IoT Console URL : " + this.getServerUrl());
}
- private String getIoTUrl() {
+ private String getServerUrl() {
// Hostname
String hostName = "localhost";
try {
@@ -48,7 +48,7 @@ public class URLPrinterStartupHandler implements ServerStartupObserver {
// HTTPS port
String mgtConsoleTransport = CarbonUtils.getManagementTransport();
ConfigurationContextService configContextService =
- IoTDeviceManagementDataHolder.getInstance().getConfigurationContextService();
+ UrlPrinterDataHolder.getInstance().getConfigurationContextService();
int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport);
int httpsProxyPort =
CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), mgtConsoleTransport);
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IoTDeviceManagementDataHolder.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterDataHolder.java
similarity index 79%
rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IoTDeviceManagementDataHolder.java
rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterDataHolder.java
index 76edfc41c..cd74cbe24 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IoTDeviceManagementDataHolder.java
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterDataHolder.java
@@ -16,18 +16,18 @@
* under the License.
*
*/
-package org.wso2.carbon.device.mgt.iot.internal;
+package org.wso2.carbon.device.mgt.iot.url.printer.internal;
import org.wso2.carbon.utils.ConfigurationContextService;
-public class IoTDeviceManagementDataHolder {
+public class UrlPrinterDataHolder {
private ConfigurationContextService configurationContextService;
- private static IoTDeviceManagementDataHolder thisInstance = new IoTDeviceManagementDataHolder();
+ private static UrlPrinterDataHolder thisInstance = new UrlPrinterDataHolder();
- private IoTDeviceManagementDataHolder() {}
+ private UrlPrinterDataHolder() {}
- public static IoTDeviceManagementDataHolder getInstance() {
+ public static UrlPrinterDataHolder getInstance() {
return thisInstance;
}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterServiceComponent.java
similarity index 62%
rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java
rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterServiceComponent.java
index 87483048a..38fb00168 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterServiceComponent.java
@@ -16,20 +16,18 @@
* under the License.
*/
-package org.wso2.carbon.device.mgt.iot.internal;
+package org.wso2.carbon.device.mgt.iot.url.printer.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.core.ServerStartupObserver;
-import org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService;
-import org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigServiceImpl;
import org.wso2.carbon.device.mgt.iot.url.printer.URLPrinterStartupHandler;
import org.wso2.carbon.utils.ConfigurationContextService;
/**
- * @scr.component name="org.wso2.carbon.device.mgt.iot.internal.IotDeviceManagementServiceComponent"
+ * @scr.component name="org.wso2.carbon.device.mgt.iot.url.printer.internal.UrlPrinterServiceComponent"
* immediate="true"
* @scr.reference name="config.context.service"
* interface="org.wso2.carbon.utils.ConfigurationContextService"
@@ -38,32 +36,28 @@ import org.wso2.carbon.utils.ConfigurationContextService;
* bind="setConfigurationContextService"
* unbind="unsetConfigurationContextService"
*/
-public class IotDeviceManagementServiceComponent {
+public class UrlPrinterServiceComponent {
- private static final Log log = LogFactory.getLog(IotDeviceManagementServiceComponent.class);
+ private static final Log log = LogFactory.getLog(UrlPrinterServiceComponent.class);
protected void activate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
- log.debug("Activating Iot Device Management Service Component");
+ log.debug("Activating Url printer Service Component");
}
try {
BundleContext bundleContext = ctx.getBundleContext();
bundleContext.registerService(ServerStartupObserver.class.getName(), new URLPrinterStartupHandler(), null);
if (log.isDebugEnabled()) {
- log.debug("Iot Device Management Service Component has been successfully activated");
+ log.debug("Url printer Service Component has been successfully activated");
}
- DeviceTypeConfigServiceImpl deviceTypeConfigLoaderService = new DeviceTypeConfigServiceImpl();
- deviceTypeConfigLoaderService.initialize();
- bundleContext.registerService(DeviceTypeConfigService.class.getName(), deviceTypeConfigLoaderService,
- null);
} catch (Throwable e) {
- log.error("Error occurred while activating Iot Device Management Service Component", e);
+ log.error("Error occurred while activating Url printer Service Component", e);
}
}
protected void deactivate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
- log.debug("De-activating Iot Device Management Service Component");
+ log.debug("De-activating Url printer Service Component");
}
}
@@ -72,7 +66,7 @@ public class IotDeviceManagementServiceComponent {
log.debug("Setting ConfigurationContextService");
}
- IoTDeviceManagementDataHolder.getInstance().setConfigurationContextService(configurationContextService);
+ UrlPrinterDataHolder.getInstance().setConfigurationContextService(configurationContextService);
}
@@ -80,6 +74,6 @@ public class IotDeviceManagementServiceComponent {
if (log.isDebugEnabled()) {
log.debug("Un-setting ConfigurationContextService");
}
- IoTDeviceManagementDataHolder.getInstance().setConfigurationContextService(null);
+ UrlPrinterDataHolder.getInstance().setConfigurationContextService(null);
}
}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml
deleted file mode 100644
index 3e2a8cc02..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml
+++ /dev/null
@@ -1,199 +0,0 @@
-
-
-
-
-
-
-
- iot-base-plugin
- org.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
- ../pom.xml
-
-
- 4.0.0
- org.wso2.carbon.device.mgt.iot
- bundle
- WSO2 Carbon - IoT Device Management Common Impl
- WSO2 Carbon - IoT Device Management and Control Implementation
- http://wso2.org
-
-
-
-
- org.apache.felix
- maven-scr-plugin
-
-
- maven-compiler-plugin
-
- 1.7
- 1.7
-
- 2.3.2
-
-
- org.apache.felix
- maven-bundle-plugin
- 1.4.0
- true
-
-
- ${project.artifactId}
- ${project.artifactId}
- ${carbon.devicemgt.plugins.version}
- IoT Server Impl Bundle
- org.wso2.carbon.device.mgt.iot.internal
-
- org.wso2.carbon.base.*,
- org.osgi.framework,
- org.osgi.service.component,
- org.apache.axis2.context,
- org.apache.commons.io,
- org.apache.commons.logging,
- org.wso2.carbon.core,
- org.wso2.carbon.device.mgt.common,
- org.wso2.carbon.utils,
- javax.xml.bind,
- javax.xml.bind.annotation,
- javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}",
- org.w3c.dom
-
-
- !org.wso2.carbon.device.mgt.iot.internal,
- org.wso2.carbon.device.mgt.iot.*;version="${project.version}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.eclipse.osgi
- org.eclipse.osgi
-
-
- org.eclipse.osgi
- org.eclipse.osgi.services
-
-
- org.wso2.carbon
- org.wso2.carbon.logging
-
-
- org.wso2.carbon
- org.wso2.carbon.utils
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.common
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.core
-
-
- org.apache.httpcomponents.wso2
- httpclient
-
-
-
-
- org.wso2.carbon
- org.wso2.carbon.ndatasource.core
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.policy.mgt.core
- provided
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.policy.mgt.common
- provided
-
-
-
- org.json.wso2
- json
-
-
- org.wso2.carbon
- org.wso2.carbon.core
-
-
- commons-collections
- commons-collections
-
-
- commons-configuration
- commons-configuration
-
-
- org.wso2.carbon.analytics-common
- org.wso2.carbon.databridge.agent
-
-
- org.wso2.carbon.analytics-common
- org.wso2.carbon.databridge.core
-
-
- org.wso2.carbon.commons
- org.wso2.carbon.databridge.commons
-
-
- org.eclipse.paho
- org.eclipse.paho.client.mqttv3
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.analytics.data.publisher
-
-
-
- org.igniterealtime.smack.wso2
- smack
-
-
- org.igniterealtime.smack.wso2
- smackx
-
-
- commons-codec
- commons-codec
-
-
-
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigIdentifier.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigIdentifier.java
deleted file mode 100644
index 4d06cef39..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigIdentifier.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.iot.devicetype;
-
-import java.io.Serializable;
-
-/**
- * This class holds key for the configuration of the device type and its provider tenant.
- */
-public class DeviceTypeConfigIdentifier implements Serializable {
-
- private String deviceType;
- private String tenantDomain;
-
- public DeviceTypeConfigIdentifier(String deviceType, String tenantDomain) {
- this.deviceType = deviceType;
- this.tenantDomain = tenantDomain;
- }
-
- @Override
- public int hashCode() {
- int result = this.deviceType.hashCode();
- result = 31 * result + ("@" + this.tenantDomain).hashCode();
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- return (obj instanceof DeviceTypeConfigIdentifier) && deviceType.equals(
- ((DeviceTypeConfigIdentifier) obj).deviceType) && tenantDomain.equals(
- ((DeviceTypeConfigIdentifier) obj).tenantDomain);
- }
-}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigService.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigService.java
deleted file mode 100644
index fc1bf27d6..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigService.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.wso2.carbon.device.mgt.iot.devicetype;
-
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-
-/**
- * Service to retrieve device type configs.
- */
-public interface DeviceTypeConfigService {
-
- /**
- * This service will read the device type configuration files from conf/etc/device-type-plugins
- *
- * @param deviceType retrive the device type configuration.
- * @param tenantDomain retrieve the device type of this tenant domain.
- * @return device management configuratio for the device type owned by the given tenant domain.
- */
- DeviceManagementConfiguration getConfiguration(String deviceType, String tenantDomain);
-}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigServiceImpl.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigServiceImpl.java
deleted file mode 100644
index fbdc9b37f..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigServiceImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.wso2.carbon.device.mgt.iot.devicetype;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.exception.DeviceTypeConfigurationException;
-import org.wso2.carbon.device.mgt.iot.devicetype.util.DeviceTypeConfigUtil;
-import org.wso2.carbon.utils.CarbonUtils;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-public class DeviceTypeConfigServiceImpl implements DeviceTypeConfigService {
-
- private static final Log log = LogFactory.getLog(DeviceTypeConfigServiceImpl.class);
- private static final String DEVICE_TYPE_CONFIG_PATH =
- CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-mgt-plugins";
- private Map deviceTypeConfigurationMap = new HashMap<>();
-
- public void initialize() {
- File configurationDirectory = new File(DEVICE_TYPE_CONFIG_PATH);
- File[] deviceTypeConfigurationFiles = configurationDirectory.listFiles();
- if (deviceTypeConfigurationFiles != null) {
- for (File file : deviceTypeConfigurationFiles) {
- String filename = file.getName();
- if (filename.endsWith(".xml") || filename.endsWith(".XML")) {
- try {
- DeviceManagementConfiguration deviceManagementConfiguration = getDeviceTypeConfiguration(file);
- String deviceType = deviceManagementConfiguration.getDeviceType();
- String tenantDomain = deviceManagementConfiguration.getDeviceManagementConfigRepository()
- .getProvisioningConfig().getTenantDomain();
- if (deviceType != null && !deviceType.isEmpty() && tenantDomain != null
- && !tenantDomain.isEmpty()) {
- deviceTypeConfigurationMap.put(new DeviceTypeConfigIdentifier(deviceType, tenantDomain),
- deviceManagementConfiguration);
- }
-
- } catch (DeviceTypeConfigurationException e) {
- //continue reading other files
- log.error(e.getMessage(), e);
- }
- }
- }
- }
- }
-
- private DeviceManagementConfiguration getDeviceTypeConfiguration(File configurationFile)
- throws DeviceTypeConfigurationException {
- try {
- Document doc = DeviceTypeConfigUtil.convertToDocument(configurationFile);
-
- /* Un-marshaling Webapp Authenticator configuration */
- JAXBContext ctx = JAXBContext.newInstance(DeviceManagementConfiguration.class);
- Unmarshaller unmarshaller = ctx.createUnmarshaller();
- //unmarshaller.setSchema(getSchema());
- return (DeviceManagementConfiguration) unmarshaller.unmarshal(doc);
- } catch (JAXBException e) {
- throw new DeviceTypeConfigurationException("Error occurred while un-marshalling the file " +
- configurationFile.getAbsolutePath(), e);
- }
- }
-
- @Override
- public DeviceManagementConfiguration getConfiguration(String deviceType, String tenantDomain) {
- return deviceTypeConfigurationMap.get(new DeviceTypeConfigIdentifier(deviceType, tenantDomain));
- }
-}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DataSourceConfig.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DataSourceConfig.java
deleted file mode 100644
index 1b8c33765..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DataSourceConfig.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2014, 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.iot.devicetype.config;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * Class for holding device type configuration and parsing with JAXB.
- */
-@XmlRootElement(name = "DataSourceConfiguration")
-public class DataSourceConfig {
-
- private JNDILookupDefinition jndiLookupDefinition;
-
- @XmlElement(name = "JndiLookupDefinition", required = true)
- public JNDILookupDefinition getJndiLookupDefinition() {
- return jndiLookupDefinition;
- }
-
- public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) {
- this.jndiLookupDefinition = jndiLookupDefinition;
- }
-
-}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfigRepository.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfigRepository.java
deleted file mode 100644
index 680935c7d..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfigRepository.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2014, 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.iot.devicetype.config;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * Class for holding management repository data.
- */
-@XmlRootElement(name = "ManagementRepository")
-public class DeviceManagementConfigRepository {
-
- private DataSourceConfig dataSourceConfig;
- private ProvisioningConfig provisioningConfig;
-
- @XmlElement(name = "DataSourceConfiguration", required = true)
- public DataSourceConfig getDataSourceConfig() {
- return dataSourceConfig;
- }
-
- public void setDataSourceConfig(DataSourceConfig dataSourceConfig) {
- this.dataSourceConfig = dataSourceConfig;
- }
-
- @XmlElement(name = "ProvisioningConfig", required = true)
- public ProvisioningConfig getProvisioningConfig() {
- return provisioningConfig;
- }
-
- public void setProvisioningConfig(
- ProvisioningConfig provisioningConfig) {
- this.provisioningConfig = provisioningConfig;
- }
-}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java
deleted file mode 100644
index 369b9af67..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.iot.devicetype.config;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name = "DeviceManagementConfiguration")
-public class DeviceManagementConfiguration {
-
- private DeviceManagementConfigRepository deviceManagementConfigRepository;
- private PushNotificationConfig pushNotificationConfig;
- private String deviceType;
-
- private static final Log log = LogFactory.getLog(DeviceManagementConfiguration.class);
-
- private DeviceManagementConfiguration() {
- }
-
- @XmlElement(name = "DeviceType", required = false)
- public String getDeviceType() {
- return deviceType;
- }
-
- public void setDeviceType(String deviceType) {
- this.deviceType = deviceType;
- }
-
- @XmlElement(name = "ManagementRepository", required = true)
- public DeviceManagementConfigRepository getDeviceManagementConfigRepository() {
- return deviceManagementConfigRepository;
- }
-
- public void setDeviceManagementConfigRepository(DeviceManagementConfigRepository deviceManagementConfigRepository) {
- this.deviceManagementConfigRepository = deviceManagementConfigRepository;
- }
-
- @XmlElement(name = "PushNotificationConfiguration", required = false)
- public PushNotificationConfig getPushNotificationConfig() {
- return pushNotificationConfig;
- }
-
- public void setPushNotificationConfig(PushNotificationConfig pushNotificationConfig) {
- this.pushNotificationConfig = pushNotificationConfig;
- }
-}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/JNDILookupDefinition.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/JNDILookupDefinition.java
deleted file mode 100644
index 370bb1c2d..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/JNDILookupDefinition.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2014, 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.iot.devicetype.config;
-
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlValue;
-import java.util.List;
-
-/**
- * Class for hold JndiLookupDefinition parsing with JAXB.
- */
-@XmlRootElement(name = "JndiLookupDefinition")
-public class JNDILookupDefinition {
-
- private String jndiName;
- private List jndiProperties;
-
- @XmlElement(name = "Name", required = false)
- public String getJndiName() {
- return jndiName;
- }
-
- public void setJndiName(String jndiName) {
- this.jndiName = jndiName;
- }
-
- @XmlElementWrapper(name = "Environment", required = false)
- @XmlElement(name = "Property", nillable = false)
- public List getJndiProperties() {
- return jndiProperties;
- }
-
- public void setJndiProperties(List jndiProperties) {
- this.jndiProperties = jndiProperties;
- }
-
- @XmlRootElement(name = "Property")
- public static class JNDIProperty {
-
- private String name;
-
- private String value;
-
- @XmlAttribute(name = "Name")
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @XmlValue
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
- }
-
-}
-
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/ProvisioningConfig.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/ProvisioningConfig.java
deleted file mode 100644
index 7185212d4..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/ProvisioningConfig.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2014, 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.iot.devicetype.config;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * Class for holding device type configuration and parsing with JAXB.
- */
-@XmlRootElement(name = "ProvisioningConfig")
-public class ProvisioningConfig {
-
- private String tenantDomain;
- private boolean sharedWithAllTenants;
-
- @XmlElement(name = "TenantDomain", required = true)
- public String getTenantDomain() {
- return tenantDomain;
- }
-
- public void setTenantDomain(String tenantDomain) {
- this.tenantDomain = tenantDomain;
- }
-
- @XmlElement(name = "SharedWithAllTenants", required = true)
- public boolean isSharedWithAllTenants() {
- return sharedWithAllTenants;
- }
-
- public void setSharedWithAllTenants(boolean sharedWithAllTenants) {
- this.sharedWithAllTenants = sharedWithAllTenants;
- }
-}
\ No newline at end of file
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/exception/InvalidConfigurationStateException.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/exception/InvalidConfigurationStateException.java
deleted file mode 100644
index fdbee792e..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/exception/InvalidConfigurationStateException.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.wso2.carbon.device.mgt.iot.devicetype.config.exception;
-
-public class InvalidConfigurationStateException extends RuntimeException {
-
- private static final long serialVersionUID = -3151279411229070297L;
-
- public InvalidConfigurationStateException(int errorCode, String message) {
- super(message);
- }
-
- public InvalidConfigurationStateException(int errorCode, String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidConfigurationStateException(String msg, Exception nestedEx) {
- super(msg, nestedEx);
- }
-
- public InvalidConfigurationStateException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidConfigurationStateException(String msg) {
- super(msg);
- }
-
- public InvalidConfigurationStateException() {
- super();
- }
-
- public InvalidConfigurationStateException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/util/DeviceTypeConfigUtil.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/util/DeviceTypeConfigUtil.java
deleted file mode 100644
index a32a88bdf..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/util/DeviceTypeConfigUtil.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.iot.devicetype.util;
-
-import org.w3c.dom.Document;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.exception.DeviceTypeConfigurationException;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.File;
-
-public class DeviceTypeConfigUtil {
-
- public static final String CARBON_HOME = "carbon.home";
- public static final String CARBON_HOME_ENTRY = "${carbon.home}";
-
- public static Document convertToDocument(File file) throws DeviceTypeConfigurationException {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- try {
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- return docBuilder.parse(file);
- } catch (Exception e) {
- throw new DeviceTypeConfigurationException("Error occurred while parsing file, while converting " +
- "to a org.w3c.dom.Document", e);
- }
- }
-
-
-
-
-}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/Utils.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/Utils.java
deleted file mode 100644
index c11176983..000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/Utils.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * 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.iot.util;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.NetworkUtils;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.SocketException;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-/**
- * Provides utility methods required by the device type plugins.
- */
-public class Utils {
-
- public static final String HOST_NAME = "HostName";
- private static final Log log = LogFactory.getLog(Utils.class);
-
- public static String getServerUrl() {
- String hostName = ServerConfiguration.getInstance().getFirstProperty(HOST_NAME);
- try {
- if (hostName == null) {
- hostName = NetworkUtils.getLocalHostname();
- }
- } catch (SocketException e) {
- hostName = "localhost";
- log.warn("Failed retrieving the hostname, therefore set to localhost", e);
- }
- return hostName;
- }
-
- public static ZipArchive getSketchArchive(String archivesPath, String templateSketchPath, Map contextParams,
- String zipFileName)
- throws DeviceManagementException, IOException {
- String sketchPath = CarbonUtils.getCarbonHome() + File.separator + templateSketchPath;
- FileUtils.deleteDirectory(new File(archivesPath));//clear directory
- FileUtils.deleteDirectory(new File(archivesPath + ".zip"));//clear zip
- if (!new File(archivesPath).mkdirs()) { //new dir
- String message = "Could not create directory at path: " + archivesPath;
- log.error(message);
- throw new DeviceManagementException(message);
- }
- zipFileName = zipFileName + ".zip";
- try {
- Map> properties = getProperties(sketchPath + File.separator + "sketch" + ".properties");
- List templateFiles = properties.get("templates");
-
- for (String templateFile : templateFiles) {
- parseTemplate(templateSketchPath + File.separator + templateFile, archivesPath + File.separator + templateFile,
- contextParams);
- }
-
- templateFiles.add("sketch.properties"); // ommit copying the props file
- copyFolder(new File(sketchPath), new File(archivesPath), templateFiles);
- createZipArchive(archivesPath);
- FileUtils.deleteDirectory(new File(archivesPath));
- File zip = new File(archivesPath + ".zip");
- return new ZipArchive(zipFileName, zip);
- } catch (IOException ex) {
- throw new DeviceManagementException(
- "Error occurred when trying to read property " + "file sketch.properties", ex);
- }
- }
-
- private static Map> getProperties(String propertyFilePath) throws IOException {
- Properties prop = new Properties();
- InputStream input = null;
-
- try {
-
- input = new FileInputStream(propertyFilePath);
-
- // load a properties file
- prop.load(input);
- Map> properties = new HashMap>();
-
- String templates = prop.getProperty("templates");
- List list = new ArrayList(Arrays.asList(templates.split(",")));
- properties.put("templates", list);
-
- final String filename = prop.getProperty("zipfilename");
- list = new ArrayList() {{
- add(filename);
- }};
- properties.put("zipfilename", list);
- return properties;
-
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- log.error("Failed closing connection", e);
- }
- }
- }
- }
-
- private static void parseTemplate(String srcFile, String dstFile, Map contextParams) throws IOException {
- //read from file
- FileInputStream inputStream = null;
- FileOutputStream outputStream = null;
- try {
- inputStream = new FileInputStream(srcFile);
- outputStream = new FileOutputStream(dstFile);
- String content = IOUtils.toString(inputStream, StandardCharsets.UTF_8.toString());
- Iterator iterator = contextParams.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry mapEntry = (Map.Entry) iterator.next();
- content = content.replaceAll("\\$\\{" + mapEntry.getKey() + "\\}", mapEntry.getValue().toString());
- }
- IOUtils.write(content, outputStream, StandardCharsets.UTF_8.toString());
- } finally {
- if (inputStream != null) {
- inputStream.close();
- }
- if (outputStream != null) {
- outputStream.close();
- }
- }
- }
-
- private static void copyFolder(File src, File dest, List excludeFileNames) throws IOException {
-
- if (src.isDirectory()) {
- //if directory not exists, create it
- if (!dest.exists() && !dest.mkdirs()) {
- String message = "Could not create directory at path: " + dest;
- log.error(message);
- throw new IOException(message);
- }
- //list all the directory contents
- String files[] = src.list();
-
- if (files == null) {
- log.warn("There are no files insides the directory " + src.getAbsolutePath());
- return;
- }
-
- for (String file : files) {
- //construct the src and dest file structure
- File srcFile = new File(src, file);
- File destFile = new File(dest, file);
- //recursive copy
- copyFolder(srcFile, destFile, excludeFileNames);
- }
-
- } else {
- for (String fileName : excludeFileNames) {
- if (src.getName().equals(fileName)) {
- return;
- }
- }
- //if file, then copy it
- //Use bytes stream to support all file types
- InputStream in = null;
- OutputStream out = null;
-
- try {
- in = new FileInputStream(src);
- out = new FileOutputStream(dest);
-
- byte[] buffer = new byte[1024];
-
- int length;
- //copy the file content in bytes
- while ((length = in.read(buffer)) > 0) {
- out.write(buffer, 0, length);
- }
- } finally {
- if (in != null) {
- in.close();
- }
- if (out != null) {
- out.close();
- }
- }
- }
- }
-
- private static boolean createZipArchive(String srcFolder) throws IOException {
- BufferedInputStream origin = null;
- ZipOutputStream out = null;
-
- try {
- final int BUFFER = 2048;
- FileOutputStream dest = new FileOutputStream(new File(srcFolder + ".zip"));
- out = new ZipOutputStream(new BufferedOutputStream(dest));
- byte data[] = new byte[BUFFER];
- File subDir = new File(srcFolder);
- String subdirList[] = subDir.list();
- if (subdirList == null) {
- log.warn("The sub directory " + subDir.getAbsolutePath() + " is empty");
- return false;
- }
- for (String sd : subdirList) {
- // get a list of files from current directory
- File f = new File(srcFolder + "/" + sd);
- if (f.isDirectory()) {
- String files[] = f.list();
-
- if (files == null) {
- log.warn("The current directory " + f.getAbsolutePath() + " is empty. Has no files");
- return false;
- }
-
- for (int i = 0; i < files.length; i++) {
- FileInputStream fi = new FileInputStream(srcFolder + "/" + sd + "/" + files[i]);
- origin = new BufferedInputStream(fi, BUFFER);
- ZipEntry entry = new ZipEntry(sd + "/" + files[i]);
- out.putNextEntry(entry);
- int count;
- while ((count = origin.read(data, 0, BUFFER)) != -1) {
- out.write(data, 0, count);
- out.flush();
- }
-
- }
- } else //it is just a file
- {
- FileInputStream fi = new FileInputStream(f);
- origin = new BufferedInputStream(fi, BUFFER);
- ZipEntry entry = new ZipEntry(sd);
- out.putNextEntry(entry);
- int count;
- while ((count = origin.read(data, 0, BUFFER)) != -1) {
- out.write(data, 0, count);
- out.flush();
- }
- }
- }
- out.flush();
- } finally {
- if (origin != null) {
- origin.close();
- }
- if (out != null) {
- out.close();
- }
- }
- return true;
- }
-
-}
diff --git a/components/iot-plugins/iot-base-plugin/pom.xml b/components/iot-plugins/iot-base-plugin/pom.xml
index 31ae28209..c0f29c683 100644
--- a/components/iot-plugins/iot-base-plugin/pom.xml
+++ b/components/iot-plugins/iot-base-plugin/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgt-pluginsiot-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
@@ -33,7 +33,7 @@
http://wso2.org
- org.wso2.carbon.device.mgt.iot
+ org.wso2.carbon.device.mgt.iot.url.printerorg.wso2.carbon.device.mgt.iot.uiorg.wso2.carbon.device.mgt.iot.output.adapter.mqttorg.wso2.carbon.device.mgt.iot.output.adapter.xmpp
diff --git a/components/iot-plugins/pom.xml b/components/iot-plugins/pom.xml
index 2a1a3ed14..ea223d344 100644
--- a/components/iot-plugins/pom.xml
+++ b/components/iot-plugins/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgt-pluginscarbon-device-mgt-plugins-parent
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../../pom.xml
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml
index 78a3cd5b1..87b869c23 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml
@@ -21,7 +21,7 @@
raspberrypi-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml
index e0cfde124..8d08d8fdf 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml
@@ -21,7 +21,7 @@
raspberrypi-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
@@ -69,13 +69,6 @@
provided
-
-
- org.eclipse.paho
- org.eclipse.paho.client.mqttv3
- provided
-
-
org.apache.httpcomponents
@@ -83,16 +76,6 @@
4.1provided
-
- org.wso2.carbon.devicemgt-plugins
- org.wso2.carbon.device.mgt.iot
- provided
-
-
- org.wso2.carbon.devicemgt-plugins
- org.wso2.carbon.device.mgt.iot.raspberrypi.plugin
- provided
-
@@ -113,22 +96,11 @@
jsr311-apiprovided
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.analytics.data.publisher
- provided
- org.wso2.carbon.devicemgtorg.wso2.carbon.apimgt.annotationsprovided
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.apimgt.webapp.publisher
- provided
- org.wso2.carbon.devicemgtorg.wso2.carbon.identity.jwt.client.extension
@@ -144,6 +116,11 @@
org.wso2.carbon.analytics.apiprovided
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.extensions
+ provided
+
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java
index 5b098a3e0..13b131041 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java
@@ -34,11 +34,11 @@ import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiConstants;
+import org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.constants.RaspberrypiConstants;
import org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.dto.SensorRecord;
import org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.util.APIUtil;
+import org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.util.ZipArchive;
import org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.util.ZipUtil;
-import org.wso2.carbon.device.mgt.iot.util.ZipArchive;
import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/constants/RaspberrypiConstants.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java
similarity index 76%
rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/constants/RaspberrypiConstants.java
rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java
index 9dae80462..f77aabf80 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/constants/RaspberrypiConstants.java
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java
@@ -16,24 +16,17 @@
* under the License.
*/
-package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants;
-
-import org.wso2.carbon.utils.CarbonUtils;
-
-import java.io.File;
+package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.constants;
public class RaspberrypiConstants {
public final static String DEVICE_TYPE = "raspberrypi";
- public final static String DEVICE_PLUGIN_DEVICE_NAME = "DEVICE_NAME";
- public final static String DEVICE_PLUGIN_DEVICE_ID = "RASPBERRYPI_DEVICE_ID";
public final static String STATE_ON = "ON";
public final static String STATE_OFF = "OFF";
public static final String BULB_CONTEXT = "BULB";
//sensor events summerized table name
public static final String TEMPERATURE_EVENT_TABLE = "DEVICE_TEMPERATURE_SUMMARY";
- public final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
//mqtt tranport related constants
public static final String MQTT_ADAPTER_TOPIC_PROPERTY_NAME = "mqtt.adapter.topic";
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java
index 34a65dc26..fee581528 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java
@@ -7,7 +7,7 @@ import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDrillDownRequest;
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
-import org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceUtils;
+import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
import org.wso2.carbon.analytics.datasource.commons.Record;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
@@ -78,7 +78,7 @@ public class APIUtil {
sortByFields);
List recordIds = getRecordIds(resultEntries);
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
- Map sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords(
+ Map sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords(
analyticsDataAPI, response));
List sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
return sortedSensorData;
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipArchive.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipArchive.java
new file mode 100644
index 000000000..eb5ed95da
--- /dev/null
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipArchive.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.util;
+
+import java.io.File;
+
+/**
+ * This is an utility class to hold zip files.
+ */
+public class ZipArchive {
+
+ private File zipFile = null;
+ private String fileName = null;
+
+ public ZipArchive(String fileName, File zipFile) {
+ this.fileName = fileName;
+ this.zipFile = zipFile;
+ }
+
+ public File getZipFile() {
+ return zipFile;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+}
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java
index 834d31138..d12a2df04 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java
@@ -18,25 +18,45 @@
package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.util;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
-import org.wso2.carbon.device.mgt.iot.util.Utils;
-import org.wso2.carbon.device.mgt.iot.util.ZipArchive;
import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.NetworkUtils;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.SocketException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
/**
* This is used to create a zip file that includes the necessary configuration required for the agent.
*/
public class ZipUtil {
+ private static final Log log = LogFactory.getLog(ZipUtil.class);
+ public static final String HOST_NAME = "HostName";
private static final String HTTPS_PORT_PROPERTY = "httpsPort";
private static final String HTTP_PORT_PROPERTY = "httpPort";
@@ -57,7 +77,7 @@ public class ZipUtil {
String iotServerIP;
try {
- iotServerIP = Utils.getServerUrl();
+ iotServerIP = getServerUrl();
String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY);
String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY);
String httpsServerEP = HTTPS_PROTOCOL_APPENDER + iotServerIP + ":" + httpsServerPort;
@@ -101,7 +121,7 @@ public class ZipUtil {
contextParams.put("DEVICE_REFRESH_TOKEN", refreshToken);
ZipArchive zipFile;
- zipFile = Utils.getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName);
+ zipFile = getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName);
return zipFile;
} catch (IOException e) {
throw new DeviceManagementException("Zip File Creation Failed", e);
@@ -109,4 +129,227 @@ public class ZipUtil {
throw new DeviceManagementException("Failed to retrieve configuration", e);
}
}
+
+ private static String getServerUrl() {
+ String hostName = ServerConfiguration.getInstance().getFirstProperty(HOST_NAME);
+ try {
+ if (hostName == null) {
+ hostName = NetworkUtils.getLocalHostname();
+ }
+ } catch (SocketException e) {
+ hostName = "localhost";
+ log.warn("Failed retrieving the hostname, therefore set to localhost", e);
+ }
+ return hostName;
+ }
+
+ private static ZipArchive getSketchArchive(String archivesPath, String templateSketchPath, Map contextParams
+ , String zipFileName)
+ throws DeviceManagementException, IOException {
+ String sketchPath = CarbonUtils.getCarbonHome() + File.separator + templateSketchPath;
+ FileUtils.deleteDirectory(new File(archivesPath));//clear directory
+ FileUtils.deleteDirectory(new File(archivesPath + ".zip"));//clear zip
+ if (!new File(archivesPath).mkdirs()) { //new dir
+ String message = "Could not create directory at path: " + archivesPath;
+ log.error(message);
+ throw new DeviceManagementException(message);
+ }
+ zipFileName = zipFileName + ".zip";
+ try {
+ Map> properties = getProperties(sketchPath + File.separator + "sketch" + ".properties");
+ List templateFiles = properties.get("templates");
+
+ for (String templateFile : templateFiles) {
+ parseTemplate(templateSketchPath + File.separator + templateFile, archivesPath + File.separator + templateFile,
+ contextParams);
+ }
+
+ templateFiles.add("sketch.properties"); // ommit copying the props file
+ copyFolder(new File(sketchPath), new File(archivesPath), templateFiles);
+ createZipArchive(archivesPath);
+ FileUtils.deleteDirectory(new File(archivesPath));
+ File zip = new File(archivesPath + ".zip");
+ return new ZipArchive(zipFileName, zip);
+ } catch (IOException ex) {
+ throw new DeviceManagementException(
+ "Error occurred when trying to read property " + "file sketch.properties", ex);
+ }
+ }
+
+ private static Map> getProperties(String propertyFilePath) throws IOException {
+ Properties prop = new Properties();
+ InputStream input = null;
+
+ try {
+ input = new FileInputStream(propertyFilePath);
+ // load a properties file
+ prop.load(input);
+ Map> properties = new HashMap>();
+
+ String templates = prop.getProperty("templates");
+ List list = new ArrayList(Arrays.asList(templates.split(",")));
+ properties.put("templates", list);
+
+ final String filename = prop.getProperty("zipfilename");
+ list = new ArrayList() {{
+ add(filename);
+ }};
+ properties.put("zipfilename", list);
+ return properties;
+
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (IOException e) {
+ log.error("Failed closing connection", e);
+ }
+ }
+ }
+ }
+
+ private static void parseTemplate(String srcFile, String dstFile, Map contextParams) throws IOException {
+ //read from file
+ FileInputStream inputStream = null;
+ FileOutputStream outputStream = null;
+ try {
+ inputStream = new FileInputStream(srcFile);
+ outputStream = new FileOutputStream(dstFile);
+ String content = IOUtils.toString(inputStream, StandardCharsets.UTF_8.toString());
+ Iterator iterator = contextParams.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry mapEntry = (Map.Entry) iterator.next();
+ content = content.replaceAll("\\$\\{" + mapEntry.getKey() + "\\}", mapEntry.getValue().toString());
+ }
+ IOUtils.write(content, outputStream, StandardCharsets.UTF_8.toString());
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ }
+ }
+
+ private static void copyFolder(File src, File dest, List excludeFileNames) throws IOException {
+
+ if (src.isDirectory()) {
+ //if directory not exists, create it
+ if (!dest.exists() && !dest.mkdirs()) {
+ String message = "Could not create directory at path: " + dest;
+ log.error(message);
+ throw new IOException(message);
+ }
+ //list all the directory contents
+ String files[] = src.list();
+
+ if (files == null) {
+ log.warn("There are no files insides the directory " + src.getAbsolutePath());
+ return;
+ }
+
+ for (String file : files) {
+ //construct the src and dest file structure
+ File srcFile = new File(src, file);
+ File destFile = new File(dest, file);
+ //recursive copy
+ copyFolder(srcFile, destFile, excludeFileNames);
+ }
+
+ } else {
+ for (String fileName : excludeFileNames) {
+ if (src.getName().equals(fileName)) {
+ return;
+ }
+ }
+ //if file, then copy it
+ //Use bytes stream to support all file types
+ InputStream in = null;
+ OutputStream out = null;
+
+ try {
+ in = new FileInputStream(src);
+ out = new FileOutputStream(dest);
+
+ byte[] buffer = new byte[1024];
+
+ int length;
+ //copy the file content in bytes
+ while ((length = in.read(buffer)) > 0) {
+ out.write(buffer, 0, length);
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+ }
+
+ private static boolean createZipArchive(String srcFolder) throws IOException {
+ BufferedInputStream origin = null;
+ ZipOutputStream out = null;
+
+ try {
+ final int BUFFER = 2048;
+ FileOutputStream dest = new FileOutputStream(new File(srcFolder + ".zip"));
+ out = new ZipOutputStream(new BufferedOutputStream(dest));
+ byte data[] = new byte[BUFFER];
+ File subDir = new File(srcFolder);
+ String subdirList[] = subDir.list();
+ if (subdirList == null) {
+ log.warn("The sub directory " + subDir.getAbsolutePath() + " is empty");
+ return false;
+ }
+ for (String sd : subdirList) {
+ // get a list of files from current directory
+ File f = new File(srcFolder + "/" + sd);
+ if (f.isDirectory()) {
+ String files[] = f.list();
+
+ if (files == null) {
+ log.warn("The current directory " + f.getAbsolutePath() + " is empty. Has no files");
+ return false;
+ }
+
+ for (int i = 0; i < files.length; i++) {
+ FileInputStream fi = new FileInputStream(srcFolder + "/" + sd + "/" + files[i]);
+ origin = new BufferedInputStream(fi, BUFFER);
+ ZipEntry entry = new ZipEntry(sd + "/" + files[i]);
+ out.putNextEntry(entry);
+ int count;
+ while ((count = origin.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ out.flush();
+ }
+
+ }
+ } else //it is just a file
+ {
+ FileInputStream fi = new FileInputStream(f);
+ origin = new BufferedInputStream(fi, BUFFER);
+ ZipEntry entry = new ZipEntry(sd);
+ out.putNextEntry(entry);
+ int count;
+ while ((count = origin.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ out.flush();
+ }
+ }
+ }
+ out.flush();
+ } finally {
+ if (origin != null) {
+ origin.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ }
+ return true;
+ }
}
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/pom.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/pom.xml
deleted file mode 100644
index 189e2de7d..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/pom.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
-
-
-
-
-
- raspberrypi-plugin
- org.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
- ../pom.xml
-
-
- 4.0.0
- org.wso2.carbon.device.mgt.iot.raspberrypi.plugin
- bundle
- WSO2 Carbon - IoT Server RaspberryPi Management Plugin
- WSO2 Carbon - RaspberryPi Management/Control Plugin Implementation
- http://wso2.org
-
-
-
-
- org.apache.felix
- maven-scr-plugin
-
-
- maven-compiler-plugin
-
- 1.7
- 1.7
-
- 2.3.2
-
-
- org.apache.felix
- maven-bundle-plugin
- 1.4.0
- true
-
-
- ${project.artifactId}
- ${project.artifactId}
- ${carbon.devicemgt.plugins.version}
- IoT Server Impl Bundle
- org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.internal
-
- org.osgi.framework,
- org.osgi.service.component,
- org.apache.commons.logging,
- javax.naming;resolution:=optional,
- javax.sql;resolution:=optional,
- org.wso2.carbon.device.mgt.common.*,
- org.wso2.carbon.device.mgt.common,
- org.wso2.carbon.device.mgt.iot.*,
- org.wso2.carbon.device.mgt.extensions.feature.mgt.*,
- org.wso2.carbon.utils.*,
- org.wso2.carbon.base,
- org.wso2.carbon.context,
- org.wso2.carbon.core,
- org.wso2.carbon.core.util,
- org.wso2.carbon.ndatasource.core,
- org.wso2.carbon.device.mgt.iot.devicetype.*
-
-
- !org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.internal,
- org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.*
-
-
-
-
-
-
-
-
-
- org.eclipse.osgi
- org.eclipse.osgi
-
-
- org.eclipse.osgi
- org.eclipse.osgi.services
-
-
- org.wso2.carbon
- org.wso2.carbon.logging
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.common
-
-
- org.wso2.carbon
- org.wso2.carbon.ndatasource.core
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.extensions
-
-
- org.wso2.carbon
- org.wso2.carbon.utils
-
-
- org.wso2.carbon.devicemgt-plugins
- org.wso2.carbon.device.mgt.iot
-
-
-
\ No newline at end of file
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/exception/RaspberrypiDeviceMgtPluginException.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/exception/RaspberrypiDeviceMgtPluginException.java
deleted file mode 100644
index 805775195..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/exception/RaspberrypiDeviceMgtPluginException.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.exception;
-
-
-public class RaspberrypiDeviceMgtPluginException extends Exception{
-
- private String errorMessage;
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- public RaspberrypiDeviceMgtPluginException(String msg, Exception nestedEx) {
- super(msg, nestedEx);
- setErrorMessage(msg);
- }
-
- public RaspberrypiDeviceMgtPluginException(String message, Throwable cause) {
- super(message, cause);
- setErrorMessage(message);
- }
-
- public RaspberrypiDeviceMgtPluginException(String msg) {
- super(msg);
- setErrorMessage(msg);
- }
-
- public RaspberrypiDeviceMgtPluginException() {
- super();
- }
-
- public RaspberrypiDeviceMgtPluginException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java
deleted file mode 100644
index 00370b8bf..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.DeviceManager;
-import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
-import org.wso2.carbon.device.mgt.common.FeatureManager;
-import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
-import org.wso2.carbon.device.mgt.common.license.mgt.License;
-import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.exception.RaspberrypiDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.dao.RaspberrypiDAOUtil;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.feature.RaspberrypiFeatureManager;
-
-import java.util.List;
-
-/**
- * This represents the Raspberrypi implementation of DeviceManagerService.
- */
-public class RaspberrypiManager implements DeviceManager {
-
- private static final RaspberrypiDAOUtil raspberrypiDAO = new RaspberrypiDAOUtil();
- private static final Log log = LogFactory.getLog(RaspberrypiManager.class);
- private RaspberrypiFeatureManager raspberrypiFeatureManager = new RaspberrypiFeatureManager();
- @Override
- public FeatureManager getFeatureManager() {
- return raspberrypiFeatureManager;
- }
-
- @Override
- public boolean saveConfiguration(PlatformConfiguration tenantConfiguration)
- throws DeviceManagementException {
- return false;
- }
-
- @Override
- public PlatformConfiguration getConfiguration() throws DeviceManagementException {
- return null;
- }
-
- @Override
- public boolean enrollDevice(Device device) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Enrolling a new Raspberrypi device : " + device.getDeviceIdentifier());
- }
- RaspberrypiDAOUtil.beginTransaction();
- status = raspberrypiDAO.getDeviceDAO().addDevice(device);
- RaspberrypiDAOUtil.commitTransaction();
- } catch (RaspberrypiDeviceMgtPluginException e) {
- try {
- RaspberrypiDAOUtil.rollbackTransaction();
- } catch (RaspberrypiDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the device enrol transaction :" + device.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg = "Error while enrolling the Raspberrypi device : " + device.getDeviceIdentifier();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean modifyEnrollment(Device device) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Modifying the Raspberrypi device enrollment data");
- }
- RaspberrypiDAOUtil.beginTransaction();
- status = raspberrypiDAO.getDeviceDAO().updateDevice(device);
- RaspberrypiDAOUtil.commitTransaction();
- } catch (RaspberrypiDeviceMgtPluginException e) {
- try {
- RaspberrypiDAOUtil.rollbackTransaction();
- } catch (RaspberrypiDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the update device transaction :" + device.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg = "Error while updating the enrollment of the Raspberrypi device : " +
- device.getDeviceIdentifier();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Dis-enrolling Raspberrypi device : " + deviceId);
- }
- RaspberrypiDAOUtil.beginTransaction();
- status = raspberrypiDAO.getDeviceDAO().deleteDevice(deviceId.getId());
- RaspberrypiDAOUtil.commitTransaction();
- } catch (RaspberrypiDeviceMgtPluginException e) {
- try {
- RaspberrypiDAOUtil.rollbackTransaction();
- } catch (RaspberrypiDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg = "Error while removing the Raspberrypi device : " + deviceId.getId();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
- boolean isEnrolled = false;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Checking the enrollment of Raspberrypi device : " + deviceId.getId());
- }
- Device iotDevice = raspberrypiDAO.getDeviceDAO().getDevice(deviceId.getId());
- if (iotDevice != null) {
- isEnrolled = true;
- }
- } catch (RaspberrypiDeviceMgtPluginException e) {
- String msg = "Error while checking the enrollment status of Raspberrypi device : " +
- deviceId.getId();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return isEnrolled;
- }
-
- @Override
- public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
- return true;
- }
-
- @Override
- public boolean setActive(DeviceIdentifier deviceId, boolean status)
- throws DeviceManagementException {
- return true;
- }
-
- @Override
- public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
- Device device;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Getting the details of Raspberrypi device : " + deviceId.getId());
- }
- device = raspberrypiDAO.getDeviceDAO().getDevice(deviceId.getId());
- } catch (RaspberrypiDeviceMgtPluginException e) {
- String msg = "Error while fetching the Raspberrypi device : " + deviceId.getId();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return device;
- }
-
- @Override
- public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
- throws DeviceManagementException {
- return true;
- }
-
- public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
- EnrolmentInfo.Status status) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public License getLicense(String s) throws LicenseManagementException {
- return null;
- }
-
- @Override
- public void addLicense(License license) throws LicenseManagementException {
-
- }
-
- @Override
- public boolean requireDeviceAuthorization() {
- return false;
- }
-
- @Override
- public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug(
- "updating the details of Raspberrypi device : " + deviceIdentifier);
- }
- RaspberrypiDAOUtil.beginTransaction();
- status = raspberrypiDAO.getDeviceDAO().updateDevice(device);
- RaspberrypiDAOUtil.commitTransaction();
- } catch (RaspberrypiDeviceMgtPluginException e) {
- try {
- RaspberrypiDAOUtil.rollbackTransaction();
- } catch (RaspberrypiDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the update device info transaction :" + device.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg =
- "Error while updating the Raspberrypi device : " + deviceIdentifier;
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public List getAllDevices() throws DeviceManagementException {
- List devices = null;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Fetching the details of all Raspberrypi devices");
- }
- List iotDevices = raspberrypiDAO.getDeviceDAO().getAllDevices();
- } catch (RaspberrypiDeviceMgtPluginException e) {
- String msg = "Error while fetching all Raspberrypi devices.";
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return devices;
- }
-}
\ No newline at end of file
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java
deleted file mode 100644
index b0c3858c7..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl;
-
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.DeviceManager;
-import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
-import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
-import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
-import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiConstants;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.internal.RaspberrypiManagementDataHolder;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class RaspberrypiManagerService implements DeviceManagementService {
-
- private DeviceManager deviceManager;
- private PushNotificationConfig pushNotificationConfig;
-
- @Override
- public String getType() {
- return RaspberrypiConstants.DEVICE_TYPE;
- }
-
- @Override
- public void init() throws DeviceManagementException {
- deviceManager = new RaspberrypiManager();
- this.pushNotificationConfig = this.populatePushNotificationConfig();
- }
-
- private PushNotificationConfig populatePushNotificationConfig() {
- DeviceManagementConfiguration deviceManagementConfiguration = RaspberrypiManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(RaspberrypiConstants.DEVICE_TYPE,
- RaspberrypiConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- org.wso2.carbon.device.mgt.iot.devicetype.config.PushNotificationConfig sourceConfig =
- deviceManagementConfiguration.getPushNotificationConfig();
- Map staticProps = new HashMap<>();
- for (org.wso2.carbon.device.mgt.iot.devicetype.config.PushNotificationConfig.Property
- property : sourceConfig.getProperties()) {
- staticProps.put(property.getName(), property.getValue());
- }
- return new PushNotificationConfig(sourceConfig.getPushNotificationProvider(), staticProps);
- }
-
- @Override
- public DeviceManager getDeviceManager() {
- return deviceManager;
- }
-
- @Override
- public ApplicationManager getApplicationManager() {
- return null;
- }
-
- @Override
- public ProvisioningConfig getProvisioningConfig() {
- DeviceManagementConfiguration deviceManagementConfiguration = RaspberrypiManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(RaspberrypiConstants.DEVICE_TYPE,
- RaspberrypiConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- boolean sharedWithAllTenants = deviceManagementConfiguration.getDeviceManagementConfigRepository()
- .getProvisioningConfig().isSharedWithAllTenants();
- return new ProvisioningConfig(RaspberrypiConstants.DEVICE_TYPE_PROVIDER_DOMAIN, sharedWithAllTenants);
- }
-
- @Override
- public PushNotificationConfig getPushNotificationConfig() {
- return pushNotificationConfig;
- }
-
-
-}
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/RaspberrypiDAOUtil.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/RaspberrypiDAOUtil.java
deleted file mode 100644
index fd1adbc4d..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/RaspberrypiDAOUtil.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.dao;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.exception.RaspberrypiDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiConstants;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.internal.RaspberrypiManagementDataHolder;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-public class RaspberrypiDAOUtil {
-
- private static final Log log = LogFactory.getLog(RaspberrypiDAOUtil.class);
- static DataSource dataSource;
- private static ThreadLocal currentConnection = new ThreadLocal();
-
- public RaspberrypiDAOUtil() {
- initRaspberrypiDAO();
- }
-
- public RaspberrypiDeviceDAO getDeviceDAO() {
- return new RaspberrypiDeviceDAO();
- }
-
- public static void initRaspberrypiDAO() {
- DeviceManagementConfiguration deviceManagementConfiguration = RaspberrypiManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(RaspberrypiConstants.DEVICE_TYPE,
- RaspberrypiConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- String datasource = deviceManagementConfiguration.getDeviceManagementConfigRepository().getDataSourceConfig()
- .getJndiLookupDefinition().getJndiName();
- try {
- Context ctx = new InitialContext();
- dataSource = (DataSource) ctx.lookup(datasource);
- } catch (NamingException e) {
- log.error("Error while looking up the data source: " + datasource, e);
- }
- }
-
- public static void beginTransaction() throws RaspberrypiDeviceMgtPluginException {
- try {
- Connection conn = dataSource.getConnection();
- conn.setAutoCommit(false);
- currentConnection.set(conn);
- } catch (SQLException e) {
- throw new RaspberrypiDeviceMgtPluginException("Error occurred while retrieving datasource connection", e);
- }
- }
-
- public static Connection getConnection() throws RaspberrypiDeviceMgtPluginException {
- if (currentConnection.get() == null) {
- try {
- currentConnection.set(dataSource.getConnection());
- } catch (SQLException e) {
- throw new RaspberrypiDeviceMgtPluginException("Error occurred while retrieving data source connection", e);
- }
- }
- return currentConnection.get();
- }
-
- public static void commitTransaction() throws RaspberrypiDeviceMgtPluginException {
- try {
- Connection conn = currentConnection.get();
- if (conn != null) {
- conn.commit();
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Datasource connection associated with the current thread is null, hence commit "
- + "has not been attempted");
- }
- }
- } catch (SQLException e) {
- throw new RaspberrypiDeviceMgtPluginException("Error occurred while committing the transaction", e);
- } finally {
- closeConnection();
- }
- }
-
- public static void closeConnection() throws RaspberrypiDeviceMgtPluginException {
- Connection con = currentConnection.get();
- if (con != null) {
- try {
- con.close();
- } catch (SQLException e) {
- log.error("Error occurred while close the connection");
- }
- }
- currentConnection.remove();
- }
-
- public static void rollbackTransaction() throws RaspberrypiDeviceMgtPluginException {
- try {
- Connection conn = currentConnection.get();
- if (conn != null) {
- conn.rollback();
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Datasource connection associated with the current thread is null, hence rollback "
- + "has not been attempted");
- }
- }
- } catch (SQLException e) {
- throw new RaspberrypiDeviceMgtPluginException("Error occurred while rollback the transaction", e);
- } finally {
- closeConnection();
- }
- }
-}
\ No newline at end of file
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/RaspberrypiDeviceDAO.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/RaspberrypiDeviceDAO.java
deleted file mode 100644
index 83cb3f51c..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/RaspberrypiDeviceDAO.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.dao;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.exception.RaspberrypiDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.util.RaspberrypiUtils;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiConstants;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Implements CRUD for Raspberrypi Devices.
- */
-public class RaspberrypiDeviceDAO {
-
- private static final Log log = LogFactory.getLog(RaspberrypiDeviceDAO.class);
-
- public Device getDevice(String iotDeviceId) throws RaspberrypiDeviceMgtPluginException {
- Connection conn;
- PreparedStatement stmt = null;
- Device device = null;
- ResultSet resultSet = null;
- try {
- conn = RaspberrypiDAOUtil.getConnection();
- String selectDBQuery =
- "SELECT RASPBERRYPI_DEVICE_ID, DEVICE_NAME FROM RASPBERRYPI_DEVICE WHERE RASPBERRYPI_DEVICE_ID = ?";
- stmt = conn.prepareStatement(selectDBQuery);
- stmt.setString(1, iotDeviceId);
- resultSet = stmt.executeQuery();
-
- if (resultSet.next()) {
- device = new Device();
- device.setName(resultSet.getString(RaspberrypiConstants.DEVICE_PLUGIN_DEVICE_NAME));
- if (log.isDebugEnabled()) {
- log.debug("Raspberrypi device " + iotDeviceId + " data has been fetched from " +
- "Raspberrypi database.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while fetching Raspberrypi device : '" + iotDeviceId + "'";
- log.error(msg, e);
- throw new RaspberrypiDeviceMgtPluginException(msg, e);
- } finally {
- RaspberrypiUtils.cleanupResources(stmt, resultSet);
- RaspberrypiDAOUtil.closeConnection();
- }
- return device;
- }
-
- public boolean addDevice(Device device) throws RaspberrypiDeviceMgtPluginException {
- boolean status = false;
- Connection conn;
- PreparedStatement stmt = null;
- try {
- conn = RaspberrypiDAOUtil.getConnection();
- String createDBQuery =
- "INSERT INTO RASPBERRYPI_DEVICE(RASPBERRYPI_DEVICE_ID, DEVICE_NAME) VALUES (?, ?)";
-
- stmt = conn.prepareStatement(createDBQuery);
- stmt.setString(1, device.getDeviceIdentifier());
- stmt.setString(2, device.getName());
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Raspberrypi device " + device.getDeviceIdentifier() + " data has been" +
- " added to the Raspberrypi database.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while adding the Raspberrypi device '" +
- device.getDeviceIdentifier() + "' to the Raspberrypi db.";
- log.error(msg, e);
- throw new RaspberrypiDeviceMgtPluginException(msg, e);
- } finally {
- RaspberrypiUtils.cleanupResources(stmt, null);
- }
- return status;
- }
-
- public boolean updateDevice(Device device) throws RaspberrypiDeviceMgtPluginException {
- boolean status = false;
- Connection conn;
- PreparedStatement stmt = null;
- try {
- conn = RaspberrypiDAOUtil.getConnection();
- String updateDBQuery = "UPDATE RASPBERRYPI_DEVICE SET DEVICE_NAME = ? WHERE RASPBERRYPI_DEVICE_ID = ?";
- stmt = conn.prepareStatement(updateDBQuery);
- stmt.setString(1, device.getName());
- stmt.setString(2, device.getDeviceIdentifier());
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Raspberrypi device " + device.getDeviceIdentifier() + " data has been" +
- " modified.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while modifying the Raspberrypi device '" + device.getDeviceIdentifier()
- + "' data.";
- log.error(msg, e);
- throw new RaspberrypiDeviceMgtPluginException(msg, e);
- } finally {
- RaspberrypiUtils.cleanupResources(stmt, null);
- }
- return status;
- }
-
- public boolean deleteDevice(String iotDeviceId) throws RaspberrypiDeviceMgtPluginException {
- boolean status = false;
- Connection conn;
- PreparedStatement stmt = null;
- try {
- conn = RaspberrypiDAOUtil.getConnection();
- String deleteDBQuery = "DELETE FROM RASPBERRYPI_DEVICE WHERE RASPBERRYPI_DEVICE_ID = ?";
- stmt = conn.prepareStatement(deleteDBQuery);
- stmt.setString(1, iotDeviceId);
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Raspberrypi device " + iotDeviceId + " data has deleted" +
- " from the Raspberrypi database.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while deleting Raspberrypi device " + iotDeviceId;
- log.error(msg, e);
- throw new RaspberrypiDeviceMgtPluginException(msg, e);
- } finally {
- RaspberrypiUtils.cleanupResources(stmt, null);
- }
- return status;
- }
-
- public List getAllDevices() throws RaspberrypiDeviceMgtPluginException {
- Connection conn;
- PreparedStatement stmt = null;
- ResultSet resultSet = null;
- Device device;
- List devices = new ArrayList<>();
- try {
- conn = RaspberrypiDAOUtil.getConnection();
- String selectDBQuery = "SELECT RASPBERRYPI_DEVICE_ID, DEVICE_NAME FROM RASPBERRYPI_DEVICE";
- stmt = conn.prepareStatement(selectDBQuery);
- resultSet = stmt.executeQuery();
- while (resultSet.next()) {
- device = new Device();
- device.setDeviceIdentifier(resultSet.getString(RaspberrypiConstants.DEVICE_PLUGIN_DEVICE_ID));
- device.setName(resultSet.getString(RaspberrypiConstants.DEVICE_PLUGIN_DEVICE_NAME));
- devices.add(device);
- }
- if (log.isDebugEnabled()) {
- log.debug("All Raspberrypi device details have fetched from Raspberrypi database.");
- }
- return devices;
- } catch (SQLException e) {
- String msg = "Error occurred while fetching all Raspberrypi device data'";
- log.error(msg, e);
- throw new RaspberrypiDeviceMgtPluginException(msg, e);
- } finally {
- RaspberrypiUtils.cleanupResources(stmt, resultSet);
- RaspberrypiDAOUtil.closeConnection();
- }
- }
-}
\ No newline at end of file
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/feature/RaspberrypiFeatureManager.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/feature/RaspberrypiFeatureManager.java
deleted file mode 100644
index 755b7ae0d..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/feature/RaspberrypiFeatureManager.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.feature;
-
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.Feature;
-import org.wso2.carbon.device.mgt.common.FeatureManager;
-import org.wso2.carbon.device.mgt.extensions.feature.mgt.GenericFeatureManager;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiConstants;
-
-import java.util.List;
-
-public class RaspberrypiFeatureManager implements FeatureManager {
- @Override
- public boolean addFeature(Feature feature) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean addFeatures(List features) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public Feature getFeature(String name) throws DeviceManagementException {
- GenericFeatureManager genericFeatureManager = GenericFeatureManager.getInstance();
- return genericFeatureManager.getFeature(RaspberrypiConstants.DEVICE_TYPE, name);
- }
-
- @Override
- public List getFeatures() throws DeviceManagementException {
- GenericFeatureManager genericFeatureManager = GenericFeatureManager.getInstance();
- return genericFeatureManager.getFeatures(RaspberrypiConstants.DEVICE_TYPE);
- }
-
- @Override
- public boolean removeFeature(String name) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
- return false;
- }
-}
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/DeviceSchemaInitializer.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/DeviceSchemaInitializer.java
deleted file mode 100644
index ba790567a..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/DeviceSchemaInitializer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.iot.raspberrypi.plugin.impl.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiConstants;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
-
-import javax.sql.DataSource;
-import java.io.File;
-
-/**
- * Provides methods for initializing the database script.
- */
-public class DeviceSchemaInitializer extends DatabaseCreator{
-
- private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class);
- private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts"
- + File.separator + "cdm" + File.separator + "plugins" + File.separator + RaspberrypiConstants.DEVICE_TYPE
- + File.separator;
-
- public DeviceSchemaInitializer(DataSource dataSource) {
- super(dataSource);
- }
-
- @Override
- protected String getDbScriptLocation(String databaseType) {
- String scriptName = databaseType + ".sql";
- if (log.isDebugEnabled()) {
- log.debug("Loading database script from :" + scriptName);
- }
- return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName;
- }
-}
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/RaspberrypiUtils.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/RaspberrypiUtils.java
deleted file mode 100644
index 8bd1b6e2e..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/RaspberrypiUtils.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.core.util.Utils;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiConstants;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.exception.RaspberrypiDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.internal.RaspberrypiManagementDataHolder;
-import org.wso2.carbon.event.output.adapter.core.MessageType;
-import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration;
-import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Contains utility methods used by Raspberrypi plugin.
- */
-public class RaspberrypiUtils {
-
- private static Log log = LogFactory.getLog(RaspberrypiUtils.class);
-
- public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException e) {
- log.warn("Error occurred while closing result set", e);
- }
- }
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException e) {
- log.warn("Error occurred while closing prepared statement", e);
- }
- }
- if (conn != null) {
- try {
- conn.close();
- } catch (SQLException e) {
- log.warn("Error occurred while closing database connection", e);
- }
- }
- }
-
- public static void cleanupResources(PreparedStatement stmt, ResultSet rs) {
- cleanupResources(null, stmt, rs);
- }
-
- /**
- * Creates the device management schema.
- */
- public static void setupDeviceManagementSchema() throws RaspberrypiDeviceMgtPluginException {
- DeviceManagementConfiguration deviceManagementConfiguration = RaspberrypiManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(RaspberrypiConstants.DEVICE_TYPE,
- RaspberrypiConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- String datasource = deviceManagementConfiguration.getDeviceManagementConfigRepository().getDataSourceConfig()
- .getJndiLookupDefinition().getJndiName();
- try {
- Context ctx = new InitialContext();
- DataSource dataSource = (DataSource) ctx.lookup(datasource);
- DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
- String checkSql = "select * from RASPBERRYPI_DEVICE";
- if (!initializer.isDatabaseStructureCreated(checkSql)) {
- log.info("Initializing device management repository database schema");
- initializer.createRegistryDatabase();
- } else {
- log.info("Device management repository database already exists. Not creating a new database.");
- }
- } catch (NamingException e) {
- log.error("Error while looking up the data source: " + datasource, e);
- } catch (Exception e) {
- throw new RaspberrypiDeviceMgtPluginException("Error occurred while initializing Iot Device " +
- "Management database schema", e);
- }
- }
-
-}
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/internal/RaspberrypiManagementDataHolder.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/internal/RaspberrypiManagementDataHolder.java
deleted file mode 100644
index a582b54ed..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/internal/RaspberrypiManagementDataHolder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * you may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.internal;
-
-import org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService;
-import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
-
-/**
- * DataHolder class of plugins component.
- */
-public class RaspberrypiManagementDataHolder {
-
- private DeviceTypeConfigService deviceTypeConfigService;
-
- private static RaspberrypiManagementDataHolder thisInstance = new RaspberrypiManagementDataHolder();
-
- private RaspberrypiManagementDataHolder() {
- }
-
- public static RaspberrypiManagementDataHolder getInstance() {
- return thisInstance;
- }
-
- public DeviceTypeConfigService getDeviceTypeConfigService() {
- return deviceTypeConfigService;
- }
-
- public void setDeviceTypeConfigService(
- DeviceTypeConfigService deviceTypeConfigService) {
- this.deviceTypeConfigService = deviceTypeConfigService;
- }
-
-}
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/internal/RaspberrypiManagementServiceComponent.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/internal/RaspberrypiManagementServiceComponent.java
deleted file mode 100644
index 9b4e3de02..000000000
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/internal/RaspberrypiManagementServiceComponent.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.internal;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
-import org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.exception.RaspberrypiDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.RaspberrypiManagerService;
-import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.util.RaspberrypiUtils;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-
-/**
- * @scr.component name="org.wso2.carbon.device.mgt.iot.raspberrypi.internal.RaspberrypiManagementServiceComponent"
- * immediate="true"
- * @scr.reference name="org.wso2.carbon.ndatasource"
- * interface="org.wso2.carbon.ndatasource.core.DataSourceService"
- * cardinality="1..1"
- * policy="dynamic"
- * bind="setDataSourceService"
- * unbind="unsetDataSourceService"
- * @scr.reference name="devicetype.configuration.service"
- * interface="org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService"
- * cardinality="1..1"
- * policy="dynamic"
- * bind="setDeviceTypeConfigService"
- * unbind="unsetDeviceTypeConfigService"
- */
-public class RaspberrypiManagementServiceComponent {
-
- private ServiceRegistration raspberrypiServiceRegRef;
- private static final Log log = LogFactory.getLog(RaspberrypiManagementServiceComponent.class);
-
- protected void activate(ComponentContext ctx) {
- if (log.isDebugEnabled()) {
- log.debug("Activating Raspberrypi Device Management Service Component");
- }
- try {
- BundleContext bundleContext = ctx.getBundleContext();
- raspberrypiServiceRegRef = bundleContext.registerService(DeviceManagementService.class.getName(),
- new RaspberrypiManagerService(), null);
- String setupOption = System.getProperty("setup");
- if (setupOption != null) {
- if (log.isDebugEnabled()) {
- log.debug("-Dsetup is enabled. Iot Device management repository schema initialization is about " +
- "to begin");
- }
- try {
- RaspberrypiUtils.setupDeviceManagementSchema();
- } catch (RaspberrypiDeviceMgtPluginException e) {
- log.error("Exception occurred while initializing device management database schema", e);
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("Raspberrypi Device Management Service Component has been successfully activated");
- }
- } catch (Throwable e) {
- log.error(
- "Error occurred while activating Raspberrypi Device Management Service Component", e);
- }
- }
-
- protected void deactivate(ComponentContext ctx) {
- if (log.isDebugEnabled()) {
- log.debug("De-activating Raspberrypi Device Management Service Component");
- }
- try {
- if (raspberrypiServiceRegRef != null) {
- raspberrypiServiceRegRef.unregister();
- }
- if (log.isDebugEnabled()) {
- log.debug("Raspberrypi Device Management Service Component has been successfully de-activated");
- }
- } catch (Throwable e) {
- log.error("Error occurred while de-activating Raspberrypi Device Management bundle", e);
- }
- }
-
- protected void setDataSourceService(DataSourceService dataSourceService) {
- /* This is to avoid mobile device management component getting initialized before the underlying datasources
- are registered */
- if (log.isDebugEnabled()) {
- log.debug("Data source service set to service component");
- }
- }
-
- protected void unsetDataSourceService(DataSourceService dataSourceService) {
- //do nothing
- }
-
- protected void setDeviceTypeConfigService(DeviceTypeConfigService deviceTypeConfigService) {
- RaspberrypiManagementDataHolder.getInstance().setDeviceTypeConfigService(deviceTypeConfigService);
- }
-
- protected void unsetDeviceTypeConfigService(DeviceTypeConfigService deviceTypeConfigService) {
- RaspberrypiManagementDataHolder.getInstance().setDeviceTypeConfigService(null);
- }
-
-}
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml
index 7651ff38d..f045606c1 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml
@@ -23,7 +23,7 @@
raspberrypi-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.hbs b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.hbs
index 9b6cf69dc..d881228b8 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.hbs
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.hbs
@@ -64,9 +64,9 @@
01
- Connect RaspberryPi, DHT11 Temperature sensor and LED as per the
+ Connect RaspberryPi, DHT11 Temperature sensor and LED as per the
schematic below.
02
- Ensure your RaspberryPi Board can connect to Internet.
+ Ensure your RaspberryPi Board can connect to Internet.
03
- Download RaspberryPi Agent via [Download Agent] button above.
+ Download RaspberryPi Agent via [Download Agent] button above.
(Alternatively you can use the "curl" command to directly download the Agent to your
RaspberryPi.)
04
- Copy downloaded Agent into your RaspberryPi.
+ Copy downloaded Agent into your RaspberryPi.
05
- Unzip the downloaded Agent and start terminal to run below commands.
+ Unzip the downloaded Agent and start terminal to run below commands.
-
+
- [sudo ./testAgent.sh] - Script to test agent
+ [sudo ./testAgent.sh] - Script to test agent
functionality.
-
+
- [sudo ./startService.sh] - Use this to start
+ [sudo ./startService.sh] - Use this to start
agent as Daemon.
@@ -254,17 +254,17 @@
01
- You can view all your connected devices at
+ You can view all your connected devices at
[Device Management] page.
02
- Select one of connected devices and check for available control
+ Select one of connected devices and check for available control
operations and monitor Real-Time data.
03
- You can also view analytics of the data published to IoT-Server by
+ You can also view analytics of the data published to IoT-Server by
navigating to Device Analytics page.
diff --git a/components/iot-plugins/raspberrypi-plugin/pom.xml b/components/iot-plugins/raspberrypi-plugin/pom.xml
index 468a3f157..1e0ad5f23 100644
--- a/components/iot-plugins/raspberrypi-plugin/pom.xml
+++ b/components/iot-plugins/raspberrypi-plugin/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgt-pluginsiot-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
@@ -33,7 +33,6 @@
http://wso2.org
- org.wso2.carbon.device.mgt.iot.raspberrypi.pluginorg.wso2.carbon.device.mgt.iot.raspberrypi.uiorg.wso2.carbon.device.mgt.iot.raspberrypi.apiorg.wso2.carbon.device.mgt.iot.raspberrypi.analytics
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml
index fcaa97701..49852083b 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml
@@ -23,7 +23,7 @@
virtual-fire-alarm-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml
index 53cd03c0d..edcaf1c5e 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml
@@ -23,7 +23,7 @@
virtual-fire-alarm-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml
index da6ec336b..0d8e5b5bf 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml
@@ -21,7 +21,7 @@
virtual-fire-alarm-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
@@ -107,16 +107,6 @@
4.1provided
-
- org.wso2.carbon.devicemgt-plugins
- org.wso2.carbon.device.mgt.iot
- provided
-
-
- org.wso2.carbon.devicemgt-plugins
- org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin
- provided
-
@@ -206,18 +196,15 @@
-
commons-codeccommons-codec
-
org.wso2.carbon.devicemgtorg.wso2.carbon.apimgt.annotationsprovided
-
org.igniterealtime.smack.wso2smack
@@ -228,11 +215,6 @@
smackxprovided
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.apimgt.webapp.publisher
- provided
- org.wso2.carbon.devicemgtorg.wso2.carbon.identity.jwt.client.extension
@@ -248,9 +230,17 @@
org.wso2.carbon.analytics.apiprovided
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.extensions
+ provided
+
+
+ org.wso2.carbon.devicemgt-plugins
+ org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin
+ provided
+
-
-
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java
index 486437ac9..ce54d9537 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java
@@ -35,10 +35,9 @@ import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
-import org.wso2.carbon.device.mgt.iot.util.ZipArchive;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util.VirtualFirealarmSecurityManager;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.VirtualFirealarmSecurityManager;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.xmpp.XmppAccount;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.xmpp.XmppConfig;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.xmpp.XmppServerClient;
@@ -46,6 +45,7 @@ import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.dto.SensorRe
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.exception.VirtualFireAlarmException;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util.APIUtil;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util.VirtualFireAlarmServiceUtils;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util.ZipArchive;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util.ZipUtil;
import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java
index 0509eb80b..d302e7281 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java
@@ -3,11 +3,10 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
+import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
-import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDrillDownRequest;
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
-import org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceUtils;
import org.wso2.carbon.analytics.datasource.commons.Record;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
@@ -21,7 +20,6 @@ import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -79,7 +77,7 @@ public class APIUtil {
sortByFields);
List recordIds = getRecordIds(resultEntries);
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
- Map sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords(
+ Map sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords(
analyticsDataAPI, response));
List sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
return sortedSensorData;
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java
index de76845d6..277000e0f 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java
@@ -19,11 +19,9 @@
package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util;
import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util.VirtualFirealarmSecurityManager;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.VirtualFirealarmSecurityManager;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.exception.VirtualFireAlarmException;
import java.lang.*;
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipArchive.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipArchive.java
new file mode 100644
index 000000000..22fda92b3
--- /dev/null
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipArchive.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util;
+
+import java.io.File;
+
+/**
+ * This is an utility class to hold zip files.
+ */
+public class ZipArchive {
+
+ private File zipFile = null;
+ private String fileName = null;
+
+ public ZipArchive(String fileName, File zipFile) {
+ this.fileName = fileName;
+ this.zipFile = zipFile;
+ }
+
+ public File getZipFile() {
+ return zipFile;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java
index 01990fe51..feb8135db 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java
@@ -19,24 +19,40 @@
package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util;
import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;
import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants;
+import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
-import org.wso2.carbon.device.mgt.iot.util.Utils;
-import org.wso2.carbon.device.mgt.iot.util.ZipArchive;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.xmpp.XmppConfig;
import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.NetworkUtils;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.SocketException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
/**
* This is used to create a zip file that includes the necessary configuration required for the agent.
@@ -52,6 +68,7 @@ public class ZipUtil {
private static final String HTTP_PROTOCOL_APPENDER = "http://";
private static final String CONFIG_TYPE = "general";
private static final String DEFAULT_MQTT_ENDPOINT = "tcp://localhost:1883";
+ public static final String HOST_NAME = "HostName";
public ZipArchive createZipFile(String owner, String deviceType, String deviceId, String deviceName,
String apiApplicationKey, String token, String refreshToken)
@@ -65,7 +82,7 @@ public class ZipUtil {
String iotServerIP;
try {
- iotServerIP = Utils.getServerUrl();
+ iotServerIP = getServerUrl();
String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY);
String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY);
String httpsServerEP = HTTPS_PROTOCOL_APPENDER + iotServerIP + ":" + httpsServerPort;
@@ -125,7 +142,7 @@ public class ZipUtil {
? "" : XmppConfig.getInstance().getJid());
ZipArchive zipFile;
- zipFile = Utils.getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName);
+ zipFile = getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName);
return zipFile;
} catch (IOException e) {
throw new DeviceManagementException("Zip File Creation Failed", e);
@@ -142,4 +159,229 @@ public class ZipUtil {
String stringToEncode = consumerKey + ":" + consumerSecret;
return Base64.encodeBase64String(stringToEncode.getBytes());
}
+
+ public static String getServerUrl() {
+ String hostName = ServerConfiguration.getInstance().getFirstProperty(HOST_NAME);
+ try {
+ if (hostName == null) {
+ hostName = NetworkUtils.getLocalHostname();
+ }
+ } catch (SocketException e) {
+ hostName = "localhost";
+ log.warn("Failed retrieving the hostname, therefore set to localhost", e);
+ }
+ return hostName;
+ }
+
+ public static ZipArchive getSketchArchive(String archivesPath, String templateSketchPath, Map contextParams
+ , String zipFileName)
+ throws DeviceManagementException, IOException {
+ String sketchPath = CarbonUtils.getCarbonHome() + File.separator + templateSketchPath;
+ FileUtils.deleteDirectory(new File(archivesPath));//clear directory
+ FileUtils.deleteDirectory(new File(archivesPath + ".zip"));//clear zip
+ if (!new File(archivesPath).mkdirs()) { //new dir
+ String message = "Could not create directory at path: " + archivesPath;
+ log.error(message);
+ throw new DeviceManagementException(message);
+ }
+ zipFileName = zipFileName + ".zip";
+ try {
+ Map> properties = getProperties(sketchPath + File.separator + "sketch" + ".properties");
+ List templateFiles = properties.get("templates");
+
+ for (String templateFile : templateFiles) {
+ parseTemplate(templateSketchPath + File.separator + templateFile, archivesPath + File.separator + templateFile,
+ contextParams);
+ }
+
+ templateFiles.add("sketch.properties"); // ommit copying the props file
+ copyFolder(new File(sketchPath), new File(archivesPath), templateFiles);
+ createZipArchive(archivesPath);
+ FileUtils.deleteDirectory(new File(archivesPath));
+ File zip = new File(archivesPath + ".zip");
+ return new org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util.ZipArchive(zipFileName, zip);
+ } catch (IOException ex) {
+ throw new DeviceManagementException(
+ "Error occurred when trying to read property " + "file sketch.properties", ex);
+ }
+ }
+
+ private static Map> getProperties(String propertyFilePath) throws IOException {
+ Properties prop = new Properties();
+ InputStream input = null;
+
+ try {
+
+ input = new FileInputStream(propertyFilePath);
+
+ // load a properties file
+ prop.load(input);
+ Map> properties = new HashMap>();
+
+ String templates = prop.getProperty("templates");
+ List list = new ArrayList(Arrays.asList(templates.split(",")));
+ properties.put("templates", list);
+
+ final String filename = prop.getProperty("zipfilename");
+ list = new ArrayList() {{
+ add(filename);
+ }};
+ properties.put("zipfilename", list);
+ return properties;
+
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (IOException e) {
+ log.error("Failed closing connection", e);
+ }
+ }
+ }
+ }
+
+ private static void parseTemplate(String srcFile, String dstFile, Map contextParams) throws IOException {
+ //read from file
+ FileInputStream inputStream = null;
+ FileOutputStream outputStream = null;
+ try {
+ inputStream = new FileInputStream(srcFile);
+ outputStream = new FileOutputStream(dstFile);
+ String content = IOUtils.toString(inputStream, StandardCharsets.UTF_8.toString());
+ Iterator iterator = contextParams.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry mapEntry = (Map.Entry) iterator.next();
+ content = content.replaceAll("\\$\\{" + mapEntry.getKey() + "\\}", mapEntry.getValue().toString());
+ }
+ IOUtils.write(content, outputStream, StandardCharsets.UTF_8.toString());
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ }
+ }
+
+ private static void copyFolder(File src, File dest, List excludeFileNames) throws IOException {
+
+ if (src.isDirectory()) {
+ //if directory not exists, create it
+ if (!dest.exists() && !dest.mkdirs()) {
+ String message = "Could not create directory at path: " + dest;
+ log.error(message);
+ throw new IOException(message);
+ }
+ //list all the directory contents
+ String files[] = src.list();
+
+ if (files == null) {
+ log.warn("There are no files insides the directory " + src.getAbsolutePath());
+ return;
+ }
+
+ for (String file : files) {
+ //construct the src and dest file structure
+ File srcFile = new File(src, file);
+ File destFile = new File(dest, file);
+ //recursive copy
+ copyFolder(srcFile, destFile, excludeFileNames);
+ }
+
+ } else {
+ for (String fileName : excludeFileNames) {
+ if (src.getName().equals(fileName)) {
+ return;
+ }
+ }
+ //if file, then copy it
+ //Use bytes stream to support all file types
+ InputStream in = null;
+ OutputStream out = null;
+
+ try {
+ in = new FileInputStream(src);
+ out = new FileOutputStream(dest);
+
+ byte[] buffer = new byte[1024];
+
+ int length;
+ //copy the file content in bytes
+ while ((length = in.read(buffer)) > 0) {
+ out.write(buffer, 0, length);
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+ }
+
+ private static boolean createZipArchive(String srcFolder) throws IOException {
+ BufferedInputStream origin = null;
+ ZipOutputStream out = null;
+
+ try {
+ final int BUFFER = 2048;
+ FileOutputStream dest = new FileOutputStream(new File(srcFolder + ".zip"));
+ out = new ZipOutputStream(new BufferedOutputStream(dest));
+ byte data[] = new byte[BUFFER];
+ File subDir = new File(srcFolder);
+ String subdirList[] = subDir.list();
+ if (subdirList == null) {
+ log.warn("The sub directory " + subDir.getAbsolutePath() + " is empty");
+ return false;
+ }
+ for (String sd : subdirList) {
+ // get a list of files from current directory
+ File f = new File(srcFolder + "/" + sd);
+ if (f.isDirectory()) {
+ String files[] = f.list();
+
+ if (files == null) {
+ log.warn("The current directory " + f.getAbsolutePath() + " is empty. Has no files");
+ return false;
+ }
+
+ for (int i = 0; i < files.length; i++) {
+ FileInputStream fi = new FileInputStream(srcFolder + "/" + sd + "/" + files[i]);
+ origin = new BufferedInputStream(fi, BUFFER);
+ ZipEntry entry = new ZipEntry(sd + "/" + files[i]);
+ out.putNextEntry(entry);
+ int count;
+ while ((count = origin.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ out.flush();
+ }
+
+ }
+ } else //it is just a file
+ {
+ FileInputStream fi = new FileInputStream(f);
+ origin = new BufferedInputStream(fi, BUFFER);
+ ZipEntry entry = new ZipEntry(sd);
+ out.putNextEntry(entry);
+ int count;
+ while ((count = origin.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ out.flush();
+ }
+ }
+ }
+ out.flush();
+ } finally {
+ if (origin != null) {
+ origin.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ }
+ return true;
+ }
}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/util/Utils.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/util/Utils.java
new file mode 100644
index 000000000..586de223c
--- /dev/null
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/util/Utils.java
@@ -0,0 +1,61 @@
+/*
+ * 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.iot.virtualfirealarm.service.impl.util.util;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.base.ServerConfiguration;
+import org.wso2.carbon.device.mgt.common.DeviceManagementException;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util.ZipArchive;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.NetworkUtils;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.SocketException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Provides utility methods required by the device type plugins.
+ */
+public class Utils {
+
+ public static final String HOST_NAME = "HostName";
+ private static final Log log = LogFactory.getLog(Utils.class);
+
+
+
+}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml
index 2f18393cf..2d1c6e26b 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml
@@ -24,10 +24,6 @@
doAuthenticationtrue
-
- isSharedWithAllTenants
- true
- providerTenantDomaincarbon.super
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml
index 586307aad..3bfbc0d11 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml
@@ -23,7 +23,7 @@
virtual-fire-alarm-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
@@ -83,7 +83,10 @@
org.wso2.carbon.event.input.adapter.core,
org.wso2.carbon.event.input.adapter.core.exception,
org.jivesoftware.smack.*,
- org.wso2.carbon.device.mgt.iot.devicetype.*
+ javax.xml.bind,
+ javax.xml.bind.annotation,
+ javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}",
+ org.w3c.dom
!org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal,
@@ -160,9 +163,5 @@
org.igniterealtime.smack.wso2smackx
-
- org.wso2.carbon.devicemgt-plugins
- org.wso2.carbon.device.mgt.iot
-
\ No newline at end of file
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/DeviceManagementConfiguration.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/DeviceManagementConfiguration.java
new file mode 100644
index 000000000..f7721fdd2
--- /dev/null
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/DeviceManagementConfiguration.java
@@ -0,0 +1,45 @@
+/*
+ * 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.iot.virtualfirealarm.plugin.config;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "DeviceManagementConfiguration")
+public class DeviceManagementConfiguration {
+
+ private EventListenerConfiguration eventListenerConfiguration;
+
+ private static final Log log = LogFactory.getLog(DeviceManagementConfiguration.class);
+
+ private DeviceManagementConfiguration() {
+ }
+
+ @XmlElement(name = "EventListenerConfiguration", required = false)
+ public EventListenerConfiguration getEventListenerConfiguration() {
+ return eventListenerConfiguration;
+ }
+
+ public void setEventListenerConfiguration(EventListenerConfiguration eventListenerConfiguration) {
+ this.eventListenerConfiguration = eventListenerConfiguration;
+ }
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/PushNotificationConfig.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/EventListenerConfiguration.java
similarity index 78%
rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/PushNotificationConfig.java
rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/EventListenerConfiguration.java
index 71f8eb687..c182b9218 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/PushNotificationConfig.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/EventListenerConfiguration.java
@@ -16,7 +16,7 @@
* under the License.
*
*/
-package org.wso2.carbon.device.mgt.iot.devicetype.config;
+package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
@@ -25,10 +25,10 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import java.util.List;
-@XmlRootElement(name = "PushNotificationConfiguration")
-public class PushNotificationConfig {
+@XmlRootElement(name = "EventListenerConfiguration")
+public class EventListenerConfiguration {
- private String pushNotificationProvider;
+ private String eventListenerProvider;
private List properties;
@XmlElementWrapper(name = "Properties", required = true)
@@ -41,13 +41,13 @@ public class PushNotificationConfig {
this.properties = properties;
}
- @XmlElement(name = "PushNotificationProvider", required = true)
- public String getPushNotificationProvider() {
- return pushNotificationProvider;
+ @XmlElement(name = "EventListenerProvider", required = true)
+ public String getEventListenerProvider() {
+ return eventListenerProvider;
}
- public void setPushNotificationProvider(String pushNotificationProvider) {
- this.pushNotificationProvider = pushNotificationProvider;
+ public void setEventListenerProvider(String eventListenerProvider) {
+ this.eventListenerProvider = eventListenerProvider;
}
@XmlRootElement(name = "Property")
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java
new file mode 100644
index 000000000..a5a75611e
--- /dev/null
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java
@@ -0,0 +1,60 @@
+package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.exception.VirtualFirealarmConfigurationException;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+public class VirtualFirealarmConfig {
+
+ private static final Log log = LogFactory.getLog(VirtualFirealarmConfig.class);
+ private static final String DEVICE_TYPE_CONFIG_PATH =
+ CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-mgt-plugins" + File.separator
+ + "virtual_firealarm.xml";
+ private static VirtualFirealarmConfig virtualFirealarmConfig = new VirtualFirealarmConfig();
+ private static DeviceManagementConfiguration deviceManagementConfiguration;
+
+ public static VirtualFirealarmConfig getInstance() {
+ return virtualFirealarmConfig;
+ }
+
+ public static void initialize() throws VirtualFirealarmConfigurationException {
+ File configFile = new File(DEVICE_TYPE_CONFIG_PATH);
+ try {
+ Document doc = convertToDocument(configFile);
+
+ /* Un-marshaling Webapp Authenticator configuration */
+ JAXBContext ctx = JAXBContext.newInstance(DeviceManagementConfiguration.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ //unmarshaller.setSchema(getSchema());
+ deviceManagementConfiguration = (DeviceManagementConfiguration) unmarshaller.unmarshal(doc);
+ } catch (JAXBException e) {
+ throw new VirtualFirealarmConfigurationException("Error occurred while un-marshalling the file " +
+ DEVICE_TYPE_CONFIG_PATH, e);
+ }
+
+ }
+
+ public DeviceManagementConfiguration getDeviceTypeConfiguration() {
+ return deviceManagementConfiguration;
+ }
+
+ public static Document convertToDocument(File file) throws VirtualFirealarmConfigurationException {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ try {
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ return docBuilder.parse(file);
+ } catch (Exception e) {
+ throw new VirtualFirealarmConfigurationException("Error occurred while parsing file, while converting " +
+ "to a org.w3c.dom.Document", e);
+ }
+ }
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/exception/DeviceTypeConfigurationException.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/exception/VirtualFirealarmConfigurationException.java
similarity index 59%
rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/exception/DeviceTypeConfigurationException.java
rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/exception/VirtualFirealarmConfigurationException.java
index aa0735c10..0cba81bcc 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/exception/DeviceTypeConfigurationException.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/exception/VirtualFirealarmConfigurationException.java
@@ -16,37 +16,37 @@
* under the License.
*
*/
-package org.wso2.carbon.device.mgt.iot.devicetype.config.exception;
+package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.exception;
-public class DeviceTypeConfigurationException extends Exception {
+public class VirtualFirealarmConfigurationException extends Exception {
private static final long serialVersionUID = -3151279431229070297L;
- public DeviceTypeConfigurationException(int errorCode, String message) {
+ public VirtualFirealarmConfigurationException(int errorCode, String message) {
super(message);
}
- public DeviceTypeConfigurationException(int errorCode, String message, Throwable cause) {
+ public VirtualFirealarmConfigurationException(int errorCode, String message, Throwable cause) {
super(message, cause);
}
- public DeviceTypeConfigurationException(String msg, Exception nestedEx) {
+ public VirtualFirealarmConfigurationException(String msg, Exception nestedEx) {
super(msg, nestedEx);
}
- public DeviceTypeConfigurationException(String message, Throwable cause) {
+ public VirtualFirealarmConfigurationException(String message, Throwable cause) {
super(message, cause);
}
- public DeviceTypeConfigurationException(String msg) {
+ public VirtualFirealarmConfigurationException(String msg) {
super(msg);
}
- public DeviceTypeConfigurationException() {
+ public VirtualFirealarmConfigurationException() {
super();
}
- public DeviceTypeConfigurationException(Throwable cause) {
+ public VirtualFirealarmConfigurationException(Throwable cause) {
super(cause);
}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManager.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManager.java
deleted file mode 100644
index 96617f47b..000000000
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManager.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.DeviceManager;
-import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
-import org.wso2.carbon.device.mgt.common.FeatureManager;
-import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
-import org.wso2.carbon.device.mgt.common.license.mgt.License;
-import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.dao.VirtualFireAlarmDAOUtil;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.feature.VirtualFirealarmFeatureManager;
-import java.util.List;
-
-
-/**
- * This represents the FireAlarm implementation of DeviceManagerService.
- */
-public class VirtualFireAlarmManager implements DeviceManager {
-
- private static final VirtualFireAlarmDAOUtil virtualFireAlarmDAO = new VirtualFireAlarmDAOUtil();
- private static final Log log = LogFactory.getLog(VirtualFireAlarmManager.class);
- private FeatureManager virtualFirealarmFeatureManager = new VirtualFirealarmFeatureManager();
-
- @Override
- public FeatureManager getFeatureManager() {
- return virtualFirealarmFeatureManager;
- }
-
- @Override
- public boolean saveConfiguration(PlatformConfiguration PlatformConfiguration)
- throws DeviceManagementException {
- return false;
- }
-
- @Override
- public PlatformConfiguration getConfiguration() throws DeviceManagementException {
- return null;
- }
-
- @Override
- public boolean enrollDevice(Device device) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Enrolling a new Virtual Firealarm device : " + device.getDeviceIdentifier());
- }
- VirtualFireAlarmDAOUtil.beginTransaction();
- status = virtualFireAlarmDAO.getDeviceDAO().addDevice(device);
- VirtualFireAlarmDAOUtil.commitTransaction();
- } catch (VirtualFirealarmDeviceMgtPluginException e) {
- try {
- VirtualFireAlarmDAOUtil.rollbackTransaction();
- } catch (VirtualFirealarmDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the device enrol transaction :" + device.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg = "Error while enrolling the Virtual Firealarm device : " + device.getDeviceIdentifier();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean modifyEnrollment(Device device) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Modifying the Virtual Firealarm device enrollment data");
- }
- VirtualFireAlarmDAOUtil.beginTransaction();
- status = virtualFireAlarmDAO.getDeviceDAO().updateDevice(device);
- VirtualFireAlarmDAOUtil.commitTransaction();
- } catch (VirtualFirealarmDeviceMgtPluginException e) {
- try {
- VirtualFireAlarmDAOUtil.rollbackTransaction();
- } catch (VirtualFirealarmDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the update device transaction :" + device.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg = "Error while updating the enrollment of the Virtual Firealarm device : " +
- device.getDeviceIdentifier();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Dis-enrolling Virtual Firealarm device : " + deviceId);
- }
- VirtualFireAlarmDAOUtil.beginTransaction();
- status = virtualFireAlarmDAO.getDeviceDAO().deleteDevice(deviceId.getId());
- VirtualFireAlarmDAOUtil.commitTransaction();
- } catch (VirtualFirealarmDeviceMgtPluginException e) {
- try {
- VirtualFireAlarmDAOUtil.rollbackTransaction();
- } catch (VirtualFirealarmDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg = "Error while removing the Virtual Firealarm device : " + deviceId.getId();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
- boolean isEnrolled = false;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Checking the enrollment of Virtual Firealarm device : " + deviceId.getId());
- }
- Device device = virtualFireAlarmDAO.getDeviceDAO().getDevice(deviceId.getId());
- if (device != null) {
- isEnrolled = true;
- }
- } catch (VirtualFirealarmDeviceMgtPluginException e) {
- String msg = "Error while checking the enrollment status of Virtual Firealarm device : " +
- deviceId.getId();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return isEnrolled;
- }
-
- @Override
- public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
- return true;
- }
-
- @Override
- public boolean setActive(DeviceIdentifier deviceId, boolean status)
- throws DeviceManagementException {
- return true;
- }
-
- @Override
- public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
- Device device;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Getting the details of Virtual Firealarm device : " + deviceId.getId());
- }
- device = virtualFireAlarmDAO.getDeviceDAO().getDevice(deviceId.getId());
- } catch (VirtualFirealarmDeviceMgtPluginException e) {
- String msg = "Error while fetching the Virtual Firealarm device : " + deviceId.getId();
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return device;
- }
-
- @Override
- public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
- throws DeviceManagementException {
- return true;
- }
-
- public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
- EnrolmentInfo.Status status) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public License getLicense(String s) throws LicenseManagementException {
- return null;
- }
-
- @Override
- public void addLicense(License license) throws LicenseManagementException {
-
- }
-
- @Override
- public boolean requireDeviceAuthorization() {
- return false;
- }
-
- @Override
- public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug(
- "updating the details of Virtual Firealarm device : " + deviceIdentifier);
- }
- VirtualFireAlarmDAOUtil.beginTransaction();
- status = virtualFireAlarmDAO.getDeviceDAO().updateDevice(device);
- VirtualFireAlarmDAOUtil.commitTransaction();
- } catch (VirtualFirealarmDeviceMgtPluginException e) {
- try {
- VirtualFireAlarmDAOUtil.rollbackTransaction();
- } catch (VirtualFirealarmDeviceMgtPluginException iotDAOEx) {
- String msg = "Error occurred while roll back the update device info transaction :" + device.toString();
- log.warn(msg, iotDAOEx);
- }
- String msg =
- "Error while updating the Virtual Firealarm device : " + deviceIdentifier;
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public List getAllDevices() throws DeviceManagementException {
- List devices;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Fetching the details of all Virtual Firealarm devices");
- }
- devices = virtualFireAlarmDAO.getDeviceDAO().getAllDevices();
- } catch (VirtualFirealarmDeviceMgtPluginException e) {
- String msg = "Error while fetching all Virtual Firealarm devices.";
- log.error(msg, e);
- throw new DeviceManagementException(msg, e);
- }
- return devices;
- }
-
-}
\ No newline at end of file
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManagerService.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManagerService.java
deleted file mode 100644
index 6b93ecce8..000000000
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManagerService.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
-
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.DeviceManager;
-import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
-import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
-import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
-import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class VirtualFireAlarmManagerService implements DeviceManagementService {
-
- private DeviceManager deviceManager;
- private PushNotificationConfig pushNotificationConfig;
-
- @Override
- public String getType() {
- return VirtualFireAlarmConstants.DEVICE_TYPE;
- }
-
- @Override
- public void init() throws DeviceManagementException {
- this.deviceManager = new VirtualFireAlarmManager();
- this.pushNotificationConfig = this.populatePushNotificationConfig();
- }
-
- private PushNotificationConfig populatePushNotificationConfig() {
- DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(VirtualFireAlarmConstants.DEVICE_TYPE,
- VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- org.wso2.carbon.device.mgt.iot.devicetype.config.PushNotificationConfig sourceConfig =
- deviceManagementConfiguration.getPushNotificationConfig();
- Map staticProps = new HashMap<>();
- for (org.wso2.carbon.device.mgt.iot.devicetype.config.PushNotificationConfig.Property
- property : sourceConfig.getProperties()) {
- staticProps.put(property.getName(), property.getValue());
- }
- return new PushNotificationConfig(sourceConfig.getPushNotificationProvider(), staticProps);
- }
-
- @Override
- public DeviceManager getDeviceManager() {
- return deviceManager;
- }
-
- @Override
- public ApplicationManager getApplicationManager() {
- return null;
- }
-
- @Override
- public ProvisioningConfig getProvisioningConfig() {
- DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(VirtualFireAlarmConstants.DEVICE_TYPE,
- VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- boolean sharedWithAllTenants = deviceManagementConfiguration.getDeviceManagementConfigRepository()
- .getProvisioningConfig().isSharedWithAllTenants();
- return new ProvisioningConfig(VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN, sharedWithAllTenants);
- }
-
- @Override
- public PushNotificationConfig getPushNotificationConfig() {
- return pushNotificationConfig;
- }
-
-}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFireAlarmUtils.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmUtils.java
similarity index 80%
rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFireAlarmUtils.java
rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmUtils.java
index 66d5d7747..d9dbf9936 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFireAlarmUtils.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmUtils.java
@@ -16,7 +16,7 @@
* under the License.
*/
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util;
+package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
@@ -26,7 +26,6 @@ import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
@@ -37,17 +36,9 @@ import org.wso2.carbon.event.input.adapter.core.MessageType;
import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException;
import org.json.JSONObject;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
import java.io.IOException;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
@@ -58,62 +49,6 @@ public class VirtualFireAlarmUtils {
private static Log log = LogFactory.getLog(VirtualFireAlarmUtils.class);
- public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException e) {
- log.warn("Error occurred while closing result set", e);
- }
- }
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException e) {
- log.warn("Error occurred while closing prepared statement", e);
- }
- }
- if (conn != null) {
- try {
- conn.close();
- } catch (SQLException e) {
- log.warn("Error occurred while closing database connection", e);
- }
- }
- }
-
- public static void cleanupResources(PreparedStatement stmt, ResultSet rs) {
- cleanupResources(null, stmt, rs);
- }
-
- /**
- * Creates the device management schema.
- */
- public static void setupDeviceManagementSchema() throws VirtualFirealarmDeviceMgtPluginException {
- DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(VirtualFireAlarmConstants.DEVICE_TYPE,
- VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- String datasourceName = deviceManagementConfiguration.getDeviceManagementConfigRepository()
- .getDataSourceConfig().getJndiLookupDefinition().getJndiName();
- try {
- Context ctx = new InitialContext();
- DataSource dataSource = (DataSource) ctx.lookup(datasourceName);
- DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
- String checkSql = "select * from VIRTUAL_FIREALARM_DEVICE";
- if (!initializer.isDatabaseStructureCreated(checkSql)) {
- log.info("Initializing device management repository database schema");
- initializer.createRegistryDatabase();
- } else {
- log.info("Device management repository database already exists. Not creating a new database.");
- }
- } catch (NamingException e) {
- log.error("Error while looking up the data source: " + datasourceName, e);
- } catch (Exception e) {
- throw new VirtualFirealarmDeviceMgtPluginException("Error occurred while initializing Iot Device " +
- "Management database schema", e);
- }
- }
-
public static void setupMqttInputAdapter() throws IOException {
if (!MqttConfig.getInstance().isEnabled()) {
return;
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmEventAdapterSubscription.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmEventAdapterSubscription.java
similarity index 98%
rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmEventAdapterSubscription.java
rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmEventAdapterSubscription.java
index 25489d9b5..89c977260 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmEventAdapterSubscription.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmEventAdapterSubscription.java
@@ -1,4 +1,4 @@
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util;
+package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapterSubscription;
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmMqttContentTransformer.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java
similarity index 98%
rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmMqttContentTransformer.java
rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java
index 65b55f980..0cf2a6cfa 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmMqttContentTransformer.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java
@@ -1,4 +1,4 @@
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util;
+package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
import org.json.JSONObject;
import org.wso2.carbon.context.PrivilegedCarbonContext;
@@ -6,7 +6,6 @@ import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentTransformer
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-import java.math.BigInteger;
import java.security.PublicKey;
import java.util.Map;
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmSecurityManager.java
similarity index 99%
rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java
rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmSecurityManager.java
index 9a8defc4b..9ff12424b 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmSecurityManager.java
@@ -16,7 +16,7 @@
* under the License.
*/
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util;
+package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmStartupListener.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmStartupListener.java
similarity index 99%
rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmStartupListener.java
rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmStartupListener.java
index b9075fcf0..70dbcc7d9 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmStartupListener.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmStartupListener.java
@@ -16,7 +16,7 @@
* under the License.
*/
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util;
+package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmXmppContentTransformer.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java
similarity index 99%
rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmXmppContentTransformer.java
rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java
index 9a7b7d518..849091b74 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmXmppContentTransformer.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java
@@ -1,4 +1,4 @@
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util;
+package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
import org.json.JSONObject;
import org.wso2.carbon.context.PrivilegedCarbonContext;
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/VirtualFireAlarmDAOUtil.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/VirtualFireAlarmDAOUtil.java
deleted file mode 100644
index 7cde7981f..000000000
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/VirtualFireAlarmDAOUtil.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.dao;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-public class VirtualFireAlarmDAOUtil {
-
- private static final Log log = LogFactory.getLog(VirtualFireAlarmDAOUtil.class);
- static DataSource dataSource;
- private static ThreadLocal currentConnection = new ThreadLocal();
-
- public VirtualFireAlarmDAOUtil() {
- initFireAlarmDAO();
- }
-
- public static void initFireAlarmDAO() {
- DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(VirtualFireAlarmConstants.DEVICE_TYPE,
- VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- String datasourceName = deviceManagementConfiguration.getDeviceManagementConfigRepository()
- .getDataSourceConfig().getJndiLookupDefinition().getJndiName();
- try {
- Context ctx = new InitialContext();
- dataSource = (DataSource) ctx.lookup(datasourceName);
- } catch (NamingException e) {
- log.error("Error while looking up the data source: " + datasourceName, e);
- }
- }
-
- public VirtualFireAlarmDeviceDAO getDeviceDAO() {
- return new VirtualFireAlarmDeviceDAO();
- }
-
- public static void beginTransaction() throws VirtualFirealarmDeviceMgtPluginException {
- try {
- Connection conn = dataSource.getConnection();
- conn.setAutoCommit(false);
- currentConnection.set(conn);
- } catch (SQLException e) {
- throw new VirtualFirealarmDeviceMgtPluginException("Error occurred while retrieving datasource connection", e);
- }
- }
-
- public static Connection getConnection() throws VirtualFirealarmDeviceMgtPluginException {
- if (currentConnection.get() == null) {
- try {
- currentConnection.set(dataSource.getConnection());
- } catch (SQLException e) {
- throw new VirtualFirealarmDeviceMgtPluginException("Error occurred while retrieving data source connection", e);
- }
- }
- return currentConnection.get();
- }
-
- public static void commitTransaction() throws VirtualFirealarmDeviceMgtPluginException {
- try {
- Connection conn = currentConnection.get();
- if (conn != null) {
- conn.commit();
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Datasource connection associated with the current thread is null, hence commit "
- + "has not been attempted");
- }
- }
- } catch (SQLException e) {
- throw new VirtualFirealarmDeviceMgtPluginException("Error occurred while committing the transaction", e);
- } finally {
- closeConnection();
- }
- }
-
- public static void closeConnection() throws VirtualFirealarmDeviceMgtPluginException {
-
- Connection con = currentConnection.get();
- if (con != null) {
- try {
- con.close();
- } catch (SQLException e) {
- log.error("Error occurred while close the connection");
- }
- }
- currentConnection.remove();
- }
-
- public static void rollbackTransaction() throws VirtualFirealarmDeviceMgtPluginException {
- try {
- Connection conn = currentConnection.get();
- if (conn != null) {
- conn.rollback();
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Datasource connection associated with the current thread is null, hence rollback "
- + "has not been attempted");
- }
- }
- } catch (SQLException e) {
- throw new VirtualFirealarmDeviceMgtPluginException("Error occurred while rollback the transaction", e);
- } finally {
- closeConnection();
- }
- }
-}
\ No newline at end of file
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/VirtualFireAlarmDeviceDAO.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/VirtualFireAlarmDeviceDAO.java
deleted file mode 100644
index c20a83372..000000000
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/VirtualFireAlarmDeviceDAO.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.dao;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util.VirtualFireAlarmUtils;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Implements CRUD for virtual firealarm Devices.
- */
-public class VirtualFireAlarmDeviceDAO {
-
- private static final Log log = LogFactory.getLog(VirtualFireAlarmDeviceDAO.class);
-
- public Device getDevice(String deviceId) throws VirtualFirealarmDeviceMgtPluginException {
- Connection conn = null;
- PreparedStatement stmt = null;
- Device device = null;
- ResultSet resultSet = null;
- try {
- conn = VirtualFireAlarmDAOUtil.getConnection();
- String selectDBQuery =
- "SELECT VIRTUAL_FIREALARM_DEVICE_ID, DEVICE_NAME" +
- " FROM VIRTUAL_FIREALARM_DEVICE WHERE VIRTUAL_FIREALARM_DEVICE_ID = ?";
- stmt = conn.prepareStatement(selectDBQuery);
- stmt.setString(1, deviceId);
- resultSet = stmt.executeQuery();
-
- if (resultSet.next()) {
- device = new Device();
- device.setName(resultSet.getString(VirtualFireAlarmConstants.DEVICE_PLUGIN_DEVICE_NAME));
- if (log.isDebugEnabled()) {
- log.debug("Virtual Firealarm device " + deviceId + " data has been fetched from " +
- "Virtual Firealarm database.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while fetching Virtual Firealarm device : '" + deviceId + "'";
- log.error(msg, e);
- throw new VirtualFirealarmDeviceMgtPluginException(msg, e);
- } finally {
- VirtualFireAlarmUtils.cleanupResources(stmt, resultSet);
- VirtualFireAlarmDAOUtil.closeConnection();
- }
-
- return device;
- }
-
- public boolean addDevice(Device device) throws VirtualFirealarmDeviceMgtPluginException {
- boolean status = false;
- Connection conn = null;
- PreparedStatement stmt = null;
- try {
- conn = VirtualFireAlarmDAOUtil.getConnection();
- String createDBQuery =
- "INSERT INTO VIRTUAL_FIREALARM_DEVICE(VIRTUAL_FIREALARM_DEVICE_ID, DEVICE_NAME) VALUES (?, ?)";
-
- stmt = conn.prepareStatement(createDBQuery);
- stmt.setString(1, device.getDeviceIdentifier());
- stmt.setString(2, device.getName());
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Virtual Firealarm device " + device.getDeviceIdentifier() + " data has been" +
- " added to the Virtual Firealarm database.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while adding the Virtual Firealarm device '" +
- device.getDeviceIdentifier() + "' to the Virtual Firealarm db.";
- log.error(msg, e);
- throw new VirtualFirealarmDeviceMgtPluginException(msg, e);
- } finally {
- VirtualFireAlarmUtils.cleanupResources(stmt, null);
- }
- return status;
- }
-
- public boolean updateDevice(Device device) throws VirtualFirealarmDeviceMgtPluginException {
- boolean status = false;
- Connection conn = null;
- PreparedStatement stmt = null;
- try {
- conn = VirtualFireAlarmDAOUtil.getConnection();
- String updateDBQuery =
- "UPDATE VIRTUAL_FIREALARM_DEVICE SET DEVICE_NAME = ? WHERE VIRTUAL_FIREALARM_DEVICE_ID = ?";
-
- stmt = conn.prepareStatement(updateDBQuery);
- stmt.setString(1, device.getName());
- stmt.setString(2, device.getDeviceIdentifier());
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Virtualm Firealarm device " + device.getDeviceIdentifier() + " data has been" +
- " modified.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while modifying the Virtual Firealarm device '" +
- device.getDeviceIdentifier() + "' data.";
- log.error(msg, e);
- throw new VirtualFirealarmDeviceMgtPluginException(msg, e);
- } finally {
- VirtualFireAlarmUtils.cleanupResources(stmt, null);
- }
- return status;
- }
-
- public boolean deleteDevice(String iotDeviceId) throws VirtualFirealarmDeviceMgtPluginException {
- boolean status = false;
- Connection conn = null;
- PreparedStatement stmt = null;
- try {
- conn = VirtualFireAlarmDAOUtil.getConnection();
- String deleteDBQuery = "DELETE FROM VIRTUAL_FIREALARM_DEVICE WHERE VIRTUAL_FIREALARM_DEVICE_ID = ?";
- stmt = conn.prepareStatement(deleteDBQuery);
- stmt.setString(1, iotDeviceId);
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Virtual Firealarm device " + iotDeviceId + " data has deleted" +
- " from the Virtual Firealarm database.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while deleting Virtual Firealarm device " + iotDeviceId;
- log.error(msg, e);
- throw new VirtualFirealarmDeviceMgtPluginException(msg, e);
- } finally {
- VirtualFireAlarmUtils.cleanupResources(stmt, null);
- }
- return status;
- }
-
- public List getAllDevices() throws VirtualFirealarmDeviceMgtPluginException {
- Connection conn;
- PreparedStatement stmt = null;
- ResultSet resultSet = null;
- Device device;
- List devices = new ArrayList<>();
- try {
- conn = VirtualFireAlarmDAOUtil.getConnection();
- String selectDBQuery =
- "SELECT VIRTUAL_FIREALARM_DEVICE_ID, DEVICE_NAME FROM VIRTUAL_FIREALARM_DEVICE";
- stmt = conn.prepareStatement(selectDBQuery);
- resultSet = stmt.executeQuery();
- while (resultSet.next()) {
- device = new Device();
- device.setDeviceIdentifier(resultSet.getString(VirtualFireAlarmConstants.DEVICE_PLUGIN_DEVICE_ID));
- device.setName(resultSet.getString(VirtualFireAlarmConstants.DEVICE_PLUGIN_DEVICE_NAME));
- devices.add(device);
- }
- if (log.isDebugEnabled()) {
- log.debug("All Virtual Firealarm device details have fetched from Firealarm database.");
- }
- return devices;
- } catch (SQLException e) {
- String msg = "Error occurred while fetching all Virtual Firealarm device data'";
- log.error(msg, e);
- throw new VirtualFirealarmDeviceMgtPluginException(msg, e);
- } finally {
- VirtualFireAlarmUtils.cleanupResources(stmt, resultSet);
- VirtualFireAlarmDAOUtil.closeConnection();
- }
- }
-}
\ No newline at end of file
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/feature/VirtualFirealarmFeatureManager.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/feature/VirtualFirealarmFeatureManager.java
deleted file mode 100644
index 7290b6179..000000000
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/feature/VirtualFirealarmFeatureManager.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.feature;
-
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.Feature;
-import org.wso2.carbon.device.mgt.common.FeatureManager;
-import org.wso2.carbon.device.mgt.extensions.feature.mgt.GenericFeatureManager;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
-
-import java.util.List;
-
-public class VirtualFirealarmFeatureManager implements FeatureManager{
- @Override
- public boolean addFeature(Feature feature) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean addFeatures(List features) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public Feature getFeature(String name) throws DeviceManagementException {
- GenericFeatureManager genericFeatureManager = GenericFeatureManager.getInstance();
- return genericFeatureManager.getFeature(VirtualFireAlarmConstants.DEVICE_TYPE, name);
- }
-
- @Override
- public List getFeatures() throws DeviceManagementException {
- GenericFeatureManager genericFeatureManager = GenericFeatureManager.getInstance();
- return genericFeatureManager.getFeatures(VirtualFireAlarmConstants.DEVICE_TYPE);
- }
-
- @Override
- public boolean removeFeature(String name) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
- return false;
- }
-}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/DeviceSchemaInitializer.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/DeviceSchemaInitializer.java
deleted file mode 100644
index a738386af..000000000
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/DeviceSchemaInitializer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.iot.virtualfirealarm.plugin.impl.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
-
-import javax.sql.DataSource;
-import java.io.File;
-
-/**
- * Provides methods for initializing the database script.
- */
-public class DeviceSchemaInitializer extends DatabaseCreator{
-
- private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class);
- private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts"
- + File.separator + "cdm" + File.separator + "plugins" + File.separator
- + VirtualFireAlarmConstants.DEVICE_TYPE + File.separator;
-
- public DeviceSchemaInitializer(DataSource dataSource) {
- super(dataSource);
- }
-
- @Override
- protected String getDbScriptLocation(String databaseType) {
- String scriptName = databaseType + ".sql";
- if (log.isDebugEnabled()) {
- log.debug("Loading database script from :" + scriptName);
- }
- return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName;
- }
-}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java
index 7d0a96e74..9fc9111fb 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java
@@ -20,7 +20,6 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal;
import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
-import org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapterService;
/**
@@ -31,7 +30,6 @@ public class VirtualFirealarmManagementDataHolder {
private InputEventAdapterService inputEventAdapterService;
private EventsPublisherService eventsPublisherService;
private CertificateManagementService certificateManagementService;
- private DeviceTypeConfigService deviceTypeConfigService;
private static VirtualFirealarmManagementDataHolder thisInstance = new VirtualFirealarmManagementDataHolder();
@@ -66,13 +64,4 @@ public class VirtualFirealarmManagementDataHolder {
public void setCertificateManagementService(CertificateManagementService certificateManagementService) {
this.certificateManagementService = certificateManagementService;
}
-
- public DeviceTypeConfigService getDeviceTypeConfigService() {
- return deviceTypeConfigService;
- }
-
- public void setDeviceTypeConfigService(
- DeviceTypeConfigService deviceTypeConfigService) {
- this.deviceTypeConfigService = deviceTypeConfigService;
- }
}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java
index 47f3a7f27..6a1e8c4bf 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java
@@ -26,13 +26,9 @@ import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
-import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
-import org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.VirtualFireAlarmManagerService;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util.VirtualFireAlarmUtils;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util.VirtualFirealarmSecurityManager;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util.VirtualFirealarmStartupListener;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.VirtualFirealarmConfig;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.VirtualFirealarmSecurityManager;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.VirtualFirealarmStartupListener;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapterService;
/**
@@ -57,12 +53,6 @@ import org.wso2.carbon.event.input.adapter.core.InputEventAdapterService;
* policy="dynamic"
* bind="setEventsPublisherService"
* unbind="unsetEventsPublisherService"
- * @scr.reference name="devicetype.configuration.service"
- * interface="org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService"
- * cardinality="1..1"
- * policy="dynamic"
- * bind="setDeviceTypeConfigService"
- * unbind="unsetDeviceTypeConfigService"
*/
public class VirtualFirealarmManagementServiceComponent {
@@ -74,25 +64,10 @@ public class VirtualFirealarmManagementServiceComponent {
log.debug("Activating Virtual Firealarm Device Management Service Component");
}
try {
-
- VirtualFireAlarmManagerService virtualFireAlarmManagerService = new VirtualFireAlarmManagerService();
+ VirtualFirealarmConfig.initialize();
BundleContext bundleContext = ctx.getBundleContext();
- firealarmServiceRegRef = bundleContext.registerService(DeviceManagementService.class.getName()
- ,virtualFireAlarmManagerService, null);
bundleContext.registerService(ServerStartupObserver.class.getName(), new VirtualFirealarmStartupListener(),
null);
- String setupOption = System.getProperty("setup");
- if (setupOption != null) {
- if (log.isDebugEnabled()) {
- log.debug("-Dsetup is enabled. Iot Device management repository schema initialization is about " +
- "to begin");
- }
- try {
- VirtualFireAlarmUtils.setupDeviceManagementSchema();
- } catch (VirtualFirealarmDeviceMgtPluginException e) {
- log.error("Exception occurred while initializing device management database schema", e);
- }
- }
if (log.isDebugEnabled()) {
log.debug("Virtual Firealarm Device Management Service Component has been successfully activated");
}
@@ -106,16 +81,6 @@ public class VirtualFirealarmManagementServiceComponent {
if (log.isDebugEnabled()) {
log.debug("De-activating Virtual Firealarm Device Management Service Component");
}
- try {
- if (firealarmServiceRegRef != null) {
- firealarmServiceRegRef.unregister();
- }
- if (log.isDebugEnabled()) {
- log.debug("Virtual Firealarm Device Management Service Component has been successfully de-activated");
- }
- } catch (Throwable e) {
- log.error("Error occurred while de-activating Virtual Firealarm Device Management bundle", e);
- }
}
/**
@@ -149,12 +114,4 @@ public class VirtualFirealarmManagementServiceComponent {
protected void unsetEventsPublisherService(EventsPublisherService eventsPublisherService) {
VirtualFirealarmManagementDataHolder.getInstance().setEventsPublisherService(null);
}
-
- protected void setDeviceTypeConfigService(DeviceTypeConfigService deviceTypeConfigService) {
- VirtualFirealarmManagementDataHolder.getInstance().setDeviceTypeConfigService(deviceTypeConfigService);
- }
-
- protected void unsetDeviceTypeConfigService(DeviceTypeConfigService deviceTypeConfigService) {
- VirtualFirealarmManagementDataHolder.getInstance().setDeviceTypeConfigService(null);
- }
}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java
index 7a0c8f688..e47ac11ea 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java
@@ -20,10 +20,9 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.mqtt;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.PushNotificationConfig;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.DeviceManagementConfiguration;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.EventListenerConfiguration;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.VirtualFirealarmConfig;
import java.util.List;
@@ -41,17 +40,16 @@ public class MqttConfig {
private String clearSession;
private MqttConfig() {
- DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(VirtualFireAlarmConstants.DEVICE_TYPE,
- VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- List properties = deviceManagementConfiguration
- .getPushNotificationConfig().getProperties();
- String provider = deviceManagementConfiguration.getPushNotificationConfig().getPushNotificationProvider();
+ DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmConfig.getInstance()
+ .getDeviceTypeConfiguration();
+ List properties = deviceManagementConfiguration
+ .getEventListenerConfiguration().getProperties();
+ String provider = deviceManagementConfiguration.getEventListenerConfiguration().getEventListenerProvider();
if (provider.equals("MQTT")) {
enabled = true;
}
if (enabled) {
- for (PushNotificationConfig.Property property : properties) {
+ for (EventListenerConfiguration.Property property : properties) {
switch (property.getName()) {
case "url":
url = property.getValue();
@@ -71,8 +69,6 @@ public class MqttConfig {
case "clearSession":
clearSession = property.getValue();
break;
-
-
}
}
}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java
index 2ac57e0b8..d600b3a82 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java
@@ -20,10 +20,10 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.xmpp;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.PushNotificationConfig;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.DeviceManagementConfiguration;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.EventListenerConfiguration;
+import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.VirtualFirealarmConfig;
+
import java.util.List;
public class XmppConfig {
@@ -39,17 +39,16 @@ public class XmppConfig {
private static final Log log = LogFactory.getLog(XmppConfig.class);
private XmppConfig() {
- DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmManagementDataHolder.getInstance()
- .getDeviceTypeConfigService().getConfiguration(VirtualFireAlarmConstants.DEVICE_TYPE,
- VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- List properties = deviceManagementConfiguration.getPushNotificationConfig()
+ DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmConfig.getInstance()
+ .getDeviceTypeConfiguration();
+ List properties = deviceManagementConfiguration.getEventListenerConfiguration()
.getProperties();
- String provider = deviceManagementConfiguration.getPushNotificationConfig().getPushNotificationProvider();
+ String provider = deviceManagementConfiguration.getEventListenerConfiguration().getEventListenerProvider();
if ("XMPP".equals(provider)) {
enabled = true;
}
if (enabled) {
- for (PushNotificationConfig.Property property : properties) {
+ for (EventListenerConfiguration.Property property : properties) {
switch (property.getName()) {
case "host":
host = property.getValue();
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml
index 9b91291a4..c9bef4a5f 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml
@@ -21,7 +21,7 @@
virtual-fire-alarm-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml
index 7b5398616..f8a4b7445 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml
@@ -23,7 +23,7 @@
virtual-fire-alarm-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.hbs b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.hbs
index 01fd58063..bc4a3f42c 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.hbs
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.hbs
@@ -66,9 +66,9 @@
STEP 01
- Go ahead and [Download] the Device.
+ Go ahead and [Download] the Device.
STEP 02
- Proceed to [Prepare] section.
+ Proceed to [Prepare] section.
STEP 03
- Read [Try Out] section to further experiment with the device.
+ Read [Try Out] section to further experiment with the device.
View API
+ target="_blank"> View API
Download Agent
@@ -71,7 +71,7 @@
- Add your new firealarm device to {{@app.conf.appName}}
+ Add your new firealarm device to {{@app.conf.appName}}
@@ -99,7 +99,7 @@
-
+
@@ -148,7 +148,7 @@
01
- Download your VirtualFireAlarm using [Download Agent] button above.
+ Download your VirtualFireAlarm using [Download Agent] button above.
02
- Unzip the downloaded Agent.
+ Unzip the downloaded Agent.
03
- Move into the unzipped Agent folder in the terminal.
+ Move into the unzipped Agent folder in the terminal.
04
- Unzip the downloaded Agent and start terminal to run this command: [sh
+ Unzip the downloaded Agent and start terminal to run this command: [sh
start-device.sh]
@@ -244,17 +244,17 @@
01
- You can view all your connected devices at
+ You can view all your connected devices at
[Device Management] page.
02
- Select one of connected devices and check for available control
+ Select one of connected devices and check for available control
operations and monitor Real-Time data.
03
- You can also view analytics of the data published to IoT-Server by
+ You can also view analytics of the data published to IoT-Server by
navigating to Device Analytics page.
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/pom.xml
index cb8636148..b26da2cca 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/pom.xml
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgt-pluginsiot-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml
index d427b89bd..997876edc 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml
@@ -21,7 +21,7 @@
android-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java
index cf40ad506..9832c3f03 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java
@@ -36,7 +36,7 @@ import java.util.List;
@XmlAccessorType(XmlAccessType.NONE)
@ApiModel(
value = "PlatformConfiguration",
- description = "This class carries all information related to a Tenant configuration"
+ description = "This class carries all the information related to Android platform configurations."
)
public class AndroidPlatformConfiguration implements Serializable {
public static final int INVALID_NOTIFIER_FREQUENCY = -1;
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java
index 30dcb4704..d45f466b0 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java
@@ -21,6 +21,7 @@ package org.wso2.carbon.mdm.services.android.services;
import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission;
+import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.mdm.services.android.bean.wrapper.*;
@@ -48,16 +49,16 @@ public interface DeviceManagementAdminService {
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
- value = "Adds a Device Lock on Android Devices",
+ value = "Adding a Screen Lock on Android devices",
notes = "Using this API you have the option of hard locking an Android device, where the Administrator " +
- "permanently locks the device or screen locking an Android device",
+ "permanently locks the device or screen locking an Android device.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Device lock operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the device lock operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -72,11 +73,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified. \n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -86,37 +87,41 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported.\n"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
- "Server error occurred while adding a new lock operation.")
+ "Server error occurred while locking the device.")
})
@Permission(name = "Lock Device", permission = "/device-mgt/devices/owning-device/operations/android/lock")
Response configureDeviceLock(
- @ApiParam(name = "deviceLockBeanWrapper",
- value = "Device lock configurations with device IDs") DeviceLockBeanWrapper deviceLockBeanWrapper);
+ @ApiParam(
+ name = "deviceLock",
+ value = "Provide the ID of the Android device, the message that needs to be sent out when locking the device, " +
+ "and define true as the value if you need to hard lock the device or define false as the value to " +
+ "screen lock the device." +
+ "Multiple device IDs can be added by using comma separated values. ",
+ required = true) DeviceLockBeanWrapper deviceLockBeanWrapper);
@POST
@Path("/unlock-devices")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
- value = "Adding a Device Unlock on Android Devices",
+ value = "Unlocking Android Devices",
responseContainer = "List",
- notes = "Using this API you have the option of unlocking an Android device, where the Administrator " +
- "unlocks the device",
+ notes = "Unlock devices that were locked permanently using the hard lock operation. Devices that are hard locked can only be unlocked by the EMM administrator.",
response = Activity.class,
tags = "Android Device Management Administrative Service")
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Device un-lock operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the device unlock operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
- description = "URL of the activity instance that refers to the scheduled operation."),
+ description = "The URL of the activity instance that refers to the scheduled operation."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@@ -126,11 +131,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -140,15 +145,18 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a new un-lock operation.")
+ "Server error occurred while unlocking the device.")
})
@Permission(name = "Unlock Device", permission = "/device-mgt/devices/owning-device/operations/android/unlock")
Response configureDeviceUnlock(
- @ApiParam(name = "deviceIDs", value = "DeviceIds to be enable device unlock operation")
+ @ApiParam(
+ name = "deviceIDs",
+ value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ",
+ required = true)
List deviceIDs);
@@ -157,9 +165,10 @@ public interface DeviceManagementAdminService {
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
- value = "Requesting Location Coordinates of Android Devices",
+ value = "Requesting Location Coordinates",
responseContainer = "List",
- notes = "Request location coordinates of Android devices",
+ notes = "Request location coordinates of Android devices. \n" +
+ "Example: In situations where you have lost your device and need to find out where it is, you can use this REST API to get the location of the device.",
response = Activity.class,
tags = "Android Device Management Administrative Service")
@ApiResponses(value = {
@@ -180,11 +189,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -194,14 +203,17 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a new get-location operation.")})
@Permission(name = "Get Device Location", permission = "/device-mgt/devices/owning-device/operations/android/location")
Response getDeviceLocation(
- @ApiParam(name = "deviceIDs", value = "DeviceIDs to be requested to get device location")
+ @ApiParam(
+ name = "deviceIDs",
+ value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ",
+ required = true)
List deviceIDs);
@POST
@@ -212,12 +224,12 @@ public interface DeviceManagementAdminService {
value = "Clearing the Password on Android Devices",
notes = "Clear the password on Android devices",
response = Activity.class,
- tags = "Android Device Management Administrative Service"
+ tags = "Android Device Management Administrative Service."
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Clear password operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the clear password operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -232,11 +244,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -246,7 +258,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -255,7 +267,8 @@ public interface DeviceManagementAdminService {
@Permission(name = "Clear Password of Device", permission = "/device-mgt/devices/owning-device/operations/android/clear-password")
Response removePassword(
@ApiParam(name = "deviceIDs",
- value = "DeviceIds to be requested to remove password") List deviceIDs);
+ value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ",
+ required = true) List deviceIDs);
@POST
@Path("/control-camera")
@@ -263,14 +276,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Enabling or Disabling the Camera on Android Devices",
- notes = "Enable or disable the camera on Android devices",
+ notes = "Enable or disable the camera on Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Control camera operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the camera control operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -285,11 +298,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -299,15 +312,21 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a new control camera operation.")
+ "Server error occurred while adding the new camera control operation.")
})
@Permission(name = "Manage Camera", permission = "/device-mgt/devices/owning-device/operations/android/camera")
Response configureCamera(
- @ApiParam(name = "cameraBeanWrapper", value = "Camera enable/disable configurations with device IDs")
+ @ApiParam(
+ name = "cameraControl",
+ value = "Define the properties to enable/disable the camera. " +
+ "Disable the camera on the device by assigning true as the value or enable the " +
+ "camera on the device to function by defining false as the value and the ID of the Android device. " +
+ "Multiple device IDs can be added by using comma separated values. ",
+ required = true)
CameraBeanWrapper cameraBeanWrapper);
@POST
@@ -326,7 +345,7 @@ public interface DeviceManagementAdminService {
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Device info operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the device info operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -341,11 +360,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -355,7 +374,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -363,7 +382,10 @@ public interface DeviceManagementAdminService {
})
@Permission(name = "Get Device Information", permission = "/device-mgt/devices/owning-device/operations/android/info")
Response getDeviceInformation(
- @ApiParam(name = "deviceIds", value = "Device IDs to be requested to get device information")
+ @ApiParam(
+ name = "deviceIds",
+ value = "Provide the device ID of the Android device. Multiple device IDs can be added by using comma separated values.",
+ required = true)
List deviceIDs);
@POST
@@ -372,17 +394,17 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
- value = "Requesting logcat from Android Devices",
+ value = "Requesting Logcat Details from Android Devices",
notes = "Using this REST API you are able to request for Android device log details. Once this REST API is" +
" executed it will be in the Android operation queue until the device calls the server to retrieve " +
- "the list of operations that needs to be executed on the device",
+ "the list of operations that needs to be executed on the device.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Device logcat operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the operation to get the logcat details.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -397,11 +419,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -411,7 +433,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -419,7 +441,10 @@ public interface DeviceManagementAdminService {
})
@Permission(name = "Get Logs", permission = "/device-mgt/devices/owning-device/operations/android/logcat")
Response getDeviceLogcat(
- @ApiParam(name = "deviceIds", value = "Device IDs to be requested to get device logcat")
+ @ApiParam(
+ name = "deviceIds",
+ value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values.",
+ required = true)
List deviceIDs);
@POST
@@ -430,14 +455,14 @@ public interface DeviceManagementAdminService {
httpMethod = "POST",
value = "Enterprise Wiping Android Devices",
notes = "Enterprise wipe is the process of deleting enterprise related data on a device while keeping the " +
- "personal data intact. You are able to enterprise wipe Android devices using this REST API",
+ "personal data intact. You are able to enterprise wipe Android devices using this REST API.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Enterprise wipe operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the enterprise wipe operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -452,11 +477,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified." +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -466,14 +491,18 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a enterprise wipe operation.")})
+ "Server error occurred while adding the enterprise wipe operation.")})
@Permission(name = "Enterprise Wipe", permission = "/device-mgt/devices/owning-device/operations/android/enterprise-wipe")
- Response wipeDevice(@ApiParam(name = "deviceIDs", value = "Device IDs to be requested to do enterprise-wipe")
- List deviceIDs);
+ Response wipeDevice(
+ @ApiParam(
+ name = "deviceIDs",
+ value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ",
+ required = true)
+ List deviceIDs);
@POST
@Path("/wipe")
@@ -481,15 +510,15 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Factory Resetting an Android Device",
- notes = "Factory rest or erases all the data stored in the Android devices " +
- "to restore them back to the original system",
+ notes = "Factory rest or erase all the data stored on the Android devices " +
+ "to restore them back to the original system.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Device wipe operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the device wipe/factory reset operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -504,11 +533,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -518,14 +547,18 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a device wipe operation.")})
+ "Server error occurred while adding the device wipe operation.")})
@Permission(name = "Factory Reset", permission = "/device-mgt/devices/owning-device/operations/android/wipe")
Response wipeData(
- @ApiParam(name = "wipeDataBeanWrapper", value = "Configurations and DeviceIds needed to do wipe-data")
+ @ApiParam(
+ name = "wipeData",
+ value = "Provide the the passcode, which is the passcode that the Android agent prompts the device owner to set at the time of device enrollment, " +
+ "to enable the factory reset operation, and the ID of the Android device. Multiple device IDs can be added by using comma separated values. ",
+ required = true)
WipeDataBeanWrapper wipeDataBeanWrapper);
@POST
@@ -534,18 +567,18 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
- value = "Requesting the List of Installed Applications on Android Devices",
+ value = "Getting the List of Installed Applications on Android Devices",
notes = "Using this REST API the server requests for the list of applications that are installed on" +
" the Android devices. Once this REST API is executed it will be in the Android operation queue " +
"until the device calls the server to retrieve the list of operations that needs to be executed " +
- "on the device",
+ "on the device.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Get-applications operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the get-applications operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -560,11 +593,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -574,15 +607,18 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a new get-applications operation.")
+ "Server error occurred while adding the new get-applications operation.")
})
@Permission(name = "Get Installed Application", permission = "/device-mgt/devices/owning-device/operations/android/applications")
Response getApplications(
- @ApiParam(name = "deviceIDs", value = "Device Ids needed to get applications that are already installed")
+ @ApiParam(
+ name = "deviceIDs",
+ value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values." ,
+ required = true)
List deviceIDs);
@POST
@@ -591,14 +627,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Ringing Android Devices",
- notes = "Ring Android devices",
+ notes = "Ring Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Device ring operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the device ring operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -613,11 +649,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -627,7 +663,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported.\n"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -635,7 +671,10 @@ public interface DeviceManagementAdminService {
})
@Permission(name = "Ring Device", permission = "/device-mgt/devices/owning-device/operations/android/ring")
Response ringDevice(
- @ApiParam(name = "deviceIDs", value = "Device Ids needed for ring")
+ @ApiParam(
+ name = "deviceIDs",
+ value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values.",
+ required = true)
List deviceIDs);
@POST
@@ -644,14 +683,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Rebooting Android Devices",
- notes = "Reboot Android devices",
+ notes = "Reboot or restart your Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Device reboot operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the device reboot operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -666,11 +705,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -680,15 +719,18 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported.\n"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
- "Server error occurred while adding a new device reboot operation.")
+ "Server error occurred while adding the new device reboot operation.")
})
@Permission(name = "Reboot Device", permission = "/device-mgt/devices/owning-device/operations/android/reboot")
Response rebootDevice(
- @ApiParam(name = "deviceIDs", value = "Device Ids needed for reboot.")
+ @ApiParam(
+ name = "deviceIDs",
+ value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values. ",
+ required = true)
List deviceIDs);
@POST
@@ -696,14 +738,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Muting Android Devices",
- notes = "Mute Android devices",
+ notes = "Mute or enable a silent profile for Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Device mute operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the device mute operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -718,11 +760,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -732,7 +774,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -741,7 +783,10 @@ public interface DeviceManagementAdminService {
@Path("/mute")
@Permission(name = "Mute Device", permission = "/device-mgt/devices/owning-device/operations/android/mute")
Response muteDevice(
- @ApiParam(name = "deviceIDs", value = "DeviceIDs need to be muted")
+ @ApiParam(
+ name = "deviceIDs",
+ value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values. ",
+ required = true)
List deviceIDs);
@POST
@@ -751,16 +796,15 @@ public interface DeviceManagementAdminService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Installing an Application on Android Devices",
- notes = "Install an application on an Android device. If the device you are installing the application" +
- " on has the WSO2 system service installed, the application installation will happen in silent " +
- "mode, else the device user's consent will be required",
+ notes = "Install an application on an Android device. If the device you are installing the application has the WSO2 system service application installed," +
+ " the application installation will happen in silent mode, else the device user's consent will be required.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Install application operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the install application operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -775,11 +819,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -789,7 +833,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported.\n"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -797,7 +841,12 @@ public interface DeviceManagementAdminService {
})
@Permission(name = "Install Applications", permission = "/device-mgt/devices/owning-device/operations/android/install-app")
Response installApplication(
- @ApiParam(name = "applicationInstallationBeanWrapper", value = "Properties of installed apps and device IDs")
+ @ApiParam(
+ name = "applicationInstallation",
+ value = "Properties required to install an application on Android devices. Provide the the package name, type," +
+ " URL and name of the application, the date and time for the scheduled installation, and the ID of the " +
+ "Android device. Multiple device IDs can be added by using comma separated values.",
+ required = true)
ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper);
@POST
@@ -807,16 +856,16 @@ public interface DeviceManagementAdminService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Updating an Application on Android Devices",
- notes = "Update an application on an Android device. If the device you are updating the application" +
- " has the WSO2 system service installed, the application update will happen in silent " +
- "mode, else the device user's consent will be required",
+ notes = "Update an application on an Android device. If the device" +
+ " has the WSO2 system service application installed, the application update will happen in silent " +
+ "mode, else the device user's consent is required.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Update-application operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the update-application operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -831,11 +880,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -845,15 +894,20 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a new update-application operation.")
+ "Server error occurred while adding the new update-application operation.")
})
@Permission(name = "Update installed applications", permission = "/device-mgt/devices/owning-device/operations/android/update-app")
Response updateApplication(
- @ApiParam(name = "applicationUpdateBeanWrapper", value = "Properties of updated apps and device IDs")
+ @ApiParam(
+ name = "applicationUpdate",
+ value = "Properties required to update an application on Android devices. Provide the the package name, type," +
+ "URL and name of the application, the date and time for the scheduled installation, and the ID of the" +
+ "Android device. Multiple device IDs can be added by using comma separated values.",
+ required = true)
ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper);
@POST
@@ -862,14 +916,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Uninstalling an Application from Android Devices",
- notes = "Uninstall an application from Android devices",
+ notes = "Uninstall an application from Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Uninstall-application operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the uninstall-application operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -884,11 +938,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -898,7 +952,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -906,8 +960,12 @@ public interface DeviceManagementAdminService {
})
@Permission(name = "Uninstall Applications", permission = "/device-mgt/devices/owning-device/operations/android/uninstall-app")
Response uninstallApplication(
- @ApiParam(name = "applicationUninstallationBeanWrapper",
- value = "applicationUninstallationConfigs and Device Ids")
+ @ApiParam(
+ name = "applicationUninstallation",
+ value = "Properties required to uninstall an application. Provide the the package name, type," +
+ "URL and name of the application, the date and time for the scheduled installation, and the ID of the" +
+ "Android device. Multiple device IDs can be added by using comma separated values.",
+ required = true)
ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper);
@POST
@@ -916,15 +974,18 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
- value = "Get BlackListed Applications",
- notes = "Getting BlackListed Applications",
+ value = "BlackListing Applications for Android Devices",
+ notes = "Prevents you from using specific applications. For Android operation systems before Lollipop," +
+ " when a blacklisted application is clicked a screen is displayed to prevent you from using the app. For the Lollipop" +
+ " Android operating systems and after, the blacklisted apps will be hidden. Blacklisting can be used on both BYOD and " +
+ "COPE devices. Applications can be blacklisted via the application restriction policy too.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Blacklist-applications operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the application blacklist operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -939,11 +1000,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -953,16 +1014,19 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a new blacklist-applications operation.")
+ "Server error occurred while adding the new blacklist-applications operation.")
})
@Permission(name = "Blacklist Applications", permission = "/device-mgt/devices/owning-device/operations/android/blacklist-app")
Response blacklistApplications(
- @ApiParam(name = "blacklistApplicationsBeanWrapper", value = "BlacklistApplications " +
- "Configuration and DeviceIds")
+ @ApiParam(
+ name = "blacklistApplications",
+ value = "The properties required to blacklist applications. Provide the package name of the application to be blacklisted," +
+ " and the ID of the Android device. Multiple device IDs can be added by using comma separated values. ",
+ required = true)
@Valid BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper);
@POST
@@ -971,15 +1035,15 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
- value = "Upgrading device firmware",
- notes = "Device firmware upgrade",
+ value = "UUpgrading Firmware of Android Devices",
+ notes = "Upgrade the firmware of Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Upgrade firmware operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the firmware upgrade operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -994,11 +1058,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -1008,7 +1072,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -1016,8 +1080,13 @@ public interface DeviceManagementAdminService {
})
@Permission(name = "Upgrade Firmware", permission = "/device-mgt/devices/owning-device/operations/android/upgrade")
Response upgradeFirmware(
- @ApiParam(name = "upgradeFirmwareBeanWrapper",
- value = "Firmware upgrade configuration and DeviceIds")
+ @ApiParam(
+ name = "upgradeFirmware",
+ value = "Properties required to upgrade the firmware. Provide the date and time to schedule the firmware update in the " +
+ "yyyy-MM-dd'T'HH:mm:ss.SSSXXX format, the OTA upgrade server URL in one of the following formats " +
+ "(example: http//abc.com, http://abc.com/ota), " +
+ "and the ID of the Android device. Multiple device IDs can be added by using comma separated values.",
+ required = true)
UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper);
@POST
@@ -1027,19 +1096,19 @@ public interface DeviceManagementAdminService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Configuring VPN on Android devices",
- notes = "Configure VPN on Android devices",
+ notes = "Configure VPN on Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Configure VPN operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the configure VPN operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
- description = "URL of the activity instance that refers to the scheduled operation."),
+ description = "The URL of the activity instance that refers to the scheduled operation."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@@ -1049,11 +1118,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified." +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -1063,16 +1132,18 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a new configure VPN operation.")
+ "Server error occurred while configuring the VPN.")
})
@Permission(name = "Add VPN", permission = "/device-mgt/devices/owning-device/operations/android/vpn")
Response configureVPN(
- @ApiParam(name = "vpnBeanWrapper",
- value = "VPN configuration and DeviceIds")
+ @ApiParam(
+ name = "vpnBean",
+ value = "VPN configuration and DeviceIds",
+ required = true)
VpnBeanWrapper vpnBeanWrapper);
@POST
@@ -1081,14 +1152,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Sending a Notification to Android Devices",
- notes = "Send a notification to Android devices",
+ notes = "Send a notification or message to Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Send notification operation has successfully been scheduled",
+ message = "Created. \n Successfully sent the notification.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -1103,11 +1174,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -1117,7 +1188,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -1125,8 +1196,11 @@ public interface DeviceManagementAdminService {
})
@Permission(name = "Send Notifications", permission = "/device-mgt/devices/owning-device/operations/android/send-notification")
Response sendNotification(
- @ApiParam(name = "notificationBeanWrapper",
- value = "Notification Configurations and device Ids")
+ @ApiParam(
+ name = "notification",
+ value = "The properties required to send a notification. Provide the message you wish to send and the ID of the " +
+ "Android device. Multiple device IDs can be added by using comma separated values.",
+ required = true)
NotificationBeanWrapper notificationBeanWrapper);
@POST
@@ -1135,14 +1209,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Configuring Wi-Fi on Android Devices",
- notes = "Configure Wi-Fi on Android devices",
+ notes = "Configure Wi-Fi on Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Configure wifi operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the configure Wi-Fi operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -1157,11 +1231,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified." +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -1171,16 +1245,21 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a new configure wifi operation.")
+ "Server error occurred while configuring Wi-Fi.")
})
@Permission(name = "Add Wifi Configuration", permission = "/device-mgt/devices/owning-device/operations/android/wifi")
Response configureWifi(
- @ApiParam(name = "wifiBeanWrapper",
- value = "WifiConfigurations and Device Ids") WifiBeanWrapper wifiBeanWrapper);
+ @ApiParam(
+ name = "wifi",
+ value = "The properties required to configure Wi-Fi. Provide the password to connect to the specified Wi-Fi network," +
+ "the ssid or the name of the Wi-Fi network that you wish to configure and the ID of the Android device." +
+ " Multiple device IDs can be added by using comma separated values.",
+ required = true)
+ WifiBeanWrapper wifiBeanWrapper);
@POST
@Path("/encrypt-storage")
@@ -1188,14 +1267,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Encrypting Storage on Android Devices",
- notes = "Encrypt the data stored on Android devices",
+ notes = "Encrypt the data stored on Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Encrypt storage operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the encrypt storage operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -1210,11 +1289,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified." +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -1224,7 +1303,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -1232,8 +1311,12 @@ public interface DeviceManagementAdminService {
})
@Permission(name = "Encrypt Device", permission = "/device-mgt/devices/owning-device/operations/android/encrypt")
Response encryptStorage(
- @ApiParam(name = "encryptionBeanWrapper",
- value = "Configurations and deviceIds need to be done data encryption")
+ @ApiParam(
+ name = "encryption",
+ value = "Properties required to encrypt the storage. Encrypt the storage on the device by assigning " +
+ "true as the value or do not encrypt the storage on the device by assigning false as the value and " +
+ "provide the ID of the Android device. Multiple device IDs can be added by using comma separated values.",
+ required = true)
EncryptionBeanWrapper encryptionBeanWrapper);
@POST
@@ -1242,14 +1325,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Changing the Lock Code on Android Devices",
- notes = "Change the lock code on Android devices",
+ notes = "Change the lock code on Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Change lock code operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the change lock code operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -1264,11 +1347,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -1278,7 +1361,7 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -1286,8 +1369,12 @@ public interface DeviceManagementAdminService {
})
@Permission(name = "Change Password of Device", permission = "/device-mgt/devices/owning-device/operations/android/change-lock-code")
Response changeLockCode(
- @ApiParam(name = "lockCodeBeanWrapper",
- value = "Configurations and device Ids need to be done change lock code")
+ @ApiParam(
+ name = "lockCode",
+ value = "The properties to change th lock code. Provide the lock code that will replace the current lock code on Android devices and " +
+ "the ID of the Android device. Multiple device IDs can be added by using comma separated values. " +
+ "If a passcode policy has been set in EMM, the lock code should comply to the passcode policy.\t",
+ required = true)
LockCodeBeanWrapper lockCodeBeanWrapper);
@POST
@@ -1295,15 +1382,15 @@ public interface DeviceManagementAdminService {
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
- value = "Setting a Passcode Policy on Android Devices",
- notes = "Set a password policy on Android devices",
+ value = "Setting a Password Policy on Android Devices",
+ notes = "Set a password policy on Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Set password policy operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the set password policy operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -1318,11 +1405,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -1340,8 +1427,10 @@ public interface DeviceManagementAdminService {
})
@Permission(name = "Set Password Policy", permission = "/device-mgt/devices/owning-device/operations/android/password-policy")
Response setPasswordPolicy(
- @ApiParam(name = "passwordPolicyBeanWrapper",
- value = "Password Policy Configurations and Device Ids")
+ @ApiParam(
+ name = "passwordPolicy",
+ value = "The properties required to set a password policy.",
+ required = true)
PasswordPolicyBeanWrapper passwordPolicyBeanWrapper);
@POST
@@ -1350,14 +1439,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Setting a Web Clip on Android Devices",
- notes = "Set a web clip on Android devices. A web clip is used to add a bookmark to a web application",
+ notes = "Set a web clip on Android devices. A web clip is used to add a bookmark to a web application.",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Set webclip operation has successfully been scheduled",
+ message = "Created. \n Successfully scheduled the set web clip operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
@@ -1372,11 +1461,11 @@ public interface DeviceManagementAdminService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -1386,16 +1475,18 @@ public interface DeviceManagementAdminService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 adding a new set webclip operation.")
+ "Server error occurred while adding adding a the set web clip operation.")
})
@Permission(name = "Add Webclips", permission = "/device-mgt/devices/owning-device/operations/android/webclip")
Response setWebClip(
- @ApiParam(name = "webClipBeanWrapper",
- value = "Configurations to need set web clip on device and device Ids")
+ @ApiParam(
+ name = "webClip",
+ value = "The properties to set the web clip.",
+ required = true)
WebClipBeanWrapper webClipBeanWrapper);
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java
index 66b84a875..e7731778e 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java
@@ -39,7 +39,7 @@ import java.util.List;
tags = {"devicemgt_android"})
@Api(value = "Android Device Management",
- description = "This carries all the resources related to Android device management functionalities")
+ description = "This carries all the resources related to the Android device management functionalities.")
@Path("/devices")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@@ -51,13 +51,14 @@ public interface DeviceManagementService {
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
- value = "Update the application list of a device",
+ value = "Updating the Application Details on Android Devices",
+ notes = "Update the details of the applications that are installed on Android devices.",
tags = "Android Device Management"
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
- message = "OK. \n Application list has been updated successfully",
+ message = "OK. \n Successfully updated the application details.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -71,17 +72,17 @@ public interface DeviceManagementService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
- message = "Not Found. \n Resource to be deleted does not exist."),
+ message = "Not Found. \n The specified resource does not exist."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -91,14 +92,14 @@ public interface DeviceManagementService {
Response updateApplicationList(
@ApiParam(
name = "id",
- value = "Device Identifier")
+ value = "The unique device identifier.")
@NotNull
@Size(min = 2 , max = 45)
@Pattern(regexp = "^[A-Za-z0-9]*$")
@PathParam("id") String id,
@ApiParam(
name = "applications",
- value = "List of applications that need to be persisted against the device")
+ value = "The properties to update application details. Multiple applications can be updated using comma separated values.")
List androidApplications);
@PUT
@@ -106,16 +107,18 @@ public interface DeviceManagementService {
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
- value = "Get the operation list pending for the device",
+ value = "Getting the Pending Operation List",
responseContainer = "List",
notes = "The Android agent communicates with the server to get the operations that are queued up " +
- "at the server end for a given device using via this particular resource",
+ "at the server end via this REST API." +
+ " While getting the pending operations the details of the operations executed at the device end is shared with the server. " +
+ "The server then updates the status of the operations that were carried out on the device.",
response = Operation.class,
tags = "Android Device Management")
@ApiResponses(value = {
@ApiResponse(
code = 200,
- message = "OK. \n Successfully fetched the pending application list of the Android device.",
+ message = "OK. \n Successfully fetched the pending operations of the Android device.",
response = Operation.class,
responseContainer = "List",
responseHeaders = {
@@ -128,33 +131,36 @@ public interface DeviceManagementService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ 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 has already the latest version of the requested resource."),
+ message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
- message = "Internal Server Error. \n Server error occurred while fetching policies.")
+ message = "Internal Server Error. \n Server error occurred while fetching the list of pending operations.")
})
@Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/android")
Response getPendingOperations(
@ApiParam(
name = "id",
- value = "Device Identifier")
+ value = "The unique device identifier.",
+ required = true)
@PathParam("id") String id,
@ApiParam(
name = "If-Modified-Since",
- value = "Validates if the requested variant has not been modified since the time specified",
+ value = "Checks if the requested variant was modified, since the specified date-time.\n" +
+ "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
+ "Example: Mon, 05 Jan 2014 15:10:00 +0200.",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@ApiParam(
name = "resultOperations",
- value = "Device Operation Status")
+ value = "Properties to update the device operations and their status.")
List extends Operation> resultOperations);
@POST
@@ -162,17 +168,17 @@ public interface DeviceManagementService {
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
- value = "Register an Android Device",
- notes = "When carrying out device registration via an Android device, you need to initially install" +
- " an Android Agent on the device, before being able to register the device with WSO2 EMM. Instead," +
+ value = "Registering an Android Device",
+ notes = "When registering an Android device, you need to install" +
+ " the Android Agent on the device, before being able to register the device with WSO2 EMM. Instead," +
" you can use this REST API to register an Android device with WSO2 EMM, without having to install" +
- " an Android Agent on the respective device",
+ " an Android Agent. This API can be mainly used to test the device enrollment process.",
tags = "Android Device Management"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
- message = "Created. \n Device enrollment has successfully been created",
+ message = "Created. \n Successfully created an instance of the device.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -186,11 +192,11 @@ public interface DeviceManagementService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -200,14 +206,16 @@ public interface DeviceManagementService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported.\n"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while adding a new device.")
})
@Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/android")
- Response enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll")
+ Response enrollDevice(@ApiParam(
+ name = "device",
+ value = "The properties required to enroll a device.")
@Valid AndroidDevice device);
@GET
@@ -215,7 +223,7 @@ public interface DeviceManagementService {
@ApiOperation(
httpMethod = "GET",
value = "Getting the Registration Status of an Android Device",
- notes = "Use this REST API to retrieve the registration status of an Android device",
+ notes = "Use this REST API to retrieve the registration status of an Android device.",
tags = "Android Device Management"
)
@ApiResponses(value = {
@@ -232,12 +240,12 @@ public interface DeviceManagementService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ 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 has already the latest version of the requested resource."),
+ message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@@ -249,11 +257,13 @@ public interface DeviceManagementService {
Response isEnrolled(
@ApiParam(
name = "id",
- value = "Device Identifier")
+ value = "The unique device identifier")
@PathParam("id") String id,
@ApiParam(
name = "If-Modified-Since",
- value = "Validates if the requested variant has not been modified since the time specified",
+ value = "Checks if the requested variant was modified, since the specified date-time.\n" +
+ "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
+ "Example: Mon, 05 Jan 2014 15:10:00 +0200",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@@ -262,14 +272,14 @@ public interface DeviceManagementService {
@ApiOperation(
httpMethod = "PUT",
value = "Updating the Registration Details of an Android Device",
- notes = "Use this REST API to update the registration details of an Android device",
+ notes = "Use this REST API to update the registration details of an Android device.",
tags = "Android Device Management"
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
- message = "OK. \n Device enrollment has been updated successfully",
+ message = "OK. \n Successfully updated the device enrollment details.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -283,17 +293,17 @@ public interface DeviceManagementService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
- message = "Not Found. \n Resource to be deleted does not exist."),
+ message = "Not Found. \n The specified resource does not exist."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -303,27 +313,27 @@ public interface DeviceManagementService {
Response modifyEnrollment(
@ApiParam(
name = "id",
- value = "Device Identifier")
+ value = "The unique device identifier.")
@PathParam("id") String id,
@ApiParam(
name = "device",
- value = "Device information to be modify") @Valid AndroidDevice androidDevice);
+ value = "The properties of required to update device enrollment details.") @Valid AndroidDevice androidDevice);
@DELETE
@Path("/{id}")
@ApiOperation(
httpMethod = "DELETE",
- value = "Un-register an Android Device",
- notes = "Use this REST API to un-register a specific Android device",
+ value = "Unregistering an Android Device",
+ notes = "Use this REST API to unregister an Android device.",
tags = "Android Device Management"
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
- message = "OK. \n Device has successfully been dis-enrolled"),
+ message = "OK. \n Successfully disenrolled the device."),
@ApiResponse(
code = 404,
- message = "Not Found. \n Resource to be deleted does not exist."),
+ message = "Not Found. \n The specified resource does not exist."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -333,7 +343,7 @@ public interface DeviceManagementService {
Response disEnrollDevice(
@ApiParam(
name = "id",
- value = "Device Identifier")
+ value = "The unique device identifier.")
@PathParam("id") String id);
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java
index e5e42f31f..dba8b4afd 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java
@@ -34,8 +34,7 @@ import javax.ws.rs.core.Response;
context = "api/device-mgt/android/v1.0/configuration",
tags = {"devicemgt_android"})
-@Api(value = "Android Configuration Management", description = "This API carries all resource associated with " +
- "manipulating the general configurations of Android platform")
+@Api(value = "Android Configuration Management", description = "This API carries all the resource used to mange the Android platform configurations.")
@Path("/configuration")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@@ -46,14 +45,14 @@ public interface DeviceTypeConfigurationService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Android Platform Configurations",
- notes = "Get the Android platform configuration details using this REST API",
+ notes = "Get the Android platform configuration details using this REST API.",
response = PlatformConfiguration.class,
tags = "Android Configuration Management"
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
- message = "OK. \n Successfully fetched Android platform configuration.",
+ message = "OK. \n Successfully fetched the Android platform configurations.",
response = PlatformConfiguration.class,
responseHeaders = {
@ResponseHeader(
@@ -65,27 +64,29 @@ public interface DeviceTypeConfigurationService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ 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 has already the latest version of the requested resource."),
+ message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 404,
- message = "Not Found. \n Resource to be deleted does not exist."),
+ message = "Not Found. \n The specified resource does not exist."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
- message = "Internal Server Error. \n Server error occurred while fetching Android platform configuration.")
+ message = "Internal Server Error. \n Server error occurred while fetching the Android platform configuration.")
})
@Permission(name = "View Configurations", permission = "/device-mgt/platform-configurations/view")
Response getConfiguration(
@ApiParam(
name = "If-Modified-Since",
- value = "Validates if the requested variant has not been modified since the time specified",
+ value = "Checks if the requested variant was modified, since the specified date-time.\n" +
+ "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
+ "Example: Mon, 05 Jan 2014 15:10:00 +0200",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@@ -94,14 +95,14 @@ public interface DeviceTypeConfigurationService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
- value = "Updating Android Platform Configuration.",
+ value = "Updating Android Platform Configurations",
notes = "Update the Android platform configurations using this REST API.",
tags = "Android Configuration Management"
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
- message = "OK. \n Android platform configuration has been updated successfully",
+ message = "OK. \n Successfully updated the Android platform configurations.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -115,26 +116,26 @@ public interface DeviceTypeConfigurationService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
- message = "Not Found. \n Resource to be deleted does not exist."),
+ message = "Not Found. \n The specified resource does not exist."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ 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 modifying Android platform configuration.")
+ "Server error occurred while modifying the Android platform configuration.")
})
@Permission(name = "Manage Configurations", permission = "/device-mgt/platform-configurations/manage")
Response updateConfiguration(
@ApiParam(name = "configuration",
- value = "AndroidPlatformConfiguration")
+ value = "The properties to update the Android platform configurations.")
@Valid AndroidPlatformConfiguration androidPlatformConfiguration);
@GET
@@ -143,9 +144,9 @@ public interface DeviceTypeConfigurationService {
@ApiOperation(
produces = MediaType.TEXT_PLAIN,
httpMethod = "GET",
- value = "Getting the License Agreement for Android Device Registration",
+ value = "Getting the License Agreement for the Android Device Registration",
notes = "Use this REST API to retrieve the license agreement that is used for the Android device " +
- "registration process",
+ "registration process.",
response = String.class,
tags = "Android Configuration Management")
@ApiResponses(value = {
@@ -163,27 +164,29 @@ public interface DeviceTypeConfigurationService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ 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 has already the latest version of the requested resource."),
+ message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 404,
- message = "Not Found. \n Resource to be deleted does not exist."),
+ message = "Not Found. \n The specified resource does not exist."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
- message = "Internal Server Error. \n Server error occurred while fetching Android license configuration.")
+ message = "Internal Server Error. \n Server error occurred while fetching the Android license configuration.")
})
@Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/android")
Response getLicense(
@ApiParam(
name = "If-Modified-Since",
- value = "Validates if the requested variant has not been modified since the time specified",
+ value = "Checks if the requested variant was modified, since the specified date-time.\n" +
+ "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
+ "Example: Mon, 05 Jan 2014 15:10:00 +0200.",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince) throws AndroidAgentException;
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java
index 2b2dd0d1e..c5a607b3a 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java
@@ -35,9 +35,9 @@ import javax.ws.rs.core.Response;
context = "api/device-mgt/android/v1.0/events",
tags = {"devicemgt_android"})
-@Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs.To enable Eventing need to" +
- " configure as ref-https://docs.wso2.com/display/EMM210/Managing+Event+Publishing+with+WSO2+Data+Analytics+Server, " +
- "https://docs.wso2.com/display/EMM210/Creating+a+New+Event+Stream+and+Receiver")
+@Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs. To enable event publishing/retrieving you need to" +
+ " configure WSO2 EMM as explained in https://docs.wso2.com/display/EMM220/Managing+Event+Publishing+with+WSO2+Data+Analytics+Server, " +
+ "https://docs.wso2.com/display/EMM220/Creating+a+New+Event+Stream+and+Receiver")
@Path("/events")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@@ -49,13 +49,13 @@ public interface EventReceiverService {
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
- value = "Event publishing via REST API.",
- notes = "Publish events received by the EMM Android client to WSO2 DAS using this API.",
+ value = "Publishing Events",
+ notes = "Publish events received by the WSO2 EMM Android client to the WSO2 Data Analytics Server (DAS) using this API.",
tags = "Event Receiver"
)
@ApiResponses(
value = {
- @ApiResponse(code = 201, message = "Created. \n Event is published successfully. Location header " +
+ @ApiResponse(code = 201, message = "Created. \n Successfully published the event. Location header " +
"contains URL of newly enrolled device",
responseHeaders = {
@ResponseHeader(
@@ -70,12 +70,12 @@ public interface EventReceiverService {
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
+ description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")
}),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
@@ -85,7 +85,7 @@ public interface EventReceiverService {
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
@@ -104,10 +104,10 @@ public interface EventReceiverService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting event details for a given time period.",
- notes = "Get the event details of a device for a given time duration using this API.Request must contain " +
- "the device identifier. Optionally, both, date from and date to value should be present to get " +
- "alerts between times. Based on device type and the device identifier also filtering can be done" +
- "(This cannot be combined with to and from parameters).",
+ notes = "Get the event details of a device for a given time duration using this API. The request must contain " +
+ "the device identifier. Optionally, both date from and date to value should be present to get " +
+ "alerts between a specified time. Filtering can also be done based on the device type and the device identifier." +
+ "(This cannot be combined with the to and from parameters).",
response = DeviceState.class,
responseContainer = "List",
tags = "Event Receiver"
@@ -116,12 +116,11 @@ public interface EventReceiverService {
value = {
@ApiResponse(
code = 200,
- message = "OK. \n Event details of a device for a given time duration have been successfully fetched",
+ message = "OK. \n Successfully fetched the event details of the specified device for a given time duration.",
response = DeviceState.class, responseContainer = "List"),
@ApiResponse(
code = 303,
- message = "See Other. \n Source can be retrieved from the URL specified at" +
- " the Location header.",
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(name = "Content-Location", description = "Source URL of the document.")
}),
@@ -132,39 +131,44 @@ public interface EventReceiverService {
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error. You must provide" +
- " the device identifier. Additionally, the device identifier can be combined with either the type" +
- " OR date from and to."),
+ " the device identifier. Additionally, the device identifier can be combined with either the device type" +
+ " OR the from and to date."),
@ApiResponse(
code = 404,
- message = "Not Found. \n Resource requested does not exist."),
+ message = "Not Found. \n The specified resource does not exist."),
@ApiResponse(
code = 500,
- message = "Error occurred while getting published events for specific device.")
+ message = "Error occurred while getting the published events for the specified device.")
})
@Permission(name = "Publish Events to DAS", permission = "/device-mgt/devices/enroll/android")
Response retrieveAlerts(
@ApiParam(
name = "id",
- value = "Device Identifier to be need to retrieve events.",
+ value = "The unique device identifier.",
required = true)
@Size(min = 2, max = 45)
@QueryParam("id") String deviceId,
@ApiParam(
name = "from",
- value = "From Date.")
+ value = "Specify the time and date from when you want to get the data." +
+ "Provide the time and date format in the unix/epoch format as the value for {unixTimestamp}. Use a Epoch convertor, to convert the time and date to this format.")
@QueryParam("from") long from,
@ApiParam(
name = "to",
- value = "To Date.")
+ value = "Specify the time and date up to when you require the data." +
+ "Provide the time and date format in the unix/epoch format as the value for {unixTimestamp}. Use a Epoch convertor, to convert the time and date to this format.")
@QueryParam("to") long to,
@ApiParam(
name = "type",
- value = "Type of the Alert to be need to retrieve events.")
+ value = "The alert type to retrieve the events." +
+ "Provide APPLICATION_STATE or RUNTIME_STATE as the value.")
@Size(min = 2, max = 45)
@QueryParam("type") String type,
@ApiParam(
name = "If-Modified-Since",
- value = "Validates if the requested variant has not been modified since the time specified",
+ value = "Checks if the requested variant was modified, since the specified date-time.\n" +
+ "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
+ "Example: Mon, 05 Jan 2014 15:10:00 +0200",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java
index b7fcd5f92..2349aa3ef 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java
@@ -1072,7 +1072,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
private static void validateScheduleDate(String dateString){
try {
- if (dateString != null) {
+ if (dateString != null && !dateString.isEmpty()) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
sdf.setLenient(false);
sdf.parse(dateString);
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java
index f068b8884..9e8d1306b 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java
@@ -24,7 +24,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
-import org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceUtils;
+import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
import org.wso2.carbon.analytics.datasource.commons.Record;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.context.CarbonContext;
@@ -218,7 +218,7 @@ public class AndroidAPIUtils {
List resultEntries = analyticsDataAPI.search(tenantId, tableName, query, 0, eventCount);
List recordIds = getRecordIds(resultEntries);
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
- Map deviceStateses = createDeviceStatusData(AnalyticsDataServiceUtils.listRecords(
+ Map deviceStateses = createDeviceStatusData(AnalyticsDataAPIUtil.listRecords(
analyticsDataAPI, response));
return getSortedDeviceStateData(deviceStateses, resultEntries);
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml
index 7c07ebd28..4f0e65511 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml
@@ -51,7 +51,7 @@
-
+
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml
index 0edf76351..05b1a0479 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml
@@ -23,13 +23,13 @@
android-pluginorg.wso2.carbon.devicemgt-plugins
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOT../pom.xml4.0.0org.wso2.carbon.device.mgt.mobile.android.ui
- 2.2.5-SNAPSHOT
+ 2.2.6-SNAPSHOTWSO2 Carbon - Mobile Android UIpom
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.hbs
index bba71218c..d607d3875 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.hbs
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.hbs
@@ -55,9 +55,9 @@