From afde45b2f0cd9ca4d56ed88d5c4abaecab7895cc Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sun, 8 Jan 2017 21:29:08 +0530 Subject: [PATCH 1/3] Added default values for input and output adapters --- .../distribution/input-adapter-change.xml | 29 +++++++++++++ .../distribution/output-adapter-change.xml | 40 +++++++++++++++++ modules/analytics/distribution/pom.xml | 34 +++++++++++++++ .../distribution/src/bin/wso2server.bat | 2 +- .../distribution/src/bin/wso2server.sh | 4 ++ .../distribution/input-adapter-change.xml | 29 +++++++++++++ .../distribution/output-adapter-change.xml | 40 +++++++++++++++++ modules/core/distribution/pom.xml | 43 +++++++++++++++++++ .../src/repository/bin/wso2server.bat | 2 +- .../src/repository/bin/wso2server.sh | 8 ++++ 10 files changed, 229 insertions(+), 2 deletions(-) create mode 100644 modules/analytics/distribution/input-adapter-change.xml create mode 100644 modules/analytics/distribution/output-adapter-change.xml create mode 100644 modules/core/distribution/input-adapter-change.xml create mode 100644 modules/core/distribution/output-adapter-change.xml diff --git a/modules/analytics/distribution/input-adapter-change.xml b/modules/analytics/distribution/input-adapter-change.xml new file mode 100644 index 00000000..854702e0 --- /dev/null +++ b/modules/analytics/distribution/input-adapter-change.xml @@ -0,0 +1,29 @@ + + + + inputEventAdaptersConfig/adapterConfig[@type="jms"] + + 8 + 100 + 20000 + 10000 + 2 + 100 + https://${iot.keymanager.host}:${iot.keymanager.https.port} + admin + admin + + + + + 8 + 100 + 20000 + 10000 + 60 + https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.11/register + https://${iot.gateway.host}:${iot.gateway.https.port}/token + tcp://${mqtt.broker.host}:${mqtt.broker.port} +]]> + + \ No newline at end of file diff --git a/modules/analytics/distribution/output-adapter-change.xml b/modules/analytics/distribution/output-adapter-change.xml new file mode 100644 index 00000000..3a824330 --- /dev/null +++ b/modules/analytics/distribution/output-adapter-change.xml @@ -0,0 +1,40 @@ + + + + /outputEventAdaptersConfig/adapterConfig[@type="websocket"] + + + 8 + 100 + 20000 + 10000 + 60 + https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.11/register + https://${iot.gateway.host}:${iot.gateway.https.port}/token + tcp://${mqtt.broker.host}:${mqtt.broker.port} + + + + + 8 + 100 + 20000 + 10000 + + org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.OAuthAuthenticator + https://${iot.keymanager.host}:${iot.keymanager.https.port} + 2 + 100 + org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.DeviceAuthorizer + https://${iot.gateway.host}:${iot.gateway.https.port}/token + https://${iot.core.host}:${iot.core.https.port} + admin + admin + + + /permission/device-mgt/realtime_analytics + + 100 + ]]> + + \ No newline at end of file diff --git a/modules/analytics/distribution/pom.xml b/modules/analytics/distribution/pom.xml index 6ac4ace9..6b4d246c 100644 --- a/modules/analytics/distribution/pom.xml +++ b/modules/analytics/distribution/pom.xml @@ -102,6 +102,40 @@ + + init-input-adapter-config + prepare-package + + process + + + true + + + ${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/input-event-adapters.xml + ../../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/input-event-adapters.xml + input-adapter-change.xml + + + + + + init-output-adapter-config + prepare-package + + process + + + true + + + ${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/output-event-adapters.xml + ../../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/output-event-adapters.xml + output-adapter-change.xml + + + + diff --git a/modules/analytics/distribution/src/bin/wso2server.bat b/modules/analytics/distribution/src/bin/wso2server.bat index 999592c2..7f227e68 100644 --- a/modules/analytics/distribution/src/bin/wso2server.bat +++ b/modules/analytics/distribution/src/bin/wso2server.bat @@ -196,7 +196,7 @@ set CARBON_CLASSPATH=.\lib;%CARBON_CLASSPATH% set JAVA_ENDORSED=".\lib\endorsed";"%JAVA_HOME%\jre\lib\endorsed";"%JAVA_HOME%\lib\endorsed" -set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dlogger.server.name="IoT-Analytics" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dmqtt.broker.host="localhost" -Dmqtt.broker.port="1886" -Diot.core.host="localhost" -Diot.core.https.port="9443" -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8 +set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dlogger.server.name="IoT-Analytics" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dmqtt.broker.host="localhost" -Dmqtt.broker.port="1886" -Diot.core.host="localhost" -Diot.core.https.port="9443" -Diot.keymanager.host="localhost" -Diot.keymanager.https.port="9443" -Diot.gatway.host="localhost" -Diot.gateway.https.port="8243" -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8 :runJava echo JAVA_HOME environment variable is set to %JAVA_HOME% diff --git a/modules/analytics/distribution/src/bin/wso2server.sh b/modules/analytics/distribution/src/bin/wso2server.sh index c99980c3..29029c30 100755 --- a/modules/analytics/distribution/src/bin/wso2server.sh +++ b/modules/analytics/distribution/src/bin/wso2server.sh @@ -326,6 +326,10 @@ do -Dmqtt.broker.port="1886" \ -Diot.core.host="localhost" \ -Diot.core.https.port="9443" \ + -Diot.keymanager.host="localhost" \ + -Diot.keymanager.https.port="9443" \ + -Diot.gateway.host="localhost" \ + -Diot.gateway.https.port="8243" \ $NODE_PARAMS \ org.wso2.carbon.bootstrap.Bootstrap $* status=$? diff --git a/modules/core/distribution/input-adapter-change.xml b/modules/core/distribution/input-adapter-change.xml new file mode 100644 index 00000000..854702e0 --- /dev/null +++ b/modules/core/distribution/input-adapter-change.xml @@ -0,0 +1,29 @@ + + + + inputEventAdaptersConfig/adapterConfig[@type="jms"] + + 8 + 100 + 20000 + 10000 + 2 + 100 + https://${iot.keymanager.host}:${iot.keymanager.https.port} + admin + admin + + + + + 8 + 100 + 20000 + 10000 + 60 + https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.11/register + https://${iot.gateway.host}:${iot.gateway.https.port}/token + tcp://${mqtt.broker.host}:${mqtt.broker.port} +]]> + + \ No newline at end of file diff --git a/modules/core/distribution/output-adapter-change.xml b/modules/core/distribution/output-adapter-change.xml new file mode 100644 index 00000000..3a824330 --- /dev/null +++ b/modules/core/distribution/output-adapter-change.xml @@ -0,0 +1,40 @@ + + + + /outputEventAdaptersConfig/adapterConfig[@type="websocket"] + + + 8 + 100 + 20000 + 10000 + 60 + https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.11/register + https://${iot.gateway.host}:${iot.gateway.https.port}/token + tcp://${mqtt.broker.host}:${mqtt.broker.port} + + + + + 8 + 100 + 20000 + 10000 + + org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.OAuthAuthenticator + https://${iot.keymanager.host}:${iot.keymanager.https.port} + 2 + 100 + org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.DeviceAuthorizer + https://${iot.gateway.host}:${iot.gateway.https.port}/token + https://${iot.core.host}:${iot.core.https.port} + admin + admin + + + /permission/device-mgt/realtime_analytics + + 100 + ]]> + + \ No newline at end of file diff --git a/modules/core/distribution/pom.xml b/modules/core/distribution/pom.xml index 82a6af46..4e8d95c3 100644 --- a/modules/core/distribution/pom.xml +++ b/modules/core/distribution/pom.xml @@ -90,6 +90,49 @@ + + + com.google.code.maven-config-processor-plugin + config-processor-maven-plugin + 2.6 + + + init-input-adapter-config + prepare-package + + process + + + false + + + ${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/input-event-adapters.xml + ../../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/input-event-adapters.xml + input-adapter-change.xml + + + + + + init-output-adapter-config + prepare-package + + process + + + false + + + ${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/output-event-adapters.xml + ../../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/output-event-adapters.xml + output-adapter-change.xml + + + + + + + org.apache.maven.plugins maven-antrun-plugin diff --git a/modules/core/distribution/src/repository/bin/wso2server.bat b/modules/core/distribution/src/repository/bin/wso2server.bat index 39cf7c63..5f7dd86e 100644 --- a/modules/core/distribution/src/repository/bin/wso2server.bat +++ b/modules/core/distribution/src/repository/bin/wso2server.bat @@ -162,7 +162,7 @@ set CARBON_CLASSPATH=.\lib;%CARBON_CLASSPATH% set JAVA_ENDORSED=".\lib\endorsed";"%JAVA_HOME%\jre\lib\endorsed";"%JAVA_HOME%\lib\endorsed" -set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dlogger.server.name="IoT-Core" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8 -Dorg.wso2.ignoreHostnameVerification=true -Dorg.opensaml.httpclient.https.disableHostnameVerification=true +set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dlogger.server.name="IoT-Core" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8 -Dorg.wso2.ignoreHostnameVerification=true -Dorg.opensaml.httpclient.https.disableHostnameVerification=true -Dmqtt.broker.host="localhost" -Dmqtt.broker.port="1886" -Diot.core.host="localhost" -Diot.core.https.port="9443" -Diot.keymanager.host="localhost" -Diot.keymanager.https.port="9443" -Diot.gateway.host="localhost" -Diot.gateway.https.port="8243" :runJava echo JAVA_HOME environment variable is set to %JAVA_HOME% diff --git a/modules/core/distribution/src/repository/bin/wso2server.sh b/modules/core/distribution/src/repository/bin/wso2server.sh index 65add0f6..270aa597 100755 --- a/modules/core/distribution/src/repository/bin/wso2server.sh +++ b/modules/core/distribution/src/repository/bin/wso2server.sh @@ -307,6 +307,14 @@ do -DworkerNode=false \ -Dorg.wso2.ignoreHostnameVerification=true \ -Dorg.opensaml.httpclient.https.disableHostnameVerification=true \ + -Dmqtt.broker.host="localhost" \ + -Dmqtt.broker.port="1886" \ + -Diot.core.host="localhost" \ + -Diot.core.https.port="9443" \ + -Diot.keymanager.host="localhost" \ + -Diot.keymanager.https.port="9443" \ + -Diot.gateway.host="localhost" \ + -Diot.gateway.https.port="8243" \ org.wso2.carbon.bootstrap.Bootstrap $* status=$? done From 9c12a2c4a0b6efe61378cc3688dcc4d8b45c0e4d Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sun, 8 Jan 2017 21:29:28 +0530 Subject: [PATCH 2/3] changed default h2 port to 9095 --- modules/analytics/distribution/ds_config.xml | 2 +- .../conf/datasources/master-datasources.xml | 2 +- .../resources/devicetypes/connectedcup.xml | 38 ------------------- .../connectedcup/component/api/pom.xml | 21 +++++++++- .../api/ConnectedCupServiceImpl.java | 2 +- .../api/exception/ConnectedCupException.java | 0 .../java/org/coffeeking/api/util/APIUtil.java | 5 ++- .../org/coffeeking/api/util/SensorRecord.java | 0 .../src/main/webapp/META-INF/permissions.xml | 0 .../webapp/META-INF/webapp-classloading.xml | 0 .../src/main/webapp/WEB-INF/cxf-servlet.xml | 0 .../api/src/main/webapp/WEB-INF/web.xml | 0 .../constants/ConnectedCupConstants.java | 2 +- .../main/resources/configs/connectedcup.xml | 25 ++++++++++++ 14 files changed, 51 insertions(+), 46 deletions(-) delete mode 100644 modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/devicetypes/connectedcup.xml rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/api/pom.xml (87%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupServiceImpl.java (98%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/exception/ConnectedCupException.java (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java (98%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/SensorRecord.java (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/api/src/main/webapp/META-INF/permissions.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/api/src/main/webapp/META-INF/webapp-classloading.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/api/src/main/webapp/WEB-INF/cxf-servlet.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/api/src/main/webapp/WEB-INF/web.xml (100%) rename modules/{core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api => distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin}/constants/ConnectedCupConstants.java (96%) create mode 100644 modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/configs/connectedcup.xml diff --git a/modules/analytics/distribution/ds_config.xml b/modules/analytics/distribution/ds_config.xml index 90800a3c..c1d5903e 100644 --- a/modules/analytics/distribution/ds_config.xml +++ b/modules/analytics/distribution/ds_config.xml @@ -29,7 +29,7 @@ - jdbc:h2:../core/repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9090 + jdbc:h2:../core/repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9095 wso2carbon wso2carbon org.h2.Driver diff --git a/modules/core/distribution/src/repository/conf/datasources/master-datasources.xml b/modules/core/distribution/src/repository/conf/datasources/master-datasources.xml index 24495944..ec22c8a6 100755 --- a/modules/core/distribution/src/repository/conf/datasources/master-datasources.xml +++ b/modules/core/distribution/src/repository/conf/datasources/master-datasources.xml @@ -30,7 +30,7 @@ - jdbc:h2:repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9090 + jdbc:h2:repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9095 wso2carbon wso2carbon org.h2.Driver diff --git a/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/devicetypes/connectedcup.xml b/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/devicetypes/connectedcup.xml deleted file mode 100644 index f8f178f9..00000000 --- a/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/devicetypes/connectedcup.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - connectedcup - - - - - en_US - 1.0.0 - This is license text - - - - - - - false - - - diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/pom.xml b/modules/distribution/src/resources/samples/connectedcup/component/api/pom.xml similarity index 87% rename from modules/core/distribution/src/samples/connectedcup/component/api/pom.xml rename to modules/distribution/src/resources/samples/connectedcup/component/api/pom.xml index 3497b109..b248b5cb 100644 --- a/modules/core/distribution/src/samples/connectedcup/component/api/pom.xml +++ b/modules/distribution/src/resources/samples/connectedcup/component/api/pom.xml @@ -23,13 +23,13 @@ device-mgt-iot-connectedcup org.coffeeking - 1.0.0-SNAPSHOT + 1.0.0 ../pom.xml 4.0.0 org.coffeeking.connectedcup.api - 1.0.0-SNAPSHOT + 1.0.0 war WSO2 IoTS(Device Types) - Connected Cup API WSO2 IoTS(Device Types) - Connected Cup API @@ -71,6 +71,13 @@ provided + + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + provided + + org.apache.httpcomponents @@ -78,6 +85,11 @@ 4.1 provided + + org.coffeeking + org.coffeeking.connectedcup.plugin + provided + @@ -99,6 +111,11 @@ provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.analytics.data.publisher + provided + org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupServiceImpl.java b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupServiceImpl.java similarity index 98% rename from modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupServiceImpl.java rename to modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupServiceImpl.java index f257d400..b20e11a2 100644 --- a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupServiceImpl.java +++ b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupServiceImpl.java @@ -20,9 +20,9 @@ package org.coffeeking.api; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.coffeeking.api.constants.ConnectedCupConstants; import org.coffeeking.api.util.APIUtil; import org.coffeeking.api.util.SensorRecord; +import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants; import org.wso2.carbon.analytics.dataservice.commons.SortByField; import org.wso2.carbon.analytics.dataservice.commons.SortType; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/exception/ConnectedCupException.java b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/exception/ConnectedCupException.java similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/exception/ConnectedCupException.java rename to modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/exception/ConnectedCupException.java diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java similarity index 98% rename from modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java rename to modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java index a6266eb3..65ee31e6 100644 --- a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java +++ b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java @@ -21,10 +21,10 @@ package org.coffeeking.api.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.analytics.api.AnalyticsDataAPI; +import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; import org.wso2.carbon.analytics.dataservice.commons.SortByField; -import org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceUtils; import org.wso2.carbon.analytics.datasource.commons.Record; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.context.CarbonContext; @@ -96,12 +96,13 @@ public class APIUtil { sortByFields); List recordIds = getRecordIds(resultEntries); AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); - Map sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords( + Map sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords( analyticsDataAPI, response)); List sortedSensorData = getSortedSensorData(sensorDatas, resultEntries); return sortedSensorData; } + private static List getRecordIds(List searchResults) { List ids = new ArrayList<>(); for (SearchResultEntry searchResult : searchResults) { diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/SensorRecord.java b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/SensorRecord.java similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/SensorRecord.java rename to modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/SensorRecord.java diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/webapp/META-INF/permissions.xml b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/api/src/main/webapp/META-INF/permissions.xml rename to modules/distribution/src/resources/samples/connectedcup/component/api/src/main/webapp/META-INF/permissions.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/webapp/META-INF/webapp-classloading.xml b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/api/src/main/webapp/META-INF/webapp-classloading.xml rename to modules/distribution/src/resources/samples/connectedcup/component/api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/webapp/WEB-INF/cxf-servlet.xml b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/api/src/main/webapp/WEB-INF/cxf-servlet.xml rename to modules/distribution/src/resources/samples/connectedcup/component/api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/webapp/WEB-INF/web.xml b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/api/src/main/webapp/WEB-INF/web.xml rename to modules/distribution/src/resources/samples/connectedcup/component/api/src/main/webapp/WEB-INF/web.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/constants/ConnectedCupConstants.java b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/constants/ConnectedCupConstants.java similarity index 96% rename from modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/constants/ConnectedCupConstants.java rename to modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/constants/ConnectedCupConstants.java index 05201c09..b1b71488 100644 --- a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/constants/ConnectedCupConstants.java +++ b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/constants/ConnectedCupConstants.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.coffeeking.api.constants; +package org.coffeeking.connectedcup.plugin.constants; public class ConnectedCupConstants { diff --git a/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/configs/connectedcup.xml b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/configs/connectedcup.xml new file mode 100644 index 00000000..8d70e4d0 --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/configs/connectedcup.xml @@ -0,0 +1,25 @@ + + + + + + jdbc/ConnectedCupDM_DB + + + From 751eef086ef99e407ed14f88515186f03b5660f1 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sun, 8 Jan 2017 22:53:23 +0530 Subject: [PATCH 3/3] revived connected cup sample --- .../coffeeking/api/ConnectedCupService.java | 61 ----- modules/distribution/pom.xml | 1 + modules/distribution/src/assembly/dist.xml | 27 ++ .../resources/plugins/plugins-deployer.xml | 34 +-- .../connectedcup/component/agent/pom.xml | 4 +- .../coffeeking/agent/datasense/PushLevel.java | 0 .../agent/datasense/PushTemperature.java | 0 .../agent/transport/TransportHandler.java | 0 .../transport/TransportHandlerException.java | 0 .../ConnectedCupMQttTransportHandler.java | 0 .../transport/mqtt/MQTTTransportHandler.java | 0 .../agent/src/main/webapp/WEB-INF/web.xml | 0 .../agent/src/main/webapp/css/coffee.css | 0 .../component/agent/src/main/webapp/index.jsp | 0 .../agent/src/main/webapp/js/coffee.js | 0 .../main/webapp/js/libs/htmlpreview.min.js | 0 .../src/main/webapp/js/libs/jquery.min.js | 0 .../component/analytics/build.xml | 0 .../connectedcup/component/analytics/pom.xml | 4 +- .../component/analytics/src/assembly/src.xml | 0 .../carbonapps/coffee_level/artifacts.xml | 0 .../coffee_level_receiver/artifact.xml | 0 .../coffee_level_receiver.xml | 0 .../coffee_level_script/artifact.xml | 0 .../coffee_level_script.xml | 0 .../coffee_level_store/artifact.xml | 0 .../org_wso2_iot_devices_coffeelevel.xml | 0 .../coffee_level_stream/artifact.xml | 0 ...rg.wso2.iot.devices.coffeelevel_1.0.0.json | 0 .../carbonapps/connected_cup/artifacts.xml | 0 .../connected_cup_execution/artifact.xml | 0 .../connected_cup_execution.siddhiql | 0 .../connected_cup_publisher/artifact.xml | 0 .../connected_cup_publisher.xml | 0 .../connected_cup_receiver/artifact.xml | 0 .../connected_cup_receiver.xml | 6 +- .../connected_cup_stream/artifact.xml | 0 .../org.wso2.iot.connectedcup_1.0.0.json | 0 .../coffeeking/api/ConnectedCupService.java | 127 +++++++++ .../connectedcup/component/plugin/pom.xml | 116 ++++++++ .../ConnectedCupDeviceMgtPluginException.java | 42 +++ .../impl/ConnectedCupFeatureManager.java | 100 +++++++ .../plugin/impl/ConnectedCupManager.java | 255 ++++++++++++++++++ .../impl/ConnectedCupManagerService.java | 81 ++++++ .../plugin/impl/dao/ConnectedCupDAO.java | 204 ++++++++++++++ .../plugin/impl/dao/ConnectedCupDAOUtil.java | 132 +++++++++ .../impl/dao/util/ConnectedCupUtils.java | 88 ++++++ .../ConnectedCupServiceComponent.java | 74 +++++ .../samples/connectedcup/component/pom.xml | 5 +- .../samples/connectedcup/component/ui/pom.xml | 4 +- .../component/ui/src/assembly/src.xml | 0 .../analytics-view.hbs | 0 .../analytics-view.js | 0 .../analytics-view.json | 0 .../public/js/connectedcup.js | 0 .../device-view.hbs | 0 .../device-view.js | 0 .../device-view.json | 0 .../public/images/thumb.png | Bin .../analytics-view.hbs | 0 .../analytics-view.js | 0 .../analytics-view.json | 0 .../public/js/device-stats.js | 0 .../public/js/moment.min.js | 0 .../public/js/socket.io.min.js | 0 .../private/config.json | 0 .../public/images/coffee_stats.png | Bin .../public/images/coffeecup.png | Bin .../public/images/thumb.png | Bin .../public/js/download.js | 0 .../public/js/jquery.validate.js | 0 .../type-view.hbs | 0 .../type-view.json | 0 .../feature/connectedcup-feature/pom.xml | 59 +++- .../resources/agent/deviceConfig.properties | 0 .../main/resources/agent/sketch.properties | 0 .../src/main/resources/agent/start-device.sh | 0 .../src/main/resources/build.properties | 0 .../datasources/connectedcup-datasources.xml | 46 ++++ .../src/main/resources/dbscripts/h2.sql | 11 + .../src/main/resources/dbscripts/mysql.sql | 12 + .../src/main/resources/p2.inf | 12 +- .../samples/connectedcup/feature/pom.xml | 4 +- .../resources}/samples/connectedcup/pom.xml | 23 +- .../resources/samples/samples-deployer.xml | 190 +++++++++++++ pom.xml | 4 +- 86 files changed, 1617 insertions(+), 109 deletions(-) delete mode 100644 modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupService.java rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/pom.xml (98%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/datasense/PushLevel.java (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/datasense/PushTemperature.java (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/TransportHandler.java (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/TransportHandlerException.java (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/ConnectedCupMQttTransportHandler.java (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/MQTTTransportHandler.java (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/webapp/WEB-INF/web.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/webapp/css/coffee.css (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/webapp/index.jsp (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/webapp/js/coffee.js (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/webapp/js/libs/htmlpreview.min.js (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/agent/src/main/webapp/js/libs/jquery.min.js (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/build.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/pom.xml (97%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/assembly/src.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/artifacts.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/artifact.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/coffee_level_receiver.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/artifact.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/artifact.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/org_wso2_iot_devices_coffeelevel.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_stream/artifact.xml (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/artifacts.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/artifact.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/connected_cup_execution.siddhiql (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/artifact.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/artifact.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/connected_cup_receiver.xml (76%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_stream/artifact.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_stream/org.wso2.iot.connectedcup_1.0.0.json (100%) create mode 100644 modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupService.java create mode 100644 modules/distribution/src/resources/samples/connectedcup/component/plugin/pom.xml create mode 100644 modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/exception/ConnectedCupDeviceMgtPluginException.java create mode 100644 modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupFeatureManager.java create mode 100644 modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupManager.java create mode 100644 modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupManagerService.java create mode 100644 modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/ConnectedCupDAO.java create mode 100644 modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/ConnectedCupDAOUtil.java create mode 100644 modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/util/ConnectedCupUtils.java create mode 100644 modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/internal/ConnectedCupServiceComponent.java rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/pom.xml (96%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/pom.xml (96%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/src/assembly/src.xml (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.js (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.json (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.hbs (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.js (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.json (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/private/config.json (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => 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 (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/type-view.hbs (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/type-view.json (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/feature/connectedcup-feature/pom.xml (77%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/deviceConfig.properties (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/sketch.properties (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/start-device.sh (100%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/feature/connectedcup-feature/src/main/resources/build.properties (100%) create mode 100644 modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/datasources/connectedcup-datasources.xml create mode 100644 modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/dbscripts/h2.sql create mode 100644 modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/dbscripts/mysql.sql rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/feature/connectedcup-feature/src/main/resources/p2.inf (61%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/feature/pom.xml (95%) rename modules/{core/distribution/src => distribution/src/resources}/samples/connectedcup/pom.xml (96%) create mode 100644 modules/distribution/src/resources/samples/samples-deployer.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupService.java b/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupService.java deleted file mode 100644 index 66254e2e..00000000 --- a/modules/core/distribution/src/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupService.java +++ /dev/null @@ -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); - -} diff --git a/modules/distribution/pom.xml b/modules/distribution/pom.xml index 5b4e8a18..cf34057e 100644 --- a/modules/distribution/pom.xml +++ b/modules/distribution/pom.xml @@ -113,6 +113,7 @@ ${basedir}/src/assembly/dist.xml + \ diff --git a/modules/distribution/src/assembly/dist.xml b/modules/distribution/src/assembly/dist.xml index c26f0016..0fe2797a 100644 --- a/modules/distribution/src/assembly/dist.xml +++ b/modules/distribution/src/assembly/dist.xml @@ -60,6 +60,33 @@ */** 644 + true + + src/resources/samples + wso2iot-${product.iot.version}/samples + + */** + + 644 + + + + + src/resources/samples/samples-deployer.xml + + wso2iot-${product.iot.version}/samples/ + true + 644 + + + + src/resources/samples/connectedcup/pom.xml + + wso2iot-${product.iot.version}/samples/connectedcup + true + 644 + + diff --git a/modules/distribution/src/resources/plugins/plugins-deployer.xml b/modules/distribution/src/resources/plugins/plugins-deployer.xml index 5046dbac..66dee97a 100644 --- a/modules/distribution/src/resources/plugins/plugins-deployer.xml +++ b/modules/distribution/src/resources/plugins/plugins-deployer.xml @@ -46,28 +46,28 @@ p2-repo-gen - file:${basedir}/p2-repo - file:${basedir}/p2-repo + file:\${basedir}/p2-repo + file:\${basedir}/p2-repo true true - 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} - 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} - 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} - 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} - 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} - 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} @@ -80,22 +80,22 @@ default - file:${basedir}/p2-repo - file:${basedir}/p2-repo - ${basedir}/../core/repository/components + file:\${basedir}/p2-repo + file:\${basedir}/p2-repo + \${basedir}/../core/repository/components false org.wso2.carbon.device.mgt.iot.androidsense.feature.group - ${carbon.device.mgt.plugin.version} + \${carbon.device.mgt.plugin.version} org.wso2.carbon.device.mgt.iot.arduino.feature.group - ${carbon.device.mgt.plugin.version} + \${carbon.device.mgt.plugin.version} org.wso2.carbon.device.mgt.iot.raspberrypi.feature.group - ${carbon.device.mgt.plugin.version} + \${carbon.device.mgt.plugin.version} org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature.group @@ -103,11 +103,11 @@ org.wso2.carbon.device.mgt.mobile.android.feature.group - ${carbon.device.mgt.plugin.version} + \${carbon.device.mgt.plugin.version} org.wso2.carbon.device.mgt.mobile.windows.feature.group - ${carbon.device.mgt.plugin.version} + \${carbon.device.mgt.plugin.version} @@ -225,6 +225,6 @@ - 3.0.5 + ${carbon.device.mgt.plugin.version} \ No newline at end of file diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/pom.xml b/modules/distribution/src/resources/samples/connectedcup/component/agent/pom.xml similarity index 98% rename from modules/core/distribution/src/samples/connectedcup/component/agent/pom.xml rename to modules/distribution/src/resources/samples/connectedcup/component/agent/pom.xml index ccd996fb..2a6ad992 100644 --- a/modules/core/distribution/src/samples/connectedcup/component/agent/pom.xml +++ b/modules/distribution/src/resources/samples/connectedcup/component/agent/pom.xml @@ -21,13 +21,13 @@ device-mgt-iot-connectedcup org.coffeeking - 1.0.0-SNAPSHOT + 1.0.0 ../pom.xml 4.0.0 org.coffeeking.connectedcup.agent war - 1.0.0-SNAPSHOT + 1.0.0 WSO2 IoTS(Device Types) - Connected Cup Agent Web app http://maven.apache.org diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/datasense/PushLevel.java b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/datasense/PushLevel.java similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/datasense/PushLevel.java rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/datasense/PushLevel.java diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/datasense/PushTemperature.java b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/datasense/PushTemperature.java similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/datasense/PushTemperature.java rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/datasense/PushTemperature.java diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/TransportHandler.java b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/TransportHandler.java similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/TransportHandler.java rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/TransportHandler.java diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/TransportHandlerException.java b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/TransportHandlerException.java similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/TransportHandlerException.java rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/TransportHandlerException.java diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/ConnectedCupMQttTransportHandler.java b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/ConnectedCupMQttTransportHandler.java similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/ConnectedCupMQttTransportHandler.java rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/ConnectedCupMQttTransportHandler.java diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/MQTTTransportHandler.java b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/MQTTTransportHandler.java similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/MQTTTransportHandler.java rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/java/org/coffeeking/agent/transport/mqtt/MQTTTransportHandler.java diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/WEB-INF/web.xml b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/WEB-INF/web.xml rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/WEB-INF/web.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/css/coffee.css b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/css/coffee.css similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/css/coffee.css rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/css/coffee.css diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/index.jsp b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/index.jsp similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/index.jsp rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/index.jsp diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/js/coffee.js b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/js/coffee.js similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/js/coffee.js rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/js/coffee.js diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/js/libs/htmlpreview.min.js b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/js/libs/htmlpreview.min.js similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/js/libs/htmlpreview.min.js rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/js/libs/htmlpreview.min.js diff --git a/modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/js/libs/jquery.min.js b/modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/js/libs/jquery.min.js similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/agent/src/main/webapp/js/libs/jquery.min.js rename to modules/distribution/src/resources/samples/connectedcup/component/agent/src/main/webapp/js/libs/jquery.min.js diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/build.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/build.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/build.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/build.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/pom.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/pom.xml similarity index 97% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/pom.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/pom.xml index 5d6866b8..4cfbfa21 100644 --- a/modules/core/distribution/src/samples/connectedcup/component/analytics/pom.xml +++ b/modules/distribution/src/resources/samples/connectedcup/component/analytics/pom.xml @@ -25,13 +25,13 @@ org.coffeeking device-mgt-iot-connectedcup - 1.0.0-SNAPSHOT + 1.0.0 ../pom.xml 4.0.0 org.coffeeking.connectedcup.analytics - 1.0.0-SNAPSHOT + 1.0.0 WSO2 IoTS(Device Types) - Connected Cup Analytics capp pom diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/assembly/src.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/assembly/src.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/assembly/src.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/assembly/src.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/artifacts.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/artifacts.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/artifacts.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/artifacts.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/artifact.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/artifact.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/artifact.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/artifact.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/coffee_level_receiver.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/coffee_level_receiver.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/coffee_level_receiver.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_receiver/coffee_level_receiver.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/artifact.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/artifact.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/artifact.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/artifact.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/artifact.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/artifact.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/artifact.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/artifact.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/org_wso2_iot_devices_coffeelevel.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/org_wso2_iot_devices_coffeelevel.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/org_wso2_iot_devices_coffeelevel.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_store/org_wso2_iot_devices_coffeelevel.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_stream/artifact.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_stream/artifact.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_stream/artifact.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_stream/artifact.xml diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/artifacts.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/artifacts.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/artifacts.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/artifacts.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/artifact.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/artifact.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/artifact.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/artifact.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/connected_cup_execution.siddhiql b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/connected_cup_execution.siddhiql similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/connected_cup_execution.siddhiql rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_execution/connected_cup_execution.siddhiql diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/artifact.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/artifact.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/artifact.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/artifact.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/artifact.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/artifact.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/artifact.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/artifact.xml diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/connected_cup_receiver.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/connected_cup_receiver.xml similarity index 76% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/connected_cup_receiver.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/connected_cup_receiver.xml index cd9b0657..e63f6973 100644 --- a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/connected_cup_receiver.xml +++ b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_receiver/connected_cup_receiver.xml @@ -21,11 +21,9 @@ carbon.super/connectedcup/# admin - device_id_json_path:event.metaData.deviceId,device_id_topic_hierarchy_index:2 - org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTContentValidator + admin + org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTContentValidator default - https://localhost:${carbon.https.port}/dynamic-client-web/register - tcp://${mqtt.broker.host}:${mqtt.broker.port} true diff --git a/modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_stream/artifact.xml b/modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_stream/artifact.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_stream/artifact.xml rename to modules/distribution/src/resources/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_stream/artifact.xml diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupService.java b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupService.java new file mode 100644 index 00000000..605b92cd --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/ConnectedCupService.java @@ -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); + +} diff --git a/modules/distribution/src/resources/samples/connectedcup/component/plugin/pom.xml b/modules/distribution/src/resources/samples/connectedcup/component/plugin/pom.xml new file mode 100644 index 00000000..ac039084 --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/component/plugin/pom.xml @@ -0,0 +1,116 @@ + + + + + + device-mgt-iot-connectedcup + org.coffeeking + 1.0.0 + ../pom.xml + + + 4.0.0 + org.coffeeking.connectedcup.plugin + 1.0.0 + bundle + WSO2 IoTS(Device Types) - Connected Cup CDMF Plugin + WSO2 IoTS(Device Types) - Connected Cup CDMF Plugin + http://wso2.org + + + + + org.apache.felix + maven-scr-plugin + + + maven-compiler-plugin + + 1.7 + 1.7 + + 2.3.2 + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.device.mgt.plugin.version} + IoT Server Impl Bundle + org.coffeeking.connectedcup.plugin.internal + + 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 + + + + !org.coffeeking.connectedcup.plugin.internal, + org.coffeeking.connectedcup.plugin.* + + + + + + + + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + + org.wso2.carbon + org.wso2.carbon.logging + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + + + org.wso2.carbon + org.wso2.carbon.ndatasource.core + + + + diff --git a/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/exception/ConnectedCupDeviceMgtPluginException.java b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/exception/ConnectedCupDeviceMgtPluginException.java new file mode 100644 index 00000000..92b85968 --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/exception/ConnectedCupDeviceMgtPluginException.java @@ -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); + } + +} diff --git a/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupFeatureManager.java b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupFeatureManager.java new file mode 100644 index 00000000..d1f9e3f3 --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupFeatureManager.java @@ -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 apiParams = new HashMap<>(); + apiParams.put(METHOD, "POST"); + apiParams.put(URI, "/connectedcup/device/ordercoffee"); + List pathParams = new ArrayList<>(); + List queryParams = new ArrayList<>(); + List formParams = new ArrayList<>(); + apiParams.put(PATH_PARAMS, pathParams); + queryParams.add("deviceId"); + apiParams.put(QUERY_PARAMS, queryParams); + apiParams.put(FORM_PARAMS, formParams); + List 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 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 getFeatures() throws DeviceManagementException { + List 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; + } +} diff --git a/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupManager.java b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupManager.java new file mode 100644 index 00000000..80741f5e --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupManager.java @@ -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 getAllDevices() throws DeviceManagementException { + List 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; + } + +} \ No newline at end of file diff --git a/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupManagerService.java b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupManagerService.java new file mode 100644 index 00000000..dfb5fded --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/ConnectedCupManagerService.java @@ -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; + } + +} diff --git a/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/ConnectedCupDAO.java b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/ConnectedCupDAO.java new file mode 100644 index 00000000..deb509cc --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/ConnectedCupDAO.java @@ -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 getAllDevices() throws ConnectedCupDeviceMgtPluginException { + + Connection conn = null; + PreparedStatement stmt = null; + ResultSet resultSet = null; + Device connectedCupDevice; + List 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(); + } + + } + +} \ No newline at end of file diff --git a/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/ConnectedCupDAOUtil.java b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/ConnectedCupDAOUtil.java new file mode 100644 index 00000000..4daa8569 --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/ConnectedCupDAOUtil.java @@ -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 currentConnection = new ThreadLocal(); + + 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(); + } + } +} \ No newline at end of file diff --git a/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/util/ConnectedCupUtils.java b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/util/ConnectedCupUtils.java new file mode 100644 index 00000000..9c25f256 --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/impl/dao/util/ConnectedCupUtils.java @@ -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 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); + } + + +} diff --git a/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/internal/ConnectedCupServiceComponent.java b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/internal/ConnectedCupServiceComponent.java new file mode 100644 index 00000000..6b6f00bd --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/component/plugin/src/main/java/org/coffeeking/connectedcup/plugin/internal/ConnectedCupServiceComponent.java @@ -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); + } + } + +} diff --git a/modules/core/distribution/src/samples/connectedcup/component/pom.xml b/modules/distribution/src/resources/samples/connectedcup/component/pom.xml similarity index 96% rename from modules/core/distribution/src/samples/connectedcup/component/pom.xml rename to modules/distribution/src/resources/samples/connectedcup/component/pom.xml index 20ef83f7..b4e2bfdc 100644 --- a/modules/core/distribution/src/samples/connectedcup/component/pom.xml +++ b/modules/distribution/src/resources/samples/connectedcup/component/pom.xml @@ -24,13 +24,13 @@ org.coffeeking device.mgt.iot.connectedcup-parent - 1.0.0-SNAPSHOT + 1.0.0 ../pom.xml 4.0.0 device-mgt-iot-connectedcup - 1.0.0-SNAPSHOT + 1.0.0 pom WSO2 IoTS(Device Types) - Connected Cup Component WSO2 IoTS(Device Types) - Connected Cup Component @@ -38,6 +38,7 @@ analytics + plugin api agent ui diff --git a/modules/core/distribution/src/samples/connectedcup/component/ui/pom.xml b/modules/distribution/src/resources/samples/connectedcup/component/ui/pom.xml similarity index 96% rename from modules/core/distribution/src/samples/connectedcup/component/ui/pom.xml rename to modules/distribution/src/resources/samples/connectedcup/component/ui/pom.xml index 372f82bf..84ee9a99 100644 --- a/modules/core/distribution/src/samples/connectedcup/component/ui/pom.xml +++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/pom.xml @@ -25,13 +25,13 @@ org.coffeeking device-mgt-iot-connectedcup - 1.0.0-SNAPSHOT + 1.0.0 ../pom.xml 4.0.0 org.coffeeking.connectedcup.ui - 1.0.0-SNAPSHOT + 1.0.0 WSO2 IoTS(Device Types) - Connected Cup UI pom diff --git a/modules/core/distribution/src/samples/connectedcup/component/ui/src/assembly/src.xml b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/assembly/src.xml similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/component/ui/src/assembly/src.xml rename to modules/distribution/src/resources/samples/connectedcup/component/ui/src/assembly/src.xml diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/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 b/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 similarity index 100% rename from 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 rename to 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 diff --git a/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/pom.xml b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/pom.xml similarity index 77% rename from modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/pom.xml rename to modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/pom.xml index b177023e..ae49f350 100644 --- a/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/pom.xml +++ b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/pom.xml @@ -25,19 +25,24 @@ org.coffeeking connected-cup-feature-parent - 1.0.0-SNAPSHOT + 1.0.0 ../pom.xml 4.0.0 org.coffeeking.connectedcup.feature pom - 1.0.0-SNAPSHOT + 1.0.0 WSO2 IoTS(Device Types) - Connected Cup Feature WSO2 IoTS(Device Types) - Connected Cup Feature http://wso2.org + + org.coffeeking + org.coffeeking.connectedcup.plugin + ${wso2.iot.version} + org.coffeeking org.coffeeking.connectedcup.api @@ -50,6 +55,11 @@ ${wso2.iot.version} war + + com.h2database.wso2 + h2-database-engine + 1.2.140.wso2v3 + @@ -148,6 +158,46 @@ + + org.apache.maven.plugins + maven-antrun-plugin + + + + create-connected-cup-plugin-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.maven carbon-p2-plugin @@ -167,6 +217,11 @@ org.eclipse.equinox.p2.type.group:true + + + org.coffeeking:org.coffeeking.connectedcup.plugin:${wso2.iot.version} + + org.wso2.carbon.core.server:${carbon.kernel.version} diff --git a/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/deviceConfig.properties b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/deviceConfig.properties similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/deviceConfig.properties rename to modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/deviceConfig.properties diff --git a/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/sketch.properties b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/sketch.properties similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/sketch.properties rename to modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/sketch.properties diff --git a/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/start-device.sh b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/start-device.sh similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/start-device.sh rename to modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/agent/start-device.sh diff --git a/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/build.properties b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/build.properties similarity index 100% rename from modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/build.properties rename to modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/build.properties diff --git a/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/datasources/connectedcup-datasources.xml b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/datasources/connectedcup-datasources.xml new file mode 100644 index 00000000..893a91c0 --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/datasources/connectedcup-datasources.xml @@ -0,0 +1,46 @@ + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + ConnectedCupDM_DB + The datasource used for the Connected Cup database + + jdbc/ConnectedCupDM_DB + + + + jdbc:h2:repository/database/ConnectedCupDM_DB;DB_CLOSE_ON_EXIT=FALSE + + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + + diff --git a/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/dbscripts/h2.sql b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/dbscripts/h2.sql new file mode 100644 index 00000000..afa2ad8a --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/dbscripts/h2.sql @@ -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`) ); + + + diff --git a/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/dbscripts/mysql.sql b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/dbscripts/mysql.sql new file mode 100644 index 00000000..64560fc3 --- /dev/null +++ b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/dbscripts/mysql.sql @@ -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; + + + + diff --git a/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/p2.inf b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/p2.inf similarity index 61% rename from modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/p2.inf rename to modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/p2.inf index 7837721e..68abddb2 100644 --- a/modules/core/distribution/src/samples/connectedcup/feature/connectedcup-feature/src/main/resources/p2.inf +++ b/modules/distribution/src/resources/samples/connectedcup/feature/connectedcup-feature/src/main/resources/p2.inf @@ -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);\ diff --git a/modules/core/distribution/src/samples/connectedcup/feature/pom.xml b/modules/distribution/src/resources/samples/connectedcup/feature/pom.xml similarity index 95% rename from modules/core/distribution/src/samples/connectedcup/feature/pom.xml rename to modules/distribution/src/resources/samples/connectedcup/feature/pom.xml index 7f513907..886d3a05 100644 --- a/modules/core/distribution/src/samples/connectedcup/feature/pom.xml +++ b/modules/distribution/src/resources/samples/connectedcup/feature/pom.xml @@ -23,14 +23,14 @@ org.coffeeking device.mgt.iot.connectedcup-parent - 1.0.0-SNAPSHOT + 1.0.0 ../pom.xml 4.0.0 connected-cup-feature-parent pom - 1.0.0-SNAPSHOT + 1.0.0 WSO2 IoTS(Device Types) - Connected Cup Feature Parent WSO2 IoTS(Device Types) - Connected Cup Feature Parent http://wso2.org diff --git a/modules/core/distribution/src/samples/connectedcup/pom.xml b/modules/distribution/src/resources/samples/connectedcup/pom.xml similarity index 96% rename from modules/core/distribution/src/samples/connectedcup/pom.xml rename to modules/distribution/src/resources/samples/connectedcup/pom.xml index 6f6f6caf..c5437a48 100644 --- a/modules/core/distribution/src/samples/connectedcup/pom.xml +++ b/modules/distribution/src/resources/samples/connectedcup/pom.xml @@ -31,7 +31,7 @@ org.coffeeking device.mgt.iot.connectedcup-parent - ${project.version} + 1.0.0 pom WSO2 IoTS(Device Types) - Connected Cup Component WSO2 IoTS(Device Types) - Connected Cup Component @@ -135,6 +135,12 @@ 4.1 provided + + org.coffeeking + org.coffeeking.connectedcup.plugin + ${wso2.iot.version} + provided + org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.webapp.publisher @@ -145,11 +151,6 @@ org.wso2.carbon.ndatasource.core ${carbon.kernel.version} - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot - ${carbon.device.mgt.plugin.version} - org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.core @@ -363,11 +364,11 @@ - 4.4.3 + 4.4.11 - 1.2.6-SNAPSHOT - 2.2.5-SNAPSHOT + 2.0.7-SNAPSHOT + 3.0.6-SNAPSHOT 1.0.2 3.0.0.wso2v1 @@ -382,8 +383,8 @@ 3.1.0.wso2v2 3.0.0.wso2v1 3.6.100.v20120522-1841 - 1.2.8 - 1.0.0-SNAPSHOT + 1.3.0 + 1.0.0 diff --git a/modules/distribution/src/resources/samples/samples-deployer.xml b/modules/distribution/src/resources/samples/samples-deployer.xml new file mode 100644 index 00000000..8339633d --- /dev/null +++ b/modules/distribution/src/resources/samples/samples-deployer.xml @@ -0,0 +1,190 @@ + + + + + org.wso2 + wso2 + 1 + + + 4.0.0 + org.wso2.iot.devicemgt-plugins + iot-devicetype-samples + 1.0.0 + pom + Creating custom distribution + http://wso2.org + + + + + org.wso2.maven + carbon-p2-plugin + 1.5.3 + + + 2-p2-repo-generation + package + + p2-repo-gen + + + file:\${basedir}/p2-repo + file:\${basedir}/p2-repo + true + true + + + org.coffeeking:org.coffeeking.connectedcup.feature:\${carbon.device.mgt.plugin.version} + + + + + + default-feature-install + package + + p2-profile-gen + + + default + file:\${basedir}/p2-repo + file:\${basedir}/p2-repo + \${basedir}/../core/repository/components + false + + + org.coffeeking.connectedcup.feature.group + \${carbon.device.mgt.plugin.version} + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.1 + + + default-feature-install + package + + + + + + + + + + + + + + run + + + + + + + + + + wso2.releases + WSO2 internal Repository + http://maven.wso2.org/nexus/content/repositories/releases/ + + true + daily + ignore + + + + wso2.snapshots + Apache Snapshot Repository + http://maven.wso2.org/nexus/content/repositories/snapshots/ + + true + daily + + + false + + + + wso2-nexus + WSO2 internal Repository + http://maven.wso2.org/nexus/content/groups/wso2-public/ + + true + daily + ignore + + + + + + + + + wso2-nexus + WSO2 internal Repository + http://maven.wso2.org/nexus/content/groups/wso2-public/ + + true + daily + ignore + + + + wso2.releases + WSO2 internal Repository + http://maven.wso2.org/nexus/content/repositories/releases/ + + true + daily + ignore + + + + wso2.snapshots + WSO2 Snapshot Repository + http://maven.wso2.org/nexus/content/repositories/snapshots/ + + true + daily + + + false + + + + + 1.0.0 + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index a6e3128e..8986dcd0 100644 --- a/pom.xml +++ b/pom.xml @@ -1528,14 +1528,14 @@ 4.7.0 - 2.0.6 + 2.0.7-SNAPSHOT [2.0.0, 3.0.0) 3.0.0-SNAPSHOT - 3.0.5 + 3.0.6-SNAPSHOT 6.1.35