revived connected cup sample

application-manager-new
ayyoob 8 years ago
parent 9c12a2c4a0
commit 751eef086e

@ -1,61 +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.coffeeking.api;
import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType;
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
@API(name = "connectedcup", version = "1.0.0", context = "/connectedcup", tags = {"connectedcup"})
@DeviceType(value = "connectedcup")
public interface ConnectedCupService {
@Path("device/ordercoffee")
@POST
@Feature(code = "ordercoffee", name = "Order Coffee", description = "Order coffee cup")
//@Permission(scope = "connectedcup_user", permissions = {"/permission/admin/device-mgt/user/operations"})
Response orderCoffee(@QueryParam("deviceId") String deviceId);
/**
* Retrieve Sensor data for the device type
*/
@Path("stats/{deviceId}/sensors/{sensorName}")
@GET
@Consumes("application/json")
@Produces("application/json")
//@Permission(scope = "connectedcup_user", permissions = {"/permission/admin/device-mgt/user/stats"})
Response getDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensor,
@QueryParam("from") long from, @QueryParam("to") long to);
@Path("device/register")
@POST
//@Permission(scope = "connectedcup_user", permissions = {"/permission/admin/device-mgt/user/devices"})
boolean register(@QueryParam("name") String name);
}

@ -113,6 +113,7 @@
<descriptors>
<descriptor>${basedir}/src/assembly/dist.xml</descriptor>
</descriptors>
<escapeString>\</escapeString>
</configuration>
</execution>
</executions>

@ -60,6 +60,33 @@
<include>*/**</include>
</includes>
<fileMode>644</fileMode>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>src/resources/samples</directory>
<outputDirectory>wso2iot-${product.iot.version}/samples</outputDirectory>
<includes>
<include>*/**</include>
</includes>
<fileMode>644</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>
src/resources/samples/samples-deployer.xml
</source>
<outputDirectory>wso2iot-${product.iot.version}/samples/</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<file>
<source>
src/resources/samples/connectedcup/pom.xml
</source>
<outputDirectory>wso2iot-${product.iot.version}/samples/connectedcup</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
</files>
</assembly>

