Skip to content

Commit

Permalink
PubNub SDK v5.0.1 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
client-engineering-bot committed Sep 28, 2020
1 parent 54b375e commit cb35b4c
Show file tree
Hide file tree
Showing 21 changed files with 362 additions and 268 deletions.
14 changes: 12 additions & 2 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
name: kotlin
version: 5.0.0
version: 5.0.1
schema: 1
scm: github.com/pubnub/kotlin
files:
- build/libs/pubnub-kotlin-5.0.0-all.jar
- build/libs/pubnub-kotlin-5.0.1-all.jar
changelog:
-
version: 5.0.1
date: 2020-09-28
changes:
-
type: feature
text: "Add simplified Objects API support with UUID and Channel metadata / membership management."
-
type: bug
text: "Fix crashing Telemetry Manager."
-
version: v5.0.0
date: 2020-08-12
Expand Down
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## [v5.0.0](https://github.com/pubnub/kotlin/releases/tag/v5.0.0)
August 12 2020
## [5.0.1](https://github.com/pubnub/kotlin/releases/tag/5.0.1)
September 28 2020

[Full Changelog](https://github.com/pubnub/kotlin/compare/v1.0.0...v5.0.0)
[Full Changelog](https://github.com/pubnub/kotlin/compare/v5.0.0...5.0.1)

- PubNub methods will no longer support builder style calls and will use named arguments instead.
- Add simplified Objects API support with UUID and Channel metadata / membership management.
- Fix crashing Telemetry Manager.


49 changes: 9 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,13 @@
# kotlin
### PubNub Kotlin-based SDKs for Android

## Using your PubNub keys
[![Build Status](https://travis-ci.org/pubnub/kotlin.svg?branch=master)](https://travis-ci.org/pubnub/kotlin)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/164fd518c314417e896b3de494ab75df)](https://www.codacy.com/app/PubNub/kotlin?utm_source=github.com&utm_medium=referral&utm_content=pubnub/kotlin&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/164fd518c314417e896b3de494ab75df)](https://www.codacy.com/app/PubNub/kotlin?utm_source=github.com&utm_medium=referral&utm_content=pubnub/kotlin&utm_campaign=Badge_Coverage)
[![Download](https://api.bintray.com/packages/bintray/jcenter/com.pubnub%3Apubnub-kotlin/images/download.svg)](https://bintray.com/bintray/jcenter/com.pubnub%3Apubnub-kotlin/_latestVersion)
[![Maven Central](https://img.shields.io/maven-central/v/com.pubnub/pubnub-kotlin.svg)]()

If you would like to run integration tests against your keys, Execute the following commands to add your publish, subscribe and secret keys to your local copy of the SDK.
### [Documentation](https://www.pubnub.com/docs/kotlin-java/pubnub-java-sdk)

```bash
cd src/test/resources/
echo pub_key=YOUR_PUB_KEY >> config.properties
echo sub_key=YOUR_SUB_KEY >> config.properties
echo pam_pub_key=YOUR_PAM_PUB_KEY >> config.properties
echo pam_sub_key=YOUR_PAM_SUB_KEY >> config.properties
echo pam_sec_key=YOUR_PAM_SEC_KEY >> config.properties
```
## Communication

Please create two keys:
- with disabled Access Manager - pub, sub
- with enabled Access Manager - pam_pub, pam_sub, pam_sec

Configuration of the rest functionality should be:

| Key | Value |
| -------------------------------- | --------------------------- |
| **PRESENCE** | **ON** |
| Announce Max | 20 |
| Interval | 30 |
| Presence Deltas | OFF |
| Generate Leave on TCP FIN or RST | ON |
| Global Here Now | ON |
| Stream Filtering | ON |
| Debounce | 2 |
| **STORAGE & PLAYBACK** | **ON** |
| Retention | 7 Day |
| Enable Delete-From-History | ON |
| Include presence events | ON |
| **STREAM CONTROLLER** | |
| Enable Wildcard Subscribe | ON |
| **OBJECTS** | |
| Region | select nearest one |
| User Metadata Events | ON |
| Channel Metadata Events | ON |
| Membership Events | ON |
| **PUBNUB FUNCTIONS** | ON |
| **ACCESS MANAGER** | ON for PAM, OFF default |
- If you **need help** or have a **general question**, contact <[email protected]>
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = 'com.pubnub'
version = '5.0.0'
version = '5.0.1'

repositories {
mavenCentral()
Expand Down Expand Up @@ -65,6 +65,8 @@ dependencies {
allTest "ch.qos.logback:logback-core:1.2.3"
allTest "org.json:json:20190722"
allTest "dev.nohus:AutoKonfig:1.0.0"

testImplementation "io.mockk:mockk:1.10.0"
}

shadowJar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ abstract class AccessManagerIntegrationTest : BaseIntegrationTest() {
value = emoji(),
messageTimetoken = 1L
)
).retryForbidden({ requestAccess(WRITE) }) { _, status ->
).asyncRetry { _, status ->
requestAccess(WRITE)
assertAuthKey(status)
assertUuid(status)
assertStatusSuccess(status)
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/com/pubnub/api/vendor/Crypto.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ public static byte[] hexEncode(byte[] input) throws PubNubException {
}

public static PubNubException newCryptoError(int code, Exception exception) {
PubNubException pubNubException = new PubNubException();
pubNubException.setPubnubError(PubNubError.CRYPTO_ERROR);
pubNubException.setErrorMessage(exception.getClass().getSimpleName() + " " + exception.getMessage() + " " + code);
return pubNubException;
return new PubNubException(
exception.getClass().getSimpleName() + " " + exception.getMessage() + " " + code,
PubNubError.CRYPTO_ERROR,
null,
0,
null
);
}

public String encrypt(String input) throws PubNubException {
Expand Down
185 changes: 96 additions & 89 deletions src/main/kotlin/com/pubnub/api/Endpoint.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ abstract class Endpoint<Input, Output> protected constructor(protected val pubnu

/**
* Key-value object to pass with every PubNub API operation. Used for debugging purposes.
* todo: it should be removed!
*/
val queryParam: MutableMap<String, String> = mutableMapOf()

Expand All @@ -62,10 +63,11 @@ abstract class Endpoint<Input, Output> protected constructor(protected val pubnu
try {
call.execute()
} catch (e: Exception) {
throw PubNubException(PubNubError.PARSING_ERROR).apply {
errorMessage = e.toString()
throw PubNubException(
pubnubError = PubNubError.PARSING_ERROR,
errorMessage = e.toString(),
affectedCall = call
}
)
}

when {
Expand All @@ -75,12 +77,13 @@ abstract class Endpoint<Input, Output> protected constructor(protected val pubnu
}
else -> {
val (errorString, errorJson) = extractErrorBody(response)
throw PubNubException(PubNubError.HTTP_ERROR).apply {
errorMessage = errorString
jso = errorJson.toString()
statusCode = response.code()
throw PubNubException(
pubnubError = PubNubError.HTTP_ERROR,
errorMessage = errorString,
jso = errorJson.toString(),
statusCode = response.code(),
affectedCall = call
}
)
}
}
}
Expand Down Expand Up @@ -133,12 +136,13 @@ abstract class Endpoint<Input, Output> protected constructor(protected val pubnu
else -> {
val (errorString, errorJson) = extractErrorBody(response)

val exception = PubNubException(PubNubError.HTTP_ERROR).apply {
errorMessage = errorString
jso = errorJson.toString()
statusCode = response.code()
val exception = PubNubException(
pubnubError = PubNubError.HTTP_ERROR,
errorMessage = errorString,
jso = errorJson.toString(),
statusCode = response.code(),
affectedCall = call
}
)

val pnStatusCategory = when (response.code()) {
SERVER_RESPONSE_FORBIDDEN -> PNAccessDeniedCategory
Expand All @@ -163,44 +167,35 @@ abstract class Endpoint<Input, Output> protected constructor(protected val pubnu

override fun onFailure(call: Call<Input>, t: Throwable) {

if (silenceFailures) {
return
}

lateinit var pnStatusCategory: PNStatusCategory

val pubnubException = PubNubException(t.toString())
if (silenceFailures) return

try {
throw t
} catch (networkException: UnknownHostException) {
pubnubException.pubnubError = PubNubError.CONNECTION_NOT_SET
pnStatusCategory = PNUnexpectedDisconnectCategory
} catch (connectException: ConnectException) {
pubnubException.pubnubError = PubNubError.CONNECT_EXCEPTION
pnStatusCategory = PNUnexpectedDisconnectCategory
} catch (socketTimeoutException: SocketTimeoutException) {
pubnubException.pubnubError = PubNubError.SUBSCRIBE_TIMEOUT
pnStatusCategory = PNTimeoutCategory
} catch (ioException: IOException) {
pubnubException.pubnubError = PubNubError.PARSING_ERROR
pnStatusCategory = PNMalformedResponseCategory
} catch (ioException: IllegalStateException) {
pubnubException.pubnubError = PubNubError.PARSING_ERROR
pnStatusCategory = PNMalformedResponseCategory
} catch (throwable1: Throwable) {
pubnubException.pubnubError = PubNubError.HTTP_ERROR
pnStatusCategory = if (call.isCanceled) {
PNCancelledCategory
} else {
PNBadRequestCategory
val (error: PubNubError, category: PNStatusCategory) =
when (t) {
is UnknownHostException -> {
PubNubError.CONNECTION_NOT_SET to PNUnexpectedDisconnectCategory
}
is ConnectException -> {
PubNubError.CONNECT_EXCEPTION to PNUnexpectedDisconnectCategory
}
is SocketTimeoutException -> {
PubNubError.SUBSCRIBE_TIMEOUT to PNTimeoutCategory
}
is IOException -> {
PubNubError.PARSING_ERROR to PNMalformedResponseCategory
}
is IllegalStateException -> {
PubNubError.PARSING_ERROR to PNMalformedResponseCategory
}
else -> {
PubNubError.HTTP_ERROR to if (call.isCanceled) PNCancelledCategory else PNBadRequestCategory
}
}

val pubnubException = PubNubException(errorMessage = t.toString(), pubnubError = error)
callback.invoke(
null,
createStatusResponse(
category = pnStatusCategory,
category = category,
exception = pubnubException
)
)
Expand Down Expand Up @@ -285,7 +280,11 @@ abstract class Endpoint<Input, Output> protected constructor(protected val pubnu
val errorGroups = mutableListOf<String>()

if (errorBody != null) {
if (pubnub.mapper.isJsonObject(errorBody) && pubnub.mapper.hasField(errorBody, "payload")) {
if (pubnub.mapper.isJsonObject(errorBody) && pubnub.mapper.hasField(
errorBody,
"payload"
)
) {

val payloadBody = pubnub.mapper.getField(errorBody, "payload")!!

Expand Down Expand Up @@ -365,67 +364,75 @@ abstract class Endpoint<Input, Output> protected constructor(protected val pubnu
try {
return createResponse(input)
} catch (pubnubException: PubNubException) {
throw pubnubException.apply {
statusCode = input.code()
jso = pubnub.mapper.toJson(input.body())
throw pubnubException.copy(
statusCode = input.code(),
jso = pubnub.mapper.toJson(input.body()),
affectedCall = call
}
)
} catch (e: KotlinNullPointerException) {
throw PubNubException(PubNubError.PARSING_ERROR).apply {
errorMessage = e.toString()
affectedCall = call
statusCode = input.code()
throw PubNubException(
pubnubError = PubNubError.PARSING_ERROR,
errorMessage = e.toString(),
affectedCall = call,
statusCode = input.code(),
jso = pubnub.mapper.toJson(input.body())
}
)
} catch (e: IllegalStateException) {
throw PubNubException(PubNubError.PARSING_ERROR).apply {
errorMessage = e.toString()
affectedCall = call
statusCode = input.code()
throw PubNubException(
pubnubError = PubNubError.PARSING_ERROR,
errorMessage = e.toString(),
affectedCall = call,
statusCode = input.code(),
jso = pubnub.mapper.toJson(input.body())
}
)
} catch (e: IndexOutOfBoundsException) {
throw PubNubException(PubNubError.PARSING_ERROR).apply {
errorMessage = e.toString()
affectedCall = call
statusCode = input.code()
throw PubNubException(
pubnubError = PubNubError.PARSING_ERROR,
errorMessage = e.toString(),
affectedCall = call,
statusCode = input.code(),
jso = pubnub.mapper.toJson(input.body())
}
)
} catch (e: NullPointerException) {
throw PubNubException(PubNubError.PARSING_ERROR).apply {
errorMessage = e.toString()
affectedCall = call
statusCode = input.code()
throw PubNubException(
pubnubError = PubNubError.PARSING_ERROR,
errorMessage = e.toString(),
affectedCall = call,
statusCode = input.code(),
jso = pubnub.mapper.toJson(input.body())
}
)
} catch (e: IllegalArgumentException) {
throw PubNubException(PubNubError.PARSING_ERROR).apply {
errorMessage = e.toString()
affectedCall = call
statusCode = input.code()
throw PubNubException(
pubnubError = PubNubError.PARSING_ERROR,
errorMessage = e.toString(),
affectedCall = call,
statusCode = input.code(),
jso = pubnub.mapper.toJson(input.body())
}
)
} catch (e: TypeCastException) {
throw PubNubException(PubNubError.PARSING_ERROR).apply {
errorMessage = e.toString()
affectedCall = call
statusCode = input.code()
throw PubNubException(
pubnubError = PubNubError.PARSING_ERROR,
errorMessage = e.toString(),
affectedCall = call,
statusCode = input.code(),
jso = pubnub.mapper.toJson(input.body())
}
)
} catch (e: ClassCastException) {
throw PubNubException(PubNubError.PARSING_ERROR).apply {
errorMessage = e.toString()
affectedCall = call
statusCode = input.code()
throw PubNubException(
pubnubError = PubNubError.PARSING_ERROR,
errorMessage = e.toString(),
affectedCall = call,
statusCode = input.code(),
jso = pubnub.mapper.toJson(input.body())
}
)
} catch (e: UninitializedPropertyAccessException) {
throw PubNubException(PubNubError.PARSING_ERROR).apply {
errorMessage = e.toString()
affectedCall = call
statusCode = input.code()
throw PubNubException(
pubnubError = PubNubError.PARSING_ERROR,
errorMessage = e.toString(),
affectedCall = call,
statusCode = input.code(),
jso = pubnub.mapper.toJson(input.body())
}
)
}
}

Expand Down
Loading

0 comments on commit cb35b4c

Please sign in to comment.