From bb39ee29f68a02b05c24d1704d8d82bf49518915 Mon Sep 17 00:00:00 2001 From: Sina Madani Date: Mon, 29 Jan 2024 10:17:44 +0000 Subject: [PATCH] chore: Bump version & misc cleanup (#511) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Address some IDE warnings * Bump Java version in CI * Bump version: v8.1.0 → v8.2.0 * Use Java 17 for publish * Update build.gradle --- .bumpversion.cfg | 2 +- .github/workflows/build.yml | 8 +++--- .github/workflows/publish.yml | 4 +-- CHANGELOG.md | 7 ++--- README.md | 4 +-- build.gradle | 9 ++++-- .../com/vonage/client/AbstractMethod.java | 6 ++-- .../java/com/vonage/client/HttpWrapper.java | 2 +- .../client/auth/hashutils/HashUtil.java | 2 +- .../numberinsight2/NumberInsight2Client.java | 16 +++++------ .../client/numbers/ListNumbersResponse.java | 6 ++-- .../client/numbers/SearchNumbersResponse.java | 6 ++-- .../vonage/client/redact/RedactClient.java | 13 ++++----- .../client/sms/messages/BinaryMessage.java | 4 +-- .../client/subaccounts/AbstractTransfer.java | 5 ---- .../vonage/client/verify/VerifyDetails.java | 2 +- .../java/com/vonage/client/video/Archive.java | 2 +- .../com/vonage/client/video/Broadcast.java | 10 +++---- .../video/OPENTOK_TO_VONAGE_MIGRATION.md | 28 +++++++++---------- .../client/voice/ncco/ConversationAction.java | 6 ++-- src/main/webapp/WEB-INF/web.xml | 14 ---------- 21 files changed, 69 insertions(+), 87 deletions(-) delete mode 100644 src/main/webapp/WEB-INF/web.xml diff --git a/.bumpversion.cfg b/.bumpversion.cfg index b50b5cffe..3809dd2c8 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,7 @@ [bumpversion] commit = True tag = False -current_version = v8.1.0 +current_version = v8.2.0 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? serialize = {major}.{minor}.{patch}-{release}{build} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14988274b..e42f8a665 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,15 +24,15 @@ jobs: strategy: fail-fast: false matrix: - java: [8, 11, 17] + java: [8, 11, 20] os: [ubuntu-latest, macos-latest, windows-latest] steps: - name: Checkout the repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: ${{ matrix.java }} @@ -41,7 +41,7 @@ jobs: run: chmod +x gradlew - name: Cache Gradle packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fec30df9a..2913fe3f5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,14 +25,14 @@ jobs: with: ref: ${{ github.event.release.target_commitish }} - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: 'temurin' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Cache Gradle packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} diff --git a/CHANGELOG.md b/CHANGELOG.md index a4fad597f..98d4f9075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -249,7 +249,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Bumped dependency versions ## [6.4.0] - 2021-05-28 -- Adding Random From Number Feature for the Voice API, if set to `true`, the from number will be randomly selected from the pool of numbers available to the application making the call. +- Adding Random From Number Feature for the Voice API, if set to `true`, the `from` number will be randomly selected from the pool of numbers available to the application making the call. - adjusting operator used to check json payloads - Adding extra parsing for top level Roaming Status in Advanced Number Insights @@ -585,8 +585,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [2.0.1] - 2017-03-18 ### Changed -- Made servlet-api an optional dependency so it isn't bundled in war files. (This - could result in class conflicts in Tomcat.) +- Made servlet-api an optional dependency, so it isn't bundled in WAR files. (This could result in class conflicts in Tomcat.) ## [2.0.0] - 2017-03-16 ### Added @@ -630,7 +629,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Correcting some comments and log statements - Fix some small things reported by findbugs -- Re-factor NexmoSmsClient. There are now sub-classes of this client class depending on the level of security required +- Re-factor NexmoSmsClient. There are now subclasses of this client class depending on the level of security required - `com.nexmo.messaging.sdk.NexmoSmsClient`: The default client - `com.nexmo.messaging.sdk.NexmoSmsClientSSL`: Uses SSL / HTTPS to encrypt the requests - `com.nexmo.messaging.sdk.NexmoSmsClientSignedRequests`: Signs the requests using the secret key assigned to your account diff --git a/README.md b/README.md index 6d9d954e1..601e8a944 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,9 @@ See all of our SDKs and integrations on the [Vonage Developer portal](https://de ## Installation -Releases are published to [Maven Central](https://central.sonatype.com/artifact/com.vonage/server-sdk/8.1.0/snippets). +Releases are published to [Maven Central](https://central.sonatype.com/artifact/com.vonage/server-sdk/8.2.0/snippets). Instructions for your build system can be found in the snippets section. -They're also available from [here](https://mvnrepository.com/artifact/com.vonage/server-sdk/8.1.0). +They're also available from [here](https://mvnrepository.com/artifact/com.vonage/server-sdk/8.2.0). Release notes can be found in the [changelog](CHANGELOG.md). ### Build It Yourself diff --git a/build.gradle b/build.gradle index 259e914d4..009fa52a0 100644 --- a/build.gradle +++ b/build.gradle @@ -9,9 +9,7 @@ plugins { group = "com.vonage" archivesBaseName = "server-sdk" -version = "8.1.0" -sourceCompatibility = "1.8" -targetCompatibility = "1.8" +version = "8.2.0" ext.githubPath = 'Vonage/vonage-java-sdk' @@ -23,6 +21,11 @@ repositories { mavenCentral() } +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = sourceCompatibility +} + dependencies { def jacksonVersion = '2.16.1' def httpclientVersion = '4.5.14' diff --git a/src/main/java/com/vonage/client/AbstractMethod.java b/src/main/java/com/vonage/client/AbstractMethod.java index e5a84152c..469e952f5 100644 --- a/src/main/java/com/vonage/client/AbstractMethod.java +++ b/src/main/java/com/vonage/client/AbstractMethod.java @@ -19,7 +19,6 @@ import com.vonage.client.auth.JWTAuthMethod; import com.vonage.client.auth.SignatureAuthMethod; import com.vonage.client.auth.TokenAuthMethod; -import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpUriRequest; @@ -46,7 +45,10 @@ * response */ public abstract class AbstractMethod implements RestEndpoint { - private static final Log LOG = LogFactory.getLog(AbstractMethod.class); + static { + LogFactory.getLog(AbstractMethod.class); + } + protected static final BasicResponseHandler basicResponseHandler = new BasicResponseHandler(); protected final HttpWrapper httpWrapper; diff --git a/src/main/java/com/vonage/client/HttpWrapper.java b/src/main/java/com/vonage/client/HttpWrapper.java index 3bb061c58..664b7fbbb 100644 --- a/src/main/java/com/vonage/client/HttpWrapper.java +++ b/src/main/java/com/vonage/client/HttpWrapper.java @@ -30,7 +30,7 @@ */ public class HttpWrapper { private static final String CLIENT_NAME = "vonage-java-sdk"; - private static final String CLIENT_VERSION = "8.1.0"; + private static final String CLIENT_VERSION = "8.2.0"; private static final String JAVA_VERSION = System.getProperty("java.version"); private static final String USER_AGENT = String.format("%s/%s java/%s", CLIENT_NAME, CLIENT_VERSION, JAVA_VERSION); diff --git a/src/main/java/com/vonage/client/auth/hashutils/HashUtil.java b/src/main/java/com/vonage/client/auth/hashutils/HashUtil.java index f66773245..1af2588f9 100644 --- a/src/main/java/com/vonage/client/auth/hashutils/HashUtil.java +++ b/src/main/java/com/vonage/client/auth/hashutils/HashUtil.java @@ -26,7 +26,7 @@ */ public class HashUtil { - private static Map hashTypes = new HashMap() {{ + private static final Map hashTypes = new HashMap() {{ put(HashType.MD5, new Md5Hasher()); put(HashType.HMAC_SHA1, new HmacSha1Hasher()); put(HashType.HMAC_MD5, new HmacMd5Hasher()); diff --git a/src/main/java/com/vonage/client/numberinsight2/NumberInsight2Client.java b/src/main/java/com/vonage/client/numberinsight2/NumberInsight2Client.java index 34aed511f..671c35db8 100644 --- a/src/main/java/com/vonage/client/numberinsight2/NumberInsight2Client.java +++ b/src/main/java/com/vonage/client/numberinsight2/NumberInsight2Client.java @@ -34,23 +34,21 @@ public class NumberInsight2Client { * * @param wrapper (REQUIRED) shared HTTP wrapper object used for making REST calls. */ - @SuppressWarnings("unchecked") public NumberInsight2Client(HttpWrapper wrapper) { - - class Endpoint extends DynamicEndpoint { - Endpoint(HttpMethod method, R... type) { + @SuppressWarnings("unchecked") + final class Endpoint extends DynamicEndpoint { + Endpoint(R... type) { super(DynamicEndpoint. builder(type) .authMethod(TokenAuthMethod.class) .responseExceptionType(NumberInsight2ResponseException.class) - .requestMethod(method).wrapper(wrapper).pathGetter((de, req) -> { - String base = de.getHttpWrapper().getHttpConfig().getApiBaseUri(); - return base + "/v2/ni"; - }) + .requestMethod(HttpMethod.POST).wrapper(wrapper).pathGetter((de, req) -> + de.getHttpWrapper().getHttpConfig().getApiBaseUri() + "/v2/ni" + ) ); } } - fraudCheck = new Endpoint<>(HttpMethod.POST); + fraudCheck = new Endpoint<>(); } /** diff --git a/src/main/java/com/vonage/client/numbers/ListNumbersResponse.java b/src/main/java/com/vonage/client/numbers/ListNumbersResponse.java index 4183ce5ac..9bafb3c6a 100644 --- a/src/main/java/com/vonage/client/numbers/ListNumbersResponse.java +++ b/src/main/java/com/vonage/client/numbers/ListNumbersResponse.java @@ -27,8 +27,8 @@ @JsonInclude(value = JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class ListNumbersResponse extends JsonableBaseObject { - private int count = 0; - private OwnedNumber[] numbers = new OwnedNumber[0]; + private int count; + private OwnedNumber[] numbers; @JsonProperty("count") public int getCount() { @@ -37,7 +37,7 @@ public int getCount() { @JsonProperty("numbers") public OwnedNumber[] getNumbers() { - return numbers; + return numbers != null ? numbers : new OwnedNumber[0]; } public static ListNumbersResponse fromJson(String json) { diff --git a/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java b/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java index eaf4f3b51..44276e53a 100644 --- a/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java +++ b/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java @@ -27,8 +27,8 @@ @JsonInclude(value = JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class SearchNumbersResponse extends JsonableBaseObject { - private int count = 0; - private AvailableNumber[] numbers = new AvailableNumber[]{}; + private int count; + private AvailableNumber[] numbers; /** * @return the number of responses returned by the Vonage API. @@ -44,7 +44,7 @@ public int getCount() { */ @JsonProperty("numbers") public AvailableNumber[] getNumbers() { - return numbers; + return numbers != null ? numbers : new AvailableNumber[0]; } public static SearchNumbersResponse fromJson(String json) { diff --git a/src/main/java/com/vonage/client/redact/RedactClient.java b/src/main/java/com/vonage/client/redact/RedactClient.java index 89b3158b7..5d2c6ee34 100644 --- a/src/main/java/com/vonage/client/redact/RedactClient.java +++ b/src/main/java/com/vonage/client/redact/RedactClient.java @@ -30,19 +30,18 @@ public class RedactClient { public RedactClient(HttpWrapper wrapper) { @SuppressWarnings("unchecked") final class Endpoint extends DynamicEndpoint { - Endpoint(String path, HttpMethod method, R... type) { + Endpoint(R... type) { super(DynamicEndpoint. builder(type) - .wrapper(wrapper).requestMethod(method).applyAsBasicAuth() + .wrapper(wrapper).requestMethod(HttpMethod.POST).applyAsBasicAuth() .responseExceptionType(VonageBadRequestException.class) .authMethod(SignatureAuthMethod.class, TokenAuthMethod.class) - .pathGetter((de, req) -> { - String base = de.getHttpWrapper().getHttpConfig().getVersionedApiBaseUri("v1"); - return base + path; - }) + .pathGetter((de, req) -> de.getHttpWrapper().getHttpConfig() + .getVersionedApiBaseUri("v1") + "/redact/transaction" + ) ); } } - redactTransaction = new Endpoint<>("/redact/transaction", HttpMethod.POST); + redactTransaction = new Endpoint<>(); } /** diff --git a/src/main/java/com/vonage/client/sms/messages/BinaryMessage.java b/src/main/java/com/vonage/client/sms/messages/BinaryMessage.java index 60ba100ad..b583c2e9c 100644 --- a/src/main/java/com/vonage/client/sms/messages/BinaryMessage.java +++ b/src/main/java/com/vonage/client/sms/messages/BinaryMessage.java @@ -35,7 +35,7 @@ public class BinaryMessage extends Message { * This api, and the Vonage sms service will send this data 'as-is' (in conjunction with the binary UDH) and will not make any corrections. * so you should ensure that it is a correctly constructed message * @param udh Most binary content will require a UserDataHeader portion of the message containing commands to enable the handset to interpret the binary data - * (for example, a binary ringtone, a wap-push, OverTheAir configuration, etc). + * (for example, a binary ringtone, a wap-push, OverTheAir configuration etc.). * Additionally, if you are sending a long text message as multiple concatenated messages and are performing this operation manually rather than * using the automated long sms handling in the Vonage sms service, then you will need to construct and include here an appropriate * UserDataHeader field that describes the segmentation/re-assembly fields required to successfully concatenate multiple short messages. @@ -61,7 +61,7 @@ public byte[] getMessageBody() { /** * @return byte[] Most binary content will require a UserDataHeader portion of the message containing commands to enable the handset to interpret the binary data - * (for example, a binary ringtone, a wap-push, OverTheAir configuration, etc). + * (for example, a binary ringtone, a wap-push, OverTheAir configuration, etc.). * Additionally, if you are sending a long text message as multiple concatenated messages and are performing this operation manually rather than * using the automated long sms handling in the Vonage sms service, then you will need to construct and include here an appropriate * UserDataHeader field that describes the segmentation/re-assembly fields required to successfully concatenate multiple short messages. diff --git a/src/main/java/com/vonage/client/subaccounts/AbstractTransfer.java b/src/main/java/com/vonage/client/subaccounts/AbstractTransfer.java index 3edb5e796..980bff593 100644 --- a/src/main/java/com/vonage/client/subaccounts/AbstractTransfer.java +++ b/src/main/java/com/vonage/client/subaccounts/AbstractTransfer.java @@ -74,11 +74,6 @@ public String getFrom() { public String getTo() { return to; } - - @Override - public String toString() { - return getClass().getSimpleName()+' '+toJson(); - } @SuppressWarnings("unchecked") protected abstract static class Builder> { diff --git a/src/main/java/com/vonage/client/verify/VerifyDetails.java b/src/main/java/com/vonage/client/verify/VerifyDetails.java index 9da3c8c6c..3faa447fb 100644 --- a/src/main/java/com/vonage/client/verify/VerifyDetails.java +++ b/src/main/java/com/vonage/client/verify/VerifyDetails.java @@ -32,7 +32,7 @@ public class VerifyDetails extends JsonableBaseObject { private Date dateSubmitted, dateFinalized, firstEventDate, lastEventDate; private Status status; private BigDecimal price, estimatedPriceMessagesSent; - private List checks = new ArrayList<>(); + private List checks = new ArrayList<>(0); /** * @return The {@code request_id} that you received in the response to the diff --git a/src/main/java/com/vonage/client/video/Archive.java b/src/main/java/com/vonage/client/video/Archive.java index d9d189b9f..148cf3b21 100644 --- a/src/main/java/com/vonage/client/video/Archive.java +++ b/src/main/java/com/vonage/client/video/Archive.java @@ -173,7 +173,7 @@ public static Builder builder(String sessionId) { } /** - * Used to construct a Archive object. + * Used to construct an Archive object. * * @see Archive */ diff --git a/src/main/java/com/vonage/client/video/Broadcast.java b/src/main/java/com/vonage/client/video/Broadcast.java index 67636e5ec..5dd34895f 100644 --- a/src/main/java/com/vonage/client/video/Broadcast.java +++ b/src/main/java/com/vonage/client/video/Broadcast.java @@ -29,7 +29,7 @@ import java.util.Objects; /** - * Represents properties of a live streaming broadcast. + * Represents properties of a live-streaming broadcast. */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(value = JsonInclude.Include.NON_NULL) @@ -260,8 +260,8 @@ public Builder layout(StreamCompositionLayout layout) { * For each RTMP stream, specify serverUrl (the RTMP server URL), streamName * (the stream name, such as the YouTube Live stream name or the Facebook stream key), and * (optionally) id (a unique ID for the stream). If you specify an ID, it will be included in the REST call - * response and the REST method for getting information about a live streaming broadcast. Vonage streams - * the session to each RTMP URL you specify. Note that Vonage live streaming supports RTMP and RTMPS. + * response and the REST method for getting information about a live-streaming broadcast. Vonage streams + * the session to each RTMP URL you specify. Note that Vonage live-streaming supports RTMP and RTMPS. * * @param rtmp The RTMP stream to include in the broadcast. * @@ -278,8 +278,8 @@ public Builder addRtmpStream(Rtmp rtmp) { * For each RTMP stream, specify serverUrl (the RTMP server URL), streamName * (the stream name, such as the YouTube Live stream name or the Facebook stream key), and * (optionally) id (a unique ID for the stream). If you specify an ID, it will be included in the REST call - * response and the REST method for getting information about a live streaming broadcast. Vonage streams - * the session to each RTMP URL you specify. Note that Vonage live streaming supports RTMP and RTMPS. + * response and the REST method for getting information about a live-streaming broadcast. Vonage streams + * the session to each RTMP URL you specify. Note that Vonage live-streaming supports RTMP and RTMPS. * * @param rtmps The RTMP streams to include in the broadcast. * diff --git a/src/main/java/com/vonage/client/video/OPENTOK_TO_VONAGE_MIGRATION.md b/src/main/java/com/vonage/client/video/OPENTOK_TO_VONAGE_MIGRATION.md index 9a153dc1f..1dd6180e0 100644 --- a/src/main/java/com/vonage/client/video/OPENTOK_TO_VONAGE_MIGRATION.md +++ b/src/main/java/com/vonage/client/video/OPENTOK_TO_VONAGE_MIGRATION.md @@ -62,17 +62,17 @@ Many of these are straightforward and your IDE will help you with auto-completio ## Supported Features The following is a list of Vonage Video API features and whether the Vonage Java SDK currently supports them: -| API | Supported? -|----------|:-------------:| -| Session Creation | ✅ | -| Stream Management | ✅ | -| Signaling | ✅ | -| Moderation | ✅ | -| Archiving | ✅ | -| Live Streaming Broadcasts | ✅ | -| SIP Interconnect | ✅ | -| Account Management | ❌ | -| Experience Composer | ❌ | -| Audio Connector | ❌ | -| Live Captions | ❌ | -| Custom S3/Azure buckets | ❌ | +| API | Supported? | +|---------------------------|:----------:| +| Session Creation | ✅ | +| Stream Management | ✅ | +| Signaling | ✅ | +| Moderation | ✅ | +| Archiving | ✅ | +| Live Streaming Broadcasts | ✅ | +| SIP Interconnect | ✅ | +| Account Management | ❌ | +| Experience Composer | ❌ | +| Audio Connector | ❌ | +| Live Captions | ❌ | +| Custom S3/Azure buckets | ❌ | diff --git a/src/main/java/com/vonage/client/voice/ncco/ConversationAction.java b/src/main/java/com/vonage/client/voice/ncco/ConversationAction.java index 89076312e..ae30900aa 100644 --- a/src/main/java/com/vonage/client/voice/ncco/ConversationAction.java +++ b/src/main/java/com/vonage/client/voice/ncco/ConversationAction.java @@ -149,7 +149,7 @@ public Builder name(String name) { /** * @param musicOnHoldUrl A URL to the mp3 file to stream to participants until the conversation starts. - * By default the conversation starts when the first person calls the virtual number + * By default, the conversation starts when the first person calls the virtual number * associated with your Voice app. To stream this mp3 before the moderator joins the * conversation, set startOnEnter to false for all users other than the moderator. * @@ -162,7 +162,7 @@ public Builder musicOnHoldUrl(Collection musicOnHoldUrl) { /** * @param musicOnHoldUrl A URL to the mp3 file to stream to participants until the conversation starts. - * By default the conversation starts when the first person calls the virtual number + * By default, the conversation starts when the first person calls the virtual number * associated with your Voice app. To stream this mp3 before the moderator joins the * conversation, set startOnEnter to false for all users other than the moderator. * @@ -203,7 +203,7 @@ public Builder endOnExit(Boolean endOnExit) { * startOnEnter is set to true. When the recording is terminated, the URL you download the * recording from is sent to the event URL. *

- * By default audio is recorded in MP3 format. See the recording guide for more details + * By default, audio is recorded in MP3 format. See the recording guide for more details * * @return This builder. */ diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index df7475318..000000000 --- a/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - ncco-example - com.vonage.client.voice.servlet.examples.TestNccoServlet - - - ncco-example - /ncco - - \ No newline at end of file