public EdmStreamValue loadStream() { final URI contentSource = getEntity().getMediaContentSource() == null ? getClient().newURIBuilder(baseURI.toASCIIString()).appendValueSegment().build() : getEntity().getMediaContentSource(); if (this.stream == null && typeRef.getAnnotation(EntityType.class).hasStream() && contentSource != null) { final ODataMediaRequest retrieveReq = getClient().getRetrieveRequestFactory().getMediaEntityRequest(contentSource); if (StringUtils.isNotBlank(getEntity().getMediaContentType())) { retrieveReq.setFormat(ContentType.parse(getEntity().getMediaContentType())); } final ODataRetrieveResponse<InputStream> res = retrieveReq.execute(); this.stream = EdmStreamValue.class.cast(Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class<?>[] { EdmStreamValue.class }, new EdmStreamValueHandler(res.getContentType(), res.getBody(), contentSource, service))); } return this.stream; }
public EdmStreamValue loadStream() { final URI contentSource = getEntity().getMediaContentSource() == null ? getClient().newURIBuilder(baseURI.toASCIIString()).appendValueSegment().build() : getEntity().getMediaContentSource(); if (this.stream == null && typeRef.getAnnotation(EntityType.class).hasStream() && contentSource != null) { final ODataMediaRequest retrieveReq = getClient().getRetrieveRequestFactory().getMediaEntityRequest(contentSource); if (StringUtils.isNotBlank(getEntity().getMediaContentType())) { retrieveReq.setFormat(ContentType.parse(getEntity().getMediaContentType())); } final ODataRetrieveResponse<InputStream> res = retrieveReq.execute(); this.stream = EdmStreamValue.class.cast(Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class<?>[] { EdmStreamValue.class }, new EdmStreamValueHandler(res.getContentType(), res.getBody(), contentSource, service))); } return this.stream; }
entity.setMediaContentType(odataEntity.getMediaContentType()); entity.setMediaETag(odataEntity.getMediaETag());
entity.setMediaContentType(odataEntity.getMediaContentType()); entity.setMediaETag(odataEntity.getMediaETag());