@@ -28,7 +28,7 @@ public class ApiInvoker {
28
28
public static ApiInvoker getInstance () {
29
29
return INSTANCE ;
30
30
}
31
-
31
+
32
32
public void addDefaultHeader (String key , String value ) {
33
33
defaultHeaderMap .put (key , value );
34
34
}
@@ -47,7 +47,7 @@ public static Object deserialize(String json, String containerType, Class cls) t
47
47
else if (String .class .equals (cls )) {
48
48
if (json != null && json .startsWith ("\" " ) && json .endsWith ("\" " ) && json .length () > 1 )
49
49
return json .substring (1 , json .length () - 2 );
50
- else
50
+ else
51
51
return json ;
52
52
}
53
53
else {
@@ -61,9 +61,9 @@ else if(String.class.equals(cls)) {
61
61
62
62
public static String serialize (Object obj ) throws ApiException {
63
63
try {
64
- if (obj != null )
64
+ if (obj != null )
65
65
return JsonUtil .getJsonMapper ().writeValueAsString (obj );
66
- else
66
+ else
67
67
return null ;
68
68
}
69
69
catch (Exception e ) {
@@ -75,7 +75,7 @@ public String invokeAPI(String host, String path, String method, Map<String, Str
75
75
Client client = getClient (host );
76
76
77
77
StringBuilder b = new StringBuilder ();
78
-
78
+
79
79
for (String key : queryParams .keySet ()) {
80
80
String value = queryParams .get (key );
81
81
if (value != null ){
@@ -92,7 +92,7 @@ public String invokeAPI(String host, String path, String method, Map<String, Str
92
92
for (String key : headerParams .keySet ()) {
93
93
builder .header (key , headerParams .get (key ));
94
94
}
95
-
95
+
96
96
for (String key : defaultHeaderMap .keySet ()) {
97
97
if (!headerParams .containsKey (key )) {
98
98
builder .header (key , defaultHeaderMap .get (key ));
@@ -124,13 +124,16 @@ else if ("DELETE".equals(method)) {
124
124
else {
125
125
throw new ApiException (500 , "unknown method type " + method );
126
126
}
127
- if (response .getClientResponseStatus ().getFamily () == Family .SUCCESSFUL ) {
127
+ if (response .getClientResponseStatus () == ClientResponse .Status .NO_CONTENT ) {
128
+ return null ;
129
+ }
130
+ else if (response .getClientResponseStatus ().getFamily () == Family .SUCCESSFUL ) {
128
131
return (String ) response .getEntity (String .class );
129
132
}
130
133
else {
131
134
throw new ApiException (
132
135
response .getClientResponseStatus ().getStatusCode (),
133
- response .getEntity (String .class ));
136
+ response .getEntity (String .class ));
134
137
}
135
138
}
136
139
@@ -143,4 +146,3 @@ private Client getClient(String host) {
143
146
return hostMap .get (host );
144
147
}
145
148
}
146
-
0 commit comments