@ -46,28 +46,28 @@
<goal>p2-repo-gen</goal>
</goals>
<configuration>
<metadataRepository>file:${basedir}/p2-repo</metadataRepository>
<artifactRepository>file:${basedir}/p2-repo</artifactRepository>
<metadataRepository>file:\${basedir}/p2-repo</metadataRepository>
<artifactRepository>file:\${basedir}/p2-repo</artifactRepository>
<publishArtifacts>true</publishArtifacts>
<publishArtifactRepository>true</publishArtifactRepository>
<featureArtifacts>
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.androidsense.feature:${carbon.device.mgt.plugin.version}
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.androidsense.feature:/${carbon.device.mgt.plugin.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.arduino.feature:${carbon.device.mgt.plugin.version}
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.arduino.feature:/${carbon.device.mgt.plugin.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.raspberrypi.feature:${carbon.device.mgt.plugin.version}
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.raspberrypi.feature:/${carbon.device.mgt.plugin.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature:${carbon.device.mgt.plugin.version}
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature:/${carbon.device.mgt.plugin.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android.feature:${carbon.device.mgt.plugin.version}
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android.feature:/${carbon.device.mgt.plugin.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.windows.feature:${carbon.device.mgt.plugin.version}
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.windows.feature:/${carbon.device.mgt.plugin.version}
</featureArtifactDef>
</featureArtifacts>
</configuration>
@ -80,22 +80,22 @@
</goals>
<configuration>
<profile>default</profile>
<metadataRepository>file:${basedir}/p2-repo</metadataRepository>
<artifactRepository>file:${basedir}/p2-repo</artifactRepository>
<destination>${basedir}/../core/repository/components</destination>
<metadataRepository>file:\${basedir}/p2-repo</metadataRepository>
<artifactRepository>file:\${basedir}/p2-repo</artifactRepository>
<destination>\${basedir}/../core/repository/components</destination>
<deleteOldProfileFiles>false</deleteOldProfileFiles>
<features>
<feature>
<id>org.wso2.carbon.device.mgt.iot.androidsense.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
<version>\${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.iot.arduino.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
<version>\${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.iot.raspberrypi.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
<version>\${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature.group</id>
@ -103,11 +103,11 @@
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.android.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
<version>\${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.windows.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
<version>\${carbon.device.mgt.plugin.version}</version>
</feature>
</features>
</configuration>
@ -225,6 +225,6 @@
</repository>
</repositories>
<properties>
<carbon.device.mgt.plugin.version>3.0.5</carbon.device.mgt.plugin.version>
<carbon.device.mgt.plugin.version>${carbon.device.mgt.plugin.version}</carbon.device.mgt.plugin.version>
</properties>
</project>

@ -21,13 +21,13 @@
<parent>
<artifactId>device-mgt-iot-connectedcup</artifactId>
<groupId>org.coffeeking</groupId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.coffeeking.connectedcup.agent</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<name>WSO2 IoTS(Device Types) - Connected Cup Agent Web app</name>
<url>http://maven.apache.org</url>

@ -25,13 +25,13 @@
<parent>
<groupId>org.coffeeking</groupId>
<artifactId>device-mgt-iot-connectedcup</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.coffeeking.connectedcup.analytics</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<name>WSO2 IoTS(Device Types) - Connected Cup Analytics capp</name>
<packaging>pom</packaging>

@ -21,11 +21,9 @@
<from eventAdapterType="oauth-mqtt">
<property name="topic">carbon.super/connectedcup/#</property>
<property name="username">admin</property>
<property name="contentValidatorParams">device_id_json_path:event.metaData.deviceId,device_id_topic_hierarchy_index:2</property>
<property name="contentValidator">org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTContentValidator</property>
<property name="password">admin</property>
<property name="contentValidator">org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTContentValidator</property>
<property name="contentTransformer">default</property>
<property name="dcrUrl">https://localhost:${carbon.https.port}/dynamic-client-web/register</property>
<property name="url">tcp://${mqtt.broker.host}:${mqtt.broker.port}</property>
<property name="cleanSession">true</property>
</from>
<mapping customMapping="disable" type="json"/>

@ -0,0 +1,127 @@
/*
* 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.coffeeking.api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@SwaggerDefinition(
info = @Info(
version = "1.0.0",
title = "",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = "name", value = "connectedcup"),
@ExtensionProperty(name = "context", value = "/connectedcup"),
})
}
),
tags = {
@Tag(name = "connectedcup", description = "")
}
)
@Scopes(
scopes = {
@Scope(
name = "Enroll device",
description = "",
key = "perm:connectedcup:enroll",
permissions = {"/device-mgt/devices/enroll/connectedcup"}
)
}
)
public interface ConnectedCupService {
String SCOPE = "scope";
@Path("device/ordercoffee")
@POST
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Order Coffee",
notes = "",
response = Response.class,
tags = "connectedcup",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:connectedcup:enroll")
})
}
)
Response orderCoffee(@QueryParam("deviceId") String deviceId);
/**
* Retrieve Sensor data for the device type
*/
@Path("stats/{deviceId}/sensors/{sensorName}")
@GET
@Consumes("application/json")
@Produces("application/json")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Retrieve Sensor data for the device type",
notes = "",
response = Response.class,
tags = "connectedcup",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:connectedcup:enroll")
})
}
)
Response getDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensor,
@QueryParam("from") long from, @QueryParam("to") long to);
@Path("device/register")
@POST
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Enroll Cup",
notes = "",
response = Response.class,
tags = "connectedcup",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:connectedcup:enroll")
})
}
)
boolean register(@QueryParam("name") String name);
}

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>device-mgt-iot-connectedcup</artifactId>
<groupId>org.coffeeking</groupId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.coffeeking.connectedcup.plugin</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>
<name>WSO2 IoTS(Device Types) - Connected Cup CDMF Plugin</name>
<description>WSO2 IoTS(Device Types) - Connected Cup CDMF Plugin</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.device.mgt.plugin.version}</Bundle-Version>
<Bundle-Description>IoT Server Impl Bundle</Bundle-Description>
<Private-Package>org.coffeeking.connectedcup.plugin.internal</Private-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.apache.commons.logging,
javax.xml.bind.*;resolution:=optional,
javax.naming;resolution:=optional,
javax.sql;resolution:=optional,
javax.xml.bind.annotation.*;resolution:=optional,
javax.net;resolution:=optional,
javax.net.ssl;resolution:=optional,
org.w3c.dom;resolution:=optional,
org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.device.mgt.common,
org.wso2.carbon.context.*,
org.wso2.carbon.ndatasource.core,
javax.xml.parsers.*;resolution:=optional
</Import-Package>
<Export-Package>
!org.coffeeking.connectedcup.plugin.internal,
org.coffeeking.connectedcup.plugin.*
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,42 @@
/*
* 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.coffeeking.connectedcup.plugin.exception;
public class ConnectedCupDeviceMgtPluginException extends Exception {
public ConnectedCupDeviceMgtPluginException(String msg, Exception nestedEx) {
super(msg, nestedEx);
}
public ConnectedCupDeviceMgtPluginException(String message, Throwable cause) {
super(message, cause);
}
public ConnectedCupDeviceMgtPluginException(String msg) {
super(msg);
}
public ConnectedCupDeviceMgtPluginException() {
super();
}
public ConnectedCupDeviceMgtPluginException(Throwable cause) {
super(cause);
}
}

@ -0,0 +1,100 @@
/*
* 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.coffeeking.connectedcup.plugin.impl;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.FeatureManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* This hold the feature manager implementation for Connected CUp.
*/
public class ConnectedCupFeatureManager implements FeatureManager{
private static Feature feature = new Feature();
private static final String METHOD = "method";
private static final String URI = "uri";
private static final String CONTENT_TYPE = "contentType";
private static final String PATH_PARAMS = "pathParams";
private static final String QUERY_PARAMS = "queryParams";
private static final String FORM_PARAMS = "formParams";
public ConnectedCupFeatureManager() {
feature.setCode("ordercoffee");
feature.setName("Order Coffee");
feature.setDescription("Order coffee cup");
Map<String, Object> apiParams = new HashMap<>();
apiParams.put(METHOD, "POST");
apiParams.put(URI, "/connectedcup/device/ordercoffee");
List<String> pathParams = new ArrayList<>();
List<String> queryParams = new ArrayList<>();
List<String> formParams = new ArrayList<>();
apiParams.put(PATH_PARAMS, pathParams);
queryParams.add("deviceId");
apiParams.put(QUERY_PARAMS, queryParams);
apiParams.put(FORM_PARAMS, formParams);
List<Feature.MetadataEntry> metadataEntries = new ArrayList<>();
Feature.MetadataEntry metadataEntry = new Feature.MetadataEntry();
metadataEntry.setId(-1);
metadataEntry.setValue(apiParams);
metadataEntries.add(metadataEntry);
feature.setMetadataEntries(metadataEntries);
}
@Override
public boolean addFeature(Feature feature) throws DeviceManagementException {
return false;
}
@Override
public boolean addFeatures(List<Feature> list) throws DeviceManagementException {
return false;
}
@Override
public Feature getFeature(String code) throws DeviceManagementException {
if (code.equals(feature.getCode())) {
return feature;
}
return null;
}
@Override
public List<Feature> getFeatures() throws DeviceManagementException {
List<Feature> features = new ArrayList<>();
features.add(feature);
return features;
}
@Override
public boolean removeFeature(String s) throws DeviceManagementException {
return false;
}
@Override
public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
return false;
}
}

