From 8f40d49c463630fe494ba772f3d6e5635bbb77ea Mon Sep 17 00:00:00 2001 From: ramya vasanth Date: Tue, 24 Oct 2017 11:15:15 +0530 Subject: [PATCH] [OLINGO-1191]Code improvements --- .../core/edm/xml/ClientCsdlParameter.java | 4 +- .../core/edm/xml/ClientCsdlProperty.java | 4 +- .../core/edm/xml/ClientCsdlReturnType.java | 4 +- .../client/core/edm/xml/ClientCsdlTerm.java | 4 +- .../edm/xml/ClientCsdlTypeDefinition.java | 2 +- .../edm/xml/annotation/ClientCsdlCast.java | 4 +- .../ClientCsdlDynamicExpression.java | 2 +- .../edm/xml/annotation/ClientCsdlIsOf.java | 4 +- .../core/serialization/AtomSerializer.java | 13 +- .../core/serialization/ODataBinderImpl.java | 5 +- .../olingo/client/core/uri/URIUtils.java | 1 - .../core/edm/EdmNavigationPropertyImpl.java | 6 +- .../commons/core/edm/EdmSchemaImpl.java | 54 ++++---- .../core/edm/primitivetype/EdmDecimal.java | 2 +- .../olingo/server/core/MetadataParser.java | 130 +++++++++--------- .../olingo/server/core/ServiceDispatcher.java | 17 +-- .../olingo/server/core/ServiceRequest.java | 6 +- .../server/core/requests/DataRequest.java | 16 +-- .../core/requests/OperationRequest.java | 16 +-- .../batch/BatchQueryOperation.java | 2 +- .../server/core/etag/ETagHelperImpl.java | 2 +- .../olingo/server/core/etag/ETagParser.java | 4 +- .../olingo/server/core/uri/parser/Parser.java | 10 +- 23 files changed, 139 insertions(+), 173 deletions(-) diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlParameter.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlParameter.java index dc4f41e53..1b8d05d56 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlParameter.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlParameter.java @@ -62,12 +62,12 @@ class ClientCsdlParameter extends CsdlParameter implements Serializable { parameter.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("MaxLength".equals(jp.getCurrentName())) { final String maxLenght = jp.nextTextValue(); - parameter.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + parameter.setMaxLength("max".equalsIgnoreCase(maxLenght) ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("Precision".equals(jp.getCurrentName())) { parameter.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); - parameter.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + parameter.setScale("variable".equalsIgnoreCase(scale) ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { final String srid = jp.nextTextValue(); if (srid != null) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlProperty.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlProperty.java index 0fc75070a..86a87156c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlProperty.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlProperty.java @@ -64,12 +64,12 @@ class ClientCsdlProperty extends CsdlProperty implements Serializable { property.setDefaultValue(jp.nextTextValue()); } else if ("MaxLength".equals(jp.getCurrentName())) { final String maxLenght = jp.nextTextValue(); - property.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + property.setMaxLength("max".equalsIgnoreCase(maxLenght) ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("Precision".equals(jp.getCurrentName())) { property.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); - property.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + property.setScale("variable".equalsIgnoreCase(scale) ? 0 : Integer.valueOf(scale)); } else if ("Unicode".equals(jp.getCurrentName())) { property.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("SRID".equals(jp.getCurrentName())) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReturnType.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReturnType.java index 21f1183ed..ceffc2336 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReturnType.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReturnType.java @@ -59,12 +59,12 @@ class ClientCsdlReturnType extends CsdlReturnType implements Serializable { returnType.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("MaxLength".equals(jp.getCurrentName())) { final String maxLenght = jp.nextTextValue(); - returnType.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + returnType.setMaxLength("max".equalsIgnoreCase(maxLenght) ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("Precision".equals(jp.getCurrentName())) { returnType.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); - returnType.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + returnType.setScale("variable".equalsIgnoreCase(scale) ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { final String srid = jp.nextTextValue(); if (srid != null) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTerm.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTerm.java index 48b514e95..df3dc3930 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTerm.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTerm.java @@ -59,12 +59,12 @@ class ClientCsdlTerm extends CsdlTerm implements Serializable { term.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("MaxLength".equals(jp.getCurrentName())) { final String maxLenght = jp.nextTextValue(); - term.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + term.setMaxLength("max".equalsIgnoreCase(maxLenght) ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("Precision".equals(jp.getCurrentName())) { term.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); - term.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + term.setScale("variable".equalsIgnoreCase(scale) ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { final String srid = jp.nextTextValue(); if (srid != null) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTypeDefinition.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTypeDefinition.java index 136f30e77..ba271dae9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTypeDefinition.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTypeDefinition.java @@ -57,7 +57,7 @@ class ClientCsdlTypeDefinition extends CsdlTypeDefinition implements Serializabl typeDefinition.setPrecision(jp.nextIntValue(0)); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); - typeDefinition.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + typeDefinition.setScale("variable".equalsIgnoreCase(scale) ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { final String srid = jp.nextTextValue(); if (srid != null) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlCast.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlCast.java index 8756d9303..e62c48f2b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlCast.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlCast.java @@ -51,12 +51,12 @@ class ClientCsdlCast extends CsdlCast implements Serializable { cast.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); } else if ("MaxLength".equals(jp.getCurrentName())) { final String maxLenght = jp.nextTextValue(); - cast.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + cast.setMaxLength("max".equalsIgnoreCase(maxLenght) ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("Precision".equals(jp.getCurrentName())) { cast.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); - cast.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + cast.setScale("variable".equalsIgnoreCase(scale) ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { final String srid = jp.nextTextValue(); if (srid != null) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java index e4f85e222..8e41a642c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java @@ -90,7 +90,7 @@ public abstract class ClientCsdlDynamicExpression extends CsdlDynamicExpression } not.setLeft(jp.readValueAs(ClientCsdlDynamicExpression.class)); // Search for end object - while (jp.getCurrentToken() != JsonToken.END_OBJECT || !jp.getCurrentName().equals("Not")) { + while (jp.getCurrentToken() != JsonToken.END_OBJECT || !"Not".equals(jp.getCurrentName())) { jp.nextToken(); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlIsOf.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlIsOf.java index 411d6dde7..0244c550b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlIsOf.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlIsOf.java @@ -50,12 +50,12 @@ class ClientCsdlIsOf extends CsdlIsOf implements Serializable { isof.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); } else if ("MaxLength".equals(jp.getCurrentName())) { final String maxLenght = jp.nextTextValue(); - isof.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + isof.setMaxLength("max".equalsIgnoreCase(maxLenght) ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("Precision".equals(jp.getCurrentName())) { isof.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); - isof.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + isof.setScale("variable".equalsIgnoreCase(scale) ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { final String srid = jp.nextTextValue(); if (srid != null) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomSerializer.java index 0b8dce78b..4a2f84089 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomSerializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomSerializer.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import javax.xml.XMLConstants; import javax.xml.stream.XMLOutputFactory; @@ -154,7 +155,7 @@ public class AtomSerializer implements ODataSerializer { } EdmTypeInfo typeInfo = null; - if (property.getType() != null && !property.getValueType().name().equalsIgnoreCase("COMPLEX")) { + if (property.getType() != null && !"COMPLEX".equalsIgnoreCase(property.getValueType().name())) { typeInfo = new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build(); if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) { writer.writeAttribute(Constants.PREFIX_METADATA, Constants.NS_METADATA, @@ -279,13 +280,13 @@ public class AtomSerializer implements ODataSerializer { } } } - for (String title : entitySetLinks.keySet()) { - final ListentitySetLink = entitySetLinks.get(title); + for (Entry> entry : entitySetLinks.entrySet()) { + final ListentitySetLink = entry.getValue(); if (!entitySetLink.isEmpty()) { Link link = new Link(); - link.setTitle(title); + link.setTitle(entry.getKey()); link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE); - link.setRel(Constants.NS_NAVIGATION_LINK_REL+title); + link.setRel(Constants.NS_NAVIGATION_LINK_REL+entry.getKey()); writeLink(writer, link, new ExtraContent() { @Override @@ -302,7 +303,7 @@ public class AtomSerializer implements ODataSerializer { } }); } - } + } } private void links(final XMLStreamWriter writer, final List links) diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java index bc964296b..7d0b61c69 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java @@ -26,6 +26,7 @@ import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.apache.commons.lang3.StringUtils; import org.apache.olingo.client.api.EdmEnabledODataClient; @@ -730,8 +731,8 @@ public class ODataBinderImpl implements ODataBinder { } if (!countMap.isEmpty()) { - for (String name:countMap.keySet()) { - entity.addLink(createLinkFromEmptyNavigationProperty(name, countMap.get(name))); + for (Entry entry : countMap.entrySet()) { + entity.addLink(createLinkFromEmptyNavigationProperty(entry.getKey(), entry.getValue())); } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java index 4553597a4..e7cf3b13b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java @@ -71,7 +71,6 @@ public final class URIUtils { /** * Logger. */ -// private static final Logger LOG = LoggerFactory.getLogger(URIUtils.class); private static final Pattern ENUM_VALUE = Pattern.compile("(.+\\.)?.+'.+'"); private static final String URI_OPTIONS = "/$"; diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyImpl.java index 05abab9f1..a0ee76b03 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyImpl.java @@ -93,9 +93,9 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNamed implements EdmNa @Override public String getReferencingPropertyName(final String referencedPropertyName) { - final List referentialConstraints = navigationProperty.getReferentialConstraints(); - if (referentialConstraints != null) { - for (CsdlReferentialConstraint constraint : referentialConstraints) { + final List refConstraints = navigationProperty.getReferentialConstraints(); + if (refConstraints != null) { + for (CsdlReferentialConstraint constraint : refConstraints) { if (constraint.getReferencedProperty().equals(referencedPropertyName)) { return constraint.getProperty(); } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmSchemaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmSchemaImpl.java index 8d6b2446a..a88faeeb9 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmSchemaImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmSchemaImpl.java @@ -161,105 +161,105 @@ public class EdmSchemaImpl extends AbstractEdmAnnotatable implements EdmSchema { } protected List createTypeDefinitions() { - final List typeDefinitions = new ArrayList(); + final List typeDefns = new ArrayList(); final List providerTypeDefinitions = schema.getTypeDefinitions(); if (providerTypeDefinitions != null) { for (CsdlTypeDefinition def : providerTypeDefinitions) { FullQualifiedName typeDefName = new FullQualifiedName(namespace, def.getName()); EdmTypeDefinitionImpl typeDefImpl = new EdmTypeDefinitionImpl(edm, typeDefName, def); - typeDefinitions.add(typeDefImpl); + typeDefns.add(typeDefImpl); edm.cacheTypeDefinition(typeDefName, typeDefImpl); } } - return typeDefinitions; + return typeDefns; } protected List createEnumTypes() { - final List enumTypes = new ArrayList(); + final List enumTyps = new ArrayList(); final List providerEnumTypes = schema.getEnumTypes(); if (providerEnumTypes != null) { for (CsdlEnumType enumType : providerEnumTypes) { FullQualifiedName enumName = new FullQualifiedName(namespace, enumType.getName()); EdmEnumType enumTypeImpl = new EdmEnumTypeImpl(edm, enumName, enumType); - enumTypes.add(enumTypeImpl); + enumTyps.add(enumTypeImpl); edm.cacheEnumType(enumName, enumTypeImpl); } } - return enumTypes; + return enumTyps; } protected List createEntityTypes() { - final List entityTypes = new ArrayList(); + final List edmEntityTypes = new ArrayList(); final List providerEntityTypes = schema.getEntityTypes(); if (providerEntityTypes != null) { for (CsdlEntityType entityType : providerEntityTypes) { FullQualifiedName entityTypeName = new FullQualifiedName(namespace, entityType.getName()); EdmEntityTypeImpl entityTypeImpl = new EdmEntityTypeImpl(edm, entityTypeName, entityType); - entityTypes.add(entityTypeImpl); + edmEntityTypes.add(entityTypeImpl); edm.cacheEntityType(entityTypeName, entityTypeImpl); } } - return entityTypes; + return edmEntityTypes; } protected List createComplexTypes() { - final List complexTypes = new ArrayList(); + final List edmComplexTypes = new ArrayList(); final List providerComplexTypes = schema.getComplexTypes(); if (providerComplexTypes != null) { for (CsdlComplexType complexType : providerComplexTypes) { FullQualifiedName comlexTypeName = new FullQualifiedName(namespace, complexType.getName()); EdmComplexTypeImpl complexTypeImpl = new EdmComplexTypeImpl(edm, comlexTypeName, complexType); - complexTypes.add(complexTypeImpl); + edmComplexTypes.add(complexTypeImpl); edm.cacheComplexType(comlexTypeName, complexTypeImpl); } } - return complexTypes; + return edmComplexTypes; } protected List createActions() { - final List actions = new ArrayList(); + final List edmActions = new ArrayList(); final List providerActions = schema.getActions(); if (providerActions != null) { for (CsdlAction action : providerActions) { FullQualifiedName actionName = new FullQualifiedName(namespace, action.getName()); EdmActionImpl edmActionImpl = new EdmActionImpl(edm, actionName, action); - actions.add(edmActionImpl); + edmActions.add(edmActionImpl); edm.cacheAction(actionName, edmActionImpl); } } - return actions; + return edmActions; } protected List createFunctions() { - final List functions = new ArrayList(); + final List edmFunctions = new ArrayList(); final List providerFunctions = schema.getFunctions(); if (providerFunctions != null) { for (CsdlFunction function : providerFunctions) { FullQualifiedName functionName = new FullQualifiedName(namespace, function.getName()); EdmFunctionImpl functionImpl = new EdmFunctionImpl(edm, functionName, function); - functions.add(functionImpl); + edmFunctions.add(functionImpl); edm.cacheFunction(functionName, functionImpl); } } - return functions; + return edmFunctions; } protected List createTerms() { - final List terms = new ArrayList(); + final List edmTerms = new ArrayList(); final List providerTerms = schema.getTerms(); if (providerTerms != null) { for (CsdlTerm term : providerTerms) { FullQualifiedName termName = new FullQualifiedName(namespace, term.getName()); EdmTermImpl termImpl = new EdmTermImpl(edm, getNamespace(), term); - terms.add(termImpl); + edmTerms.add(termImpl); edm.cacheTerm(termName, termImpl); } } - return terms; + return edmTerms; } protected List createAnnotationGroups() { - final List annotationGroups = new ArrayList(); + final List edmAnnotationGroups = new ArrayList(); final List providerAnnotations = schema.getAnnotationGroups(); if (providerAnnotations != null) { @@ -271,23 +271,23 @@ public class EdmSchemaImpl extends AbstractEdmAnnotatable implements EdmSchema { targetName = new FullQualifiedName(namespace, annotationGroup.getTarget()); } EdmAnnotationsImpl annotationsImpl = new EdmAnnotationsImpl(edm, annotationGroup); - annotationGroups.add(annotationsImpl); + edmAnnotationGroups.add(annotationsImpl); edm.cacheAnnotationGroup(targetName, annotationsImpl); } } - return annotationGroups; + return edmAnnotationGroups; } protected List createAnnotations() { - final List annotations = new ArrayList(); + final List edmAnnotations = new ArrayList(); final List providerAnnotations = schema.getAnnotations(); if (providerAnnotations != null) { for (CsdlAnnotation annotation : providerAnnotations) { EdmAnnotationImpl annotationImpl = new EdmAnnotationImpl(edm, annotation); - annotations.add(annotationImpl); + edmAnnotations.add(annotationImpl); } } - return annotations; + return edmAnnotations; } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java index 1228c7a72..8044273e4 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java @@ -75,7 +75,7 @@ public final class EdmDecimal extends SingletonPrimitiveType { final Matcher matcher = PATTERN.matcher(value); matcher.matches(); - final int significantIntegerDigits = matcher.group(1).equals("0") ? 0 : matcher.group(1).length(); + final int significantIntegerDigits = "0".equals(matcher.group(1)) ? 0 : matcher.group(1).length(); final int decimals = matcher.group(2) == null ? 0 : matcher.group(2).length(); return (precision == null || precision >= significantIntegerDigits + decimals) && (decimals <= (scale == null ? 0 : scale)); diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/MetadataParser.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/MetadataParser.java index 58868c862..88b8ad2dc 100644 --- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/MetadataParser.java +++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/MetadataParser.java @@ -277,19 +277,19 @@ public class MetadataParser { private void loadCoreVocabulary(SchemaBasedEdmProvider provider, String namespace) throws XMLStreamException { - if(namespace.equalsIgnoreCase("Org.OData.Core.V1")) { + if("Org.OData.Core.V1".equalsIgnoreCase(namespace)) { loadLocalVocabularySchema(provider, "Org.OData.Core.V1", "Org.OData.Core.V1.xml"); - } else if (namespace.equalsIgnoreCase("Org.OData.Capabilities.V1")) { + } else if ("Org.OData.Capabilities.V1".equalsIgnoreCase(namespace)) { loadLocalVocabularySchema(provider, "Org.OData.Capabilities.V1", "Org.OData.Capabilities.V1.xml"); - } else if (namespace.equalsIgnoreCase("Org.OData.Measures.V1")) { + } else if ("Org.OData.Measures.V1".equalsIgnoreCase(namespace)) { loadLocalVocabularySchema(provider, "Org.OData.Measures.V1", "Org.OData.Measures.V1.xml"); } } private boolean isCoreVocabulary(String namespace) { - if(namespace.equalsIgnoreCase("Org.OData.Core.V1") || - namespace.equalsIgnoreCase("Org.OData.Capabilities.V1") || - namespace.equalsIgnoreCase("Org.OData.Measures.V1")) { + if("Org.OData.Core.V1".equalsIgnoreCase(namespace) || + "Org.OData.Capabilities.V1".equalsIgnoreCase(namespace) || + "Org.OData.Measures.V1".equalsIgnoreCase(namespace)) { return true; } return false; @@ -323,9 +323,9 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, SchemaBasedEdmProvider provider, String name) throws XMLStreamException { - if (name.equals("DataServices")) { + if ("DataServices".equals(name)) { readSchema(reader, element, provider); - } else if (name.equals("Reference")) { + } else if ("Reference".equals(name)) { readReference(reader, element, provider, "Reference"); } } @@ -345,17 +345,17 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, EdmxReference reference, String name) throws XMLStreamException { - if (name.equals("Include")) { + if ("Include".equals(name)) { EdmxReferenceInclude include = new EdmxReferenceInclude(attr(element, "Namespace"), attr(element, "Alias")); reference.addInclude(include); - } else if (name.equals("IncludeAnnotations")) { + } else if ("IncludeAnnotations".equals(name)) { EdmxReferenceIncludeAnnotation annotation = new EdmxReferenceIncludeAnnotation( attr(element, "TermNamespace")); annotation.setTargetNamespace(attr(element, "TargetNamespace")); annotation.setQualifier(attr(element, "Qualifier")); reference.addIncludeAnnotation(annotation); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, reference); } } @@ -391,25 +391,25 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, CsdlSchema schema, String name) throws XMLStreamException { - if (name.equals("Action")) { + if ("Action".equals(name)) { readAction(reader, element, schema); - } else if (name.equals("Annotations")) { + } else if ("Annotations".equals(name)) { readAnnotationGroup(reader, element, schema); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, schema); - } else if (name.equals("ComplexType")) { + } else if ("ComplexType".equals(name)) { readComplexType(reader, element, schema); - } else if (name.equals("EntityContainer")) { + } else if ("EntityContainer".equals(name)) { readEntityContainer(reader, element, schema); - } else if (name.equals("EntityType")) { + } else if ("EntityType".equals(name)) { readEntityType(reader, element, schema); - } else if (name.equals("EnumType")) { + } else if ("EnumType".equals(name)) { readEnumType(reader, element, schema); - } else if (name.equals("Function")) { + } else if ("Function".equals(name)) { readFunction(reader, element, schema); - } else if (name.equals("Term")) { + } else if ("Term".equals(name)) { schema.getTerms().add(readTerm(reader, element)); - } else if (name.equals("TypeDefinition")) { + } else if ("TypeDefinition".equals(name)) { schema.getTypeDefinitions().add(readTypeDefinition(reader, element)); } } @@ -593,7 +593,7 @@ public class MetadataParser { if (event.isStartElement()) { StartElement element = event.asStartElement(); - if (element.getName().getLocalPart().equals("Annotation")) { + if ("Annotation".equals(element.getName().getLocalPart())) { reader.nextEvent(); readAnnotations(reader, element, edmObject); } @@ -601,7 +601,7 @@ public class MetadataParser { if (event.isEndElement()) { EndElement element = event.asEndElement(); - if (element.getName().getLocalPart().equals("Annotation")) { + if ("Annotation".equals(element.getName().getLocalPart())) { reader.nextEvent(); } @@ -668,7 +668,7 @@ public class MetadataParser { throws XMLStreamException { // element based expressions - if (!name.equals("Annotation")) { + if (!"Annotation".equals(name)) { // attribute based expressions. readAttributeExpressions(element, target); @@ -680,59 +680,59 @@ public class MetadataParser { } } - if (name.equals("Collection")) { + if ("Collection".equals(name)) { CsdlCollection expr = new CsdlCollection(); readExpressions(reader, element, expr); write(target, expr); - } else if (name.equals("AnnotationPath")) { + } else if ("AnnotationPath".equals(name)) { write(target, new CsdlAnnotationPath().setValue(elementValue(reader, element))); - } else if (name.equals("NavigationPropertyPath")) { + } else if ("NavigationPropertyPath".equals(name)) { write(target, new CsdlNavigationPropertyPath() .setValue(elementValue(reader, element))); - } else if (name.equals("Path")) { + } else if ("Path".equals(name)) { write(target, new CsdlPath().setValue(elementValue(reader, element))); - } else if (name.equals("PropertyPath")) { + } else if ("PropertyPath".equals(name)) { write(target, new CsdlPropertyPath().setValue(elementValue(reader, element))); - } else if (name.equals("UrlRef")) { + } else if ("UrlRef".equals(name)) { CsdlUrlRef expr = new CsdlUrlRef(); readExpressions(reader, element, expr); write(target, expr); - } else if (name.equals("Apply")) { + } else if ("Apply".equals(name)) { CsdlApply expr = new CsdlApply(); expr.setFunction(attr(element, "Function")); readExpressions(reader, element, expr); write(target, expr); - } else if (name.equals("Cast")) { + } else if ("Cast".equals(name)) { CsdlCast expr = new CsdlCast(); expr.setType(attr(element, "Type")); readExpressions(reader, element, expr); write(target, expr); - } else if (name.equals("If")) { + } else if ("If".equals(name)) { CsdlIf expr = new CsdlIf(); readExpressions(reader, element, expr); write(target, expr); - } else if (name.equals("IsOf")) { + } else if ("IsOf".equals(name)) { CsdlIsOf expr = new CsdlIsOf(); expr.setType(attr(element, "Type")); readExpressions(reader, element, expr); write(target, expr); - } else if (name.equals("LabeledElement")) { + } else if ("LabeledElement".equals(name)) { CsdlLabeledElement expr = new CsdlLabeledElement(); expr.setName(attr(element, "Name")); readExpressions(reader, element, expr); write(target, expr); - } else if (name.equals("LabeledElementReference")) { + } else if ("LabeledElementReference".equals(name)) { CsdlLabeledElementReference expr = new CsdlLabeledElementReference(); expr.setValue(elementValue(reader, element)); write(target, expr); - } else if (name.equals("Null")) { + } else if ("Null".equals(name)) { write(target, new CsdlNull()); - } else if (name.equals("Record")) { + } else if ("Record".equals(name)) { CsdlRecord expr = new CsdlRecord(); expr.setType(attr(element, "Type")); readPropertyValues(reader, element, expr); write(target, expr); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, (CsdlAnnotatable)target); } } @@ -796,13 +796,13 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, CsdlRecord record, String name) throws XMLStreamException { - if (name.equals("PropertyValue")) { + if ("PropertyValue".equals(name)) { CsdlPropertyValue value = new CsdlPropertyValue(); value.setProperty(attr(element, "Property")); readAttributeExpressions(element, value); readExpressions(reader, element, value); record.getPropertyValues().add(value); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, record); } } @@ -831,11 +831,11 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, CsdlOperation operation, String name) throws XMLStreamException { - if (name.equals("Parameter")) { + if ("Parameter".equals(name)) { readParameter(reader, element, operation); - } else if (name.equals("ReturnType")) { + } else if ("ReturnType".equals(name)) { readReturnType(reader, element, operation); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, operation); } } @@ -863,13 +863,13 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, CsdlEnumType type, String name) throws XMLStreamException { - if (name.equals("Member")) { + if ("Member".equals(name)) { CsdlEnumMember member = new CsdlEnumMember(); member.setName(attr(element, "Name")); member.setValue(attr(element, "Value")); peekAnnotations(reader, name, member); type.getMembers().add(member); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, type); } } @@ -899,13 +899,13 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, CsdlEntityType entityType, String name) throws XMLStreamException { - if (name.equals("Property")) { + if ("Property".equals(name)) { entityType.getProperties().add(readProperty(reader, element)); - } else if (name.equals("NavigationProperty")) { + } else if ("NavigationProperty".equals(name)) { entityType.getNavigationProperties().add(readNavigationProperty(reader, element)); - } else if (name.equals("Key")) { + } else if ("Key".equals(name)) { readKey(reader, element, entityType); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, entityType); } } @@ -942,18 +942,18 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, CsdlNavigationProperty property, String name) throws XMLStreamException { - if (name.equals("ReferentialConstraint")) { + if ("ReferentialConstraint".equals(name)) { CsdlReferentialConstraint constraint = new CsdlReferentialConstraint(); constraint.setProperty(attr(element, "Property")); constraint.setReferencedProperty(attr(element, "ReferencedProperty")); peekAnnotations(reader, name, constraint); property.getReferentialConstraints().add(constraint); - } else if (name.equals("OnDelete")) { + } else if ("OnDelete".equals(name)) { CsdlOnDelete delete = new CsdlOnDelete(); delete.setAction(CsdlOnDeleteAction.valueOf(attr(element, "Action"))); property.setOnDelete(delete); peekAnnotations(reader, name, delete); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, property); } } @@ -1029,15 +1029,15 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, CsdlSchema schema, String name) throws XMLStreamException { - if (name.equals("EntitySet")) { + if ("EntitySet".equals(name)) { readEntitySet(reader, element, container); - } else if (name.equals("Singleton")) { + } else if ("Singleton".equals(name)) { readSingleton(reader, element, container); - } else if (name.equals("ActionImport")) { + } else if ("ActionImport".equals(name)) { readActionImport(reader, element, container); - } else if (name.equals("FunctionImport")) { + } else if ("FunctionImport".equals(name)) { readFunctionImport(reader, element, container); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, container); } } @@ -1103,12 +1103,12 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, CsdlBindingTarget entitySet, String name) throws XMLStreamException { - if (name.equals("NavigationPropertyBinding")) { + if ("NavigationPropertyBinding".equals(name)) { CsdlNavigationPropertyBinding binding = new CsdlNavigationPropertyBinding(); binding.setPath(attr(element, "Path")); binding.setTarget(attr(element, "Target")); entitySet.getNavigationPropertyBindings().add(binding); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, entitySet); } } @@ -1141,11 +1141,11 @@ public class MetadataParser { @Override void build(XMLEventReader reader, StartElement element, CsdlComplexType complexType, String name) throws XMLStreamException { - if (name.equals("Property")) { + if ("Property".equals(name)) { complexType.getProperties().add(readProperty(reader, element)); - } else if (name.equals("NavigationProperty")) { + } else if ("NavigationProperty".equals(name)) { complexType.getNavigationProperties().add(readNavigationProperty(reader, element)); - } else if (name.equals("Annotation")) { + } else if ("Annotation".equals(name)) { readAnnotations(reader, element, complexType); } } @@ -1212,13 +1212,13 @@ public class MetadataParser { while (reader.hasNext()) { if (event.isStartElement()) { StartElement element = event.asStartElement(); - if (element.getName().getLocalPart().equals("Annotation")) { + if ("Annotation".equals(element.getName().getLocalPart())) { skip = true; } } if (event.isEndElement()) { EndElement element = event.asEndElement(); - if (element.getName().getLocalPart().equals("Annotation")) { + if ("Annotation".equals(element.getName().getLocalPart())) { return reader.peek(); } } diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceDispatcher.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceDispatcher.java index 877ea70a4..c6c3a7900 100644 --- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceDispatcher.java +++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceDispatcher.java @@ -106,9 +106,9 @@ public class ServiceDispatcher extends RequestURLHierarchyVisitor { protected void handleException(ODataException e, ContentType contentType, ODataRequest odRequest, ODataResponse odResponse) { - ErrorHandler handler = new ErrorHandler(this.odata, this.metadata, + ErrorHandler errorHandler = new ErrorHandler(this.odata, this.metadata, this.handler, contentType); - handler.handleException(e, odRequest, odResponse); + errorHandler.handleException(e, odRequest, odResponse); } private void internalExecute(UriInfo uriInfo, ODataRequest odRequest, @@ -119,7 +119,7 @@ public class ServiceDispatcher extends RequestURLHierarchyVisitor { // part1, 8.2.6 String isolation = odRequest.getHeader(HttpHeader.ODATA_ISOLATION); - if (isolation != null && isolation.equals("snapshot") && !this.handler.supportsDataIsolation()) { + if (isolation != null && "snapshot".equals(isolation) && !this.handler.supportsDataIsolation()) { odResponse.setStatusCode(HttpStatusCode.PRECONDITION_FAILED.getStatusCode()); return; } @@ -255,17 +255,6 @@ public class ServiceDispatcher extends RequestURLHierarchyVisitor { public void visit(UriInfoEntityId info) { DataRequest dataRequest = new DataRequest(this.odata, this.metadata); this.request = dataRequest; - - /* - // this can relative or absolute form - String id = info.getIdOption().getValue(); - try { - URL url = new URL(id); - this.idOption = url.getPath(); - } catch (MalformedURLException e) { - this.idOption = id; - } - */ super.visit(info); } diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceRequest.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceRequest.java index c973ba69a..f62f305f7 100644 --- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceRequest.java +++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceRequest.java @@ -340,11 +340,11 @@ public abstract class ServiceRequest { rawPath = rawPath.substring(e+path.length()); } - UriInfo uriInfo = new Parser(serviceMetadata.getEdm(), odata).parseUri(rawPath, uri.getQuery(), null, + UriInfo reqUriInfo = new Parser(serviceMetadata.getEdm(), odata).parseUri(rawPath, uri.getQuery(), null, getODataRequest().getRawBaseUri()); ServiceDispatcher dispatcher = new ServiceDispatcher(odata, serviceMetadata, null, customContentType); - dispatcher.visit(uriInfo); - dispatcher.request.setUriInfo(uriInfo); + dispatcher.visit(reqUriInfo); + dispatcher.request.setUriInfo(reqUriInfo); return (DataRequest)dispatcher.request; } } diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java index de26be071..30589b89f 100644 --- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java +++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java @@ -216,16 +216,6 @@ public class DataRequest extends ServiceRequest { return valueRequest; } - /* - private boolean hasMediaStream() { - return this.uriResourceEntitySet != null && this.uriResourceEntitySet.getEntityType().hasStream(); - } - - private InputStream getMediaStream() { - return this.request.getBody(); - } - */ - public void setValueRequest(boolean valueRequest) { this.valueRequest = valueRequest; this.type = new ValueRequest(); @@ -340,7 +330,7 @@ public class DataRequest extends ServiceRequest { // by this specification. boolean ifMatch = getHeader(HttpHeader.IF_MATCH) != null; boolean ifNoneMatch = (getHeader(HttpHeader.IF_NONE_MATCH)!= null - && getHeader(HttpHeader.IF_NONE_MATCH).equals("*")); + && "*".equals(getHeader(HttpHeader.IF_NONE_MATCH))); if(ifMatch) { handler.updateEntity(DataRequest.this, getEntityFromClient(), isPATCH(), getETag(), entityResponse); @@ -620,8 +610,8 @@ public class DataRequest extends ServiceRequest { builder.navOrPropertyPath(edmProperty.getName()); } if (isPropertyComplex()) { - EdmComplexType type = ((UriResourceComplexProperty) uriResourceProperty).getComplexType(); - String select = helper.buildContextURLSelectList(type, getUriInfo().getExpandOption(), + EdmComplexType complexType = ((UriResourceComplexProperty) uriResourceProperty).getComplexType(); + String select = helper.buildContextURLSelectList(complexType, getUriInfo().getExpandOption(), getUriInfo().getSelectOption()); builder.selectList(select); } diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/OperationRequest.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/OperationRequest.java index 9bc797140..9094b33e6 100644 --- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/OperationRequest.java +++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/OperationRequest.java @@ -73,9 +73,7 @@ public abstract class OperationRequest extends ServiceRequest { if (!hasReturnType()) { return null; } - - //final UriHelper helper = odata.createUriHelper(); - + if (isReturnTypePrimitive() || isReturnTypeComplex()) { // Part 1 {10.14, 10.14} since the function return properties does not // represent a Entity property @@ -86,18 +84,6 @@ public abstract class OperationRequest extends ServiceRequest { return builder.build(); } - /* - // EdmTypeKind.ENTITY; - if (isBound()) { - // Bound means, we know the EnitySet of the return type. Part 1 {10.2, - // 10.3} - EdmEntitySet entitySet = this.uriResourceFunction.getFunctionImport().getReturnedEntitySet(); - ContextURL.Builder builder = DataRequest.buildEntitySetContextURL(helper, entitySet, - this.uriInfo, isCollection(), false); - return builder.build(); - } - */ - // EdmTypeKind.ENTITY; Not Bound // Here we do not know the EntitySet, then follow directions from // Part-1{10.2. 10.3} to use diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchQueryOperation.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchQueryOperation.java index a40ecb7fb..0d8fb9259 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchQueryOperation.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchQueryOperation.java @@ -46,7 +46,7 @@ public class BatchQueryOperation implements BatchPart { } protected Line consumeHttpStatusLine(final List message) throws BatchDeserializerException { - if (!message.isEmpty() && !message.get(0).toString().trim().equals("")) { + if (!message.isEmpty() && !"".equals(message.get(0).toString().trim())) { final Line method = message.get(0); message.remove(0); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagHelperImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagHelperImpl.java index 168541f9d..94a219550 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagHelperImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagHelperImpl.java @@ -65,7 +65,7 @@ public class ETagHelperImpl implements ETagHelper { */ protected ETagInformation createETagInformation(final Collection values) { final Collection eTags = ETagParser.parse(values); - final boolean isAll = eTags.size() == 1 && eTags.iterator().next().equals("*"); + final boolean isAll = eTags.size() == 1 && "*".equals(eTags.iterator().next()); return new ETagInformation(isAll, isAll ? Collections. emptySet() : Collections.unmodifiableCollection(eTags)); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagParser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagParser.java index dee4c03be..a5d7986b4 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagParser.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagParser.java @@ -56,7 +56,7 @@ public class ETagParser { Set result = new HashSet(); for (final String value : values) { final Collection part = parse(value); - if (part.size() == 1 && part.iterator().next().equals("*")) { + if (part.size() == 1 && "*".equals(part.iterator().next())) { return part; } else { result.addAll(part); @@ -66,7 +66,7 @@ public class ETagParser { } private static Collection parse(final String value) { - if (value.trim().equals("*")) { + if ("*".equals(value.trim())) { return Collections.singleton("*"); } else { Set result = new HashSet(); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java index 9bee0b65f..470b9f883 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java @@ -142,21 +142,21 @@ public class Parser { ensureLastSegment(firstSegment, 1, numberOfSegments); contextUriInfo.setKind(UriInfoKind.service); - } else if (firstSegment.equals("$batch")) { + } else if ("$batch".equals(firstSegment)) { ensureLastSegment(firstSegment, 1, numberOfSegments); contextUriInfo.setKind(UriInfoKind.batch); - } else if (firstSegment.equals("$metadata")) { + } else if ("$metadata".equals(firstSegment)) { ensureLastSegment(firstSegment, 1, numberOfSegments); contextUriInfo.setKind(UriInfoKind.metadata); contextUriInfo.setFragment(fragment); - } else if (firstSegment.equals("$all")) { + } else if ("$all".equals(firstSegment)) { ensureLastSegment(firstSegment, 1, numberOfSegments); contextUriInfo.setKind(UriInfoKind.all); contextIsCollection = true; - } else if (firstSegment.equals("$entity")) { + } else if ("$entity".equals(firstSegment)) { if (null != contextUriInfo.getIdOption()) { String idOptionText = contextUriInfo.getIdOption().getText(); if (idOptionText.startsWith(HTTP)) { @@ -317,7 +317,7 @@ public class Parser { systemOption = new FilterOptionImpl(); break; case COUNT: - if (optionValue.equals("true") || optionValue.equals("false")) { + if ("true".equals(optionValue) || "false".equals(optionValue)) { systemOption = new CountOptionImpl().setValue(Boolean.parseBoolean(optionValue)); } else { throw new UriParserSyntaxException("Illegal value of $count option!",