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 2013/09/24 14:42:39 UTC
[12/51] [partial] Refactored project structure
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/util/XmlMetadataConstants.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/util/XmlMetadataConstants.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/util/XmlMetadataConstants.java
deleted file mode 100644
index 52adf2d..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/util/XmlMetadataConstants.java
+++ /dev/null
@@ -1,96 +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.odata2.core.ep.util;
-
-/**
- * String constants for deserialization and serialization of metadata document.
- *
- */
-public class XmlMetadataConstants {
-
- public static final String EDM_DATA_SERVICES = "DataServices";
- public static final String EDM_DATA_SERVICE_VERSION = "DataServiceVersion";
- public static final String EDM_SCHEMA = "Schema";
- public static final String EDM_SCHEMA_NAMESPACE = "Namespace";
- public static final String EDM_SCHEMA_ALIAS = "Alias";
- public static final String EDM_ENTITY_TYPE = "EntityType";
- public static final String EDM_COMPLEX_TYPE = "ComplexType";
- public static final String EDM_ASSOCIATION = "Association";
- public static final String EDM_USING = "Using";
-
- public static final String EDM_NAME = "Name";
- public static final String EDM_TYPE = "Type";
- public static final String EDM_ENTITY_TYPE_KEY = "Key";
- public static final String EDM_TYPE_ABSTRACT = "Abstract";
- public static final String EDM_BASE_TYPE = "BaseType";
- public static final String EDM_PROPERTY_REF = "PropertyRef";
-
- public static final String EDM_PROPERTY = "Property";
- public static final String EDM_PROPERTY_NULLABLE = "Nullable";
- public static final String EDM_PROPERTY_MAX_LENGTH = "MaxLength";
- public static final String EDM_PROPERTY_MAX_LENGTH_MAX_VALUE = "Max";
- public static final String EDM_PROPERTY_DEFAULT_VALUE = "DefaultValue";
- public static final String EDM_PROPERTY_FIXED_LENGTH = "FixedLength";
- public static final String EDM_PROPERTY_UNICODE = "Unicode";
- public static final String EDM_PROPERTY_COLLATION = "Collation";
- public static final String EDM_PROPERTY_PRECISION = "Precision";
- public static final String EDM_PROPERTY_SCALE = "Scale";
- public static final String EDM_PROPERTY_CONCURRENCY_MODE = "ConcurrencyMode";
-
- public static final String EDM_NAVIGATION_PROPERTY = "NavigationProperty";
- public static final String EDM_NAVIGATION_FROM_ROLE = "FromRole";
- public static final String EDM_NAVIGATION_TO_ROLE = "ToRole";
- public static final String EDM_NAVIGATION_RELATIONSHIP = "Relationship";
-
- public static final String EDM_ASSOCIATION_CONSTRAINT = "ReferentialConstraint";
- public static final String EDM_ASSOCIATION_END = "End";
-
- public static final String EDM_ASSOCIATION_MULTIPLICITY = "Multiplicity";
- public static final String EDM_ASSOCIATION_ONDELETE = "OnDelete";
- public static final String EDM_ONDELETE_ACTION = "Action";
-
- public static final String EDM_ENTITY_CONTAINER = "EntityContainer";
- public static final String EDM_CONTAINER_IS_DEFAULT = "IsDefaultEntityContainer";
- public static final String EDM_CONTAINER_EXTENDZ = "Extendz";
- public static final String EDM_ENTITY_SET = "EntitySet";
- public static final String EDM_ASSOCIATION_SET = "AssociationSet";
- public static final String EDM_FUNCTION_IMPORT = "FunctionImport";
-
- public static final String EDM_FUNCTION_IMPORT_HTTP_METHOD = "HttpMethod";
- public static final String EDM_FUNCTION_IMPORT_RETURN = "ReturnType";
- public static final String EDM_FUNCTION_PARAMETER = "Parameter";
- public static final String EDM_FUNCTION_PARAMETER_MODE = "Mode";
-
- public static final String M_ENTITY_TYPE_HAS_STREAM = "HasStream";
- public static final String M_MIMETYPE = "MimeType";
- public static final String M_FC_TARGET_PATH = "FC_TargetPath";
- public static final String M_FC_SOURCE_PATH = "FC_SourcePath";
- public static final String M_FC_NS_URI = "FC_NsUri";
- public static final String M_FC_PREFIX = "FC_NsPrefix";
- public static final String M_FC_KEEP_IN_CONTENT = "FC_KeepInContent";
- public static final String M_FC_CONTENT_KIND = "FC_ContentKind";
- public static final String EDM_ASSOCIATION_PRINCIPAL = "Principal";
- public static final String EDM_ASSOCIATION_DEPENDENT = "Dependent";
-
- public static final String EDM_ROLE = "Role";
- public static final String DOCUMENTATION = "Documentation";
- public static final String SUMMARY = "Summary";
- public static final String LONG_DESCRIPTION = "LongDescription";
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/exception/MessageService.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/exception/MessageService.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/exception/MessageService.java
deleted file mode 100644
index bd87eff..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/exception/MessageService.java
+++ /dev/null
@@ -1,223 +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.odata2.core.exception;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Formatter;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingFormatArgumentException;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.apache.olingo.odata2.api.exception.MessageReference;
-
-/**
- *
- */
-public class MessageService {
- private static final String BUNDLE_NAME = "i18n";
-
- private final ResourceBundle resourceBundle;
- private final Locale requestedLocale;
-
- private static final Map<Locale, MessageService> LOCALE_2_MESSAGE_SERVICE = new HashMap<Locale, MessageService>();
-
- private MessageService(final Locale locale) {
- requestedLocale = locale;
- resourceBundle = createResourceBundle(locale);
- }
-
- /**
- * Create a {@link ResourceBundle} based on given locale and name ({@value #BUNDLE_NAME}).
- * If during creation an exception occurs it is catched and an special bundle is created with error type and message
- * of
- * this exception.
- *
- * @param locale for which locale the {@link ResourceBundle} is created
- * @return a {@link ResourceBundle}
- */
- private ResourceBundle createResourceBundle(final Locale locale) {
- ResourceBundle bundle;
- try {
- if (locale == null) {
- throw new IllegalArgumentException("Parameter locale MUST NOT be NULL.");
- }
- bundle = ResourceBundle.getBundle(BUNDLE_NAME, locale);
- } catch (final Exception e) {
- bundle = new ResourceBundle() {
- @Override
- protected Object handleGetObject(final String key) {
- return "MessageService could not be created because of exception '" +
- e.getClass().getSimpleName() + " with message '" + e.getMessage() + "'.";
- }
-
- @Override
- public Locale getLocale() {
- return Locale.ENGLISH;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Enumeration<String> getKeys() {
- return (Enumeration<String>) Collections.emptySet();
- }
- };
- }
- return bundle;
- }
-
- public static class Message {
- private final String localizedText;
- private final Locale locale;
-
- public Message(final Locale locale, final String localizedMessage) {
- super();
- localizedText = localizedMessage;
- this.locale = locale;
- }
-
- public String getText() {
- return localizedText;
- }
-
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * Get language as defined in RFC 4646 based on {@link Locale}.
- *
- * @return the language label
- */
- public String getLang() {
- Locale locale = getLocale();
- if (locale.getCountry().isEmpty()) {
- return locale.getLanguage();
- }
- return locale.getLanguage() + "-" + locale.getCountry();
- }
- }
-
- public static MessageService getInstance(final Locale locale) {
- MessageService messagesInstance = LOCALE_2_MESSAGE_SERVICE.get(locale);
- if (messagesInstance == null) {
- messagesInstance = new MessageService(locale);
- LOCALE_2_MESSAGE_SERVICE.put(locale, messagesInstance);
- }
- return messagesInstance;
- }
-
- public static boolean isLocaleSupported(final Locale locale) {
- if (locale == null) {
- return false;
- }
- MessageService service = getInstance(locale);
- return service.getLocale().equals(locale);
- }
-
- /**
- * Return first found supported {@link Locale} (iterating over list starting with first element).
- * If no {@link Locale} is supported <code>NULL</code> is returned.
- *
- * @param locales
- * @return first supported {@link Locale} or <code>NULL</code>.
- */
- public static Locale getSupportedLocale(final List<Locale> locales) {
- return getSupportedLocale(locales, null);
- }
-
- /**
- * Return first found supported {@link Locale} (iterating over list starting with first element).
- * If no {@link Locale} is supported given <code>defaultLocale</code> is returned.
- *
- * @param locales to be checked locales
- * @param defaultLocale local which is returned if no supported local is in given <code>locales</code> list
- * @return first supported {@link Locale} or given <code>defaultLocale</code>.
- */
- public static Locale getSupportedLocale(final List<Locale> locales, final Locale defaultLocale) {
- for (Locale locale : locales) {
- if (isLocaleSupported(locale)) {
- return locale;
- }
- }
- return defaultLocale;
- }
-
- public static MessageService getInstance(final List<Locale> locales) {
- MessageService service = null;
-
- for (Locale locale : locales) {
- service = getInstance(locale);
- if (service.getLocale().equals(locale)) {
- break;
- }
- }
-
- return service;
- }
-
- public static Message getMessage(final Locale language, final MessageReference context) {
- Object[] contentAsArray = context.getContent().toArray(new Object[0]);
- return getMessage(language, context.getKey(), contentAsArray);
- }
-
- public static Message getMessage(final Locale locale, final String key, final Object... replacements) {
- MessageService messages = MessageService.getInstance(locale);
- return messages.getMessage(key, replacements);
- }
-
- /**
- *
- * @param key
- * @param replacements
- * @return the message
- */
- private Message getMessage(final String key, final Object... replacements) {
- String value = null;
-
- try {
- value = resourceBundle.getString(key);
- StringBuilder builder = new StringBuilder();
- Formatter f = new Formatter(builder, requestedLocale);
- f.format(value, replacements);
- f.close();
-
- return new Message(getLocale(), builder.toString());
-
- } catch (MissingResourceException e) {
- return new Message(Locale.ENGLISH, "Missing message for key '" + key + "'!");
- } catch (MissingFormatArgumentException e) {
- return new Message(Locale.ENGLISH, "Missing replacement for place holder in value '" + value +
- "' for following arguments '" + Arrays.toString(replacements) + "'!");
- }
- }
-
- public Locale getLocale() {
- return resourceBundle.getLocale();
- }
-
- public Enumeration<String> getKeys() {
- return resourceBundle.getKeys();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/exception/ODataRuntimeException.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/exception/ODataRuntimeException.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/exception/ODataRuntimeException.java
deleted file mode 100644
index d5eaacb..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/exception/ODataRuntimeException.java
+++ /dev/null
@@ -1,47 +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.odata2.core.exception;
-
-/**
- * Common un-checked exception for the <code>OData</code> library and
- * base exception for all <code>OData</code>-related exceptions
- * caused by programming errors and/or unexpected behavior within the code.
- *
- */
-public final class ODataRuntimeException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public ODataRuntimeException() {
- super();
- }
-
- public ODataRuntimeException(final Throwable throwable) {
- super(throwable);
- }
-
- public ODataRuntimeException(final String message) {
- super(message);
- }
-
- public ODataRuntimeException(final String message, final Throwable throwable) {
- super(message, throwable);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/processor/ODataSingleProcessorService.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/processor/ODataSingleProcessorService.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/processor/ODataSingleProcessorService.java
deleted file mode 100644
index fed0a43..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/processor/ODataSingleProcessorService.java
+++ /dev/null
@@ -1,257 +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.odata2.core.processor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.ODataService;
-import org.apache.olingo.odata2.api.ODataServiceVersion;
-import org.apache.olingo.odata2.api.commons.HttpContentType;
-import org.apache.olingo.odata2.api.edm.Edm;
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.exception.ODataNotImplementedException;
-import org.apache.olingo.odata2.api.processor.ODataProcessor;
-import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
-import org.apache.olingo.odata2.api.processor.feature.CustomContentType;
-import org.apache.olingo.odata2.api.processor.part.BatchProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityComplexPropertyProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityLinkProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityLinksProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityMediaProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntitySetProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntitySimplePropertyProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntitySimplePropertyValueProcessor;
-import org.apache.olingo.odata2.api.processor.part.FunctionImportProcessor;
-import org.apache.olingo.odata2.api.processor.part.FunctionImportValueProcessor;
-import org.apache.olingo.odata2.api.processor.part.MetadataProcessor;
-import org.apache.olingo.odata2.api.processor.part.ServiceDocumentProcessor;
-import org.apache.olingo.odata2.api.rt.RuntimeDelegate;
-
-/**
- * <p>An {@link ODataService} implementation that uses {@link ODataSingleProcessor}.</p>
- * <p>Usually custom services create an instance by their implementation of
- * {@link org.apache.olingo.odata2.api.ODataServiceFactory} and populate it with their custom {@link EdmProvider} and
- * custom {@link ODataSingleProcessor} implementations.</p>
- *
- *
- */
-public class ODataSingleProcessorService implements ODataService {
-
- private final ODataSingleProcessor processor;
- private final Edm edm;
-
- /**
- * Construct service
- * @param provider A custom {@link EdmProvider}
- * @param processor A custom {@link ODataSingleProcessor}
- */
- public ODataSingleProcessorService(final EdmProvider provider, final ODataSingleProcessor processor) {
- this.processor = processor;
- edm = RuntimeDelegate.createEdm(provider);
- }
-
- /**
- * @see ODataService
- */
- @Override
- public String getVersion() throws ODataException {
- return ODataServiceVersion.V20;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public Edm getEntityDataModel() throws ODataException {
- return edm;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public MetadataProcessor getMetadataProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public ServiceDocumentProcessor getServiceDocumentProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public EntityProcessor getEntityProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public EntitySetProcessor getEntitySetProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public EntityComplexPropertyProcessor getEntityComplexPropertyProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public EntityLinkProcessor getEntityLinkProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public EntityLinksProcessor getEntityLinksProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public EntityMediaProcessor getEntityMediaProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public EntitySimplePropertyProcessor getEntitySimplePropertyProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public EntitySimplePropertyValueProcessor getEntitySimplePropertyValueProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public FunctionImportProcessor getFunctionImportProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public FunctionImportValueProcessor getFunctionImportValueProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public BatchProcessor getBatchProcessor() throws ODataException {
- return processor;
- }
-
- /**
- * @see ODataService
- */
- @Override
- public ODataProcessor getProcessor() throws ODataException {
- return processor;
- }
-
- @Override
- public List<String> getSupportedContentTypes(final Class<? extends ODataProcessor> processorFeature)
- throws ODataException {
- List<String> result = new ArrayList<String>();
-
- if (processor instanceof CustomContentType) {
- result.addAll(((CustomContentType) processor).getCustomContentTypes(processorFeature));
- }
-
- if (processorFeature == BatchProcessor.class) {
- // set wildcard for now to ignore accept header completely, reasoning: there is only one representation for $batch
- result.add(HttpContentType.WILDCARD);
- } else if (processorFeature == EntityProcessor.class) {
- result.add(HttpContentType.APPLICATION_ATOM_XML_ENTRY_UTF8);
- result.add(HttpContentType.APPLICATION_ATOM_XML_UTF8);
- result.add(HttpContentType.APPLICATION_JSON_UTF8);
- result.add(HttpContentType.APPLICATION_JSON_UTF8_VERBOSE);
- result.add(HttpContentType.APPLICATION_JSON);
- result.add(HttpContentType.APPLICATION_JSON_VERBOSE);
- result.add(HttpContentType.APPLICATION_XML_UTF8);
- } else if (processorFeature == FunctionImportProcessor.class
- || processorFeature == EntityLinkProcessor.class
- || processorFeature == EntityLinksProcessor.class
- || processorFeature == EntitySimplePropertyProcessor.class
- || processorFeature == EntityComplexPropertyProcessor.class) {
- result.add(HttpContentType.APPLICATION_XML_UTF8);
- result.add(HttpContentType.APPLICATION_JSON_UTF8);
- result.add(HttpContentType.APPLICATION_JSON_UTF8_VERBOSE);
- result.add(HttpContentType.APPLICATION_JSON);
- result.add(HttpContentType.APPLICATION_JSON_VERBOSE);
- } else if (processorFeature == EntityMediaProcessor.class
- || processorFeature == EntitySimplePropertyValueProcessor.class
- || processorFeature == FunctionImportValueProcessor.class) {
- result.add(HttpContentType.WILDCARD);
- } else if (processorFeature == EntitySetProcessor.class) {
- result.add(HttpContentType.APPLICATION_ATOM_XML_FEED_UTF8);
- result.add(HttpContentType.APPLICATION_ATOM_XML_UTF8);
- result.add(HttpContentType.APPLICATION_JSON_UTF8);
- result.add(HttpContentType.APPLICATION_JSON_UTF8_VERBOSE);
- result.add(HttpContentType.APPLICATION_JSON);
- result.add(HttpContentType.APPLICATION_JSON_VERBOSE);
- result.add(HttpContentType.APPLICATION_XML_UTF8);
- } else if (processorFeature == MetadataProcessor.class) {
- result.add(HttpContentType.APPLICATION_XML_UTF8);
- } else if (processorFeature == ServiceDocumentProcessor.class) {
- result.add(HttpContentType.APPLICATION_ATOM_SVC_UTF8);
- result.add(HttpContentType.APPLICATION_JSON_UTF8);
- result.add(HttpContentType.APPLICATION_JSON_UTF8_VERBOSE);
- result.add(HttpContentType.APPLICATION_JSON);
- result.add(HttpContentType.APPLICATION_JSON_VERBOSE);
- result.add(HttpContentType.APPLICATION_XML_UTF8);
- } else {
- throw new ODataNotImplementedException();
- }
-
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/MERGE.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/MERGE.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/MERGE.java
deleted file mode 100644
index 330030b..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/MERGE.java
+++ /dev/null
@@ -1,31 +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.odata2.core.rest;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.ws.rs.HttpMethod;
-
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-@HttpMethod("MERGE")
-public @interface MERGE {}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionMapperImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionMapperImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionMapperImpl.java
deleted file mode 100644
index b5006fd..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionMapperImpl.java
+++ /dev/null
@@ -1,211 +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.odata2.core.rest;
-
-import java.util.List;
-import java.util.Locale;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.NotAllowedException;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.ext.ExceptionMapper;
-import javax.ws.rs.ext.Provider;
-
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
-import org.apache.olingo.odata2.api.ep.EntityProviderException;
-import org.apache.olingo.odata2.api.exception.ODataApplicationException;
-import org.apache.olingo.odata2.api.processor.ODataErrorCallback;
-import org.apache.olingo.odata2.api.processor.ODataErrorContext;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.core.ODataExceptionWrapper;
-import org.apache.olingo.odata2.core.commons.ContentType;
-import org.apache.olingo.odata2.core.ep.ProviderFacadeImpl;
-
-/**
- * Creates an error response according to the format defined by the OData standard
- * if an exception occurs that is not handled elsewhere.
- *
- */
-@Provider
-public class ODataExceptionMapperImpl implements ExceptionMapper<Exception> {
-
- private static final String DOLLAR_FORMAT = "$format";
- private static final String DOLLAR_FORMAT_JSON = "json";
-
- private static final Locale DEFAULT_RESPONSE_LOCALE = Locale.ENGLISH;
-
- @Context
- UriInfo uriInfo;
- @Context
- HttpHeaders httpHeaders;
- @Context
- ServletConfig servletConfig;
- @Context
- HttpServletRequest servletRequest;
-
- @Override
- public Response toResponse(final Exception exception) {
- ODataResponse response;
- try {
- if (exception instanceof WebApplicationException) {
- response = handleWebApplicationException(exception);
- } else {
- response = handleException(exception);
- }
- } catch (Exception e) {
- response = ODataResponse.entity("Exception during error handling occured!")
- .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString())
- .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build();
- }
- // Convert OData response to JAX-RS response.
- return RestUtil.convertResponse(response);
- }
-
- private ODataResponse handleException(final Exception exception) {
- ODataExceptionWrapper exceptionWrapper =
- new ODataExceptionWrapper(uriInfo, httpHeaders, servletConfig, servletRequest);
- ODataResponse oDataResponse = exceptionWrapper.wrapInExceptionResponse(exception);
- return oDataResponse;
- }
-
- private ODataResponse handleWebApplicationException(final Exception exception) throws ClassNotFoundException,
- InstantiationException, IllegalAccessException, EntityProviderException {
- ODataErrorContext errorContext = createErrorContext((WebApplicationException) exception);
- ODataErrorCallback callback = getErrorHandlerCallback();
- return callback == null ?
- new ProviderFacadeImpl().writeErrorDocument(errorContext) : executeErrorCallback(errorContext, callback);
- }
-
- private ODataResponse executeErrorCallback(final ODataErrorContext errorContext, final ODataErrorCallback callback) {
- ODataResponse oDataResponse;
- try {
- oDataResponse = callback.handleError(errorContext);
- } catch (ODataApplicationException e) {
- oDataResponse = handleException(e);
- }
- return oDataResponse;
- }
-
- private ODataErrorContext createErrorContext(final WebApplicationException exception) {
- ODataErrorContext context = new ODataErrorContext();
- if (uriInfo != null) {
- context.setRequestUri(uriInfo.getRequestUri());
- }
- if (httpHeaders != null && httpHeaders.getRequestHeaders() != null) {
- MultivaluedMap<String, String> requestHeaders = httpHeaders.getRequestHeaders();
- Set<Entry<String, List<String>>> entries = requestHeaders.entrySet();
- for (Entry<String, List<String>> entry : entries) {
- context.putRequestHeader(entry.getKey(), entry.getValue());
- }
- }
- context.setContentType(getContentType().toContentTypeString());
- context.setException(exception);
- context.setErrorCode(null);
- context.setMessage(exception.getMessage());
- context.setLocale(DEFAULT_RESPONSE_LOCALE);
- context.setHttpStatus(HttpStatusCodes.fromStatusCode(exception.getResponse().getStatus()));
- if (exception instanceof NotAllowedException) {
- // RFC 2616, 5.1.1: " An origin server SHOULD return the status code
- // 405 (Method Not Allowed) if the method is known by the origin server
- // but not allowed for the requested resource, and 501 (Not Implemented)
- // if the method is unrecognized or not implemented by the origin server."
- // Since all recognized methods are handled elsewhere, we unconditionally
- // switch to 501 here for not-allowed exceptions thrown directly from
- // JAX-RS implementations.
- context.setHttpStatus(HttpStatusCodes.NOT_IMPLEMENTED);
- context.setMessage("The request dispatcher does not allow the HTTP method used for the request.");
- context.setLocale(Locale.ENGLISH);
- }
- return context;
- }
-
- private ContentType getContentType() {
- ContentType contentType = getContentTypeByUriInfo();
- if (contentType == null) {
- contentType = getContentTypeByAcceptHeader();
- }
- return contentType;
- }
-
- private ContentType getContentTypeByUriInfo() {
- ContentType contentType = null;
- if (uriInfo != null && uriInfo.getQueryParameters() != null) {
- MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
- if (queryParameters.containsKey(DOLLAR_FORMAT)) {
- String contentTypeString = queryParameters.getFirst(DOLLAR_FORMAT);
- if (DOLLAR_FORMAT_JSON.equals(contentTypeString)) {
- contentType = ContentType.APPLICATION_JSON;
- } else {
- // Any format mentioned in the $format parameter other than json results in an application/xml content type
- // for error messages due to the OData V2 Specification.
- contentType = ContentType.APPLICATION_XML;
- }
- }
- }
- return contentType;
- }
-
- private ContentType getContentTypeByAcceptHeader() {
- for (MediaType type : httpHeaders.getAcceptableMediaTypes()) {
- if (ContentType.isParseable(type.toString())) {
- ContentType convertedContentType = ContentType.create(type.toString());
- if (convertedContentType.isWildcard()
- || ContentType.APPLICATION_XML.equals(convertedContentType)
- || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType)
- || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType)
- || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) {
- return ContentType.APPLICATION_XML;
- } else if (ContentType.APPLICATION_JSON.equals(convertedContentType)
- || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType)) {
- return ContentType.APPLICATION_JSON;
- }
- }
- }
- return ContentType.APPLICATION_XML;
- }
-
- private ODataErrorCallback getErrorHandlerCallback() throws ClassNotFoundException, InstantiationException,
- IllegalAccessException {
- ODataErrorCallback callback = null;
- final String factoryClassName = servletConfig.getInitParameter(ODataServiceFactory.FACTORY_LABEL);
- if (factoryClassName != null) {
- ClassLoader cl = (ClassLoader) servletRequest.getAttribute(ODataServiceFactory.FACTORY_CLASSLOADER_LABEL);
- Class<?> factoryClass;
- if (cl == null) {
- factoryClass = Class.forName(factoryClassName);
- } else {
- factoryClass = Class.forName(factoryClassName, true, cl);
- }
- final ODataServiceFactory serviceFactory = (ODataServiceFactory) factoryClass.newInstance();
-
- callback = serviceFactory.getCallback(ODataErrorCallback.class);
- }
- return callback;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRedirectLocator.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRedirectLocator.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRedirectLocator.java
deleted file mode 100644
index 2ab44df..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRedirectLocator.java
+++ /dev/null
@@ -1,80 +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.odata2.core.rest;
-
-import java.net.URI;
-
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.OPTIONS;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.core.Response;
-
-/**
- *
- */
-public class ODataRedirectLocator {
-
- @GET
- public Response redirectGet() {
- return redirect();
- }
-
- @PUT
- public Response redirectPut() {
- return redirect();
- }
-
- @POST
- public Response redirectPost() {
- return redirect();
- }
-
- @DELETE
- public Response redirectDelete() {
- return redirect();
- }
-
- @OPTIONS
- public Response redirectOptions() {
- return redirect();
- }
-
- @HEAD
- public Response redirectHead() {
- return redirect();
- }
-
- @PATCH
- public Response redirectPatch() {
- return redirect();
- }
-
- @MERGE
- public Response redirectMerge() {
- return redirect();
- }
-
- private Response redirect() {
- return Response.temporaryRedirect(URI.create("/")).build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
deleted file mode 100644
index 19595e7..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
+++ /dev/null
@@ -1,134 +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.odata2.core.rest;
-
-import java.util.List;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Encoded;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.Request;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.core.exception.ODataRuntimeException;
-
-/**
- * Default OData root locator responsible to handle the whole path and delegate all calls to a sub locator:<p>
- * <code>/{odata path} e.g. http://host:port/webapp/odata.svc/$metadata</code><br>
- * All path segments defined by a servlet mapping belong to the odata uri.
- * </p>
- * This behavior can be changed:<p>
- * <code>/{custom path}{odata path} e.g. http://host:port/webapp/bmw/odata.svc/$metadata</code><br>
- * The first segment defined by a servlet mapping belong to customer context and the following segments are OData
- * specific.
- * </p>
- *
- */
-public class ODataRootLocator {
-
- @Context
- private HttpHeaders httpHeaders;
- @Context
- private UriInfo uriInfo;
- @Context
- private Request request;
- @Context
- private ServletConfig servletConfig;
- @Context
- private HttpServletRequest servletRequest;
-
- /**
- * Default root behavior which will delegate all paths to a ODataLocator.
- * @param pathSegments URI path segments - all segments have to be OData
- * @param xHttpMethod HTTP Header X-HTTP-Method for tunneling through POST
- * @param xHttpMethodOverride HTTP Header X-HTTP-Method-Override for tunneling through POST
- * @return a locator handling OData protocol
- * @throws ODataException
- * @throws ClassNotFoundException
- * @throws IllegalAccessException
- * @throws InstantiationException
- */
- @Path("/{pathSegments: .*}")
- public Object handleRequest(
- @Encoded @PathParam("pathSegments") final List<PathSegment> pathSegments,
- @HeaderParam("X-HTTP-Method") final String xHttpMethod,
- @HeaderParam("X-HTTP-Method-Override") final String xHttpMethodOverride)
- throws ODataException, ClassNotFoundException, InstantiationException, IllegalAccessException {
-
- if (xHttpMethod != null && xHttpMethodOverride != null) {
-
- /*
- * X-HTTP-Method-Override : implemented by CXF
- * X-HTTP-Method : implemented in ODataSubLocator:handlePost
- */
-
- if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
- throw new ODataBadRequestException(ODataBadRequestException.AMBIGUOUS_XMETHOD);
- }
- }
-
- if (servletRequest.getPathInfo() == null) {
- return handleRedirect();
- }
-
- final String factoryClassName = servletConfig.getInitParameter(ODataServiceFactory.FACTORY_LABEL);
- if (factoryClassName == null) {
- throw new ODataRuntimeException("servlet config missing: org.apache.olingo.odata2.processor.factory");
- }
-
- ClassLoader cl = (ClassLoader) servletRequest.getAttribute(ODataServiceFactory.FACTORY_CLASSLOADER_LABEL);
- Class<?> factoryClass;
- if (cl == null) {
- factoryClass = Class.forName(factoryClassName);
- } else {
- factoryClass = Class.forName(factoryClassName, true, cl);
- }
- ODataServiceFactory serviceFactory = (ODataServiceFactory) factoryClass.newInstance();
-
- int pathSplit = 0;
- final String pathSplitAsString = servletConfig.getInitParameter(ODataServiceFactory.PATH_SPLIT_LABEL);
- if (pathSplitAsString != null) {
- pathSplit = Integer.parseInt(pathSplitAsString);
- }
-
- final SubLocatorParameter param = new SubLocatorParameter();
- param.setServiceFactory(serviceFactory);
- param.setPathSegments(pathSegments);
- param.setHttpHeaders(httpHeaders);
- param.setUriInfo(uriInfo);
- param.setRequest(request);
- param.setServletRequest(servletRequest);
- param.setPathSplit(pathSplit);
-
- return ODataSubLocator.create(param);
- }
-
- private Object handleRedirect() {
- return new ODataRedirectLocator();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataSubLocator.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataSubLocator.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataSubLocator.java
deleted file mode 100644
index 3fe903a..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataSubLocator.java
+++ /dev/null
@@ -1,173 +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.odata2.core.rest;
-
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.OPTIONS;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.core.Response;
-
-import org.apache.olingo.odata2.api.ODataService;
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.commons.ODataHttpMethod;
-import org.apache.olingo.odata2.api.exception.MessageReference;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.exception.ODataNotImplementedException;
-import org.apache.olingo.odata2.api.processor.ODataRequest;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.core.ODataContextImpl;
-import org.apache.olingo.odata2.core.ODataExceptionWrapper;
-import org.apache.olingo.odata2.core.ODataRequestHandler;
-
-/**
- *
- */
-public final class ODataSubLocator {
-
- private ODataServiceFactory serviceFactory;
- private ODataRequest request;
-
- @GET
- public Response handleGet() throws ODataException {
- return handle(ODataHttpMethod.GET);
- }
-
- @PUT
- public Response handlePut() throws ODataException {
- return handle(ODataHttpMethod.PUT);
- }
-
- @PATCH
- public Response handlePatch() throws ODataException {
- return handle(ODataHttpMethod.PATCH);
- }
-
- @MERGE
- public Response handleMerge() throws ODataException {
- return handle(ODataHttpMethod.MERGE);
- }
-
- @DELETE
- public Response handleDelete() throws ODataException {
- return handle(ODataHttpMethod.DELETE);
- }
-
- @POST
- public Response handlePost(@HeaderParam("X-HTTP-Method") final String xHttpMethod) throws ODataException {
- Response response;
-
- if (xHttpMethod == null) {
- response = handle(ODataHttpMethod.POST);
- } else {
- /* tunneling */
- if ("MERGE".equals(xHttpMethod)) {
- response = handle(ODataHttpMethod.MERGE);
- } else if ("PATCH".equals(xHttpMethod)) {
- response = handle(ODataHttpMethod.PATCH);
- } else if (HttpMethod.DELETE.equals(xHttpMethod)) {
- response = handle(ODataHttpMethod.DELETE);
- } else if (HttpMethod.PUT.equals(xHttpMethod)) {
- response = handle(ODataHttpMethod.PUT);
- } else if (HttpMethod.GET.equals(xHttpMethod)) {
- response = handle(ODataHttpMethod.GET);
- } else if (HttpMethod.POST.equals(xHttpMethod)) {
- response = handle(ODataHttpMethod.POST);
- } else if (HttpMethod.HEAD.equals(xHttpMethod)) {
- response = handleHead();
- } else if (HttpMethod.OPTIONS.equals(xHttpMethod)) {
- response = handleOptions();
- } else {
- response = returnNotImplementedResponse(ODataNotImplementedException.TUNNELING);
- }
- }
- return response;
- }
-
- private Response returnNotImplementedResponse(final MessageReference messageReference) {
- // RFC 2616, 5.1.1: "An origin server SHOULD return the status code [...]
- // 501 (Not Implemented) if the method is unrecognized [...] by the origin server."
- ODataContextImpl context = new ODataContextImpl(request, serviceFactory);
- context.setRequest(request);
- context.setAcceptableLanguages(request.getAcceptableLanguages());
- context.setPathInfo(request.getPathInfo());
- context.setServiceFactory(serviceFactory);
- ODataExceptionWrapper exceptionWrapper =
- new ODataExceptionWrapper(context, request.getQueryParameters(), request.getAcceptHeaders());
- ODataResponse response =
- exceptionWrapper.wrapInExceptionResponse(new ODataNotImplementedException(messageReference));
- return RestUtil.convertResponse(response);
- }
-
- @OPTIONS
- public Response handleOptions() throws ODataException {
- // RFC 2616, 5.1.1: "An origin server SHOULD return the status code [...]
- // 501 (Not Implemented) if the method is unrecognized or not implemented
- // by the origin server."
- return returnNotImplementedResponse(ODataNotImplementedException.COMMON);
- }
-
- @HEAD
- public Response handleHead() throws ODataException {
- // RFC 2616, 5.1.1: "An origin server SHOULD return the status code [...]
- // 501 (Not Implemented) if the method is unrecognized or not implemented
- // by the origin server."
- return returnNotImplementedResponse(ODataNotImplementedException.COMMON);
- }
-
- private Response handle(final ODataHttpMethod method) throws ODataException {
- request = ODataRequest.fromRequest(request).method(method).build();
-
- ODataContextImpl context = new ODataContextImpl(request, serviceFactory);
- ODataService service = serviceFactory.createService(context);
- context.setService(service);
- service.getProcessor().setContext(context);
-
- ODataRequestHandler requestHandler = new ODataRequestHandler(serviceFactory, service, context);
-
- final ODataResponse odataResponse = requestHandler.handle(request);
- final Response response = RestUtil.convertResponse(odataResponse);
-
- return response;
- }
-
- public static ODataSubLocator create(final SubLocatorParameter param) throws ODataException {
- ODataSubLocator subLocator = new ODataSubLocator();
-
- subLocator.serviceFactory = param.getServiceFactory();
- subLocator.request = ODataRequest.acceptableLanguages(param.getHttpHeaders().getAcceptableLanguages())
- .acceptHeaders(RestUtil.extractAcceptHeaders(param))
- .body(RestUtil.contentAsStream(RestUtil.extractRequestContent(param)))
- .pathInfo(RestUtil.buildODataPathInfo(param))
- .queryParameters(RestUtil.convertToSinglevaluedMap(param.getUriInfo().getQueryParameters()))
- .requestHeaders(param.getHttpHeaders().getRequestHeaders())
- .contentType(RestUtil.extractRequestContentType(param).toContentTypeString())
- .build();
-
- return subLocator;
- }
-
- private ODataSubLocator() {
- super();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/PATCH.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/PATCH.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/PATCH.java
deleted file mode 100644
index 00554c0..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/PATCH.java
+++ /dev/null
@@ -1,31 +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.odata2.core.rest;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.ws.rs.HttpMethod;
-
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-@HttpMethod("PATCH")
-public @interface PATCH {}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/RestUtil.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/RestUtil.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/RestUtil.java
deleted file mode 100644
index 410e261..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/RestUtil.java
+++ /dev/null
@@ -1,267 +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.odata2.core.rest;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.olingo.odata2.api.commons.HttpHeaders;
-import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.exception.ODataNotFoundException;
-import org.apache.olingo.odata2.api.exception.ODataUnsupportedMediaTypeException;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.api.uri.PathSegment;
-import org.apache.olingo.odata2.core.ODataPathSegmentImpl;
-import org.apache.olingo.odata2.core.PathInfoImpl;
-import org.apache.olingo.odata2.core.commons.ContentType;
-import org.apache.olingo.odata2.core.commons.Decoder;
-
-/**
- *
- */
-public class RestUtil {
- public static Response convertResponse(final ODataResponse odataResponse) {
- try {
- ResponseBuilder responseBuilder =
- Response.noContent().status(odataResponse.getStatus().getStatusCode()).entity(odataResponse.getEntity());
-
- for (final String name : odataResponse.getHeaderNames()) {
- responseBuilder = responseBuilder.header(name, odataResponse.getHeader(name));
- }
-
- return responseBuilder.build();
- } catch (RuntimeException e) {
- if (odataResponse != null) {
- try {
- odataResponse.close();
- } catch (IOException inner) {
- // if close throw an exception we ignore these and re-throw our exception
- throw e;
- }
- }
- throw e;
- }
- }
-
- public static ContentType extractRequestContentType(final SubLocatorParameter param)
- throws ODataUnsupportedMediaTypeException {
- final String contentType = param.getHttpHeaders().getHeaderString(HttpHeaders.CONTENT_TYPE);
- if (contentType == null || contentType.isEmpty()) {
- // RFC 2616, 7.2.1:
- // "Any HTTP/1.1 message containing an entity-body SHOULD include a
- // Content-Type header field defining the media type of that body. [...]
- // If the media type remains unknown, the recipient SHOULD treat it
- // as type "application/octet-stream"."
- return ContentType.APPLICATION_OCTET_STREAM;
- } else if (ContentType.isParseable(contentType)) {
- return ContentType.create(contentType);
- } else {
- throw new ODataUnsupportedMediaTypeException(ODataUnsupportedMediaTypeException.NOT_SUPPORTED_CONTENT_TYPE
- .addContent(HttpHeaders.CONTENT_TYPE, contentType));
- }
- }
-
- /**
- * Extracts the request content from the servlet as input stream.
- * @param param initialization parameters
- * @return the request content as input stream
- * @throws ODataException
- */
- public static ServletInputStream extractRequestContent(final SubLocatorParameter param) throws ODataException {
- try {
- return param.getServletRequest().getInputStream();
- } catch (final IOException e) {
- throw new ODataException("Error getting request content as ServletInputStream.", e);
- }
- }
-
- public static <T> InputStream contentAsStream(final T content) throws ODataException {
- if (content == null) {
- throw new ODataBadRequestException(ODataBadRequestException.COMMON);
- }
-
- InputStream inputStream;
- if (content instanceof InputStream) {
- inputStream = (InputStream) content;
- } else if (content instanceof String) {
- try {
- inputStream = new ByteArrayInputStream(((String) content).getBytes("UTF-8"));
- } catch (final UnsupportedEncodingException e) {
- throw new ODataBadRequestException(ODataBadRequestException.COMMON, e);
- }
- } else {
- throw new ODataBadRequestException(ODataBadRequestException.COMMON);
- }
- return inputStream;
- }
-
- public static List<String> extractAcceptHeaders(final SubLocatorParameter param) throws ODataBadRequestException {
- List<String> acceptHeaders = param.getHttpHeaders().getRequestHeader(HttpHeaders.ACCEPT);
-
- List<String> toSort = new LinkedList<String>();
- if (acceptHeaders != null) {
- for (String acceptHeader : acceptHeaders) {
- String[] contentTypes = acceptHeader.split(",");
- for (String contentType : contentTypes) {
- toSort.add(contentType.trim());
- }
- }
- }
-
- ContentType.sortForQParameter(toSort);
- return toSort;
- }
-
- public static Map<String, String> extractRequestHeaders(final javax.ws.rs.core.HttpHeaders httpHeaders) {
- final MultivaluedMap<String, String> headers = httpHeaders.getRequestHeaders();
- Map<String, String> headerMap = new HashMap<String, String>();
-
- for (final String key : headers.keySet()) {
- List<String> header = httpHeaders.getRequestHeader(key);
- if (header != null && !header.isEmpty()) {
- /*
- * consider first header value only
- * avoid using jax-rs 2.0 (getHeaderString())
- */
- String value = header.get(0);
- if (value != null && !"".equals(value)) {
- headerMap.put(key, value);
- }
- }
-
- }
- return headerMap;
- }
-
- public static PathInfoImpl buildODataPathInfo(final SubLocatorParameter param) throws ODataException {
- final UriInfo uriInfo = param.getUriInfo();
- PathInfoImpl pathInfo = splitPath(param);
- pathInfo.setServiceRoot(buildBaseUri(param.getServletRequest(), uriInfo, pathInfo.getPrecedingSegments()));
- pathInfo.setRequestUri(uriInfo.getRequestUri());
-
- return pathInfo;
- }
-
- private static PathInfoImpl splitPath(final SubLocatorParameter param) throws ODataException {
- PathInfoImpl pathInfo = new PathInfoImpl();
-
- List<javax.ws.rs.core.PathSegment> precedingPathSegments;
- List<javax.ws.rs.core.PathSegment> pathSegments;
-
- if (param.getPathSplit() == 0) {
- precedingPathSegments = Collections.emptyList();
- pathSegments = param.getPathSegments();
- } else {
- if (param.getPathSegments().size() < param.getPathSplit()) {
- throw new ODataBadRequestException(ODataBadRequestException.URLTOOSHORT);
- }
-
- precedingPathSegments = param.getPathSegments().subList(0, param.getPathSplit());
- final int pathSegmentCount = param.getPathSegments().size();
- pathSegments = param.getPathSegments().subList(param.getPathSplit(), pathSegmentCount);
- }
-
- // Percent-decode only the preceding path segments.
- // The OData path segments are decoded during URI parsing.
- pathInfo.setPrecedingPathSegment(convertPathSegmentList(precedingPathSegments));
-
- List<PathSegment> odataSegments = new ArrayList<PathSegment>();
- for (final javax.ws.rs.core.PathSegment segment : pathSegments) {
- if (segment.getMatrixParameters() == null || segment.getMatrixParameters().isEmpty()) {
- odataSegments.add(new ODataPathSegmentImpl(segment.getPath(), null));
- } else {
- // post condition: we do not allow matrix parameters in OData path segments
- throw new ODataNotFoundException(ODataNotFoundException.MATRIX.addContent(segment.getMatrixParameters()
- .keySet(), segment.getPath()));
- }
- }
- pathInfo.setODataPathSegment(odataSegments);
-
- return pathInfo;
- }
-
- private static URI buildBaseUri(final HttpServletRequest request, final javax.ws.rs.core.UriInfo uriInfo,
- final List<PathSegment> precedingPathSegments) throws ODataException {
- try {
- UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
- for (final PathSegment ps : precedingPathSegments) {
- uriBuilder = uriBuilder.path(ps.getPath());
- for (final String key : ps.getMatrixParameters().keySet()) {
- final Object[] v = ps.getMatrixParameters().get(key).toArray();
- uriBuilder = uriBuilder.matrixParam(key, v);
- }
- }
-
- /*
- * workaround because of host name is cached by uriInfo
- */
- uriBuilder.host(request.getServerName());
-
- String uriString = uriBuilder.build().toString();
- if (!uriString.endsWith("/")) {
- uriString = uriString + "/";
- }
-
- return new URI(uriString);
- } catch (final URISyntaxException e) {
- throw new ODataException(e);
- }
- }
-
- private static List<PathSegment> convertPathSegmentList(final List<javax.ws.rs.core.PathSegment> pathSegments) {
- ArrayList<PathSegment> converted = new ArrayList<PathSegment>();
- for (final javax.ws.rs.core.PathSegment pathSegment : pathSegments) {
- final PathSegment segment =
- new ODataPathSegmentImpl(Decoder.decode(pathSegment.getPath()), pathSegment.getMatrixParameters());
- converted.add(segment);
- }
- return converted;
- }
-
- public static Map<String, String> convertToSinglevaluedMap(final MultivaluedMap<String, String> multi) {
- final Map<String, String> single = new HashMap<String, String>();
-
- for (final String key : multi.keySet()) {
- final String value = multi.getFirst(key);
- single.put(key, value);
- }
-
- return single;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/SubLocatorParameter.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/SubLocatorParameter.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/SubLocatorParameter.java
deleted file mode 100644
index 8a0370c..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/SubLocatorParameter.java
+++ /dev/null
@@ -1,96 +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.odata2.core.rest;
-
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Request;
-
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-
-/**
- *
- */
-public class SubLocatorParameter {
-
- private List<javax.ws.rs.core.PathSegment> pathSegments;
- private javax.ws.rs.core.HttpHeaders httpHeaders;
- private javax.ws.rs.core.UriInfo uriInfo;
- private Request request;
- private int pathSplit;
- private ODataServiceFactory serviceFactory;
- private HttpServletRequest servletRequest;
-
- public ODataServiceFactory getServiceFactory() {
- return serviceFactory;
- }
-
- public void setServiceFactory(final ODataServiceFactory serviceFactory) {
- this.serviceFactory = serviceFactory;
- }
-
- public List<javax.ws.rs.core.PathSegment> getPathSegments() {
- return pathSegments;
- }
-
- public void setPathSegments(final List<javax.ws.rs.core.PathSegment> pathSegments) {
- this.pathSegments = pathSegments;
- }
-
- public javax.ws.rs.core.HttpHeaders getHttpHeaders() {
- return httpHeaders;
- }
-
- public void setHttpHeaders(final javax.ws.rs.core.HttpHeaders httpHeaders) {
- this.httpHeaders = httpHeaders;
- }
-
- public javax.ws.rs.core.UriInfo getUriInfo() {
- return uriInfo;
- }
-
- public void setUriInfo(final javax.ws.rs.core.UriInfo uriInfo) {
- this.uriInfo = uriInfo;
- }
-
- public Request getRequest() {
- return request;
- }
-
- public void setRequest(final Request request) {
- this.request = request;
- }
-
- public int getPathSplit() {
- return pathSplit;
- }
-
- public void setPathSplit(final int pathSplit) {
- this.pathSplit = pathSplit;
- }
-
- public void setServletRequest(final HttpServletRequest servletRequest) {
- this.servletRequest = servletRequest;
- }
-
- public HttpServletRequest getServletRequest() {
- return servletRequest;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/app/ODataApplication.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/app/ODataApplication.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/app/ODataApplication.java
deleted file mode 100644
index 6a73ded..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/app/ODataApplication.java
+++ /dev/null
@@ -1,88 +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.odata2.core.rest.app;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.Provider;
-
-import org.apache.olingo.odata2.core.rest.ODataExceptionMapperImpl;
-import org.apache.olingo.odata2.core.rest.ODataRootLocator;
-
-/**
- *
- */
-public class ODataApplication extends Application {
-
- @Override
- public Set<Class<?>> getClasses() {
- Set<Class<?>> classes = new HashSet<Class<?>>();
- classes.add(ODataRootLocator.class);
- classes.add(ODataExceptionMapperImpl.class);
- classes.add(MyProvider.class);
- return classes;
- }
-
- /**
- * Singletons are not recommended because they break the state less REST principle.
- */
- @Override
- public Set<Object> getSingletons() {
- return Collections.emptySet();
- }
-
- @Provider
- @Produces({ "generic/value", "multipart/mixed" })
- public static final class MyProvider implements MessageBodyWriter<String> {
-
- @Override
- public boolean isWriteable(final Class<?> type, final Type genericType, final Annotation[] annotations,
- final MediaType mediaType) {
- return (type == String.class);
- }
-
- @Override
- public long getSize(final String t, final Class<?> type, final Type genericType, final Annotation[] annotations,
- final MediaType mediaType) {
- return t.length();
- }
-
- @Override
- public void writeTo(final String t, final Class<?> type, final Type genericType, final Annotation[] annotations,
- final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream)
- throws IOException, WebApplicationException {
- StringBuilder b = new StringBuilder();
- b.append(t);
- entityStream.write(b.toString().getBytes("UTF-8"));
- entityStream.flush();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/rt/RuntimeDelegateImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/rt/RuntimeDelegateImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/rt/RuntimeDelegateImpl.java
deleted file mode 100644
index cc1c6e7..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/rt/RuntimeDelegateImpl.java
+++ /dev/null
@@ -1,132 +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.odata2.core.rt;
-
-import java.io.InputStream;
-
-import org.apache.olingo.odata2.api.ODataService;
-import org.apache.olingo.odata2.api.batch.BatchResponsePart.BatchResponsePartBuilder;
-import org.apache.olingo.odata2.api.client.batch.BatchChangeSet.BatchChangeSetBuilder;
-import org.apache.olingo.odata2.api.client.batch.BatchChangeSetPart.BatchChangeSetPartBuilder;
-import org.apache.olingo.odata2.api.client.batch.BatchQueryPart.BatchQueryPartBuilder;
-import org.apache.olingo.odata2.api.edm.Edm;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeFacade;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.ep.EntityProvider.EntityProviderInterface;
-import org.apache.olingo.odata2.api.ep.EntityProviderException;
-import org.apache.olingo.odata2.api.processor.ODataRequest.ODataRequestBuilder;
-import org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder;
-import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
-import org.apache.olingo.odata2.api.rt.RuntimeDelegate.RuntimeDelegateInstance;
-import org.apache.olingo.odata2.api.uri.UriParser;
-import org.apache.olingo.odata2.core.ODataRequestImpl;
-import org.apache.olingo.odata2.core.ODataResponseImpl;
-import org.apache.olingo.odata2.core.batch.BatchChangeSetImpl;
-import org.apache.olingo.odata2.core.batch.BatchChangeSetPartImpl;
-import org.apache.olingo.odata2.core.batch.BatchQueryPartImpl;
-import org.apache.olingo.odata2.core.batch.BatchResponsePartImpl;
-import org.apache.olingo.odata2.core.edm.EdmSimpleTypeFacadeImpl;
-import org.apache.olingo.odata2.core.edm.provider.EdmImplProv;
-import org.apache.olingo.odata2.core.edm.provider.EdmxProvider;
-import org.apache.olingo.odata2.core.ep.ProviderFacadeImpl;
-import org.apache.olingo.odata2.core.processor.ODataSingleProcessorService;
-import org.apache.olingo.odata2.core.uri.UriParserImpl;
-
-/**
- *
- */
-public class RuntimeDelegateImpl extends RuntimeDelegateInstance {
-
- @Override
- protected ODataResponseBuilder createODataResponseBuilder() {
- ODataResponseImpl r = new ODataResponseImpl();
- return r.new ODataResponseBuilderImpl();
- }
-
- @Override
- protected EdmSimpleType getEdmSimpleType(final EdmSimpleTypeKind edmSimpleType) {
- return EdmSimpleTypeFacadeImpl.getEdmSimpleType(edmSimpleType);
- }
-
- @Override
- protected UriParser getUriParser(final Edm edm) {
- return new UriParserImpl(edm);
- }
-
- @Override
- protected EdmSimpleTypeFacade getSimpleTypeFacade() {
- return new EdmSimpleTypeFacadeImpl();
- }
-
- @Override
- protected Edm createEdm(final EdmProvider provider) {
- return new EdmImplProv(provider);
- }
-
- @Override
- protected EntityProviderInterface createEntityProvider() {
- return new ProviderFacadeImpl();
- }
-
- @Override
- protected ODataService createODataSingleProcessorService(final EdmProvider provider,
- final ODataSingleProcessor processor) {
- return new ODataSingleProcessorService(provider, processor);
- }
-
- @Override
- protected EdmProvider createEdmProvider(final InputStream metadataXml, final boolean validate)
- throws EntityProviderException {
- return new EdmxProvider().parse(metadataXml, validate);
- }
-
- @Override
- protected BatchResponsePartBuilder createBatchResponsePartBuilder() {
- BatchResponsePartImpl part = new BatchResponsePartImpl();
- return part.new BatchResponsePartBuilderImpl();
- }
-
- @Override
- protected ODataRequestBuilder createODataRequestBuilder() {
- ODataRequestImpl request = new ODataRequestImpl();
- return request.new ODataRequestBuilderImpl();
- }
-
- @Override
- protected BatchChangeSetBuilder createBatchChangeSetBuilder() {
- BatchChangeSetImpl changeSet = new BatchChangeSetImpl();
- return changeSet.new BatchChangeSetBuilderImpl();
- }
-
- @Override
- protected BatchQueryPartBuilder createBatchQueryRequestBuilder() {
- BatchQueryPartImpl batchQueryRequest = new BatchQueryPartImpl();
- return batchQueryRequest.new BatchQueryRequestBuilderImpl();
- }
-
- @Override
- protected BatchChangeSetPartBuilder createBatchChangeSetRequest() {
- BatchChangeSetPartImpl batchChangeSetRequest = new BatchChangeSetPartImpl();
- ;
- return batchChangeSetRequest.new BatchChangeSetRequestBuilderImpl();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/servicedocument/AcceptImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/servicedocument/AcceptImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/servicedocument/AcceptImpl.java
deleted file mode 100644
index 9f3fa65..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/servicedocument/AcceptImpl.java
+++ /dev/null
@@ -1,50 +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.odata2.core.servicedocument;
-
-import org.apache.olingo.odata2.api.servicedocument.Accept;
-import org.apache.olingo.odata2.api.servicedocument.CommonAttributes;
-
-/**
- *
- */
-public class AcceptImpl implements Accept {
- private String value;
- private CommonAttributes commonAttributes;
-
- @Override
- public String getValue() {
- return value;
- }
-
- @Override
- public CommonAttributes getCommonAttributes() {
- return commonAttributes;
- }
-
- public AcceptImpl setText(final String text) {
- value = text;
- return this;
- }
-
- public AcceptImpl setCommonAttributes(final CommonAttributes commonAttributes) {
- this.commonAttributes = commonAttributes;
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/servicedocument/AtomInfoImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/servicedocument/AtomInfoImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/servicedocument/AtomInfoImpl.java
deleted file mode 100644
index 5f5080d..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/servicedocument/AtomInfoImpl.java
+++ /dev/null
@@ -1,100 +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.odata2.core.servicedocument;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.Edm;
-import org.apache.olingo.odata2.api.edm.EdmEntitySetInfo;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.ep.EntityProviderException;
-import org.apache.olingo.odata2.api.servicedocument.AtomInfo;
-import org.apache.olingo.odata2.api.servicedocument.Collection;
-import org.apache.olingo.odata2.api.servicedocument.CommonAttributes;
-import org.apache.olingo.odata2.api.servicedocument.ExtensionElement;
-import org.apache.olingo.odata2.api.servicedocument.Workspace;
-import org.apache.olingo.odata2.core.edm.provider.EdmEntitySetInfoImplProv;
-
-/**
- *
- */
-public class AtomInfoImpl implements AtomInfo {
- private List<Workspace> workspaces;
- private CommonAttributes attributes;
- private List<ExtensionElement> extensionElements;
-
- @Override
- public CommonAttributes getCommonAttributes() {
- return attributes;
- }
-
- @Override
- public List<Workspace> getWorkspaces() {
- return workspaces;
- }
-
- @Override
- public List<ExtensionElement> getExtesionElements() {
- return extensionElements;
- }
-
- public AtomInfoImpl setWorkspaces(final List<Workspace> workspaces) {
- this.workspaces = workspaces;
- return this;
- }
-
- public AtomInfoImpl setCommonAttributes(final CommonAttributes attributes) {
- this.attributes = attributes;
- return this;
- }
-
- public AtomInfoImpl setExtesionElements(final List<ExtensionElement> elements) {
- extensionElements = elements;
- return this;
- }
-
- public List<EdmEntitySetInfo> getEntitySetsInfo() throws EntityProviderException {
- List<EdmEntitySetInfo> entitySets = new ArrayList<EdmEntitySetInfo>();
- for (Workspace workspace : workspaces) {
- for (Collection collection : workspace.getCollections()) {
- String[] names = collection.getHref().split("\\" + Edm.DELIMITER + "(?=[^" + Edm.DELIMITER + "]+$)");
- try {
- if (names.length == 1) {
- EntitySet entitySet = new EntitySet().setName(names[0]);
- EntityContainerInfo container = new EntityContainerInfo().setDefaultEntityContainer(true);
- EdmEntitySetInfo entitySetInfo = new EdmEntitySetInfoImplProv(entitySet, container);
- entitySets.add(entitySetInfo);
- } else if (names.length == 2) {
- EntitySet entitySet = new EntitySet().setName(names[1]);
- EntityContainerInfo container =
- new EntityContainerInfo().setName(names[0]).setDefaultEntityContainer(false);
- EdmEntitySetInfo entitySetInfo = new EdmEntitySetInfoImplProv(entitySet, container);
- entitySets.add(entitySetInfo);
- }
- } catch (EdmException e) {
- throw new EntityProviderException(EntityProviderException.COMMON, e);
- }
- }
- }
- return entitySets;
- }
-}