mirror of
https://github.com/apache/olingo-odata4.git
synced 2025-03-08 17:59:41 +00:00
[OLINGO-328] refactor EntitySetProcessor to CollectionProcessor
This commit is contained in:
parent
f70c294a6f
commit
77af7dfab0
@ -22,8 +22,8 @@ import org.apache.olingo.server.api.ODataRequest;
|
||||
import org.apache.olingo.server.api.ODataResponse;
|
||||
import org.apache.olingo.server.api.uri.UriInfo;
|
||||
|
||||
public interface EntitySetProcessor extends Processor {
|
||||
public interface CollectionProcessor extends Processor {
|
||||
|
||||
void readEntitySet(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format);
|
||||
void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format);
|
||||
|
||||
}
|
@ -110,8 +110,8 @@ public class ODataHandler {
|
||||
case entitySet:
|
||||
if (((UriResourcePartTyped) lastPathSegment).isCollection()) {
|
||||
if (request.getMethod().equals(HttpMethod.GET)) {
|
||||
EntitySetProcessor esp = selectProcessor(EntitySetProcessor.class);
|
||||
esp.readEntitySet(request, response, uriInfo, requestedContentType);
|
||||
CollectionProcessor esp = selectProcessor(CollectionProcessor.class);
|
||||
esp.readCollection(request, response, uriInfo, requestedContentType);
|
||||
} else {
|
||||
throw new ODataRuntimeException("not implemented");
|
||||
}
|
||||
@ -127,8 +127,8 @@ public class ODataHandler {
|
||||
case navigationProperty:
|
||||
if (((UriResourceNavigation) lastPathSegment).isCollection()) {
|
||||
if (request.getMethod().equals(HttpMethod.GET)) {
|
||||
EntitySetProcessor esp = selectProcessor(EntitySetProcessor.class);
|
||||
esp.readEntitySet(request, response, uriInfo, requestedContentType);
|
||||
CollectionProcessor esp = selectProcessor(CollectionProcessor.class);
|
||||
esp.readCollection(request, response, uriInfo, requestedContentType);
|
||||
} else {
|
||||
throw new ODataRuntimeException("not implemented");
|
||||
}
|
||||
|
@ -37,13 +37,13 @@ import org.apache.olingo.server.api.OData;
|
||||
import org.apache.olingo.server.api.ODataRequest;
|
||||
import org.apache.olingo.server.api.ODataResponse;
|
||||
import org.apache.olingo.server.api.processor.EntityProcessor;
|
||||
import org.apache.olingo.server.api.processor.EntitySetProcessor;
|
||||
import org.apache.olingo.server.api.processor.CollectionProcessor;
|
||||
import org.apache.olingo.server.api.serializer.ODataSerializer;
|
||||
import org.apache.olingo.server.api.uri.UriInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor {
|
||||
public class SampleJsonProcessor implements CollectionProcessor, EntityProcessor {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SampleJsonProcessor.class);
|
||||
|
||||
private OData odata;
|
||||
@ -56,7 +56,7 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntitySet(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
|
||||
public void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
|
||||
long time = System.nanoTime();
|
||||
|
||||
EntitySet entitySet = createEntitySet();
|
||||
|
@ -25,11 +25,11 @@ import org.apache.olingo.server.api.OData;
|
||||
import org.apache.olingo.server.api.ODataRequest;
|
||||
import org.apache.olingo.server.api.ODataResponse;
|
||||
import org.apache.olingo.server.api.processor.EntityProcessor;
|
||||
import org.apache.olingo.server.api.processor.EntitySetProcessor;
|
||||
import org.apache.olingo.server.api.processor.CollectionProcessor;
|
||||
import org.apache.olingo.server.api.uri.UriInfo;
|
||||
import org.apache.olingo.server.tecsvc.data.DataProvider;
|
||||
|
||||
public class TechnicalProcessor implements EntitySetProcessor, EntityProcessor {
|
||||
public class TechnicalProcessor implements CollectionProcessor, EntityProcessor {
|
||||
|
||||
private OData odata;
|
||||
private Edm edm;
|
||||
@ -52,7 +52,7 @@ public class TechnicalProcessor implements EntitySetProcessor, EntityProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntitySet(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
|
||||
public void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
|
||||
response.setContent(new ByteArrayInputStream("EntitySet".getBytes()));
|
||||
response.setStatusCode(200);
|
||||
}
|
||||
|
@ -168,6 +168,7 @@ public class ODataHandlerTest {
|
||||
|
||||
assertEquals(ODataServiceVersion.V40.toString(), response.getHeaders().get(HttpHeader.ODATA_VERSION));
|
||||
}
|
||||
|
||||
@Test(expected = Exception.class)
|
||||
public void testMaxVersionNotSupported() {
|
||||
ODataRequest request = new ODataRequest();
|
||||
|
Loading…
x
Reference in New Issue
Block a user