refactored device type after changes done for the deployer

revert-dabc3590
ayyoob 8 years ago
parent 8906d964b0
commit b195759dcf

@ -44,24 +44,7 @@
<artifactId>cxf-rt-frontend-jaxrs</artifactId> <artifactId>cxf-rt-frontend-jaxrs</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--MQTT -->
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<scope>provided</scope>
</dependency>
<!--IOT -->
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.plugin</artifactId>
<scope>provided</scope>
</dependency>
<!--JAX-RS --> <!--JAX-RS -->
<dependency> <dependency>
<groupId>org.codehaus.jackson</groupId> <groupId>org.codehaus.jackson</groupId>
@ -82,12 +65,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId> <artifactId>org.wso2.carbon.utils</artifactId>
@ -171,6 +148,11 @@
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>

@ -30,12 +30,10 @@ 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.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; 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.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants; import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.constants.AndroidSenseConstants;
import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.APIUtil; import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.APIUtil;
import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.AndroidConfiguration; import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.AndroidConfiguration;
import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.Constants;
import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.SensorRecord; import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.SensorRecord;
import org.wso2.carbon.device.mgt.iot.util.Utils;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@ -286,8 +284,8 @@ public class AndroidSenseServiceImpl implements AndroidSenseService {
AndroidConfiguration androidConfiguration = new AndroidConfiguration(); AndroidConfiguration androidConfiguration = new AndroidConfiguration();
androidConfiguration.setTenantDomain(APIUtil.getAuthenticatedUserTenantDomain()); androidConfiguration.setTenantDomain(APIUtil.getAuthenticatedUserTenantDomain());
String mqttEndpoint = DEFAULT_MQTT_ENDPOINT; String mqttEndpoint = DEFAULT_MQTT_ENDPOINT;
if (mqttEndpoint.contains(Constants.LOCALHOST)) { if (mqttEndpoint.contains(AndroidSenseConstants.LOCALHOST)) {
mqttEndpoint = mqttEndpoint.replace(Constants.LOCALHOST, Utils.getServerUrl()); mqttEndpoint = mqttEndpoint.replace(AndroidSenseConstants.LOCALHOST, APIUtil.getServerUrl());
} }
androidConfiguration.setMqttEndpoint(mqttEndpoint); androidConfiguration.setMqttEndpoint(mqttEndpoint);
return Response.ok(androidConfiguration.toString()).build(); return Response.ok(androidConfiguration.toString()).build();

@ -19,8 +19,6 @@ package org.wso2.carbon.device.mgt.iot.androidsense.service.impl.constants;
public class AndroidSenseConstants { public class AndroidSenseConstants {
public final static String DEVICE_TYPE = "android_sense"; public final static String DEVICE_TYPE = "android_sense";
public final static String DEVICE_PLUGIN_DEVICE_NAME = "DEVICE_NAME";
public final static String DEVICE_PLUGIN_DEVICE_ID = "ANDROID_DEVICE_ID";
//Android Sensor names //Android Sensor names
public static final String SENSOR_ACCELEROMETER = "accelerometer"; public static final String SENSOR_ACCELEROMETER = "accelerometer";
@ -35,9 +33,13 @@ public class AndroidSenseConstants {
public static final String SENSOR_ROTATION = "rotation"; public static final String SENSOR_ROTATION = "rotation";
public static final String SENSOR_WORDCOUNT = "wordcounter"; public static final String SENSOR_WORDCOUNT = "wordcounter";
//MQTT Subscribe topic //MQTT Subscribe topic
public final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
//mqtt tranport related constants //mqtt tranport related constants
public static final String MQTT_ADAPTER_TOPIC_PROPERTY_NAME = "mqtt.adapter.topic"; public static final String MQTT_ADAPTER_TOPIC_PROPERTY_NAME = "mqtt.adapter.topic";
public static final String HOST_NAME = "HostName";
public static final String LOCALHOST = "localhost";
public static final String CONFIG_TYPE = "general";
public static final String DEFAULT_ENDPOINT = "tcp://localhost:1883";
} }

@ -10,6 +10,7 @@ import org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceUtils;
import org.wso2.carbon.analytics.datasource.commons.Record; import org.wso2.carbon.analytics.datasource.commons.Record;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
@ -18,13 +19,13 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManageme
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.iot.util.Utils; import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.constants.AndroidSenseConstants;
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.NetworkUtils;
import java.net.SocketException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -204,10 +205,10 @@ public class APIUtil {
} }
public static String getMqttEndpoint() throws ConfigurationManagementException { public static String getMqttEndpoint() throws ConfigurationManagementException {
String iotServerIP = Constants.DEFAULT_ENDPOINT; String iotServerIP = AndroidSenseConstants.DEFAULT_ENDPOINT;
iotServerIP = iotServerIP.replace(Constants.LOCALHOST, Utils.getServerUrl());; iotServerIP = iotServerIP.replace(AndroidSenseConstants.LOCALHOST, getServerUrl());;
PlatformConfiguration configuration = APIUtil.getTenantConfigurationManagementService().getConfiguration( PlatformConfiguration configuration = APIUtil.getTenantConfigurationManagementService().getConfiguration(
Constants.CONFIG_TYPE); AndroidSenseConstants.CONFIG_TYPE);
if (configuration != null && configuration.getConfiguration() != null && configuration if (configuration != null && configuration.getConfiguration() != null && configuration
.getConfiguration().size() > 0) { .getConfiguration().size() > 0) {
List<ConfigurationEntry> configurations = configuration.getConfiguration(); List<ConfigurationEntry> configurations = configuration.getConfiguration();
@ -221,4 +222,17 @@ public class APIUtil {
} }
return iotServerIP; return iotServerIP;
} }
public static String getServerUrl() {
String hostName = ServerConfiguration.getInstance().getFirstProperty(AndroidSenseConstants.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;
}
} }

@ -35,7 +35,6 @@
<modules> <modules>
<module>org.wso2.carbon.device.mgt.iot.androidsense.analytics</module> <module>org.wso2.carbon.device.mgt.iot.androidsense.analytics</module>
<module>org.wso2.carbon.device.mgt.iot.androidsense.api</module> <module>org.wso2.carbon.device.mgt.iot.androidsense.api</module>
<module>org.wso2.carbon.device.mgt.iot.androidsense.plugin</module>
<module>org.wso2.carbon.device.mgt.iot.androidsense.ui</module> <module>org.wso2.carbon.device.mgt.iot.androidsense.ui</module>
</modules> </modules>

@ -109,13 +109,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--MQTT -->
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<scope>provided</scope>
</dependency>
<!--IOT --> <!--IOT -->
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
@ -123,16 +116,6 @@
<version>4.1</version> <version>4.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.arduino.plugin</artifactId>
<scope>provided</scope>
</dependency>
<!--JAX-RS --> <!--JAX-RS -->
<dependency> <dependency>
@ -154,18 +137,17 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.analytics</groupId>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId> <artifactId>org.wso2.carbon.analytics.api</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.analytics</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.analytics.api</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

@ -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.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; 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.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.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.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.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.JWTClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
@ -54,7 +54,6 @@ import java.util.*;
public class ArduinoServiceImpl implements ArduinoService { public class ArduinoServiceImpl implements ArduinoService {
private static Log log = LogFactory.getLog(ArduinoServiceImpl.class); private static Log log = LogFactory.getLog(ArduinoServiceImpl.class);
private static Map<String, LinkedList<String>> internalControlsQueue = new HashMap<>();
private static final String KEY_TYPE = "PRODUCTION"; private static final String KEY_TYPE = "PRODUCTION";
private static ApiApplicationKey apiApplicationKey; private static ApiApplicationKey apiApplicationKey;

@ -20,9 +20,6 @@ package org.wso2.carbon.device.mgt.iot.arduino.service.impl.constants;
public class ArduinoConstants { public class ArduinoConstants {
public final static String DEVICE_TYPE = "arduino"; 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://"; public static final String URL_PREFIX = "http://";
//sensor events summerized table name //sensor events summerized table name

@ -25,11 +25,9 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.concurrent.FutureCallback; import org.apache.http.concurrent.FutureCallback;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClients; 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.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 javax.ws.rs.HttpMethod;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;

@ -18,20 +18,38 @@
package org.wso2.carbon.device.mgt.iot.arduino.service.impl.util; 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.MultitenantConstants;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; 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.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException; 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.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.CarbonUtils;
import org.wso2.carbon.utils.NetworkUtils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; 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.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; 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. * 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 HTTP_PORT_PROPERTY = "httpPort";
private static final String CONFIG_TYPE = "general"; 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, public ZipArchive createZipFile(String owner, String tenantDomain, String deviceType,
String deviceId, String deviceName, String token, String deviceId, String deviceName, String token,
@ -52,7 +72,7 @@ public class ZipUtil {
String iotServerIP; String iotServerIP;
try { try {
iotServerIP = Utils.getServerUrl(); iotServerIP = getServerUrl();
String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY); String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY);
Map<String, String> contextParams = new HashMap<>(); Map<String, String> contextParams = new HashMap<>();
@ -88,7 +108,7 @@ public class ZipUtil {
contextParams.put("DEVICE_REFRESH_TOKEN", refreshToken); contextParams.put("DEVICE_REFRESH_TOKEN", refreshToken);
ZipArchive zipFile; ZipArchive zipFile;
zipFile = Utils.getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName); zipFile = getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName);
return zipFile; return zipFile;
} catch (IOException e) { } catch (IOException e) {
throw new DeviceManagementException("Zip File Creation Failed", e); throw new DeviceManagementException("Zip File Creation Failed", e);
@ -96,4 +116,227 @@ public class ZipUtil {
throw new DeviceManagementException("Failed to retrieve configuration", e); 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<String, List<String>> properties = getProperties(sketchPath + File.separator + "sketch" + ".properties");
List<String> 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<String, List<String>> 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<String, List<String>> properties = new HashMap<String, List<String>>();
String templates = prop.getProperty("templates");
List<String> list = new ArrayList<String>(Arrays.asList(templates.split(",")));
properties.put("templates", list);
final String filename = prop.getProperty("zipfilename");
list = new ArrayList<String>() {{
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<String> 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;
}
} }

@ -35,7 +35,6 @@
<modules> <modules>
<module>org.wso2.carbon.device.mgt.iot.arduino.api</module> <module>org.wso2.carbon.device.mgt.iot.arduino.api</module>
<module>org.wso2.carbon.device.mgt.iot.arduino.plugin</module>
<module>org.wso2.carbon.device.mgt.iot.arduino.ui</module> <module>org.wso2.carbon.device.mgt.iot.arduino.ui</module>
<module>org.wso2.carbon.device.mgt.iot.arduino.analytics</module> <module>org.wso2.carbon.device.mgt.iot.arduino.analytics</module>
</modules> </modules>

@ -28,10 +28,10 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.url.printer</artifactId>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - IoT Device Management Common Impl</name> <name>WSO2 Carbon - IoT url printer</name>
<description>WSO2 Carbon - IoT Device Management and Control Implementation</description> <description>WSO2 Carbon - IoT url printer</description>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<build> <build>
@ -59,44 +59,23 @@
<Bundle-Name>${project.artifactId}</Bundle-Name> <Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.devicemgt.plugins.version}</Bundle-Version> <Bundle-Version>${carbon.devicemgt.plugins.version}</Bundle-Version>
<Bundle-Description>IoT Server Impl Bundle</Bundle-Description> <Bundle-Description>IoT Server Impl Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.device.mgt.iot.internal</Private-Package> <Private-Package>org.wso2.carbon.device.mgt.iot.url.printer.internal</Private-Package>
<Import-Package> <Import-Package>
org.wso2.carbon.base.*,
org.osgi.framework, org.osgi.framework,
org.osgi.service.component, org.osgi.service.component,
org.apache.axis2.context,
org.apache.commons.io,
org.apache.commons.logging, org.apache.commons.logging,
org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.wso2.carbon.core, org.wso2.carbon.core,
org.wso2.carbon.device.mgt.common, org.wso2.carbon.utils.*,
org.wso2.carbon.utils,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}",
org.w3c.dom
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
!org.wso2.carbon.device.mgt.iot.internal, !org.wso2.carbon.device.mgt.iot.url.printer.internal,
org.wso2.carbon.device.mgt.iot.*;version="${project.version}" org.wso2.carbon.device.mgt.iot.url.printer.*;version="${project.version}"
</Export-Package> </Export-Package>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-surefire-plugin</artifactId>-->
<!--<version>2.18</version>-->
<!--<configuration>-->
<!--<systemPropertyVariables>-->
<!--<log4j.configuration>file:src/test/resources/log4j.properties-->
<!--</log4j.configuration>-->
<!--</systemPropertyVariables>-->
<!--<suiteXmlFiles>-->
<!--<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>-->
<!--</suiteXmlFiles>-->
<!--</configuration>-->
<!--</plugin>-->
</plugins> </plugins>
</build> </build>
@ -111,89 +90,19 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId> <artifactId>org.wso2.carbon.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents.wso2</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ndatasource.core</artifactId> <artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
<artifactId>json</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.core</artifactId> <artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.analytics-common</groupId>
<artifactId>org.wso2.carbon.databridge.agent</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.analytics-common</groupId>
<artifactId>org.wso2.carbon.databridge.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.commons</groupId>
<artifactId>org.wso2.carbon.databridge.commons</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
</dependency>
<!--Dependencies on XMPP Client Library-->
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>org.apache.axis2.wso2</groupId>
<artifactId>commons-codec</artifactId> <artifactId>axis2</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

@ -1,60 +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;
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.utils.CarbonUtils;
import org.wso2.carbon.utils.ConfigurationContextService;
import org.wso2.carbon.utils.NetworkUtils;
public class URLPrinterStartupHandler implements ServerStartupObserver {
private static final Log log = LogFactory.getLog(URLPrinterStartupHandler.class);
@Override
public void completingServerStartup() {
}
@Override
public void completedServerStartup() {
log.info("IoT Console URL : " + this.getIoTUrl());
}
private String getIoTUrl() {
// Hostname
String hostName = "localhost";
try {
hostName = NetworkUtils.getMgtHostName();
} catch (Exception ignored) {
}
// HTTPS port
String mgtConsoleTransport = CarbonUtils.getManagementTransport();
ConfigurationContextService configContextService =
IoTDeviceManagementDataHolder.getInstance().getConfigurationContextService();
int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport);
int httpsProxyPort =
CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), mgtConsoleTransport);
if (httpsProxyPort > 0) {
port = httpsProxyPort;
}
return "https://" + hostName + ":" + port + "/devicemgt";
}
}

@ -1,34 +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.internal;
import org.wso2.carbon.utils.ConfigurationContextService;
public class UrlPrinterDataHolder {
private static UrlPrinterDataHolder thisInstance = new UrlPrinterDataHolder();
private UrlPrinterDataHolder() {}
public static UrlPrinterDataHolder getInstance() {
return thisInstance;
}
}

@ -1,85 +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.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.URLPrinterStartupHandler;
import org.wso2.carbon.utils.ConfigurationContextService;
/**
* @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"
* cardinality="0..1"
* policy="dynamic"
* bind="setConfigurationContextService"
* unbind="unsetConfigurationContextService"
*/
public class UrlPrinterServiceComponent {
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");
}
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");
}
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);
}
}
protected void deactivate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("De-activating Iot Device Management Service Component");
}
}
protected void setConfigurationContextService(ConfigurationContextService configurationContextService) {
if (log.isDebugEnabled()) {
log.debug("Setting ConfigurationContextService");
}
IoTDeviceManagementDataHolder.getInstance().setConfigurationContextService(configurationContextService);
}
protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) {
if (log.isDebugEnabled()) {
log.debug("Un-setting ConfigurationContextService");
}
IoTDeviceManagementDataHolder.getInstance().setConfigurationContextService(null);
}
}

