@@ -52,12 +52,12 @@ private void initHttpClient(String userName, String password) {
52
52
httpClient .getCredentialsProvider ().setCredentials (AuthScope .ANY , credentials );
53
53
}
54
54
55
- private <T > T processResponse (String responseBody , Class <T > returnType ) throws Exception {
56
- T parsedResponse = XmlUtils .fromXml (responseBody , returnType );
55
+ private <T > T processResponse (IrisResponse response , Class <T > returnType ) throws Exception {
56
+ T parsedResponse = XmlUtils .fromXml (response . getResponseBody () , returnType );
57
57
if (parsedResponse instanceof BaseResponse ) {
58
58
BaseResponse baseResponse = (BaseResponse ) parsedResponse ;
59
59
if (baseResponse .getResponseStatus () != null ) {
60
- throw new IrisClientException (baseResponse .getResponseStatus ().getErrorCode (),
60
+ throw new IrisClientException (response . getStatusCode (), baseResponse .getResponseStatus ().getErrorCode (),
61
61
baseResponse .getResponseStatus ().getDescription ());
62
62
}
63
63
}
@@ -66,15 +66,15 @@ private <T> T processResponse(String responseBody, Class<T> returnType) throws E
66
66
67
67
public <T > T get (String uri , Class <T > returnType ) throws Exception {
68
68
IrisResponse response = get (uri );
69
- return processResponse (response . getResponseBody () , returnType );
69
+ return processResponse (response , returnType );
70
70
}
71
71
72
72
public byte [] getFile (String uri ) throws Exception {
73
73
HttpGet get = new HttpGet (uri );
74
74
HttpResponse response = httpClient .execute (get );
75
75
76
76
if (response .getStatusLine ().getStatusCode () != 200 ) {
77
- throw new IrisClientException ("Status code getting LOAS file: " + response .getStatusLine ().getStatusCode ());
77
+ throw new IrisClientException ( response . getStatusLine (). getStatusCode (), "Status code getting LOAS file: " + response .getStatusLine ().getStatusCode (), "" );
78
78
}
79
79
return response .getEntity () != null ? EntityUtils .toByteArray (response .getEntity ()) : new byte []{};
80
80
}
@@ -86,7 +86,7 @@ public IrisResponse get(String uri) throws Exception {
86
86
87
87
public <T > T post (String uri , BaseModel data , Class <T > returnType ) throws Exception {
88
88
IrisResponse response = post (uri , data );
89
- return processResponse (response . getResponseBody () , returnType );
89
+ return processResponse (response , returnType );
90
90
}
91
91
92
92
public IrisResponse post (String uri , BaseModel data ) throws Exception {
@@ -104,7 +104,7 @@ public IrisResponse delete(String uri) throws Exception {
104
104
105
105
public <T > T put (String uri , BaseModel data , Class <T > returnType ) throws Exception {
106
106
IrisResponse response = put (uri , data );
107
- return processResponse (response . getResponseBody () , returnType );
107
+ return processResponse (response , returnType );
108
108
}
109
109
110
110
public IrisResponse put (String uri , BaseModel data ) throws Exception {
@@ -170,7 +170,7 @@ protected IrisResponse executeRequest(HttpUriRequest request) throws Exception {
170
170
irisResponse .setHeaders (headers );
171
171
172
172
if (!irisResponse .isOK ()) {
173
- throw new IrisClientException (irisResponse .getResponseBody ());
173
+ throw new IrisClientException (irisResponse .getStatusCode (), "" , irisResponse . getResponseBody ());
174
174
}
175
175
return irisResponse ;
176
176
}
@@ -179,10 +179,10 @@ public String getIdFromLocationHeader(String locationHeader) {
179
179
return locationHeader .substring (locationHeader .lastIndexOf ("/" ) + 1 );
180
180
}
181
181
182
- public void checkResponse (BaseResponse response ) throws IrisClientException {
183
- if ( response .getResponseStatus () != null ) {
184
- throw new IrisClientException (response .getResponseStatus ().getErrorCode (),
185
- response .getResponseStatus ().getDescription ());
182
+ public void checkResponse ( IrisResponse response , BaseResponse baseResponse ) throws IrisClientException {
183
+ if ( baseResponse .getResponseStatus () != null ) {
184
+ throw new IrisClientException (response .getStatusCode (), baseResponse . getResponseStatus ().getErrorCode (),
185
+ baseResponse .getResponseStatus ().getDescription ());
186
186
}
187
187
}
188
188
0 commit comments