You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/02/17 10:53:39 UTC
[25/35] olingo-odata4 git commit: [OLINGO-575] Removed V4 server code
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
deleted file mode 100644
index baf8093..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.EdmAnnotation;
-import org.apache.olingo.commons.api.edm.EdmAnnotations;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmFunction;
-import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmTerm;
-import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.core.edm.AbstractEdm;
-import org.apache.olingo.server.api.edm.provider.Action;
-import org.apache.olingo.server.api.edm.provider.AliasInfo;
-import org.apache.olingo.server.api.edm.provider.ComplexType;
-import org.apache.olingo.server.api.edm.provider.EdmProvider;
-import org.apache.olingo.server.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.server.api.edm.provider.EntityType;
-import org.apache.olingo.server.api.edm.provider.EnumType;
-import org.apache.olingo.server.api.edm.provider.Function;
-import org.apache.olingo.server.api.edm.provider.Parameter;
-import org.apache.olingo.server.api.edm.provider.Schema;
-import org.apache.olingo.server.api.edm.provider.TypeDefinition;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-public class EdmProviderImpl extends AbstractEdm {
-
- private final EdmProvider provider;
-
- private final Map<FullQualifiedName, List<Action>> actionsMap = new HashMap<FullQualifiedName, List<Action>>();
-
- private final Map<FullQualifiedName, List<Function>> functionsMap = new HashMap<FullQualifiedName, List<Function>>();
-
- public EdmProviderImpl(final EdmProvider provider) {
- this.provider = provider;
-
- }
-
- @Override
- public EdmEntityContainer createEntityContainer(final FullQualifiedName containerName) {
- try {
- EntityContainerInfo entityContainerInfo = provider.getEntityContainerInfo(containerName);
- if (entityContainerInfo != null) {
- return new EdmEntityContainerImpl(this, provider, entityContainerInfo);
- }
- return null;
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
-
- @Override
- public EdmEnumType createEnumType(final FullQualifiedName enumName) {
- try {
- EnumType enumType = provider.getEnumType(enumName);
- if (enumType != null) {
- return new EdmEnumTypeImpl(this, enumName, enumType);
- }
- return null;
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
-
- @Override
- public EdmTypeDefinition createTypeDefinition(final FullQualifiedName typeDefinitionName) {
- try {
- TypeDefinition typeDefinition = provider.getTypeDefinition(typeDefinitionName);
- if (typeDefinition != null) {
- return new EdmTypeDefinitionImpl(this, typeDefinitionName, typeDefinition);
- }
- return null;
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
-
- @Override
- public EdmEntityType createEntityType(final FullQualifiedName entityTypeName) {
- try {
- EntityType entityType = provider.getEntityType(entityTypeName);
- if (entityType != null) {
- return EdmEntityTypeImpl.getInstance(this, entityTypeName, entityType);
- }
- return null;
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
-
- @Override
- public EdmComplexType createComplexType(final FullQualifiedName complexTypeName) {
- try {
- final ComplexType complexType = provider.getComplexType(complexTypeName);
- if (complexType != null) {
- return EdmComplexTypeImpl.getInstance(this, complexTypeName, complexType);
- }
- return null;
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
-
- @Override
- public EdmAction createBoundAction(final FullQualifiedName actionName,
- final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
-
- try {
- List<Action> actions = actionsMap.get(actionName);
- if (actions == null) {
- actions = provider.getActions(actionName);
- if (actions == null) {
- return null;
- } else {
- actionsMap.put(actionName, actions);
- }
- }
- // Search for bound action where binding parameter matches
- for (Action action : actions) {
- if (action.isBound()) {
- final List<Parameter> parameters = action.getParameters();
- final Parameter parameter = parameters.get(0);
- if (bindingParameterTypeName.equals(parameter.getType())
- && isBindingParameterCollection.booleanValue() == parameter.isCollection()) {
-
- return EdmActionImpl.getInstance(this, actionName, action);
- }
-
- }
- }
- return null;
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
-
- @Override
- public EdmFunction createBoundFunction(final FullQualifiedName functionName,
- final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
- final List<String> parameterNames) {
-
- try {
- List<Function> functions = functionsMap.get(functionName);
- if (functions == null) {
- functions = provider.getFunctions(functionName);
- if (functions == null) {
- return null;
- } else {
- functionsMap.put(functionName, functions);
- }
- }
- final List<String> parameterNamesCopy =
- parameterNames == null ? Collections.<String> emptyList() : parameterNames;
- for (Function function : functions) {
- if (function.isBound()) {
- List<Parameter> providerParameters = function.getParameters();
- if (providerParameters == null || providerParameters.size() == 0) {
- throw new EdmException("No parameter specified for bound function: " + functionName);
- }
- final Parameter bindingParameter = providerParameters.get(0);
- if (bindingParameterTypeName.equals(bindingParameter.getType())
- && isBindingParameterCollection.booleanValue() == bindingParameter.isCollection()) {
-
- if (parameterNamesCopy.size() == providerParameters.size() - 1) {
- final List<String> providerParameterNames = new ArrayList<String>();
- for (int i = 1; i < providerParameters.size(); i++) {
- providerParameterNames.add(providerParameters.get(i).getName());
- }
- if (parameterNamesCopy.containsAll(providerParameterNames)) {
- return EdmFunctionImpl.getInstance(this, functionName, function);
- }
- }
- }
- }
- }
- return null;
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
-
- @Override
- protected Map<String, String> createAliasToNamespaceInfo() {
- final Map<String, String> aliasToNamespaceInfos = new HashMap<String, String>();
- try {
- final List<AliasInfo> aliasInfos = provider.getAliasInfos();
- if (aliasInfos != null) {
- for (AliasInfo info : aliasInfos) {
- aliasToNamespaceInfos.put(info.getAlias(), info.getNamespace());
- }
- }
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- return aliasToNamespaceInfos;
- }
-
- @Override
- protected EdmAction createUnboundAction(final FullQualifiedName actionName) {
- try {
- List<Action> actions = actionsMap.get(actionName);
- if (actions == null) {
- actions = provider.getActions(actionName);
- if (actions == null) {
- return null;
- } else {
- actionsMap.put(actionName, actions);
- }
- }
- // Search for first unbound action
- for (Action action : actions) {
- if (!action.isBound()) {
- return EdmActionImpl.getInstance(this, actionName, action);
- }
- }
- return null;
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
-
- @Override
- protected List<EdmFunction> createUnboundFunctions(final FullQualifiedName functionName) {
- List<EdmFunction> result = new ArrayList<EdmFunction>();
-
- try {
- List<Function> functions = functionsMap.get(functionName);
- if (functions == null) {
- functions = provider.getFunctions(functionName);
- if (functions != null) {
- functionsMap.put(functionName, functions);
- }
- }
- if (functions != null) {
- for (Function function : functions) {
- if (!function.isBound()) {
- result.add(EdmFunctionImpl.getInstance(this, functionName, function));
- }
- }
- }
- } catch (ODataException e) {
- throw new EdmException(e);
- }
-
- return result;
- }
-
- @Override
- protected EdmFunction createUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) {
- try {
- List<Function> functions = functionsMap.get(functionName);
- if (functions == null) {
- functions = provider.getFunctions(functionName);
- if (functions == null) {
- return null;
- } else {
- functionsMap.put(functionName, functions);
- }
- }
-
- final List<String> parameterNamesCopy =
- parameterNames == null ? Collections.<String> emptyList() : parameterNames;
- for (Function function : functions) {
- if (!function.isBound()) {
- List<Parameter> providerParameters = function.getParameters();
- if (providerParameters == null) {
- providerParameters = Collections.emptyList();
- }
- if (parameterNamesCopy.size() == providerParameters.size()) {
- final List<String> functionParameterNames = new ArrayList<String>();
- for (Parameter parameter : providerParameters) {
- functionParameterNames.add(parameter.getName());
- }
-
- if (parameterNamesCopy.containsAll(functionParameterNames)) {
- return EdmFunctionImpl.getInstance(this, functionName, function);
- }
- }
- }
- }
- return null;
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
-
- @Override
- protected Map<String, EdmSchema> createSchemas() {
- try {
- final Map<String, EdmSchema> _schemas = new LinkedHashMap<String, EdmSchema>();
- for (Schema schema : provider.getSchemas()) {
- _schemas.put(schema.getNamespace(), new EdmSchemaImpl(this, provider, schema));
- }
- return _schemas;
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
-
- @Override
- protected EdmTerm createTerm(final FullQualifiedName termName) {
- // TODO: implement
- return null;
- }
-
- @Override
- protected EdmAnnotations createAnnotationGroup(final FullQualifiedName targetName) {
- // TODO: implement
- return null;
- }
-
- @Override
- protected List<EdmAnnotation> createAnnotations(final FullQualifiedName annotatedName) {
- // TODO: implement
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReferentialConstraintImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReferentialConstraintImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReferentialConstraintImpl.java
deleted file mode 100644
index 7007740..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReferentialConstraintImpl.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import org.apache.olingo.commons.api.edm.EdmAnnotation;
-import org.apache.olingo.commons.api.edm.EdmTerm;
-import org.apache.olingo.commons.core.edm.AbstractEdmReferentialConstraint;
-
-import java.util.List;
-
-public class EdmReferentialConstraintImpl extends AbstractEdmReferentialConstraint {
-
- public EdmReferentialConstraintImpl(final String property, final String referencedProperty) {
- super(property, referencedProperty);
- }
-
- @Override
- public EdmAnnotation getAnnotation(final EdmTerm term) {
- // TODO: implement
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public List<EdmAnnotation> getAnnotations() {
- // TODO: implement
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImpl.java
deleted file mode 100644
index 95c2c83..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImpl.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.geo.SRID;
-import org.apache.olingo.commons.core.edm.AbstractEdmReturnType;
-import org.apache.olingo.server.api.edm.provider.ReturnType;
-
-public class EdmReturnTypeImpl extends AbstractEdmReturnType {
-
- private final ReturnType returnType;
-
- public EdmReturnTypeImpl(final Edm edm, final ReturnType returnType) {
- super(edm, returnType.getType());
- this.returnType = returnType;
- }
-
- @Override
- public boolean isCollection() {
- return returnType.isCollection();
- }
-
- @Override
- public Boolean isNullable() {
- return returnType.getNullable();
- }
-
- @Override
- public Integer getMaxLength() {
- return returnType.getMaxLength();
- }
-
- @Override
- public Integer getPrecision() {
- return returnType.getPrecision();
- }
-
- @Override
- public Integer getScale() {
- return returnType.getScale();
- }
-
- @Override
- public SRID getSrid() {
- return null; // TODO: provide implementation
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java
deleted file mode 100644
index b617db9..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.EdmAnnotation;
-import org.apache.olingo.commons.api.edm.EdmAnnotations;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmFunction;
-import org.apache.olingo.commons.api.edm.EdmTerm;
-import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.core.edm.AbstractEdmSchema;
-import org.apache.olingo.server.api.edm.provider.Action;
-import org.apache.olingo.server.api.edm.provider.ComplexType;
-import org.apache.olingo.server.api.edm.provider.EdmProvider;
-import org.apache.olingo.server.api.edm.provider.EntityType;
-import org.apache.olingo.server.api.edm.provider.EnumType;
-import org.apache.olingo.server.api.edm.provider.Function;
-import org.apache.olingo.server.api.edm.provider.Schema;
-import org.apache.olingo.server.api.edm.provider.TypeDefinition;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class EdmSchemaImpl extends AbstractEdmSchema {
-
- private final Schema schema;
-
- private final Edm edm;
-
- private final EdmProvider provider;
-
- public EdmSchemaImpl(final Edm edm, final EdmProvider provider, final Schema schema) {
- super(schema.getNamespace(), schema.getAlias());
- this.edm = edm;
- this.provider = provider;
- this.schema = schema;
- }
-
- @Override
- protected EdmEntityContainer createEntityContainer() {
- if (schema.getEntityContainer() != null) {
- FullQualifiedName containerFQN = new FullQualifiedName(namespace, schema.getEntityContainer().getName());
- return new EdmEntityContainerImpl(edm, provider, containerFQN, schema.getEntityContainer());
- }
- return null;
- }
-
- @Override
- protected List<EdmTypeDefinition> createTypeDefinitions() {
- final List<EdmTypeDefinition> typeDefinitions = new ArrayList<EdmTypeDefinition>();
- final List<TypeDefinition> providerTypeDefinitions = schema.getTypeDefinitions();
- if (providerTypeDefinitions != null) {
- for (TypeDefinition def : providerTypeDefinitions) {
- typeDefinitions.add(new EdmTypeDefinitionImpl(edm, new FullQualifiedName(namespace, def.getName()), def));
- }
- }
- return typeDefinitions;
- }
-
- @Override
- protected List<EdmEnumType> createEnumTypes() {
- final List<EdmEnumType> enumTypes = new ArrayList<EdmEnumType>();
- final List<EnumType> providerEnumTypes = schema.getEnumTypes();
- if (providerEnumTypes != null) {
- for (EnumType enumType : providerEnumTypes) {
- enumTypes.add(new EdmEnumTypeImpl(edm, new FullQualifiedName(namespace, enumType.getName()), enumType));
- }
- }
- return enumTypes;
- }
-
- @Override
- protected List<EdmEntityType> createEntityTypes() {
- final List<EdmEntityType> entityTypes = new ArrayList<EdmEntityType>();
- final List<EntityType> providerEntityTypes = schema.getEntityTypes();
- if (providerEntityTypes != null) {
- for (EntityType entityType : providerEntityTypes) {
- entityTypes.add(EdmEntityTypeImpl.getInstance(edm, new FullQualifiedName(namespace, entityType.getName()),
- entityType));
- }
- }
- return entityTypes;
- }
-
- @Override
- protected List<EdmComplexType> createComplexTypes() {
- final List<EdmComplexType> complexTypes = new ArrayList<EdmComplexType>();
- final List<ComplexType> providerComplexTypes = schema.getComplexTypes();
- if (providerComplexTypes != null) {
- for (ComplexType complexType : providerComplexTypes) {
- complexTypes.add(EdmComplexTypeImpl.getInstance(edm, new FullQualifiedName(namespace, complexType.getName()),
- complexType));
- }
- }
- return complexTypes;
- }
-
- @Override
- protected List<EdmAction> createActions() {
- final List<EdmAction> actions = new ArrayList<EdmAction>();
- final List<Action> providerActions = schema.getActions();
- if (providerActions != null) {
- for (Action action : providerActions) {
- actions.add(EdmActionImpl.getInstance(edm, new FullQualifiedName(namespace, action.getName()), action));
- }
- }
- return actions;
- }
-
- @Override
- protected List<EdmFunction> createFunctions() {
- final List<EdmFunction> functions = new ArrayList<EdmFunction>();
- final List<Function> providerFunctions = schema.getFunctions();
- if (providerFunctions != null) {
- for (Function function : providerFunctions) {
- functions.add(EdmFunctionImpl.getInstance(edm, new FullQualifiedName(namespace, function.getName()), function));
- }
- }
- return functions;
- }
-
- @Override
- protected List<EdmTerm> createTerms() {
- // TODO: implement
- return Collections.emptyList();
- }
-
- @Override
- protected List<EdmAnnotations> createAnnotationGroups() {
- // TODO: implement
- return Collections.emptyList();
- }
-
- @Override
- protected List<EdmAnnotation> createAnnotations() {
- // TODO: implement
- return Collections.emptyList();
- }
-
- @Override
- public EdmAnnotation getAnnotation(final EdmTerm term) {
- // TODO: implement
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public List<EdmAnnotation> getAnnotations() {
- // TODO: implement
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImpl.java
deleted file mode 100644
index 41efc54..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImpl.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmAnnotation;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmSingleton;
-import org.apache.olingo.commons.api.edm.EdmTerm;
-import org.apache.olingo.server.api.edm.provider.Singleton;
-
-import java.util.List;
-
-public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSingleton {
-
- public EdmSingletonImpl(final Edm edm, final EdmEntityContainer container, final Singleton singleton) {
- super(edm, container, singleton);
- }
-
- @Override
- 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
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmStructuredTypeHelperImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmStructuredTypeHelperImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmStructuredTypeHelperImpl.java
deleted file mode 100644
index cc4c7f1..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmStructuredTypeHelperImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper;
-import org.apache.olingo.server.api.edm.provider.NavigationProperty;
-import org.apache.olingo.server.api.edm.provider.Property;
-import org.apache.olingo.server.api.edm.provider.StructuredType;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
-
- private final Edm edm;
-
- private final FullQualifiedName structuredTypeName;
-
- private final StructuredType structuredType;
-
- private Map<String, EdmProperty> properties;
-
- private Map<String, EdmNavigationProperty> navigationProperties;
-
- public EdmStructuredTypeHelperImpl(
- final Edm edm, final FullQualifiedName structuredTypeName, final StructuredType structuredType) {
-
- this.edm = edm;
- this.structuredTypeName = structuredTypeName;
- this.structuredType = structuredType;
- }
-
- @Override
- public Map<String, EdmProperty> getProperties() {
- if (properties == null) {
- properties = new LinkedHashMap<String, EdmProperty>();
- if (structuredType.getProperties() != null) {
- for (Property property : structuredType.getProperties()) {
- properties.put(property.getName(), new EdmPropertyImpl(edm, structuredTypeName, property));
- }
- }
- }
- return properties;
- }
-
- @Override
- public Map<String, EdmNavigationProperty> getNavigationProperties() {
- if (navigationProperties == null) {
- navigationProperties = new LinkedHashMap<String, EdmNavigationProperty>();
- if (structuredType.getNavigationProperties() != null) {
- for (NavigationProperty navigationProperty : structuredType.getNavigationProperties()) {
- navigationProperties.put(navigationProperty.getName(),
- new EdmNavigationPropertyImpl(edm, structuredTypeName, navigationProperty));
- }
- }
- }
- return navigationProperties;
- }
-
- @Override
- public boolean isOpenType() {
- return structuredType.isOpenType();
- }
-
- @Override
- public boolean isAbstract() {
- return structuredType.isAbstract();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java
deleted file mode 100644
index 0f8c808..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * 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.EdmException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.EdmTerm;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.geo.SRID;
-import org.apache.olingo.commons.core.edm.AbstractEdmTypeDefinition;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-import org.apache.olingo.server.api.edm.provider.TypeDefinition;
-
-public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition {
-
- private TypeDefinition typeDefinition;
-
- private EdmPrimitiveType edmPrimitiveTypeInstance;
-
- public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName,
- final TypeDefinition typeDefinition) {
-
- super(edm, typeDefinitionName);
- this.typeDefinition = typeDefinition;
- }
-
- @Override
- public EdmPrimitiveType getUnderlyingType() {
- if (edmPrimitiveTypeInstance == null) {
- try {
- edmPrimitiveTypeInstance = EdmPrimitiveTypeFactory.getInstance(
- EdmPrimitiveTypeKind.valueOf(typeDefinition.getUnderlyingType().getName()));
- } catch (IllegalArgumentException e) {
- throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e);
- }
- }
- return edmPrimitiveTypeInstance;
- }
-
- @Override
- public Integer getMaxLength() {
- return typeDefinition.getMaxLength();
- }
-
- @Override
- public Integer getPrecision() {
- return typeDefinition.getPrecision();
- }
-
- @Override
- public Integer getScale() {
- return typeDefinition.getScale();
- }
-
- @Override
- public SRID getSrid() {
- return null; // TODO: provide implementation
- }
-
- @Override
- public Boolean isUnicode() {
- return typeDefinition.getIsUnicode();
- }
-
- @Override
- public EdmAnnotation getAnnotation(final EdmTerm term) {
- // TODO: implement
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public List<EdmAnnotation> getAnnotations() {
- // TODO: implement
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java
deleted file mode 100644
index a8d7898..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.serializer;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.http.HttpContentType;
-import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.batch.exception.BatchSerializerException;
-import org.apache.olingo.server.api.batch.exception.BatchSerializerException.MessageKeys;
-import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart;
-import org.apache.olingo.server.core.deserializer.batch.BatchParserCommon;
-
-public class BatchResponseSerializer {
- private static final int BUFFER_SIZE = 4096;
- private static final String DOUBLE_DASH = "--";
- private static final String COLON = ":";
- private static final String SP = " ";
- private static final String CRLF = "\r\n";
-
- public InputStream serialize(final List<ODataResponsePart> responses, final String boundary)
- throws BatchSerializerException {
- StringBuilder builder = createBody(responses, boundary);
-
- return new ByteArrayInputStream(builder.toString().getBytes());
- }
-
- private StringBuilder createBody(final List<ODataResponsePart> batchResponses, final String boundary)
- throws BatchSerializerException {
- final StringBuilder builder = new StringBuilder();
-
- for (final ODataResponsePart part : batchResponses) {
- builder.append(getDashBoundary(boundary));
-
- if (part.isChangeSet()) {
- appendChangeSet(part, builder);
- } else {
- appendBodyPart(part.getResponses().get(0), builder, false);
- }
- }
- builder.append(getCloseDelimiter(boundary));
-
- return builder;
- }
-
- private void appendChangeSet(ODataResponsePart part, StringBuilder builder) throws BatchSerializerException {
- final String changeSetBoundary = generateBoundary("changeset");
-
- appendChangeSetHeader(builder, changeSetBoundary);
- builder.append(CRLF);
-
- for (final ODataResponse response : part.getResponses()) {
- builder.append(getDashBoundary(changeSetBoundary));
- appendBodyPart(response, builder, true);
- }
-
- builder.append(getCloseDelimiter(changeSetBoundary));
- }
-
- private void appendBodyPart(ODataResponse response, StringBuilder builder, boolean isChangeSet)
- throws BatchSerializerException {
- byte[] body = getBody(response);
-
- appendBodyPartHeader(response, builder, isChangeSet);
- builder.append(CRLF);
-
- appendStatusLine(response, builder);
- appendResponseHeader(response, body.length, builder);
- builder.append(CRLF);
-
- builder.append(new String(body));
- builder.append(CRLF);
- }
-
- private byte[] getBody(final ODataResponse response) {
- final InputStream content = response.getContent();
- final ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- if (content != null) {
- byte[] buffer = new byte[BUFFER_SIZE];
- int n;
-
- try {
- while ((n = content.read(buffer, 0, buffer.length)) != -1) {
- out.write(buffer, 0, n);
- }
- out.flush();
- } catch (IOException e) {
- throw new ODataRuntimeException(e);
- }
-
- return out.toByteArray();
- } else {
- return new byte[0];
- }
- }
-
- private void appendChangeSetHeader(StringBuilder builder, final String changeSetBoundary) {
- appendHeader(HttpHeader.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED.toString() + "; boundary="
- + changeSetBoundary, builder);
- }
-
- private void appendHeader(String name, String value, StringBuilder builder) {
- builder.append(name)
- .append(COLON)
- .append(SP)
- .append(value)
- .append(CRLF);
- }
-
- private void appendStatusLine(ODataResponse response, StringBuilder builder) {
- builder.append("HTTP/1.1")
- .append(SP)
- .append("" + response.getStatusCode())
- .append(SP)
- .append(HttpStatusCode.fromStatusCode(response.getStatusCode()).toString())
- .append(CRLF);
- }
-
- private void appendResponseHeader(ODataResponse response, int contentLength, StringBuilder builder) {
- final Map<String, String> header = response.getHeaders();
-
- for (final String key : header.keySet()) {
- // Requests do never has a content id header
- if (!key.equalsIgnoreCase(BatchParserCommon.HTTP_CONTENT_ID)) {
- appendHeader(key, header.get(key), builder);
- }
- }
-
- appendHeader(HttpHeader.CONTENT_LENGTH, "" + contentLength, builder);
- }
-
- private void appendBodyPartHeader(ODataResponse response, StringBuilder builder, boolean isChangeSet)
- throws BatchSerializerException {
- appendHeader(HttpHeader.CONTENT_TYPE, HttpContentType.APPLICATION_HTTP, builder);
- appendHeader(BatchParserCommon.HTTP_CONTENT_TRANSFER_ENCODING, BatchParserCommon.BINARY_ENCODING, builder);
-
- if (isChangeSet) {
- if (response.getHeaders().get(BatchParserCommon.HTTP_CONTENT_ID) != null) {
- appendHeader(BatchParserCommon.HTTP_CONTENT_ID, response.getHeaders().get(BatchParserCommon.HTTP_CONTENT_ID),
- builder);
- } else {
- throw new BatchSerializerException("Missing content id", MessageKeys.MISSING_CONTENT_ID);
- }
- }
- }
-
- private String getDashBoundary(String boundary) {
- return DOUBLE_DASH + boundary + CRLF;
- }
-
- private String getCloseDelimiter(final String boundary) {
- return DOUBLE_DASH + boundary + DOUBLE_DASH + CRLF;
- }
-
- private String generateBoundary(final String value) {
- return value + "_" + UUID.randomUUID().toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerImpl.java
----------------------------------------------------------------------
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
deleted file mode 100644
index 004b23a..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerImpl.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.serializer;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.server.api.batch.exception.BatchSerializerException;
-import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart;
-import org.apache.olingo.server.api.serializer.FixedFormatSerializer;
-import org.apache.olingo.server.api.serializer.PrimitiveValueSerializerOptions;
-import org.apache.olingo.server.api.serializer.SerializerException;
-
-public class FixedFormatSerializerImpl implements FixedFormatSerializer {
-
- @Override
- public InputStream binary(final byte[] binary) throws SerializerException {
- return new ByteArrayInputStream(binary);
- }
-
- @Override
- public InputStream count(final Integer count) throws SerializerException {
- return new ByteArrayInputStream(count.toString().getBytes());
- }
-
- @Override
- public InputStream primitiveValue(final EdmPrimitiveType type, final Object value,
- final PrimitiveValueSerializerOptions options) throws SerializerException {
- try {
- final String result = type.valueToString(value,
- options.isNullable(), options.getMaxLength(),
- options.getPrecision(), options.getScale(), options.isUnicode());
- return new ByteArrayInputStream(result.getBytes("UTF-8"));
- } catch (final EdmPrimitiveTypeException e) {
- throw new SerializerException("Error in primitive-value formatting.", e,
- SerializerException.MessageKeys.WRONG_PRIMITIVE_VALUE,
- type.getFullQualifiedName().getFullQualifiedNameAsString(), value.toString());
- } catch (final UnsupportedEncodingException e) {
- throw new SerializerException("Encoding exception.", e, SerializerException.MessageKeys.IO_EXCEPTION);
- }
- }
-
- // TODO: Signature
- @Override
- public InputStream batchResponse(final List<ODataResponsePart> batchResponses, final String boundary)
- throws BatchSerializerException {
- final BatchResponseSerializer serializer = new BatchResponseSerializer();
-
- return serializer.serialize(batchResponses, boundary);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java
deleted file mode 100644
index 14381bb..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.serializer.json;
-
-import java.io.IOException;
-
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.domain.ODataErrorDetail;
-import org.apache.olingo.server.api.serializer.SerializerException;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-
-public class ODataErrorSerializer {
-
- public void writeErrorDocument(JsonGenerator json, final ODataError error)
- throws IOException, SerializerException {
- if (error == null) {
- throw new SerializerException("ODataError object MUST NOT be null!",
- SerializerException.MessageKeys.NULL_INPUT);
- }
- json.writeStartObject();
- json.writeFieldName(Constants.JSON_ERROR);
-
- json.writeStartObject();
- writeODataError(json, error.getCode(), error.getMessage(), error.getTarget());
-
- if (error.getDetails() != null) {
- json.writeArrayFieldStart(Constants.ERROR_DETAILS);
- for (ODataErrorDetail detail : error.getDetails()) {
- json.writeStartObject();
- writeODataError(json, detail.getCode(), detail.getMessage(), detail.getTarget());
- json.writeEndObject();
- }
- json.writeEndArray();
- }
-
- json.writeEndObject();
- json.writeEndObject();
- }
-
- private void writeODataError(JsonGenerator json, String code, String message, String target) throws IOException {
- json.writeFieldName(Constants.ERROR_CODE);
- if (code == null) {
- json.writeNull();
- } else {
- json.writeString(code);
- }
-
- json.writeFieldName(Constants.ERROR_MESSAGE);
- if (message == null) {
- json.writeNull();
- } else {
- json.writeString(message);
- }
-
- if (target != null) {
- json.writeStringField(Constants.ERROR_TARGET, target);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
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
deleted file mode 100644
index 6067312..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.serializer.json;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.LinkedComplexValue;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.EdmStructuredType;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-import org.apache.olingo.server.api.ODataServerError;
-import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
-import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
-import org.apache.olingo.server.api.serializer.ODataSerializer;
-import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
-import org.apache.olingo.server.api.serializer.SerializerException;
-import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
-import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
-import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
-import org.apache.olingo.server.api.uri.queryoption.SelectOption;
-import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
-import org.apache.olingo.server.core.serializer.utils.ContextURLBuilder;
-import org.apache.olingo.server.core.serializer.utils.ExpandSelectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
-
-public class ODataJsonSerializer implements ODataSerializer {
-
- private static final Logger log = LoggerFactory.getLogger(ODataJsonSerializer.class);
-
- private final ODataFormat format;
-
- public ODataJsonSerializer(final ODataFormat format) {
- this.format = format;
- }
-
- @Override
- public InputStream serviceDocument(final Edm edm, final String serviceRoot) throws SerializerException {
- CircleStreamBuffer buffer;
- JsonGenerator gen = null;
-
- // TODO: move stream initialization into separate method
- try {
- buffer = new CircleStreamBuffer();
- gen = new JsonFactory().createGenerator(buffer.getOutputStream())
- .setPrettyPrinter(new DefaultPrettyPrinter());
-
- new ServiceDocumentJsonSerializer(edm, serviceRoot).writeServiceDocument(gen);
-
- gen.close();
-
- // TODO: Check correct stream handling
- // writer.flush();
- // buffer.closeWrite();
-
- return buffer.getInputStream();
-
- } catch (final IOException e) {
- log.error(e.getMessage(), e);
- throw new SerializerException("An I/O exception occurred.", e,
- SerializerException.MessageKeys.IO_EXCEPTION);
- } finally {
- if (gen != null) {
- try {
- gen.close();
- } catch (IOException e) {
- throw new SerializerException("An I/O exception occurred.", e,
- SerializerException.MessageKeys.IO_EXCEPTION);
- }
- }
- }
- }
-
- @Override
- public InputStream metadataDocument(final ServiceMetadata serviceMetadata) throws SerializerException {
- throw new SerializerException("Metadata in JSON format not supported!",
- SerializerException.MessageKeys.JSON_METADATA);
- }
-
- @Override
- public InputStream error(final ODataServerError error) throws SerializerException {
- CircleStreamBuffer buffer = new CircleStreamBuffer();
- try {
- JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
- new ODataErrorSerializer().writeErrorDocument(json, error);
- json.close();
- } catch (final IOException e) {
- throw new SerializerException("An I/O exception occurred.", e,
- SerializerException.MessageKeys.IO_EXCEPTION);
- }
- return buffer.getInputStream();
- }
-
- @Override
- public InputStream entityCollection(final EdmEntityType entityType, final EntitySet entitySet,
- final EntityCollectionSerializerOptions options) throws SerializerException {
- CircleStreamBuffer buffer = new CircleStreamBuffer();
- try {
- JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
- json.writeStartObject();
-
- final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
- if (contextURL != null) {
- json.writeStringField(Constants.JSON_CONTEXT,
- ContextURLBuilder.create(contextURL).toASCIIString());
- }
-
- if (options != null && options.getCount() != null && options.getCount().getValue()
- && entitySet.getCount() != null) {
- json.writeNumberField(Constants.JSON_COUNT, entitySet.getCount());
- }
- json.writeFieldName(Constants.VALUE);
- writeEntitySet(entityType, entitySet,
- options == null ? null : options.getExpand(), options == null ? null : options.getSelect(), json);
- if (entitySet.getNext() != null) {
- json.writeStringField(Constants.JSON_NEXT_LINK, entitySet.getNext().toASCIIString());
- }
- json.close();
- } catch (final IOException e) {
- throw new SerializerException("An I/O exception occurred.", e,
- SerializerException.MessageKeys.IO_EXCEPTION);
- }
- return buffer.getInputStream();
- }
-
- @Override
- public InputStream entity(final EdmEntityType entityType, final Entity entity,
- final EntitySerializerOptions options) throws SerializerException {
- final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
- CircleStreamBuffer buffer = new CircleStreamBuffer();
- try {
- JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
- writeEntity(entityType, entity, contextURL,
- options == null ? null : options.getExpand(), options == null ? null : options.getSelect(), json);
- json.close();
- } catch (final IOException e) {
- throw new SerializerException("An I/O exception occurred.", e,
- SerializerException.MessageKeys.IO_EXCEPTION);
- }
- return buffer.getInputStream();
- }
-
- private ContextURL checkContextURL(final ContextURL contextURL) throws SerializerException {
- if (format == ODataFormat.JSON_NO_METADATA) {
- return null;
- } else if (contextURL == null) {
- throw new SerializerException("ContextURL null!", SerializerException.MessageKeys.NO_CONTEXT_URL);
- }
- return contextURL;
- }
-
- protected void writeEntitySet(final EdmEntityType entityType, final EntitySet entitySet,
- final ExpandOption expand, final SelectOption select, final JsonGenerator json)
- throws IOException, SerializerException {
- json.writeStartArray();
- for (final Entity entity : entitySet.getEntities()) {
- writeEntity(entityType, entity, null, expand, select, json);
- }
- json.writeEndArray();
- }
-
- protected void writeEntity(final EdmEntityType entityType, final Entity entity, final ContextURL contextURL,
- final ExpandOption expand, final SelectOption select, final JsonGenerator json)
- throws IOException, SerializerException {
- json.writeStartObject();
- if (format != ODataFormat.JSON_NO_METADATA) {
- if (contextURL != null) {
- json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString());
- }
- if (entity.getETag() != null) {
- json.writeStringField(Constants.JSON_ETAG, entity.getETag());
- }
- if (entityType.hasStream()) {
- if (entity.getMediaETag() != null) {
- json.writeStringField(Constants.JSON_MEDIA_ETAG, entity.getMediaETag());
- }
- if (entity.getMediaContentType() != null) {
- json.writeStringField(Constants.JSON_MEDIA_CONTENT_TYPE, entity.getMediaContentType());
- }
- }
- }
- writeProperties(entityType, entity.getProperties(), select, json);
- writeNavigationProperties(entityType, entity, expand, json);
- json.writeEndObject();
- }
-
- protected void writeProperties(final EdmStructuredType type, final List<Property> properties,
- final SelectOption select, JsonGenerator json) throws IOException, SerializerException {
- final boolean all = ExpandSelectHelper.isAll(select);
- final Set<String> selected = all ? null :
- ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
- for (final String propertyName : type.getPropertyNames()) {
- if (all || selected.contains(propertyName)) {
- final EdmProperty edmProperty = type.getStructuralProperty(propertyName);
- final Property property = findProperty(propertyName, properties);
- final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null :
- ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName);
- writeProperty(edmProperty, property, selectedPaths, json);
- }
- }
- }
-
- protected void writeNavigationProperties(final EdmStructuredType type, final Linked linked,
- final ExpandOption expand, final JsonGenerator json) throws SerializerException, IOException {
- if (ExpandSelectHelper.hasExpand(expand)) {
- final boolean expandAll = ExpandSelectHelper.isExpandAll(expand);
- final Set<String> expanded = expandAll ? null :
- ExpandSelectHelper.getExpandedPropertyNames(expand.getExpandItems());
- for (final String propertyName : type.getNavigationPropertyNames()) {
- if (expandAll || expanded.contains(propertyName)) {
- final EdmNavigationProperty property = type.getNavigationProperty(propertyName);
- final Link navigationLink = linked.getNavigationLink(property.getName());
- final ExpandItem innerOptions = expandAll ? null :
- ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName);
- if (innerOptions != null && (innerOptions.isRef() || innerOptions.getLevelsOption() != null)) {
- throw new SerializerException("Expand options $ref and $levels are not supported.",
- SerializerException.MessageKeys.NOT_IMPLEMENTED);
- }
- writeExpandedNavigationProperty(property, navigationLink,
- innerOptions == null ? null : innerOptions.getExpandOption(),
- innerOptions == null ? null : innerOptions.getSelectOption(),
- json);
- }
- }
- }
- }
-
- protected void writeExpandedNavigationProperty(final EdmNavigationProperty property, final Link navigationLink,
- final ExpandOption innerExpand, final SelectOption innerSelect, JsonGenerator json)
- throws IOException, SerializerException {
- json.writeFieldName(property.getName());
- if (property.isCollection()) {
- if (navigationLink == null || navigationLink.getInlineEntitySet() == null) {
- json.writeStartArray();
- json.writeEndArray();
- } else {
- writeEntitySet(property.getType(), navigationLink.getInlineEntitySet(), innerExpand, innerSelect, json);
- }
- } else {
- if (navigationLink == null || navigationLink.getInlineEntity() == null) {
- json.writeNull();
- } else {
- writeEntity(property.getType(), navigationLink.getInlineEntity(), null, innerExpand, innerSelect, json);
- }
- }
- }
-
- protected void writeProperty(final EdmProperty edmProperty, final Property property,
- final Set<List<String>> selectedPaths, final JsonGenerator json) throws IOException, SerializerException {
- json.writeFieldName(edmProperty.getName());
- if (property == null || property.isNull()) {
- if (edmProperty.isNullable() == Boolean.FALSE) {
- throw new SerializerException("Non-nullable property not present!",
- SerializerException.MessageKeys.MISSING_PROPERTY, edmProperty.getName());
- } else {
- json.writeNull();
- }
- } else {
- writePropertyValue(edmProperty, property, selectedPaths, json);
- }
- }
-
- private void writePropertyValue(final EdmProperty edmProperty,
- final Property property, final Set<List<String>> selectedPaths,
- final JsonGenerator json) throws IOException, SerializerException {
- try {
- if (edmProperty.isPrimitive()) {
- if (edmProperty.isCollection()) {
- writePrimitiveCollection((EdmPrimitiveType) edmProperty.getType(), property,
- edmProperty.isNullable(), edmProperty.getMaxLength(),
- edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(),
- json);
- } else {
- writePrimitive((EdmPrimitiveType) edmProperty.getType(), property,
- edmProperty.isNullable(), edmProperty.getMaxLength(),
- edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(),
- json);
- }
- } else if (edmProperty.isCollection()) {
- writeComplexCollection((EdmComplexType) edmProperty.getType(), property, selectedPaths, json);
- } else if (property.isLinkedComplex()) {
- writeComplexValue((EdmComplexType) edmProperty.getType(), property.asLinkedComplex().getValue(),
- selectedPaths, json);
- } else if (property.isComplex()) {
- writeComplexValue((EdmComplexType) edmProperty.getType(), property.asComplex(), selectedPaths, json);
- } else {
- throw new SerializerException("Property type not yet supported!",
- SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
- }
- } catch (final EdmPrimitiveTypeException e) {
- throw new SerializerException("Wrong value for property!", e,
- SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
- edmProperty.getName(), property.getValue().toString());
- }
- }
-
- private void writePrimitiveCollection(final EdmPrimitiveType type, final Property property,
- final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
- final Boolean isUnicode,
- JsonGenerator json) throws IOException, EdmPrimitiveTypeException, SerializerException {
- json.writeStartArray();
- for (Object value : property.asCollection()) {
- switch (property.getValueType()) {
- case COLLECTION_PRIMITIVE:
- writePrimitiveValue(type, value, isNullable, maxLength, precision, scale, isUnicode, json);
- break;
- case COLLECTION_GEOSPATIAL:
- throw new SerializerException("Property type not yet supported!",
- SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName());
- case COLLECTION_ENUM:
- json.writeString(value.toString());
- break;
- default:
- throw new SerializerException("Property type not yet supported!",
- SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName());
- }
- }
- json.writeEndArray();
- }
-
- private void writeComplexCollection(final EdmComplexType type, final Property property,
- final Set<List<String>> selectedPaths, JsonGenerator json)
- throws IOException, EdmPrimitiveTypeException, SerializerException {
- json.writeStartArray();
- for (Object value : property.asCollection()) {
- switch (property.getValueType()) {
- case COLLECTION_LINKED_COMPLEX:
- writeComplexValue(type, ((LinkedComplexValue) value).getValue(), selectedPaths, json);
- break;
- case COLLECTION_COMPLEX:
- writeComplexValue(type, ((Property) value).asComplex(), selectedPaths, json);
- break;
- default:
- throw new SerializerException("Property type not yet supported!",
- SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName());
- }
- }
- json.writeEndArray();
- }
-
- private void writePrimitive(final EdmPrimitiveType type, final Property property,
- final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
- final Boolean isUnicode, JsonGenerator json)
- throws EdmPrimitiveTypeException, IOException, SerializerException {
- if (property.isPrimitive()) {
- writePrimitiveValue(type, property.asPrimitive(),
- isNullable, maxLength, precision, scale, isUnicode, json);
- } else if (property.isGeospatial()) {
- throw new SerializerException("Property type not yet supported!",
- SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName());
- } else if (property.isEnum()) {
- writePrimitiveValue(type, property.asEnum(),
- isNullable, maxLength, precision, scale, isUnicode, json);
- } else {
- throw new SerializerException("Inconsistent property type!",
- SerializerException.MessageKeys.INCONSISTENT_PROPERTY_TYPE, property.getName());
- }
- }
-
- protected void writePrimitiveValue(final EdmPrimitiveType type, final Object primitiveValue,
- final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
- final Boolean isUnicode,
- final JsonGenerator json) throws EdmPrimitiveTypeException, IOException {
- final String value = type.valueToString(primitiveValue,
- isNullable, maxLength, precision, scale, isUnicode);
- if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean)) {
- json.writeBoolean(Boolean.parseBoolean(value));
- } else if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Byte)
- || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Decimal)
- || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Double)
- || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int16)
- || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32)
- || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int64)
- || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.SByte)
- || type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Single)) {
- json.writeNumber(value);
- } else {
- json.writeString(value);
- }
- }
-
- protected void writeComplexValue(final EdmComplexType type, final List<Property> properties,
- final Set<List<String>> selectedPaths, JsonGenerator json)
- throws IOException, EdmPrimitiveTypeException, SerializerException {
- json.writeStartObject();
- for (final String propertyName : type.getPropertyNames()) {
- final Property property = findProperty(propertyName, properties);
- if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths, propertyName)) {
- writeProperty((EdmProperty) type.getProperty(propertyName), property,
- selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths, propertyName),
- json);
- }
- }
- json.writeEndObject();
- }
-
- private Property findProperty(final String propertyName, final List<Property> properties) {
- for (final Property property : properties) {
- if (propertyName.equals(property.getName())) {
- return property;
- }
- }
- return null;
- }
-
- @Override
- public InputStream primitive(final EdmPrimitiveType type, final Property property,
- final PrimitiveSerializerOptions options) throws SerializerException {
- final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
- CircleStreamBuffer buffer = new CircleStreamBuffer();
- try {
- JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
- json.writeStartObject();
- if (contextURL != null) {
- json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString());
- }
- if (property.isNull()) {
- throw new SerializerException("Property value can not be null.", SerializerException.MessageKeys.NULL_INPUT);
- } else {
- json.writeFieldName(Constants.VALUE);
- writePrimitive(type, property,
- options.isNullable(), options.getMaxLength(), options.getPrecision(), options.getScale(),
- options.isUnicode(),
- json);
- }
- json.writeEndObject();
- json.close();
- } catch (final IOException e) {
- throw new SerializerException("An I/O exception occurred.", e,
- SerializerException.MessageKeys.IO_EXCEPTION);
- } catch (final EdmPrimitiveTypeException e) {
- throw new SerializerException("Wrong value for property!", e,
- SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
- property.getName(), property.getValue().toString());
- }
- return buffer.getInputStream();
- }
-
- @Override
- public InputStream complex(final EdmComplexType type, final Property property,
- final ComplexSerializerOptions options) throws SerializerException {
- final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
- CircleStreamBuffer buffer = new CircleStreamBuffer();
- try {
- JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
- json.writeStartObject();
- if (contextURL != null) {
- json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString());
- }
- final List<Property> values = property.isNull() ? Collections.<Property> emptyList() :
- property.isComplex() ? property.asComplex() : property.asLinkedComplex().getValue();
- writeProperties(type, values, options == null ? null : options.getSelect(), json);
- if (!property.isNull() && property.isLinkedComplex()) {
- writeNavigationProperties(type, property.asLinkedComplex(),
- options == null ? null : options.getExpand(), json);
- }
- json.writeEndObject();
- json.close();
- } catch (final IOException e) {
- throw new SerializerException("An I/O exception occurred.", e,
- SerializerException.MessageKeys.IO_EXCEPTION);
- }
- return buffer.getInputStream();
- }
-
- @Override
- public InputStream primitiveCollection(final EdmPrimitiveType type, final Property property,
- final PrimitiveSerializerOptions options) throws SerializerException {
- final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
- CircleStreamBuffer buffer = new CircleStreamBuffer();
- try {
- JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
- json.writeStartObject();
- if (contextURL != null) {
- json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString());
- }
- json.writeFieldName(Constants.VALUE);
- writePrimitiveCollection(type, property,
- options.isNullable(), options.getMaxLength(), options.getPrecision(), options.getScale(),
- options.isUnicode(),
- json);
- json.writeEndObject();
- json.close();
- } catch (final IOException e) {
- throw new SerializerException("An I/O exception occurred.", e,
- SerializerException.MessageKeys.IO_EXCEPTION);
- } catch (final EdmPrimitiveTypeException e) {
- throw new SerializerException("Wrong value for property!", e,
- SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
- property.getName(), property.getValue().toString());
- }
- return buffer.getInputStream();
- }
-
- @Override
- public InputStream complexCollection(final EdmComplexType type, final Property property,
- final ComplexSerializerOptions options) throws SerializerException {
- final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
- CircleStreamBuffer buffer = new CircleStreamBuffer();
- try {
- JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
- json.writeStartObject();
- if (contextURL != null) {
- json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString());
- }
- json.writeFieldName(Constants.VALUE);
- writeComplexCollection(type, property, null, json);
- json.writeEndObject();
- json.close();
- } catch (final IOException e) {
- throw new SerializerException("An I/O exception occurred.", e,
- SerializerException.MessageKeys.IO_EXCEPTION);
- } catch (final EdmPrimitiveTypeException e) {
- throw new SerializerException("Wrong value for property!", e,
- SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
- property.getName(), property.getValue().toString());
- }
- return buffer.getInputStream();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java
deleted file mode 100644
index e2f7261..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- * 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
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.serializer.json;
-
-import java.io.IOException;
-
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-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 com.fasterxml.jackson.core.JsonGenerator;
-
-public class ServiceDocumentJsonSerializer {
- public static final String KIND = "kind";
-
- public static final String FUNCTION_IMPORT = "FunctionImport";
- public static final String SINGLETON = "Singleton";
- public static final String SERVICE_DOCUMENT = "ServiceDocument";
-
- private final Edm edm;
- private final String serviceRoot;
-
- public ServiceDocumentJsonSerializer(final Edm edm, final String serviceRoot) {
- this.edm = edm;
- this.serviceRoot = serviceRoot;
- }
-
- public void writeServiceDocument(final JsonGenerator gen) throws IOException {
- gen.writeStartObject();
-
- Object metadataUri;
-
- if (serviceRoot == null) {
- metadataUri = Constants.METADATA;
- } else {
- if (serviceRoot.endsWith("/")) {
- metadataUri = serviceRoot + Constants.METADATA;
- } else {
- metadataUri = serviceRoot + "/" + Constants.METADATA;
- }
- }
-
- gen.writeObjectField(Constants.JSON_CONTEXT, metadataUri);
- gen.writeArrayFieldStart(Constants.VALUE);
-
- writeEntitySets(gen, edm);
- writeFunctionImports(gen, edm);
- writeSingletons(gen, edm);
- }
-
- private void writeEntitySets(final JsonGenerator gen, final Edm edm) throws IOException {
- EdmEntityContainer container = edm.getEntityContainer(null);
-
- for (EdmEntitySet edmEntitySet : container.getEntitySets()) {
- if (edmEntitySet.isIncludeInServiceDocument()) {
- gen.writeStartObject();
- gen.writeObjectField(Constants.JSON_NAME, edmEntitySet.getName());
- gen.writeObjectField(Constants.JSON_URL, edmEntitySet.getName());
- gen.writeEndObject();
- }
- }
- }
-
- private void writeFunctionImports(final JsonGenerator gen, final Edm edm) throws IOException {
- EdmEntityContainer container = edm.getEntityContainer(null);
-
- for (EdmFunctionImport edmFunctionImport : container.getFunctionImports()) {
- if (edmFunctionImport.isIncludeInServiceDocument()) {
- gen.writeStartObject();
- gen.writeObjectField(Constants.JSON_NAME, edmFunctionImport.getName());
- gen.writeObjectField(Constants.JSON_URL, edmFunctionImport.getName());
- gen.writeObjectField(KIND, FUNCTION_IMPORT);
- gen.writeEndObject();
- }
- }
- }
-
- private void writeSingletons(final JsonGenerator gen, final Edm edm) throws IOException {
- EdmEntityContainer container = edm.getEntityContainer(null);
-
- for (EdmSingleton edmSingleton : container.getSingletons()) {
- gen.writeStartObject();
- gen.writeObjectField(Constants.JSON_NAME, edmSingleton.getName());
- gen.writeObjectField(Constants.JSON_URL, edmSingleton.getName());
- gen.writeObjectField(KIND, SINGLETON);
- gen.writeEndObject();
- }
- }
-}