@ -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);
|
||||
|
||||
}
|
0
modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/ConnectedCupMQttTransportHandler.java → modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/ConnectedCupMQttTransportHandler.java
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/artifact.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/artifact.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/coffee_level_receiver.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/coffee_level_receiver.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/artifact.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/artifact.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/artifact.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/artifact.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/org_wso2_iot_devices_coffeelevel.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/org_wso2_iot_devices_coffeelevel.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_stream/artifact.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_stream/artifact.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_stream/org.wso2.iot.devices.coffeelevel_1.0.0.json → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_stream/org.wso2.iot.devices.coffeelevel_1.0.0.json
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/artifact.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/artifact.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/connected_cup_execution.siddhiql → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/connected_cup_execution.siddhiql
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/artifact.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/artifact.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/artifact.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/artifact.xml
6
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/connected_cup_receiver.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/connected_cup_receiver.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_stream/artifact.xml → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_stream/artifact.xml
0
modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_stream/org.wso2.iot.connectedcup_1.0.0.json → modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_stream/org.wso2.iot.connectedcup_1.0.0.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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.js → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.js
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.json → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.json
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/public/js/connectedcup.js → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/public/js/connectedcup.js
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.hbs → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.hbs
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.js → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.js
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.json → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.json
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/public/images/thumb.png → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/public/images/thumb.png
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.hbs → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.hbs
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.js → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.js
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.json → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.json
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/moment.min.js → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/moment.min.js
vendored
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/socket.io.min.js → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/socket.io.min.js
vendored
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/private/config.json → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/private/config.json
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/images/coffee_stats.png → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/images/coffee_stats.png
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/images/coffeecup.png → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/images/coffeecup.png
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/images/thumb.png → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/images/thumb.png
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/js/download.js → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/js/download.js
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/js/jquery.validate.js → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/js/jquery.validate.js
vendored
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/type-view.hbs → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/type-view.hbs
0
modules/core/distribution/src/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/type-view.json → modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/type-view.json
@ -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);\
|
@ -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>
|