[OLINGO-1479]Allow system query option select and expand for POST request
This commit is contained in:
parent
97a714e34f
commit
c62513795e
|
@ -408,7 +408,8 @@ public class UriValidator {
|
||||||
for (SystemQueryOption queryOption : options) {
|
for (SystemQueryOption queryOption : options) {
|
||||||
isSelectOrExpand = ((queryOption.getKind() == SystemQueryOptionKind.EXPAND) ||
|
isSelectOrExpand = ((queryOption.getKind() == SystemQueryOptionKind.EXPAND) ||
|
||||||
(queryOption.getKind() == SystemQueryOptionKind.SELECT)) &&
|
(queryOption.getKind() == SystemQueryOptionKind.SELECT)) &&
|
||||||
(httpMethod == HttpMethod.PUT || httpMethod == HttpMethod.PATCH);
|
(httpMethod == HttpMethod.PUT || httpMethod == HttpMethod.PATCH ||
|
||||||
|
httpMethod == HttpMethod.POST);
|
||||||
}
|
}
|
||||||
return isSelectOrExpand;
|
return isSelectOrExpand;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ public class TechnicalActionProcessor extends TechnicalProcessor
|
||||||
final EdmEntityType type = (EdmEntityType) action.getReturnType().getType();
|
final EdmEntityType type = (EdmEntityType) action.getReturnType().getType();
|
||||||
final EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions.with()
|
final EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions.with()
|
||||||
.contextURL(isODataMetadataNone(responseFormat) ? null : getContextUrl(edmEntitySet, type, false))
|
.contextURL(isODataMetadataNone(responseFormat) ? null : getContextUrl(edmEntitySet, type, false))
|
||||||
|
.expand(uriInfo.getExpandOption())
|
||||||
.build();
|
.build();
|
||||||
response.setContent(odata.createSerializer(responseFormat)
|
response.setContent(odata.createSerializer(responseFormat)
|
||||||
.entityCollection(serviceMetadata, type, collection, options).getContent());
|
.entityCollection(serviceMetadata, type, collection, options).getContent());
|
||||||
|
|
|
@ -353,17 +353,25 @@ public class UriValidatorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void systemQueryOptionsNotAllowedForHttpPostDelete() throws Exception {
|
public void systemQueryOptionsNotAllowedForHttpDelete() throws Exception {
|
||||||
final String[] queryOptions =
|
final String[] queryOptions =
|
||||||
{ QO_FILTER, QO_FORMAT, QO_EXPAND, QO_COUNT, QO_ORDERBY, QO_SEARCH, QO_SELECT, QO_SKIP, QO_TOP, QO_SKIPTOKEN };
|
{ QO_FILTER, QO_FORMAT, QO_EXPAND, QO_COUNT, QO_ORDERBY, QO_SEARCH, QO_SELECT, QO_SKIP, QO_TOP, QO_SKIPTOKEN };
|
||||||
for (int i = 0; i < queryOptions.length; i++) {
|
for (int i = 0; i < queryOptions.length; i++) {
|
||||||
validateWrong(URI_ENTITY, queryOptions[i], HttpMethod.POST,
|
|
||||||
UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD);
|
|
||||||
validateWrong(URI_ENTITY, queryOptions[i], HttpMethod.DELETE,
|
validateWrong(URI_ENTITY, queryOptions[i], HttpMethod.DELETE,
|
||||||
UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD);
|
UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void systemQueryOptionsNotAllowedForHttpPost() throws Exception {
|
||||||
|
final String[] queryOptions =
|
||||||
|
{ QO_FILTER, QO_FORMAT, QO_COUNT, QO_ORDERBY, QO_SEARCH, QO_SKIP, QO_TOP, QO_SKIPTOKEN };
|
||||||
|
for (int i = 0; i < queryOptions.length; i++) {
|
||||||
|
validateWrong(URI_ENTITY, queryOptions[i], HttpMethod.POST,
|
||||||
|
UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void systemQueryOptionsExpandAndSelectAllowedForHttpPutAndPatch() throws Exception {
|
public void systemQueryOptionsExpandAndSelectAllowedForHttpPutAndPatch() throws Exception {
|
||||||
final String[] queryOptions =
|
final String[] queryOptions =
|
||||||
|
@ -371,6 +379,7 @@ public class UriValidatorTest {
|
||||||
for (int i = 0; i < queryOptions.length; i++) {
|
for (int i = 0; i < queryOptions.length; i++) {
|
||||||
validate(URI_ENTITY, queryOptions[i], HttpMethod.PUT);
|
validate(URI_ENTITY, queryOptions[i], HttpMethod.PUT);
|
||||||
validate(URI_ENTITY, queryOptions[i], HttpMethod.PATCH);
|
validate(URI_ENTITY, queryOptions[i], HttpMethod.PATCH);
|
||||||
|
validate(URI_ENTITY, queryOptions[i], HttpMethod.POST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue