[OLINGO-659] Small codestyle fixes
This commit is contained in:
parent
b376959f9f
commit
77c0ef5ccc
|
@ -30,26 +30,6 @@ import org.apache.olingo.client.api.EdmEnabledODataClient;
|
|||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.api.data.ServiceDocument;
|
||||
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.ClientAnnotation;
|
||||
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.ClientValuable;
|
||||
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.ClientDeletedEntityImpl;
|
||||
import org.apache.olingo.client.core.domain.ClientDeltaLinkImpl;
|
||||
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.EdmBindingTarget;
|
||||
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.EdmType;
|
||||
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.format.ContentType;
|
||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||
|
|
|
@ -266,12 +266,21 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
|
|||
return getFullQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.getFullQualifiedName().getFullQualifiedNameAsString().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if(obj == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(obj == this){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(obj instanceof EdmEnumType){
|
||||
EdmEnumType other = (EdmEnumType) obj;
|
||||
if(this.getFullQualifiedName().equals(other.getFullQualifiedName())){
|
||||
|
|
|
@ -27,6 +27,7 @@ public class SerializerException extends ODataLibraryException {
|
|||
|
||||
/** Keys for exception texts in the resource bundle. */
|
||||
public enum MessageKeys implements MessageKey {
|
||||
NULL_METADATA_OR_EDM,
|
||||
NOT_IMPLEMENTED,
|
||||
/** parameter: format */
|
||||
UNSUPPORTED_FORMAT,
|
||||
|
|
|
@ -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.EdmSingleton;
|
||||
import org.apache.olingo.server.api.ServiceMetadata;
|
||||
import org.apache.olingo.server.api.serializer.SerializerException;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
||||
|
@ -42,7 +43,11 @@ public class ServiceDocumentJsonSerializer {
|
|||
private final boolean isODataMetadataNone;
|
||||
|
||||
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.serviceRoot = serviceRoot;
|
||||
this.isODataMetadataNone = isODataMetadataNone;
|
||||
|
|
|
@ -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.EdmxReferenceIncludeAnnotation;
|
||||
import org.apache.olingo.server.api.serializer.ODataSerializer;
|
||||
import org.apache.olingo.server.api.serializer.SerializerException;
|
||||
|
||||
public class MetadataDocumentXmlSerializer {
|
||||
|
||||
|
@ -123,7 +124,11 @@ public class MetadataDocumentXmlSerializer {
|
|||
private final ServiceMetadata serviceMetadata;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.edmx.EdmxReference;
|
||||
import org.apache.olingo.server.api.serializer.ODataSerializer;
|
||||
import org.apache.olingo.server.api.serializer.SerializerException;
|
||||
|
||||
public class ServiceDocumentXmlSerializer {
|
||||
public static final String KIND = "kind";
|
||||
|
@ -37,7 +38,7 @@ public class ServiceDocumentXmlSerializer {
|
|||
public static final String FUNCTION_IMPORT = "FunctionImport";
|
||||
public static final String SINGLETON = "Singleton";
|
||||
public static final String SERVICE_DOCUMENT = "ServiceDocument";
|
||||
|
||||
|
||||
private static final String APP = "app";
|
||||
private static final String NS_APP = "http://www.w3.org/2007/app";
|
||||
private static final String ATOM = "atom";
|
||||
|
@ -48,7 +49,12 @@ public class ServiceDocumentXmlSerializer {
|
|||
private final ServiceMetadata metadata;
|
||||
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.serviceRoot = serviceRoot;
|
||||
}
|
||||
|
@ -56,15 +62,15 @@ public class ServiceDocumentXmlSerializer {
|
|||
public void writeServiceDocument(final XMLStreamWriter writer) throws XMLStreamException {
|
||||
final String metadataUri =
|
||||
(serviceRoot == null ? "" : serviceRoot.endsWith("/") ? serviceRoot : (serviceRoot + "/"))
|
||||
+ Constants.METADATA;
|
||||
|
||||
+ Constants.METADATA;
|
||||
|
||||
writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0");
|
||||
writer.writeStartElement(APP, "service", NS_APP);
|
||||
writer.writeNamespace(ATOM, NS_ATOM);
|
||||
writer.writeNamespace(APP, NS_APP);
|
||||
writer.writeNamespace(METADATA, NS_METADATA);
|
||||
writer.writeAttribute(METADATA, NS_METADATA, "context", metadataUri);
|
||||
|
||||
|
||||
if (metadata != null
|
||||
&& metadata.getServiceMetadataETagSupport() != null
|
||||
&& metadata.getServiceMetadataETagSupport().getMetadataETag() != null) {
|
||||
|
@ -73,25 +79,25 @@ public class ServiceDocumentXmlSerializer {
|
|||
}
|
||||
|
||||
writer.writeStartElement(APP, "workspace", NS_APP);
|
||||
|
||||
|
||||
final Edm edm = metadata.getEdm();
|
||||
|
||||
writer.writeStartElement(ATOM, "title", NS_APP);
|
||||
writer.writeCharacters(edm.getEntityContainer(null).getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
writer.writeEndElement();
|
||||
|
||||
|
||||
writeEntitySets(writer, edm);
|
||||
writeFunctionImports(writer, edm);
|
||||
writeSingletons(writer, edm);
|
||||
writeServiceDocuments(writer);
|
||||
writer.writeEndElement(); // end workspace
|
||||
writer.writeEndElement(); // end service
|
||||
writer.writeEndElement(); // end service
|
||||
}
|
||||
|
||||
private void writeServiceDocuments(XMLStreamWriter writer) throws XMLStreamException {
|
||||
|
||||
|
||||
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.writeStartElement(ATOM, "title", NS_ATOM);
|
||||
writer.writeCharacters(reference.getUri().toASCIIString());
|
||||
|
@ -124,7 +130,7 @@ public class ServiceDocumentXmlSerializer {
|
|||
writer.writeStartElement(ATOM, "title", NS_ATOM);
|
||||
writer.writeCharacters(edmFunctionImport.getName());
|
||||
writer.writeEndElement();
|
||||
writer.writeEndElement();
|
||||
writer.writeEndElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +141,7 @@ public class ServiceDocumentXmlSerializer {
|
|||
writer.writeStartElement(METADATA, "singleton", NS_METADATA);
|
||||
writer.writeAttribute("href", edmSingleton.getName());
|
||||
writer.writeStartElement(ATOM, "title", NS_ATOM);
|
||||
writer.writeCharacters( edmSingleton.getName());
|
||||
writer.writeCharacters(edmSingleton.getName());
|
||||
writer.writeEndElement();
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
|
|
@ -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.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.UNSUPPORTED_FORMAT=The format '%1$s' is not supported.
|
||||
SerializerException.JSON_METADATA=The metadata document cannot be provided in JSON format.
|
||||
|
|
Loading…
Reference in New Issue