Skip to content
This repository has been archived by the owner on Nov 15, 2019. It is now read-only.

Commit

Permalink
[Edgent-379] upgrade to WIoTP iot-java 0.2.2
Browse files Browse the repository at this point in the history
- update build.gradle files
- update eclipse .classpath files
- update LICENSE
- update binary license files
- update RELEASE_NOTES with noteworthy change in iot-java behavior
- update IotpDevice to avoid some deprecated iot-java methods
  and bug in new method (see commentary in IotpDevice)
- update iotp sample run scripts
  • Loading branch information
dlaboss committed Feb 17, 2017
1 parent 3699553 commit 261c7ee
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 18 deletions.
35 changes: 35 additions & 0 deletions RELEASE_NOTES
@@ -1,3 +1,38 @@
Apache Edgent (incubating) 1.?.?
==================
This release blah blah blah...

See EDGENT-379 below for important information related to the
Edgent connector for the IBM Watson IoT Platform.

New Features
--------------------
TODO

Incompatible changes
--------------------
TODO

Miscellaneous changes
---------------------
EDGENT-379 - upgrade to the WIoTP 0.2.2 Java client API
Upgrade the Edgent connector for the IBM Watson IoT Platform to use
the WIoTP 0.2.2 Java client API.
Note: the WIoTP API changed the way it publishes device events.
See the "Migration from release 0.1.5 to 0.2.1" information at
https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021
for details including how to revert the behavior if needed.
See https://github.com/ibm-watson-iot/iot-java/releases
for general release information about the WIoTP Java client API.

Known Issues
--------
None yet

Bug Fixes
---------
TODO

Apache Edgent (incubating) 1.0.0
==================
The first official Apache Edgent release
Expand Down
6 changes: 3 additions & 3 deletions binary-release/LICENSE
Expand Up @@ -245,10 +245,10 @@ connectors/http/ext

--------------------------------
connectors/iotp/ext
watson-iot-0.1.5.jar com.ibm.messaging:watson-iot:0.1.5
LICENSE: EPL-1.0 For details, see licenses/binary-release/watson-iot-0.1.5.EPL-1.0
watson-iot-0.2.2.jar com.ibm.messaging:watson-iot:0.2.2
LICENSE: EPL-1.0 For details, see licenses/binary-release/watson-iot-0.2.2.EPL-1.0
Only binary form content is included.
https://mvnrepository.com/artifact/com.ibm.messaging/watson-iot/0.1.5
https://mvnrepository.com/artifact/com.ibm.messaging/watson-iot/0.2.2

