diff --git a/api/pom.xml b/api/pom.xml index 2d99afc..6ce5039 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -92,11 +92,6 @@ java-jwt 4.4.0 - - org.apache.maven - maven-artifact - 3.9.6 - junit junit diff --git a/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java b/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java index a5e897d..a5e4244 100644 --- a/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java +++ b/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java @@ -8,7 +8,6 @@ import com.messagebird.exceptions.UnauthorizedException; import com.messagebird.objects.ErrorReport; import com.messagebird.objects.PagedPaging; -import org.apache.maven.artifact.versioning.ComparableVersion; import java.io.File; import java.io.FileOutputStream; @@ -62,7 +61,7 @@ public class MessageBirdServiceImpl implements MessageBirdService { private static final String[] PROTOCOL_LISTS = new String[]{"http://", "https://"}; private static final List PROTOCOLS = Arrays.asList(PROTOCOL_LISTS); - private static final ComparableVersion JAVA_VERSION = getJavaVersion(); + private static final String JAVA_VERSION = getJavaVersion(); // Indicates whether we've overridden HttpURLConnection's behaviour to // allow PATCH requests yet. Also see docs on allowPatchRequestsIfNeeded(). @@ -89,13 +88,9 @@ public MessageBirdServiceImpl(final String accessKey, final String serviceUrl) { } - private static ComparableVersion getJavaVersion() { - try { - String version = System.getProperty("java.version"); - return new ComparableVersion(version); - } catch (IllegalArgumentException e) { - return new ComparableVersion("0.0"); - } + private static String getJavaVersion() { + String version = System.getProperty("java.version"); + return version != null ? version : "0.0"; } private String determineUserAgentString() { @@ -113,7 +108,7 @@ public MessageBirdServiceImpl(final String accessKey) { @Override public R request(String request, Class clazz) - throws UnauthorizedException, GeneralException, NotFoundException { + throws UnauthorizedException, GeneralException, NotFoundException { return getJsonData(request, null, "GET", clazz); } @@ -142,7 +137,7 @@ public R requestByID(String request, String id, Map params, @Override public List requestByIdAsList(String request, String id, Class elementClass) - throws UnauthorizedException, GeneralException, NotFoundException { + throws UnauthorizedException, GeneralException, NotFoundException { String path = ""; if (id != null) { path = "/" + id; @@ -276,8 +271,8 @@ public T getJsonData(final String request, final P payload, final String // Prevents mismatched exception when clazz is null return clazz == null - ? null - : this.readValue(mapper, body, clazz); + ? null + : this.readValue(mapper, body, clazz); } catch (IOException ioe) { throw new GeneralException(ioe); } @@ -290,8 +285,8 @@ public T getJsonData(final String request, final P payload, final String // todo: need to refactor for duplicated code. public List getJsonDataAsList(final String request, - final P payload, final String requestType, final Map headers, final Class elementClass) - throws UnauthorizedException, GeneralException, NotFoundException { + final P payload, final String requestType, final Map headers, final Class elementClass) + throws UnauthorizedException, GeneralException, NotFoundException { if (request == null) { throw new IllegalArgumentException(REQUEST_VALUE_MUST_BE_SPECIFIED); } @@ -327,12 +322,12 @@ public List getJsonDataAsList(final String request, } private T readValue(ObjectMapper mapper, String content, Class clazz) - throws JsonProcessingException { + throws JsonProcessingException { return mapper.readValue(content, clazz); } private List readValueAsList(ObjectMapper mapper, String content, final Class elementClass) - throws JsonProcessingException { + throws JsonProcessingException { return mapper.readValue(content, mapper.getTypeFactory().constructCollectionType(List.class, elementClass)); } @@ -637,11 +632,7 @@ private void setAdditionalHeaders(HttpURLConnection connection, Map 0) { - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); - } - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZ"); + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); } /** @@ -798,4 +789,4 @@ private String getPathVariables(final Map map) { } return bpath.toString(); } -} +} \ No newline at end of file diff --git a/api/src/main/java/com/messagebird/common/StringUtils.java b/api/src/main/java/com/messagebird/common/StringUtils.java new file mode 100644 index 0000000..f59ecd0 --- /dev/null +++ b/api/src/main/java/com/messagebird/common/StringUtils.java @@ -0,0 +1,12 @@ +package com.messagebird.common; + +public class StringUtils { + + private StringUtils() { + // static utility + } + + public static boolean isBlank(String text) { + return text == null || text.trim().isEmpty(); + } +} diff --git a/api/src/main/java/com/messagebird/objects/conversations/MessageParam.java b/api/src/main/java/com/messagebird/objects/conversations/MessageParam.java index 38ae18f..6a84526 100644 --- a/api/src/main/java/com/messagebird/objects/conversations/MessageParam.java +++ b/api/src/main/java/com/messagebird/objects/conversations/MessageParam.java @@ -1,7 +1,7 @@ package com.messagebird.objects.conversations; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.StringUtils; +import com.messagebird.common.StringUtils; public class MessageParam { diff --git a/api/src/main/java/com/messagebird/objects/integrations/HSMComponent.java b/api/src/main/java/com/messagebird/objects/integrations/HSMComponent.java index ed93847..5f2db2d 100644 --- a/api/src/main/java/com/messagebird/objects/integrations/HSMComponent.java +++ b/api/src/main/java/com/messagebird/objects/integrations/HSMComponent.java @@ -1,7 +1,7 @@ package com.messagebird.objects.integrations; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.StringUtils; +import com.messagebird.common.StringUtils; import java.util.List;