[Olingo-266] clean up

This commit is contained in:
Stephan Klevenz 2014-05-14 17:15:39 +02:00
parent bb48147bc2
commit 92ad3423a9
25 changed files with 90 additions and 85 deletions

View File

@ -30,23 +30,22 @@ public class ODataHandler {
private ODataServer server;
private Edm edm;
public ODataHandler(ODataServer server, Edm edm) {
public ODataHandler(final ODataServer server, final Edm edm) {
this.server = server;
this.edm = edm;
}
public ODataResponse process(ODataRequest odRequest) {
public ODataResponse process(final ODataRequest odRequest) {
ODataResponse response = new ODataResponse();
ODataSerializer serializer = server.createSerializer(ODataFormat.JSON);
InputStream responseEntity = serializer.serviceDocument(edm, "http//:root");
response.setStatusCode(200);
response.setHeader("Content-Type", "application/json");
response.setContent(responseEntity);
return response;
}
}

View File

@ -46,13 +46,13 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
private Edm edm;
private ODataServer server;
public ODataHttpHandlerImpl(ODataServer server, Edm edm) {
public ODataHttpHandlerImpl(final ODataServer server, final Edm edm) {
this.edm = edm;
this.server = server;
}
@Override
public void process(HttpServletRequest request, HttpServletResponse response) {
public void process(final HttpServletRequest request, final HttpServletResponse response) {
ODataRequest odRequest = createODataRequest(request);
ODataHandler handler = new ODataHandler(server, edm);
@ -60,7 +60,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
convertToHttp(response, odResponse);
}
private void convertToHttp(HttpServletResponse response, ODataResponse odResponse) {
private void convertToHttp(final HttpServletResponse response, final ODataResponse odResponse) {
response.setStatus(odResponse.getStatusCode());
for (Entry<String, String> entry : odResponse.getHeaders().entrySet()) {
@ -68,13 +68,11 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
}
InputStream in = odResponse.getContent();
try
{
try {
byte[] buffer = new byte[1024];
int bytesRead = 0;
do
{
do {
bytesRead = in.read(buffer, 0, buffer.length);
response.getOutputStream().write(buffer, 0, bytesRead);
} while (bytesRead == buffer.length);
@ -94,7 +92,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
}
}
private ODataRequest createODataRequest(HttpServletRequest request) {
private ODataRequest createODataRequest(final HttpServletRequest request) {
try {
ODataRequest odRequest = new ODataRequest();

View File

@ -36,7 +36,7 @@ public class ODataRequest {
return method;
}
public void setMethod(HttpMethod method) {
public void setMethod(final HttpMethod method) {
this.method = method;
}
@ -44,7 +44,7 @@ public class ODataRequest {
return headers;
}
public void setHeaders(Map<String, List<String>> headers) {
public void setHeaders(final Map<String, List<String>> headers) {
this.headers = headers;
}
@ -52,7 +52,7 @@ public class ODataRequest {
return body;
}
public void setBody(InputStream body) {
public void setBody(final InputStream body) {
this.body = body;
}
@ -60,7 +60,7 @@ public class ODataRequest {
return queryParameters;
}
public void setQueryParameters(Map<String, String> queryParameters) {
public void setQueryParameters(final Map<String, String> queryParameters) {
this.queryParameters = queryParameters;
}
@ -68,7 +68,7 @@ public class ODataRequest {
return contentType;
}
public void setContentType(String contentType) {
public void setContentType(final String contentType) {
this.contentType = contentType;
}
}

View File

@ -29,15 +29,15 @@ public class ODataResponse {
private Map<String, String> headers = new HashMap<String, String>();
private InputStream content;
public void setStatusCode(int statusCode) {
public void setStatusCode(final int statusCode) {
this.statusCode = statusCode;
}
public void setHeader(String name, String value) {
public void setHeader(final String name, final String value) {
headers.put(name, value);
}
public void setContent(InputStream content) {
public void setContent(final InputStream content) {
this.content = content;
}

View File

@ -49,12 +49,12 @@ public class ODataServerImpl extends ODataServer {
}
@Override
public ODataHttpHandler createHandler(Edm edm) {
public ODataHttpHandler createHandler(final Edm edm) {
return new ODataHttpHandlerImpl(this, edm);
}
@Override
public Edm createEdm(EdmProvider edmProvider) {
public Edm createEdm(final EdmProvider edmProvider) {
return new EdmProviderImpl(edmProvider);
}

View File

@ -36,7 +36,7 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
private final EdmStructuredTypeHelper helper;
public static EdmComplexTypeImpl getInstance(
final Edm edm, final FullQualifiedName name, final ComplexType complexType) {
final Edm edm, final FullQualifiedName name, final ComplexType complexType) {
final EdmComplexTypeImpl instance = new EdmComplexTypeImpl(edm, name, complexType);
return instance;

View File

@ -46,13 +46,13 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
private EntityContainer container;
public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider,
final EntityContainerInfo entityContainerInfo) {
final EntityContainerInfo entityContainerInfo) {
super(edm, entityContainerInfo.getContainerName(), entityContainerInfo.getExtendsContainer());
this.provider = provider;
}
public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider, final FullQualifiedName containerFQN,
final EntityContainer entityContainer) {
final EntityContainer entityContainer) {
super(edm, containerFQN, entityContainer.getExtendsContainer());
this.provider = provider;
container = entityContainer;
@ -195,13 +195,13 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
}
}
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -19,6 +19,7 @@
package org.apache.olingo.server.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
@ -44,13 +45,13 @@ public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntityS
public TargetType getAnnotationsTargetType() {
return TargetType.EntitySet;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -44,7 +44,7 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
private boolean baseTypeChecked = false;
public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName name,
final EntityType entityType) {
final EntityType entityType) {
final EdmEntityTypeImpl instance = new EdmEntityTypeImpl(edm, name, entityType);
return instance;
@ -105,7 +105,7 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -47,7 +47,7 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType
underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32);
} else {
underlyingType = EdmPrimitiveTypeFactory.getInstance(
EdmPrimitiveTypeKind.valueOf(enumType.getUnderlyingType().getName()));
EdmPrimitiveTypeKind.valueOf(enumType.getUnderlyingType().getName()));
// TODO: Should we validate that the underlying type is of byte, sbyte, in16, int32 or int64?
}

View File

@ -1,24 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmTerm;
@ -36,7 +37,7 @@ public class EdmMemberImpl extends AbstractEdmMember {
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -39,7 +39,7 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty {
private List<EdmReferentialConstraint> referentialConstraints;
public EdmNavigationPropertyImpl(
final Edm edm, final FullQualifiedName structuredTypeName, final NavigationProperty navigationProperty) {
final Edm edm, final FullQualifiedName structuredTypeName, final NavigationProperty navigationProperty) {
super(edm, navigationProperty.getName());
@ -93,7 +93,7 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty {
if (providerConstraints != null) {
for (ReferentialConstraint constraint : providerConstraints) {
referentialConstraints.add(
new EdmReferentialConstraintImpl(constraint.getProperty(), constraint.getReferencedProperty()));
new EdmReferentialConstraintImpl(constraint.getProperty(), constraint.getReferencedProperty()));
}
}
}
@ -110,7 +110,7 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty {
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -61,7 +61,7 @@ public abstract class EdmOperationImpl extends AbstractEdmOperation {
}
protected EdmOperationImpl(final Edm edm, final FullQualifiedName name, final Operation operation,
final EdmTypeKind kind) {
final EdmTypeKind kind) {
super(edm, name, kind);
this.operation = operation;

View File

@ -19,6 +19,7 @@
package org.apache.olingo.server.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
@ -29,7 +30,7 @@ import org.apache.olingo.server.api.edm.provider.OperationImport;
public abstract class EdmOperationImportImpl extends AbstractEdmOperationImport {
public EdmOperationImportImpl(final Edm edm, final EdmEntityContainer container,
final OperationImport operationImport) {
final OperationImport operationImport) {
super(edm, container, operationImport.getName(), operationImport.getEntitySet());
}

View File

@ -19,6 +19,7 @@
package org.apache.olingo.server.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmMapping;
@ -68,7 +69,7 @@ public class EdmParameterImpl extends AbstractEdmParameter {
@Override
public SRID getSrid() {
return null; // TODO: provide implementation
return null; // TODO: provide implementation
}
@Override
@ -76,7 +77,7 @@ public class EdmParameterImpl extends AbstractEdmParameter {
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -19,6 +19,7 @@
package org.apache.olingo.server.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmMapping;
@ -43,7 +44,7 @@ public class EdmPropertyImpl extends AbstractEdmProperty implements EdmProperty
this.structuredTypeName = structuredTypeName;
this.property = property;
this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType().toString()).build();
typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType().toString()).build();
}
@Override
@ -88,7 +89,7 @@ public class EdmPropertyImpl extends AbstractEdmProperty implements EdmProperty
@Override
public SRID getSrid() {
return null; // TODO: provide implementation
return null; // TODO: provide implementation
}
@Override
@ -111,7 +112,7 @@ public class EdmPropertyImpl extends AbstractEdmProperty implements EdmProperty
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -133,7 +133,7 @@ public class EdmProviderImpl extends AbstractEdm {
@Override
public EdmAction createBoundAction(final FullQualifiedName actionName,
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
try {
List<Action> actions = actionsMap.get(actionName);
@ -151,7 +151,7 @@ public class EdmProviderImpl extends AbstractEdm {
final List<Parameter> parameters = action.getParameters();
final Parameter parameter = parameters.get(0);
if (bindingParameterTypeName.equals(parameter.getType())
&& isBindingParameterCollection.booleanValue() == parameter.isCollection()) {
&& isBindingParameterCollection.booleanValue() == parameter.isCollection()) {
return EdmActionImpl.getInstance(this, actionName, action);
}
@ -166,8 +166,8 @@ public class EdmProviderImpl extends AbstractEdm {
@Override
public EdmFunction createBoundFunction(final FullQualifiedName functionName,
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
final List<String> parameterNames) {
final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
final List<String> parameterNames) {
try {
List<Function> functions = functionsMap.get(functionName);
@ -179,8 +179,8 @@ public class EdmProviderImpl extends AbstractEdm {
functionsMap.put(functionName, functions);
}
}
final List<String> parameterNamesCopy
= parameterNames == null ? Collections.<String>emptyList() : parameterNames;
final List<String> parameterNamesCopy =
parameterNames == null ? Collections.<String> emptyList() : parameterNames;
for (Function function : functions) {
if (function.isBound()) {
List<Parameter> providerParameters = function.getParameters();
@ -189,7 +189,7 @@ public class EdmProviderImpl extends AbstractEdm {
}
final Parameter bindingParameter = providerParameters.get(0);
if (bindingParameterTypeName.equals(bindingParameter.getType())
&& isBindingParameterCollection.booleanValue() == bindingParameter.isCollection()) {
&& isBindingParameterCollection.booleanValue() == bindingParameter.isCollection()) {
if (parameterNamesCopy.size() == providerParameters.size() - 1) {
final List<String> providerParameterNames = new ArrayList<String>();
@ -293,8 +293,8 @@ public class EdmProviderImpl extends AbstractEdm {
}
}
final List<String> parameterNamesCopy
= parameterNames == null ? Collections.<String>emptyList() : parameterNames;
final List<String> parameterNamesCopy =
parameterNames == null ? Collections.<String> emptyList() : parameterNames;
for (Function function : functions) {
if (!function.isBound()) {
List<Parameter> providerParameters = function.getParameters();

View File

@ -1,24 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.core.edm.AbstractEdmReferentialConstraint;
@ -34,7 +35,7 @@ public class EdmReferentialConstraintImpl extends AbstractEdmReferentialConstrai
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -59,6 +59,6 @@ public class EdmReturnTypeImpl extends AbstractEdmReturnType {
@Override
public SRID getSrid() {
return null; // TODO: provide implementation
return null; // TODO: provide implementation
}
}

View File

@ -99,7 +99,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
if (providerEntityTypes != null) {
for (EntityType entityType : providerEntityTypes) {
entityTypes.add(EdmEntityTypeImpl.getInstance(edm, new FullQualifiedName(namespace, entityType.getName()),
entityType));
entityType));
}
}
return entityTypes;
@ -112,7 +112,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
if (providerComplexTypes != null) {
for (ComplexType complexType : providerComplexTypes) {
complexTypes.add(EdmComplexTypeImpl.getInstance(edm, new FullQualifiedName(namespace, complexType.getName()),
complexType));
complexType));
}
}
return complexTypes;
@ -165,7 +165,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -175,7 +175,7 @@ public class EdmServiceMetadataImpl implements EdmServiceMetadata {
if (functionImports != null) {
for (FunctionImport functionImport : functionImports) {
functionImportInfos.add(
new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
}
}
}

View File

@ -19,6 +19,7 @@
package org.apache.olingo.server.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
@ -36,13 +37,13 @@ public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSinglet
public TargetType getAnnotationsTargetType() {
return TargetType.Singleton;
}
@Override
public EdmAnnotation getAnnotation(final EdmTerm term) {
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -43,7 +43,7 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
private Map<String, EdmNavigationProperty> navigationProperties;
public EdmStructuredTypeHelperImpl(
final Edm edm, final FullQualifiedName structuredTypeName, final StructuredType structuredType) {
final Edm edm, final FullQualifiedName structuredTypeName, final StructuredType structuredType) {
this.edm = edm;
this.structuredTypeName = structuredTypeName;
@ -70,7 +70,7 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
if (structuredType.getNavigationProperties() != null) {
for (NavigationProperty navigationProperty : structuredType.getNavigationProperties()) {
navigationProperties.put(navigationProperty.getName(),
new EdmNavigationPropertyImpl(edm, structuredTypeName, navigationProperty));
new EdmNavigationPropertyImpl(edm, structuredTypeName, navigationProperty));
}
}
}

View File

@ -19,6 +19,7 @@
package org.apache.olingo.server.core.edm.provider;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAnnotation;
import org.apache.olingo.commons.api.edm.EdmException;
@ -39,7 +40,7 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements
private EdmPrimitiveType edmPrimitiveTypeInstance;
public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName,
final TypeDefinition typeDefinition) {
final TypeDefinition typeDefinition) {
super(edm, typeDefinitionName);
this.typeDefinition = typeDefinition;
@ -50,7 +51,7 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements
if (edmPrimitiveTypeInstance == null) {
try {
edmPrimitiveTypeInstance = EdmPrimitiveTypeFactory.getInstance(
EdmPrimitiveTypeKind.valueOf(typeDefinition.getUnderlyingType().getName()));
EdmPrimitiveTypeKind.valueOf(typeDefinition.getUnderlyingType().getName()));
} catch (IllegalArgumentException e) {
throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e);
}
@ -75,7 +76,7 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements
@Override
public SRID getSrid() {
return null; // TODO: provide implementation
return null; // TODO: provide implementation
}
@Override
@ -88,7 +89,7 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements
// TODO: implement
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<EdmAnnotation> getAnnotations() {
// TODO: implement

View File

@ -44,9 +44,9 @@ public class UriContext {
* Used to stack type information for nested $expand, $filter query options and other cases.
*/
public Stack<TypeInformation> contextTypes;
//CHECKSTYLE:OFF (Maven checkstyle)
/**
// CHECKSTYLE:OFF (Maven checkstyle)
/**
* Set within method
* {@link #visitExpandItem(org.apache.olingo.server.core.uri.antlr.UriParserParser.ExpandPathContext ctx)} and {@link
* #visitExpandPathExtension(final
@ -57,7 +57,7 @@ public class UriContext {
* segments to the currently processed {@link ExpandItemImpl}.
*/
public ExpandItemImpl contextExpandItemPath;
//CHECKSTYLE:ON (Maven checkstyle)
// CHECKSTYLE:ON (Maven checkstyle)
/**
* Set within method