public ODataEntityProviderPropertiesBuilder getBuilderAfterURLRewrite() throws ODataException { URI rootURI = extractServiceRoot(); ODataEntityProviderPropertiesBuilder propertiesBuilder = null; propertiesBuilder = EntityProviderWriteProperties.serviceRoot(rootURI); return propertiesBuilder; }
public ODataEntityProviderPropertiesBuilder fromProperties(final EntityProviderWriteProperties properties) { this.properties.mediaResourceMimeType = properties.getMediaResourceMimeType(); this.properties.inlineCountType = properties.getInlineCountType(); this.properties.inlineCount = properties.getInlineCount(); this.properties.nextLink = properties.getNextLink(); this.properties.expandSelectTree = properties.getExpandSelectTree(); this.properties.callbacks = properties.getCallbacks(); this.properties.selfLink = properties.getSelfLink(); this.properties.includeSimplePropertyType = properties.includeSimplePropertyType; return this; } }
public static ODataEntityProviderPropertiesBuilder fromProperties(final EntityProviderWriteProperties properties) { final ODataEntityProviderPropertiesBuilder builder = EntityProviderWriteProperties.serviceRoot(properties.getServiceRoot()); return builder.fromProperties(properties); } }
writer.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, FormatXml.XML_BASE, properties.getServiceRoot() .toASCIIString()); if (properties.getInlineCountType() == InlineCount.ALLPAGES) { appendInlineCount(writer, properties.getInlineCount()); if (properties.getNextLink() != null) { appendNextLink(writer, properties.getNextLink());
if (!properties.isOmitJsonWrapper()) { jsonStreamWriter.beginObject() .name(FormatJson.D); if (properties.getInlineCountType() == InlineCount.ALLPAGES) { final int inlineCount = properties.getInlineCount() == null ? 0 : properties.getInlineCount(); jsonStreamWriter.beginObject() .namedStringValueRaw(FormatJson.COUNT, String.valueOf(inlineCount)).separator() final String serviceRoot = properties.getServiceRoot().toASCIIString(); boolean first = true; for (final Map<String, Object> entryData : data) { if (properties.getInlineCountType() == InlineCount.ALLPAGES) { jsonStreamWriter.endObject(); if (!properties.isOmitJsonWrapper()) { jsonStreamWriter.endObject();
if (properties.getCallbacks() != null && properties.getCallbacks().containsKey(navigationPropertyName)) { context.setEntryData(data); context.setCurrentWriteProperties(properties); ExpandSelectTreeNode subNode = properties.getExpandSelectTree().getLinks().get(navigationPropertyName); context.setCurrentExpandSelectTreeNode(subNode); context.setSelfLink(new URI(self)); ODataCallback callback = properties.getCallbacks().get(navigationPropertyName); if (callback == null) { throw new EntityProviderProducerException(EntityProviderException.EXPANDNOTSUPPORTED); if (properties.isOmitInlineForNullData() && inlineData.isEmpty()) { return; AtomFeedProducer inlineFeedProducer = new AtomFeedProducer(inlineProperties); EntityInfoAggregator inlineEia = EntityInfoAggregator.create(inlineEntitySet, inlineProperties.getExpandSelectTree()); inlineFeedProducer.append(writer, inlineEia, inlineData, true);
.name(FormatJson.D); if (properties.getInlineCountType() == InlineCount.ALLPAGES) { final int inlineCount = properties.getInlineCount() == null ? 0 : properties.getInlineCount(); jsonStreamWriter.beginObject() .namedStringValueRaw(FormatJson.COUNT, String.valueOf(inlineCount)).separator() final String serviceRoot = properties.getServiceRoot().toASCIIString(); boolean first = true; for (final Map<String, Object> entryData : data) { if (properties.getInlineCountType() == InlineCount.ALLPAGES) { jsonStreamWriter.endObject();
@Override public ODataResponse writeFeed(final EdmEntitySet entitySet, final List<Map<String, Object>> data, final EntityProviderWriteProperties properties) throws EntityProviderException { final EntityInfoAggregator entityInfo = EntityInfoAggregator.create(entitySet, properties.getExpandSelectTree()); CircleStreamBuffer buffer = new CircleStreamBuffer(); try { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(buffer.getOutputStream(), DEFAULT_CHARSET)); new JsonFeedEntityProducer(properties).append(writer, entityInfo, data, true); writer.flush(); buffer.closeWrite(); return ODataResponse.entity(buffer.getInputStream()).build(); } catch (EntityProviderException e) { buffer.close(); throw e; } catch (Exception e) { buffer.close(); throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
if (properties.getInlineCountType() == InlineCount.ALLPAGES) { final int inlineCount = properties.getInlineCount() == null ? 0 : properties.getInlineCount(); jsonStreamWriter.namedStringValueRaw(FormatJson.COUNT, String.valueOf(inlineCount)).separator(); if (properties.getNextLink() != null) { jsonStreamWriter.separator() .namedStringValue(FormatJson.NEXT, properties.getNextLink());
private void appendRefAttribute(final XMLStreamWriter writer, final EntityInfoAggregator eia, final EntityProviderWriteProperties properties, final Map<String, Object> deletedEntry) throws XMLStreamException, EntityProviderException { String ref = properties.getServiceRoot().toASCIIString() + AtomEntryEntityProducer.createSelfLink(eia, deletedEntry, null); writer.writeAttribute(FormatXml.ATOM_TOMBSTONE_REF, ref); }
context.setEntryData(data); context.setCurrentWriteProperties(properties); context.setCurrentExpandSelectTreeNode(properties.getExpandSelectTree().getLinks().get( navigationPropertyName)); ODataCallback callback = properties.getCallbacks().get(navigationPropertyName); if (callback == null) { throw new EntityProviderProducerException(EntityProviderException.EXPANDNOTSUPPORTED); if(properties.isOmitInlineForNullData() && inlineData.isEmpty()){ writeDeferredUri(entityInfo, navigationPropertyName); return; EntityInfoAggregator.create(inlineEntitySet, inlineProperties.getExpandSelectTree()); if (properties.isResponsePayload()) { jsonFeedEntityProducer.appendAsObject(writer, inlineEntityInfo, inlineData, false); } else { if(properties.isOmitInlineForNullData() && (inlineData == null || inlineData.isEmpty())){ writeDeferredUri(entityInfo, navigationPropertyName); return; final EntityProviderWriteProperties inlineProperties = result.getInlineProperties(); final EntityInfoAggregator inlineEntityInfo = EntityInfoAggregator.create(inlineEntitySet, inlineProperties.getExpandSelectTree()); new JsonEntryEntityProducer(inlineProperties).append(writer, inlineEntityInfo, inlineData, false); } else {
@Override public ODataResponse writeLinks(final EdmEntitySet entitySet, final List<Map<String, Object>> data, final EntityProviderWriteProperties properties) throws EntityProviderException { final EntityInfoAggregator entityInfo = EntityInfoAggregator.create(entitySet, properties.getExpandSelectTree()); CircleStreamBuffer buffer = new CircleStreamBuffer(); try { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(buffer.getOutputStream(), DEFAULT_CHARSET)); new JsonLinksEntityProducer(properties).append(writer, entityInfo, data); writer.flush(); buffer.closeWrite(); ODataResponseBuilder response = ODataResponse.entity(buffer.getInputStream()); if (properties.getInlineCountType() != InlineCount.ALLPAGES) { response = response.header(ODataHttpHeaders.DATASERVICEVERSION, ODataServiceVersion.V10); } return response.build(); } catch (EntityProviderException e) { buffer.close(); throw e; } catch (Exception e) { buffer.close(); throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
if (properties.getCallbacks() != null && properties.getCallbacks().containsKey(navigationPropertyName)) { writer.writeStartElement(Edm.NAMESPACE_M_2007_08, FormatXml.M_INLINE); context.setNavigationProperty(navProp); context.setEntryData(data); ExpandSelectTreeNode subNode = properties.getExpandSelectTree().getLinks().get(navigationPropertyName); context.setCurrentExpandSelectTreeNode(subNode); context.setSelfLink(new URI(self)); ODataCallback callback = properties.getCallbacks().get(navigationPropertyName); if (callback == null) { throw new EntityProviderException(EntityProviderException.EXPANDNOTSUPPORTED); AtomFeedProducer inlineFeedProducer = new AtomFeedProducer(inlineProperties); EntityInfoAggregator inlineEia = EntityInfoAggregator.create(inlineEntitySet, inlineProperties.getExpandSelectTree()); inlineFeedProducer.append(writer, inlineEia, inlineData, true);
private TombstoneCallback getTombstoneCallback() { if (properties.getCallbacks() != null && properties.getCallbacks().containsKey(TombstoneCallback.CALLBACK_KEY_TOMBSTONE)) { TombstoneCallback callback = (TombstoneCallback) properties.getCallbacks().get(TombstoneCallback.CALLBACK_KEY_TOMBSTONE); return callback; } else { return null; } }
if (properties.getInlineCountType() == InlineCount.ALLPAGES) { final int inlineCount = properties.getInlineCount() == null ? 0 : properties.getInlineCount(); jsonStreamWriter.namedStringValueRaw(FormatJson.COUNT, String.valueOf(inlineCount)).separator();
public void append(final Writer writer, final EntityInfoAggregator entityInfo, final Map<String, Object> data) throws EntityProviderException { JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer); final String uri = (properties.getServiceRoot() == null ? "" : properties.getServiceRoot().toASCIIString()) + AtomEntryEntityProducer.createSelfLink(entityInfo, data, null); try { if (!properties.isOmitJsonWrapper()) { jsonStreamWriter.beginObject() .name(FormatJson.D); } appendUri(jsonStreamWriter, uri); if (!properties.isOmitJsonWrapper()) { jsonStreamWriter.endObject(); } } catch (final IOException e) { throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
private void appendAtomSelfLink(final XMLStreamWriter writer, final EntityInfoAggregator eia) throws EntityProviderException { URI self = properties.getSelfLink(); String selfLink = ""; if (self == null) { selfLink = createSelfLink(eia); } else { selfLink = self.toASCIIString(); } try { writer.writeStartElement(FormatXml.ATOM_LINK); writer.writeAttribute(FormatXml.ATOM_HREF, selfLink); writer.writeAttribute(FormatXml.ATOM_REL, Edm.LINK_REL_SELF); writer.writeAttribute(FormatXml.ATOM_TITLE, eia.getEntitySetName()); writer.writeEndElement(); } catch (XMLStreamException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } }
public void append(final XMLStreamWriter writer, final EntityInfoAggregator entityInfo, final List<Map<String, Object>> data) throws EntityProviderException { try { writer.writeStartElement(FormatXml.D_LINKS); writer.writeDefaultNamespace(Edm.NAMESPACE_D_2007_08); if (properties.getInlineCount() != null) { writer.writeStartElement(Edm.PREFIX_M, FormatXml.M_COUNT, Edm.NAMESPACE_M_2007_08); writer.writeNamespace(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08); writer.writeCharacters(properties.getInlineCount().toString()); writer.writeEndElement(); } XmlLinkEntityProducer provider = new XmlLinkEntityProducer(properties); for (final Map<String, Object> entityData : data) { provider.append(writer, entityInfo, entityData, false); } writer.writeEndElement(); writer.flush(); } catch (final XMLStreamException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } } }
private void appendNextLink(final JsonStreamWriter jsonStreamWriter) throws IOException { // Write "next" link. // To be compatible with other implementations out there, the link is // written directly after "__next" and not as "{"uri":"next link"}", // deviating from the OData 2.0 specification. if (properties.getNextLink() != null) { jsonStreamWriter.separator() .namedStringValue(FormatJson.NEXT, properties.getNextLink()); } }
writer.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, FormatXml.XML_BASE, properties.getServiceRoot() .toASCIIString()); if (properties.getInlineCountType() == InlineCount.ALLPAGES) { appendInlineCount(writer, properties.getInlineCount()); if (properties.getNextLink() != null) { appendNextLink(writer, properties.getNextLink());