private void deleteObject(final String key) { WebClient client = getWebClient() .accept(MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON) .path(CALL_PATH, key); try { client.delete(); } catch (NotFoundException e) { return; } catch (WebApplicationException e) { handleWebException(e); } catch (Throwable e) { if (e instanceof ConnectException || e instanceof ClientException) { if (null != client) { client.reset(); } switchServerURL(client.getBaseURI().toString()); deleteObject(key); } } finally { if (null != client) { client.reset(); } } }
private String lookupObject(final String contextKey) { WebClient client = getWebClient() .accept(MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON) .path(CALL_PATH, contextKey); String object = null; try { object = client.get(String.class); } catch (NotFoundException e) { return null; } catch (WebApplicationException e) { handleWebException(e); } catch (Throwable e) { if (e instanceof ConnectException || e instanceof ClientException) { if (null != client) { client.reset(); } switchServerURL(client.getBaseURI().toString()); return lookupObject(contextKey); } } finally { if (null != client) { client.reset(); } } return object; }
@Override public String saveObject(E ctx) { String key = findAuxiliaryObjectFactory().createObjectKey(ctx); WebClient client = getWebClient() .accept(MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON) .path(CALL_PATH, key); try { Response resp = client.put(findAuxiliaryObjectFactory().marshalObject(ctx)); if (resp.getStatus() == 404) { if (null != client) { client.reset(); } switchServerURL(client.getBaseURI().toString()); return saveObject(ctx); } return key; } catch (WebApplicationException e) { handleWebException(e); } catch (Throwable e) { if (e instanceof ConnectException || e instanceof ClientException) { if (null != client) { client.reset(); } switchServerURL(client.getBaseURI().toString()); return saveObject(ctx); } } finally { if (null != client) { client.reset(); } } return null; }