[OLINGO-659] Small codestyle fixes

This commit is contained in:
Christian Amend 2015-08-24 16:12:35 +02:00
parent b376959f9f
commit 77c0ef5ccc
7 changed files with 61 additions and 35 deletions

View File

@ -30,26 +30,6 @@ import org.apache.olingo.client.api.EdmEnabledODataClient;
import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.data.ServiceDocument; import org.apache.olingo.client.api.data.ServiceDocument;
import org.apache.olingo.client.api.data.ServiceDocumentItem; import org.apache.olingo.client.api.data.ServiceDocumentItem;
import org.apache.olingo.client.api.serialization.ODataBinder;
import org.apache.olingo.client.api.serialization.ODataSerializerException;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.Annotatable;
import org.apache.olingo.commons.api.data.Annotation;
import org.apache.olingo.commons.api.data.ComplexValue;
import org.apache.olingo.commons.api.data.ContextURL;
import org.apache.olingo.commons.api.data.DeletedEntity;
import org.apache.olingo.commons.api.data.Delta;
import org.apache.olingo.commons.api.data.DeltaLink;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.EntityCollection;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Linked;
import org.apache.olingo.commons.api.data.Operation;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.data.Valuable;
import org.apache.olingo.commons.api.data.ValueType;
import org.apache.olingo.client.api.domain.ClientAnnotatable; import org.apache.olingo.client.api.domain.ClientAnnotatable;
import org.apache.olingo.client.api.domain.ClientAnnotation; import org.apache.olingo.client.api.domain.ClientAnnotation;
import org.apache.olingo.client.api.domain.ClientCollectionValue; import org.apache.olingo.client.api.domain.ClientCollectionValue;
@ -69,10 +49,30 @@ import org.apache.olingo.client.api.domain.ClientProperty;
import org.apache.olingo.client.api.domain.ClientServiceDocument; import org.apache.olingo.client.api.domain.ClientServiceDocument;
import org.apache.olingo.client.api.domain.ClientValuable; import org.apache.olingo.client.api.domain.ClientValuable;
import org.apache.olingo.client.api.domain.ClientValue; import org.apache.olingo.client.api.domain.ClientValue;
import org.apache.olingo.client.api.serialization.ODataBinder;
import org.apache.olingo.client.api.serialization.ODataSerializerException;
import org.apache.olingo.client.core.domain.ClientAnnotationImpl; import org.apache.olingo.client.core.domain.ClientAnnotationImpl;
import org.apache.olingo.client.core.domain.ClientDeletedEntityImpl; import org.apache.olingo.client.core.domain.ClientDeletedEntityImpl;
import org.apache.olingo.client.core.domain.ClientDeltaLinkImpl; import org.apache.olingo.client.core.domain.ClientDeltaLinkImpl;
import org.apache.olingo.client.core.domain.ClientPropertyImpl; import org.apache.olingo.client.core.domain.ClientPropertyImpl;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.Annotatable;
import org.apache.olingo.commons.api.data.Annotation;
import org.apache.olingo.commons.api.data.ComplexValue;
import org.apache.olingo.commons.api.data.ContextURL;
import org.apache.olingo.commons.api.data.DeletedEntity;
import org.apache.olingo.commons.api.data.Delta;
import org.apache.olingo.commons.api.data.DeltaLink;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.EntityCollection;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Linked;
import org.apache.olingo.commons.api.data.Operation;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.data.Valuable;
import org.apache.olingo.commons.api.data.ValueType;
import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmBindingTarget; import org.apache.olingo.commons.api.edm.EdmBindingTarget;
import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmComplexType;
@ -90,7 +90,6 @@ import org.apache.olingo.commons.api.edm.EdmStructuredType;
import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.api.edm.geo.Geospatial; import org.apache.olingo.commons.api.edm.geo.Geospatial;
import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.commons.core.edm.EdmTypeInfo;

View File

