8
8
import com .messagebird .exceptions .UnauthorizedException ;
9
9
import com .messagebird .objects .ErrorReport ;
10
10
import com .messagebird .objects .PagedPaging ;
11
- import org .apache .maven .artifact .versioning .ComparableVersion ;
12
11
13
12
import java .io .File ;
14
13
import java .io .FileOutputStream ;
@@ -62,7 +61,7 @@ public class MessageBirdServiceImpl implements MessageBirdService {
62
61
private static final String [] PROTOCOL_LISTS = new String []{"http://" , "https://" };
63
62
private static final List <String > PROTOCOLS = Arrays .asList (PROTOCOL_LISTS );
64
63
65
- private static final ComparableVersion JAVA_VERSION = getJavaVersion ();
64
+ private static final String JAVA_VERSION = getJavaVersion ();
66
65
67
66
// Indicates whether we've overridden HttpURLConnection's behaviour to
68
67
// allow PATCH requests yet. Also see docs on allowPatchRequestsIfNeeded().
@@ -89,13 +88,9 @@ public MessageBirdServiceImpl(final String accessKey, final String serviceUrl) {
89
88
90
89
}
91
90
92
- private static ComparableVersion getJavaVersion () {
93
- try {
94
- String version = System .getProperty ("java.version" );
95
- return new ComparableVersion (version );
96
- } catch (IllegalArgumentException e ) {
97
- return new ComparableVersion ("0.0" );
98
- }
91
+ private static String getJavaVersion () {
92
+ String version = System .getProperty ("java.version" );
93
+ return version != null ? version : "0.0" ;
99
94
}
100
95
101
96
private String determineUserAgentString () {
@@ -113,7 +108,7 @@ public MessageBirdServiceImpl(final String accessKey) {
113
108
114
109
@ Override
115
110
public <R > R request (String request , Class <R > clazz )
116
- throws UnauthorizedException , GeneralException , NotFoundException {
111
+ throws UnauthorizedException , GeneralException , NotFoundException {
117
112
return getJsonData (request , null , "GET" , clazz );
118
113
}
119
114
@@ -142,7 +137,7 @@ public <R> R requestByID(String request, String id, Map<String, Object> params,
142
137
143
138
@ Override
144
139
public <E > List <E > requestByIdAsList (String request , String id , Class <E > elementClass )
145
- throws UnauthorizedException , GeneralException , NotFoundException {
140
+ throws UnauthorizedException , GeneralException , NotFoundException {
146
141
String path = "" ;
147
142
if (id != null ) {
148
143
path = "/" + id ;
@@ -276,8 +271,8 @@ public <T, P> T getJsonData(final String request, final P payload, final String
276
271
277
272
// Prevents mismatched exception when clazz is null
278
273
return clazz == null
279
- ? null
280
- : this .readValue (mapper , body , clazz );
274
+ ? null
275
+ : this .readValue (mapper , body , clazz );
281
276
} catch (IOException ioe ) {
282
277
throw new GeneralException (ioe );
283
278
}
@@ -290,8 +285,8 @@ public <T, P> T getJsonData(final String request, final P payload, final String
290
285
291
286
// todo: need to refactor for duplicated code.
292
287
public <P , E > List <E > getJsonDataAsList (final String request ,
293
- final P payload , final String requestType , final Map <String , String > headers , final Class <E > elementClass )
294
- throws UnauthorizedException , GeneralException , NotFoundException {
288
+ final P payload , final String requestType , final Map <String , String > headers , final Class <E > elementClass )
289
+ throws UnauthorizedException , GeneralException , NotFoundException {
295
290
if (request == null ) {
296
291
throw new IllegalArgumentException (REQUEST_VALUE_MUST_BE_SPECIFIED );
297
292
}
@@ -327,12 +322,12 @@ public <P, E> List<E> getJsonDataAsList(final String request,
327
322
}
328
323
329
324
private <T > T readValue (ObjectMapper mapper , String content , Class <T > clazz )
330
- throws JsonProcessingException {
325
+ throws JsonProcessingException {
331
326
return mapper .readValue (content , clazz );
332
327
}
333
328
334
329
private <E > List <E > readValueAsList (ObjectMapper mapper , String content , final Class <E > elementClass )
335
- throws JsonProcessingException {
330
+ throws JsonProcessingException {
336
331
return mapper .readValue (content , mapper .getTypeFactory ().constructCollectionType (List .class , elementClass ));
337
332
}
338
333
@@ -637,11 +632,7 @@ private void setAdditionalHeaders(HttpURLConnection connection, Map<String, Stri
637
632
}
638
633
639
634
private DateFormat getDateFormat () {
640
- ComparableVersion java6 = new ComparableVersion ("1.6" );
641
- if (JAVA_VERSION .compareTo (java6 ) > 0 ) {
642
- return new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ssXXX" );
643
- }
644
- return new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ssZZZ" );
635
+ return new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ssXXX" );
645
636
}
646
637
647
638
/**
@@ -798,4 +789,4 @@ private String getPathVariables(final Map<String, Object> map) {
798
789
}
799
790
return bpath .toString ();
800
791
}
801
- }
792
+ }
0 commit comments