Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Change Log
## [5.45.4](https://github.com/plivo/plivo-java/tree/v5.45.4)(2025-02-18)
**Feature - Throw GeoPermissionException on synchronous geopermissions error**

## [5.45.3](https://github.com/plivo/plivo-java/tree/v5.45.3)(2024-10-23)
**Feature - fraudCheck param in Create, Get and List Session**
- Support for the `fraud_check` parameter in sms verify session request
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM openjdk:8-alpine
FROM openjdk:8-buster

RUN apk update && apk add git vim bash wget make
RUN apt-get update && apt-get install -y git vim bash wget make

WORKDIR /usr/src/app
ENV CLASSPATH ${CLASSPATH}:/etc/jars/*
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The Plivo Java SDK makes it simpler to integrate communications into your Java a

### To Install Stable release

You can use this SDK by adding it as a dependency in your dependency management tool. Alternatively, you can use the [JAR file](https://search.maven.org/remotecontent?filepath=com/plivo/plivo-java/5.45.3/plivo-java-5.45.3.jar).
You can use this SDK by adding it as a dependency in your dependency management tool. Alternatively, you can use the [JAR file](https://search.maven.org/remotecontent?filepath=com/plivo/plivo-java/5.45.4/plivo-java-5.45.4.jar).


If you are using Maven, use the following XML to include the Plivo SDK as a dependency.
Expand All @@ -19,13 +19,13 @@ If you are using Maven, use the following XML to include the Plivo SDK as a depe
<dependency>
<groupId>com.plivo</groupId>
<artifactId>plivo-java</artifactId>
<version>5.45.3</version>
<version>5.45.4</version>
</dependency>
```

If you are using Gradle, use the following line in your dependencies.
```
compile 'com.plivo:plivo-java:5.45.3'
compile 'com.plivo:plivo-java:5.45.4'
```

### To Install Beta release
Expand Down
2 changes: 1 addition & 1 deletion pom.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Written manually.

version=5.45.3
version=5.45.4
groupId=com.plivo
artifactId=plivo-java

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.plivo</groupId>
<artifactId>plivo-java</artifactId>
<version>5.45.3</version>
<version>5.45.4</version>
<name>plivo-java</name>
<description>A Java SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML</description>
<licenses>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.plivo.api.exceptions;

public class GeoPermissionException extends PlivoRestException {

public GeoPermissionException(String message) {
super(message);
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/plivo/api/models/base/BaseRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.exceptions.ResourceNotFoundException;
import com.plivo.api.exceptions.ServerException;
import com.plivo.api.exceptions.GeoPermissionException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import okhttp3.ResponseBody;
import retrofit2.Response;

Expand All @@ -24,6 +28,12 @@ public abstract class BaseRequest<T extends BaseResource> {
@JsonIgnore
protected PlivoClient plivoClient = Plivo.getClient();

private static final List<String> GEO_PERMISSION_ENDPOINTS = Arrays.asList(
"/Call/",
"/Message/",
"/Session/"
);

public PlivoClient client() {
return this.plivoClient;
}
Expand Down Expand Up @@ -84,6 +94,18 @@ protected void handleResponse(Response response) throws PlivoRestException, IOEx
throw new InvalidRequestException(response.errorBody().string());
case 401:
throw new AuthenticationException(response.errorBody().string());
case 403:
try {
String url = response.raw().request().url().toString();
if ((this instanceof Creator || this instanceof VoiceCreator) &&
GEO_PERMISSION_ENDPOINTS.stream().anyMatch(endpoint -> url.endsWith(endpoint))) {
throw new GeoPermissionException(response.errorBody().string());
}
} catch (GeoPermissionException e) {
throw e;
} catch (Exception e) {
// nop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw e?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Throw GeoPermissionException. Any other exception while extracting url, etc will be ignored

}
case 404:
throw new ResourceNotFoundException(response.errorBody().string());
case 405:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/com/plivo/api/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.45.3
5.45.4
Loading