Skip to content

Commit b8f2563

Browse files
Merge pull request #629 from watson-developer-cloud/develop
3.7.1
2 parents add98fe + a493dd4 commit b8f2563

File tree

42 files changed

+1219
-115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1219
-115
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
Change Log
22
==========
33

4+
## Version 3.7.1
5+
6+
_2017-03-31_
7+
8+
9+
* Fix: Enable all cipher suites cf58894 74cae1b
10+
* Fix: `afterEvaluate` source for docs task 0f93ec3
11+
* Fix: Disable HTML escaping, #532 c6497ed
12+
* Fix: CheckStyle d5ccc68 9a7654b 9a7654b
13+
* Fix: Examples link in README.md 430f3a6 by @rborer
14+
15+
* Doc: Exclude tests from javadoc generation 60e80de
16+
* Doc: Update HTTP logging information #496 85e2424
17+
18+
* New: Add aggregate Javadocs plugin b6d1123
19+
* New: Add tradeoff analytics test case for #306 9f40779
20+
* New: Adds an HTTPLogging interceptor #496 620d8d9
21+
* New: Unit tests for Natural Language Understanding 5e89f3a
22+
423
## Version 3.7.0
524

625
_2017-03-19_

README.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ APIs and SDKs that use cognitive computing to solve complex problems.
4040
* [Android](#android)
4141
* [Running in Bluemix](#running-in-bluemix)
4242
* [Default Headers](#default-headers)
43+
* [Debug](#debug)
4344
* [Eclipse and Intellij](#working-with-eclipse-and-intellij-idea)
4445
* [License](#license)
4546
* [Contributing](#contributing)
@@ -53,7 +54,7 @@ All the services:
5354
<dependency>
5455
<groupId>com.ibm.watson.developer_cloud</groupId>
5556
<artifactId>java-sdk</artifactId>
56-
<version>3.7.0</version>
57+
<version>3.7.1</version>
5758
</dependency>
5859
```
5960

@@ -62,25 +63,25 @@ Only Retrieve and Rank:
6263
<dependency>
6364
<groupId>com.ibm.watson.developer_cloud</groupId>
6465
<artifactId>retrieve-and-rank</artifactId>
65-
<version>3.7.0</version>
66+
<version>3.7.1</version>
6667
</dependency>
6768
```
6869

6970
##### Gradle
7071

7172
All the services:
7273
```gradle
73-
'com.ibm.watson.developer_cloud:java-sdk:3.7.0'
74+
'com.ibm.watson.developer_cloud:java-sdk:3.7.1'
7475
```
7576

7677
Only Retrieve and Rank:
7778
```gradle
78-
'com.ibm.watson.developer_cloud:retrieve-and-rank:3.7.0'
79+
'com.ibm.watson.developer_cloud:retrieve-and-rank:3.7.1'
7980
```
8081

8182
Only Visual Recognition:
8283
```gradle
83-
'com.ibm.watson.developer_cloud:visual-recognition:3.7.0'
84+
'com.ibm.watson.developer_cloud:visual-recognition:3.7.1'
8485
```
8586

8687
Snapshots of the development version are available in [Sonatype's snapshots repository][sonatype_snapshots].
@@ -90,7 +91,7 @@ Snapshots of the development version are available in [Sonatype's snapshots repo
9091

9192
Download the jar with dependencies [here][jar].
9293

93-
Now, you are ready to see some [examples](https://github.com/watson-developer-cloud/java-sdk/tree/master/examples/java/com/ibm/watson/developer_cloud).
94+
Now, you are ready to see some [examples](https://github.com/watson-developer-cloud/java-sdk/tree/master/examples/src/main/java/com/ibm/watson/developer_cloud).
9495

9596

9697
## Usage
@@ -248,6 +249,34 @@ service.setDefaultHeaders(headers);
248249

249250
// All the api calls from now on will send the default headers
250251
```
252+
## Debug
253+
254+
HTTP requests can be logging by adding a `loggging.properties` file to your classpath.
255+
256+
```none
257+
handlers=java.util.logging.ConsoleHandler
258+
java.util.logging.ConsoleHandler.level=FINE
259+
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
260+
java.util.logging.SimpleFormatter.format=%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s %4$s: %5$s%n
261+
.level=SEVERE
262+
# HTTP Logging - Basic
263+
com.ibm.watson.developer_cloud.util.HttpLogging.level=INFO
264+
```
265+
266+
The configuration above will log only the URL and query parameters for each request.
267+
268+
For example:
269+
```none
270+
Mar 30, 2017 7:31:22 PM okhttp3.internal.platform.Platform log
271+
INFO: --> POST https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/dilemmas?generate_visualization=false http/1.1 (923-byte body)
272+
Mar 30, 2017 7:31:22 PM okhttp3.internal.platform.Platform log
273+
INFO: <-- 200 OK https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/dilemmas?generate_visualization=false (104ms, unknown-length body)
274+
Mar 30, 2017 7:31:23 PM okhttp3.internal.platform.Platform log
275+
INFO: --> POST https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/dilemmas?generate_visualization=true http/1.1 (12398-byte body)
276+
Mar 30, 2017 7:31:35 PM okhttp3.internal.platform.Platform log
277+
INFO: <-- 200 OK https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/dilemmas?generate_visualization=true (12311ms, unknown-length body)
278+
```
279+
**Warning:** The logs generated by this logger when using the level `FINE` or `ALL` has the potential to leak sensitive information such as "Authorization" or "Cookie" headers and the contents of request and response bodies. This data should only be logged in a controlled way or in a non-production environment.
251280

252281
## Build + Test
253282

@@ -257,7 +286,7 @@ Gradle:
257286

258287
```sh
259288
$ cd java-sdk
260-
$ gradle jar # build jar file (build/libs/watson-developer-cloud-3.7.0.jar)
289+
$ gradle jar # build jar file (build/libs/watson-developer-cloud-3.7.1.jar)
261290
$ gradle test # run tests
262291
$ gradle check # performs quality checks on source files and generates reports
263292
$ gradle testReport # run tests and generate the aggregated test report (build/reports/allTests)
@@ -294,4 +323,4 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
294323
[apache_maven]: http://maven.apache.org/
295324
[sonatype_snapshots]: https://oss.sonatype.org/content/repositories/snapshots/com/ibm/watson/developer_cloud/
296325

297-
[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-3.7.0/java-sdk-3.7.0-jar-with-dependencies.jar
326+
[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-3.7.1/java-sdk-3.7.1-jar-with-dependencies.jar

alchemy/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<dependency>
88
<groupId>com.ibm.watson.developer_cloud</groupId>
99
<artifactId>alchemy</artifactId>
10-
<version>3.7.0</version>
10+
<version>3.7.1</version>
1111
</dependency>
1212
```
1313

1414
##### Gradle
1515
```gradle
16-
'com.ibm.watson.developer_cloud:alchemy:3.7.0'
16+
'com.ibm.watson.developer_cloud:alchemy:3.7.1'
1717
```
1818

1919
## Alchemy Language

alchemy/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Concept.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class Concept extends GenericModel {
8282

8383
/** The knowledge graph. */
8484
private KnowledgeGraph knowledgeGraph;
85-
85+
8686
/**
8787
* Gets the knowledge graph.
8888
*

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ subprojects {
5252
afterEvaluate {
5353
if (plugins.hasPlugin(JavaPlugin)) {
5454
rootProject.tasks.docs {
55-
source += files(sourceSets.collect { srcSet -> srcSet.allJava })
55+
source += files(sourceSets.main.allJava)
5656
classpath += files(sourceSets*.compileClasspath)
5757
}
5858
}

conversation/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<dependency>
88
<groupId>com.ibm.watson.developer_cloud</groupId>
99
<artifactId>conversation</artifactId>
10-
<version>3.7.0</version>
10+
<version>3.7.1</version>
1111
</dependency>
1212
```
1313

1414
##### Gradle
1515
```gradle
16-
'com.ibm.watson.developer_cloud:conversation:3.7.0'
16+
'com.ibm.watson.developer_cloud:conversation:3.7.1'
1717
```
1818

1919
## Usage

core/src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.io.IOException;
1616
import java.net.CookieManager;
1717
import java.net.CookiePolicy;
18+
import java.util.Arrays;
1819
import java.util.Map;
1920
import java.util.concurrent.TimeUnit;
2021
import java.util.logging.Level;
@@ -40,13 +41,15 @@
4041
import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException;
4142
import com.ibm.watson.developer_cloud.service.exception.UnsupportedException;
4243
import com.ibm.watson.developer_cloud.util.CredentialUtils;
44+
import com.ibm.watson.developer_cloud.util.HttpLogging;
4345
import com.ibm.watson.developer_cloud.util.RequestUtils;
4446
import com.ibm.watson.developer_cloud.util.ResponseConverterUtils;
4547
import com.ibm.watson.developer_cloud.util.ResponseUtils;
4648

4749
import jersey.repackaged.jsr166e.CompletableFuture;
4850
import okhttp3.Call;
4951
import okhttp3.Callback;
52+
import okhttp3.ConnectionSpec;
5053
import okhttp3.Credentials;
5154
import okhttp3.Headers;
5255
import okhttp3.HttpUrl;
@@ -124,6 +127,14 @@ protected OkHttpClient configureHttpClient() {
124127
builder.writeTimeout(60, TimeUnit.SECONDS);
125128
builder.readTimeout(90, TimeUnit.SECONDS);
126129

130+
builder.addNetworkInterceptor(HttpLogging.getLoggingInterceptor());
131+
132+
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
133+
.allEnabledCipherSuites()
134+
.build();
135+
136+
builder.connectionSpecs(Arrays.asList(spec, ConnectionSpec.CLEARTEXT));
137+
127138
return builder.build();
128139
}
129140

core/src/main/java/com/ibm/watson/developer_cloud/util/GsonSingleton.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private static Gson createGson(Boolean prettyPrint) {
4444
if (prettyPrint) {
4545
builder.setPrettyPrinting();
4646
}
47-
47+
builder.disableHtmlEscaping();
4848
return builder.create();
4949
}
5050

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2017 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.watson.developer_cloud.util;
14+
15+
import java.util.logging.Logger;
16+
17+
import okhttp3.logging.HttpLoggingInterceptor;
18+
import okhttp3.logging.HttpLoggingInterceptor.Level;
19+
20+
/**
21+
* HttpLogging logs HTTP request and response data.
22+
*
23+
* Instantiates a new HTTP logging. The logging level will be determinate by the {@link Logger} used in this class.
24+
* Basic HTTP request response will be log if Level is INFO, HEADERS if level is FINE and all the bodies if Level is
25+
* ALL.
26+
*/
27+
public class HttpLogging {
28+
private static final Logger LOG = Logger.getLogger(HttpLogging.class.getName());
29+
30+
private HttpLogging() { }
31+
32+
private static final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
33+
static {
34+
if (LOG.isLoggable(java.util.logging.Level.ALL)) {
35+
loggingInterceptor.setLevel(Level.BODY);
36+
} else if (LOG.isLoggable(java.util.logging.Level.FINE)) {
37+
loggingInterceptor.setLevel(Level.HEADERS);
38+
} else if (LOG.isLoggable(java.util.logging.Level.INFO)) {
39+
loggingInterceptor.setLevel(Level.BASIC);
40+
}
41+
}
42+
43+
public static HttpLoggingInterceptor getLoggingInterceptor() {
44+
return loggingInterceptor;
45+
}
46+
}

core/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ private void setupLogging() {
150150
(ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
151151
root.setLevel(ch.qos.logback.classic.Level.OFF);
152152
try {
153-
FileInputStream configFile = new FileInputStream("src/test/resources/logging.properties");
153+
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
154+
InputStream configFile = classLoader.getResourceAsStream("logging.properties");
154155
LogManager.getLogManager().readConfiguration(configFile);
155156
} catch (IOException ex) {
156157
System.out.println("WARNING: Could not open configuration file");

0 commit comments

Comments
 (0)