public ODataResponse readEntity(GetEntityUriInfo uriInfo, String contentType) throws ODataException { LOG.debug("Reading Entity: " + uriInfo); if (uriInfo.getNavigationSegments().size() == 0) { EdmEntitySet entitySet = uriInfo.getStartEntitySet(); if (ENTITY_SET_NAME_CARS.equals(entitySet.getName())) { int id = getKeyValue(uriInfo.getKeyPredicates().get(0)); Map<String, Object> data = dataStore.getCar(id); if (data != null) { URI serviceRoot = getContext().getPathInfo().getServiceRoot(); ODataEntityProviderPropertiesBuilder propertiesBuilder = EntityProviderWriteProperties.serviceRoot(serviceRoot); expandManufacturer(uriInfo, serviceRoot, propertiesBuilder); return EntityProvider.writeEntry(contentType, entitySet, data, propertiesBuilder.build()); } } else if (ENTITY_SET_NAME_MANUFACTURERS.equals(entitySet.getName())) { int id = getKeyValue(uriInfo.getKeyPredicates().get(0)); Map<String, Object> data = dataStore.getManufacturer(id); if (data != null) { URI serviceRoot = getContext().getPathInfo().getServiceRoot(); ODataEntityProviderPropertiesBuilder propertiesBuilder = EntityProviderWriteProperties.serviceRoot(serviceRoot); expandCars(uriInfo, serviceRoot, propertiesBuilder); return EntityProvider.writeEntry(contentType, entitySet, data, propertiesBuilder.build()); } } throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } else if (uriInfo.getNavigationSegments().size() == 1) { // navigation first level, simplified example for illustration // purposes only EdmEntitySet entitySet = uriInfo.getTargetEntitySet(); if (ENTITY_SET_NAME_MANUFACTURERS.equals(entitySet.getName())) { int carKey = getKeyValue(uriInfo.getKeyPredicates().get(0)); return EntityProvider.writeEntry( contentType, uriInfo.getTargetEntitySet(), dataStore.getManufacturer(carKey), EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()) .build()); } throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } throw new ODataNotImplementedException(); }