@ -0,0 +1,255 @@
/*
* 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.coffeeking.connectedcup.plugin.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.coffeeking.connectedcup.plugin.exception.ConnectedCupDeviceMgtPluginException;
import org.coffeeking.connectedcup.plugin.impl.dao.ConnectedCupDAOUtil;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import java.util.List;
/**
* Device Manager interface impl for connected cup.
*/
public class ConnectedCupManager implements DeviceManager {
private static final Log log = LogFactory.getLog(ConnectedCupManager.class);
private static final ConnectedCupDAOUtil CONNECTED_CUP_DAO_UTIL = new ConnectedCupDAOUtil();
@Override
public FeatureManager getFeatureManager() {
return null;
}
@Override
public boolean saveConfiguration(PlatformConfiguration platformConfiguration) throws DeviceManagementException {
return false;
}
@Override
public PlatformConfiguration getConfiguration() throws DeviceManagementException {
return null;
}
@Override
public boolean enrollDevice(Device device) throws DeviceManagementException {
boolean status;
try {
if (log.isDebugEnabled()) {
log.debug("Enrolling a new Connected Cup device : " + device.getDeviceIdentifier());
}
ConnectedCupDAOUtil.beginTransaction();
status = CONNECTED_CUP_DAO_UTIL.getConnectedCupDeviceDAO().addDevice(device);
ConnectedCupDAOUtil.commitTransaction();
} catch (ConnectedCupDeviceMgtPluginException e) {
try {
ConnectedCupDAOUtil.rollbackTransaction();
} catch (ConnectedCupDeviceMgtPluginException iotDAOEx) {
String msg = "Error occurred while roll back the device enrol transaction :" + device.toString();
log.warn(msg, iotDAOEx);
}
String msg = "Error while enrolling the Connected Cup device : " + device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
boolean status;
try {
if (log.isDebugEnabled()) {
log.debug("Modifying the Connected Cup device enrollment data");
}
ConnectedCupDAOUtil.beginTransaction();
status = CONNECTED_CUP_DAO_UTIL.getConnectedCupDeviceDAO().updateDevice(device);
ConnectedCupDAOUtil.commitTransaction();
} catch (ConnectedCupDeviceMgtPluginException e) {
try {
ConnectedCupDAOUtil.rollbackTransaction();
} catch (ConnectedCupDeviceMgtPluginException iotDAOEx) {
String msg = "Error occurred while roll back the update device transaction :" + device.toString();
log.warn(msg, iotDAOEx);
}
String msg = "Error while updating the enrollment of the Connected Cup device : " +
device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
boolean status;
try {
if (log.isDebugEnabled()) {
log.debug("Dis-enrolling Connected Cup device : " + deviceId);
}
ConnectedCupDAOUtil.beginTransaction();
status = CONNECTED_CUP_DAO_UTIL.getConnectedCupDeviceDAO().deleteDevice(deviceId.getId());
ConnectedCupDAOUtil.commitTransaction();
} catch (ConnectedCupDeviceMgtPluginException e) {
try {
ConnectedCupDAOUtil.rollbackTransaction();
} catch (ConnectedCupDeviceMgtPluginException iotDAOEx) {
String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString();
log.warn(msg, iotDAOEx);
}
String msg = "Error while removing the Connected Cup device : " + deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
boolean isEnrolled = false;
try {
if (log.isDebugEnabled()) {
log.debug("Checking the enrollment of Connected Cup device : " + deviceId.getId());
}
Device iotDevice = CONNECTED_CUP_DAO_UTIL.getConnectedCupDeviceDAO().getDevice(deviceId.getId());
if (iotDevice != null) {
isEnrolled = true;
}
} catch (ConnectedCupDeviceMgtPluginException e) {
String msg = "Error while checking the enrollment status of Connected Cup device : " +
deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return isEnrolled;
}
@Override
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
}
@Override
public boolean setActive(DeviceIdentifier deviceId, boolean status)
throws DeviceManagementException {
return true;
}
@Override
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
Device device;
try {if (log.isDebugEnabled()) {
log.debug("Getting the details of Connected Cup device : " + deviceId.getId());
}
device = CONNECTED_CUP_DAO_UTIL.getConnectedCupDeviceDAO().getDevice(deviceId.getId());
} catch (ConnectedCupDeviceMgtPluginException e) {
String msg = "Error while fetching the Connected Cup device : " + deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return device;
}
@Override
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
throws DeviceManagementException {
return true;
}
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
return false;
}
@Override
public boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
EnrolmentInfo.Status status) throws DeviceManagementException {
return false;
}
@Override
public License getLicense(String s) throws LicenseManagementException {
return null;
}
@Override
public void addLicense(License license) throws LicenseManagementException {
}
@Override
public boolean requireDeviceAuthorization() {
return false;
}
@Override
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
boolean status;
try {
if (log.isDebugEnabled()) {
log.debug(
"updating the details of Connected Cup device : " + deviceIdentifier);
}
ConnectedCupDAOUtil.beginTransaction();
status = CONNECTED_CUP_DAO_UTIL.getConnectedCupDeviceDAO().updateDevice(device);
ConnectedCupDAOUtil.commitTransaction();
} catch (ConnectedCupDeviceMgtPluginException e) {
try {
ConnectedCupDAOUtil.rollbackTransaction();
} catch (ConnectedCupDeviceMgtPluginException iotDAOEx) {
String msg = "Error occurred while roll back the update device info transaction :" + device.toString();
log.warn(msg, iotDAOEx);
}
String msg =
"Error while updating the Connected Cup device : " + deviceIdentifier;
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public List<Device> getAllDevices() throws DeviceManagementException {
List<Device> devices = null;
try {
if (log.isDebugEnabled()) {
log.debug("Fetching the details of all Connected Cup devices");
}
devices = CONNECTED_CUP_DAO_UTIL.getConnectedCupDeviceDAO().getAllDevices();
} catch (ConnectedCupDeviceMgtPluginException e) {
String msg = "Error while fetching all Connected Cup devices.";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return devices;
}
}

@ -0,0 +1,81 @@
/*
* 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.coffeeking.connectedcup.plugin.impl;
import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import java.util.List;
public class ConnectedCupManagerService implements DeviceManagementService{
private DeviceManager deviceManager;
@Override
public String getType() {
return ConnectedCupConstants.DEVICE_TYPE;
}
@Override
public OperationMonitoringTaskConfig getOperationMonitoringConfig() {
return null;
}
@Override
public void init() throws DeviceManagementException {
this.deviceManager=new ConnectedCupManager();
}
@Override
public DeviceManager getDeviceManager() {
return deviceManager;
}
@Override
public ApplicationManager getApplicationManager() {
return null;
}
@Override
public ProvisioningConfig getProvisioningConfig() {
return new ProvisioningConfig(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, false);
}
@Override
public PushNotificationConfig getPushNotificationConfig() {
return null;
}
@Override
public PolicyMonitoringManager getPolicyMonitoringManager() {
return null;
}
}

@ -0,0 +1,204 @@
/*
* 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.coffeeking.connectedcup.plugin.impl.dao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
import org.coffeeking.connectedcup.plugin.exception.ConnectedCupDeviceMgtPluginException;
import org.coffeeking.connectedcup.plugin.impl.dao.util.ConnectedCupUtils;
import org.wso2.carbon.device.mgt.common.Device;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* Device Dao for connected cup Devices.
*/
public class ConnectedCupDAO {
private static final Log log = LogFactory.getLog(ConnectedCupDAO.class);
public Device getDevice(String deviceId) throws ConnectedCupDeviceMgtPluginException {
Connection conn = null;
PreparedStatement stmt = null;
Device connectedCupDevice = null;
ResultSet resultSet = null;
try {
conn = ConnectedCupDAOUtil.getConnection();
String selectDBQuery =
"SELECT CONNECTED_CUP_DEVICE_ID, DEVICE_NAME FROM CONNECTED_CUP_DEVICE WHERE CONNECTED_CUP_DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId);
resultSet = stmt.executeQuery();
if (resultSet.next()) {
connectedCupDevice = new Device();
connectedCupDevice.setName(resultSet.getString(ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_NAME));
if (log.isDebugEnabled()) {
log.debug("Connected Cup service " + deviceId + " data has been fetched from" +
"Connected Cup database.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while fetching Connected Cup device : '" + deviceId + "'";
log.error(msg, e);
throw new ConnectedCupDeviceMgtPluginException(msg, e);
} finally {
ConnectedCupUtils.cleanupResources(stmt, resultSet);
ConnectedCupDAOUtil.closeConnection();
}
return connectedCupDevice;
}
public boolean addDevice(Device connectedCupDevice) throws ConnectedCupDeviceMgtPluginException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = ConnectedCupDAOUtil.getConnection();
String createDBQuery =
"INSERT INTO CONNECTED_CUP_DEVICE(CONNECTED_CUP_DEVICE_ID, DEVICE_NAME ) VALUES (?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, connectedCupDevice.getDeviceIdentifier());
stmt.setString(2, connectedCupDevice.getName());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
if (log.isDebugEnabled()) {
log.debug("Connected Cup device " + connectedCupDevice.getDeviceIdentifier() +
" data has been added to the Connected Cup database.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while adding the Connected Cup device '" +
connectedCupDevice.getDeviceIdentifier() + "' to the Connected Cup db.";
log.error(msg, e);
throw new ConnectedCupDeviceMgtPluginException(msg, e);
} finally {
ConnectedCupUtils.cleanupResources(stmt, null);
}
return status;
}
public boolean updateDevice(Device connectedCupDevice) throws ConnectedCupDeviceMgtPluginException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = ConnectedCupDAOUtil.getConnection();
String updateDBQuery =
"UPDATE CONNECTED_CUP_DEVICE SET DEVICE_NAME = ? WHERE CONNECTED_CUP_DEVICE_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, connectedCupDevice.getName());
stmt.setString(2, connectedCupDevice.getDeviceIdentifier());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
if (log.isDebugEnabled()) {
log.debug("Connected Cup device " + connectedCupDevice.getDeviceIdentifier() +
" data has been modified.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while modifying the Connected Cup device '" +
connectedCupDevice.getDeviceIdentifier() + "' data.";
log.error(msg, e);
throw new ConnectedCupDeviceMgtPluginException(msg, e);
} finally {
ConnectedCupUtils.cleanupResources(stmt, null);
}
return status;
}
public boolean deleteDevice(String deviceId) throws ConnectedCupDeviceMgtPluginException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = ConnectedCupDAOUtil.getConnection();
String deleteDBQuery =
"DELETE FROM CONNECTED_CUP_DEVICE WHERE CONNECTED_CUP_DEVICE_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, deviceId);
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
if (log.isDebugEnabled()) {
log.debug("Connected Cup device " + deviceId + " data has deleted" +
" from the Connected Cup database.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while deleting Connected Cup device " + deviceId;
log.error(msg, e);
throw new ConnectedCupDeviceMgtPluginException(msg, e);
} finally {
ConnectedCupUtils.cleanupResources(stmt, null);
}
return status;
}
public List<Device> getAllDevices() throws ConnectedCupDeviceMgtPluginException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet resultSet = null;
Device connectedCupDevice;
List<Device> iotDevices = new ArrayList<>();
try {
conn = ConnectedCupDAOUtil.getConnection();
String selectDBQuery =
"SELECT CONNECTED_CUP_DEVICE_ID, DEVICE_NAME" +
"FROM CONNECTED_CUP_DEVICE";
stmt = conn.prepareStatement(selectDBQuery);
resultSet = stmt.executeQuery();
while (resultSet.next()) {
connectedCupDevice = new Device();
connectedCupDevice.setDeviceIdentifier(resultSet.getString(
ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_ID));
connectedCupDevice.setName(resultSet.getString(
ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_NAME));
}
if (log.isDebugEnabled()) {
log.debug("All Connected Cup device details have fetched from Connected Cup database" +
".");
}
return iotDevices;
} catch (SQLException e) {
String msg = "Error occurred while fetching all Connected Cup device data'";
log.error(msg, e);
throw new ConnectedCupDeviceMgtPluginException(msg, e);
} finally {
ConnectedCupUtils.cleanupResources(stmt, resultSet);
ConnectedCupDAOUtil.closeConnection();
}
}
}

@ -0,0 +1,132 @@
/*
* 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.coffeeking.connectedcup.plugin.impl.dao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
import org.coffeeking.connectedcup.plugin.exception.ConnectedCupDeviceMgtPluginException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
public class ConnectedCupDAOUtil {
private static final Log log = LogFactory.getLog(ConnectedCupDAOUtil.class);
static DataSource dataSource;
private static ThreadLocal<Connection> currentConnection = new ThreadLocal<Connection>();
public ConnectedCupDAOUtil() {
initConnectedCupDAO();
}
public static void initConnectedCupDAO() {
try {
Context ctx = new InitialContext();
dataSource = (DataSource) ctx.lookup(ConnectedCupConstants.DATA_SOURCE_NAME);
} catch (NamingException e) {
log.error("Error while looking up the data source: " +
ConnectedCupConstants.DATA_SOURCE_NAME);
}
}
public ConnectedCupDAO getConnectedCupDeviceDAO() {
return new ConnectedCupDAO();
}
public static void beginTransaction() throws ConnectedCupDeviceMgtPluginException {
try {
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
currentConnection.set(conn);
} catch (SQLException e) {
throw new ConnectedCupDeviceMgtPluginException(
"Error occurred while retrieving datasource connection", e);
}
}
public static Connection getConnection() throws ConnectedCupDeviceMgtPluginException {
if (currentConnection.get() == null) {
try {
currentConnection.set(dataSource.getConnection());
} catch (SQLException e) {
throw new ConnectedCupDeviceMgtPluginException(
"Error occurred while retrieving data source connection", e);
}
}
return currentConnection.get();
}
public static void commitTransaction() throws ConnectedCupDeviceMgtPluginException {
try {
Connection conn = currentConnection.get();
if (conn != null) {
conn.commit();
} else {
if (log.isDebugEnabled()) {
log.debug("Datasource connection associated with the current thread is null, " +
"hence commit has not been attempted");
}
}
} catch (SQLException e) {
throw new ConnectedCupDeviceMgtPluginException(
"Error occurred while committing the transaction", e);
} finally {
closeConnection();
}
}
public static void closeConnection() throws ConnectedCupDeviceMgtPluginException {
Connection con = currentConnection.get();
if (con != null) {
try {
con.close();
} catch (SQLException e) {
log.error("Error occurred while close the connection");
}
}
currentConnection.remove();
}
public static void rollbackTransaction() throws ConnectedCupDeviceMgtPluginException {
try {
Connection conn = currentConnection.get();
if (conn != null) {
conn.rollback();
} else {
if (log.isDebugEnabled()) {
log.debug(
"Datasource connection associated with the current thread is null, " +
"hence rollback has not been attempted");
}
}
} catch (SQLException e) {
throw new ConnectedCupDeviceMgtPluginException("Error occurred while rollback the transaction", e);
} finally {
closeConnection();
}
}
}

@ -0,0 +1,88 @@
/*
* 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.coffeeking.connectedcup.plugin.impl.dao.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
/**
* Contains utility methods used by FireAlarm plugin.
*/
public class ConnectedCupUtils {
private static Log log = LogFactory.getLog(ConnectedCupUtils.class);
public static String getDeviceProperty(List<Device.Property> deviceProperties, String propertyKey) {
String deviceProperty = "";
for (Device.Property property : deviceProperties) {
if (propertyKey.equals(property.getName())) {
deviceProperty = property.getValue();
}
}
return deviceProperty;
}
public static Device.Property getProperty(String property, String value) {
if (property != null) {
Device.Property prop = new Device.Property();
prop.setName(property);
prop.setValue(value);
return prop;
}
return null;
}
public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
log.warn("Error occurred while closing result set", e);
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
log.warn("Error occurred while closing prepared statement", e);
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
log.warn("Error occurred while closing database connection", e);
}
}
}
public static void cleanupResources(PreparedStatement stmt, ResultSet rs) {
cleanupResources(null, stmt, rs);
}
}

@ -0,0 +1,74 @@
/*
* 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.coffeeking.connectedcup.plugin.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.coffeeking.connectedcup.plugin.impl.ConnectedCupManagerService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
/**
* @scr.component name="org.coffeeking.connectedcup.plugin.internal
* .ConnectedCupServiceComponent"
* immediate="true"
*/
public class ConnectedCupServiceComponent {
private static final Log log = LogFactory.getLog(ConnectedCupServiceComponent.class);
private ServiceRegistration connectedCupServiceRegRef;
protected void activate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("Activating Connected Cup Service Component");
}
try {
BundleContext bundleContext = ctx.getBundleContext();
connectedCupServiceRegRef =
bundleContext.registerService(DeviceManagementService.class.getName(),
new ConnectedCupManagerService(), null);
if (log.isDebugEnabled()) {
log.debug("Connected Cup Service Component has been successfully activated");
}
} catch (Throwable e) {
log.error("Error occurred while activating Connected Cup Service Component", e);
}
}
protected void deactivate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("De-activating Connected Cup Service Component");
}
try {
if (connectedCupServiceRegRef != null) {
connectedCupServiceRegRef.unregister();
}
if (log.isDebugEnabled()) {
log.debug("Connected Cup Service Component has been successfully de-activated");
}
} catch (Throwable e) {
log.error("Error occurred while de-activating Connected Cup Service Component", e);
}
}
}

