@Override public void createTable(String apiKey, String table, TableOptions options, Map<String, ?> template, Audit audit) throws TableExistsException { checkNotNull(table, "table"); checkNotNull(options, "options"); checkNotNull(template, "template"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_table", table) .queryParam("options", RisonHelper.asORison(options)) .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(template); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
@Override public void createTable(String apiKey, String table, TableOptions options, Map<String, ?> template, Audit audit) throws TableExistsException { checkNotNull(table, "table"); checkNotNull(options, "options"); checkNotNull(template, "template"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_table", table) .queryParam("options", RisonHelper.asORison(options)) .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(template); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
@Override public void setTableTemplate(String apiKey, String table, Map<String, ?> template, Audit audit) { checkNotNull(table, "table"); checkNotNull(template, "template"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_table", table, "template") .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(template); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
@Override public void createFacade(String apiKey, String table, FacadeOptions options, Audit audit) throws TableExistsException { checkNotNull(table, "table"); checkNotNull(options, "options"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_facade", table) .queryParam("options", RisonHelper.asORison(options)) .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
@Override public void setTableTemplate(String apiKey, String table, Map<String, ?> template, Audit audit) { checkNotNull(table, "table"); checkNotNull(template, "template"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_table", table, "template") .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(template); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
@Override public void createFacade(String apiKey, String table, FacadeOptions options, Audit audit) throws TableExistsException { checkNotNull(table, "table"); checkNotNull(options, "options"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_facade", table) .queryParam("options", RisonHelper.asORison(options)) .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
return new UnsupportedOperationException("Permanent redirect: " + response.getLocation(), e);
return new UnsupportedOperationException("Permanent redirect: " + response.getLocation(), e);
return new UnsupportedOperationException("Permanent redirect: " + response.getLocation(), e);
return new UnsupportedOperationException("Permanent redirect: " + response.getLocation(), e);