@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.iot.URLPrinterStartupHandler; import org.wso2.carbon.device.mgt.iot.url.printer.URLPrinterStartupHandler;
import org.wso2.carbon.utils.ConfigurationContextService; import org.wso2.carbon.utils.ConfigurationContextService;
/** /**

@ -33,7 +33,7 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<modules> <modules>
<module>org.wso2.carbon.device.mgt.iot</module> <module>org.wso2.carbon.device.mgt.iot.url.printer</module>
<module>org.wso2.carbon.device.mgt.iot.ui</module> <module>org.wso2.carbon.device.mgt.iot.ui</module>
<module>org.wso2.carbon.device.mgt.iot.output.adapter.mqtt</module> <module>org.wso2.carbon.device.mgt.iot.output.adapter.mqtt</module>
<module>org.wso2.carbon.device.mgt.iot.output.adapter.xmpp</module> <module>org.wso2.carbon.device.mgt.iot.output.adapter.xmpp</module>

@ -69,13 +69,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--MQTT -->
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<scope>provided</scope>
</dependency>
<!--IOT --> <!--IOT -->
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
@ -83,16 +76,6 @@
<version>4.1</version> <version>4.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.raspberrypi.plugin</artifactId>
<scope>provided</scope>
</dependency>
<!--JAX-RS --> <!--JAX-RS -->
<dependency> <dependency>
@ -113,22 +96,11 @@
<artifactId>jsr311-api</artifactId> <artifactId>jsr311-api</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId> <artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
@ -144,6 +116,11 @@
<artifactId>org.wso2.carbon.analytics.api</artifactId> <artifactId>org.wso2.carbon.analytics.api</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>

@ -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.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; 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.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.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.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.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.JWTClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;

@ -21,15 +21,12 @@ package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.constants;
public class RaspberrypiConstants { public class RaspberrypiConstants {
public final static String DEVICE_TYPE = "raspberrypi"; 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_ON = "ON";
public final static String STATE_OFF = "OFF"; public final static String STATE_OFF = "OFF";
public static final String BULB_CONTEXT = "BULB"; public static final String BULB_CONTEXT = "BULB";
//sensor events summerized table name //sensor events summerized table name
public static final String TEMPERATURE_EVENT_TABLE = "DEVICE_TEMPERATURE_SUMMARY"; public static final String TEMPERATURE_EVENT_TABLE = "DEVICE_TEMPERATURE_SUMMARY";
public final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
//mqtt tranport related constants //mqtt tranport related constants
public static final String MQTT_ADAPTER_TOPIC_PROPERTY_NAME = "mqtt.adapter.topic"; public static final String MQTT_ADAPTER_TOPIC_PROPERTY_NAME = "mqtt.adapter.topic";

@ -18,25 +18,45 @@
package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.util; 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.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; 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.ConfigurationManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; 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.CarbonUtils;
import org.wso2.carbon.utils.NetworkUtils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; 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.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; 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. * This is used to create a zip file that includes the necessary configuration required for the agent.
*/ */
public class ZipUtil { 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 HTTPS_PORT_PROPERTY = "httpsPort";
private static final String HTTP_PORT_PROPERTY = "httpPort"; private static final String HTTP_PORT_PROPERTY = "httpPort";
@ -57,7 +77,7 @@ public class ZipUtil {
String iotServerIP; String iotServerIP;
try { try {
iotServerIP = Utils.getServerUrl(); iotServerIP = getServerUrl();
String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY); String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY);
String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY); String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY);
String httpsServerEP = HTTPS_PROTOCOL_APPENDER + iotServerIP + ":" + httpsServerPort; String httpsServerEP = HTTPS_PROTOCOL_APPENDER + iotServerIP + ":" + httpsServerPort;
@ -101,7 +121,7 @@ public class ZipUtil {
contextParams.put("DEVICE_REFRESH_TOKEN", refreshToken); contextParams.put("DEVICE_REFRESH_TOKEN", refreshToken);
ZipArchive zipFile; ZipArchive zipFile;
zipFile = Utils.getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName); zipFile = getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName);
return zipFile; return zipFile;
} catch (IOException e) { } catch (IOException e) {
throw new DeviceManagementException("Zip File Creation Failed", e); throw new DeviceManagementException("Zip File Creation Failed", e);
@ -109,4 +129,227 @@ public class ZipUtil {
throw new DeviceManagementException("Failed to retrieve configuration", e); 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<String, List<String>> properties = getProperties(sketchPath + File.separator + "sketch" + ".properties");
List<String> 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<String, List<String>> 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<String, List<String>> properties = new HashMap<String, List<String>>();
String templates = prop.getProperty("templates");
List<String> list = new ArrayList<String>(Arrays.asList(templates.split(",")));
properties.put("templates", list);
final String filename = prop.getProperty("zipfilename");
list = new ArrayList<String>() {{
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<String> 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;
}
} }

@ -33,7 +33,6 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<modules> <modules>
<module>org.wso2.carbon.device.mgt.iot.raspberrypi.plugin</module>
<module>org.wso2.carbon.device.mgt.iot.raspberrypi.ui</module> <module>org.wso2.carbon.device.mgt.iot.raspberrypi.ui</module>
<module>org.wso2.carbon.device.mgt.iot.raspberrypi.api</module> <module>org.wso2.carbon.device.mgt.iot.raspberrypi.api</module>
<module>org.wso2.carbon.device.mgt.iot.raspberrypi.analytics</module> <module>org.wso2.carbon.device.mgt.iot.raspberrypi.analytics</module>

@ -107,16 +107,6 @@
<version>4.1</version> <version>4.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin</artifactId>
<scope>provided</scope>
</dependency>
<!--JAX-RS --> <!--JAX-RS -->
<dependency> <dependency>
@ -206,18 +196,15 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.igniterealtime.smack.wso2</groupId> <groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId> <artifactId>smack</artifactId>
@ -228,11 +215,6 @@
<artifactId>smackx</artifactId> <artifactId>smackx</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId> <artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
@ -248,9 +230,17 @@
<artifactId>org.wso2.carbon.analytics.api</artifactId> <artifactId>org.wso2.carbon.analytics.api</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

@ -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.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; 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.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.constants.VirtualFireAlarmConstants;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException; 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.XmppAccount;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.xmpp.XmppConfig; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.xmpp.XmppConfig;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.xmpp.XmppServerClient; 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.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.APIUtil;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util.VirtualFireAlarmServiceUtils; 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.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.JWTClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;

@ -19,11 +19,9 @@
package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util; package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util;
import org.apache.commons.codec.binary.Base64; 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.json.JSONObject;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException; 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 org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.exception.VirtualFireAlarmException;
import java.lang.*; import java.lang.*;

@ -19,24 +19,40 @@
package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util; package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util;
import org.apache.commons.codec.binary.Base64; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.json.JSONObject; import org.json.JSONObject;
import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; 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.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; 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.ConfigurationManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; 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.device.mgt.iot.virtualfirealarm.plugin.xmpp.XmppConfig;
import org.wso2.carbon.utils.CarbonUtils; 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.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; 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.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; 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. * 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 HTTP_PROTOCOL_APPENDER = "http://";
private static final String CONFIG_TYPE = "general"; private static final String CONFIG_TYPE = "general";
private static final String DEFAULT_MQTT_ENDPOINT = "tcp://localhost:1883"; 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, public ZipArchive createZipFile(String owner, String deviceType, String deviceId, String deviceName,
String apiApplicationKey, String token, String refreshToken) String apiApplicationKey, String token, String refreshToken)
@ -65,7 +82,7 @@ public class ZipUtil {
String iotServerIP; String iotServerIP;
try { try {
iotServerIP = Utils.getServerUrl(); iotServerIP = getServerUrl();
String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY); String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY);
String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY); String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY);
String httpsServerEP = HTTPS_PROTOCOL_APPENDER + iotServerIP + ":" + httpsServerPort; String httpsServerEP = HTTPS_PROTOCOL_APPENDER + iotServerIP + ":" + httpsServerPort;
@ -125,7 +142,7 @@ public class ZipUtil {
? "" : XmppConfig.getInstance().getJid()); ? "" : XmppConfig.getInstance().getJid());
ZipArchive zipFile; ZipArchive zipFile;
zipFile = Utils.getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName); zipFile = getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName);
return zipFile; return zipFile;
} catch (IOException e) { } catch (IOException e) {
throw new DeviceManagementException("Zip File Creation Failed", e); throw new DeviceManagementException("Zip File Creation Failed", e);
@ -142,4 +159,229 @@ public class ZipUtil {
String stringToEncode = consumerKey + ":" + consumerSecret; String stringToEncode = consumerKey + ":" + consumerSecret;
return Base64.encodeBase64String(stringToEncode.getBytes()); 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<String, List<String>> properties = getProperties(sketchPath + File.separator + "sketch" + ".properties");
List<String> 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<String, List<String>> 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<String, List<String>> properties = new HashMap<String, List<String>>();
String templates = prop.getProperty("templates");
List<String> list = new ArrayList<String>(Arrays.asList(templates.split(",")));
properties.put("templates", list);
final String filename = prop.getProperty("zipfilename");
list = new ArrayList<String>() {{
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<String> 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;
}
} }

@ -24,6 +24,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; 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.CarbonUtils;
import org.wso2.carbon.utils.NetworkUtils; import org.wso2.carbon.utils.NetworkUtils;
@ -55,229 +56,6 @@ public class Utils {
public static final String HOST_NAME = "HostName"; public static final String HOST_NAME = "HostName";
private static final Log log = LogFactory.getLog(Utils.class); 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<String, List<String>> properties = getProperties(sketchPath + File.separator + "sketch" + ".properties");
List<String> 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<String, List<String>> 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<String, List<String>> properties = new HashMap<String, List<String>>();
String templates = prop.getProperty("templates");
List<String> list = new ArrayList<String>(Arrays.asList(templates.split(",")));
properties.put("templates", list);
final String filename = prop.getProperty("zipfilename");
list = new ArrayList<String>() {{
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<String> 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;
}
} }

@ -83,7 +83,10 @@
org.wso2.carbon.event.input.adapter.core, org.wso2.carbon.event.input.adapter.core,
org.wso2.carbon.event.input.adapter.core.exception, org.wso2.carbon.event.input.adapter.core.exception,
org.jivesoftware.smack.*, 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
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
!org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal, !org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal,
@ -160,9 +163,5 @@
<groupId>org.igniterealtime.smack.wso2</groupId> <groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId> <artifactId>smackx</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -27,39 +27,19 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "DeviceManagementConfiguration") @XmlRootElement(name = "DeviceManagementConfiguration")
public class DeviceManagementConfiguration { public class DeviceManagementConfiguration {
private DeviceManagementConfigRepository deviceManagementConfigRepository; private EventListenerConfiguration eventListenerConfiguration;
private PushNotificationConfig pushNotificationConfig;
private String deviceType;
private static final Log log = LogFactory.getLog(DeviceManagementConfiguration.class); private static final Log log = LogFactory.getLog(DeviceManagementConfiguration.class);
private DeviceManagementConfiguration() { 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) @XmlElement(name = "PushNotificationConfiguration", required = false)
public PushNotificationConfig getPushNotificationConfig() { public EventListenerConfiguration getEventListenerConfiguration() {
return pushNotificationConfig; return eventListenerConfiguration;
} }
public void setPushNotificationConfig(PushNotificationConfig pushNotificationConfig) { public void setEventListenerConfiguration(EventListenerConfiguration eventListenerConfiguration) {
this.pushNotificationConfig = pushNotificationConfig; this.eventListenerConfiguration = eventListenerConfiguration;
} }
} }