@ -24,13 +24,13 @@
<parent>
<groupId>org.coffeeking</groupId>
<artifactId>device.mgt.iot.connectedcup-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>device-mgt-iot-connectedcup</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>WSO2 IoTS(Device Types) - Connected Cup Component</name>
<description>WSO2 IoTS(Device Types) - Connected Cup Component</description>
@ -38,6 +38,7 @@
<modules>
<module>analytics</module>
<module>plugin</module>
<module>api</module>
<module>agent</module>
<module>ui</module>

@ -25,13 +25,13 @@
<parent>
<groupId>org.coffeeking</groupId>
<artifactId>device-mgt-iot-connectedcup</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.coffeeking.connectedcup.ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<name>WSO2 IoTS(Device Types) - Connected Cup UI</name>
<packaging>pom</packaging>

@ -25,19 +25,24 @@
<parent>
<groupId>org.coffeeking</groupId>
<artifactId>connected-cup-feature-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.coffeeking.connectedcup.feature</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<name>WSO2 IoTS(Device Types) - Connected Cup Feature</name>
<description>WSO2 IoTS(Device Types) - Connected Cup Feature</description>
<url>http://wso2.org</url>
<dependencies>
<dependency>
<groupId>org.coffeeking</groupId>
<artifactId>org.coffeeking.connectedcup.plugin</artifactId>
<version>${wso2.iot.version}</version>
</dependency>
<dependency>
<groupId>org.coffeeking</groupId>
<artifactId>org.coffeeking.connectedcup.api</artifactId>
@ -50,6 +55,11 @@
<version>${wso2.iot.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.h2database.wso2</groupId>
<artifactId>h2-database-engine</artifactId>
<version>1.2.140.wso2v3</version>
</dependency>
</dependencies>
<build>
@ -148,6 +158,46 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<!-- Creating Connected Cup Plugin Management schema -->
<id>create-connected-cup-plugin-mgt-schema</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo
message="########### Create Connected Cup 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}/ConnectedCupDM_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>
<groupId>org.wso2.maven</groupId>
<artifactId>carbon-p2-plugin</artifactId>
@ -167,6 +217,11 @@
<propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef>
</properties>
</adviceFile>
<bundles>
<bundleDef>
org.coffeeking:org.coffeeking.connectedcup.plugin:${wso2.iot.version}
</bundleDef>
</bundles>
<importFeatures>
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}
</importFeatureDef>

