public void visit(EntityResponse response) throws ODataLibraryException, ODataApplicationException { EntityCollection entitySet = (EntityCollection)queryResponse; if (entitySet.getEntities().isEmpty()) { if (visitor.hasNavigation()) { response.writeNoContent(true); } else { response.writeNotFound(true); } } else { response.writeReadEntity(visitor.getContext().getEdmEntityType(), entitySet.getEntities().get(0)); } }
@Override public void visit(EntityResponse response) throws ODataApplicationException, SerializerException { if (details.entity == null) { /*Sometimes there can be navigation entity might be null, therefore according to the ODATA spec we should send NoContent Header */ if (details.eTagMatched) { response.writeNoContent(true); } else { response.writeNotFound(true); } } else { if (details.eTagMatched) { response.writeReadEntity(details.entityType, details.entity); } else { response.getODataResponse().setStatusCode(HttpStatusCode.PRECONDITION_FAILED.getStatusCode()); } } } });
Entity entity = getEntity(request.getEntitySet().getEntityType(), keys, baseUrl); if (entity == null) { response.writeNotFound(true); if (log.isDebugEnabled()) { StringBuilder message = new StringBuilder(); response.writeNotModified(); } else { response.writeNotFound(true);
Entity entity = getEntity(request.getEntitySet().getEntityType(), keys, baseUrl); if (entity == null) { response.writeNotFound(true); if (log.isDebugEnabled()) { StringBuilder message = new StringBuilder();
public void writeReadEntity(EdmEntityType entityType, Entity entity) throws SerializerException { assert (!isClosed()); if (entity == null) { writeNotFound(true); return; } if (ContentTypeHelper.isODataMetadataFull(this.responseContentType)) { EdmAction action = this.metadata.getEdm().getBoundActionWithBindingType( entityType.getFullQualifiedName(), false); if (action != null) { entity.getOperations().add(buildOperation(action, entity.getId().toASCIIString())); } List<EdmFunction> functions = this.metadata.getEdm() .getBoundFunctionsWithBindingType(entityType.getFullQualifiedName(),false); for (EdmFunction function:functions) { entity.getOperations().add(buildOperation(function, entity.getId().toASCIIString())); } } // write the entity to response this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options).getContent()); writeOK(responseContentType); close(); }
public void writeReadEntity(EdmEntityType entityType, Entity entity) throws SerializerException { assert (!isClosed()); if (entity == null) { writeNotFound(true); return; } if (ContentTypeHelper.isODataMetadataFull(this.responseContentType)) { EdmAction action = this.metadata.getEdm().getBoundActionWithBindingType( entityType.getFullQualifiedName(), false); if (action != null) { entity.getOperations().add(buildOperation(action, entity.getId().toASCIIString())); } List<EdmFunction> functions = this.metadata.getEdm() .getBoundFunctionsWithBindingType(entityType.getFullQualifiedName(),false); for (EdmFunction function:functions) { entity.getOperations().add(buildOperation(function, entity.getId().toASCIIString())); } } // write the entity to response this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options).getContent()); writeOK(responseContentType); close(); }