From 20a00704d8c51a08c615dba6f3286ea6d53d2f45 Mon Sep 17 00:00:00 2001 From: Klaus Straubinger Date: Thu, 15 Sep 2016 13:54:36 +0200 Subject: [PATCH] [OLINGO-936] clean-up Signed-off-by: Christian Amend --- .../olingo/fit/tecsvc/client/BasicITCase.java | 3 --- .../fit/tecsvc/client/ConformanceITCase.java | 2 -- .../fit/tecsvc/http/BasicStreamITCase.java | 1 - .../core/serialization/JsonDeserializer.java | 1 - .../server/core/debug/ExpressionJsonVisitor.java | 9 ++++++++- .../serializer/json/ODataJsonSerializer.java | 2 +- .../core/serializer/xml/ODataXmlSerializer.java | 2 +- .../processor/TechnicalEntityProcessor.java | 16 +++++++--------- .../expression/ExpressionVisitorImpl.java | 9 ++++++++- 9 files changed, 25 insertions(+), 20 deletions(-) diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java index 63f7fa0f9..8cef37db6 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java @@ -69,8 +69,6 @@ import org.apache.olingo.client.api.domain.ClientObjectFactory; import org.apache.olingo.client.api.domain.ClientPrimitiveValue; import org.apache.olingo.client.api.domain.ClientProperty; import org.apache.olingo.client.api.domain.ClientServiceDocument; -import org.apache.olingo.client.api.domain.ClientSingleton; -import org.apache.olingo.client.api.domain.ClientValuable; import org.apache.olingo.client.api.domain.ClientValue; import org.apache.olingo.client.api.edm.xml.Reference; import org.apache.olingo.client.api.edm.xml.XMLMetadata; @@ -88,7 +86,6 @@ import org.apache.olingo.commons.api.ex.ODataError; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.http.HttpHeader; import org.apache.olingo.commons.api.http.HttpStatusCode; -import static org.junit.Assert.assertNotNull; import org.junit.Ignore; import org.junit.Test; diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConformanceITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConformanceITCase.java index 7ac81a47a..831499af3 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConformanceITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConformanceITCase.java @@ -35,8 +35,6 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.http.HttpHeader; import org.apache.olingo.commons.api.http.HttpStatusCode; -import static org.apache.olingo.fit.tecsvc.client.AbstractTecSvcITCase.SERVICE_NAMESPACE; -import static org.apache.olingo.fit.tecsvc.client.AbstractTecSvcITCase.SERVICE_URI; import static org.junit.Assert.assertEquals; import org.junit.Test; import static org.junit.Assert.assertNotNull; diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicStreamITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicStreamITCase.java index 33eb4f54b..8935f97e6 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicStreamITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicStreamITCase.java @@ -70,7 +70,6 @@ public class BasicStreamITCase extends AbstractBaseTestITCase { assertEquals(ContentType.APPLICATION_XML, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE))); final String content = IOUtils.toString(connection.getInputStream()); -System.out.println(content); assertTrue(content.contains("Streamed-Employee1@company.example" + "Streamed-Employee2@company.example" + "Streamed-Employee3@company.example")); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java index 8775f1735..3691d8be7 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java @@ -30,7 +30,6 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.olingo.client.api.data.ResWrap; import org.apache.olingo.client.api.serialization.ODataDeserializer; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java index b93bb3f63..cff320f97 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java @@ -29,7 +29,14 @@ import org.apache.olingo.server.api.uri.UriResource; import org.apache.olingo.server.api.uri.UriResourceLambdaAll; import org.apache.olingo.server.api.uri.UriResourceLambdaAny; import org.apache.olingo.server.api.uri.UriResourcePartTyped; -import org.apache.olingo.server.api.uri.queryoption.expression.*; +import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; +import org.apache.olingo.server.api.uri.queryoption.expression.Expression; +import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; +import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; +import org.apache.olingo.server.api.uri.queryoption.expression.Literal; +import org.apache.olingo.server.api.uri.queryoption.expression.Member; +import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind; +import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; import java.util.List; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java index 3d6aa6898..57af7a95d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java @@ -683,7 +683,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer { throws IOException, SerializerException{ json.writeStartObject(); String derivedName = property.getType(); - final EdmComplexType resolvedType = resolveComplexType(metadata, (EdmComplexType) type, derivedName); + final EdmComplexType resolvedType = resolveComplexType(metadata, type, derivedName); if (!isODataMetadataNone && !resolvedType.equals(type) || isODataMetadataFull) { json.writeStringField(Constants.JSON_TYPE, "#" + property.getType()); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java index 06bb13d52..0f0a673d5 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java @@ -1307,7 +1307,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer { || invalidCharacterReplacement == null || isUniCode == null || !isUniCode) { return value; } - String s = (String) value; + String s = value; StringBuilder result = null; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java index c54799299..e6b625ed5 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java @@ -624,22 +624,20 @@ public class TechnicalEntityProcessor extends TechnicalProcessor private void addTo(String name, Object data, List properties) { int pos = 0; for (Property property : properties) { - if(property.isComplex()) { - final List cvs; - if(property.isCollection()) { - cvs = (List) property.asCollection(); - } else { - cvs = Collections.singletonList(property.asComplex()); - } + if (property.isComplex()) { + @SuppressWarnings("unchecked") + final List cvs = property.isCollection() ? + (List) property.asCollection() : + Collections.singletonList(property.asComplex()); for (ComplexValue cv : cvs) { final List value = cv.getValue(); - if(value != null) { + if (value != null) { addTo(name, data, value); } } } - if(name.equals(property.getName())) { + if (name.equals(property.getName())) { properties.remove(pos); final String old = property.getValue().toString(); String newValue = (old == null ? "": old) + data.toString(); diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java index 3748ab88b..475925c2c 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java @@ -38,7 +38,14 @@ import org.apache.olingo.server.api.uri.UriParameter; import org.apache.olingo.server.api.uri.UriResource; import org.apache.olingo.server.api.uri.UriResourceFunction; import org.apache.olingo.server.api.uri.UriResourceProperty; -import org.apache.olingo.server.api.uri.queryoption.expression.*; +import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; +import org.apache.olingo.server.api.uri.queryoption.expression.Expression; +import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; +import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; +import org.apache.olingo.server.api.uri.queryoption.expression.Literal; +import org.apache.olingo.server.api.uri.queryoption.expression.Member; +import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind; +import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; import org.apache.olingo.server.tecsvc.data.DataProvider; import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.TypedOperand; import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.UntypedOperand;