commons-codec-1.10.jar org.apache.commons:commons-codec:1.10
LICENSE: AL-2.0 For details, see licenses/binary-release/commons-codec-1.10.AL-2.0
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -78,7 +78,7 @@ rat {
'licenses/binary-release/javax.websocket-api-1.0.CDDL-1.1', // OK, only binary form content
'licenses/binary-release/mqttv3-1.0.2.EDL-1.0', // OK, EDL-1.0
'licenses/binary-release/mqttv3-1.1.0.EDL-1.0', // OK, EDL-1.0
'licenses/binary-release/watson-iot-0.1.5.EPL-1.0', // OK, only binary form content
'licenses/binary-release/watson-iot-0.2.2.EPL-1.0', // OK, only binary form content
'samples/**/*.properties',
'samples/**/device.cfg',
'scripts/**/*.properties',
Expand Down Expand Up @@ -321,7 +321,7 @@ subprojects {
// e.g.,
// dependencies {
// addTargetDirProjectJarDependency 'compile', ':api:topology' # NOT compile project(':api:topology')
// addProjectExtDependency 'compile', 'com.ibm.messaging:watson-iot:0.1.5' # NOT compile 'com.ibm.messaging:watson-iot:0.1.5'
// addProjectExtDependency 'compile', 'com.ibm.messaging:watson-iot:0.2.2' # NOT compile 'com.ibm.messaging:watson-iot:0.2.2'
// addProjectExtDependency 'compile', 'org.apache.kafka:kafka_2.10:0.8.2.2@jar'
// addTargetDirCoreExtDependencies 'compile'
// addMyTargetDirProjectJarDependency 'testCompile'
Expand Down
2 changes: 1 addition & 1 deletion connectors/.classpath
Expand Up @@ -32,7 +32,7 @@
<classpathentry kind="lib" path="../externalJars/java8/connectors/http/ext/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="../externalJars/java8/connectors/http/ext/httpclient-4.5.1.jar"/>
<classpathentry kind="lib" path="../externalJars/java8/connectors/http/ext/httpcore-4.4.4.jar"/>
<classpathentry kind="lib" path="../externalJars/java8/connectors/iotp/ext/watson-iot-0.1.5.jar"/>
<classpathentry kind="lib" path="../externalJars/java8/connectors/iotp/ext/watson-iot-0.2.2.jar"/>
<classpathentry kind="lib" path="../externalJars/java8/connectors/iotp/ext/commons-lang3-3.4.jar"/>
<classpathentry kind="lib" path="../externalJars/java8/connectors/iotp/ext/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="../externalJars/java8/connectors/iotp/ext/commons-logging-1.2.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion connectors/iotp/build.gradle
Expand Up @@ -19,7 +19,7 @@ under the License.
dependencies {
addTargetDirProjectJarDependency 'compile', ':api:topology'
addTargetDirProjectJarDependency 'compile', ':connectors:iot'
addProjectExtDependency 'compile', 'com.ibm.messaging:watson-iot:0.1.5'
addProjectExtDependency 'compile', 'com.ibm.messaging:watson-iot:0.2.2'
addTargetDirCoreExtJarDependencies 'compile'

addTargetDirProjectJarDependency 'testCompile', ':providers:direct'
Expand Down
Expand Up @@ -71,7 +71,14 @@ Licensed to the Apache Software Foundation (ASF) under one
* <BR>
* See the IBM Watson IoT Platform documentation for Developing devices at
* <a href="https://internetofthings.ibmcloud.com/">https://internetofthings.ibmcloud.com/</a>
*
* <p>
* See <a href="https://github.com/ibm-watson-iot/iot-java/releases">WIoTP Java Client Library Releases</a>
* for general information.
* <p>
* See <a href="https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021">WIoTP Migration from release 0.1.5 to 0.2.1</a>
* for details of changes that occurred to device event payloads
* and how to revert the behavior if needed.
* <p>
* @see <a href="{@docRoot}/org/apache/edgent/connectors/iot/package-summary.html">Edgent generic device model</a>
* @see org.apache.edgent.samples.connectors.iotp.IotpSensors Sample application
*/
Expand Down Expand Up @@ -278,21 +285,31 @@ public TStream<JsonObject> commands(String... commands) {
return all.map(cmd -> {
JsonObject full = new JsonObject();
full.addProperty("command", cmd.getCommand());
full.addProperty("tsms", cmd.getTimestamp().getMillis());
full.addProperty("tsms", System.currentTimeMillis());
full.addProperty("format", cmd.getFormat());
if ("json".equals(cmd.getFormat())) {
if ("json".equalsIgnoreCase(cmd.getFormat())) {
JsonParser parser = new JsonParser();
// iot-java 0.2.2 bug https://github.com/ibm-watson-iot/iot-java/issues/81
// cmd.getData() returns byte[] instead of JsonObject (or String).
// Must continue to use the deprecated method until that's fixed.
// final JsonObject jsonPayload = (JsonObject) cmd.getData();
// final JsonObject jsonPayload = (JsonObject) parser.parse((String)cmd.getData());
@SuppressWarnings("deprecation")
final JsonObject jsonPayload = (JsonObject) parser.parse(cmd.getPayload());
final JsonObject cmdData;
// wiotp java client API >= 0.2.1 (other clients earlier?)
// A json fmt command's msg payload may or may not have "d" wrapping of
// the actual command data.
// The wiotp client API doesn't mask that from clients
// so deal with that here.
if (jsonPayload.has("d")) {
cmdData = jsonPayload.getAsJsonObject("d");
} else {
// No data, create an empty object.
cmdData = new JsonObject();
cmdData = jsonPayload;
}
full.add("payload", cmdData);
} else {
full.addProperty("payload", cmd.getPayload());
full.addProperty("payload", cmd.getData().toString());
}
return full;

Expand Down
2 changes: 1 addition & 1 deletion samples/.classpath
Expand Up @@ -19,7 +19,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/runtime"/>
<classpathentry combineaccessrules="false" kind="src" path="/provider_iot"/>
<classpathentry combineaccessrules="false" kind="src" path="/apps"/>
<classpathentry kind="lib" path="../externalJars/java8/connectors/iotp/ext/watson-iot-0.1.5.jar"/>
<classpathentry kind="lib" path="../externalJars/java8/connectors/iotp/ext/watson-iot-0.2.2.jar"/>
<classpathentry kind="lib" path="../externalJars/java8/connectors/iotp/ext/org.eclipse.paho.client.mqttv3-1.1.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
18 changes: 18 additions & 0 deletions scripts/connectors/iotp/runiotpquickstart.sh
Expand Up @@ -32,3 +32,21 @@ edgent=../../..
export CLASSPATH=${edgent}/samples/lib/edgent.samples.connectors.jar

java org.apache.edgent.samples.connectors.iotp.IotpQuickstart

# Avoid a paho mqtt class security exception.
# The connector samples jar has dependencies on both the iotp and mqtt connectors
# and those have dependencies on different versions of the paho mqtt jar.
# Ensure the right one is used for this sample.
#
#export CLASSPATH=${edgent}/samples/lib/edgent.samples.connectors.jar
IOTP_MQTT_JAR=`ls ${edgent}/connectors/iotp/ext/org.eclipse.paho.client.mqtt*.jar`
export CLASSPATH=${IOTP_MQTT_JAR}:${edgent}/samples/lib/edgent.samples.connectors.jar

# https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021
# Uncomment the following to use the pre-0.2.1 WIoTP client behavior.
#
#USE_OLD_EVENT_FORMAT=-Dcom.ibm.iotf.enableCustomFormat=false

VM_OPTS=${USE_OLD_EVENT_FORMAT}

java ${VM_OPTS} org.apache.edgent.samples.connectors.iotp.IotpQuickstart
12 changes: 10 additions & 2 deletions scripts/connectors/iotp/runiotpquickstart2.sh
Expand Up @@ -27,14 +27,22 @@ edgent=../../..
#
# The application prints out a URL which allows a browser
# to see the data being sent from this sample to
# IBM Watson IoT Plaform Quickstart sample.
# IBM Watson IoT Platform Quickstart sample.

# Avoid a paho mqtt class security exception.
# The connector samples jar has dependencies on both the iotp and mqtt connectors
# and those have dependencies on different versions of the paho mqtt jar.
# Ensure the right one is used for this sample.
#
#export CLASSPATH=${edgent}/samples/lib/edgent.samples.connectors.jar
IOTP_MQTT_JAR=`ls ${edgent}/connectors/iotp/ext/org.eclipse.paho.client.mqtt*.jar`
export CLASSPATH=${IOTP_MQTT_JAR}:${edgent}/samples/lib/edgent.samples.connectors.jar

java org.apache.edgent.samples.connectors.iotp.IotpQuickstart2 $*
# https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021
# Uncomment the following to use the pre-0.2.1 WIoTP client behavior.
#
#USE_OLD_EVENT_FORMAT=-Dcom.ibm.iotf.enableCustomFormat=false

VM_OPTS=${USE_OLD_EVENT_FORMAT}

java ${VM_OPTS} org.apache.edgent.samples.connectors.iotp.IotpQuickstart2 $*
18 changes: 16 additions & 2 deletions scripts/connectors/iotp/runiotpsensors.sh
Expand Up @@ -30,6 +30,20 @@ edgent=../../..
# IBM Watson IoT Platform and a sample is in this directory
# (omitting values for the authorization tokens).

export CLASSPATH=${edgent}/samples/lib/edgent.samples.connectors.jar
# Avoid a paho mqtt class security exception.
# The connector samples jar has dependencies on both the iotp and mqtt connectors
# and those have dependencies on different versions of the paho mqtt jar.
# Ensure the right one is used for this sample.
#
#export CLASSPATH=${edgent}/samples/lib/edgent.samples.connectors.jar
IOTP_MQTT_JAR=`ls ${edgent}/connectors/iotp/ext/org.eclipse.paho.client.mqtt*.jar`
export CLASSPATH=${IOTP_MQTT_JAR}:${edgent}/samples/lib/edgent.samples.connectors.jar

# https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021
# Uncomment the following to use the pre-0.2.1 WIoTP client behavior.
#
#USE_OLD_EVENT_FORMAT=-Dcom.ibm.iotf.enableCustomFormat=false

VM_OPTS=${USE_OLD_EVENT_FORMAT}

java org.apache.edgent.samples.connectors.iotp.IotpSensors $1
java ${VM_OPTS} org.apache.edgent.samples.connectors.iotp.IotpSensors $1

0 comments on commit 261c7ee

Please sign in to comment.