OLINGO-911: using json serializer for response purpose, but this will ever be used to just send the 204 in cases of update and delete
This commit is contained in:
parent
49b8599432
commit
11e040babc
|
@ -275,6 +275,11 @@ public abstract class ServiceRequest {
|
|||
SerializerException {
|
||||
return this.odata.createSerializer(getResponseContentType());
|
||||
}
|
||||
|
||||
public ODataSerializer getSerializer(ContentType type) throws ContentNegotiatorException,
|
||||
SerializerException {
|
||||
return this.odata.createSerializer(type);
|
||||
}
|
||||
|
||||
public Map<String, String> getPreferences(){
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
|
|
|
@ -51,17 +51,24 @@ public class PropertyResponse extends ServiceResponse {
|
|||
public static PropertyResponse getInstance(ServiceRequest request, ODataResponse response,
|
||||
EdmType edmType, ContextURL contextURL, boolean collection) throws ContentNegotiatorException,
|
||||
SerializerException {
|
||||
|
||||
ContentType type = request.getResponseContentType();
|
||||
ODataSerializer serializer = null;
|
||||
if (type.equals(ContentType.TEXT_PLAIN)) {
|
||||
serializer = request.getSerializer(ContentType.APPLICATION_JSON);
|
||||
} else {
|
||||
serializer = request.getSerializer();
|
||||
}
|
||||
|
||||
if (edmType.getKind() == EdmTypeKind.PRIMITIVE) {
|
||||
PrimitiveSerializerOptions options = request.getSerializerOptions(
|
||||
PrimitiveSerializerOptions.class, contextURL, false);
|
||||
ContentType type = request.getResponseContentType();
|
||||
return new PropertyResponse(request.getServiceMetaData(), request.getSerializer(), response,
|
||||
PrimitiveSerializerOptions.class, contextURL, false);
|
||||
return new PropertyResponse(request.getServiceMetaData(), serializer, response,
|
||||
options, type, collection, request.getPreferences());
|
||||
}
|
||||
ComplexSerializerOptions options = request.getSerializerOptions(ComplexSerializerOptions.class,
|
||||
contextURL, false);
|
||||
ContentType type = request.getResponseContentType();
|
||||
return new PropertyResponse(request.getServiceMetaData(), request.getSerializer(), response,
|
||||
contextURL, false);
|
||||
return new PropertyResponse(request.getServiceMetaData(), serializer, response,
|
||||
options, type, collection, request.getPreferences());
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,18 @@ public class TripPinServiceTest {
|
|||
HttpResponse response = httpGET(baseURL + "/Airlines('AA')/Name/$value", 200);
|
||||
assertEquals("American Airlines", IOUtils.toString(response.getEntity().getContent()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdateRawValue() throws Exception {
|
||||
// Note that in-real services must convert raw value (byte[]) to
|
||||
// the data type it needs to save in in updateProperty method
|
||||
String editUrl = baseURL + "/Airlines('AF')/Name/$value";
|
||||
HttpPut request = new HttpPut(editUrl);
|
||||
request.setEntity(new StringEntity("Safari"));
|
||||
HttpResponse response = httpSend(request, 204);
|
||||
EntityUtils.consumeQuietly(response.getEntity());
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
// TODO: Support geometry types to make this run
|
||||
public void testReadComplexProperty() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue