[OLINGO-1191]Code improvements

This commit is contained in:
ramya vasanth 2017-10-24 11:15:15 +05:30
parent 96223df38d
commit 8f40d49c46
23 changed files with 139 additions and 173 deletions

View File

@ -62,12 +62,12 @@ class ClientCsdlParameter extends CsdlParameter implements Serializable {
parameter.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); parameter.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
} else if ("MaxLength".equals(jp.getCurrentName())) { } else if ("MaxLength".equals(jp.getCurrentName())) {
final String maxLenght = jp.nextTextValue(); 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())) { } else if ("Precision".equals(jp.getCurrentName())) {
parameter.setPrecision(Integer.valueOf(jp.nextTextValue())); parameter.setPrecision(Integer.valueOf(jp.nextTextValue()));
} else if ("Scale".equals(jp.getCurrentName())) { } else if ("Scale".equals(jp.getCurrentName())) {
final String scale = jp.nextTextValue(); 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())) { } else if ("SRID".equals(jp.getCurrentName())) {
final String srid = jp.nextTextValue(); final String srid = jp.nextTextValue();
if (srid != null) { if (srid != null) {

View File

@ -64,12 +64,12 @@ class ClientCsdlProperty extends CsdlProperty implements Serializable {
property.setDefaultValue(jp.nextTextValue()); property.setDefaultValue(jp.nextTextValue());
} else if ("MaxLength".equals(jp.getCurrentName())) { } else if ("MaxLength".equals(jp.getCurrentName())) {
final String maxLenght = jp.nextTextValue(); 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())) { } else if ("Precision".equals(jp.getCurrentName())) {
property.setPrecision(Integer.valueOf(jp.nextTextValue())); property.setPrecision(Integer.valueOf(jp.nextTextValue()));
} else if ("Scale".equals(jp.getCurrentName())) { } else if ("Scale".equals(jp.getCurrentName())) {
final String scale = jp.nextTextValue(); 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())) { } else if ("Unicode".equals(jp.getCurrentName())) {
property.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue())); property.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue()));
} else if ("SRID".equals(jp.getCurrentName())) { } else if ("SRID".equals(jp.getCurrentName())) {

View File

@ -59,12 +59,12 @@ class ClientCsdlReturnType extends CsdlReturnType implements Serializable {
returnType.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); returnType.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
} else if ("MaxLength".equals(jp.getCurrentName())) { } else if ("MaxLength".equals(jp.getCurrentName())) {
final String maxLenght = jp.nextTextValue(); 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())) { } else if ("Precision".equals(jp.getCurrentName())) {
returnType.setPrecision(Integer.valueOf(jp.nextTextValue())); returnType.setPrecision(Integer.valueOf(jp.nextTextValue()));
} else if ("Scale".equals(jp.getCurrentName())) { } else if ("Scale".equals(jp.getCurrentName())) {
final String scale = jp.nextTextValue(); 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())) { } else if ("SRID".equals(jp.getCurrentName())) {
final String srid = jp.nextTextValue(); final String srid = jp.nextTextValue();
if (srid != null) { if (srid != null) {

View File

@ -59,12 +59,12 @@ class ClientCsdlTerm extends CsdlTerm implements Serializable {
term.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); term.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
} else if ("MaxLength".equals(jp.getCurrentName())) { } else if ("MaxLength".equals(jp.getCurrentName())) {
final String maxLenght = jp.nextTextValue(); 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())) { } else if ("Precision".equals(jp.getCurrentName())) {
term.setPrecision(Integer.valueOf(jp.nextTextValue())); term.setPrecision(Integer.valueOf(jp.nextTextValue()));
} else if ("Scale".equals(jp.getCurrentName())) { } else if ("Scale".equals(jp.getCurrentName())) {
final String scale = jp.nextTextValue(); 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())) { } else if ("SRID".equals(jp.getCurrentName())) {
final String srid = jp.nextTextValue(); final String srid = jp.nextTextValue();
if (srid != null) { if (srid != null) {

View File

@ -57,7 +57,7 @@ class ClientCsdlTypeDefinition extends CsdlTypeDefinition implements Serializabl
typeDefinition.setPrecision(jp.nextIntValue(0)); typeDefinition.setPrecision(jp.nextIntValue(0));
} else if ("Scale".equals(jp.getCurrentName())) { } else if ("Scale".equals(jp.getCurrentName())) {
final String scale = jp.nextTextValue(); 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())) { } else if ("SRID".equals(jp.getCurrentName())) {
final String srid = jp.nextTextValue(); final String srid = jp.nextTextValue();
if (srid != null) { if (srid != null) {

View File

@ -51,12 +51,12 @@ class ClientCsdlCast extends CsdlCast implements Serializable {
cast.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); cast.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class));
} else if ("MaxLength".equals(jp.getCurrentName())) { } else if ("MaxLength".equals(jp.getCurrentName())) {
final String maxLenght = jp.nextTextValue(); 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())) { } else if ("Precision".equals(jp.getCurrentName())) {
cast.setPrecision(Integer.valueOf(jp.nextTextValue())); cast.setPrecision(Integer.valueOf(jp.nextTextValue()));
} else if ("Scale".equals(jp.getCurrentName())) { } else if ("Scale".equals(jp.getCurrentName())) {
final String scale = jp.nextTextValue(); 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())) { } else if ("SRID".equals(jp.getCurrentName())) {
final String srid = jp.nextTextValue(); final String srid = jp.nextTextValue();
if (srid != null) { if (srid != null) {

View File

@ -90,7 +90,7 @@ public abstract class ClientCsdlDynamicExpression extends CsdlDynamicExpression
} }
not.setLeft(jp.readValueAs(ClientCsdlDynamicExpression.class)); not.setLeft(jp.readValueAs(ClientCsdlDynamicExpression.class));
// Search for end object // 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(); jp.nextToken();
} }

View File

@ -50,12 +50,12 @@ class ClientCsdlIsOf extends CsdlIsOf implements Serializable {
isof.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); isof.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class));
} else if ("MaxLength".equals(jp.getCurrentName())) { } else if ("MaxLength".equals(jp.getCurrentName())) {
final String maxLenght = jp.nextTextValue(); 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())) { } else if ("Precision".equals(jp.getCurrentName())) {
isof.setPrecision(Integer.valueOf(jp.nextTextValue())); isof.setPrecision(Integer.valueOf(jp.nextTextValue()));
} else if ("Scale".equals(jp.getCurrentName())) { } else if ("Scale".equals(jp.getCurrentName())) {
final String scale = jp.nextTextValue(); 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())) { } else if ("SRID".equals(jp.getCurrentName())) {
final String srid = jp.nextTextValue(); final String srid = jp.nextTextValue();
if (srid != null) { if (srid != null) {

View File

@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLOutputFactory;
@ -154,7 +155,7 @@ public class AtomSerializer implements ODataSerializer {
} }
EdmTypeInfo typeInfo = null; 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(); typeInfo = new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) { if (!EdmPrimitiveTypeKind.String.getFullQualifiedName().toString().equals(typeInfo.internal())) {
writer.writeAttribute(Constants.PREFIX_METADATA, Constants.NS_METADATA, writer.writeAttribute(Constants.PREFIX_METADATA, Constants.NS_METADATA,
@ -279,13 +280,13 @@ public class AtomSerializer implements ODataSerializer {
} }
} }
} }
for (String title : entitySetLinks.keySet()) { for (Entry<String, List<String>> entry : entitySetLinks.entrySet()) {
final List<String>entitySetLink = entitySetLinks.get(title); final List<String>entitySetLink = entry.getValue();
if (!entitySetLink.isEmpty()) { if (!entitySetLink.isEmpty()) {
Link link = new Link(); Link link = new Link();
link.setTitle(title); link.setTitle(entry.getKey());
link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE); 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() { writeLink(writer, link, new ExtraContent() {
@Override @Override

View File

@ -26,6 +26,7 @@ import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.EdmEnabledODataClient; import org.apache.olingo.client.api.EdmEnabledODataClient;
@ -730,8 +731,8 @@ public class ODataBinderImpl implements ODataBinder {
} }
if (!countMap.isEmpty()) { if (!countMap.isEmpty()) {
for (String name:countMap.keySet()) { for (Entry<String, Integer> entry : countMap.entrySet()) {
entity.addLink(createLinkFromEmptyNavigationProperty(name, countMap.get(name))); entity.addLink(createLinkFromEmptyNavigationProperty(entry.getKey(), entry.getValue()));
} }
} }

View File

@ -71,7 +71,6 @@ public final class URIUtils {
/** /**
* Logger. * Logger.
*/ */
// private static final Logger LOG = LoggerFactory.getLogger(URIUtils.class);
private static final Pattern ENUM_VALUE = Pattern.compile("(.+\\.)?.+'.+'"); private static final Pattern ENUM_VALUE = Pattern.compile("(.+\\.)?.+'.+'");
private static final String URI_OPTIONS = "/$"; private static final String URI_OPTIONS = "/$";

View File

@ -93,9 +93,9 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNamed implements EdmNa
@Override @Override
public String getReferencingPropertyName(final String referencedPropertyName) { public String getReferencingPropertyName(final String referencedPropertyName) {
final List<CsdlReferentialConstraint> referentialConstraints = navigationProperty.getReferentialConstraints(); final List<CsdlReferentialConstraint> refConstraints = navigationProperty.getReferentialConstraints();
if (referentialConstraints != null) { if (refConstraints != null) {
for (CsdlReferentialConstraint constraint : referentialConstraints) { for (CsdlReferentialConstraint constraint : refConstraints) {
if (constraint.getReferencedProperty().equals(referencedPropertyName)) { if (constraint.getReferencedProperty().equals(referencedPropertyName)) {
return constraint.getProperty(); return constraint.getProperty();
} }

View File

@ -161,105 +161,105 @@ public class EdmSchemaImpl extends AbstractEdmAnnotatable implements EdmSchema {
} }
protected List<EdmTypeDefinition> createTypeDefinitions() { protected List<EdmTypeDefinition> createTypeDefinitions() {
final List<EdmTypeDefinition> typeDefinitions = new ArrayList<EdmTypeDefinition>(); final List<EdmTypeDefinition> typeDefns = new ArrayList<EdmTypeDefinition>();
final List<CsdlTypeDefinition> providerTypeDefinitions = schema.getTypeDefinitions(); final List<CsdlTypeDefinition> providerTypeDefinitions = schema.getTypeDefinitions();
if (providerTypeDefinitions != null) { if (providerTypeDefinitions != null) {
for (CsdlTypeDefinition def : providerTypeDefinitions) { for (CsdlTypeDefinition def : providerTypeDefinitions) {
FullQualifiedName typeDefName = new FullQualifiedName(namespace, def.getName()); FullQualifiedName typeDefName = new FullQualifiedName(namespace, def.getName());
EdmTypeDefinitionImpl typeDefImpl = new EdmTypeDefinitionImpl(edm, typeDefName, def); EdmTypeDefinitionImpl typeDefImpl = new EdmTypeDefinitionImpl(edm, typeDefName, def);
typeDefinitions.add(typeDefImpl); typeDefns.add(typeDefImpl);
edm.cacheTypeDefinition(typeDefName, typeDefImpl); edm.cacheTypeDefinition(typeDefName, typeDefImpl);
} }
} }
return typeDefinitions; return typeDefns;
} }
protected List<EdmEnumType> createEnumTypes() { protected List<EdmEnumType> createEnumTypes() {
final List<EdmEnumType> enumTypes = new ArrayList<EdmEnumType>(); final List<EdmEnumType> enumTyps = new ArrayList<EdmEnumType>();
final List<CsdlEnumType> providerEnumTypes = schema.getEnumTypes(); final List<CsdlEnumType> providerEnumTypes = schema.getEnumTypes();
if (providerEnumTypes != null) { if (providerEnumTypes != null) {
for (CsdlEnumType enumType : providerEnumTypes) { for (CsdlEnumType enumType : providerEnumTypes) {
FullQualifiedName enumName = new FullQualifiedName(namespace, enumType.getName()); FullQualifiedName enumName = new FullQualifiedName(namespace, enumType.getName());
EdmEnumType enumTypeImpl = new EdmEnumTypeImpl(edm, enumName, enumType); EdmEnumType enumTypeImpl = new EdmEnumTypeImpl(edm, enumName, enumType);
enumTypes.add(enumTypeImpl); enumTyps.add(enumTypeImpl);
edm.cacheEnumType(enumName, enumTypeImpl); edm.cacheEnumType(enumName, enumTypeImpl);
} }
} }
return enumTypes; return enumTyps;
} }
protected List<EdmEntityType> createEntityTypes() { protected List<EdmEntityType> createEntityTypes() {
final List<EdmEntityType> entityTypes = new ArrayList<EdmEntityType>(); final List<EdmEntityType> edmEntityTypes = new ArrayList<EdmEntityType>();
final List<CsdlEntityType> providerEntityTypes = schema.getEntityTypes(); final List<CsdlEntityType> providerEntityTypes = schema.getEntityTypes();
if (providerEntityTypes != null) { if (providerEntityTypes != null) {
for (CsdlEntityType entityType : providerEntityTypes) { for (CsdlEntityType entityType : providerEntityTypes) {
FullQualifiedName entityTypeName = new FullQualifiedName(namespace, entityType.getName()); FullQualifiedName entityTypeName = new FullQualifiedName(namespace, entityType.getName());
EdmEntityTypeImpl entityTypeImpl = new EdmEntityTypeImpl(edm, entityTypeName, entityType); EdmEntityTypeImpl entityTypeImpl = new EdmEntityTypeImpl(edm, entityTypeName, entityType);
entityTypes.add(entityTypeImpl); edmEntityTypes.add(entityTypeImpl);
edm.cacheEntityType(entityTypeName, entityTypeImpl); edm.cacheEntityType(entityTypeName, entityTypeImpl);
} }
} }
return entityTypes; return edmEntityTypes;
} }
protected List<EdmComplexType> createComplexTypes() { protected List<EdmComplexType> createComplexTypes() {
final List<EdmComplexType> complexTypes = new ArrayList<EdmComplexType>(); final List<EdmComplexType> edmComplexTypes = new ArrayList<EdmComplexType>();
final List<CsdlComplexType> providerComplexTypes = schema.getComplexTypes(); final List<CsdlComplexType> providerComplexTypes = schema.getComplexTypes();
if (providerComplexTypes != null) { if (providerComplexTypes != null) {
for (CsdlComplexType complexType : providerComplexTypes) { for (CsdlComplexType complexType : providerComplexTypes) {
FullQualifiedName comlexTypeName = new FullQualifiedName(namespace, complexType.getName()); FullQualifiedName comlexTypeName = new FullQualifiedName(namespace, complexType.getName());
EdmComplexTypeImpl complexTypeImpl = new EdmComplexTypeImpl(edm, comlexTypeName, complexType); EdmComplexTypeImpl complexTypeImpl = new EdmComplexTypeImpl(edm, comlexTypeName, complexType);
complexTypes.add(complexTypeImpl); edmComplexTypes.add(complexTypeImpl);
edm.cacheComplexType(comlexTypeName, complexTypeImpl); edm.cacheComplexType(comlexTypeName, complexTypeImpl);
} }
} }
return complexTypes; return edmComplexTypes;
} }
protected List<EdmAction> createActions() { protected List<EdmAction> createActions() {
final List<EdmAction> actions = new ArrayList<EdmAction>(); final List<EdmAction> edmActions = new ArrayList<EdmAction>();
final List<CsdlAction> providerActions = schema.getActions(); final List<CsdlAction> providerActions = schema.getActions();
if (providerActions != null) { if (providerActions != null) {
for (CsdlAction action : providerActions) { for (CsdlAction action : providerActions) {
FullQualifiedName actionName = new FullQualifiedName(namespace, action.getName()); FullQualifiedName actionName = new FullQualifiedName(namespace, action.getName());
EdmActionImpl edmActionImpl = new EdmActionImpl(edm, actionName, action); EdmActionImpl edmActionImpl = new EdmActionImpl(edm, actionName, action);
actions.add(edmActionImpl); edmActions.add(edmActionImpl);
edm.cacheAction(actionName, edmActionImpl); edm.cacheAction(actionName, edmActionImpl);
} }
} }
return actions; return edmActions;
} }
protected List<EdmFunction> createFunctions() { protected List<EdmFunction> createFunctions() {
final List<EdmFunction> functions = new ArrayList<EdmFunction>(); final List<EdmFunction> edmFunctions = new ArrayList<EdmFunction>();
final List<CsdlFunction> providerFunctions = schema.getFunctions(); final List<CsdlFunction> providerFunctions = schema.getFunctions();
if (providerFunctions != null) { if (providerFunctions != null) {
for (CsdlFunction function : providerFunctions) { for (CsdlFunction function : providerFunctions) {
FullQualifiedName functionName = new FullQualifiedName(namespace, function.getName()); FullQualifiedName functionName = new FullQualifiedName(namespace, function.getName());
EdmFunctionImpl functionImpl = new EdmFunctionImpl(edm, functionName, function); EdmFunctionImpl functionImpl = new EdmFunctionImpl(edm, functionName, function);
functions.add(functionImpl); edmFunctions.add(functionImpl);
edm.cacheFunction(functionName, functionImpl); edm.cacheFunction(functionName, functionImpl);
} }
} }
return functions; return edmFunctions;
} }
protected List<EdmTerm> createTerms() { protected List<EdmTerm> createTerms() {
final List<EdmTerm> terms = new ArrayList<EdmTerm>(); final List<EdmTerm> edmTerms = new ArrayList<EdmTerm>();
final List<CsdlTerm> providerTerms = schema.getTerms(); final List<CsdlTerm> providerTerms = schema.getTerms();
if (providerTerms != null) { if (providerTerms != null) {
for (CsdlTerm term : providerTerms) { for (CsdlTerm term : providerTerms) {
FullQualifiedName termName = new FullQualifiedName(namespace, term.getName()); FullQualifiedName termName = new FullQualifiedName(namespace, term.getName());
EdmTermImpl termImpl = new EdmTermImpl(edm, getNamespace(), term); EdmTermImpl termImpl = new EdmTermImpl(edm, getNamespace(), term);
terms.add(termImpl); edmTerms.add(termImpl);
edm.cacheTerm(termName, termImpl); edm.cacheTerm(termName, termImpl);
} }
} }
return terms; return edmTerms;
} }
protected List<EdmAnnotations> createAnnotationGroups() { protected List<EdmAnnotations> createAnnotationGroups() {
final List<EdmAnnotations> annotationGroups = new ArrayList<EdmAnnotations>(); final List<EdmAnnotations> edmAnnotationGroups = new ArrayList<EdmAnnotations>();
final List<CsdlAnnotations> providerAnnotations = final List<CsdlAnnotations> providerAnnotations =
schema.getAnnotationGroups(); schema.getAnnotationGroups();
if (providerAnnotations != null) { if (providerAnnotations != null) {
@ -271,23 +271,23 @@ public class EdmSchemaImpl extends AbstractEdmAnnotatable implements EdmSchema {
targetName = new FullQualifiedName(namespace, annotationGroup.getTarget()); targetName = new FullQualifiedName(namespace, annotationGroup.getTarget());
} }
EdmAnnotationsImpl annotationsImpl = new EdmAnnotationsImpl(edm, annotationGroup); EdmAnnotationsImpl annotationsImpl = new EdmAnnotationsImpl(edm, annotationGroup);
annotationGroups.add(annotationsImpl); edmAnnotationGroups.add(annotationsImpl);
edm.cacheAnnotationGroup(targetName, annotationsImpl); edm.cacheAnnotationGroup(targetName, annotationsImpl);
} }
} }
return annotationGroups; return edmAnnotationGroups;
} }
protected List<EdmAnnotation> createAnnotations() { protected List<EdmAnnotation> createAnnotations() {
final List<EdmAnnotation> annotations = new ArrayList<EdmAnnotation>(); final List<EdmAnnotation> edmAnnotations = new ArrayList<EdmAnnotation>();
final List<CsdlAnnotation> providerAnnotations = final List<CsdlAnnotation> providerAnnotations =
schema.getAnnotations(); schema.getAnnotations();
if (providerAnnotations != null) { if (providerAnnotations != null) {
for (CsdlAnnotation annotation : providerAnnotations) { for (CsdlAnnotation annotation : providerAnnotations) {
EdmAnnotationImpl annotationImpl = new EdmAnnotationImpl(edm, annotation); EdmAnnotationImpl annotationImpl = new EdmAnnotationImpl(edm, annotation);
annotations.add(annotationImpl); edmAnnotations.add(annotationImpl);
} }
} }
return annotations; return edmAnnotations;
} }
} }

View File

@ -75,7 +75,7 @@ public final class EdmDecimal extends SingletonPrimitiveType {
final Matcher matcher = PATTERN.matcher(value); final Matcher matcher = PATTERN.matcher(value);
matcher.matches(); 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(); final int decimals = matcher.group(2) == null ? 0 : matcher.group(2).length();
return (precision == null || precision >= significantIntegerDigits + decimals) return (precision == null || precision >= significantIntegerDigits + decimals)
&& (decimals <= (scale == null ? 0 : scale)); && (decimals <= (scale == null ? 0 : scale));

View File

@ -277,19 +277,19 @@ public class MetadataParser {
private void loadCoreVocabulary(SchemaBasedEdmProvider provider, private void loadCoreVocabulary(SchemaBasedEdmProvider provider,
String namespace) throws XMLStreamException { 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"); 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"); 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"); loadLocalVocabularySchema(provider, "Org.OData.Measures.V1", "Org.OData.Measures.V1.xml");
} }
} }
private boolean isCoreVocabulary(String namespace) { private boolean isCoreVocabulary(String namespace) {
if(namespace.equalsIgnoreCase("Org.OData.Core.V1") || if("Org.OData.Core.V1".equalsIgnoreCase(namespace) ||
namespace.equalsIgnoreCase("Org.OData.Capabilities.V1") || "Org.OData.Capabilities.V1".equalsIgnoreCase(namespace) ||
namespace.equalsIgnoreCase("Org.OData.Measures.V1")) { "Org.OData.Measures.V1".equalsIgnoreCase(namespace)) {
return true; return true;
} }
return false; return false;
@ -323,9 +323,9 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, SchemaBasedEdmProvider provider, void build(XMLEventReader reader, StartElement element, SchemaBasedEdmProvider provider,
String name) throws XMLStreamException { String name) throws XMLStreamException {
if (name.equals("DataServices")) { if ("DataServices".equals(name)) {
readSchema(reader, element, provider); readSchema(reader, element, provider);
} else if (name.equals("Reference")) { } else if ("Reference".equals(name)) {
readReference(reader, element, provider, "Reference"); readReference(reader, element, provider, "Reference");
} }
} }
@ -345,17 +345,17 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, void build(XMLEventReader reader, StartElement element,
EdmxReference reference, String name) throws XMLStreamException { EdmxReference reference, String name) throws XMLStreamException {
if (name.equals("Include")) { if ("Include".equals(name)) {
EdmxReferenceInclude include = new EdmxReferenceInclude(attr(element, "Namespace"), EdmxReferenceInclude include = new EdmxReferenceInclude(attr(element, "Namespace"),
attr(element, "Alias")); attr(element, "Alias"));
reference.addInclude(include); reference.addInclude(include);
} else if (name.equals("IncludeAnnotations")) { } else if ("IncludeAnnotations".equals(name)) {
EdmxReferenceIncludeAnnotation annotation = new EdmxReferenceIncludeAnnotation( EdmxReferenceIncludeAnnotation annotation = new EdmxReferenceIncludeAnnotation(
attr(element, "TermNamespace")); attr(element, "TermNamespace"));
annotation.setTargetNamespace(attr(element, "TargetNamespace")); annotation.setTargetNamespace(attr(element, "TargetNamespace"));
annotation.setQualifier(attr(element, "Qualifier")); annotation.setQualifier(attr(element, "Qualifier"));
reference.addIncludeAnnotation(annotation); reference.addIncludeAnnotation(annotation);
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, reference); readAnnotations(reader, element, reference);
} }
} }
@ -391,25 +391,25 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, CsdlSchema schema, String name) void build(XMLEventReader reader, StartElement element, CsdlSchema schema, String name)
throws XMLStreamException { throws XMLStreamException {
if (name.equals("Action")) { if ("Action".equals(name)) {
readAction(reader, element, schema); readAction(reader, element, schema);
} else if (name.equals("Annotations")) { } else if ("Annotations".equals(name)) {
readAnnotationGroup(reader, element, schema); readAnnotationGroup(reader, element, schema);
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, schema); readAnnotations(reader, element, schema);
} else if (name.equals("ComplexType")) { } else if ("ComplexType".equals(name)) {
readComplexType(reader, element, schema); readComplexType(reader, element, schema);
} else if (name.equals("EntityContainer")) { } else if ("EntityContainer".equals(name)) {
readEntityContainer(reader, element, schema); readEntityContainer(reader, element, schema);
} else if (name.equals("EntityType")) { } else if ("EntityType".equals(name)) {
readEntityType(reader, element, schema); readEntityType(reader, element, schema);
} else if (name.equals("EnumType")) { } else if ("EnumType".equals(name)) {
readEnumType(reader, element, schema); readEnumType(reader, element, schema);
} else if (name.equals("Function")) { } else if ("Function".equals(name)) {
readFunction(reader, element, schema); readFunction(reader, element, schema);
} else if (name.equals("Term")) { } else if ("Term".equals(name)) {
schema.getTerms().add(readTerm(reader, element)); schema.getTerms().add(readTerm(reader, element));
} else if (name.equals("TypeDefinition")) { } else if ("TypeDefinition".equals(name)) {
schema.getTypeDefinitions().add(readTypeDefinition(reader, element)); schema.getTypeDefinitions().add(readTypeDefinition(reader, element));
} }
} }
@ -593,7 +593,7 @@ public class MetadataParser {
if (event.isStartElement()) { if (event.isStartElement()) {
StartElement element = event.asStartElement(); StartElement element = event.asStartElement();
if (element.getName().getLocalPart().equals("Annotation")) { if ("Annotation".equals(element.getName().getLocalPart())) {
reader.nextEvent(); reader.nextEvent();
readAnnotations(reader, element, edmObject); readAnnotations(reader, element, edmObject);
} }
@ -601,7 +601,7 @@ public class MetadataParser {
if (event.isEndElement()) { if (event.isEndElement()) {
EndElement element = event.asEndElement(); EndElement element = event.asEndElement();
if (element.getName().getLocalPart().equals("Annotation")) { if ("Annotation".equals(element.getName().getLocalPart())) {
reader.nextEvent(); reader.nextEvent();
} }
@ -668,7 +668,7 @@ public class MetadataParser {
throws XMLStreamException { throws XMLStreamException {
// element based expressions // element based expressions
if (!name.equals("Annotation")) { if (!"Annotation".equals(name)) {
// attribute based expressions. // attribute based expressions.
readAttributeExpressions(element, target); readAttributeExpressions(element, target);
@ -680,59 +680,59 @@ public class MetadataParser {
} }
} }
if (name.equals("Collection")) { if ("Collection".equals(name)) {
CsdlCollection expr = new CsdlCollection(); CsdlCollection expr = new CsdlCollection();
readExpressions(reader, element, expr); readExpressions(reader, element, expr);
write(target, expr); write(target, expr);
} else if (name.equals("AnnotationPath")) { } else if ("AnnotationPath".equals(name)) {
write(target, new CsdlAnnotationPath().setValue(elementValue(reader, element))); write(target, new CsdlAnnotationPath().setValue(elementValue(reader, element)));
} else if (name.equals("NavigationPropertyPath")) { } else if ("NavigationPropertyPath".equals(name)) {
write(target, new CsdlNavigationPropertyPath() write(target, new CsdlNavigationPropertyPath()
.setValue(elementValue(reader, element))); .setValue(elementValue(reader, element)));
} else if (name.equals("Path")) { } else if ("Path".equals(name)) {
write(target, new CsdlPath().setValue(elementValue(reader, element))); 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))); write(target, new CsdlPropertyPath().setValue(elementValue(reader, element)));
} else if (name.equals("UrlRef")) { } else if ("UrlRef".equals(name)) {
CsdlUrlRef expr = new CsdlUrlRef(); CsdlUrlRef expr = new CsdlUrlRef();
readExpressions(reader, element, expr); readExpressions(reader, element, expr);
write(target, expr); write(target, expr);
} else if (name.equals("Apply")) { } else if ("Apply".equals(name)) {
CsdlApply expr = new CsdlApply(); CsdlApply expr = new CsdlApply();
expr.setFunction(attr(element, "Function")); expr.setFunction(attr(element, "Function"));
readExpressions(reader, element, expr); readExpressions(reader, element, expr);
write(target, expr); write(target, expr);
} else if (name.equals("Cast")) { } else if ("Cast".equals(name)) {
CsdlCast expr = new CsdlCast(); CsdlCast expr = new CsdlCast();
expr.setType(attr(element, "Type")); expr.setType(attr(element, "Type"));
readExpressions(reader, element, expr); readExpressions(reader, element, expr);
write(target, expr); write(target, expr);
} else if (name.equals("If")) { } else if ("If".equals(name)) {
CsdlIf expr = new CsdlIf(); CsdlIf expr = new CsdlIf();
readExpressions(reader, element, expr); readExpressions(reader, element, expr);
write(target, expr); write(target, expr);
} else if (name.equals("IsOf")) { } else if ("IsOf".equals(name)) {
CsdlIsOf expr = new CsdlIsOf(); CsdlIsOf expr = new CsdlIsOf();
expr.setType(attr(element, "Type")); expr.setType(attr(element, "Type"));
readExpressions(reader, element, expr); readExpressions(reader, element, expr);
write(target, expr); write(target, expr);
} else if (name.equals("LabeledElement")) { } else if ("LabeledElement".equals(name)) {
CsdlLabeledElement expr = new CsdlLabeledElement(); CsdlLabeledElement expr = new CsdlLabeledElement();
expr.setName(attr(element, "Name")); expr.setName(attr(element, "Name"));
readExpressions(reader, element, expr); readExpressions(reader, element, expr);
write(target, expr); write(target, expr);
} else if (name.equals("LabeledElementReference")) { } else if ("LabeledElementReference".equals(name)) {
CsdlLabeledElementReference expr = new CsdlLabeledElementReference(); CsdlLabeledElementReference expr = new CsdlLabeledElementReference();
expr.setValue(elementValue(reader, element)); expr.setValue(elementValue(reader, element));
write(target, expr); write(target, expr);
} else if (name.equals("Null")) { } else if ("Null".equals(name)) {
write(target, new CsdlNull()); write(target, new CsdlNull());
} else if (name.equals("Record")) { } else if ("Record".equals(name)) {
CsdlRecord expr = new CsdlRecord(); CsdlRecord expr = new CsdlRecord();
expr.setType(attr(element, "Type")); expr.setType(attr(element, "Type"));
readPropertyValues(reader, element, expr); readPropertyValues(reader, element, expr);
write(target, expr); write(target, expr);
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, (CsdlAnnotatable)target); readAnnotations(reader, element, (CsdlAnnotatable)target);
} }
} }
@ -796,13 +796,13 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, CsdlRecord record, String name) void build(XMLEventReader reader, StartElement element, CsdlRecord record, String name)
throws XMLStreamException { throws XMLStreamException {
if (name.equals("PropertyValue")) { if ("PropertyValue".equals(name)) {
CsdlPropertyValue value = new CsdlPropertyValue(); CsdlPropertyValue value = new CsdlPropertyValue();
value.setProperty(attr(element, "Property")); value.setProperty(attr(element, "Property"));
readAttributeExpressions(element, value); readAttributeExpressions(element, value);
readExpressions(reader, element, value); readExpressions(reader, element, value);
record.getPropertyValues().add(value); record.getPropertyValues().add(value);
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, record); readAnnotations(reader, element, record);
} }
} }
@ -831,11 +831,11 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, CsdlOperation operation, String name) void build(XMLEventReader reader, StartElement element, CsdlOperation operation, String name)
throws XMLStreamException { throws XMLStreamException {
if (name.equals("Parameter")) { if ("Parameter".equals(name)) {
readParameter(reader, element, operation); readParameter(reader, element, operation);
} else if (name.equals("ReturnType")) { } else if ("ReturnType".equals(name)) {
readReturnType(reader, element, operation); readReturnType(reader, element, operation);
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, operation); readAnnotations(reader, element, operation);
} }
} }
@ -863,13 +863,13 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, CsdlEnumType type, String name) void build(XMLEventReader reader, StartElement element, CsdlEnumType type, String name)
throws XMLStreamException { throws XMLStreamException {
if (name.equals("Member")) { if ("Member".equals(name)) {
CsdlEnumMember member = new CsdlEnumMember(); CsdlEnumMember member = new CsdlEnumMember();
member.setName(attr(element, "Name")); member.setName(attr(element, "Name"));
member.setValue(attr(element, "Value")); member.setValue(attr(element, "Value"));
peekAnnotations(reader, name, member); peekAnnotations(reader, name, member);
type.getMembers().add(member); type.getMembers().add(member);
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, type); readAnnotations(reader, element, type);
} }
} }
@ -899,13 +899,13 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, CsdlEntityType entityType, String name) void build(XMLEventReader reader, StartElement element, CsdlEntityType entityType, String name)
throws XMLStreamException { throws XMLStreamException {
if (name.equals("Property")) { if ("Property".equals(name)) {
entityType.getProperties().add(readProperty(reader, element)); entityType.getProperties().add(readProperty(reader, element));
} else if (name.equals("NavigationProperty")) { } else if ("NavigationProperty".equals(name)) {
entityType.getNavigationProperties().add(readNavigationProperty(reader, element)); entityType.getNavigationProperties().add(readNavigationProperty(reader, element));
} else if (name.equals("Key")) { } else if ("Key".equals(name)) {
readKey(reader, element, entityType); readKey(reader, element, entityType);
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, entityType); readAnnotations(reader, element, entityType);
} }
} }
@ -942,18 +942,18 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, CsdlNavigationProperty property, void build(XMLEventReader reader, StartElement element, CsdlNavigationProperty property,
String name) throws XMLStreamException { String name) throws XMLStreamException {
if (name.equals("ReferentialConstraint")) { if ("ReferentialConstraint".equals(name)) {
CsdlReferentialConstraint constraint = new CsdlReferentialConstraint(); CsdlReferentialConstraint constraint = new CsdlReferentialConstraint();
constraint.setProperty(attr(element, "Property")); constraint.setProperty(attr(element, "Property"));
constraint.setReferencedProperty(attr(element, "ReferencedProperty")); constraint.setReferencedProperty(attr(element, "ReferencedProperty"));
peekAnnotations(reader, name, constraint); peekAnnotations(reader, name, constraint);
property.getReferentialConstraints().add(constraint); property.getReferentialConstraints().add(constraint);
} else if (name.equals("OnDelete")) { } else if ("OnDelete".equals(name)) {
CsdlOnDelete delete = new CsdlOnDelete(); CsdlOnDelete delete = new CsdlOnDelete();
delete.setAction(CsdlOnDeleteAction.valueOf(attr(element, "Action"))); delete.setAction(CsdlOnDeleteAction.valueOf(attr(element, "Action")));
property.setOnDelete(delete); property.setOnDelete(delete);
peekAnnotations(reader, name, delete); peekAnnotations(reader, name, delete);
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, property); readAnnotations(reader, element, property);
} }
} }
@ -1029,15 +1029,15 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, CsdlSchema schema, String name) void build(XMLEventReader reader, StartElement element, CsdlSchema schema, String name)
throws XMLStreamException { throws XMLStreamException {
if (name.equals("EntitySet")) { if ("EntitySet".equals(name)) {
readEntitySet(reader, element, container); readEntitySet(reader, element, container);
} else if (name.equals("Singleton")) { } else if ("Singleton".equals(name)) {
readSingleton(reader, element, container); readSingleton(reader, element, container);
} else if (name.equals("ActionImport")) { } else if ("ActionImport".equals(name)) {
readActionImport(reader, element, container); readActionImport(reader, element, container);
} else if (name.equals("FunctionImport")) { } else if ("FunctionImport".equals(name)) {
readFunctionImport(reader, element, container); readFunctionImport(reader, element, container);
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, container); readAnnotations(reader, element, container);
} }
} }
@ -1103,12 +1103,12 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, void build(XMLEventReader reader, StartElement element,
CsdlBindingTarget entitySet, String name) throws XMLStreamException { CsdlBindingTarget entitySet, String name) throws XMLStreamException {
if (name.equals("NavigationPropertyBinding")) { if ("NavigationPropertyBinding".equals(name)) {
CsdlNavigationPropertyBinding binding = new CsdlNavigationPropertyBinding(); CsdlNavigationPropertyBinding binding = new CsdlNavigationPropertyBinding();
binding.setPath(attr(element, "Path")); binding.setPath(attr(element, "Path"));
binding.setTarget(attr(element, "Target")); binding.setTarget(attr(element, "Target"));
entitySet.getNavigationPropertyBindings().add(binding); entitySet.getNavigationPropertyBindings().add(binding);
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, entitySet); readAnnotations(reader, element, entitySet);
} }
} }
@ -1141,11 +1141,11 @@ public class MetadataParser {
@Override @Override
void build(XMLEventReader reader, StartElement element, CsdlComplexType complexType, String name) void build(XMLEventReader reader, StartElement element, CsdlComplexType complexType, String name)
throws XMLStreamException { throws XMLStreamException {
if (name.equals("Property")) { if ("Property".equals(name)) {
complexType.getProperties().add(readProperty(reader, element)); complexType.getProperties().add(readProperty(reader, element));
} else if (name.equals("NavigationProperty")) { } else if ("NavigationProperty".equals(name)) {
complexType.getNavigationProperties().add(readNavigationProperty(reader, element)); complexType.getNavigationProperties().add(readNavigationProperty(reader, element));
} else if (name.equals("Annotation")) { } else if ("Annotation".equals(name)) {
readAnnotations(reader, element, complexType); readAnnotations(reader, element, complexType);
} }
} }
@ -1212,13 +1212,13 @@ public class MetadataParser {
while (reader.hasNext()) { while (reader.hasNext()) {
if (event.isStartElement()) { if (event.isStartElement()) {
StartElement element = event.asStartElement(); StartElement element = event.asStartElement();
if (element.getName().getLocalPart().equals("Annotation")) { if ("Annotation".equals(element.getName().getLocalPart())) {
skip = true; skip = true;
} }
} }
if (event.isEndElement()) { if (event.isEndElement()) {
EndElement element = event.asEndElement(); EndElement element = event.asEndElement();
if (element.getName().getLocalPart().equals("Annotation")) { if ("Annotation".equals(element.getName().getLocalPart())) {
return reader.peek(); return reader.peek();
} }
} }

View File

@ -106,9 +106,9 @@ public class ServiceDispatcher extends RequestURLHierarchyVisitor {
protected void handleException(ODataException e, ContentType contentType, protected void handleException(ODataException e, ContentType contentType,
ODataRequest odRequest, ODataResponse odResponse) { ODataRequest odRequest, ODataResponse odResponse) {
ErrorHandler handler = new ErrorHandler(this.odata, this.metadata, ErrorHandler errorHandler = new ErrorHandler(this.odata, this.metadata,
this.handler, contentType); this.handler, contentType);
handler.handleException(e, odRequest, odResponse); errorHandler.handleException(e, odRequest, odResponse);
} }
private void internalExecute(UriInfo uriInfo, ODataRequest odRequest, private void internalExecute(UriInfo uriInfo, ODataRequest odRequest,
@ -119,7 +119,7 @@ public class ServiceDispatcher extends RequestURLHierarchyVisitor {
// part1, 8.2.6 // part1, 8.2.6
String isolation = odRequest.getHeader(HttpHeader.ODATA_ISOLATION); 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()); odResponse.setStatusCode(HttpStatusCode.PRECONDITION_FAILED.getStatusCode());
return; return;
} }
@ -255,17 +255,6 @@ public class ServiceDispatcher extends RequestURLHierarchyVisitor {
public void visit(UriInfoEntityId info) { public void visit(UriInfoEntityId info) {
DataRequest dataRequest = new DataRequest(this.odata, this.metadata); DataRequest dataRequest = new DataRequest(this.odata, this.metadata);
this.request = dataRequest; 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); super.visit(info);
} }

View File

@ -340,11 +340,11 @@ public abstract class ServiceRequest {
rawPath = rawPath.substring(e+path.length()); 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()); getODataRequest().getRawBaseUri());
ServiceDispatcher dispatcher = new ServiceDispatcher(odata, serviceMetadata, null, customContentType); ServiceDispatcher dispatcher = new ServiceDispatcher(odata, serviceMetadata, null, customContentType);
dispatcher.visit(uriInfo); dispatcher.visit(reqUriInfo);
dispatcher.request.setUriInfo(uriInfo); dispatcher.request.setUriInfo(reqUriInfo);
return (DataRequest)dispatcher.request; return (DataRequest)dispatcher.request;
} }
} }

View File

@ -216,16 +216,6 @@ public class DataRequest extends ServiceRequest {
return valueRequest; 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) { public void setValueRequest(boolean valueRequest) {
this.valueRequest = valueRequest; this.valueRequest = valueRequest;
this.type = new ValueRequest(); this.type = new ValueRequest();
@ -340,7 +330,7 @@ public class DataRequest extends ServiceRequest {
// by this specification. // by this specification.
boolean ifMatch = getHeader(HttpHeader.IF_MATCH) != null; boolean ifMatch = getHeader(HttpHeader.IF_MATCH) != null;
boolean ifNoneMatch = (getHeader(HttpHeader.IF_NONE_MATCH)!= null boolean ifNoneMatch = (getHeader(HttpHeader.IF_NONE_MATCH)!= null
&& getHeader(HttpHeader.IF_NONE_MATCH).equals("*")); && "*".equals(getHeader(HttpHeader.IF_NONE_MATCH)));
if(ifMatch) { if(ifMatch) {
handler.updateEntity(DataRequest.this, getEntityFromClient(), isPATCH(), getETag(), handler.updateEntity(DataRequest.this, getEntityFromClient(), isPATCH(), getETag(),
entityResponse); entityResponse);
@ -620,8 +610,8 @@ public class DataRequest extends ServiceRequest {
builder.navOrPropertyPath(edmProperty.getName()); builder.navOrPropertyPath(edmProperty.getName());
} }
if (isPropertyComplex()) { if (isPropertyComplex()) {
EdmComplexType type = ((UriResourceComplexProperty) uriResourceProperty).getComplexType(); EdmComplexType complexType = ((UriResourceComplexProperty) uriResourceProperty).getComplexType();
String select = helper.buildContextURLSelectList(type, getUriInfo().getExpandOption(), String select = helper.buildContextURLSelectList(complexType, getUriInfo().getExpandOption(),
getUriInfo().getSelectOption()); getUriInfo().getSelectOption());
builder.selectList(select); builder.selectList(select);
} }

View File

@ -74,8 +74,6 @@ public abstract class OperationRequest extends ServiceRequest {
return null; return null;
} }
//final UriHelper helper = odata.createUriHelper();
if (isReturnTypePrimitive() || isReturnTypeComplex()) { if (isReturnTypePrimitive() || isReturnTypeComplex()) {
// Part 1 {10.14, 10.14} since the function return properties does not // Part 1 {10.14, 10.14} since the function return properties does not
// represent a Entity property // represent a Entity property
@ -86,18 +84,6 @@ public abstract class OperationRequest extends ServiceRequest {
return builder.build(); 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 // EdmTypeKind.ENTITY; Not Bound
// Here we do not know the EntitySet, then follow directions from // Here we do not know the EntitySet, then follow directions from
// Part-1{10.2. 10.3} to use // Part-1{10.2. 10.3} to use

View File

@ -46,7 +46,7 @@ public class BatchQueryOperation implements BatchPart {
} }
protected Line consumeHttpStatusLine(final List<Line> message) throws BatchDeserializerException { protected Line consumeHttpStatusLine(final List<Line> 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); final Line method = message.get(0);
message.remove(0); message.remove(0);

View File

@ -65,7 +65,7 @@ public class ETagHelperImpl implements ETagHelper {
*/ */
protected ETagInformation createETagInformation(final Collection<String> values) { protected ETagInformation createETagInformation(final Collection<String> values) {
final Collection<String> eTags = ETagParser.parse(values); final Collection<String> 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, return new ETagInformation(isAll,
isAll ? Collections.<String> emptySet() : Collections.unmodifiableCollection(eTags)); isAll ? Collections.<String> emptySet() : Collections.unmodifiableCollection(eTags));
} }

View File

@ -56,7 +56,7 @@ public class ETagParser {
Set<String> result = new HashSet<String>(); Set<String> result = new HashSet<String>();
for (final String value : values) { for (final String value : values) {
final Collection<String> part = parse(value); final Collection<String> part = parse(value);
if (part.size() == 1 && part.iterator().next().equals("*")) { if (part.size() == 1 && "*".equals(part.iterator().next())) {
return part; return part;
} else { } else {
result.addAll(part); result.addAll(part);
@ -66,7 +66,7 @@ public class ETagParser {
} }
private static Collection<String> parse(final String value) { private static Collection<String> parse(final String value) {
if (value.trim().equals("*")) { if ("*".equals(value.trim())) {
return Collections.singleton("*"); return Collections.singleton("*");
} else { } else {
Set<String> result = new HashSet<String>(); Set<String> result = new HashSet<String>();

View File

@ -142,21 +142,21 @@ public class Parser {
ensureLastSegment(firstSegment, 1, numberOfSegments); ensureLastSegment(firstSegment, 1, numberOfSegments);
contextUriInfo.setKind(UriInfoKind.service); contextUriInfo.setKind(UriInfoKind.service);
} else if (firstSegment.equals("$batch")) { } else if ("$batch".equals(firstSegment)) {
ensureLastSegment(firstSegment, 1, numberOfSegments); ensureLastSegment(firstSegment, 1, numberOfSegments);
contextUriInfo.setKind(UriInfoKind.batch); contextUriInfo.setKind(UriInfoKind.batch);
} else if (firstSegment.equals("$metadata")) { } else if ("$metadata".equals(firstSegment)) {
ensureLastSegment(firstSegment, 1, numberOfSegments); ensureLastSegment(firstSegment, 1, numberOfSegments);
contextUriInfo.setKind(UriInfoKind.metadata); contextUriInfo.setKind(UriInfoKind.metadata);
contextUriInfo.setFragment(fragment); contextUriInfo.setFragment(fragment);
} else if (firstSegment.equals("$all")) { } else if ("$all".equals(firstSegment)) {
ensureLastSegment(firstSegment, 1, numberOfSegments); ensureLastSegment(firstSegment, 1, numberOfSegments);
contextUriInfo.setKind(UriInfoKind.all); contextUriInfo.setKind(UriInfoKind.all);
contextIsCollection = true; contextIsCollection = true;
} else if (firstSegment.equals("$entity")) { } else if ("$entity".equals(firstSegment)) {
if (null != contextUriInfo.getIdOption()) { if (null != contextUriInfo.getIdOption()) {
String idOptionText = contextUriInfo.getIdOption().getText(); String idOptionText = contextUriInfo.getIdOption().getText();
if (idOptionText.startsWith(HTTP)) { if (idOptionText.startsWith(HTTP)) {
@ -317,7 +317,7 @@ public class Parser {
systemOption = new FilterOptionImpl(); systemOption = new FilterOptionImpl();
break; break;
case COUNT: case COUNT:
if (optionValue.equals("true") || optionValue.equals("false")) { if ("true".equals(optionValue) || "false".equals(optionValue)) {
systemOption = new CountOptionImpl().setValue(Boolean.parseBoolean(optionValue)); systemOption = new CountOptionImpl().setValue(Boolean.parseBoolean(optionValue));
} else { } else {
throw new UriParserSyntaxException("Illegal value of $count option!", throw new UriParserSyntaxException("Illegal value of $count option!",