@Override public Edm getEdm(final String metadataETag) { synchronized (this) { if (this.edm == null || (metadataETag != null && !metadataETag.equals(this.metadataETag))) { final EdmMetadataRequest metadataReq = getRetrieveRequestFactory().getMetadataRequest(serviceRoot); final ODataRetrieveResponse<Edm> metadataRes = metadataReq.execute(); this.metadataETag = metadataRes.getETag(); this.edm = metadataRes.getBody(); } } return this.edm; }
@Override public Edm getEdm(final String metadataETag) { synchronized (this) { if (this.edm == null || (metadataETag != null && !metadataETag.equals(this.metadataETag))) { final EdmMetadataRequest metadataReq = getRetrieveRequestFactory().getMetadataRequest(serviceRoot); final ODataRetrieveResponse<Edm> metadataRes = metadataReq.execute(); this.metadataETag = metadataRes.getETag(); this.edm = metadataRes.getBody(); } } return this.edm; }
@Override protected void load() { // Search against the service final Object key = uuid.getKey(); try { final ODataEntityRequest<ClientEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(uri.build()); req.setPrefer(getClient().newPreferences().includeAnnotations("*")); final ODataRetrieveResponse<ClientEntity> res = req.execute(); final ClientEntity entity = res.getBody(); if (entity == null) { throw new IllegalArgumentException("Invalid " + typeRef.getSimpleName() + "(" + key + ")"); } setEntity(entity); setETag(res.getETag()); if (key != null && !key.equals(CoreUtils.getKey(getClient(), this, typeRef, entity))) { throw new IllegalArgumentException("Invalid " + typeRef.getSimpleName() + "(" + key + ")"); } if (this.stream != null) { this.stream.close(); this.stream = null; } } catch (IllegalArgumentException e) { LOG.warn("Entity '" + uuid + "' not found", e); throw e; } catch (Exception e) { LOG.warn("Error retrieving entity '" + uuid + "'", e); throw new IllegalArgumentException("Error retrieving " + typeRef.getSimpleName() + "(" + key + ")", e); } }
@Override protected void load() { // Search against the service final Object key = uuid.getKey(); try { final ODataEntityRequest<ClientEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(uri.build()); req.setPrefer(getClient().newPreferences().includeAnnotations("*")); final ODataRetrieveResponse<ClientEntity> res = req.execute(); final ClientEntity entity = res.getBody(); if (entity == null) { throw new IllegalArgumentException("Invalid " + typeRef.getSimpleName() + "(" + key + ")"); } setEntity(entity); setETag(res.getETag()); if (key != null && !key.equals(CoreUtils.getKey(getClient(), this, typeRef, entity))) { throw new IllegalArgumentException("Invalid " + typeRef.getSimpleName() + "(" + key + ")"); } if (this.stream != null) { this.stream.close(); this.stream = null; } } catch (IllegalArgumentException e) { LOG.warn("Entity '" + uuid + "' not found", e); throw e; } catch (Exception e) { LOG.warn("Error retrieving entity '" + uuid + "'", e); throw new IllegalArgumentException("Error retrieving " + typeRef.getSimpleName() + "(" + key + ")", e); } }