@ -25,10 +25,10 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue; import javax.xml.bind.annotation.XmlValue;
import java.util.List; import java.util.List;
@XmlRootElement(name = "PushNotificationConfiguration") @XmlRootElement(name = "EventListenerConfiguration")
public class EventListenerConfiguration { public class EventListenerConfiguration {
private String pushNotificationProvider; private String eventListenerProvider;
private List<Property> properties; private List<Property> properties;
@XmlElementWrapper(name = "Properties", required = true) @XmlElementWrapper(name = "Properties", required = true)
@ -41,13 +41,13 @@ public class EventListenerConfiguration {
this.properties = properties; this.properties = properties;
} }
@XmlElement(name = "PushNotificationProvider", required = true) @XmlElement(name = "EventListenerProvider", required = true)
public String getPushNotificationProvider() { public String getEventListenerProvider() {
return pushNotificationProvider; return eventListenerProvider;
} }
public void setPushNotificationProvider(String pushNotificationProvider) { public void setEventListenerProvider(String eventListenerProvider) {
this.pushNotificationProvider = pushNotificationProvider; this.eventListenerProvider = eventListenerProvider;
} }
@XmlRootElement(name = "Property") @XmlRootElement(name = "Property")

@ -18,8 +18,13 @@ public class VirtualFirealarmConfig {
private static final String DEVICE_TYPE_CONFIG_PATH = private static final String DEVICE_TYPE_CONFIG_PATH =
CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-mgt-plugins" + File.separator CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-mgt-plugins" + File.separator
+ "virtual_firealarm.xml"; + "virtual_firealarm.xml";
private static VirtualFirealarmConfig virtualFirealarmConfig = new VirtualFirealarmConfig();
private static DeviceManagementConfiguration deviceManagementConfiguration; private static DeviceManagementConfiguration deviceManagementConfiguration;
public static VirtualFirealarmConfig getInstance() {
return virtualFirealarmConfig;
}
public static void initialize() throws VirtualFirealarmConfigurationException { public static void initialize() throws VirtualFirealarmConfigurationException {
File configFile = new File(DEVICE_TYPE_CONFIG_PATH); File configFile = new File(DEVICE_TYPE_CONFIG_PATH);
try { try {
@ -37,7 +42,7 @@ public class VirtualFirealarmConfig {
} }
private DeviceManagementConfiguration getDeviceTypeConfiguration(File configurationFile) { public DeviceManagementConfiguration getDeviceTypeConfiguration() {
return deviceManagementConfiguration; return deviceManagementConfiguration;
} }

@ -26,7 +26,6 @@ import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService
import org.wso2.carbon.context.PrivilegedCarbonContext; 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.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; 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.constants.VirtualFireAlarmConstants;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder; 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.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException;
import org.json.JSONObject; 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.io.IOException;
import java.security.PublicKey; import java.security.PublicKey;
import java.security.cert.X509Certificate; 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.HashMap;
import java.util.Map; import java.util.Map;
@ -58,62 +49,6 @@ public class VirtualFireAlarmUtils {
private static Log log = LogFactory.getLog(VirtualFireAlarmUtils.class); 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 { public static void setupMqttInputAdapter() throws IOException {
if (!MqttConfig.getInstance().isEnabled()) { if (!MqttConfig.getInstance().isEnabled()) {
return; return;

@ -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.certificate.mgt.core.service.CertificateManagementService;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; 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; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterService;
/** /**
@ -31,7 +30,6 @@ public class VirtualFirealarmManagementDataHolder {
private InputEventAdapterService inputEventAdapterService; private InputEventAdapterService inputEventAdapterService;
private EventsPublisherService eventsPublisherService; private EventsPublisherService eventsPublisherService;
private CertificateManagementService certificateManagementService; private CertificateManagementService certificateManagementService;
private DeviceTypeConfigService deviceTypeConfigService;
private static VirtualFirealarmManagementDataHolder thisInstance = new VirtualFirealarmManagementDataHolder(); private static VirtualFirealarmManagementDataHolder thisInstance = new VirtualFirealarmManagementDataHolder();
@ -66,13 +64,4 @@ public class VirtualFirealarmManagementDataHolder {
public void setCertificateManagementService(CertificateManagementService certificateManagementService) { public void setCertificateManagementService(CertificateManagementService certificateManagementService) {
this.certificateManagementService = certificateManagementService; this.certificateManagementService = certificateManagementService;
} }
public DeviceTypeConfigService getDeviceTypeConfigService() {
return deviceTypeConfigService;
}
public void setDeviceTypeConfigService(
DeviceTypeConfigService deviceTypeConfigService) {
this.deviceTypeConfigService = deviceTypeConfigService;
}
} }

@ -26,13 +26,9 @@ import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService; import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; 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.virtualfirealarm.plugin.config.VirtualFirealarmConfig;
import org.wso2.carbon.device.mgt.iot.devicetype.DeviceTypeConfigService; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.VirtualFirealarmSecurityManager;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.VirtualFirealarmStartupListener;
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.event.input.adapter.core.InputEventAdapterService; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterService;
/** /**
@ -57,12 +53,6 @@ import org.wso2.carbon.event.input.adapter.core.InputEventAdapterService;
* policy="dynamic" * policy="dynamic"
* bind="setEventsPublisherService" * bind="setEventsPublisherService"
* unbind="unsetEventsPublisherService" * 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 { public class VirtualFirealarmManagementServiceComponent {
@ -74,25 +64,10 @@ public class VirtualFirealarmManagementServiceComponent {
log.debug("Activating Virtual Firealarm Device Management Service Component"); log.debug("Activating Virtual Firealarm Device Management Service Component");
} }
try { try {
VirtualFirealarmConfig.initialize();
// VirtualFireAlarmManagerService virtualFireAlarmManagerService = new VirtualFireAlarmManagerService();
BundleContext bundleContext = ctx.getBundleContext(); BundleContext bundleContext = ctx.getBundleContext();
// firealarmServiceRegRef = bundleContext.registerService(DeviceManagementService.class.getName()
// ,virtualFireAlarmManagerService, null);
bundleContext.registerService(ServerStartupObserver.class.getName(), new VirtualFirealarmStartupListener(), bundleContext.registerService(ServerStartupObserver.class.getName(), new VirtualFirealarmStartupListener(),
null); 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()) { if (log.isDebugEnabled()) {
log.debug("Virtual Firealarm Device Management Service Component has been successfully activated"); log.debug("Virtual Firealarm Device Management Service Component has been successfully activated");
} }
@ -103,19 +78,9 @@ public class VirtualFirealarmManagementServiceComponent {
} }
protected void deactivate(ComponentContext ctx) { protected void deactivate(ComponentContext ctx) {
// if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
// log.debug("De-activating Virtual Firealarm Device Management Service Component"); 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) { protected void unsetEventsPublisherService(EventsPublisherService eventsPublisherService) {
VirtualFirealarmManagementDataHolder.getInstance().setEventsPublisherService(null); VirtualFirealarmManagementDataHolder.getInstance().setEventsPublisherService(null);
} }
protected void setDeviceTypeConfigService(DeviceTypeConfigService deviceTypeConfigService) {
VirtualFirealarmManagementDataHolder.getInstance().setDeviceTypeConfigService(deviceTypeConfigService);
}
protected void unsetDeviceTypeConfigService(DeviceTypeConfigService deviceTypeConfigService) {
VirtualFirealarmManagementDataHolder.getInstance().setDeviceTypeConfigService(null);
}
} }

@ -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.Log;
import org.apache.commons.logging.LogFactory; 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.config.DeviceManagementConfiguration;
import org.wso2.carbon.device.mgt.iot.devicetype.config.PushNotificationConfig; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.EventListenerConfiguration;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.VirtualFirealarmConfig;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
import java.util.List; import java.util.List;
@ -41,17 +40,16 @@ public class MqttConfig {
private String clearSession; private String clearSession;
private MqttConfig() { private MqttConfig() {
DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmManagementDataHolder.getInstance() DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmConfig.getInstance()
.getDeviceTypeConfigService().getConfiguration(VirtualFireAlarmConstants.DEVICE_TYPE, .getDeviceTypeConfiguration();
VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN); List<EventListenerConfiguration.Property> properties = deviceManagementConfiguration
List<PushNotificationConfig.Property> properties = deviceManagementConfiguration .getEventListenerConfiguration().getProperties();
.getPushNotificationConfig().getProperties(); String provider = deviceManagementConfiguration.getEventListenerConfiguration().getEventListenerProvider();
String provider = deviceManagementConfiguration.getPushNotificationConfig().getPushNotificationProvider();
if (provider.equals("MQTT")) { if (provider.equals("MQTT")) {
enabled = true; enabled = true;
} }
if (enabled) { if (enabled) {
for (PushNotificationConfig.Property property : properties) { for (EventListenerConfiguration.Property property : properties) {
switch (property.getName()) { switch (property.getName()) {
case "url": case "url":
url = property.getValue(); url = property.getValue();
@ -71,8 +69,6 @@ public class MqttConfig {
case "clearSession": case "clearSession":
clearSession = property.getValue(); clearSession = property.getValue();
break; break;
} }
} }
} }

@ -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.Log;
import org.apache.commons.logging.LogFactory; 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.config.DeviceManagementConfiguration;
import org.wso2.carbon.device.mgt.iot.devicetype.config.PushNotificationConfig; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.EventListenerConfiguration;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.VirtualFirealarmConfig;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
import java.util.List; import java.util.List;
public class XmppConfig { public class XmppConfig {
@ -39,17 +39,16 @@ public class XmppConfig {
private static final Log log = LogFactory.getLog(XmppConfig.class); private static final Log log = LogFactory.getLog(XmppConfig.class);
private XmppConfig() { private XmppConfig() {
DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmManagementDataHolder.getInstance() DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmConfig.getInstance()
.getDeviceTypeConfigService().getConfiguration(VirtualFireAlarmConstants.DEVICE_TYPE, .getDeviceTypeConfiguration();
VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN); List<EventListenerConfiguration.Property> properties = deviceManagementConfiguration.getEventListenerConfiguration()
List<PushNotificationConfig.Property> properties = deviceManagementConfiguration.getPushNotificationConfig()
.getProperties(); .getProperties();
String provider = deviceManagementConfiguration.getPushNotificationConfig().getPushNotificationProvider(); String provider = deviceManagementConfiguration.getEventListenerConfiguration().getEventListenerProvider();
if ("XMPP".equals(provider)) { if ("XMPP".equals(provider)) {
enabled = true; enabled = true;
} }
if (enabled) { if (enabled) {
for (PushNotificationConfig.Property property : properties) { for (EventListenerConfiguration.Property property : properties) {
switch (property.getName()) { switch (property.getName()) {
case "host": case "host":
host = property.getValue(); host = property.getValue();

@ -37,19 +37,11 @@
</description> </description>
<dependencies> <dependencies>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.plugin</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.api</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.androidsense.api</artifactId>
<type>war</type> <type>war</type>
</dependency> </dependency>
<dependency>
<groupId>com.h2database.wso2</groupId>
<artifactId>h2-database-engine</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -195,11 +187,6 @@
<propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef> <propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef>
</properties> </properties>
</adviceFile> </adviceFile>
<bundles>
<bundleDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.androidsense.plugin:${carbon.devicemgt.plugins.version}
</bundleDef>
</bundles>
<importFeatures> <importFeatures>
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}</importFeatureDef> <importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}</importFeatureDef>
<importFeatureDef>org.wso2.carbon.device.mgt.server:${carbon.devicemgt.version}</importFeatureDef> <importFeatureDef>org.wso2.carbon.device.mgt.server:${carbon.devicemgt.version}</importFeatureDef>

@ -18,7 +18,7 @@
~ under the License. ~ under the License.
--> -->
<DeviceManagementConfiguration> <DeviceManagementConfiguration>
<DeviceType>raspberrypi</DeviceType> <DeviceType>android_sense</DeviceType>
<ManagementRepository> <ManagementRepository>
<DeviceDefinition> <DeviceDefinition>
@ -41,7 +41,7 @@
<!--MQTT Config--> <!--MQTT Config-->
<PushNotificationProvider>MQTT</PushNotificationProvider> <PushNotificationProvider>MQTT</PushNotificationProvider>
<Properties> <Properties>
<Property Name="mqtt.adapter.name">raspberrypi.mqtt.adapter</Property> <Property Name="mqtt.adapter.name">android_sense.mqtt.adapter</Property>
<Property Name="url">tcp://localhost:1883</Property> <Property Name="url">tcp://localhost:1883</Property>
<Property Name="username">admin</Property> <Property Name="username">admin</Property>
<Property Name="dcrUrl">https://localhost:9443/dynamic-client-web/register</Property> <Property Name="dcrUrl">https://localhost:9443/dynamic-client-web/register</Property>
@ -49,16 +49,5 @@
<Property Name="scopes"/> <Property Name="scopes"/>
<Property Name="clearSession">true</Property> <Property Name="clearSession">true</Property>
</Properties> </Properties>
<!--XMPP Config-->
<!--PushNotificationProvider>XMPP</PushNotificationProvider>
<Properties>
<Property Name="xmpp.adapter.name">virtualfirealarm.xmpp.adapter</Property>
<Property Name="host">localhost</Property>
<Property Name="port">5222</Property>
<Property Name="username">admin</Property>
<Property Name="password">admin</Property>
<Property Name="jid">admin@localhost</Property>
<Property Name="server.name">localhost</Property>
</Properties-->
</PushNotificationConfiguration> </PushNotificationConfiguration>
</DeviceManagementConfiguration> </DeviceManagementConfiguration>

@ -9,7 +9,8 @@ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../depl
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/conf/android-sense-config.xml,target:${installFolder}/../../conf/etc/device-mgt-plugins/android-sense-config.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\
instructions.unconfigure = \ instructions.unconfigure = \
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/android_sense.war);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/android_sense.war);\
@ -24,4 +25,4 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/android_sense.car);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/android_sense.car);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/etc/device-mgt-plugins/android-sense-config.xml);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/android_sense.xml);\

@ -36,10 +36,6 @@
</description> </description>
<dependencies> <dependencies>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.arduino.plugin</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.arduino.api</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.arduino.api</artifactId>
@ -140,42 +136,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<!-- Creating Arduino Plugin Management schema -->
<id>create-arduino-plugin-mgt-schema</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="########### Create Arduino plugin Management H2 Schema ###########" />
<property name="db.dir" value="target/maven-shared-archive-resources/database" />
<property name="userid" value="wso2carbon" />
<property name="password" value="wso2carbon" />
<property name="dbURL" value="jdbc:h2:file:${basedir}/${db.dir}/ArduinoDM_DB;DB_CLOSE_ON_EXIT=FALSE" />
<mkdir dir="${basedir}/${db.dir}" />
<sql driver="org.h2.Driver" url="${dbURL}" userid="${userid}" password="${password}" autocommit="true" onerror="continue">
<classpath refid="maven.dependency.classpath" />
<classpath refid="maven.compile.classpath" />
<classpath refid="maven.runtime.classpath" />
<fileset file="${basedir}/src/main/resources/dbscripts/h2.sql" />
</sql>
<echo message="##################### END ####################" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.wso2.maven</groupId> <groupId>org.wso2.maven</groupId>
<artifactId>carbon-p2-plugin</artifactId> <artifactId>carbon-p2-plugin</artifactId>
@ -196,11 +156,6 @@
<propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef> <propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef>
</properties> </properties>
</adviceFile> </adviceFile>
<bundles>
<bundleDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.arduino.plugin:${carbon.devicemgt.plugins.version}
</bundleDef>
</bundles>
<importFeatures> <importFeatures>
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version} <importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}
</importFeatureDef> </importFeatureDef>

@ -18,7 +18,7 @@
~ under the License. ~ under the License.
--> -->
<DeviceManagementConfiguration> <DeviceManagementConfiguration>
<DeviceType>raspberrypi</DeviceType> <DeviceType>arduino</DeviceType>
<ManagementRepository> <ManagementRepository>
<DeviceDefinition> <DeviceDefinition>
@ -35,30 +35,4 @@
<SharedWithAllTenants>false</SharedWithAllTenants> <SharedWithAllTenants>false</SharedWithAllTenants>
</ProvisioningConfig> </ProvisioningConfig>
</ManagementRepository> </ManagementRepository>
<PushNotificationConfiguration>
<!--MQTT Config-->
<PushNotificationProvider>MQTT</PushNotificationProvider>
<Properties>
<Property Name="mqtt.adapter.name">raspberrypi.mqtt.adapter</Property>
<Property Name="url">tcp://localhost:1883</Property>
<Property Name="username">admin</Property>
<Property Name="dcrUrl">https://localhost:9443/dynamic-client-web/register</Property>
<Property Name="qos">0</Property>
<Property Name="scopes"/>
<Property Name="clearSession">true</Property>
</Properties>
<!--XMPP Config-->
<!--PushNotificationProvider>XMPP</PushNotificationProvider>
<Properties>
<Property Name="xmpp.adapter.name">virtualfirealarm.xmpp.adapter</Property>
<Property Name="host">localhost</Property>
<Property Name="port">5222</Property>
<Property Name="username">admin</Property>
<Property Name="password">admin</Property>
<Property Name="jid">admin@localhost</Property>
<Property Name="server.name">localhost</Property>
</Properties-->
</PushNotificationConfiguration>
</DeviceManagementConfiguration> </DeviceManagementConfiguration>

@ -4,27 +4,21 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/arduino/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/arduino/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/agent/,target:${installFolder}/../../resources/sketches/arduino/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/agent/,target:${installFolder}/../../resources/sketches/arduino/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/arduino,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/conf/arduino-config.xml,target:${installFolder}/../../conf/etc/device-mgt-plugins/arduino-config.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\
instructions.unconfigure = \ instructions.unconfigure = \
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/arduino.war);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/arduino.war);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/arduino);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/arduino);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/arduino);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../resources/sketches/arduino);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../resources/sketches/arduino);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/datasources/arduino-datasources.xml);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/ArduinoDM_DB.h2.db);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/arduino.car);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/arduino.car);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/etc/device-mgt-plugins/arduino-config.xml);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/arduino.xml);\

@ -28,7 +28,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.url.printer.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.2.5-SNAPSHOT</version> <version>2.2.5-SNAPSHOT</version>
<name>WSO2 Carbon - IoT Device Management Feature</name> <name>WSO2 Carbon - IoT Device Management Feature</name>
@ -38,20 +38,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.url.printer</artifactId>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
<artifactId>json</artifactId>
</dependency>
<!--Dependencies on XMPP Client Library-->
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
@ -122,7 +109,7 @@
<goal>p2-feature-gen</goal> <goal>p2-feature-gen</goal>
</goals> </goals>
<configuration> <configuration>
<id>org.wso2.carbon.device.mgt.iot</id> <id>org.wso2.carbon.device.mgt.iot.url.printer</id>
<propertiesFile>../../../features/etc/feature.properties</propertiesFile> <propertiesFile>../../../features/etc/feature.properties</propertiesFile>
<adviceFile> <adviceFile>
<properties> <properties>
@ -132,10 +119,7 @@
</adviceFile> </adviceFile>
<bundles> <bundles>
<bundleDef> <bundleDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot:${carbon.devicemgt.plugins.version} org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.url.printer:${carbon.devicemgt.plugins.version}
</bundleDef>
<bundleDef>
org.json.wso2:json:${commons-json.version}
</bundleDef> </bundleDef>
</bundles> </bundles>
<importFeatures> <importFeatures>

@ -1,5 +1,5 @@
instructions.configure = \ instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.url.printer_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/resources/email-templates);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/resources/email-templates);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.url.printer_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\

@ -34,7 +34,7 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<modules> <modules>
<module>org.wso2.carbon.device.mgt.iot.feature</module> <module>org.wso2.carbon.device.mgt.iot.url.printer.feature</module>
<module>org.wso2.carbon.device.mgt.iot.adapter.feature</module> <module>org.wso2.carbon.device.mgt.iot.adapter.feature</module>
</modules> </modules>

@ -36,10 +36,6 @@
</description> </description>
<dependencies> <dependencies>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.raspberrypi.plugin</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.raspberrypi.api</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.raspberrypi.api</artifactId>
@ -195,11 +191,6 @@
<propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef> <propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef>
</properties> </properties>
</adviceFile> </adviceFile>
<bundles>
<bundleDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.raspberrypi.plugin:${carbon.devicemgt.plugins.version}
</bundleDef>
</bundles>
<importFeatures> <importFeatures>
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version} <importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}
</importFeatureDef> </importFeatureDef>

@ -18,7 +18,7 @@
~ under the License. ~ under the License.
--> -->
<DeviceManagementConfiguration> <DeviceManagementConfiguration>
<DeviceType>virtual_firealarm</DeviceType> <DeviceType>raspberrypi</DeviceType>
<ManagementRepository> <ManagementRepository>
<DeviceDefinition> <DeviceDefinition>
@ -41,7 +41,7 @@
<!--MQTT Config--> <!--MQTT Config-->
<PushNotificationProvider>MQTT</PushNotificationProvider> <PushNotificationProvider>MQTT</PushNotificationProvider>
<Properties> <Properties>
<Property Name="mqtt.adapter.name">virtualfirealarm.mqtt.adapter</Property> <Property Name="mqtt.adapter.name">raspberrypi.mqtt.adapter</Property>
<Property Name="url">tcp://localhost:1883</Property> <Property Name="url">tcp://localhost:1883</Property>
<Property Name="username">admin</Property> <Property Name="username">admin</Property>
<Property Name="dcrUrl">https://localhost:9443/dynamic-client-web/register</Property> <Property Name="dcrUrl">https://localhost:9443/dynamic-client-web/register</Property>
@ -49,16 +49,5 @@
<Property Name="scopes"/> <Property Name="scopes"/>
<Property Name="clearSession">true</Property> <Property Name="clearSession">true</Property>
</Properties> </Properties>
<!--XMPP Config-->
<!--PushNotificationProvider>XMPP</PushNotificationProvider>
<Properties>
<Property Name="xmpp.adapter.name">virtualfirealarm.xmpp.adapter</Property>
<Property Name="host">localhost</Property>
<Property Name="port">5222</Property>
<Property Name="username">admin</Property>
<Property Name="password">admin</Property>
<Property Name="jid">admin@localhost</Property>
<Property Name="server.name">localhost</Property>
</Properties-->
</PushNotificationConfiguration> </PushNotificationConfiguration>
</DeviceManagementConfiguration> </DeviceManagementConfiguration>

@ -12,7 +12,9 @@ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../data
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/conf/raspberrypi-config.xml,target:${installFolder}/../../conf/etc/device-mgt-plugins/raspberrypi-config.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\
instructions.unconfigure = \ instructions.unconfigure = \
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/raspberrypi.war);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/raspberrypi.war);\
@ -27,4 +29,4 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/raspberrypi.car);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/raspberrypi.car);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/etc/device-mgt-plugins/raspberrypi-config.xml);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/raspberrypi.xml);\

@ -18,21 +18,9 @@
~ under the License. ~ under the License.
--> -->
<DeviceManagementConfiguration> <DeviceManagementConfiguration>
<DeviceType>virtual_firealarm</DeviceType> <EventListenerConfiguration>
<ManagementRepository>
<DataSourceConfiguration>
<JndiLookupDefinition>
<Name>jdbc/VirtualFireAlarmDM_DB</Name>
</JndiLookupDefinition>
</DataSourceConfiguration>
<ProvisioningConfig>
<TenantDomain>carbon.super</TenantDomain>
<SharedWithAllTenants>false</SharedWithAllTenants>
</ProvisioningConfig>
</ManagementRepository>
<PushNotificationConfiguration>
<!--MQTT Config--> <!--MQTT Config-->
<PushNotificationProvider>MQTT</PushNotificationProvider> <EventListenerProvider>MQTT</EventListenerProvider>
<Properties> <Properties>
<Property Name="mqtt.adapter.name">virtualfirealarm.mqtt.adapter</Property> <Property Name="mqtt.adapter.name">virtualfirealarm.mqtt.adapter</Property>
<Property Name="url">tcp://localhost:1883</Property> <Property Name="url">tcp://localhost:1883</Property>
@ -53,5 +41,5 @@
<Property Name="jid">admin@localhost</Property> <Property Name="jid">admin@localhost</Property>
<Property Name="server.name">localhost</Property> <Property Name="server.name">localhost</Property>
</Properties--> </Properties-->
</PushNotificationConfiguration> </EventListenerConfiguration>
</DeviceManagementConfiguration> </DeviceManagementConfiguration>

@ -21,27 +21,14 @@
<DeviceType>virtual_firealarm</DeviceType> <DeviceType>virtual_firealarm</DeviceType>
<ManagementRepository> <ManagementRepository>
<!--<DataSourceConfiguration>-->
<!--<JndiLookupDefinition>-->
<!--<Name>jdbc/DM_DS</Name>-->
<!--</JndiLookupDefinition>-->
<!--</DataSourceConfiguration>-->
<DeviceDefinition> <DeviceDefinition>
<!--<TableName></TableName>-->
<!--&lt;!&ndash;Primary Key should be the device identifier&ndash;&gt;-->
<!--<PrimaryKey></PrimaryKey>-->
<!--<Attributes>-->
<!--<Attribute>column1</Attribute>-->
<!--<Attribute>column2</Attribute>-->
<!--</Attributes>-->
<License> <License>
<Language>en_US</Language> <Language>en_US</Language>
<Version>1.0.0</Version> <Version>1.0.0</Version>
<Text>This is license text</Text> <Text>This is license text</Text>
</License> </License>
<!--if generate is set to true then the feature information will be picked up from the annotation in the api--> <!--if generate is set to true then the feature information will be picked up from the annotation in the api-->
<Features generate="true"></Features> <Features generate="true"/>
</DeviceDefinition> </DeviceDefinition>
<ProvisioningConfig> <ProvisioningConfig>
@ -53,10 +40,8 @@
<PushNotificationConfiguration> <PushNotificationConfiguration>
<!--MQTT Config--> <!--MQTT Config-->
<PushNotificationProvider>MQTT</PushNotificationProvider> <PushNotificationProvider>MQTT</PushNotificationProvider>
<FileBasedProperties>true</FileBasedProperties>
<!--if file based properties is set to false then the configuration will be picked from platform configuration-->
<Properties> <Properties>
<Property Name="mqtt.adapter.name">sample.mqtt.adapter.sample</Property> <Property Name="mqtt.adapter.name">virtualfirealarm.mqtt.adapter</Property>
<Property Name="url">tcp://localhost:1883</Property> <Property Name="url">tcp://localhost:1883</Property>
<Property Name="username">admin</Property> <Property Name="username">admin</Property>
<Property Name="dcrUrl">https://localhost:9443/dynamic-client-web/register</Property> <Property Name="dcrUrl">https://localhost:9443/dynamic-client-web/register</Property>
@ -64,5 +49,16 @@
<Property Name="scopes"/> <Property Name="scopes"/>
<Property Name="clearSession">true</Property> <Property Name="clearSession">true</Property>
</Properties> </Properties>
<!--XMPP Config-->
<!--PushNotificationProvider>XMPP</PushNotificationProvider>
<Properties>
<Property Name="xmpp.adapter.name">virtualfirealarm.xmpp.adapter</Property>
<Property Name="host">localhost</Property>
<Property Name="port">5222</Property>
<Property Name="username">admin</Property>
<Property Name="password">admin</Property>
<Property Name="jid">admin@localhost</Property>
<Property Name="server.name">localhost</Property>
</Properties-->
</PushNotificationConfiguration> </PushNotificationConfiguration>
</DeviceManagementConfiguration> </DeviceManagementConfiguration>

@ -15,10 +15,10 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/security/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/security/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/certs/,target:${installFolder}/../../resources/security/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/certs/,target:${installFolder}/../../resources/security/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/device-types/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/device-types/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/conf/virtual-fire-alarm-config.xml,target:${installFolder}/../../conf/etc/device-mgt-plugins/virtual-fire-alarm-config.xml,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/etc/device-mgt-plugins/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/conf/virtual_firealarm.xml,target:${installFolder}/../../conf/etc/device-mgt-plugins/virtual_firealarm.xml,overwrite:true);\
instructions.unconfigure = \ instructions.unconfigure = \
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/virtual_firealarm.war);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/virtual_firealarm.war);\
@ -39,5 +39,5 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-wizard);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-wizard);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../resources/security/wso2certs.jks);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../resources/security/wso2certs.jks);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/etc/device-mgt-plugins/virtual-fire-alarm-config.xml);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/virtual_firealarm.xml);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/virtual_firealarm.xml);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/etc/device-mgt-plugins/virtual_firealarm.xml);\

@ -367,7 +367,7 @@
<!--IoT Server specific dependencies--> <!--IoT Server specific dependencies-->
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.url.printer</artifactId>
<version>${carbon.devicemgt.plugins.version}</version> <version>${carbon.devicemgt.plugins.version}</version>
</dependency> </dependency>
<dependency> <dependency>
@ -413,11 +413,6 @@
</dependency> </dependency>
<!--Android sense DeviceType Impl, API and Agent--> <!--Android sense DeviceType Impl, API and Agent-->
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.plugin</artifactId>
<version>${carbon.devicemgt.plugins.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.api</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.androidsense.api</artifactId>
@ -426,11 +421,6 @@
</dependency> </dependency>
<!--Arduino DeviceType Impl, API and Agent--> <!--Arduino DeviceType Impl, API and Agent-->
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.arduino.plugin</artifactId>
<version>${carbon.devicemgt.plugins.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.arduino.api</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.arduino.api</artifactId>
@ -439,11 +429,6 @@
</dependency> </dependency>
<!--RaspberryPi DeviceType Impl, API and Agent--> <!--RaspberryPi DeviceType Impl, API and Agent-->
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.raspberrypi.plugin</artifactId>
<version>${carbon.devicemgt.plugins.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.raspberrypi.api</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.raspberrypi.api</artifactId>

Loading…
Cancel
Save