@ -0,0 +1,46 @@
<!--
~ 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.
-->
<datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration">
<providers>
<provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider>
</providers>
<datasources>
<datasource>
<name>ConnectedCupDM_DB</name>
<description>The datasource used for the Connected Cup database</description>
<jndiConfig>
<name>jdbc/ConnectedCupDM_DB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:repository/database/ConnectedCupDM_DB;DB_CLOSE_ON_EXIT=FALSE
</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
</datasources>
</datasources-configuration>

@ -0,0 +1,11 @@
-- -----------------------------------------------------
-- Table `CONNECTED_CUP_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `CONNECTED_CUP_DEVICE` (
`CONNECTED_CUP_DEVICE_ID` VARCHAR(45) NOT NULL ,
`DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL,
PRIMARY KEY (`CONNECTED_CUP_DEVICE_ID`) );

@ -0,0 +1,12 @@
-- -----------------------------------------------------
-- Table `CONNECTED_CUP_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `CONNECTED_CUP_DEVICE` (
`CONNECTED_CUP_DEVICE_ID` VARCHAR(45) NOT NULL ,
`DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL,
PRIMARY KEY (`CONNECTED_CUP_DEVICE_ID`) )
ENGINE = InnoDB;

@ -1,18 +1,26 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.coffeeking.connectedcup_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.coffeeking.connectedcup_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.coffeeking.connectedcup_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.coffeeking.connectedcup_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/connectedcup,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.coffeeking.connectedcup_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.coffeeking.connectedcup_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,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.connectedcup_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.coffeeking.connectedcup_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\
instructions.unconfigure = \
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/device-types/connectedcup.xml);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/connectedcup.war);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/connected-cup-agent.war);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/connectedcup);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/connected-cup-agent);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/connectedcup);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/datasources/connectedcup-datasources.xml);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/ConnectedCupDM_DB.h2.db);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view);\

