From 3b37d29948bfe03cdb1a7d14a6cb3c80f743129b Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Wed, 18 Mar 2015 14:35:45 +0100 Subject: [PATCH] [OLINGO-575] Cleanup of TODOs --- .../olingo/ext/proxy/AbstractService.java | 1 - .../commons/AbstractInvocationHandler.java | 9 ---- .../olingo/ext/proxy/utils/CoreUtils.java | 20 +------- .../client/core/edm/xml/AnnotationImpl.java | 46 ------------------- .../olingo/client/core/v4/MetadataTest.java | 1 - .../olingo/commons/api/edm/EdmOperation.java | 5 ++ .../commons/api/edm/provider/Annotation.java | 37 +++++++-------- .../commons/api/edm/provider/EnumType.java | 1 - .../commons/api/edm/provider/Property.java | 1 - .../commons/core/data/PropertyImpl.java | 2 +- .../core/edm/provider/EdmOperationImpl.java | 5 ++ .../core/edm/provider/EdmProviderImpl.java | 2 +- .../api/serializer/FixedFormatSerializer.java | 1 - .../deserializer/batch/BatchParserCommon.java | 1 - .../serializer/FixedFormatSerializerImpl.java | 2 +- .../serializer/json/ODataJsonSerializer.java | 5 -- .../xml/MetadataDocumentXmlSerializer.java | 24 ++++++---- .../xml/ODataXmlSerializerImpl.java | 1 - 18 files changed, 46 insertions(+), 118 deletions(-) diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/AbstractService.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/AbstractService.java index fd34aa987..f353856f4 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/AbstractService.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/AbstractService.java @@ -91,7 +91,6 @@ public abstract class AbstractService { }else{ edm = null; } - // TODO: check runtime exception or not if (version.compareTo(ODataServiceVersion.V40) < 0) { throw new ODataRuntimeException("Only OData V4 or higher supported."); } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java index 69ccdc0a0..abc0ee80e 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java @@ -210,16 +210,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler { final String containerNS, final String entitySetName, final AbstractService service) { final URIBuilder uriBuilder = service.getClient().newURIBuilder(); -// final Edm edm = service.getClient().getCachedEdm(); - final StringBuilder entitySetSegment = new StringBuilder(); - //TODO: Container is always default in v4 -// if (StringUtils.isNotBlank(containerNS)) { -// final EdmEntityContainer container = edm.getEntityContainer(new FullQualifiedName(containerNS)); -// if (!container.isDefault()) { -// entitySetSegment.append(container.getFullQualifiedName().toString()).append('.'); -// } -// } entitySetSegment.append(entitySetName); uriBuilder.appendEntitySetSegment(entitySetSegment.toString()); diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java index 6cd82d70e..65af8d60c 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java @@ -651,25 +651,9 @@ public final class CoreUtils { return mediaEditLink == null ? URIUtils.getURI(entity.getEditLink(), name) : mediaEditLink.getLink(); } - public static URI getTargetEntitySetURI( - final EdmEnabledODataClient client, final NavigationProperty property) { -// final Edm edm = client.getCachedEdm(); -// -// final FullQualifiedName containerName = -// new FullQualifiedName(property.targetSchema(), property.targetContainer()); - -// final EdmEntityContainer container = edm.getEntityContainer(containerName); + public static URI getTargetEntitySetURI(final EdmEnabledODataClient client, final NavigationProperty property) { final URIBuilder uriBuilder = client.newURIBuilder(client.getServiceRoot()); -//TODO: Container can only be default in V4 -// if (!container.isDefault()) { -// final StringBuilder entitySetSegment = new StringBuilder(); -// entitySetSegment.append(container.getFullQualifiedName()).append('.'); -// entitySetSegment.append(property.targetEntitySet()); -// uriBuilder.appendEntitySetSegment(entitySetSegment.toString()); -// } else { - uriBuilder.appendEntitySetSegment(property.targetEntitySet()); -// } - + uriBuilder.appendEntitySetSegment(property.targetEntitySet()); return uriBuilder.build(); } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java index c482877fd..156cc82c7 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java @@ -18,11 +18,7 @@ */ package org.apache.olingo.client.core.edm.xml; -import java.util.ArrayList; -import java.util.List; - import org.apache.olingo.commons.api.edm.provider.Annotation; -import org.apache.olingo.commons.api.edm.provider.annotation.AnnotationExpression; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -31,46 +27,4 @@ public class AnnotationImpl extends Annotation { private static final long serialVersionUID = 5464714417411058033L; - private String term; - - private String qualifier; - - private AnnotationExpression annotationExpression; - - private final List annotations = new ArrayList(); - - @Override - public List getAnnotations() { - return annotations; - } - - @Override - public String getTerm() { - return term; - } - - public AnnotationImpl setTerm(final String term) { - this.term = term; - return this; - } - - @Override - public String getQualifier() { - return qualifier; - } - - public AnnotationImpl setQualifier(final String qualifier) { - this.qualifier = qualifier; - return this; - } - - @Override - public AnnotationExpression getExpression() { - return annotationExpression; - } - - public void setAnnotationExpression(final AnnotationExpression annotationExpression) { - this.annotationExpression = annotationExpression; - } - } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java index c9deca245..e360516bb 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java @@ -223,7 +223,6 @@ public class MetadataTest extends AbstractTest { final Function productsByRating = metadata.getSchema(0).getFunctions("ProductsByRating").get(0); assertNotNull(productsByRating.getParameter("Rating")); assertEquals("Edm.Int32", productsByRating.getParameter("Rating").getType()); -// assertEquals("Collection(ODataDemo.Product)", productsByRating.getReturnType().getType()); assertEquals("ODataDemo.Product", productsByRating.getReturnType().getType()); assertTrue(productsByRating.getReturnType().isCollection()); diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java index d1bc3de04..d6101b3a6 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java @@ -63,5 +63,10 @@ public interface EdmOperation extends EdmType, EdmAnnotatable { * @return true if binding parameter is of type collection. */ Boolean isBindingParameterTypeCollection(); + + /** + * @return the entity set path as a String or null if not present + */ + String getEntitySetPath(); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Annotation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Annotation.java index ed1d8a426..173cf3e8f 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Annotation.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Annotation.java @@ -18,23 +18,30 @@ */ package org.apache.olingo.commons.api.edm.provider; +import java.util.ArrayList; import java.util.List; import org.apache.olingo.commons.api.edm.provider.annotation.AnnotationExpression; -public class Annotation extends AbstractEdmItem implements Annotatable{ +public class Annotation extends AbstractEdmItem implements Annotatable { private static final long serialVersionUID = -7137313445729486860L; private String term; - // Target should be a target path -// private String targetPath; private String qualifier; - private AnnotationExpression expression; + private List annotation = new ArrayList(); - private List annotation; + private AnnotationExpression annotationExpression; + + public AnnotationExpression getExpression() { + return annotationExpression; + } + + public void setAnnotationExpression(final AnnotationExpression annotationExpression) { + this.annotationExpression = annotationExpression; + } public String getTerm() { return term; @@ -54,27 +61,17 @@ public class Annotation extends AbstractEdmItem implements Annotatable{ return this; } - public AnnotationExpression getExpression() { - return expression; - } +// public List getAnnotation() { +// return annotation; +// } - public Annotation setExpression(final AnnotationExpression expression) { - this.expression = expression; - return this; - } - - public List getAnnotation() { - return annotation; - } - - public Annotation setAnnotation(final List annotation) { + public Annotation setAnnotations(final List annotation) { this.annotation = annotation; return this; } @Override public List getAnnotations() { - // TODO Auto-generated method stub - return null; + return annotation; } } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/EnumType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/EnumType.java index c2c2c6d57..badf0ba41 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/EnumType.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/EnumType.java @@ -55,7 +55,6 @@ public class EnumType extends AbstractEdmItem implements Named, Annotatable { return this; } - //TODO: Underlying type has a default public String getUnderlyingType() { if(underlyingType != null){ return underlyingType.getFullQualifiedNameAsString(); diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Property.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Property.java index e556e67df..cf4e928ff 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Property.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Property.java @@ -34,7 +34,6 @@ public class Property extends AbstractEdmItem implements Named, Annotatable{ private boolean collection; - // TODO: Mimetype and mapping what here private String mimeType; private Mapping mapping; diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java index 89f2e8996..31583e320 100755 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java @@ -60,6 +60,6 @@ public class PropertyImpl extends AbstractValuable implements Property { @Override public boolean isNull() { - return getValue() == null || "Edm.Null".equals(type); // TODO: improve + return getValue() == null || "Edm.Null".equals(type); } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmOperationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmOperationImpl.java index 6b451c342..009eadc13 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmOperationImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmOperationImpl.java @@ -96,4 +96,9 @@ public abstract class EdmOperationImpl extends AbstractEdmOperation { public List getAnnotations() { return helper.getAnnotations(); } + + @Override + public String getEntitySetPath(){ + return operation.getEntitySetPath(); + } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImpl.java index 1468e8167..79fe22c78 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImpl.java @@ -340,7 +340,7 @@ public class EdmProviderImpl extends AbstractEdm { } } - //TODO: Check implementation + //TODO: Check Provider annotations implementation @Override protected EdmAnnotations createAnnotationGroup(final FullQualifiedName targetName) { try { diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/FixedFormatSerializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/FixedFormatSerializer.java index 7e62136d1..a62531baf 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/FixedFormatSerializer.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/FixedFormatSerializer.java @@ -49,7 +49,6 @@ public interface FixedFormatSerializer { InputStream primitiveValue(EdmPrimitiveType type, Object value, PrimitiveValueSerializerOptions options) throws SerializerException; - // TODO: Return type /** * Serializes a batch response * @param batchResponses diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java index a1874c8c2..949e598c0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java @@ -185,7 +185,6 @@ public class BatchParserCommon { public static void consumeBlankLine(final List remainingMessage, final boolean isStrict) throws BatchDeserializerException { - // TODO is \r\n to strict? if (remainingMessage.size() > 0 && remainingMessage.get(0).toString().matches("\\s*(\r\n|\n)\\s*")) { remainingMessage.remove(0); } else { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerImpl.java index 004b23aff..6fd911b86 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerImpl.java @@ -60,7 +60,7 @@ public class FixedFormatSerializerImpl implements FixedFormatSerializer { } } - // TODO: Signature + // TODO: Signature refactoring for writeBatchResponse @Override public InputStream batchResponse(final List batchResponses, final String boundary) throws BatchSerializerException { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java index e7a9cfbf2..aab662454 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java @@ -79,7 +79,6 @@ public class ODataJsonSerializer implements ODataSerializer { CircleStreamBuffer buffer; JsonGenerator gen = null; - // TODO: move stream initialization into separate method try { buffer = new CircleStreamBuffer(); gen = new JsonFactory().createGenerator(buffer.getOutputStream()) @@ -89,10 +88,6 @@ public class ODataJsonSerializer implements ODataSerializer { gen.close(); - // TODO: Check correct stream handling - // writer.flush(); - // buffer.closeWrite(); - return buffer.getInputStream(); } catch (final IOException e) { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java index 54f366a9a..17a02d61a 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java @@ -116,6 +116,7 @@ public class MetadataDocumentXmlSerializer { private final static String NS_EDMX = "http://docs.oasis-open.org/odata/ns/edmx"; private final static String NS_EDM = "http://docs.oasis-open.org/odata/ns/edm"; + private static final String XML_ENTITY_SET_PATH = "EntitySetPath"; private final ServiceMetadata serviceMetadata; private final Map namespaceToAlias = new HashMap(); @@ -124,6 +125,8 @@ public class MetadataDocumentXmlSerializer { this.serviceMetadata = serviceMetadata; } + // TODO: Annotations in metadata document + public void writeMetadataDocument(final XMLStreamWriter writer) throws XMLStreamException { writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0"); writer.setPrefix(PREFIX_EDMX, NS_EDMX); @@ -247,7 +250,7 @@ public class MetadataDocumentXmlSerializer { for (EdmFunctionImport functionImport : functionImports) { writer.writeStartElement(XML_FUNCTION_IMPORT); writer.writeAttribute(XML_NAME, functionImport.getName()); - + String functionFQNString; FullQualifiedName functionFqn = functionImport.getFunctionFqn(); if (namespaceToAlias.get(functionFqn.getNamespace()) != null) { @@ -256,14 +259,13 @@ public class MetadataDocumentXmlSerializer { functionFQNString = functionFqn.getFullQualifiedNameAsString(); } writer.writeAttribute(XML_FUNCTION, functionFQNString); - + EdmEntitySet returnedEntitySet = functionImport.getReturnedEntitySet(); if (returnedEntitySet != null) { writer.writeAttribute(XML_ENTITY_SET, containerNamespace + "." + returnedEntitySet.getName()); } writer.writeAttribute(XML_INCLUDE_IN_SERVICE_DOCUMENT, "" + functionImport.isIncludeInServiceDocument()); - // TODO: Annotations writer.writeEndElement(); } } @@ -274,7 +276,6 @@ public class MetadataDocumentXmlSerializer { writer.writeStartElement(XML_ACTION_IMPORT); writer.writeAttribute(XML_NAME, actionImport.getName()); writer.writeAttribute(XML_ACTION, getAliasedFullQualifiedName(actionImport.getUnboundAction(), false)); - // TODO: Annotations writer.writeEndElement(); } } @@ -287,7 +288,6 @@ public class MetadataDocumentXmlSerializer { writer.writeAttribute(XML_ENTITY_TYPE, getAliasedFullQualifiedName(singleton.getEntityType(), false)); appendNavigationPropertyBindings(writer, singleton); - // TODO: Annotations writer.writeEndElement(); } @@ -312,7 +312,6 @@ public class MetadataDocumentXmlSerializer { writer.writeAttribute(XML_ENTITY_TYPE, getAliasedFullQualifiedName(entitySet.getEntityType(), false)); appendNavigationPropertyBindings(writer, entitySet); - // TODO: Annotations writer.writeEndElement(); } } @@ -322,7 +321,9 @@ public class MetadataDocumentXmlSerializer { for (EdmFunction function : functions) { writer.writeStartElement(XML_FUNCTION); writer.writeAttribute(XML_NAME, function.getName()); - // TODO: EntitySetPath + if (function.getEntitySetPath() != null) { + writer.writeAttribute(XML_ENTITY_SET_PATH, function.getEntitySetPath()); + } writer.writeAttribute(XML_IS_BOUND, "" + function.isBound()); writer.writeAttribute(XML_IS_COMPOSABLE, "" + function.isComposable()); @@ -373,6 +374,9 @@ public class MetadataDocumentXmlSerializer { for (EdmAction action : actions) { writer.writeStartElement(XML_ACTION); writer.writeAttribute(XML_NAME, action.getName()); + if (action.getEntitySetPath() != null) { + writer.writeAttribute(XML_ENTITY_SET_PATH, action.getEntitySetPath()); + } writer.writeAttribute(XML_IS_BOUND, "" + action.isBound()); appendOperationParameters(writer, action); @@ -424,11 +428,11 @@ public class MetadataDocumentXmlSerializer { if (complexType.getBaseType() != null) { writer.writeAttribute(XML_BASE_TYPE, getAliasedFullQualifiedName(complexType.getBaseType(), false)); } - - if(complexType.isAbstract()) { + + if (complexType.isAbstract()) { writer.writeAttribute(ABSTRACT, TRUE); } - + appendProperties(writer, complexType); appendNavigationProperties(writer, complexType); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java index ac856a730..acd1dedd0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java @@ -61,7 +61,6 @@ public class ODataXmlSerializerImpl implements ODataSerializer { CircleStreamBuffer buffer; XMLStreamWriter xmlStreamWriter = null; - // TODO: move stream initialization into separate method try { buffer = new CircleStreamBuffer(); xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(buffer.getOutputStream(), DEFAULT_CHARSET);