private boolean isEntityOrNavigationMedia(final UriResource pathSegment) { // This method MUST NOT check if the resource is of type function since these are handled differently return pathSegment instanceof UriResourceEntitySet && ((UriResourceEntitySet) pathSegment).getEntityType().hasStream() || pathSegment instanceof UriResourceNavigation && ((EdmEntityType) ((UriResourceNavigation) pathSegment).getType()).hasStream(); }
private boolean isEntityOrNavigationMedia(final UriResource pathSegment) { // This method MUST NOT check if the resource is of type function since these are handled differently return pathSegment instanceof UriResourceEntitySet && ((UriResourceEntitySet) pathSegment).getEntityType().hasStream() || pathSegment instanceof UriResourceNavigation && ((EdmEntityType) ((UriResourceNavigation) pathSegment).getType()).hasStream(); }
@Override public boolean hasStream() { checkBaseType(); if (hasStream || entityBaseType != null && entityBaseType.hasStream()) { return true; } return false; } }
@Override public boolean hasStream() { checkBaseType(); if (hasStream || entityBaseType != null && entityBaseType.hasStream()) { return true; } return false; } }
private boolean isSingletonMedia(final UriResource pathSegment) { return pathSegment instanceof UriResourceSingleton && ((UriResourceSingleton) pathSegment).getEntityType().hasStream(); }
private boolean isSingletonMedia(final UriResource pathSegment) { return pathSegment instanceof UriResourceSingleton && ((UriResourceSingleton) pathSegment).getEntityType().hasStream(); }
private void appendEntityTypes(final XMLStreamWriter writer, final List<EdmEntityType> entityTypes) throws XMLStreamException { for (EdmEntityType entityType : entityTypes) { writer.writeStartElement(XML_ENTITY_TYPE); writer.writeAttribute(XML_NAME, entityType.getName()); if (entityType.hasStream()) { writer.writeAttribute(XML_HAS_STREAM, "" + entityType.hasStream()); } if (entityType.getBaseType() != null) { writer.writeAttribute(XML_BASE_TYPE, getAliasedFullQualifiedName(entityType.getBaseType(), false)); } if (entityType.isAbstract()) { writer.writeAttribute(ABSTRACT, TRUE); } if (entityType.isOpenType()) { writer.writeAttribute(OPEN_TYPE, TRUE); } appendKey(writer, entityType); appendProperties(writer, entityType); appendNavigationProperties(writer, entityType); appendAnnotations(writer, entityType); writer.writeEndElement(); } }
private void appendEntityTypes(final XMLStreamWriter writer, final List<EdmEntityType> entityTypes) throws XMLStreamException { for (EdmEntityType entityType : entityTypes) { writer.writeStartElement(XML_ENTITY_TYPE); writer.writeAttribute(XML_NAME, entityType.getName()); if (entityType.hasStream()) { writer.writeAttribute(XML_HAS_STREAM, "" + entityType.hasStream()); } if (entityType.getBaseType() != null) { writer.writeAttribute(XML_BASE_TYPE, getAliasedFullQualifiedName(entityType.getBaseType(), false)); } if (entityType.isAbstract()) { writer.writeAttribute(ABSTRACT, TRUE); } if (entityType.isOpenType()) { writer.writeAttribute(OPEN_TYPE, TRUE); } appendKey(writer, entityType); appendProperties(writer, entityType); appendNavigationProperties(writer, entityType); appendAnnotations(writer, entityType); writer.writeEndElement(); } }
private void requireMediaResourceInCaseOfEntity(UriResource resource) throws UriParserSemanticException { // If the resource is an entity or navigatio if (resource instanceof UriResourceEntitySet && !((UriResourceEntitySet) resource).getEntityType().hasStream() || resource instanceof UriResourceNavigation && !((EdmEntityType) ((UriResourceNavigation) resource).getType()).hasStream()) { throw new UriParserSemanticException("$value on entity is only allowed on media resources.", UriParserSemanticException.MessageKeys.NOT_A_MEDIA_RESOURCE, resource.getSegmentValue()); } // Functions can also deliver an entity. In this case we have to check if the returned entity is a media resource if (resource instanceof UriResourceFunction) { EdmType returnType = ((UriResourceFunction) resource).getFunction().getReturnType().getType(); //Collection check is above so not needed here if (returnType instanceof EdmEntityType && !((EdmEntityType) returnType).hasStream()) { throw new UriParserSemanticException("$value on returned entity is only allowed on media resources.", UriParserSemanticException.MessageKeys.NOT_A_MEDIA_RESOURCE, resource.getSegmentValue()); } } }
private void requireMediaResourceInCaseOfEntity(UriResource resource) throws UriParserSemanticException { // If the resource is an entity or navigatio if (resource instanceof UriResourceEntitySet && !((UriResourceEntitySet) resource).getEntityType().hasStream() || resource instanceof UriResourceNavigation && !((EdmEntityType) ((UriResourceNavigation) resource).getType()).hasStream()) { throw new UriParserSemanticException("$value on entity is only allowed on media resources.", UriParserSemanticException.MessageKeys.NOT_A_MEDIA_RESOURCE, resource.getSegmentValue()); } // Functions can also deliver an entity. In this case we have to check if the returned entity is a media resource if (resource instanceof UriResourceFunction) { EdmType returnType = ((UriResourceFunction) resource).getFunction().getReturnType().getType(); //Collection check is above so not needed here if (returnType instanceof EdmEntityType && !((EdmEntityType) returnType).hasStream()) { throw new UriParserSemanticException("$value on returned entity is only allowed on media resources.", UriParserSemanticException.MessageKeys.NOT_A_MEDIA_RESOURCE, resource.getSegmentValue()); } } }
if (entityType.hasStream()) { writer.writeStartElement(NS_ATOM, Constants.ATOM_ELEM_CONTENT); writer.writeAttribute(Constants.ATTR_TYPE, entity.getMediaContentType()); if (!entityType.hasStream()) { writer.writeStartElement(NS_ATOM, Constants.ATOM_ELEM_CONTENT); writer.writeAttribute(Constants.ATTR_TYPE, "application/xml"); if (!entityType.hasStream()) { // content writer.writeEndElement();
if (entityType.hasStream()) { writer.writeStartElement(NS_ATOM, Constants.ATOM_ELEM_CONTENT); writer.writeAttribute(Constants.ATTR_TYPE, entity.getMediaContentType()); if (!entityType.hasStream()) { writer.writeStartElement(NS_ATOM, Constants.ATOM_ELEM_CONTENT); writer.writeAttribute(Constants.ATTR_TYPE, "application/xml"); if (!entityType.hasStream()) { // content writer.writeEndElement();
private void appendEntityTypes(JsonGenerator json, List<EdmEntityType> entityTypes) throws SerializerException, IOException { for (EdmEntityType entityType : entityTypes) { json.writeObjectFieldStart(entityType.getName()); json.writeStringField(KIND, Kind.EntityType.name()); if (entityType.hasStream()) { json.writeBooleanField(HAS_STREAM, entityType.hasStream()); } if (entityType.getBaseType() != null) { json.writeStringField(BASE_TYPE, getAliasedFullQualifiedName(entityType.getBaseType())); } if (entityType.isAbstract()) { json.writeBooleanField(ABSTRACT, entityType.isAbstract()); } appendKey(json, entityType); appendProperties(json, entityType); appendNavigationProperties(json, entityType); appendAnnotations(json, entityType, null); json.writeEndObject(); } }
private void appendEntityTypes(JsonGenerator json, List<EdmEntityType> entityTypes) throws SerializerException, IOException { for (EdmEntityType entityType : entityTypes) { json.writeObjectFieldStart(entityType.getName()); json.writeStringField(KIND, Kind.EntityType.name()); if (entityType.hasStream()) { json.writeBooleanField(HAS_STREAM, entityType.hasStream()); } if (entityType.getBaseType() != null) { json.writeStringField(BASE_TYPE, getAliasedFullQualifiedName(entityType.getBaseType())); } if (entityType.isAbstract()) { json.writeBooleanField(ABSTRACT, entityType.isAbstract()); } appendKey(json, entityType); appendProperties(json, entityType); appendNavigationProperties(json, entityType); appendAnnotations(json, entityType, null); json.writeEndObject(); } }
json.writeStringField(constants.getEtag(), entity.getETag()); if (entityType.hasStream()) { if (entity.getMediaETag() != null) { json.writeStringField(constants.getMediaEtag(), entity.getMediaETag());
json.writeStringField(constants.getEtag(), entity.getETag()); if (entityType.hasStream()) { if (entity.getMediaETag() != null) { json.writeStringField(constants.getMediaEtag(), entity.getMediaETag());
@Override public void updateEntity(DataRequest request, Entity entity, boolean merge, String entityETag, EntityResponse response) throws ODataLibraryException, ODataApplicationException { if (request.getEntitySet().getEntityType().hasStream()) { selectProcessor(MediaEntityProcessor.class).updateMediaEntity( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getRequestContentType(),request.getResponseContentType()); } else { selectProcessor(EntityProcessor.class).updateEntity(request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getRequestContentType(), request.getResponseContentType()); } }
@Override public void createEntity(DataRequest request, Entity entity, EntityResponse response) throws ODataLibraryException, ODataApplicationException { if (request.getEntitySet().getEntityType().hasStream()) { selectProcessor(MediaEntityProcessor.class).createMediaEntity( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getRequestContentType(),request.getResponseContentType()); } else { selectProcessor(EntityProcessor.class).createEntity(request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getRequestContentType(), request.getResponseContentType()); } }
@Override public void createEntity(DataRequest request, Entity entity, EntityResponse response) throws ODataLibraryException, ODataApplicationException { if (request.getEntitySet().getEntityType().hasStream()) { selectProcessor(MediaEntityProcessor.class).createMediaEntity( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getRequestContentType(),request.getResponseContentType()); } else { selectProcessor(EntityProcessor.class).createEntity(request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getRequestContentType(), request.getResponseContentType()); } }
@Override public void updateEntity(DataRequest request, Entity entity, boolean merge, String entityETag, EntityResponse response) throws ODataLibraryException, ODataApplicationException { if (request.getEntitySet().getEntityType().hasStream()) { selectProcessor(MediaEntityProcessor.class).updateMediaEntity( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getRequestContentType(),request.getResponseContentType()); } else { selectProcessor(EntityProcessor.class).updateEntity(request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getRequestContentType(), request.getResponseContentType()); } }