@@ -30,7 +30,7 @@ public class XeroClient {
3030 private String token = null ;
3131 private String tokenSecret = null ;
3232 final static Logger logger = Logger .getLogger (XeroClient .class );
33-
33+ static XeroJAXBMarshaller u = new XeroJAXBMarshaller ();
3434 protected static final DateFormat utcFormatter ;
3535
3636 static {
@@ -67,7 +67,7 @@ protected Response get(String endPoint) throws IOException {
6767 }
6868
6969 protected Response get (String endPoint , Date modifiedAfter , Map <String , String > params ) throws IOException {
70- XeroJAXBMarshaller u = new XeroJAXBMarshaller ();
70+ // XeroJAXBMarshaller u = new XeroJAXBMarshaller();
7171
7272 OAuthRequestResource req = new OAuthRequestResource (config , signerFactory , endPoint , "GET" , null , params );
7373 req .setToken (token );
@@ -77,15 +77,15 @@ protected Response get(String endPoint, Date modifiedAfter, Map<String, String>
7777 }
7878
7979 try {
80- Map <String , String > resp = req .execute ();
81- Object r = resp .get ("content" );
80+ Map <String , String > resp = req .execute ();
81+ Object r = resp .get ("content" );
8282 return u .unmarshall (r .toString (), Response .class );
8383 } catch (IOException ioe ) {
84- logger .error (ioe );
84+ logger .error (ioe );
8585 throw xeroExceptionHandler .convertException (ioe );
8686 } catch (XeroApiException e ) {
87- logger .error (e );
88- throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
87+ logger .error (e );
88+ throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
8989 }
9090 }
9191 /*
@@ -111,7 +111,7 @@ protected String getFile(String endPoint,
111111 String fileName = null ;
112112
113113 try {
114- ByteArrayInputStream input = req .executefile ();
114+ ByteArrayInputStream input = req .executefile ();
115115 fileName = req .getFileName ();
116116 saveFilePath = dirPath + File .separator + fileName ;
117117
@@ -133,11 +133,11 @@ protected String getFile(String endPoint,
133133
134134 return saveFilePath ;
135135 } catch (IOException ioe ) {
136- logger .error (ioe );
136+ logger .error (ioe );
137137 throw xeroExceptionHandler .convertException (ioe );
138138 } catch (XeroApiException e ) {
139- logger .error (e );
140- throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
139+ logger .error (e );
140+ throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
141141 }
142142 }
143143
@@ -156,16 +156,16 @@ protected ByteArrayInputStream getInputStream(String endPoint,
156156 ByteArrayInputStream byteStream = req .executefile ();
157157 return byteStream ;
158158 } catch (IOException ioe ) {
159- logger .error (ioe );
159+ logger .error (ioe );
160160 throw xeroExceptionHandler .convertException (ioe );
161161 } catch (XeroApiException e ) {
162- logger .error (e );
163- throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
162+ logger .error (e );
163+ throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
164164 }
165165 }
166166
167167 protected Response put (String endPoint , JAXBElement <?> object ) {
168- XeroJAXBMarshaller u = new XeroJAXBMarshaller ();
168+ // XeroJAXBMarshaller u = new XeroJAXBMarshaller();
169169
170170 String contents = u .marshall (object );
171171
@@ -174,144 +174,143 @@ protected Response put(String endPoint, JAXBElement<?> object) {
174174 req .setTokenSecret (tokenSecret );
175175
176176 try {
177- Map <String , String > resp = req .execute ();
178- Object r = resp .get ("content" );
179- return u .unmarshall (r .toString (), Response .class );
177+ Map <String , String > resp = req .execute ();
178+ Object r = resp .get ("content" );
179+ return u .unmarshall (r .toString (), Response .class );
180180 } catch (IOException ioe ) {
181- logger .error (ioe );
182- throw xeroExceptionHandler .convertException (ioe );
181+ logger .error (ioe );
182+ throw xeroExceptionHandler .convertException (ioe );
183183 } catch (XeroApiException e ) {
184- logger .error (e );
185- throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
184+ logger .error (e );
185+ throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
186186 }
187187 }
188188
189189 protected Response put (String endPoint , String contentType , byte [] bytes ) throws IOException {
190- return put (endPoint , contentType , bytes , null );
190+ return put (endPoint , contentType , bytes , null );
191191 }
192192
193- protected Response put (String endPoint , String contentType , byte [] bytes , Map <? extends String , ?> params ) throws IOException {
194- XeroJAXBMarshaller u = new XeroJAXBMarshaller ();
193+ protected Response put (String endPoint , String contentType , byte [] bytes , Map <? extends String , ?> params ) throws IOException {
194+ // XeroJAXBMarshaller u = new XeroJAXBMarshaller();
195195
196- OAuthRequestResource req = new OAuthRequestResource (config , signerFactory , endPoint , "PUT" , contentType , bytes , params );
196+ OAuthRequestResource req = new OAuthRequestResource (config , signerFactory , endPoint , "PUT" , contentType , bytes , params );
197197
198198 req .setToken (token );
199199 req .setTokenSecret (tokenSecret );
200200
201201 try {
202- Map <String , String > resp = req .execute ();
203- Object r = resp .get ("content" );
202+ Map <String , String > resp = req .execute ();
203+ Object r = resp .get ("content" );
204204 return u .unmarshall (r .toString (), Response .class );
205205 } catch (IOException ioe ) {
206- logger .error (ioe );
207- throw xeroExceptionHandler .convertException (ioe );
206+ logger .error (ioe );
207+ throw xeroExceptionHandler .convertException (ioe );
208208 } catch (XeroApiException e ) {
209- logger .error (e );
210- throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
209+ logger .error (e );
210+ throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
211211 }
212212 }
213213
214214 protected Response put (String endPoint , JAXBElement <?> object , Map <String , String > params ) {
215- XeroJAXBMarshaller u = new XeroJAXBMarshaller ();
216-
217- String contents = u .marshall (object );
215+ //XeroJAXBMarshaller u = new XeroJAXBMarshaller();
216+ String contents = u .marshall (object );
218217
219218 OAuthRequestResource req = new OAuthRequestResource (config , signerFactory , endPoint , "PUT" , contents , params );
220219 req .setToken (token );
221220 req .setTokenSecret (tokenSecret );
222221
223222 try {
224- Map <String , String > resp = req .execute ();
225- Object r = resp .get ("content" );
223+ Map <String , String > resp = req .execute ();
224+ Object r = resp .get ("content" );
226225 return u .unmarshall (r .toString (), Response .class );
227226 } catch (IOException ioe ) {
228- logger .error (ioe );
227+ logger .error (ioe );
229228 throw xeroExceptionHandler .convertException (ioe );
230229 } catch (XeroApiException e ) {
231- logger .error (e );
232- throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
230+ logger .error (e );
231+ throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
233232 }
234233 }
235234
236235 protected Response put (String endPoint , String contentType , File file ) throws IOException {
237- XeroJAXBMarshaller u = new XeroJAXBMarshaller ();
236+ // XeroJAXBMarshaller u = new XeroJAXBMarshaller();
238237
239- OAuthRequestResource req = new OAuthRequestResource (config , signerFactory , endPoint , "PUT" , contentType , file , null );
238+ OAuthRequestResource req = new OAuthRequestResource (config , signerFactory , endPoint , "PUT" , contentType , file , null );
240239 req .setToken (token );
241240 req .setTokenSecret (tokenSecret );
242241
243242 try {
244- Map <String , String > resp = req .execute ();
245- Object r = resp .get ("content" );
243+ Map <String , String > resp = req .execute ();
244+ Object r = resp .get ("content" );
246245 return u .unmarshall (r .toString (), Response .class );
247246 } catch (IOException ioe ) {
248- logger .error (ioe );
247+ logger .error (ioe );
249248 throw xeroExceptionHandler .convertException (ioe );
250249 } catch (XeroApiException e ) {
251- logger .error (e );
252- throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
250+ logger .error (e );
251+ throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
253252 }
254253 }
255254
256255 protected Response post (String endPoint , JAXBElement <?> object ) throws IOException {
257- XeroJAXBMarshaller u = new XeroJAXBMarshaller ();
256+ // XeroJAXBMarshaller u = new XeroJAXBMarshaller();
258257
259- String contents = u .marshall (object );
258+ String contents = u .marshall (object );
260259 OAuthRequestResource req = new OAuthRequestResource (config , signerFactory , endPoint , "POST" , contents , null );
261260 req .setToken (token );
262261 req .setTokenSecret (tokenSecret );
263262
264263 try {
265- Map <String , String > resp = req .execute ();
266- Object r = resp .get ("content" );
264+ Map <String , String > resp = req .execute ();
265+ Object r = resp .get ("content" );
267266 return u .unmarshall (r .toString (), Response .class );
268267 } catch (IOException ioe ) {
269- logger .error (ioe );
268+ logger .error (ioe );
270269 throw xeroExceptionHandler .convertException (ioe );
271270 } catch (XeroApiException e ) {
272- logger .error (e );
273- throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
271+ logger .error (e );
272+ throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
274273 }
275274 }
276275
277276 protected Response post (String endPoint , JAXBElement <?> object , Map <String , String > params ) throws IOException {
278- XeroJAXBMarshaller u = new XeroJAXBMarshaller ();
277+ // XeroJAXBMarshaller u = new XeroJAXBMarshaller();
279278
280- String contents = u .marshall (object );
279+ String contents = u .marshall (object );
281280 OAuthRequestResource req = new OAuthRequestResource (config , signerFactory , endPoint , "POST" , contents , params );
282281 req .setToken (token );
283282 req .setTokenSecret (tokenSecret );
284283
285284 try {
286- Map <String , String > resp = req .execute ();
287- Object r = resp .get ("content" );
285+ Map <String , String > resp = req .execute ();
286+ Object r = resp .get ("content" );
288287 return u .unmarshall (r .toString (), Response .class );
289288 } catch (IOException ioe ) {
290- logger .error (ioe );
289+ logger .error (ioe );
291290 throw xeroExceptionHandler .convertException (ioe );
292291 } catch (XeroApiException e ) {
293- logger .error (e );
294- throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
292+ logger .error (e );
293+ throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
295294 }
296295 }
297296
298297 protected Response delete (String endPoint ) throws IOException {
299- XeroJAXBMarshaller u = new XeroJAXBMarshaller ();
298+ // XeroJAXBMarshaller u = new XeroJAXBMarshaller();
300299
301- OAuthRequestResource req = new OAuthRequestResource (config , signerFactory , endPoint , "DELETE" , null , null );
300+ OAuthRequestResource req = new OAuthRequestResource (config , signerFactory , endPoint , "DELETE" , null , null );
302301 req .setToken (token );
303302 req .setTokenSecret (tokenSecret );
304303
305304 try {
306- Map <String , String > resp = req .execute ();
307- Object r = resp .get ("content" );
305+ Map <String , String > resp = req .execute ();
306+ Object r = resp .get ("content" );
308307 return u .unmarshall (r .toString (), Response .class );
309308 } catch (IOException ioe ) {
310- logger .error (ioe );
311- throw xeroExceptionHandler .convertException (ioe );
309+ logger .error (ioe );
310+ throw xeroExceptionHandler .convertException (ioe );
312311 } catch (XeroApiException e ) {
313- logger .error (e );
314- throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
312+ logger .error (e );
313+ throw this .xeroExceptionHandler .handleBadRequest (e .getMessage (),e .getResponseCode ());
315314 }
316315 }
317316
0 commit comments