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:50 UTC

[23/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/ODataRequestImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestImpl.java
deleted file mode 100644
index dd3173b..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestImpl.java
+++ /dev/null
@@ -1,198 +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;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.commons.ODataHttpMethod;
-import org.apache.olingo.odata2.api.processor.ODataRequest;
-import org.apache.olingo.odata2.api.uri.PathInfo;
-import org.apache.olingo.odata2.core.commons.ContentType;
-
-/**
- *  
- */
-public class ODataRequestImpl extends ODataRequest {
-
-  private ODataHttpMethod method;
-  private Map<String, List<String>> requestHeaders = new HashMap<String, List<String>>();
-  private InputStream body;
-  private PathInfo pathInfo;
-  private Map<String, String> queryParameters;
-  private List<String> acceptHeaders;
-  private ContentType contentType;
-  private List<Locale> acceptableLanguages;
-
-  @Override
-  public Map<String, String> getQueryParameters() {
-    return queryParameters;
-  }
-
-  @Override
-  public List<String> getAcceptHeaders() {
-    return acceptHeaders;
-  }
-
-  @Override
-  public String getContentType() {
-    return contentType == null ? null : contentType.toContentTypeString();
-  }
-
-  @Override
-  public List<Locale> getAcceptableLanguages() {
-    return acceptableLanguages;
-  }
-
-  @Override
-  public String getRequestHeaderValue(final String name) {
-    final List<String> headerList = requestHeaders.get(name);
-    return headerList == null || headerList.isEmpty() ? null : headerList.get(0);
-  }
-
-  @Override
-  public Map<String, List<String>> getRequestHeaders() {
-    return Collections.unmodifiableMap(requestHeaders);
-  }
-
-  @Override
-  public InputStream getBody() {
-    return body;
-  }
-
-  @Override
-  public ODataHttpMethod getMethod() {
-    return method;
-  }
-
-  @Override
-  public PathInfo getPathInfo() {
-    return pathInfo;
-  }
-
-  public class ODataRequestBuilderImpl extends ODataRequestBuilder {
-    private ODataHttpMethod method;
-    private Map<String, List<String>> requestHeaders = new HashMap<String, List<String>>();
-    private InputStream body;
-    private PathInfo pathInfo;
-    private Map<String, String> queryParameters;
-    private List<String> acceptHeaders;
-    private ContentType contentType;
-    private List<Locale> acceptableLanguages;
-
-    @Override
-    public ODataRequest build() {
-      ODataRequestImpl.this.method = method;
-      ODataRequestImpl.this.requestHeaders = requestHeaders;
-      ODataRequestImpl.this.body = body;
-      ODataRequestImpl.this.pathInfo = pathInfo;
-      ODataRequestImpl.this.queryParameters = queryParameters;
-      ODataRequestImpl.this.acceptHeaders = acceptHeaders;
-      ODataRequestImpl.this.contentType = contentType;
-      ODataRequestImpl.this.acceptableLanguages = acceptableLanguages;
-      return ODataRequestImpl.this;
-    }
-
-    @Override
-    public ODataRequestBuilder requestHeaders(final Map<String, List<String>> headers) {
-      requestHeaders = headers;
-      return this;
-    }
-
-    @Override
-    public ODataRequestBuilder body(final InputStream body) {
-      this.body = body;
-      return this;
-    }
-
-    @Override
-    public ODataRequestBuilder pathInfo(final PathInfo pathInfo) {
-      this.pathInfo = pathInfo;
-      return this;
-    }
-
-    @Override
-    public ODataRequestBuilder method(final ODataHttpMethod method) {
-      this.method = method;
-      return this;
-    }
-
-    @Override
-    public ODataRequestBuilder acceptableLanguages(final List<Locale> acceptableLanguages) {
-      this.acceptableLanguages = acceptableLanguages;
-      return this;
-    }
-
-    @Override
-    public ODataRequestBuilder acceptHeaders(final List<String> acceptHeaders) {
-      this.acceptHeaders = acceptHeaders;
-      return this;
-    }
-
-    @Override
-    public ODataRequestBuilder queryParameters(final Map<String, String> queryParameters) {
-      this.queryParameters = queryParameters;
-      return this;
-    }
-
-    @Override
-    public ODataRequestBuilder contentType(final String contentType) {
-      this.contentType = ContentType.create(contentType);
-      return this;
-    }
-
-    @Override
-    public ODataRequestBuilder fromRequest(final ODataRequest request) {
-      pathInfo = request.getPathInfo();
-      method = request.getMethod();
-      body = request.getBody();
-      if (request.getContentType() != null) {
-        contentType = ContentType.create(request.getContentType());
-      }
-      requestHeaders = request.getRequestHeaders();
-
-      if (request.getAcceptHeaders() != null) {
-        acceptHeaders = new ArrayList<String>();
-        for (String acceptHeader : request.getAcceptHeaders()) {
-          acceptHeaders.add(acceptHeader);
-        }
-      }
-      if (request.getAcceptableLanguages() != null) {
-        acceptableLanguages = new ArrayList<Locale>();
-        for (Locale acceptLanguage : request.getAcceptableLanguages()) {
-          acceptableLanguages.add(acceptLanguage);
-        }
-      }
-      if (request.getQueryParameters() != null) {
-        queryParameters = new HashMap<String, String>();
-        for (Map.Entry<String, String> queryParameter : request.getQueryParameters().entrySet()) {
-          String queryParameterName = queryParameter.getKey();
-          queryParameters.put(queryParameterName, queryParameter.getValue());
-        }
-      }
-      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/ODataResponseImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataResponseImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataResponseImpl.java
deleted file mode 100644
index f332726..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataResponseImpl.java
+++ /dev/null
@@ -1,160 +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;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Set;
-
-import org.apache.olingo.odata2.api.commons.HttpHeaders;
-import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-
-/**
- *  
- */
-public class ODataResponseImpl extends ODataResponse {
-
-  private HttpStatusCodes status;
-  private Object entity;
-  private HashMap<String, String> headers;
-
-  @Override
-  public HttpStatusCodes getStatus() {
-    return status;
-  }
-
-  @Override
-  public Object getEntity() {
-    return entity;
-  }
-
-  @Override
-  public void close() throws IOException {
-    if (entity != null && entity instanceof Closeable) {
-      Closeable closeableEntity = (Closeable) entity;
-      closeableEntity.close();
-    }
-  }
-
-  @Override
-  public String getHeader(final String name) {
-    return headers.get(name);
-  }
-
-  @Override
-  public Set<String> getHeaderNames() {
-    return headers.keySet();
-  }
-
-  @Override
-  public String getIdLiteral() {
-    return headers.get(HttpHeaders.LOCATION);
-  }
-
-  @Override
-  public String getETag() {
-    return headers.get(HttpHeaders.ETAG);
-  }
-
-  @Override
-  public String getContentHeader() {
-    return headers.get(HttpHeaders.CONTENT_TYPE);
-  }
-
-  @Override
-  public boolean containsHeader(final String header) {
-    boolean contains = false;
-    for (String containedHeader : headers.keySet()) {
-      if (containedHeader.equalsIgnoreCase(header)) {
-        contains = true;
-        break;
-      }
-    }
-    return contains;
-  }
-
-  public class ODataResponseBuilderImpl extends ODataResponseBuilder {
-    private HttpStatusCodes status;
-    private Object entity;
-    private HashMap<String, String> headers = new HashMap<String, String>();
-
-    @Override
-    public ODataResponse build() {
-      ODataResponseImpl.this.status = status;
-      ODataResponseImpl.this.entity = entity;
-      ODataResponseImpl.this.headers = headers;
-
-      return ODataResponseImpl.this;
-    }
-
-    @Override
-    public ODataResponseBuilder status(final HttpStatusCodes status) {
-      this.status = status;
-      return this;
-    }
-
-    @Override
-    public ODataResponseBuilder entity(final Object entity) {
-      this.entity = entity;
-      return this;
-    }
-
-    @Override
-    public ODataResponseBuilder header(final String name, final String value) {
-      if (value == null) {
-        headers.remove(name);
-      } else {
-        headers.put(name, value);
-      }
-
-      return this;
-    }
-
-    @Override
-    public ODataResponseBuilder idLiteral(final String idLiteral) {
-      return header(HttpHeaders.LOCATION, idLiteral);
-    }
-
-    @Override
-    public ODataResponseBuilder eTag(final String eTag) {
-      return header(HttpHeaders.ETAG, eTag);
-    }
-
-    @Override
-    public ODataResponseBuilder contentHeader(final String value) {
-      return header(HttpHeaders.CONTENT_TYPE, value);
-    }
-
-    @Override
-    protected ODataResponseBuilder fromResponse(final ODataResponse response) {
-      status = response.getStatus();
-      entity = response.getEntity();
-
-      headers = new HashMap<String, String>();
-      for (String key : response.getHeaderNames()) {
-        headers.put(key, response.getHeader(key));
-      }
-
-      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/PathInfoImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/PathInfoImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/PathInfoImpl.java
deleted file mode 100644
index 85000cc..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/PathInfoImpl.java
+++ /dev/null
@@ -1,73 +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;
-
-import java.net.URI;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.uri.PathInfo;
-import org.apache.olingo.odata2.api.uri.PathSegment;
-
-/**
- *  
- */
-public class PathInfoImpl implements PathInfo {
-
-  private List<PathSegment> precedingPathSegment = Collections.emptyList();
-  private List<PathSegment> odataPathSegment = Collections.emptyList();
-  private URI serviceRoot;
-  private URI requestUri;
-
-  public void setODataPathSegment(final List<PathSegment> odataPathSegement) {
-    odataPathSegment = odataPathSegement;
-  }
-
-  public void setPrecedingPathSegment(final List<PathSegment> precedingPathSegement) {
-    precedingPathSegment = precedingPathSegement;
-  }
-
-  public void setServiceRoot(final URI uri) {
-    serviceRoot = uri;
-  }
-
-  @Override
-  public List<PathSegment> getPrecedingSegments() {
-    return Collections.unmodifiableList(precedingPathSegment);
-  }
-
-  @Override
-  public List<PathSegment> getODataSegments() {
-    return Collections.unmodifiableList(odataPathSegment);
-  }
-
-  @Override
-  public URI getServiceRoot() {
-    return serviceRoot;
-  }
-
-  @Override
-  public URI getRequestUri() {
-    return requestUri;
-  }
-
-  public void setRequestUri(final URI requestUri) {
-    this.requestUri = requestUri;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/AcceptParser.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/AcceptParser.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/AcceptParser.java
deleted file mode 100644
index d56e13e..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/AcceptParser.java
+++ /dev/null
@@ -1,175 +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.batch;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Scanner;
-import java.util.TreeSet;
-import java.util.regex.MatchResult;
-import java.util.regex.Pattern;
-
-import org.apache.olingo.odata2.api.batch.BatchException;
-
-/**
- *  
- */
-public class AcceptParser {
-
-  private static final String BAD_REQUEST = "400";
-  private static final String ALL = "*";
-  private static final String REG_EX_QUALITY_FACTOR = "q=((?:1\\.0{0,3})|(?:0\\.[0-9]{0,2}[1-9]))";
-  private static final String REG_EX_OPTIONAL_WHITESPACE = "\\s?";
-  private static final Pattern REG_EX_ACCEPT = Pattern.compile("([a-z\\*]+/[a-z0-9\\+\\*\\-=;\\s]+)");
-  private static final Pattern REG_EX_ACCEPT_WITH_Q_FACTOR = Pattern.compile(REG_EX_ACCEPT + "(?:;"
-      + REG_EX_OPTIONAL_WHITESPACE + REG_EX_QUALITY_FACTOR + ")?");
-  private static final Pattern REG_EX_ACCEPT_LANGUAGES = Pattern
-      .compile("((?:(?:[a-z]{1,8})|(?:\\*))\\-?(?:[a-zA-Z]{1,8})?)");
-  private static final Pattern REG_EX_ACCEPT_LANGUAGES_WITH_Q_FACTOR = Pattern.compile(REG_EX_ACCEPT_LANGUAGES + "(?:;"
-      + REG_EX_OPTIONAL_WHITESPACE + REG_EX_QUALITY_FACTOR + ")?");
-
-  private static final double QUALITY_PARAM_FACTOR = 0.001;
-
-  public static List<String> parseAcceptHeaders(final String headerValue) throws BatchException {
-    TreeSet<Accept> acceptTree = getAcceptTree();
-    List<String> acceptHeaders = new ArrayList<String>();
-    Scanner acceptHeaderScanner = new Scanner(headerValue).useDelimiter(",\\s?");
-    while (acceptHeaderScanner.hasNext()) {
-      if (acceptHeaderScanner.hasNext(REG_EX_ACCEPT_WITH_Q_FACTOR)) {
-        acceptHeaderScanner.next(REG_EX_ACCEPT_WITH_Q_FACTOR);
-        MatchResult result = acceptHeaderScanner.match();
-        if (result.groupCount() == 2) {
-          String acceptHeaderValue = result.group(1);
-          double qualityFactor = result.group(2) != null ? Double.parseDouble(result.group(2)) : 1d;
-          qualityFactor = getQualityFactor(acceptHeaderValue, qualityFactor);
-          Accept acceptHeader = new Accept().setQuality(qualityFactor).setValue(acceptHeaderValue);
-          acceptTree.add(acceptHeader);
-        } else {
-          String header = acceptHeaderScanner.next();
-          acceptHeaderScanner.close();
-          throw new BatchException(BatchException.INVALID_ACCEPT_HEADER.addContent(header), BAD_REQUEST);
-        }
-      } else {
-        String header = acceptHeaderScanner.next();
-        acceptHeaderScanner.close();
-        throw new BatchException(BatchException.INVALID_ACCEPT_HEADER.addContent(header), BAD_REQUEST);
-      }
-    }
-    for (Accept accept : acceptTree) {
-      acceptHeaders.add(accept.getValue());
-    }
-    acceptHeaderScanner.close();
-    return acceptHeaders;
-  }
-
-  private static double getQualityFactor(final String acceptHeaderValue, double qualityFactor) {
-    int paramNumber = 0;
-    double typeFactor = 0.0;
-    double subtypeFactor = 0.0;
-    String[] mediaRange = acceptHeaderValue.split("(?=[^;]+);");
-    String[] mediaTypes = mediaRange[0].split("/");
-    if (mediaTypes.length == 2) {
-      String type = mediaTypes[0];
-      String subtype = mediaTypes[1];
-      if (!ALL.equals(type)) {
-        typeFactor = 0.001;
-      }
-      if (!ALL.equals(subtype)) {
-        subtypeFactor = 0.001;
-      }
-    }
-    if (mediaRange.length == 2) {
-      String[] parameters = mediaRange[1].split(";\\s?");
-      paramNumber = parameters.length;
-    }
-    qualityFactor = qualityFactor + paramNumber * QUALITY_PARAM_FACTOR + typeFactor + subtypeFactor;
-    return qualityFactor;
-  }
-
-  public static List<String> parseAcceptableLanguages(final String headerValue) throws BatchException {
-    List<String> acceptLanguages = new LinkedList<String>();
-    TreeSet<Accept> acceptTree = getAcceptTree();
-    Scanner acceptLanguageScanner = new Scanner(headerValue).useDelimiter(",\\s?");
-    while (acceptLanguageScanner.hasNext()) {
-      if (acceptLanguageScanner.hasNext(REG_EX_ACCEPT_LANGUAGES_WITH_Q_FACTOR)) {
-        acceptLanguageScanner.next(REG_EX_ACCEPT_LANGUAGES_WITH_Q_FACTOR);
-        MatchResult result = acceptLanguageScanner.match();
-        if (result.groupCount() == 2) {
-          String languagerange = result.group(1);
-          double qualityFactor = result.group(2) != null ? Double.parseDouble(result.group(2)) : 1d;
-          acceptTree.add(new Accept().setQuality(qualityFactor).setValue(languagerange));
-        } else {
-          String acceptLanguage = acceptLanguageScanner.next();
-          acceptLanguageScanner.close();
-          throw new BatchException(BatchException.INVALID_ACCEPT_LANGUAGE_HEADER.addContent(acceptLanguage),
-              BAD_REQUEST);
-        }
-      } else {
-        String acceptLanguage = acceptLanguageScanner.next();
-        acceptLanguageScanner.close();
-        throw new BatchException(BatchException.INVALID_ACCEPT_LANGUAGE_HEADER.addContent(acceptLanguage), BAD_REQUEST);
-      }
-    }
-    for (Accept accept : acceptTree) {
-      acceptLanguages.add(accept.getValue());
-    }
-    acceptLanguageScanner.close();
-    return acceptLanguages;
-  }
-
-  private static TreeSet<Accept> getAcceptTree() {
-    TreeSet<Accept> treeSet = new TreeSet<Accept>(new Comparator<Accept>() {
-      @Override
-      public int compare(final Accept o1, final Accept o2) {
-        if (o1.getQuality() <= o2.getQuality()) {
-          return 1;
-        } else {
-          return -1;
-        }
-      }
-    });
-    return treeSet;
-  }
-
-  private static class Accept {
-    private double quality;
-    private String value;
-
-    public String getValue() {
-      return value;
-    }
-
-    public Accept setValue(final String value) {
-      this.value = value;
-      return this;
-    }
-
-    public double getQuality() {
-      return quality;
-    }
-
-    public Accept setQuality(final double quality) {
-      this.quality = quality;
-      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/batch/BatchChangeSetImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchChangeSetImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchChangeSetImpl.java
deleted file mode 100644
index 2a0c1ce..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchChangeSetImpl.java
+++ /dev/null
@@ -1,49 +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.batch;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.client.batch.BatchChangeSet;
-import org.apache.olingo.odata2.api.client.batch.BatchChangeSetPart;
-
-public class BatchChangeSetImpl extends BatchChangeSet {
-  private List<BatchChangeSetPart> requests = new ArrayList<BatchChangeSetPart>();
-
-  @Override
-  public void add(final BatchChangeSetPart request) {
-    requests.add(request);
-  }
-
-  @Override
-  public List<BatchChangeSetPart> getChangeSetParts() {
-    return Collections.unmodifiableList(requests);
-  }
-
-  public class BatchChangeSetBuilderImpl extends BatchChangeSetBuilder {
-
-    @Override
-    public BatchChangeSet build() {
-      return BatchChangeSetImpl.this;
-    }
-
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchChangeSetPartImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchChangeSetPartImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchChangeSetPartImpl.java
deleted file mode 100644
index 6adcf63..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchChangeSetPartImpl.java
+++ /dev/null
@@ -1,116 +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.batch;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.client.batch.BatchChangeSetPart;
-
-public class BatchChangeSetPartImpl extends BatchChangeSetPart {
-  private String method;
-  private Map<String, String> headers = new HashMap<String, String>();
-  private String body;
-  private String uri;
-  public String contentId;
-  private static final String CHANGE_METHODS = "(PUT|POST|DELETE|MERGE|PATCH)";
-
-  @Override
-  public Map<String, String> getHeaders() {
-    return Collections.unmodifiableMap(headers);
-  }
-
-  @Override
-  public String getBody() {
-    return body;
-  }
-
-  @Override
-  public String getMethod() {
-    return method;
-  }
-
-  @Override
-  public String getUri() {
-    return uri;
-  }
-
-  @Override
-  public String getContentId() {
-    return contentId;
-  }
-
-  public class BatchChangeSetRequestBuilderImpl extends BatchChangeSetPartBuilder {
-    private String method;
-    private Map<String, String> headers = new HashMap<String, String>();
-    private String body;
-    private String uri;
-    private String contentId;
-
-    @Override
-    public BatchChangeSetPart build() {
-      if (method == null || uri == null) {
-        throw new IllegalArgumentException();
-      }
-      BatchChangeSetPartImpl.this.method = method;
-      BatchChangeSetPartImpl.this.headers = headers;
-      BatchChangeSetPartImpl.this.body = body;
-      BatchChangeSetPartImpl.this.uri = uri;
-      BatchChangeSetPartImpl.this.contentId = contentId;
-      return BatchChangeSetPartImpl.this;
-    }
-
-    @Override
-    public BatchChangeSetPartBuilder headers(final Map<String, String> headers) {
-      this.headers = headers;
-      return this;
-    }
-
-    @Override
-    public BatchChangeSetPartBuilder body(final String body) {
-      this.body = body;
-      return this;
-    }
-
-    @Override
-    public BatchChangeSetPartBuilder uri(final String uri) {
-      this.uri = uri;
-      return this;
-    }
-
-    @Override
-    public BatchChangeSetPartBuilder method(final String method) {
-      if (method != null && method.matches(CHANGE_METHODS)) {
-        this.method = method;
-      } else {
-        throw new IllegalArgumentException();
-      }
-      return this;
-    }
-
-    @Override
-    public BatchChangeSetPartBuilder contentId(final String contentId) {
-      this.contentId = contentId;
-      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/batch/BatchHandlerImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHandlerImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHandlerImpl.java
deleted file mode 100644
index d2d4cee..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHandlerImpl.java
+++ /dev/null
@@ -1,187 +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.batch;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.ODataService;
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.batch.BatchHandler;
-import org.apache.olingo.odata2.api.batch.BatchRequestPart;
-import org.apache.olingo.odata2.api.batch.BatchResponsePart;
-import org.apache.olingo.odata2.api.commons.HttpHeaders;
-import org.apache.olingo.odata2.api.commons.ODataHttpMethod;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataRequest;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.api.uri.PathSegment;
-import org.apache.olingo.odata2.core.ODataContextImpl;
-import org.apache.olingo.odata2.core.ODataPathSegmentImpl;
-import org.apache.olingo.odata2.core.ODataRequestHandler;
-import org.apache.olingo.odata2.core.PathInfoImpl;
-
-public class BatchHandlerImpl implements BatchHandler {
-  private static final int BAD_REQUEST = 400;
-  private ODataServiceFactory factory;
-  private ODataService service;
-  private Map<String, String> contentIdMap;
-
-  public BatchHandlerImpl(final ODataServiceFactory factory, final ODataService service) {
-    this.factory = factory;
-    this.service = service;
-  }
-
-  @Override
-  public BatchResponsePart handleBatchPart(final BatchRequestPart batchPart) throws ODataException {
-    if (batchPart.isChangeSet()) {
-      List<ODataRequest> changeSetRequests = batchPart.getRequests();
-      contentIdMap = new HashMap<String, String>();
-      return service.getBatchProcessor().executeChangeSet(this, changeSetRequests);
-    } else {
-      if (batchPart.getRequests().size() != 1) {
-        throw new ODataException("Query Operation should contain one request");
-      }
-      ODataRequest request = batchPart.getRequests().get(0);
-      ODataRequestHandler handler = createHandler(request);
-      String mimeHeaderContentId =
-          request.getRequestHeaderValue(BatchHelper.MIME_HEADER_CONTENT_ID.toLowerCase(Locale.ENGLISH));
-      String requestHeaderContentId =
-          request.getRequestHeaderValue(BatchHelper.REQUEST_HEADER_CONTENT_ID.toLowerCase(Locale.ENGLISH));
-      ODataResponse response = setContentIdHeader(handler.handle(request), mimeHeaderContentId, requestHeaderContentId);
-      List<ODataResponse> responses = new ArrayList<ODataResponse>(1);
-      responses.add(response);
-      return BatchResponsePart.responses(responses).changeSet(false).build();
-    }
-  }
-
-  @Override
-  public ODataResponse handleRequest(final ODataRequest suppliedRequest) throws ODataException {
-    ODataRequest request;
-    String mimeHeaderContentId =
-        suppliedRequest.getRequestHeaderValue(BatchHelper.MIME_HEADER_CONTENT_ID.toLowerCase(Locale.ENGLISH));
-    String requestHeaderContentId =
-        suppliedRequest.getRequestHeaderValue(BatchHelper.REQUEST_HEADER_CONTENT_ID.toLowerCase(Locale.ENGLISH));
-
-    List<PathSegment> odataSegments = suppliedRequest.getPathInfo().getODataSegments();
-    if (!odataSegments.isEmpty() && odataSegments.get(0).getPath().matches("\\$.*")) {
-      request = modifyRequest(suppliedRequest, odataSegments);
-    } else {
-      request = suppliedRequest;
-    }
-    ODataRequestHandler handler = createHandler(request);
-    ODataResponse response = handler.handle(request);
-    if (response.getStatus().getStatusCode() < BAD_REQUEST) {
-      response = setContentIdHeader(response, mimeHeaderContentId, requestHeaderContentId);
-    }
-    if (request.getMethod().equals(ODataHttpMethod.POST)) {
-      String baseUri = getBaseUri(request);
-      if (mimeHeaderContentId != null) {
-        fillContentIdMap(response, mimeHeaderContentId, baseUri);
-      } else if (requestHeaderContentId != null) {
-        fillContentIdMap(response, requestHeaderContentId, baseUri);
-      }
-    }
-    return response;
-  }
-
-  private void fillContentIdMap(final ODataResponse response, final String contentId, final String baseUri) {
-    String location = response.getHeader(HttpHeaders.LOCATION);
-    String relLocation = location.replace(baseUri + "/", "");
-    contentIdMap.put("$" + contentId, relLocation);
-  }
-
-  private ODataRequest modifyRequest(final ODataRequest request, final List<PathSegment> odataSegments)
-      throws ODataException {
-    String contentId = contentIdMap.get(odataSegments.get(0).getPath());
-    PathInfoImpl pathInfo = new PathInfoImpl();
-    try {
-      List<PathSegment> modifiedODataSegments = new ArrayList<PathSegment>();
-      String[] segments = contentId.split("/");
-      for (String segment : segments) {
-        modifiedODataSegments.add(new ODataPathSegmentImpl(segment, null));
-      }
-      String newRequestUri = getBaseUri(request);
-      newRequestUri += "/" + contentId;
-      for (int i = 1; i < odataSegments.size(); i++) {
-        newRequestUri += "/" + odataSegments.get(i).getPath();
-        modifiedODataSegments.add(odataSegments.get(i));
-      }
-      for (Map.Entry<String, String> entry : request.getQueryParameters().entrySet()) {
-        newRequestUri += "/" + entry;
-      }
-
-      pathInfo.setServiceRoot(request.getPathInfo().getServiceRoot());
-      pathInfo.setPrecedingPathSegment(request.getPathInfo().getPrecedingSegments());
-      pathInfo.setRequestUri(new URI(newRequestUri));
-      pathInfo.setODataPathSegment(modifiedODataSegments);
-    } catch (URISyntaxException e) {
-      throw new ODataException(e);
-    }
-    ODataRequest modifiedRequest = ODataRequest.fromRequest(request).pathInfo(pathInfo).build();
-    return modifiedRequest;
-  }
-
-  private ODataResponse setContentIdHeader(final ODataResponse response, final String mimeHeaderContentId,
-      final String requestHeaderContentId) {
-    ODataResponse modifiedResponse;
-    if (requestHeaderContentId != null && mimeHeaderContentId != null) {
-      modifiedResponse =
-          ODataResponse.fromResponse(response).header(BatchHelper.REQUEST_HEADER_CONTENT_ID, requestHeaderContentId)
-              .header(BatchHelper.MIME_HEADER_CONTENT_ID, mimeHeaderContentId).build();
-    } else if (requestHeaderContentId != null) {
-      modifiedResponse =
-          ODataResponse.fromResponse(response).header(BatchHelper.REQUEST_HEADER_CONTENT_ID, requestHeaderContentId)
-              .build();
-    } else if (mimeHeaderContentId != null) {
-      modifiedResponse =
-          ODataResponse.fromResponse(response).header(BatchHelper.MIME_HEADER_CONTENT_ID, mimeHeaderContentId).build();
-    } else {
-      return response;
-    }
-    return modifiedResponse;
-  }
-
-  private String getBaseUri(final ODataRequest request) {
-    String baseUri = request.getPathInfo().getServiceRoot().toASCIIString();
-    if (baseUri.endsWith("/")) {
-      baseUri = baseUri.substring(0, baseUri.length() - 1);
-    }
-    for (PathSegment segment : request.getPathInfo().getPrecedingSegments()) {
-      baseUri += "/" + segment.getPath();
-    }
-    return baseUri;
-  }
-
-  private ODataRequestHandler createHandler(final ODataRequest request) throws ODataException {
-    ODataContextImpl context = new ODataContextImpl(request, factory);
-    ODataContext parentContext = service.getProcessor().getContext();
-    context.setBatchParentContext(parentContext);
-    context.setService(service);
-    service.getProcessor().setContext(context);
-    return new ODataRequestHandler(factory, service, context);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHelper.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHelper.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHelper.java
deleted file mode 100644
index 3a64288..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHelper.java
+++ /dev/null
@@ -1,51 +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.batch;
-
-import java.io.UnsupportedEncodingException;
-import java.util.UUID;
-
-import org.apache.olingo.odata2.core.exception.ODataRuntimeException;
-
-public class BatchHelper {
-
-  public static final String BINARY_ENCODING = "binary";
-
-  public static final String DEFAULT_ENCODING = "utf-8";
-
-  public static final String HTTP_CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
-
-  public static final String HTTP_CONTENT_ID = "Content-Id";
-
-  public static final String MIME_HEADER_CONTENT_ID = "MimeHeader-ContentId";
-
-  public static final String REQUEST_HEADER_CONTENT_ID = "RequestHeader-ContentId";
-
-  protected static String generateBoundary(final String value) {
-    return value + "_" + UUID.randomUUID().toString();
-  }
-
-  protected static byte[] getBytes(final String body) {
-    try {
-      return body.getBytes(DEFAULT_ENCODING);
-    } catch (UnsupportedEncodingException e) {
-      throw new ODataRuntimeException(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchQueryPartImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchQueryPartImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchQueryPartImpl.java
deleted file mode 100644
index 4833f9f..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchQueryPartImpl.java
+++ /dev/null
@@ -1,102 +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.batch;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.client.batch.BatchQueryPart;
-
-public class BatchQueryPartImpl extends BatchQueryPart {
-  private String method;
-  private Map<String, String> headers = new HashMap<String, String>();
-  private String uri;
-  private String contentId;
-  private static final String GET = "GET";
-
-  @Override
-  public Map<String, String> getHeaders() {
-    return Collections.unmodifiableMap(headers);
-  }
-
-  @Override
-  public String getMethod() {
-    return method;
-  }
-
-  @Override
-  public String getUri() {
-    return uri;
-  }
-
-  @Override
-  public String getContentId() {
-    return contentId;
-  }
-
-  public class BatchQueryRequestBuilderImpl extends BatchQueryPartBuilder {
-    private String method;
-    private Map<String, String> headers = new HashMap<String, String>();
-    private String uri;
-    private String contentId;
-
-    @Override
-    public BatchQueryPart build() {
-      if (method == null || uri == null) {
-        throw new IllegalArgumentException();
-      }
-      BatchQueryPartImpl.this.method = method;
-      BatchQueryPartImpl.this.headers = headers;
-      BatchQueryPartImpl.this.uri = uri;
-      BatchQueryPartImpl.this.contentId = contentId;
-      return BatchQueryPartImpl.this;
-    }
-
-    @Override
-    public BatchQueryPartBuilder headers(final Map<String, String> headers) {
-      this.headers = headers;
-      return this;
-    }
-
-    @Override
-    public BatchQueryPartBuilder uri(final String uri) {
-      this.uri = uri;
-      return this;
-    }
-
-    @Override
-    public BatchQueryPartBuilder method(final String method) {
-      if (method != null && method.matches(GET)) {
-        this.method = method;
-      } else {
-        throw new IllegalArgumentException();
-      }
-      return this;
-    }
-
-    @Override
-    public BatchQueryPartBuilder contentId(final String contentId) {
-      this.contentId = contentId;
-      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/batch/BatchRequestParser.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestParser.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestParser.java
deleted file mode 100644
index 2404ad8..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestParser.java
+++ /dev/null
@@ -1,598 +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.batch;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Scanner;
-import java.util.Set;
-import java.util.regex.MatchResult;
-import java.util.regex.Pattern;
-
-import org.apache.olingo.odata2.api.batch.BatchException;
-import org.apache.olingo.odata2.api.batch.BatchRequestPart;
-import org.apache.olingo.odata2.api.commons.HttpContentType;
-import org.apache.olingo.odata2.api.commons.HttpHeaders;
-import org.apache.olingo.odata2.api.commons.ODataHttpMethod;
-import org.apache.olingo.odata2.api.ep.EntityProviderBatchProperties;
-import org.apache.olingo.odata2.api.processor.ODataRequest;
-import org.apache.olingo.odata2.api.processor.ODataRequest.ODataRequestBuilder;
-import org.apache.olingo.odata2.api.uri.PathInfo;
-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.Decoder;
-import org.apache.olingo.odata2.core.exception.ODataRuntimeException;
-
-/**
- *  
- */
-public class BatchRequestParser {
-  private static final String LF = "\n";
-  private static final String REG_EX_OPTIONAL_WHITESPACE = "\\s?";
-  private static final String REG_EX_ZERO_OR_MORE_WHITESPACES = "\\s*";
-  private static final String ANY_CHARACTERS = ".*";
-
-  private static final Pattern REG_EX_BLANK_LINE = Pattern.compile("(|" + REG_EX_ZERO_OR_MORE_WHITESPACES + ")");
-  private static final Pattern REG_EX_HEADER = Pattern.compile("([a-zA-Z\\-]+):" + REG_EX_OPTIONAL_WHITESPACE + "(.*)"
-      + REG_EX_ZERO_OR_MORE_WHITESPACES);
-  private static final Pattern REG_EX_VERSION = Pattern.compile("(?:HTTP/[0-9]\\.[0-9])");
-  private static final Pattern REG_EX_ANY_BOUNDARY_STRING = Pattern.compile("--" + ANY_CHARACTERS
-      + REG_EX_ZERO_OR_MORE_WHITESPACES);
-  private static final Pattern REG_EX_REQUEST_LINE = Pattern.compile("(GET|POST|PUT|DELETE|MERGE|PATCH)\\s(.*)\\s?"
-      + REG_EX_VERSION + REG_EX_ZERO_OR_MORE_WHITESPACES);
-  private static final Pattern REG_EX_BOUNDARY_PARAMETER = Pattern.compile(REG_EX_OPTIONAL_WHITESPACE
-      + "boundary=(\".*\"|.*)" + REG_EX_ZERO_OR_MORE_WHITESPACES);
-  private static final Pattern REG_EX_CONTENT_TYPE = Pattern.compile(REG_EX_OPTIONAL_WHITESPACE
-      + HttpContentType.MULTIPART_MIXED);
-  private static final Pattern REG_EX_QUERY_PARAMETER = Pattern.compile("((?:\\$|)[^=]+)=([^=]+)");
-
-  private static final String REG_EX_BOUNDARY =
-      "([a-zA-Z0-9_\\-\\.'\\+]{1,70})|\"([a-zA-Z0-9_\\-\\.'\\+\\s\\" +
-          "(\\),/:=\\?]{1,69}[a-zA-Z0-9_\\-\\.'\\+\\(\\),/:=\\?])\""; // See RFC 2046
-
-  private String baseUri;
-  private PathInfo batchRequestPathInfo;
-  private String contentTypeMime;
-  private String boundary;
-  private String currentMimeHeaderContentId;
-  private int currentLineNumber = 0;
-  private final static Set<String> HTTP_CHANGESET_METHODS;
-  private final static Set<String> HTTP_BATCH_METHODS;
-
-  static {
-    HashSet<String> httpChangesetMethods = new HashSet<String>();
-    httpChangesetMethods.add("POST");
-    httpChangesetMethods.add("PUT");
-    httpChangesetMethods.add("DELETE");
-    httpChangesetMethods.add("MERGE");
-    httpChangesetMethods.add("PATCH");
-    HTTP_CHANGESET_METHODS = Collections.unmodifiableSet(httpChangesetMethods);
-
-    HashSet<String> httpBatchMethods = new HashSet<String>();
-    httpBatchMethods.add("GET");
-    HTTP_BATCH_METHODS = Collections.unmodifiableSet(httpBatchMethods);
-  }
-
-  public BatchRequestParser(final String contentType, final EntityProviderBatchProperties properties) {
-    contentTypeMime = contentType;
-    batchRequestPathInfo = properties.getPathInfo();
-  }
-
-  public List<BatchRequestPart> parse(final InputStream in) throws BatchException {
-    Scanner scanner = new Scanner(in, BatchHelper.DEFAULT_ENCODING).useDelimiter(LF);
-    baseUri = getBaseUri();
-    List<BatchRequestPart> requestList;
-    try {
-      requestList = parseBatchRequest(scanner);
-    } finally {// NOPMD (suppress DoNotThrowExceptionInFinally)
-      scanner.close();
-      try {
-        in.close();
-      } catch (IOException e) {
-        throw new ODataRuntimeException(e);
-      }
-    }
-    return requestList;
-  }
-
-  private List<BatchRequestPart> parseBatchRequest(final Scanner scanner) throws BatchException {
-    List<BatchRequestPart> requests = new LinkedList<BatchRequestPart>();
-    if (contentTypeMime != null) {
-      boundary = getBoundary(contentTypeMime);
-      parsePreamble(scanner);
-      final String closeDelimiter = "--" + boundary + "--" + REG_EX_ZERO_OR_MORE_WHITESPACES;
-      while (scanner.hasNext() && !scanner.hasNext(closeDelimiter)) {
-        requests.add(parseMultipart(scanner, boundary, false));
-        parseOptionalLine(scanner);
-      }
-      if (scanner.hasNext(closeDelimiter)) {
-        scanner.next(closeDelimiter);
-        currentLineNumber++;
-      } else {
-        throw new BatchException(BatchException.MISSING_CLOSE_DELIMITER.addContent(currentLineNumber));
-      }
-    } else {
-      throw new BatchException(BatchException.MISSING_CONTENT_TYPE);
-    }
-    return requests;
-  }
-
-  // The method parses additional information prior to the first boundary delimiter line
-  private void parsePreamble(final Scanner scanner) {
-    while (scanner.hasNext() && !scanner.hasNext(REG_EX_ANY_BOUNDARY_STRING)) {
-      scanner.next();
-      currentLineNumber++;
-    }
-  }
-
-  private BatchRequestPart parseMultipart(final Scanner scanner, final String boundary, final boolean isChangeSet)
-      throws BatchException {
-    Map<String, String> mimeHeaders = new HashMap<String, String>();
-    BatchRequestPart multipart = null;
-    List<ODataRequest> requests = new ArrayList<ODataRequest>();
-    if (scanner.hasNext("--" + boundary + REG_EX_ZERO_OR_MORE_WHITESPACES)) {
-      scanner.next();
-      currentLineNumber++;
-      mimeHeaders = parseHeaders(scanner);
-      currentMimeHeaderContentId = mimeHeaders.get(BatchHelper.HTTP_CONTENT_ID.toLowerCase(Locale.ENGLISH));
-
-      String contentType = mimeHeaders.get(HttpHeaders.CONTENT_TYPE.toLowerCase(Locale.ENGLISH));
-      if (contentType == null) {
-        throw new BatchException(BatchException.MISSING_CONTENT_TYPE);
-      }
-      if (isChangeSet) {
-        if (HttpContentType.APPLICATION_HTTP.equalsIgnoreCase(contentType)) {
-          validateEncoding(mimeHeaders.get(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING.toLowerCase(Locale.ENGLISH)));
-          parseNewLine(scanner);// mandatory
-
-          requests.add(parseRequest(scanner, isChangeSet));
-          multipart = new BatchRequestPartImpl(false, requests);
-        } else {
-          throw new BatchException(BatchException.INVALID_CONTENT_TYPE.addContent(HttpContentType.APPLICATION_HTTP));
-        }
-      } else {
-        if (HttpContentType.APPLICATION_HTTP.equalsIgnoreCase(contentType)) {
-          validateEncoding(mimeHeaders.get(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING.toLowerCase(Locale.ENGLISH)));
-          parseNewLine(scanner);// mandatory
-          requests.add(parseRequest(scanner, isChangeSet));
-          multipart = new BatchRequestPartImpl(false, requests);
-        } else if (contentType.matches(REG_EX_OPTIONAL_WHITESPACE + HttpContentType.MULTIPART_MIXED + ANY_CHARACTERS)) {
-          String changeSetBoundary = getBoundary(contentType);
-          if (boundary.equals(changeSetBoundary)) {
-            throw new BatchException(BatchException.INVALID_CHANGESET_BOUNDARY.addContent(currentLineNumber));
-          }
-          List<ODataRequest> changeSetRequests = new LinkedList<ODataRequest>();
-          parseNewLine(scanner);// mandatory
-          Pattern changeSetCloseDelimiter =
-              Pattern.compile("--" + changeSetBoundary + "--" + REG_EX_ZERO_OR_MORE_WHITESPACES);
-          while (!scanner.hasNext(changeSetCloseDelimiter)) {
-            BatchRequestPart part = parseMultipart(scanner, changeSetBoundary, true);
-            changeSetRequests.addAll(part.getRequests());
-          }
-          scanner.next(changeSetCloseDelimiter);
-          currentLineNumber++;
-          multipart = new BatchRequestPartImpl(true, changeSetRequests);
-        } else {
-          throw new BatchException(BatchException.INVALID_CONTENT_TYPE.addContent(HttpContentType.MULTIPART_MIXED
-              + " or " + HttpContentType.APPLICATION_HTTP));
-        }
-      }
-    } else if (scanner.hasNext(boundary + REG_EX_ZERO_OR_MORE_WHITESPACES)) {
-      currentLineNumber++;
-      throw new BatchException(BatchException.INVALID_BOUNDARY_DELIMITER.addContent(currentLineNumber));
-    } else if (scanner.hasNext(REG_EX_ANY_BOUNDARY_STRING)) {
-      currentLineNumber++;
-      throw new BatchException(BatchException.NO_MATCH_WITH_BOUNDARY_STRING.addContent(boundary).addContent(
-          currentLineNumber));
-    } else {
-      currentLineNumber++;
-      throw new BatchException(BatchException.MISSING_BOUNDARY_DELIMITER.addContent(currentLineNumber));
-    }
-    return multipart;
-
-  }
-
-  private ODataRequest parseRequest(final Scanner scanner, final boolean isChangeSet) throws BatchException {
-    if (scanner.hasNext(REG_EX_REQUEST_LINE)) {
-      scanner.next(REG_EX_REQUEST_LINE);
-      currentLineNumber++;
-      final String method;
-      final String uri;
-      MatchResult result = scanner.match();
-      if (result.groupCount() == 2) {
-        method = result.group(1);
-        uri = result.group(2).trim();
-      } else {
-        currentLineNumber++;
-        throw new BatchException(BatchException.INVALID_REQUEST_LINE.addContent(scanner.next()).addContent(
-            currentLineNumber));
-      }
-      PathInfo pathInfo = parseRequestUri(uri);
-      Map<String, String> queryParameters = parseQueryParameters(uri);
-      if (isChangeSet) {
-        if (!HTTP_CHANGESET_METHODS.contains(method)) {
-          throw new BatchException(BatchException.INVALID_CHANGESET_METHOD.addContent(currentLineNumber));
-        }
-      } else if (!HTTP_BATCH_METHODS.contains(method)) {
-        throw new BatchException(BatchException.INVALID_QUERY_OPERATION_METHOD.addContent(currentLineNumber));
-      }
-      ODataHttpMethod httpMethod = ODataHttpMethod.valueOf(method);
-      Map<String, List<String>> headers = parseRequestHeaders(scanner);
-      if (currentMimeHeaderContentId != null) {
-        List<String> headerList = new ArrayList<String>();
-        headerList.add(currentMimeHeaderContentId);
-        headers.put(BatchHelper.MIME_HEADER_CONTENT_ID.toLowerCase(Locale.ENGLISH), headerList);
-      }
-
-      String contentType = getContentTypeHeader(headers);
-      List<String> acceptHeaders = getAcceptHeader(headers);
-      List<Locale> acceptLanguages = getAcceptLanguageHeader(headers);
-      parseNewLine(scanner);
-      InputStream body = new ByteArrayInputStream(new byte[0]);
-      if (isChangeSet) {
-        body = parseBody(scanner);
-      } else {
-        parseNewLine(scanner);
-      }
-
-      ODataRequestBuilder requestBuilder = ODataRequest.method(httpMethod)
-          .queryParameters(queryParameters)
-          .requestHeaders(headers)
-          .pathInfo(pathInfo)
-          .acceptableLanguages(acceptLanguages)
-          .body(body)
-          .acceptHeaders(acceptHeaders);
-
-      if (contentType != null) {
-        requestBuilder = requestBuilder.contentType(contentType);
-      }
-      return requestBuilder.build();
-    } else {
-      currentLineNumber++;
-      throw new BatchException(BatchException.INVALID_REQUEST_LINE.addContent(scanner.next()).addContent(
-          currentLineNumber));
-    }
-
-  }
-
-  private Map<String, List<String>> parseRequestHeaders(final Scanner scanner) throws BatchException {
-    Map<String, List<String>> headers = new HashMap<String, List<String>>();
-    while (scanner.hasNext() && !scanner.hasNext(REG_EX_BLANK_LINE)) {
-      if (scanner.hasNext(REG_EX_HEADER)) {
-        scanner.next(REG_EX_HEADER);
-        currentLineNumber++;
-        MatchResult result = scanner.match();
-        if (result.groupCount() == 2) {
-          String headerName = result.group(1).trim().toLowerCase(Locale.ENGLISH);
-          String headerValue = result.group(2).trim();
-          if (HttpHeaders.ACCEPT.equalsIgnoreCase(headerName)) {
-            List<String> acceptHeaders = parseAcceptHeaders(headerValue);
-            headers.put(headerName, acceptHeaders);
-          } else if (HttpHeaders.ACCEPT_LANGUAGE.equalsIgnoreCase(headerName)) {
-            List<String> acceptLanguageHeaders = parseAcceptableLanguages(headerValue);
-            headers.put(headerName, acceptLanguageHeaders);
-          } else if (!BatchHelper.HTTP_CONTENT_ID.equalsIgnoreCase(headerName)) {
-            if (headers.containsKey(headerName)) {
-              headers.get(headerName).add(headerValue);
-            } else {
-              List<String> headerList = new ArrayList<String>();
-              headerList.add(headerValue);
-              headers.put(headerName, headerList);
-            }
-          } else {
-            List<String> headerList = new ArrayList<String>();
-            headerList.add(headerValue);
-            headers.put(BatchHelper.REQUEST_HEADER_CONTENT_ID.toLowerCase(Locale.ENGLISH), headerList);
-          }
-        }
-      } else {
-        currentLineNumber++;
-        throw new BatchException(BatchException.INVALID_HEADER.addContent(scanner.next())
-            .addContent(currentLineNumber));
-      }
-    }
-    return headers;
-  }
-
-  private PathInfo parseRequestUri(final String uri) throws BatchException {
-    PathInfoImpl pathInfo = new PathInfoImpl();
-    pathInfo.setServiceRoot(batchRequestPathInfo.getServiceRoot());
-    pathInfo.setPrecedingPathSegment(batchRequestPathInfo.getPrecedingSegments());
-    final String odataPathSegmentsAsString;
-    final String queryParametersAsString;
-    try {
-      Scanner uriScanner = new Scanner(uri).useDelimiter(LF);
-      URI uriObject = new URI(uri);
-      if (uriObject.isAbsolute()) {
-        Pattern regexRequestUri = Pattern.compile(baseUri + "/([^/][^?]*)(\\?.*)?");
-        if (uriScanner.hasNext(regexRequestUri)) {
-          uriScanner.next(regexRequestUri);
-          MatchResult result = uriScanner.match();
-          if (result.groupCount() == 2) {
-            odataPathSegmentsAsString = result.group(1);
-            queryParametersAsString = result.group(2) != null ? result.group(2) : "";
-          } else {
-            uriScanner.close();
-            throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
-          }
-        } else {
-          uriScanner.close();
-          throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
-        }
-      } else {
-        Pattern regexRequestUri = Pattern.compile("([^/][^?]*)(\\?.*)?");
-        if (uriScanner.hasNext(regexRequestUri)) {
-          uriScanner.next(regexRequestUri);
-          MatchResult result = uriScanner.match();
-          if (result.groupCount() == 2) {
-            odataPathSegmentsAsString = result.group(1);
-            queryParametersAsString = result.group(2) != null ? result.group(2) : "";
-          } else {
-            uriScanner.close();
-            throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
-          }
-        } else if (uriScanner.hasNext("/(.*)")) {
-          uriScanner.close();
-          throw new BatchException(BatchException.UNSUPPORTED_ABSOLUTE_PATH.addContent(currentLineNumber));
-        } else {
-          uriScanner.close();
-          throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
-        }
-
-      }
-      uriScanner.close();
-      pathInfo.setODataPathSegment(parseODataPathSegments(odataPathSegmentsAsString));
-      if (!odataPathSegmentsAsString.startsWith("$")) {
-        String requestUri = baseUri + "/" + odataPathSegmentsAsString + queryParametersAsString;
-        pathInfo.setRequestUri(new URI(requestUri));
-      }
-      return pathInfo;
-    } catch (URISyntaxException e) {
-      throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber), e);
-    }
-
-  }
-
-  private Map<String, String> parseQueryParameters(final String uri) throws BatchException {
-    Scanner uriScanner = new Scanner(uri).useDelimiter("\n");
-    Map<String, String> queryParametersMap = new HashMap<String, String>();
-    Pattern regex = Pattern.compile("(?:" + baseUri + "/)?" + "[^?]+" + "\\?(.*)");
-    if (uriScanner.hasNext(regex)) {
-      uriScanner.next(regex);
-      MatchResult uriResult = uriScanner.match();
-      if (uriResult.groupCount() == 1) {
-        String queryParams = uriResult.group(1);
-        Scanner queryParamsScanner = new Scanner(queryParams).useDelimiter("&");
-        while (queryParamsScanner.hasNext(REG_EX_QUERY_PARAMETER)) {
-          queryParamsScanner.next(REG_EX_QUERY_PARAMETER);
-          MatchResult result = queryParamsScanner.match();
-          if (result.groupCount() == 2) {
-            String systemQueryOption = result.group(1);
-            String value = result.group(2);
-            queryParametersMap.put(systemQueryOption, Decoder.decode(value));
-          } else {
-            queryParamsScanner.close();
-            throw new BatchException(BatchException.INVALID_QUERY_PARAMETER);
-          }
-        }
-        queryParamsScanner.close();
-
-      } else {
-        uriScanner.close();
-        throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
-      }
-    }
-    uriScanner.close();
-    return queryParametersMap;
-  }
-
-  private List<PathSegment> parseODataPathSegments(final String odataPathSegmentsAsString) {
-    Scanner pathSegmentScanner = new Scanner(odataPathSegmentsAsString).useDelimiter("/");
-    List<PathSegment> odataPathSegments = new ArrayList<PathSegment>();
-    while (pathSegmentScanner.hasNext()) {
-      odataPathSegments.add(new ODataPathSegmentImpl(pathSegmentScanner.next(), null));
-    }
-    pathSegmentScanner.close();
-    return odataPathSegments;
-  }
-
-  private List<String> parseAcceptHeaders(final String headerValue) throws BatchException {
-    return AcceptParser.parseAcceptHeaders(headerValue);
-  }
-
-  private List<String> parseAcceptableLanguages(final String headerValue) throws BatchException {
-    return AcceptParser.parseAcceptableLanguages(headerValue);
-  }
-
-  private InputStream parseBody(final Scanner scanner) {
-    StringBuilder body = null;
-    final InputStream requestBody;
-
-    while (scanner.hasNext() && !scanner.hasNext(REG_EX_ANY_BOUNDARY_STRING)) {
-      if (!scanner.hasNext(REG_EX_ZERO_OR_MORE_WHITESPACES)) {
-        if (body == null) {
-          body = new StringBuilder(scanner.next());
-        } else {
-          body.append(LF).append(scanner.next());
-        }
-      } else {
-        scanner.next();
-      }
-      currentLineNumber++;
-    }
-
-    if (body != null) {
-      requestBody = new ByteArrayInputStream(BatchHelper.getBytes(body.toString()));
-    } else {
-      requestBody = new ByteArrayInputStream(new byte[0]);
-    }
-    return requestBody;
-  }
-
-  private String getBoundary(final String contentType) throws BatchException {
-    Scanner contentTypeScanner = new Scanner(contentType).useDelimiter(";\\s?");
-    if (contentTypeScanner.hasNext(REG_EX_CONTENT_TYPE)) {
-      contentTypeScanner.next(REG_EX_CONTENT_TYPE);
-    } else {
-      contentTypeScanner.close();
-      throw new BatchException(BatchException.INVALID_CONTENT_TYPE.addContent(HttpContentType.MULTIPART_MIXED));
-    }
-    if (contentTypeScanner.hasNext(REG_EX_BOUNDARY_PARAMETER)) {
-      contentTypeScanner.next(REG_EX_BOUNDARY_PARAMETER);
-      MatchResult result = contentTypeScanner.match();
-      contentTypeScanner.close();
-      if (result.groupCount() == 1 && result.group(1).trim().matches(REG_EX_BOUNDARY)) {
-        return trimQuota(result.group(1).trim());
-      } else {
-        throw new BatchException(BatchException.INVALID_BOUNDARY);
-      }
-    } else {
-      contentTypeScanner.close();
-      throw new BatchException(BatchException.MISSING_PARAMETER_IN_CONTENT_TYPE);
-    }
-  }
-
-  private void validateEncoding(final String encoding) throws BatchException {
-    if (!BatchHelper.BINARY_ENCODING.equalsIgnoreCase(encoding)) {
-      throw new BatchException(BatchException.INVALID_CONTENT_TRANSFER_ENCODING);
-    }
-  }
-
-  private Map<String, String> parseHeaders(final Scanner scanner) throws BatchException {
-    Map<String, String> headers = new HashMap<String, String>();
-    while (scanner.hasNext() && !(scanner.hasNext(REG_EX_BLANK_LINE))) {
-      if (scanner.hasNext(REG_EX_HEADER)) {
-        scanner.next(REG_EX_HEADER);
-        currentLineNumber++;
-        MatchResult result = scanner.match();
-        if (result.groupCount() == 2) {
-          String headerName = result.group(1).trim().toLowerCase(Locale.ENGLISH);
-          String headerValue = result.group(2).trim();
-          headers.put(headerName, headerValue);
-        }
-      } else {
-        throw new BatchException(BatchException.INVALID_HEADER.addContent(scanner.next()));
-      }
-    }
-    return headers;
-  }
-
-  private void parseNewLine(final Scanner scanner) throws BatchException {
-    if (scanner.hasNext() && scanner.hasNext(REG_EX_BLANK_LINE)) {
-      scanner.next();
-      currentLineNumber++;
-    } else {
-      currentLineNumber++;
-      if (scanner.hasNext()) {
-        throw new BatchException(BatchException.MISSING_BLANK_LINE.addContent(scanner.next()).addContent(
-            currentLineNumber));
-      } else {
-        throw new BatchException(BatchException.TRUNCATED_BODY.addContent(currentLineNumber));
-
-      }
-    }
-  }
-
-  private void parseOptionalLine(final Scanner scanner) throws BatchException {
-    while (scanner.hasNext() && scanner.hasNext(REG_EX_BLANK_LINE)) {
-      scanner.next();
-      currentLineNumber++;
-    }
-  }
-
-  private String getBaseUri() throws BatchException {
-    if (batchRequestPathInfo != null) {
-      if (batchRequestPathInfo.getServiceRoot() != null) {
-        String baseUri = batchRequestPathInfo.getServiceRoot().toASCIIString();
-        if (baseUri.lastIndexOf('/') == baseUri.length() - 1) {
-          baseUri = baseUri.substring(0, baseUri.length() - 1);
-        }
-        for (PathSegment precedingPS : batchRequestPathInfo.getPrecedingSegments()) {
-          baseUri = baseUri + "/" + precedingPS.getPath();
-        }
-        return baseUri;
-      }
-    } else {
-      throw new BatchException(BatchException.INVALID_PATHINFO);
-    }
-    return null;
-  }
-
-  private String trimQuota(String boundary) {
-    if (boundary.matches("\".*\"")) {
-      boundary = boundary.replace("\"", "");
-    }
-    boundary = boundary.replaceAll("\\)", "\\\\)");
-    boundary = boundary.replaceAll("\\(", "\\\\(");
-    boundary = boundary.replaceAll("\\?", "\\\\?");
-    boundary = boundary.replaceAll("\\+", "\\\\+");
-    return boundary;
-  }
-
-  private List<String> getAcceptHeader(final Map<String, List<String>> headers) {
-    List<String> acceptHeaders = new ArrayList<String>();
-    List<String> requestAcceptHeaderList = headers.get(HttpHeaders.ACCEPT.toLowerCase(Locale.ENGLISH));
-
-    if (requestAcceptHeaderList != null) {
-      acceptHeaders = requestAcceptHeaderList;
-    }
-    return acceptHeaders;
-  }
-
-  private List<Locale> getAcceptLanguageHeader(final Map<String, List<String>> headers) {
-    List<String> requestAcceptLanguageList = headers.get(HttpHeaders.ACCEPT_LANGUAGE.toLowerCase(Locale.ENGLISH));
-    List<Locale> acceptLanguages = new ArrayList<Locale>();
-    if (requestAcceptLanguageList != null) {
-      for (String acceptLanguage : requestAcceptLanguageList) {
-        String[] part = acceptLanguage.split("-");
-        String language = part[0];
-        String country = "";
-        if (part.length == 2) {
-          country = part[part.length - 1];
-        }
-        Locale locale = new Locale(language, country);
-        acceptLanguages.add(locale);
-      }
-    }
-    return acceptLanguages;
-  }
-
-  private String getContentTypeHeader(final Map<String, List<String>> headers) {
-    List<String> requestContentTypeList = headers.get(HttpHeaders.CONTENT_TYPE.toLowerCase(Locale.ENGLISH));
-    String contentType = null;
-    if (requestContentTypeList != null) {
-      for (String requestContentType : requestContentTypeList) {
-        contentType = contentType != null ? contentType + "," + requestContentType : requestContentType;
-      }
-    }
-    return contentType;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestPartImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestPartImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestPartImpl.java
deleted file mode 100644
index bbf0c03..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestPartImpl.java
+++ /dev/null
@@ -1,58 +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.batch;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.batch.BatchRequestPart;
-import org.apache.olingo.odata2.api.processor.ODataRequest;
-
-public class BatchRequestPartImpl implements BatchRequestPart {
-
-  private List<ODataRequest> requests = new ArrayList<ODataRequest>();
-  private boolean isChangeSet;
-
-  public BatchRequestPartImpl() {}
-
-  public BatchRequestPartImpl(final boolean isChangeSet, final List<ODataRequest> requests) {
-    this.isChangeSet = isChangeSet;
-    this.requests = requests;
-  }
-
-  @Override
-  public boolean isChangeSet() {
-    return isChangeSet;
-  }
-
-  public void setChangeSet(final boolean isChangeSet) {
-    this.isChangeSet = isChangeSet;
-  }
-
-  @Override
-  public List<ODataRequest> getRequests() {
-    return Collections.unmodifiableList(requests);
-  }
-
-  public void setRequests(final List<ODataRequest> requests) {
-    this.requests = requests;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestWriter.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestWriter.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestWriter.java
deleted file mode 100644
index 4622d37..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestWriter.java
+++ /dev/null
@@ -1,128 +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.batch;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.client.batch.BatchChangeSet;
-import org.apache.olingo.odata2.api.client.batch.BatchChangeSetPart;
-import org.apache.olingo.odata2.api.client.batch.BatchPart;
-import org.apache.olingo.odata2.api.client.batch.BatchQueryPart;
-import org.apache.olingo.odata2.api.commons.HttpContentType;
-import org.apache.olingo.odata2.api.commons.HttpHeaders;
-
-public class BatchRequestWriter {
-  private static final String REG_EX_BOUNDARY =
-      "([a-zA-Z0-9_\\-\\.'\\+]{1,70})|\"([a-zA-Z0-9_\\-\\.'\\+\\s\\" +
-          "(\\),/:=\\?]{1,69}[a-zA-Z0-9_\\-\\.'\\+\\(\\),/:=\\?])\""; // See RFC 2046
-
-  private static final String COLON = ":";
-  private static final String SP = " ";
-  private static final String LF = "\r\n";
-  private String batchBoundary;
-  private StringBuilder writer = new StringBuilder();
-
-  public InputStream writeBatchRequest(final List<BatchPart> batchParts, final String boundary) {
-    if (boundary.matches(REG_EX_BOUNDARY)) {
-      batchBoundary = boundary;
-    } else {
-      throw new IllegalArgumentException();
-    }
-    for (BatchPart batchPart : batchParts) {
-      writer.append("--" + boundary).append(LF);
-      if (batchPart instanceof BatchChangeSet) {
-        appendChangeSet((BatchChangeSet) batchPart);
-      } else if (batchPart instanceof BatchQueryPart) {
-        BatchQueryPart request = (BatchQueryPart) batchPart;
-        appendRequestBodyPart(request.getMethod(), request.getUri(), null, request.getHeaders(),
-            request.getContentId());
-      }
-    }
-    writer.append("--").append(boundary).append("--").append(LF).append(LF);
-    InputStream batchRequestBody;
-    batchRequestBody = new ByteArrayInputStream(BatchHelper.getBytes(writer.toString()));
-    return batchRequestBody;
-  }
-
-  private void appendChangeSet(final BatchChangeSet batchChangeSet) {
-    String boundary = BatchHelper.generateBoundary("changeset");
-    while (boundary.equals(batchBoundary) || !boundary.matches(REG_EX_BOUNDARY)) {
-      boundary = BatchHelper.generateBoundary("changeset");
-    }
-    writer.append(HttpHeaders.CONTENT_TYPE).append(COLON).append(SP).append(
-        HttpContentType.MULTIPART_MIXED + "; boundary=" + boundary).append(LF).append(LF);
-    for (BatchChangeSetPart request : batchChangeSet.getChangeSetParts()) {
-      writer.append("--").append(boundary).append(LF);
-      appendRequestBodyPart(request.getMethod(), request.getUri(), request.getBody(), request.getHeaders(), request
-          .getContentId());
-    }
-    writer.append("--").append(boundary).append("--").append(LF).append(LF);
-  }
-
-  private void appendRequestBodyPart(final String method, final String uri, final String body,
-      final Map<String, String> headers, final String contentId) {
-    boolean isContentLengthPresent = false;
-    writer.append(HttpHeaders.CONTENT_TYPE).append(COLON).append(SP).append(HttpContentType.APPLICATION_HTTP)
-        .append(LF);
-    writer.append(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING).append(COLON).append(SP).append("binary").append(LF);
-    if (contentId != null) {
-      writer.append(BatchHelper.HTTP_CONTENT_ID).append(COLON).append(SP).append(contentId).append(LF);
-    }
-    String contentLength = getHeaderValue(headers, HttpHeaders.CONTENT_LENGTH);
-    if (contentLength != null && !contentLength.isEmpty()) {
-      isContentLengthPresent = true;
-    }
-    writer.append(LF);
-    writer.append(method).append(SP).append(uri).append(SP).append("HTTP/1.1");
-    writer.append(LF);
-
-    if (!isContentLengthPresent && body != null && !body.isEmpty()) {
-      writer.append(HttpHeaders.CONTENT_LENGTH).append(COLON).append(SP).append(BatchHelper.getBytes(body).length)
-          .append(LF);
-
-    }
-    appendHeader(headers);
-
-    if (body != null && !body.isEmpty()) {
-      writer.append(LF);
-      writer.append(body);
-    }
-    writer.append(LF).append(LF);
-  }
-
-  private void appendHeader(final Map<String, String> headers) {
-    for (Map.Entry<String, String> headerMap : headers.entrySet()) {
-      String name = headerMap.getKey();
-      writer.append(name).append(COLON).append(SP).append(headerMap.getValue()).append(LF);
-
-    }
-  }
-
-  private String getHeaderValue(final Map<String, String> headers, final String headerName) {
-    for (Map.Entry<String, String> header : headers.entrySet()) {
-      if (headerName.equalsIgnoreCase(header.getKey())) {
-        return header.getValue();
-      }
-    }
-    return null;
-  }
-}