@ -23,14 +23,14 @@
<parent>
<groupId>org.coffeeking</groupId>
<artifactId>device.mgt.iot.connectedcup-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connected-cup-feature-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<name>WSO2 IoTS(Device Types) - Connected Cup Feature Parent</name>
<description>WSO2 IoTS(Device Types) - Connected Cup Feature Parent</description>
<url>http://wso2.org</url>

@ -31,7 +31,7 @@
<groupId>org.coffeeking</groupId>
<artifactId>device.mgt.iot.connectedcup-parent</artifactId>
<version>${project.version}</version>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>WSO2 IoTS(Device Types) - Connected Cup Component</name>
<description>WSO2 IoTS(Device Types) - Connected Cup Component</description>
@ -135,6 +135,12 @@
<version>4.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.coffeeking</groupId>
<artifactId>org.coffeeking.connectedcup.plugin</artifactId>
<version>${wso2.iot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
@ -145,11 +151,6 @@
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
<version>${carbon.kernel.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
<version>${carbon.device.mgt.plugin.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
@ -363,11 +364,11 @@
<properties>
<carbon.kernel.version>4.4.3</carbon.kernel.version>
<carbon.kernel.version>4.4.11</carbon.kernel.version>
<!-- Carbon Device Management -->
<carbon.device.mgt.version>1.2.6-SNAPSHOT</carbon.device.mgt.version>
<carbon.device.mgt.plugin.version>2.2.5-SNAPSHOT</carbon.device.mgt.plugin.version>
<carbon.device.mgt.version>2.0.7-SNAPSHOT</carbon.device.mgt.version>
<carbon.device.mgt.plugin.version>3.0.6-SNAPSHOT</carbon.device.mgt.plugin.version>
<paho.mqtt.version>1.0.2</paho.mqtt.version>
<commons-json.version>3.0.0.wso2v1</commons-json.version>
@ -382,8 +383,8 @@
<commons-httpclient.orbit.version>3.1.0.wso2v2</commons-httpclient.orbit.version>
<commons-json.version>3.0.0.wso2v1</commons-json.version>
<eclipse.equinox.common.version>3.6.100.v20120522-1841</eclipse.equinox.common.version>
<analytics.version>1.2.8</analytics.version>
<wso2.iot.version>1.0.0-SNAPSHOT</wso2.iot.version>
<analytics.version>1.3.0</analytics.version>
<wso2.iot.version>1.0.0</wso2.iot.version>
</properties>
</project>

@ -0,0 +1,190 @@
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.wso2</groupId>
<artifactId>wso2</artifactId>
<version>1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.iot.devicemgt-plugins</groupId>
<artifactId>iot-devicetype-samples</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>Creating custom distribution</name>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>carbon-p2-plugin</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>2-p2-repo-generation</id>
<phase>package</phase>
<goals>
<goal>p2-repo-gen</goal>
</goals>
<configuration>
<metadataRepository>file:\${basedir}/p2-repo</metadataRepository>
<artifactRepository>file:\${basedir}/p2-repo</artifactRepository>
<publishArtifacts>true</publishArtifacts>
<publishArtifactRepository>true</publishArtifactRepository>
<featureArtifacts>
<featureArtifactDef>
org.coffeeking:org.coffeeking.connectedcup.feature:\${carbon.device.mgt.plugin.version}
</featureArtifactDef>
</featureArtifacts>
</configuration>
</execution>
<execution>
<id>default-feature-install</id>
<phase>package</phase>
<goals>
<goal>p2-profile-gen</goal>
</goals>
<configuration>
<profile>default</profile>
<metadataRepository>file:\${basedir}/p2-repo</metadataRepository>
<artifactRepository>file:\${basedir}/p2-repo</artifactRepository>
<destination>\${basedir}/../core/repository/components</destination>
<deleteOldProfileFiles>false</deleteOldProfileFiles>
<features>
<feature>
<id>org.coffeeking.connectedcup.feature.group</id>
<version>\${carbon.device.mgt.plugin.version}</version>
</feature>
</features>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>default-feature-install</id>
<phase>package</phase>
<configuration>
<tasks>
<replace token="false" value="true"
dir="../core/repository/components/default/configuration/org.eclipse.equinox.simpleconfigurator">
<include name="**/bundles.info"/>
</replace>
<copy todir="../analytics/repository/deployment/server/carbonapps">
<fileset dir="../core/repository/deployment/server/carbonapps">
<include name="*.car"/>
</fileset>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>wso2.releases</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>wso2.snapshots</id>
<name>Apache Snapshot Repository</name>
<url>http://maven.wso2.org/nexus/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
<pluginRepository>
<id>wso2-nexus</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<!-- Before adding ANYTHING in here, please start a discussion on the dev list.
Ideally the Axis2 build should only use Maven central (which is available
by default) and nothing else. We had troubles with other repositories in
the past. Therefore configuring additional repositories here should be
considered very carefully. -->
<repository>
<id>wso2-nexus</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
<repository>
<id>wso2.releases</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
<repository>
<id>wso2.snapshots</id>
<name>WSO2 Snapshot Repository</name>
<url>http://maven.wso2.org/nexus/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<properties>
<carbon.device.mgt.plugin.version>1.0.0</carbon.device.mgt.plugin.version>
</properties>
</project>

@ -1528,14 +1528,14 @@
<carbon.governance.version>4.7.0</carbon.governance.version>
<!-- Carbon Device Management -->
<carbon.device.mgt.version>2.0.6</carbon.device.mgt.version>
<carbon.device.mgt.version>2.0.7-SNAPSHOT</carbon.device.mgt.version>
<carbon.device.mgt.version.range>[2.0.0, 3.0.0)</carbon.device.mgt.version.range>
<!-- IOT Device Management -->
<product.iot.version>3.0.0-SNAPSHOT</product.iot.version>
<!-- Carbon Device Management Plugins-->
<carbon.device.mgt.plugin.version>3.0.5</carbon.device.mgt.plugin.version>
<carbon.device.mgt.plugin.version>3.0.6-SNAPSHOT</carbon.device.mgt.plugin.version>
<!-- API Management -->
<carbon.api.mgt.version>6.1.35</carbon.api.mgt.version>

Loading…
Cancel
Save