http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/it/primitiveKeysServiceV3/verify.groovy ---------------------------------------------------------------------- diff --git a/fit/src/it/primitiveKeysServiceV3/verify.groovy b/fit/src/it/primitiveKeysServiceV3/verify.groovy deleted file mode 100644 index 9b74ad2..0000000 --- a/fit/src/it/primitiveKeysServiceV3/verify.groovy +++ /dev/null @@ -1,20 +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. - */ -File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/org/apache/olingo/fit/proxy/v3" ); -assert basepkg.isDirectory() && basepkg.listFiles().length>0;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/it/staticServiceV3/pom.xml ---------------------------------------------------------------------- diff --git a/fit/src/it/staticServiceV3/pom.xml b/fit/src/it/staticServiceV3/pom.xml deleted file mode 100644 index 528d94c..0000000 --- a/fit/src/it/staticServiceV3/pom.xml +++ /dev/null @@ -1,107 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <artifactId>pojogen-maven-plugin-v3test</artifactId> - <groupId>org.apache.olingo</groupId> - <version>@project.version@</version> - <name>${project.artifactId}</name> - <description>A simple IT verifying the basic use case of pojogen-maven-plugin.</description> - - <properties> - <project.source>1.6</project.source> - <compiler.plugin.version>3.2</compiler.plugin.version> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <dependencies> - <dependency> - <artifactId>pojogen-maven-plugin</artifactId> - <groupId>org.apache.olingo</groupId> - <version>@project.version@</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <artifactId>odata-client-proxy</artifactId> - <groupId>org.apache.olingo</groupId> - <version>@project.version@</version> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>${compiler.plugin.version}</version> - <configuration> - <source>${project.source}</source> - <target>${project.source}</target> - <showWarnings>true</showWarnings> - <showDeprecation>true</showDeprecation> - <compilerArgument>-Xlint:unchecked</compilerArgument> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>1.8</version> - <executions> - <execution> - <phase>process-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>${project.build.directory}/generated-sources</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>@project.groupId@</groupId> - <artifactId>pojogen-maven-plugin</artifactId> - <version>@project.version@</version> - <executions> - <execution> - <configuration> - <outputDirectory>${project.build.directory}/generated-sources</outputDirectory> - <serviceRootURL>http://localhost:9180/stub/StaticService/V30/Static.svc</serviceRootURL> - <basePackage>org.apache.olingo.fit.proxy.v3.staticservice</basePackage> - </configuration> - <id>v3pojoGen</id> - <phase>generate-sources</phase> - <goals> - <goal>v3pojoGen</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/it/staticServiceV3/verify.groovy ---------------------------------------------------------------------- diff --git a/fit/src/it/staticServiceV3/verify.groovy b/fit/src/it/staticServiceV3/verify.groovy deleted file mode 100644 index 9b74ad2..0000000 --- a/fit/src/it/staticServiceV3/verify.groovy +++ /dev/null @@ -1,20 +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. - */ -File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/org/apache/olingo/fit/proxy/v3" ); -assert basepkg.isDirectory() && basepkg.listFiles().length>0; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java index 9c91ea3..3d70109 100644 --- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java +++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java @@ -686,7 +686,7 @@ public abstract class AbstractServices { final String location; - if ((this instanceof V3KeyAsSegment) || (this instanceof V4KeyAsSegment)) { + if ((this instanceof V4KeyAsSegment)) { location = uriInfo.getRequestUri().toASCIIString() + "/" + entityKey; final Link editLink = new LinkImpl(); @@ -1204,7 +1204,7 @@ public abstract class AbstractServices { } final Entity entry = container.getPayload(); - if ((this instanceof V3KeyAsSegment) || (this instanceof V4KeyAsSegment)) { + if ((this instanceof V4KeyAsSegment)) { final Link editLink = new LinkImpl(); editLink.setRel("edit"); editLink.setTitle(entitySetName); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java b/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java deleted file mode 100644 index 011552e..0000000 --- a/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java +++ /dev/null @@ -1,209 +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.fit; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; -import org.apache.olingo.fit.metadata.Metadata; -import org.apache.olingo.fit.utils.AbstractUtilities; -import org.apache.olingo.fit.utils.Accept; -import org.apache.olingo.fit.utils.Commons; -import org.apache.olingo.fit.utils.ConstantKey; -import org.apache.olingo.fit.utils.Constants; -import org.apache.olingo.fit.utils.FSManager; -import org.springframework.stereotype.Service; - -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; - -@Service -@Path("/V30/ActionOverloading.svc") -public class V3ActionOverloading extends V3Services { - - public V3ActionOverloading() throws IOException { - super(new Metadata(FSManager.instance(ODataServiceVersion.V30).readRes( - "actionOverloading" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA)), - Accept.XML), ODataServiceVersion.V30)); - } - - private Response replaceServiceName(final Response response) { - try { - final String content = IOUtils.toString((InputStream) response.getEntity(), Constants.ENCODING). - replaceAll("Static\\.svc", "ActionOverloading.svc"); - - final Response.ResponseBuilder builder = Response.status(response.getStatus()); - for (String headerName : response.getHeaders().keySet()) { - for (Object headerValue : response.getHeaders().get(headerName)) { - builder.header(headerName, headerValue); - } - } - - final InputStream toBeStreamedBack = IOUtils.toInputStream(content, Constants.ENCODING); - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - IOUtils.copy(toBeStreamedBack, baos); - IOUtils.closeQuietly(toBeStreamedBack); - - builder.header("Content-Length", baos.size()); - builder.entity(new ByteArrayInputStream(baos.toByteArray())); - - return builder.build(); - } catch (Exception e) { - return response; - } - } - - @GET - @Path("/$metadata") - @Produces(MediaType.APPLICATION_XML) - @Override - public Response getMetadata() { - return super.getMetadata("actionOverloading" - + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA))); - } - - @POST - @Path("/RetrieveProduct") - public Response unboundRetrieveProduct( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType) { - - final Accept acceptType; - if (StringUtils.isNotBlank(format)) { - acceptType = Accept.valueOf(format.toUpperCase()); - } else { - acceptType = Accept.parse(accept, ODataServiceVersion.V30); - } - if (acceptType == Accept.XML || acceptType == Accept.TEXT) { - throw new UnsupportedMediaTypeException("Unsupported media type"); - } - - try { - final InputStream result = FSManager.instance(ODataServiceVersion.V30). - readFile("actionOverloadingRetrieveProduct", acceptType); - return replaceServiceName(xml.createResponse(result, null, acceptType)); - } catch (Exception e) { - return replaceServiceName(xml.createFaultResponse(accept, e)); - } - } - - @GET - @Path("/Product({entityId})") - @Override - public Response getProduct( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entityId") final String entityId, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { - - final Map.Entry<Accept, AbstractUtilities> utils = super.getUtilities(accept, format); - - if (utils.getKey() == Accept.XML || utils.getKey() == Accept.TEXT) { - throw new UnsupportedMediaTypeException("Unsupported media type"); - } - - final Map.Entry<String, InputStream> entityInfo = utils.getValue().readEntity("Product", entityId, utils.getKey()); - - InputStream entity = entityInfo.getValue(); - try { - if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) { - entity = utils.getValue().addOperation(entity, "RetrieveProduct", "#DefaultContainer.RetrieveProduct", - uriInfo.getAbsolutePath().toASCIIString() - + "/RetrieveProduct"); - } - - return replaceServiceName(utils.getValue().createResponse( - entity, Commons.getETag(entityInfo.getKey(), ODataServiceVersion.V30), utils.getKey())); - } catch (Exception e) { - LOG.error("Error retrieving entity", e); - return replaceServiceName(xml.createFaultResponse(accept, e)); - } - } - - @POST - @Path("/Product({entityId})/{path:.*RetrieveProduct}") - public Response productBoundRetrieveProduct( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType) { - - return unboundRetrieveProduct(accept, format, contentType); - } - - @GET - @Path("/OrderLine(OrderId={orderId},ProductId={productId})") - public Response getOrderLine( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("orderId") final String orderId, - @PathParam("productId") final String productId, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { - - final Map.Entry<Accept, AbstractUtilities> utils = super.getUtilities(accept, format); - - if (utils.getKey() == Accept.XML || utils.getKey() == Accept.TEXT) { - throw new UnsupportedMediaTypeException("Unsupported media type"); - } - - final Map.Entry<String, InputStream> entityInfo = utils.getValue(). - readEntity("OrderLine", orderId + " " + productId, utils.getKey()); - - InputStream entity = entityInfo.getValue(); - try { - if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) { - entity = utils.getValue().addOperation(entity, "RetrieveProduct", "#DefaultContainer.RetrieveProduct", - uriInfo.getAbsolutePath().toASCIIString() - + "/RetrieveProduct"); - } - - return replaceServiceName(utils.getValue().createResponse( - entity, Commons.getETag(entityInfo.getKey(), ODataServiceVersion.V30), utils.getKey())); - } catch (Exception e) { - LOG.error("Error retrieving entity", e); - return replaceServiceName(xml.createFaultResponse(accept, e)); - } - } - - @POST - @Path("/OrderLine(OrderId={orderId},ProductId={productId})/{path:.*RetrieveProduct}") - public Response orderLineBoundRetrieveProduct( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType) { - - return unboundRetrieveProduct(accept, format, contentType); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java b/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java deleted file mode 100644 index aece8c2..0000000 --- a/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java +++ /dev/null @@ -1,181 +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.fit; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.fit.methods.MERGE; -import org.apache.olingo.fit.methods.PATCH; -import org.apache.olingo.fit.utils.Constants; -import org.springframework.stereotype.Service; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -@Service -@Path("/V30/KeyAsSegment.svc") -public class V3KeyAsSegment extends V3Services { - - public V3KeyAsSegment() throws IOException { - super(); - } - - private Response replaceServiceName(final Response response) { - try { - final String content = IOUtils.toString((InputStream) response.getEntity(), Constants.ENCODING). - replaceAll("Static\\.svc", "KeyAsSegment.svc"); - - final Response.ResponseBuilder builder = Response.status(response.getStatus()); - for (String headerName : response.getHeaders().keySet()) { - for (Object headerValue : response.getHeaders().get(headerName)) { - builder.header(headerName, headerValue); - } - } - - final InputStream toBeStreamedBack = IOUtils.toInputStream(content, Constants.ENCODING); - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - IOUtils.copy(toBeStreamedBack, baos); - IOUtils.closeQuietly(toBeStreamedBack); - - builder.header("Content-Length", baos.size()); - builder.entity(new ByteArrayInputStream(baos.toByteArray())); - - return builder.build(); - } catch (Exception e) { - return response; - } - } - - @GET - @Path("/{entitySetName}/{entityId}") - @Override - public Response getEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - @QueryParam("$expand") @DefaultValue(StringUtils.EMPTY) final String expand, - @QueryParam("$select") @DefaultValue(StringUtils.EMPTY) final String select) { - - return replaceServiceName(super.getEntityInternal(uriInfo.getRequestUri().toASCIIString(), - accept, entitySetName, entityId, format, expand, select)); - } - - @DELETE - @Path("/{entitySetName}/{entityId}") - @Override - public Response removeEntity( - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId) { - - return replaceServiceName(super.removeEntity(entitySetName, entityId)); - } - - @MERGE - @Path("/{entitySetName}/{entityId}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) - @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) - - @Override - public Response mergeEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, - @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - final String changes) { - - return replaceServiceName(super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, - entityId, changes)); - } - - @PATCH - @Path("/{entitySetName}/{entityId}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) - @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) - - @Override - public Response patchEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, - @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - final String changes) { - - return replaceServiceName(super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, - entityId, changes)); - } - - @PUT - @Path("/{entitySetName}/{entityId}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) - @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) - public Response putNewEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - final String entity) { - - return replaceServiceName(super.replaceEntity(uriInfo, accept, contentType, prefer, entitySetName, entityId, - entity)); - } - - @POST - @Path("/{entitySetName}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) - @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM}) - - @Override - public Response postNewEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, - @PathParam("entitySetName") final String entitySetName, - final String entity) { - - return replaceServiceName(super.postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, entity)); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java b/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java deleted file mode 100644 index 540c0d8..0000000 --- a/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java +++ /dev/null @@ -1,149 +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.fit; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; -import org.apache.olingo.fit.metadata.Metadata; -import org.apache.olingo.fit.utils.Accept; -import org.apache.olingo.fit.utils.ConstantKey; -import org.apache.olingo.fit.utils.Constants; -import org.apache.olingo.fit.utils.FSManager; -import org.springframework.stereotype.Service; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -@Service -@Path("/V30/OpenType.svc") -public class V3OpenType extends V3Services { - - private static final Pattern GUID = Pattern.compile("guid'(.*)'"); - - public V3OpenType() throws IOException { - super(new Metadata(FSManager.instance(ODataServiceVersion.V30). - readRes("openType" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA)), - Accept.XML), ODataServiceVersion.V30)); - } - - private Response replaceServiceName(final Response response) { - try { - final String content = IOUtils.toString((InputStream) response.getEntity(), Constants.ENCODING). - replaceAll("Static\\.svc", "OpenType.svc"); - - final Response.ResponseBuilder builder = Response.status(response.getStatus()); - for (String headerName : response.getHeaders().keySet()) { - for (Object headerValue : response.getHeaders().get(headerName)) { - builder.header(headerName, headerValue); - } - } - - final InputStream toBeStreamedBack = IOUtils.toInputStream(content, Constants.ENCODING); - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - IOUtils.copy(toBeStreamedBack, baos); - IOUtils.closeQuietly(toBeStreamedBack); - - builder.header("Content-Length", baos.size()); - builder.entity(new ByteArrayInputStream(baos.toByteArray())); - - return builder.build(); - } catch (Exception e) { - return response; - } - } - - /** - * Provide sample large metadata. - * - * @return metadata. - */ - @GET - @Path("/$metadata") - @Produces(MediaType.APPLICATION_XML) - @Override - public Response getMetadata() { - return super.getMetadata("openType" + StringUtils.capitalize( - Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA))); - } - - @GET - @Path("/{entitySetName}({entityId})") - @Override - public Response getEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - @QueryParam("$expand") @DefaultValue(StringUtils.EMPTY) final String expand, - @QueryParam("$select") @DefaultValue(StringUtils.EMPTY) final String select) { - - final Matcher matcher = GUID.matcher(entityId); - return replaceServiceName(super.getEntityInternal( - uriInfo.getRequestUri().toASCIIString(), accept, entitySetName, - matcher.matches() ? matcher.group(1) : entityId, format, expand, select)); - } - - @POST - @Path("/{entitySetName}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) - @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM}) - @Override - public Response postNewEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, - @PathParam("entitySetName") final String entitySetName, - final String entity) { - - return replaceServiceName(super.postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, entity)); - } - - @DELETE - @Path("/{entitySetName}({entityId})") - @Override - public Response removeEntity( - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId) { - - final Matcher matcher = GUID.matcher(entityId); - return replaceServiceName(super.removeEntity(entitySetName, - matcher.matches() ? matcher.group(1) : entityId)); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java b/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java deleted file mode 100644 index d74d0fd..0000000 --- a/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.fit; - -import org.apache.olingo.fit.utils.Accept; -import org.apache.olingo.fit.utils.FSManager; -import org.springframework.stereotype.Service; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.IOException; - -@Service -@Path("/V30/PrimitiveKeys.svc") -public class V3PrimitiveKeys extends V3Services { - - public V3PrimitiveKeys() throws IOException { - super(); - } - - @GET - @Path("/$metadata") - @Produces(MediaType.APPLICATION_XML) - @Override - public Response getMetadata() { - try { - return xml.createResponse( - null, FSManager.instance(version).readRes("primitiveKeysMetadata", Accept.XML), null, Accept.XML); - } catch (Exception e) { - return xml.createFaultResponse(Accept.XML.toString(version), e); - } - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/main/java/org/apache/olingo/fit/V3Services.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/V3Services.java b/fit/src/main/java/org/apache/olingo/fit/V3Services.java deleted file mode 100644 index 217f012..0000000 --- a/fit/src/main/java/org/apache/olingo/fit/V3Services.java +++ /dev/null @@ -1,482 +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.fit; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.cxf.interceptor.InInterceptors; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.apache.olingo.commons.api.data.EntitySet; -import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; -import org.apache.olingo.fit.metadata.Metadata; -import org.apache.olingo.fit.methods.MERGE; -import org.apache.olingo.fit.methods.PATCH; -import org.apache.olingo.fit.rest.XHTTPMethodInterceptor; -import org.apache.olingo.fit.utils.AbstractUtilities; -import org.apache.olingo.fit.utils.Accept; -import org.apache.olingo.fit.utils.Commons; -import org.apache.olingo.fit.utils.ConstantKey; -import org.apache.olingo.fit.utils.Constants; -import org.apache.olingo.fit.utils.FSManager; -import org.apache.olingo.fit.utils.LinkInfo; -import org.springframework.stereotype.Service; - -import javax.mail.internet.MimeBodyPart; -import javax.mail.internet.MimeMultipart; -import javax.ws.rs.BadRequestException; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -@Service -@Path("/V30/Static.svc") -@InInterceptors(classes = XHTTPMethodInterceptor.class) -public class V3Services extends AbstractServices { - - public V3Services() throws IOException { - super(ODataServiceVersion.V30, Commons.getMetadata(ODataServiceVersion.V30)); - } - - protected V3Services(final Metadata metadata) throws IOException { - super(ODataServiceVersion.V30, metadata); - } - - @GET - @Path("/InStreamErrorGetCustomer") - public Response instreamErrorGetCustomer( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { - - final Accept acceptType; - if (StringUtils.isNotBlank(format)) { - acceptType = Accept.valueOf(format.toUpperCase()); - } else { - acceptType = Accept.parse(accept, version); - } - - try { - final InputStream error = FSManager.instance(version).readFile("InStreamErrorGetCustomer", acceptType); - - return Response.ok(error). - header(Constants.get(version, ConstantKey.ODATA_SERVICE_VERSION), version + ";"). - header("Content-Type", acceptType.toString(version)). - build(); - } catch (Exception e) { - if (acceptType == Accept.XML || acceptType == Accept.TEXT) { - throw new UnsupportedMediaTypeException("Unsupported media type"); - } - - return xml.createFaultResponse(accept, e); - } - } - - /** - * Provide sample large metadata. - * - * @return metadata. - */ - @GET - @Path("/large/$metadata") - @Produces(MediaType.APPLICATION_XML) - public Response getLargeMetadata() { - return getMetadata("large" + StringUtils.capitalize(Constants.get(version, ConstantKey.METADATA))); - } - - @Override - protected void setInlineCount(final EntitySet feed, final String count) { - if ("allpages".equals(count)) { - feed.setCount(feed.getEntities().size()); - } - } - - @Override - public InputStream exploreMultipart( - final List<Attachment> attachments, final String boundary, final boolean contineOnError) - throws IOException { - - final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - Response res = null; - boolean goon = true; - for (int i = 0; i < attachments.size() && goon; i++) { - try { - final Attachment obj = attachments.get(i); - bos.write(("--" + boundary).getBytes()); - bos.write(Constants.CRLF); - - final Object content = obj.getDataHandler().getContent(); - if (content instanceof MimeMultipart) { - final Map<String, String> references = new HashMap<String, String>(); - - final String cboundary = "changeset_" + UUID.randomUUID().toString(); - bos.write(("Content-Type: multipart/mixed;boundary=" + cboundary).getBytes()); - bos.write(Constants.CRLF); - bos.write(Constants.CRLF); - - final ByteArrayOutputStream chbos = new ByteArrayOutputStream(); - String lastContebtID = null; - try { - for (int j = 0; j < ((MimeMultipart) content).getCount(); j++) { - final MimeBodyPart part = (MimeBodyPart) ((MimeMultipart) content).getBodyPart(j); - lastContebtID = part.getContentID(); - addChangesetItemIntro(chbos, lastContebtID, cboundary); - - res = bodyPartRequest(new MimeBodyPart(part.getInputStream()), references); - if (res == null || res.getStatus() >= 400) { - throw new Exception("Failure processing changeset"); - } - - addSingleBatchResponse(res, lastContebtID, chbos); - references.put("$" + lastContebtID, res.getHeaderString("Location")); - } - - bos.write(chbos.toByteArray()); - IOUtils.closeQuietly(chbos); - - bos.write(("--" + cboundary + "--").getBytes()); - bos.write(Constants.CRLF); - } catch (Exception e) { - LOG.warn("While processing changeset", e); - IOUtils.closeQuietly(chbos); - - addChangesetItemIntro(bos, lastContebtID, cboundary); - - if (res == null || res.getStatus() < 400) { - addErrorBatchResponse(e, "1", bos); - } else { - addSingleBatchResponse(res, lastContebtID, bos); - } - - goon = contineOnError; - } - } else { - addItemIntro(bos); - - res = bodyPartRequest(new MimeBodyPart(obj.getDataHandler().getInputStream())); - - if (res.getStatus() >= 400) { - goon = contineOnError; - throw new Exception("Failure processing changeset"); - } - - addSingleBatchResponse(res, bos); - } - } catch (Exception e) { - if (res == null || res.getStatus() < 400) { - addErrorBatchResponse(e, bos); - } else { - addSingleBatchResponse(res, bos); - } - } - } - - bos.write(("--" + boundary + "--").getBytes()); - - return new ByteArrayInputStream(bos.toByteArray()); - } - - @GET - @Path("/Car/{type:[a-zA-Z].*}") - public Response filterCar( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top, - @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) final String skip, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) final String count, - @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter, - @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby, - @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) { - - return super.getEntitySet(uriInfo, accept, "Car", top, skip, format, count, filter, orderby, skiptoken); - } - - @GET - @Path("/Login({entityId})") - public Response getLogin( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entityId") final String entityId, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - @QueryParam("$expand") @DefaultValue(StringUtils.EMPTY) final String expand, - @QueryParam("$select") @DefaultValue(StringUtils.EMPTY) final String select) { - - return super.getEntityInternal(uriInfo.getRequestUri().toASCIIString(), accept, - "Login", StringUtils.remove(entityId, "'"), format, expand, select); - } - - @POST - @Path("/Login") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) - @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM}) - public Response postLogin( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, - final String entity) { - - if ("{\"odata.type\":\"Microsoft.Test.OData.Services.AstoriaDefaultService.Login\"}".equals(entity)) { - return xml.createFaultResponse(accept, new BadRequestException()); - } - - return super.postNewEntity(uriInfo, accept, contentType, prefer, "Login", entity); - } - - @DELETE - @Path("/Login({entityId})") - public Response removeLogin( - @PathParam("entityId") final String entityId) { - - return super.removeEntity("Login", StringUtils.remove(entityId, "'")); - } - - /** - * Retrieve links sample. - * - * @param accept Accept header. - * @param entitySetName Entity set name. - * @param entityId entity id. - * @param linkName link name. - * @param format format query option. - * @return links. - */ - @GET - @Path("/{entitySetName}({entityId})/$links/{linkName}") - public Response getLinks( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @PathParam("linkName") final String linkName, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { - try { - final Accept acceptType; - if (StringUtils.isNotBlank(format)) { - acceptType = Accept.valueOf(format.toUpperCase()); - } else { - acceptType = Accept.parse(accept, version); - } - - if (acceptType == Accept.ATOM) { - throw new UnsupportedMediaTypeException("Unsupported media type"); - } - - final LinkInfo links = xml.readLinks(entitySetName, entityId, linkName, acceptType); - - return xml.createResponse( - links.getLinks(), - links.getEtag(), - acceptType); - } catch (Exception e) { - return xml.createFaultResponse(accept, e); - } - } - - @POST - @Path("/{entitySetName}({entityId})/$links/{linkName}") - public Response postLink( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @PathParam("linkName") final String linkName, - final String link, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { - try { - final Accept acceptType; - if (StringUtils.isNotBlank(format)) { - acceptType = Accept.valueOf(format.toUpperCase()); - } else { - acceptType = Accept.parse(accept, version); - } - - if (acceptType == Accept.ATOM) { - throw new UnsupportedMediaTypeException("Unsupported media type"); - } - - final Accept content; - if (StringUtils.isNotBlank(contentType)) { - content = Accept.parse(contentType, version); - } else { - content = acceptType; - } - - final AbstractUtilities utils = getUtilities(acceptType); - - final List<String> links; - if (content == Accept.XML || content == Accept.TEXT || content == Accept.ATOM) { - links = xml.extractLinkURIs(IOUtils.toInputStream(link, Constants.ENCODING)).getValue(); - } else { - links = json.extractLinkURIs(IOUtils.toInputStream(link, Constants.ENCODING)).getValue(); - } - - utils.putLinksInMemory( - Commons.getEntityBasePath(entitySetName, entityId), - entitySetName, - entityId, - linkName, - links); - - return xml.createResponse(null, null, null, Response.Status.NO_CONTENT); - } catch (Exception e) { - return xml.createFaultResponse(accept, e); - } - } - - @MERGE - @Path("/{entitySetName}({entityId})/$links/{linkName}") - public Response mergeLink( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @PathParam("linkName") final String linkName, - final String link, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { - return putLink(accept, contentType, entitySetName, entityId, linkName, link, format); - } - - @PATCH - @Path("/{entitySetName}({entityId})/$links/{linkName}") - public Response patchLink( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @PathParam("linkName") final String linkName, - final String link, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { - return putLink(accept, contentType, entitySetName, entityId, linkName, link, format); - } - - @PUT - @Path("/{entitySetName}({entityId})/$links/{linkName}") - public Response putLink( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @PathParam("linkName") final String linkName, - final String link, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { - try { - final Accept acceptType; - if (StringUtils.isNotBlank(format)) { - acceptType = Accept.valueOf(format.toUpperCase()); - } else { - acceptType = Accept.parse(accept, version); - } - - if (acceptType == Accept.ATOM) { - throw new UnsupportedMediaTypeException("Unsupported media type"); - } - - final Accept content; - if (StringUtils.isNotBlank(contentType)) { - content = Accept.parse(contentType, version); - } else { - content = acceptType; - } - - final AbstractUtilities utils = getUtilities(acceptType); - - final List<String> links; - if (content == Accept.XML || content == Accept.TEXT || content == Accept.ATOM) { - links = xml.extractLinkURIs(IOUtils.toInputStream(link, Constants.ENCODING)).getValue(); - } else { - links = json.extractLinkURIs(IOUtils.toInputStream(link, Constants.ENCODING)).getValue(); - } - - utils.putLinksInMemory( - Commons.getEntityBasePath(entitySetName, entityId), - entitySetName, - linkName, - links); - - return xml.createResponse(null, null, null, Response.Status.NO_CONTENT); - } catch (Exception e) { - return xml.createFaultResponse(accept, e); - } - } - - @DELETE - @Path("/{entitySetName}({entityId})/$links/{linkName}({linkId})") - public Response deleteLink( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @PathParam("linkName") final String linkName, - @PathParam("linkId") final String linkId, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { - try { - final Accept acceptType; - if (StringUtils.isNotBlank(format)) { - acceptType = Accept.valueOf(format.toUpperCase()); - } else { - acceptType = Accept.parse(accept, version); - } - - if (acceptType == Accept.ATOM) { - throw new UnsupportedMediaTypeException("Unsupported media type"); - } - - final AbstractUtilities utils = getUtilities(acceptType); - - final Map.Entry<String, List<String>> currents = json.extractLinkURIs(utils.readLinks( - entitySetName, entityId, linkName, Accept.JSON_FULLMETA).getLinks()); - - final Map.Entry<String, List<String>> toBeRemoved = json.extractLinkURIs(utils.readLinks( - entitySetName, entityId, linkName + "(" + linkId + ")", Accept.JSON_FULLMETA).getLinks()); - - final List<String> remains = currents.getValue(); - remains.removeAll(toBeRemoved.getValue()); - - utils.putLinksInMemory( - Commons.getEntityBasePath(entitySetName, entityId), - entitySetName, - linkName, - remains); - - return xml.createResponse(null, null, null, Response.Status.NO_CONTENT); - } catch (Exception e) { - return xml.createFaultResponse(accept, e); - } - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/main/java/org/apache/olingo/fit/server/TomcatTestServer.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/server/TomcatTestServer.java b/fit/src/main/java/org/apache/olingo/fit/server/TomcatTestServer.java index be94e8e..5574211 100644 --- a/fit/src/main/java/org/apache/olingo/fit/server/TomcatTestServer.java +++ b/fit/src/main/java/org/apache/olingo/fit/server/TomcatTestServer.java @@ -61,11 +61,6 @@ public class TomcatTestServer { try { LOG.trace("Start tomcat embedded server from main()"); TestServerBuilder server = TomcatTestServer.init(9180) - .addStaticContent("/stub/StaticService/V30/Static.svc/$metadata", "V30/metadata.xml") - .addStaticContent("/stub/StaticService/V30/ActionOverloading.svc/$metadata", - "V30/actionOverloadingMetadata.xml") - .addStaticContent("/stub/StaticService/V30/OpenType.svc/$metadata", "V30/openTypeMetadata.xml") - .addStaticContent("/stub/StaticService/V30/PrimitiveKeys.svc/$metadata", "V30/primitiveKeysMetadata.xml") .addStaticContent("/stub/StaticService/V40/OpenType.svc/$metadata", "V40/openTypeMetadata.xml") .addStaticContent("/stub/StaticService/V40/Demo.svc/$metadata", "V40/demoMetadata.xml") .addStaticContent("/stub/StaticService/V40/Static.svc/$metadata", "V40/metadata.xml"); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c8865db8/fit/src/main/resources/V30/AllGeoTypesSet/-10/entity.xml ---------------------------------------------------------------------- diff --git a/fit/src/main/resources/V30/AllGeoTypesSet/-10/entity.xml b/fit/src/main/resources/V30/AllGeoTypesSet/-10/entity.xml deleted file mode 100644 index b6d4244..0000000 --- a/fit/src/main/resources/V30/AllGeoTypesSet/-10/entity.xml +++ /dev/null @@ -1,161 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - 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. - ---> -<entry xml:base="http://localhost:${tomcat.servlet.port}/stub/StaticService/V30/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"> - <id>http://localhost:${tomcat.servlet.port}/stub/StaticService/V30/Static.svc/AllGeoTypesSet(-10)</id> - <category term="Microsoft.Test.OData.Services.AstoriaDefaultService.AllSpatialTypes" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> - <link rel="edit" title="AllSpatialTypes" href="AllGeoTypesSet(-10)" /> - <title /> - <updated>2014-05-08T12:27:58Z</updated> - <author> - <name /> - </author> - <content type="application/xml"> - <m:properties> - <d:Id m:type="Edm.Int32">-10</d:Id> - <d:Geog m:type="Edm.GeographyPoint"> - <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> - <gml:pos>51.65 178.7</gml:pos> - </gml:Point> - </d:Geog> - <d:GeogPoint m:type="Edm.GeographyPoint"> - <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> - <gml:pos>52.8606 173.334</gml:pos> - </gml:Point> - </d:GeogPoint> - <d:GeogLine m:type="Edm.GeographyLineString"> - <gml:LineString gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> - <gml:pos>40.5 40.5</gml:pos> - <gml:pos>30.5 30.5</gml:pos> - <gml:pos>20.5 40.5</gml:pos> - <gml:pos>10.5 30.5</gml:pos> - </gml:LineString> - </d:GeogLine> - <d:GeogPolygon m:type="Edm.GeographyPolygon"> - <gml:Polygon gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> - <gml:exterior> - <gml:LinearRing> - <gml:pos>5 15</gml:pos> - <gml:pos>10 40</gml:pos> - <gml:pos>20 10</gml:pos> - <gml:pos>10 5</gml:pos> - <gml:pos>5 15</gml:pos> - </gml:LinearRing> - </gml:exterior> - </gml:Polygon> - </d:GeogPolygon> - <d:GeogCollection m:null="true" /> - <d:GeogMultiPoint m:null="true" /> - <d:GeogMultiLine m:type="Edm.GeographyMultiLineString"> - <gml:MultiCurve gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> - <gml:curveMembers> - <gml:LineString> - <gml:pos>10 10</gml:pos> - <gml:pos>20 20</gml:pos> - <gml:pos>40 10</gml:pos> - </gml:LineString> - <gml:LineString> - <gml:pos>40 40</gml:pos> - <gml:pos>30 30</gml:pos> - <gml:pos>20 40</gml:pos> - <gml:pos>10 30</gml:pos> - </gml:LineString> - </gml:curveMembers> - </gml:MultiCurve> - </d:GeogMultiLine> - <d:GeogMultiPolygon m:null="true" /> - <d:Geom m:type="Edm.GeometryLineString"> - <gml:LineString gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0"> - <gml:pos>1 1</gml:pos> - <gml:pos>3 3</gml:pos> - <gml:pos>2 4</gml:pos> - <gml:pos>2 0</gml:pos> - </gml:LineString> - </d:Geom> - <d:GeomPoint m:type="Edm.GeometryPoint"> - <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0"> - <gml:pos /> - </gml:Point> - </d:GeomPoint> - <d:GeomLine m:null="true" /> - <d:GeomPolygon m:null="true" /> - <d:GeomCollection m:type="Edm.GeometryCollection"> - <gml:MultiGeometry gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0" /> - </d:GeomCollection> - <d:GeomMultiPoint m:type="Edm.GeometryMultiPoint"> - <gml:MultiPoint gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0" /> - </d:GeomMultiPoint> - <d:GeomMultiLine m:type="Edm.GeometryMultiLineString"> - <gml:MultiCurve gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0"> - <gml:curveMembers> - <gml:LineString> - <gml:pos>10 10</gml:pos> - <gml:pos>20 20</gml:pos> - <gml:pos>10 40</gml:pos> - </gml:LineString> - <gml:LineString> - <gml:pos>40 40</gml:pos> - <gml:pos>30 30</gml:pos> - <gml:pos>40 20</gml:pos> - <gml:pos>30 10</gml:pos> - </gml:LineString> - </gml:curveMembers> - </gml:MultiCurve> - </d:GeomMultiLine> - <d:GeomMultiPolygon m:type="Edm.GeometryMultiPolygon"> - <gml:MultiSurface gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0"> - <gml:surfaceMembers> - <gml:Polygon> - <gml:exterior> - <gml:LinearRing> - <gml:pos>40 40</gml:pos> - <gml:pos>20 45</gml:pos> - <gml:pos>45 30</gml:pos> - <gml:pos>40 40</gml:pos> - </gml:LinearRing> - </gml:exterior> - </gml:Polygon> - <gml:Polygon> - <gml:exterior> - <gml:LinearRing> - <gml:pos>20 35</gml:pos> - <gml:pos>45 20</gml:pos> - <gml:pos>30 5</gml:pos> - <gml:pos>10 10</gml:pos> - <gml:pos>10 30</gml:pos> - <gml:pos>20 35</gml:pos> - </gml:LinearRing> - </gml:exterior> - <gml:interior> - <gml:LinearRing> - <gml:pos>30 20</gml:pos> - <gml:pos>20 25</gml:pos> - <gml:pos>20 15</gml:pos> - <gml:pos>30 20</gml:pos> - </gml:LinearRing> - </gml:interior> - </gml:Polygon> - </gml:surfaceMembers> - </gml:MultiSurface> - </d:GeomMultiPolygon> - </m:properties> - </content> -</entry> \ No newline at end of file
