You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2014/07/03 09:16:50 UTC
[53/55] [abbrv] git commit: [OLINGO-328] refactoring
[OLINGO-328] refactoring
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/a51146a4
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/a51146a4
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/a51146a4
Branch: refs/heads/Olingo-317_DeSerializerRefactoring
Commit: a51146a46f43ca6f11fba52a3b762450d0d02858
Parents: b97226b
Author: Stephan Klevenz <st...@sap.com>
Authored: Tue Jul 1 15:07:46 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Tue Jul 1 15:07:46 2014 +0200
----------------------------------------------------------------------
.../apache/olingo/server/core/ContentNegotiator.java | 8 +++++---
.../org/apache/olingo/server/core/ODataHandler.java | 15 ++++++---------
.../olingo/server/core/ContentNegotiatorTest.java | 4 +---
3 files changed, 12 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a51146a4/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
index 3252767..5956df8 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
@@ -38,7 +38,9 @@ public class ContentNegotiator {
private final static Logger LOG = LoggerFactory.getLogger(ContentNegotiator.class);
- private List<FormatContentTypeMapping>
+ private ContentNegotiator() {}
+
+ private static List<FormatContentTypeMapping>
getDefaultSupportedContentTypes(final Class<? extends Processor> processorClass) {
List<FormatContentTypeMapping> defaults = new ArrayList<FormatContentTypeMapping>();
@@ -51,7 +53,7 @@ public class ContentNegotiator {
return defaults;
}
- private List<FormatContentTypeMapping> getSupportedContentTypes(final Processor processor,
+ private static List<FormatContentTypeMapping> getSupportedContentTypes(final Processor processor,
final Class<? extends Processor> processorClass) {
List<FormatContentTypeMapping> supportedContentTypes = getDefaultSupportedContentTypes(processorClass);
@@ -64,7 +66,7 @@ public class ContentNegotiator {
return supportedContentTypes;
}
- public String doContentNegotiation(final FormatOption formatOption, final ODataRequest request,
+ public static String doContentNegotiation(final FormatOption formatOption, final ODataRequest request,
final Processor processor, final Class<? extends Processor> processorClass) {
String requestedContentType = null;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a51146a4/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
index 419b047..fdb47a2 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
@@ -75,15 +75,13 @@ public class ODataHandler {
UriValidator validator = new UriValidator();
validator.validate(uriInfo, request.getMethod());
- ContentNegotiator contentNegotiator = new ContentNegotiator();
-
String requestedContentType = null;
switch (uriInfo.getKind()) {
case metadata:
MetadataProcessor mp = selectProcessor(MetadataProcessor.class);
requestedContentType =
- contentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, mp, MetadataProcessor.class);
+ ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, mp, MetadataProcessor.class);
mp.readMetadata(request, response, uriInfo, requestedContentType);
break;
@@ -95,7 +93,7 @@ public class ODataHandler {
ServiceDocumentProcessor sdp = selectProcessor(ServiceDocumentProcessor.class);
requestedContentType =
- contentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, sdp,
+ ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, sdp,
ServiceDocumentProcessor.class);
sdp.readServiceDocument(request, response, uriInfo, requestedContentType);
@@ -120,7 +118,6 @@ public class ODataHandler {
int lastPathSegmentIndex = uriInfo.getUriResourceParts().size() - 1;
UriResource lastPathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex);
String requestedContentType = null;
- ContentNegotiator contentNegotiator = new ContentNegotiator();
switch (lastPathSegment.getKind()) {
case entitySet:
@@ -129,7 +126,7 @@ public class ODataHandler {
CollectionProcessor cp = selectProcessor(CollectionProcessor.class);
requestedContentType =
- contentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, cp, CollectionProcessor.class);
+ ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, cp, CollectionProcessor.class);
cp.readCollection(request, response, uriInfo, requestedContentType);
} else {
@@ -140,7 +137,7 @@ public class ODataHandler {
EntityProcessor ep = selectProcessor(EntityProcessor.class);
requestedContentType =
- contentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, ep, EntityProcessor.class);
+ ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, ep, EntityProcessor.class);
ep.readEntity(request, response, uriInfo, requestedContentType);
} else {
@@ -154,7 +151,7 @@ public class ODataHandler {
CollectionProcessor cp = selectProcessor(CollectionProcessor.class);
requestedContentType =
- contentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, cp, CollectionProcessor.class);
+ ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, cp, CollectionProcessor.class);
cp.readCollection(request, response, uriInfo, requestedContentType);
} else {
@@ -165,7 +162,7 @@ public class ODataHandler {
EntityProcessor ep = selectProcessor(EntityProcessor.class);
requestedContentType =
- contentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, ep, EntityProcessor.class);
+ ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, ep, EntityProcessor.class);
ep.readEntity(request, response, uriInfo, requestedContentType);
} else {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a51146a4/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
index fd7fcaa..66db64a 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
@@ -144,8 +144,6 @@ public class ContentNegotiatorTest {
request.setMethod(HttpMethod.GET);
request.setRawODataPath("/" + (useCase[1] == null ? "" : "?$format=" + useCase[1]));
- ContentNegotiator cn = new ContentNegotiator();
-
ProcessorStub p = new ProcessorStub(createCustomContentTypeMapping(useCase[3], useCase[4]));
FormatOption fo = null;
@@ -158,7 +156,7 @@ public class ContentNegotiatorTest {
request.addHeader(HttpHeader.ACCEPT, Arrays.asList(useCase[2]));
}
- String requestedContentType = cn.doContentNegotiation(fo, request, p, processorClass);
+ String requestedContentType = ContentNegotiator.doContentNegotiation(fo, request, p, processorClass);
assertNotNull(requestedContentType);
assertEquals(useCase[0], requestedContentType);