private void readProperty()

in lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java [203:301]


  private void readProperty(final ODataRequest request, ODataResponse response, final UriInfo uriInfo,
      final ContentType contentType, final RepresentationType representationType)
          throws ODataApplicationException, ODataLibraryException {
    final UriInfoResource resource = uriInfo.asUriInfoResource();
    validateOptions(resource);
    validatePath(resource);
    final EdmEntitySet edmEntitySet = getEdmEntitySet(resource);

    final List<UriResource> resourceParts = resource.getUriResourceParts();
    final int trailing =
        representationType == RepresentationType.COUNT || representationType == RepresentationType.VALUE ? 1 : 0;
    final List<String> path = getPropertyPath(resourceParts, trailing);

    final Entity entity = readEntity(uriInfo);

    if (entity != null && entity.getETag() != null) {
      if (odata.createETagHelper().checkReadPreconditions(entity.getETag(),
          request.getHeaders(HttpHeader.IF_MATCH),
          request.getHeaders(HttpHeader.IF_NONE_MATCH))) {
        response.setStatusCode(HttpStatusCode.NOT_MODIFIED.getStatusCode());
        response.setHeader(HttpHeader.ETAG, entity.getETag());
        return;
      }
    }

    final Property property = entity == null ?
        getPropertyData(
            dataProvider.readFunctionPrimitiveComplex(((UriResourceFunction) resourceParts.get(0)).getFunction(),
            ((UriResourceFunction) resourceParts.get(0)).getParameters(), resource), path) :
        getData(entity, path, resourceParts, resource);

    // TODO: implement filter on collection properties (on a shallow copy of the values)
    // FilterHandler.applyFilterSystemQuery(uriInfo.getFilterOption(), property, uriInfo, serviceMetadata.getEdm());

    if (property == null && representationType != RepresentationType.COUNT) {
      if (representationType == RepresentationType.VALUE) {
        response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
      } else {
        throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
      }
    } else {
      if (property.getValue() == null && representationType != RepresentationType.COUNT) {
        response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
      } else {
        response.setStatusCode(HttpStatusCode.OK.getStatusCode());
        if (representationType == RepresentationType.COUNT) {
          response.setContent(odata.createFixedFormatSerializer().count(
              property.asCollection().size()));
        } else {
          final EdmProperty edmProperty = path.isEmpty() ? null :
              ((UriResourceProperty) resourceParts.get(resourceParts.size() - trailing - 1)).getProperty();
          EdmType type = null;
          if (resourceParts.get(resourceParts.size() - trailing - 1) 
             instanceof UriResourceComplexProperty &&
              ((UriResourceComplexProperty)resourceParts.get(resourceParts.size() - trailing - 1)).
              getComplexTypeFilter() != null) {
            type = ((UriResourceComplexProperty)resourceParts.get(resourceParts.size() - trailing - 1)).
                getComplexTypeFilter();
          }else if(resourceParts.get(resourceParts.size() - trailing - 1) 
             instanceof UriResourceFunction &&
              ((UriResourceFunction)resourceParts.get(resourceParts.size() - trailing - 1)).
              getFunction() != null){ 
            type = ((UriResourceFunction)resourceParts.get(resourceParts.size() - trailing - 1)).
                getType();
          }else {
            type = edmProperty == null ?
                ((UriResourceFunction) resourceParts.get(0)).getType() :
                edmProperty.getType();
          }
          final EdmReturnType returnType = resourceParts.get(0) instanceof UriResourceFunction ?
              ((UriResourceFunction) resourceParts.get(0)).getFunction().getReturnType() : 
                resourceParts.get(1) instanceof UriResourceFunction ? 
                    ((UriResourceFunction) resourceParts.get(1)).getFunction().getReturnType():null ;

          if (representationType == RepresentationType.VALUE) {
            response.setContent(serializePrimitiveValue(property, edmProperty, (EdmPrimitiveType) type, returnType));
          }else if(representationType == RepresentationType.PRIMITIVE && type.getFullQualifiedName()
              .getFullQualifiedNameAsString().equals(EDMSTREAM)){
            response.setContent(odata.createFixedFormatSerializer().binary(dataProvider.readStreamProperty(property)));
            response.setStatusCode(HttpStatusCode.OK.getStatusCode());
            response.setHeader(HttpHeader.CONTENT_TYPE, ((Link)property.getValue()).getType());
            if (entity.getMediaETag() != null) {
              response.setHeader(HttpHeader.ETAG, entity.getMediaETag());
            }
          }else {
            final ExpandOption expand = uriInfo.getExpandOption();
            final SelectOption select = uriInfo.getSelectOption();
            final SerializerResult result = serializeProperty(entity, edmEntitySet, path, property, edmProperty,
                type, returnType, representationType, contentType, expand, select);
            response.setContent(result.getContent());
          }
        }
        response.setHeader(HttpHeader.CONTENT_TYPE, contentType.toContentTypeString());
      }
      if (entity != null && entity.getETag() != null) {
        response.setHeader(HttpHeader.ETAG, entity.getETag());
      }
    }
  }