/** * * @param properties * @return EntityCollectionPropertiesBuilder */ public EntityCollectionPropertiesBuilder fromProperties (final EntityCollectionSerializerProperties properties) { this.properties.selfLink = properties.getSelfLink(); return this; }
/** * * @param properties * @return EntityCollectionPropertiesBuilder */ public static EntityCollectionPropertiesBuilder fromProperties (final EntityCollectionSerializerProperties properties) { final EntityCollectionPropertiesBuilder builder = EntityCollectionSerializerProperties.serviceRoot(properties.getServiceRoot()); return builder.fromProperties(properties); } }
/** * * @param properties */ public AtomFeedSerializer(final EntityCollectionSerializerProperties properties) { this.properties = properties == null ? EntityCollectionSerializerProperties.serviceRoot(null).build() : properties; }
private String createAtomId(final EntityInfoAggregator eia) throws EntityProviderException { return properties.getServiceRoot() + createSelfLink(eia); } }
/** * * @param properties * @throws EntityProviderException */ public JsonFeedEntitySerializer(final EntityCollectionSerializerProperties properties) { this.properties = properties == null ? EntityCollectionSerializerProperties. serviceRoot(null).build() : properties; }
final EntityCollection data, final boolean isInline) throws EntityProviderException { try { if (properties.getServiceRoot() == null) { throw new EntityProviderProducerException(EntityProviderException.MANDATORY_WRITE_PROPERTY); writer.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, FormatXml.XML_BASE, properties.getServiceRoot() .toASCIIString());
/** * * @param properties * @return EntityCollectionPropertiesBuilder */ public static EntityCollectionPropertiesBuilder fromProperties (final EntityCollectionSerializerProperties properties) { final EntityCollectionPropertiesBuilder builder = EntityCollectionSerializerProperties.serviceRoot(properties.getServiceRoot()); return builder.fromProperties(properties); } }
@Override public ODataResponse writeFeed(EdmEntitySet entitySet, EntityCollection data) throws EntityProviderException { final EntityCollectionSerializerProperties properties = data == null ? EntityCollectionSerializerProperties.serviceRoot(null).build() : data.getCollectionProperties() == null ? EntityCollectionSerializerProperties.serviceRoot(null).build() : data.getCollectionProperties(); final EntityInfoAggregator entityInfo = EntityInfoAggregator.create(entitySet, null); CircleStreamBuffer buffer = new CircleStreamBuffer(); try { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(buffer.getOutputStream(), DEFAULT_CHARSET)); new JsonFeedEntitySerializer(properties).appendAsObject(writer, entityInfo, data); writer.flush(); buffer.closeWrite(); return ODataResponse.entity(buffer.getInputStream()).build(); } catch (EntityProviderException e) { buffer.close(); throw e; } catch (Exception e) { buffer.close(); throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
private void appendEntries(final XMLStreamWriter writer, final EntityInfoAggregator eia, final EntityCollection data) throws EntityProviderException { AtomEntryEntitySerializer entryProvider; for (Entity singleEntryData : data.getEntities()) { entryProvider = singleEntryData.getWriteProperties() == null? data.getGlobalEntityProperties() == null ? new AtomEntryEntitySerializer (EntitySerializerProperties.serviceRoot(data.getCollectionProperties().getServiceRoot()).build()) : new AtomEntryEntitySerializer(data.getGlobalEntityProperties()): new AtomEntryEntitySerializer(singleEntryData.getWriteProperties()); entryProvider.append(writer, eia, singleEntryData, false, true); } }
/** * * @param properties * @return EntityCollectionPropertiesBuilder */ public EntityCollectionPropertiesBuilder fromProperties (final EntityCollectionSerializerProperties properties) { this.properties.selfLink = properties.getSelfLink(); return this; }
private void appendInlineFeed(final XMLStreamWriter writer, final String navigationPropertyName, final EntityInfoAggregator eia, final Entity data) throws EntityProviderException, XMLStreamException, EdmException { if (eia.getNavigationPropertyNames().contains(navigationPropertyName) && data != null && data.getNavigations().containsKey(navigationPropertyName)) { EdmNavigationProperty navProp = (EdmNavigationProperty) eia.getEntityType().getProperty(navigationPropertyName); if (navProp == null) { throw new EntityProviderProducerException(EntityProviderException.EXPANDNOTSUPPORTED); } EntityCollection inlineData; inlineData = (EntityCollection) data.getNavigation(navigationPropertyName); if (inlineData == null) { inlineData = new EntityCollection(); } if (inlineData.getEntities().isEmpty()) { return; } writer.writeStartElement(Edm.NAMESPACE_M_2007_08, FormatXml.M_INLINE); EntityCollectionSerializerProperties inlineProperties = inlineData.getCollectionProperties() == null ? EntityCollectionSerializerProperties.serviceRoot(data.getWriteProperties().getServiceRoot()).build() : inlineData.getCollectionProperties(); EdmEntitySet inlineEntitySet = eia.getEntitySet().getRelatedEntitySet(navProp); AtomFeedSerializer inlineFeedProducer = new AtomFeedSerializer(inlineProperties); inlineData.setCollectionProperties(inlineProperties); EntityInfoAggregator inlineEia = EntityInfoAggregator.create(inlineEntitySet, null); inlineFeedProducer.append(writer, inlineEia, inlineData, true); writer.writeEndElement(); } }
private void appendEntries(final Writer writer, final EntityInfoAggregator entityInfo, final EntityCollection data, JsonStreamWriter jsonStreamWriter) throws EntityProviderException, IOException { boolean first = true; for (Entity entryData : data.getEntities()) { if (first) { first = false; } else { jsonStreamWriter.separator(); } EntitySerializerProperties entryProperties = entryData == null || entryData.getWriteProperties() == null ? data.getGlobalEntityProperties() != null? data.getGlobalEntityProperties(): EntitySerializerProperties. serviceRoot(properties.getServiceRoot()). build() : entryData.getWriteProperties(); JsonEntryEntitySerializer entryProducer = new JsonEntryEntitySerializer(entryProperties); entryProducer.append(writer, entityInfo, entryData); } } }
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); } }
serviceRoot(properties.getServiceRoot()).build() : inlineData.getCollectionProperties(); JsonFeedEntitySerializer jsonFeedEntityProducer = new JsonFeedEntitySerializer(inlineProperties);