@ -266,12 +266,21 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
return getFullQualifiedName(); return getFullQualifiedName();
} }
@Override
public int hashCode() {
return this.getFullQualifiedName().getFullQualifiedNameAsString().hashCode();
}
@Override @Override
public boolean equals(Object obj){ public boolean equals(Object obj){
if(obj == null){ if(obj == null){
return false; return false;
} }
if(obj == this){
return true;
}
if(obj instanceof EdmEnumType){ if(obj instanceof EdmEnumType){
EdmEnumType other = (EdmEnumType) obj; EdmEnumType other = (EdmEnumType) obj;
if(this.getFullQualifiedName().equals(other.getFullQualifiedName())){ if(this.getFullQualifiedName().equals(other.getFullQualifiedName())){

View File

@ -27,6 +27,7 @@ public class SerializerException extends ODataLibraryException {
/** Keys for exception texts in the resource bundle. */ /** Keys for exception texts in the resource bundle. */
public enum MessageKeys implements MessageKey { public enum MessageKeys implements MessageKey {
NULL_METADATA_OR_EDM,
NOT_IMPLEMENTED, NOT_IMPLEMENTED,
/** parameter: format */ /** parameter: format */
UNSUPPORTED_FORMAT, UNSUPPORTED_FORMAT,

View File

@ -27,6 +27,7 @@ import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmSingleton; import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.server.api.ServiceMetadata; import org.apache.olingo.server.api.ServiceMetadata;
import org.apache.olingo.server.api.serializer.SerializerException;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -42,7 +43,11 @@ public class ServiceDocumentJsonSerializer {
private final boolean isODataMetadataNone; private final boolean isODataMetadataNone;
public ServiceDocumentJsonSerializer(final ServiceMetadata metadata, final String serviceRoot, public ServiceDocumentJsonSerializer(final ServiceMetadata metadata, final String serviceRoot,
final boolean isODataMetadataNone) { final boolean isODataMetadataNone) throws SerializerException {
if (metadata == null || metadata.getEdm() == null) {
throw new SerializerException("Service Metadata and EDM must not be null for a service.",
SerializerException.MessageKeys.NULL_METADATA_OR_EDM);
}
this.metadata = metadata; this.metadata = metadata;
this.serviceRoot = serviceRoot; this.serviceRoot = serviceRoot;
this.isODataMetadataNone = isODataMetadataNone; this.isODataMetadataNone = isODataMetadataNone;

View File

@ -56,6 +56,7 @@ import org.apache.olingo.server.api.edmx.EdmxReference;
import org.apache.olingo.server.api.edmx.EdmxReferenceInclude; import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
import org.apache.olingo.server.api.edmx.EdmxReferenceIncludeAnnotation; import org.apache.olingo.server.api.edmx.EdmxReferenceIncludeAnnotation;
import org.apache.olingo.server.api.serializer.ODataSerializer; import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.api.serializer.SerializerException;
public class MetadataDocumentXmlSerializer { public class MetadataDocumentXmlSerializer {
@ -123,7 +124,11 @@ public class MetadataDocumentXmlSerializer {
private final ServiceMetadata serviceMetadata; private final ServiceMetadata serviceMetadata;
private final Map<String, String> namespaceToAlias = new HashMap<String, String>(); private final Map<String, String> namespaceToAlias = new HashMap<String, String>();
public MetadataDocumentXmlSerializer(final ServiceMetadata serviceMetadata) { public MetadataDocumentXmlSerializer(final ServiceMetadata serviceMetadata) throws SerializerException {
if (serviceMetadata == null || serviceMetadata.getEdm() == null) {
throw new SerializerException("Service Metadata and EDM must not be null for a service.",
SerializerException.MessageKeys.NULL_METADATA_OR_EDM);
}
this.serviceMetadata = serviceMetadata; this.serviceMetadata = serviceMetadata;
} }

View File

@ -30,6 +30,7 @@ import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.server.api.ServiceMetadata; import org.apache.olingo.server.api.ServiceMetadata;
import org.apache.olingo.server.api.edmx.EdmxReference; import org.apache.olingo.server.api.edmx.EdmxReference;
import org.apache.olingo.server.api.serializer.ODataSerializer; import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.api.serializer.SerializerException;
public class ServiceDocumentXmlSerializer { public class ServiceDocumentXmlSerializer {
public static final String KIND = "kind"; public static final String KIND = "kind";
@ -48,7 +49,12 @@ public class ServiceDocumentXmlSerializer {
private final ServiceMetadata metadata; private final ServiceMetadata metadata;
private final String serviceRoot; private final String serviceRoot;
public ServiceDocumentXmlSerializer(final ServiceMetadata metadata, final String serviceRoot) { public ServiceDocumentXmlSerializer(final ServiceMetadata metadata, final String serviceRoot)
throws SerializerException {
if (metadata == null || metadata.getEdm() == null) {
throw new SerializerException("Service Metadata and EDM must not be null for a service.",
SerializerException.MessageKeys.NULL_METADATA_OR_EDM);
}
this.metadata = metadata; this.metadata = metadata;
this.serviceRoot = serviceRoot; this.serviceRoot = serviceRoot;
} }
@ -56,7 +62,7 @@ public class ServiceDocumentXmlSerializer {
public void writeServiceDocument(final XMLStreamWriter writer) throws XMLStreamException { public void writeServiceDocument(final XMLStreamWriter writer) throws XMLStreamException {
final String metadataUri = final String metadataUri =
(serviceRoot == null ? "" : serviceRoot.endsWith("/") ? serviceRoot : (serviceRoot + "/")) (serviceRoot == null ? "" : serviceRoot.endsWith("/") ? serviceRoot : (serviceRoot + "/"))
+ Constants.METADATA; + Constants.METADATA;
writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0"); writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0");
writer.writeStartElement(APP, "service", NS_APP); writer.writeStartElement(APP, "service", NS_APP);
@ -91,7 +97,7 @@ public class ServiceDocumentXmlSerializer {
private void writeServiceDocuments(XMLStreamWriter writer) throws XMLStreamException { private void writeServiceDocuments(XMLStreamWriter writer) throws XMLStreamException {
for (EdmxReference reference : this.metadata.getReferences()) { for (EdmxReference reference : this.metadata.getReferences()) {
writer.writeStartElement(METADATA , "service-document", NS_METADATA); writer.writeStartElement(METADATA, "service-document", NS_METADATA);
writer.writeAttribute("href", reference.getUri().toASCIIString()); writer.writeAttribute("href", reference.getUri().toASCIIString());
writer.writeStartElement(ATOM, "title", NS_ATOM); writer.writeStartElement(ATOM, "title", NS_ATOM);
writer.writeCharacters(reference.getUri().toASCIIString()); writer.writeCharacters(reference.getUri().toASCIIString());
@ -135,7 +141,7 @@ public class ServiceDocumentXmlSerializer {
writer.writeStartElement(METADATA, "singleton", NS_METADATA); writer.writeStartElement(METADATA, "singleton", NS_METADATA);
writer.writeAttribute("href", edmSingleton.getName()); writer.writeAttribute("href", edmSingleton.getName());
writer.writeStartElement(ATOM, "title", NS_ATOM); writer.writeStartElement(ATOM, "title", NS_ATOM);
writer.writeCharacters( edmSingleton.getName()); writer.writeCharacters(edmSingleton.getName());
writer.writeEndElement(); writer.writeEndElement();
writer.writeEndElement(); writer.writeEndElement();
} }

View File

@ -86,6 +86,7 @@ ContentNegotiatorException.UNSUPPORTED_CONTENT_TYPE=The content type '%1$s' is n
ContentNegotiatorException.NO_CONTENT_TYPE_SUPPORTED=No content type has been specified as supported. ContentNegotiatorException.NO_CONTENT_TYPE_SUPPORTED=No content type has been specified as supported.
ContentNegotiatorException.UNSUPPORTED_FORMAT_OPTION=The $format option '%1$s' is not supported. ContentNegotiatorException.UNSUPPORTED_FORMAT_OPTION=The $format option '%1$s' is not supported.
SerializerException.NULL_METADATA_OR_EDM=The server does not define any service metadata.
SerializerException.NOT_IMPLEMENTED=The requested serialization method has not been implemented yet. SerializerException.NOT_IMPLEMENTED=The requested serialization method has not been implemented yet.
SerializerException.UNSUPPORTED_FORMAT=The format '%1$s' is not supported. SerializerException.UNSUPPORTED_FORMAT=The format '%1$s' is not supported.
SerializerException.JSON_METADATA=The metadata document cannot be provided in JSON format. SerializerException.JSON_METADATA=The metadata document cannot be provided in JSON format.