From 8c30c974d9167a301c209fe6250c68b627510932 Mon Sep 17 00:00:00 2001 From: Stephan Klevenz Date: Fri, 11 Jul 2014 12:41:46 +0200 Subject: [PATCH 01/16] [OLINGO-343] update dependencies to newest version if possible --- pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 447aaa8ca..6a57639b9 100644 --- a/pom.xml +++ b/pom.xml @@ -68,19 +68,19 @@ 2.4 3.3.2 - 1.1.3 + 1.2 2.0 4.3 - 3.0.1 + 3.1.0 2.7.11 - 4.0.3.RELEASE + 4.0.6.RELEASE 1.7 - 3.1.0 - 3.2 + 3.2.2 + 3.3 4.2.6 - 2.3.3 + 2.4.1 4.1 From aa3c261049f73d7fd2766ae57e0e881de0bfca52 Mon Sep 17 00:00:00 2001 From: Stephan Klevenz Date: Fri, 11 Jul 2014 12:42:12 +0200 Subject: [PATCH 02/16] [OLINGO-343] adding LICENSE, NOTICE and README files --- LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ NOTICE | 8 +++ README | 64 ++++++++++++++++++ pom.xml | 3 +- 4 files changed, 276 insertions(+), 1 deletion(-) create mode 100644 LICENSE create mode 100644 NOTICE create mode 100644 README diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/NOTICE b/NOTICE new file mode 100644 index 000000000..65d59ef37 --- /dev/null +++ b/NOTICE @@ -0,0 +1,8 @@ + +Apache Olingo +Copyright 2013-2014 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + + diff --git a/README b/README new file mode 100644 index 000000000..85bceaa35 --- /dev/null +++ b/README @@ -0,0 +1,64 @@ +========================== +Apache Olingo +========================== + +Apache Olingo is a Java library and extensions around +the OData specification. + +Apache Olingo supports the specification versions + - OData 4.0 + +Building Apache Olingo +====================== + +You can build Apache Olingo like this: + + mvn clean install + +You need Maven 3 with Java 6 (or higher) for the build. +Set the environment variable MAVEN_OPTS to +'-Xmx1024m -XX:MaxPermSize=256m' to give Maven more memory. + +Documentation +============= + +The project documentation is available here: + +http://olingo.apache.org/ + +License (see also package specific LICENSE files) +================================================= + +Collective work: Copyright 2014 The Apache Software Foundation. + +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. + +Dependencies with "Weak Copyleft" or dual licenses +================================================== + +Apache Olingo uses some libraries with open source licenses that require reciprocal +licensing when modified. These libraries are included in unmodified binary +form and can be redistributed under terms that are compatible with the +Apache License. + +Some libraries used by Apache Olingo are dual-licensed under different open source +licenses. These libraries are redistributed under the license whose terms +are compatible with the Apache License. + +See LICENSE file included in all Apache Olingo packages for +full licensing details. + + diff --git a/pom.xml b/pom.xml index 6a57639b9..71813b2fd 100644 --- a/pom.xml +++ b/pom.xml @@ -87,6 +87,7 @@ 1.7.7 ${project.build.directory}/log + 0.9.9 9080 9889 @@ -162,7 +163,7 @@ com.fasterxml aalto-xml - 0.9.9 + ${aalto-xml.version} From 4e61f1093d79353d01857452b5948facf3c386d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= <--global> Date: Fri, 11 Jul 2014 12:56:02 +0200 Subject: [PATCH 03/16] [OLINGO-357] Fixed --- .../olingo/client/core/uri/URIUtils.java | 69 +++++++------------ .../olingo/client/core/uri/URIEscapeTest.java | 12 ++++ .../client/core/uri/v4/FilterFactoryTest.java | 27 ++++++-- 3 files changed, 56 insertions(+), 52 deletions(-) diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java index 53ece5fb5..01269dd4b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java @@ -55,7 +55,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.commons.api.edm.geo.Geospatial; import org.apache.olingo.commons.core.edm.primitivetype.EdmBinary; -import org.apache.olingo.commons.core.edm.primitivetype.EdmDate; import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTime; import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset; import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal; @@ -65,7 +64,6 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.commons.core.edm.primitivetype.EdmSingle; import org.apache.olingo.commons.core.edm.primitivetype.EdmTime; -import org.apache.olingo.commons.core.edm.primitivetype.EdmTimeOfDay; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -213,47 +211,26 @@ public final class URIUtils { return version.compareTo(ODataServiceVersion.V40) < 0 ? prefix(version, EdmPrimitiveTypeKind.DateTime) + URLEncoder.encode(EdmDateTime.getInstance(). - valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8) + valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), + Constants.UTF8) + suffix(version, EdmPrimitiveTypeKind.DateTime) : URLEncoder.encode(EdmDateTimeOffset.getInstance(). - valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8); + valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), + Constants.UTF8); } private static String calendar(final ODataServiceVersion version, final Calendar calendar) throws UnsupportedEncodingException, EdmPrimitiveTypeException { - String result; - if (calendar.get(Calendar.ZONE_OFFSET) == 0) { - if (version.compareTo(ODataServiceVersion.V40) < 0) { - result = prefix(version, EdmPrimitiveTypeKind.DateTime) - + URLEncoder.encode(EdmDateTime.getInstance(). - valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8) - + suffix(version, EdmPrimitiveTypeKind.DateTime); - } else { - if (calendar.get(Calendar.YEAR) == 0 && calendar.get(Calendar.MONTH) == 0 - && calendar.get(Calendar.DAY_OF_MONTH) == 0) { - - result = URLEncoder.encode(EdmTimeOfDay.getInstance(). - valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8); - } else { - result = URLEncoder.encode(EdmDate.getInstance(). - valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8); - } - } - } else { - result = prefix(version, EdmPrimitiveTypeKind.DateTimeOffset) - + URLEncoder.encode(EdmDateTimeOffset.getInstance(). - valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8) - + suffix(version, EdmPrimitiveTypeKind.DateTimeOffset); - } - - return result; + return version.compareTo(ODataServiceVersion.V40) < 0 + ? prefix(version, EdmPrimitiveTypeKind.DateTime) + + URLEncoder.encode(EdmDateTime.getInstance(). + valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), + Constants.UTF8) + + suffix(version, EdmPrimitiveTypeKind.DateTime) + : URLEncoder.encode(EdmDateTimeOffset.getInstance(). + valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), + Constants.UTF8); } private static String duration(final ODataServiceVersion version, final Duration duration) @@ -261,11 +238,11 @@ public final class URIUtils { return version.compareTo(ODataServiceVersion.V40) < 0 ? EdmTime.getInstance().toUriLiteral(URLEncoder.encode(EdmTime.getInstance(). - valueToString(duration, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8)) + valueToString(duration, null, null, + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8)) : EdmDuration.getInstance().toUriLiteral(URLEncoder.encode(EdmDuration.getInstance(). - valueToString(duration, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8)); + valueToString(duration, null, null, + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8)); } private static String quoteString(final String string, final boolean singleQuoteEscape) @@ -343,24 +320,24 @@ public final class URIUtils { ? duration(version, (Duration) obj) : (obj instanceof BigDecimal) ? EdmDecimal.getInstance().valueToString(obj, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + suffix(version, EdmPrimitiveTypeKind.Decimal) : (obj instanceof Double) ? EdmDouble.getInstance().valueToString(obj, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + suffix(version, EdmPrimitiveTypeKind.Double) : (obj instanceof Float) ? EdmSingle.getInstance().valueToString(obj, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + suffix(version, EdmPrimitiveTypeKind.Single) : (obj instanceof Long) ? EdmInt64.getInstance().valueToString(obj, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + suffix(version, EdmPrimitiveTypeKind.Int64) : (obj instanceof Geospatial) ? URLEncoder.encode(EdmPrimitiveTypeFactory.getInstance(((Geospatial) obj).getEdmPrimitiveTypeKind()). - valueToString(obj, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8) + valueToString(obj, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), + Constants.UTF8) : (obj instanceof String) ? quoteString((String) obj, singleQuoteEscape) : obj.toString(); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java index 116e98c97..309cf4b68 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java @@ -23,7 +23,9 @@ import static org.junit.Assert.assertEquals; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Arrays; +import java.util.Calendar; import java.util.Collections; +import java.util.TimeZone; import org.apache.olingo.client.core.edm.EdmEnumTypeImpl; import org.apache.olingo.client.core.edm.xml.v4.EnumTypeImpl; import org.apache.olingo.commons.api.Constants; @@ -54,6 +56,16 @@ public class URIEscapeTest { assertEquals("Sales.Pattern'Yellow'", URIUtils.escape(ODataServiceVersion.V40, pattern.toUriLiteral("Yellow"))); } + @Test + public void datetimeoffset() throws UnsupportedEncodingException { + final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+1")); + calendar.clear(); + calendar.set(2014, 6, 11, 12, 30, 04); + + assertEquals(URLEncoder.encode("2014-07-11T12:30:04+01:00", Constants.UTF8), + URIUtils.escape(ODataServiceVersion.V40, calendar)); + } + @Test public void geospatial() throws UnsupportedEncodingException { final Point point = new Point(Geospatial.Dimension.GEOGRAPHY, null); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/FilterFactoryTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/FilterFactoryTest.java index 06a07e6b7..490759c8a 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/FilterFactoryTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/FilterFactoryTest.java @@ -18,6 +18,12 @@ */ package org.apache.olingo.client.core.uri.v4; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Calendar; +import java.util.TimeZone; +import static org.junit.Assert.assertEquals; + import org.apache.olingo.client.api.v4.ODataClient; import org.apache.olingo.client.api.uri.URIFilter; import org.apache.olingo.client.api.uri.v4.FilterArgFactory; @@ -25,12 +31,10 @@ import org.apache.olingo.client.api.uri.v4.FilterFactory; import org.apache.olingo.client.core.AbstractTest; import org.apache.olingo.client.core.edm.EdmEnumTypeImpl; import org.apache.olingo.client.core.edm.xml.v4.EnumTypeImpl; +import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; - -import static org.junit.Assert.assertEquals; - import org.junit.Test; public class FilterFactoryTest extends AbstractTest { @@ -59,9 +63,8 @@ public class FilterFactoryTest extends AbstractTest { @Test public void contains() { - final URIFilter filter = getFilterFactory().match( - getFilterArgFactory().contains( - getFilterArgFactory().property("CompanyName"), getFilterArgFactory().literal("Alfreds"))); + final URIFilter filter = getFilterFactory().match(getFilterArgFactory().contains( + getFilterArgFactory().property("CompanyName"), getFilterArgFactory().literal("Alfreds"))); assertEquals("contains(CompanyName,'Alfreds')", filter.build()); } @@ -83,4 +86,16 @@ public class FilterFactoryTest extends AbstractTest { assertEquals("Items/any(d:d/Quantity gt 100)", filter.build()); } + + @Test + public void issueOLINGO357() throws UnsupportedEncodingException { + final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT-8")); + calendar.clear(); + calendar.set(2011, 2, 8, 14, 21, 12); + + final URIFilter filter = getFilterFactory().ge("OrderDate", calendar); + assertEquals("(OrderDate ge " + URLEncoder.encode("2011-03-08T14:21:12-08:00", Constants.UTF8) + ")", + filter.build()); + } + } From db149fd3b06a38dd7c9352a5f38e4cbc185d37cc Mon Sep 17 00:00:00 2001 From: Stephan Klevenz Date: Fri, 11 Jul 2014 15:38:26 +0200 Subject: [PATCH 04/16] [OLINGO-343] javadoc target --- lib/server-core/pom.xml | 4 +- pom.xml | 256 ++++++++++++++++++++++++++-------------- 2 files changed, 167 insertions(+), 93 deletions(-) diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml index 6bf11a243..51c24f02f 100644 --- a/lib/server-core/pom.xml +++ b/lib/server-core/pom.xml @@ -81,7 +81,6 @@ org.codehaus.mojo build-helper-maven-plugin - 1.7 generate-sources @@ -97,9 +96,8 @@ - org.antlr + org.antlr antlr4-maven-plugin - ${antlr.version} diff --git a/pom.xml b/pom.xml index 71813b2fd..3eed29ced 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.olingo @@ -95,6 +95,7 @@ ${log.directory}/cargo.log ${log.directory}/cargo-output.log 7.0.54 + 1.9 UTF-8 @@ -249,9 +250,19 @@ - com.keyboardsamurais.maven - maven-timestamp-plugin - 1.0 + org.codehaus.mojo + build-helper-maven-plugin + ${build-helper.version} + + + org.antlr + antlr4-maven-plugin + ${antlr.version} + + + com.keyboardsamurais.maven + maven-timestamp-plugin + 1.0 org.apache.rat @@ -266,119 +277,171 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 - - true - true - -Xlint:unchecked - + 2.3.2 - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 - - - - org.codehaus.cargo - cargo-maven2-plugin - 1.4.8 - - - tomcat7x - - http://archive.apache.org/dist/tomcat/tomcat-7/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip - ${settings.localRepository}/org/codehaus/cargo/cargo-container-archives - ${project.build.directory}/cargo/extract - - ${cargo.log} - ${cargo.output} - - - - org.apache.maven.plugins maven-surefire-plugin 2.17 - - true - alphabetical - UTF-8 - UTF-8 - UTF-8 - -Dfile.encoding=UTF-8 - org.apache.maven.plugins maven-failsafe-plugin 2.17 - - true - alphabetical - UTF-8 - UTF-8 - UTF-8 - -Dfile.encoding=UTF-8 - - - - integration-test - - integration-test - verify - - - - org.apache.maven.plugins maven-resources-plugin 2.6 - - UTF-8 - false - - ${*} - - - org.sonatype.plugins jarjar-maven-plugin 1.8 - org.apache.maven.plugins maven-war-plugin 2.4 - org.apache.maven.plugins maven-invoker-plugin 1.8 - org.apache.maven.plugins maven-javadoc-plugin 2.9.1 + + org.codehaus.cargo + cargo-maven2-plugin + 1.4.8 + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + verify + + jar-no-fork + + + + + + maven-remote-resources-plugin + + + + process + + + + Apache Olingo + + + org.apache:apache-jar-resource-bundle:1.4 + + + + + + + maven-war-plugin + + + + + ${project.build.directory}/maven-shared-archive-resources + + META-INF/* + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + alphabetical + UTF-8 + UTF-8 + UTF-8 + -Dfile.encoding=UTF-8 + + + + org.apache.maven.plugins + maven-failsafe-plugin + + true + alphabetical + UTF-8 + UTF-8 + UTF-8 + -Dfile.encoding=UTF-8 + + + + integration-test + + integration-test + verify + + + + + + org.apache.maven.plugins + maven-resources-plugin + + UTF-8 + false + + ${*} + + + + + org.codehaus.cargo + cargo-maven2-plugin + + + tomcat7x + + http://archive.apache.org/dist/tomcat/tomcat-7/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip + ${settings.localRepository}/org/codehaus/cargo/cargo-container-archives + ${project.build.directory}/cargo/extract + + ${cargo.log} + ${cargo.output} + + + org.apache.maven.plugins maven-compiler-plugin 1.6 1.6 + true + true + -Xlint:unchecked @@ -472,30 +535,43 @@ - javadocs - + apache-release - javadoc:aggregate - org.apache.maven.plugins maven-javadoc-plugin - true - - javadocs - true - true - - http://docs.oracle.com/javaee/6/api/ - http://www.slf4j.org/api/ - http://commons.apache.org/proper/commons-lang/javadocs/api-release/ - http://commons.apache.org/proper/commons-io/javadocs/api-release/ - http://commons.apache.org/proper/commons-codec/archives/1.9/apidocs/ - http://www.viste.com/Java/Language/http-client/httpcomponents-client-4.2.3-bin/httpcomponents-client-4.2.3/javadoc/ - http://fasterxml.github.io/jackson-databind/javadoc/2.3.0/ - - + + + javadoc-jar + package + + aggregate-jar + + + + org.apache.olingo.commons.core:org.apache.olingo.commons.core.*:org.apache.olingo.client.core:org.apache.olingo.client.core.*:org.apache.olingo.server.core:org.apache.olingo.server.core.* + + + -quiet + + + + OData Client + org.apache.olingo.client.api:org.apache.olingo.client.api.* + + + OData Server + org.apache.olingo.server.api:org.apache.olingo.server.api.* + + + OData Commons + org.apache.olingo.commons.api:org.apache.olingo.commons.api.* + + + + + From afba7fd65c80c70f9718ce97d7ec6c7624c3419d Mon Sep 17 00:00:00 2001 From: Stephan Klevenz Date: Fri, 11 Jul 2014 15:41:52 +0200 Subject: [PATCH 05/16] [OLINGO-343] javadoc target --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3eed29ced..173143d14 100644 --- a/pom.xml +++ b/pom.xml @@ -550,7 +550,7 @@ - org.apache.olingo.commons.core:org.apache.olingo.commons.core.*:org.apache.olingo.client.core:org.apache.olingo.client.core.*:org.apache.olingo.server.core:org.apache.olingo.server.core.* + org.apache.olingo.commons.core:org.apache.olingo.commons.core.*:org.apache.olingo.client.core:org.apache.olingo.client.core.*:org.apache.olingo.server.core:org.apache.olingo.server.core.*:org.apache.olingo.fit:org.apache.olingo.fit.* -quiet From c3a709309e19af8fc12807d71283d7ef624117d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= <--global> Date: Sat, 12 Jul 2014 17:34:21 +0200 Subject: [PATCH 06/16] Several Android enhancements --- ext/client-core-android/pom.xml | 8 +- .../http/AndroidHttpClientFactory.java | 25 ++++- ext/client-proxy-android/pom.xml | 28 ++++- .../olingo/ext/proxy/api/AsyncCall.java | 4 +- .../TransactionalPersistenceManagerImpl.java | 5 +- .../olingo/fit/utils/AbstractUtilities.java | 1 - .../apache/olingo/fit/v3/ErrorTestITCase.java | 13 +-- .../olingo/client/api/CommonODataClient.java | 2 +- ...nConfiguration.java => Configuration.java} | 2 +- .../request/batch/ODataBatchResponseItem.java | 4 +- .../client/api/http/HttpClientFactory.java | 4 +- .../api/http/HttpUriRequestFactory.java | 2 +- .../olingo/client/api/v3/ODataClient.java | 4 - .../olingo/client/api/v4/ODataClient.java | 4 - .../client/core/AbstractODataClient.java | 8 ++ ...figuration.java => ConfigurationImpl.java} | 10 +- .../client/core/ODataClientFactory.java | 1 - .../request/AbstractODataRequest.java | 37 +++--- .../batch/AbstractODataBatchResponseItem.java | 8 +- .../batch/ODataChangesetResponseItem.java | 4 +- .../request/batch/ODataSingleRequestImpl.java | 3 +- .../batch/ODataSingleResponseItem.java | 5 +- .../batch/v3/ODataBatchRequestImpl.java | 17 ++- .../batch/v4/ODataBatchRequestImpl.java | 18 +-- .../request/cud/ODataDeleteRequestImpl.java | 29 +---- .../cud/ODataEntityCreateRequestImpl.java | 27 ++--- .../cud/ODataEntityUpdateRequestImpl.java | 51 ++++----- .../cud/ODataPropertyUpdateRequestImpl.java | 26 ++--- .../cud/ODataValueUpdateRequestImpl.java | 25 +---- .../cud/v3/ODataLinkCreateRequestImpl.java | 20 +--- .../cud/v3/ODataLinkUpdateRequestImpl.java | 16 +-- .../invoke/AbstractODataInvokeRequest.java | 47 +++----- .../retrieve/AbstractMetadataRequestImpl.java | 6 +- .../AbstractODataRetrieveRequest.java | 20 +--- .../retrieve/EdmMetadataRequestImpl.java | 3 +- .../retrieve/ODataEntityRequestImpl.java | 27 ++--- .../ODataEntitySetIteratorRequestImpl.java | 14 +-- .../retrieve/ODataEntitySetRequestImpl.java | 25 +---- .../retrieve/ODataMediaRequestImpl.java | 21 +--- .../retrieve/ODataPropertyRequestImpl.java | 24 +--- .../request/retrieve/ODataRawRequestImpl.java | 23 +--- .../ODataServiceDocumentRequestImpl.java | 26 ++--- .../retrieve/ODataValueRequestImpl.java | 27 ++--- .../v3/ODataLinkCollectionRequestImpl.java | 25 ++--- .../retrieve/v3/XMLMetadataRequestImpl.java | 25 +---- .../retrieve/v4/ODataDeltaRequestImpl.java | 22 ++-- .../retrieve/v4/XMLMetadataRequestImpl.java | 18 +-- .../AbstractODataStreamedRequest.java | 6 +- .../ODataMediaEntityCreateRequestImpl.java | 23 +--- .../ODataMediaEntityUpdateRequestImpl.java | 21 +--- .../ODataStreamUpdateRequestImpl.java | 20 +--- .../request/v4/AsyncRequestWrapperImpl.java | 6 +- .../response/AbstractODataResponse.java | 29 ++--- .../batch/ODataBatchErrorResponse.java | 8 +- .../batch/ODataBatchResponseManager.java | 4 +- .../response/v4/AsyncResponseImpl.java | 23 +--- .../core/http/AbstractHttpClientFactory.java | 50 +++++++++ .../core/http/BasicAuthHttpClientFactory.java | 4 +- .../core/http/DefaultHttpClientFactory.java | 40 ++----- .../http/DefaultHttpUriRequestFactory.java | 2 +- .../core/http/NTLMAuthHttpClientFactory.java | 4 +- .../http/ProxyWrapperHttpClientFactory.java | 9 +- .../client/core/uri/AbstractURIBuilder.java | 7 +- .../client/core/uri/v3/URIBuilderImpl.java | 4 +- .../client/core/uri/v4/URIBuilderImpl.java | 4 +- .../client/core/v3/ODataClientImpl.java | 13 +-- .../client/core/v4/ODataClientImpl.java | 12 +- .../commons/api/format/ContentType.java | 106 +++++++++++------- pom.xml | 23 +++- 69 files changed, 484 insertions(+), 698 deletions(-) rename lib/client-api/src/main/java/org/apache/olingo/client/api/v4/Configuration.java => ext/client-core-android/src/main/java/org/apache/olingo/client/core/android/http/AndroidHttpClientFactory.java (51%) rename lib/client-api/src/main/java/org/apache/olingo/client/api/{CommonConfiguration.java => Configuration.java} (99%) rename lib/client-core/src/main/java/org/apache/olingo/client/core/{Configuration.java => ConfigurationImpl.java} (98%) create mode 100644 lib/client-core/src/main/java/org/apache/olingo/client/core/http/AbstractHttpClientFactory.java diff --git a/ext/client-core-android/pom.xml b/ext/client-core-android/pom.xml index 7599970f0..ed94bbfc0 100644 --- a/ext/client-core-android/pom.xml +++ b/ext/client-core-android/pom.xml @@ -39,7 +39,12 @@ org.apache.olingo olingo-client-core ${project.version} - true + provided + + + + com.google.android + android @@ -65,7 +70,6 @@ org.apache.commons:commons-lang3 org.slf4j:slf4j-api commons-io:commons-io - org.apache.httpcomponents:httpcore com.fasterxml.jackson.core:jackson-core com.fasterxml.jackson.core:jackson-databind com.fasterxml.jackson.core:jackson-annotations diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/Configuration.java b/ext/client-core-android/src/main/java/org/apache/olingo/client/core/android/http/AndroidHttpClientFactory.java similarity index 51% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/v4/Configuration.java rename to ext/client-core-android/src/main/java/org/apache/olingo/client/core/android/http/AndroidHttpClientFactory.java index f7daa911f..4baa0c233 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/Configuration.java +++ b/ext/client-core-android/src/main/java/org/apache/olingo/client/core/android/http/AndroidHttpClientFactory.java @@ -16,11 +16,28 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.olingo.client.core.android.http; -package org.apache.olingo.client.api.v4; +import android.net.http.AndroidHttpClient; +import java.net.URI; +import org.apache.http.client.HttpClient; +import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.client.core.http.AbstractHttpClientFactory; -import org.apache.olingo.client.api.CommonConfiguration; +public class AndroidHttpClientFactory extends AbstractHttpClientFactory { + + private static final long serialVersionUID = -5224104561624556177L; + + @Override + public HttpClient create(final HttpMethod method, final URI uri) { + return AndroidHttpClient.newInstance(USER_AGENT); + } + + @Override + public void close(final HttpClient httpClient) { + if (httpClient instanceof AndroidHttpClient) { + ((AndroidHttpClient) httpClient).close(); + } + } -public interface Configuration extends CommonConfiguration { - } diff --git a/ext/client-proxy-android/pom.xml b/ext/client-proxy-android/pom.xml index ecfdc534e..f48cbc150 100644 --- a/ext/client-proxy-android/pom.xml +++ b/ext/client-proxy-android/pom.xml @@ -39,12 +39,37 @@ org.apache.olingo olingo-client-proxy ${project.version} - true + provided + + + com.google.android + android + + + org.codehaus.mojo + build-helper-maven-plugin + true + + + add-client-core-proxy-source + generate-sources + + add-source + + + + ${basedir}/../client-core-android/src/main/java + + + + + + org.sonatype.plugins jarjar-maven-plugin @@ -67,7 +92,6 @@ org.apache.commons:commons-lang3 org.slf4j:slf4j-api commons-io:commons-io - org.apache.httpcomponents:httpcore com.fasterxml.jackson.core:jackson-core com.fasterxml.jackson.core:jackson-databind com.fasterxml.jackson.core:jackson-annotations diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AsyncCall.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AsyncCall.java index e3eea9e5e..eb05a4e8e 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AsyncCall.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AsyncCall.java @@ -23,13 +23,13 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.apache.olingo.client.api.CommonConfiguration; +import org.apache.olingo.client.api.Configuration; public abstract class AsyncCall implements Future { private final Future future; - public AsyncCall(final CommonConfiguration configuration) { + public AsyncCall(final Configuration configuration) { this.future = configuration.getExecutor().submit(new Callable() { @Override diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java index 1165830f8..952285a8c 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java @@ -54,8 +54,8 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana protected void doFlush(final PersistenceChanges changes, final TransactionItems items) { final CommonODataBatchRequest request = factory.getClient().getBatchRequestFactory().getBatchRequest(factory.getClient().getServiceRoot()); - String accept = factory.getClient().getConfiguration().getDefaultBatchAcceptFormat().toContentTypeString(); - ((ODataRequest) request).setAccept(accept); + ((ODataRequest) request).setAccept( + factory.getClient().getConfiguration().getDefaultBatchAcceptFormat().toContentTypeString()); final BatchManager streamManager = (BatchManager) ((ODataStreamedRequest) request).payloadManager(); @@ -105,5 +105,6 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana } } } + response.close(); } } diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java index d2e6d1faf..55d6733a4 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java @@ -38,7 +38,6 @@ import java.util.regex.Pattern; import javax.ws.rs.NotFoundException; import javax.ws.rs.core.Response; -import javax.xml.stream.XMLStreamException; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java index 2d22d23d4..c394608c3 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java @@ -51,7 +51,7 @@ import org.junit.Test; public class ErrorTestITCase extends AbstractTestITCase { private class ErrorGeneratingRequest - extends AbstractODataBasicRequest> { + extends AbstractODataBasicRequest> { public ErrorGeneratingRequest(final HttpMethod method, final URI uri) { super(client, method, uri); @@ -75,16 +75,13 @@ public class ErrorTestITCase extends AbstractTestITCase { private class ErrorResponseImpl extends AbstractODataResponse implements ODataEntityCreateResponse { - private final ODataClient odataClient; - public ErrorResponseImpl(final ODataClient odataClient, final HttpClient client, final HttpResponse res) { - super(client, res); - this.odataClient = odataClient; + super(odataClient, client, res); } @Override public ODataEntity getBody() { - return odataClient.getObjectFactory().newEntity(new FullQualifiedName("Invalid.Invalid")); + return ((ODataClient) odataClient).getObjectFactory().newEntity(new FullQualifiedName("Invalid.Invalid")); } } } @@ -146,9 +143,9 @@ public class ErrorTestITCase extends AbstractTestITCase { private void instreamError(final ODataFormat format) { final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment("InStreamErrorGetCustomer"); + appendOperationCallSegment("InStreamErrorGetCustomer"); final ODataInvokeRequest req = - client.getInvokeRequestFactory().getFunctionInvokeRequest(builder.build(), ODataEntitySet.class); + client.getInvokeRequestFactory().getFunctionInvokeRequest(builder.build(), ODataEntitySet.class); req.setFormat(format); final ODataInvokeResponse res = req.execute(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java index 136f07a5c..336fa6fb9 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java @@ -47,7 +47,7 @@ public interface CommonODataClient { ODataHeaders newVersionHeaders(); - CommonConfiguration getConfiguration(); + Configuration getConfiguration(); ODataPreferences newPreferences(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/Configuration.java similarity index 99% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/Configuration.java index b2fb01766..e1bf90788 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/Configuration.java @@ -28,7 +28,7 @@ import org.apache.olingo.commons.api.format.ODataFormat; /** * Configuration wrapper. */ -public interface CommonConfiguration { +public interface Configuration { /** * Gets the configured default Accept header value format for a batch request. diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataBatchResponseItem.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataBatchResponseItem.java index 388250492..2c829e9e4 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataBatchResponseItem.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataBatchResponseItem.java @@ -50,11 +50,11 @@ public interface ODataBatchResponseItem extends Iterator { boolean isChangeset(); /** - * Checks if the current item is a braking item like as error item or asynchronous response part. + * Checks if the current item is a breaking item like as error item or asynchronous response part. * * @return 'TRUE' if breaking; 'FALSE' otherwise. */ - boolean isBreakingitem(); + boolean isBreaking(); /** * Closes the current batch responses item including all wrapped OData responses. diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/http/HttpClientFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/http/HttpClientFactory.java index 367ef0179..b7711818f 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/http/HttpClientFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/http/HttpClientFactory.java @@ -26,5 +26,7 @@ import org.apache.http.client.HttpClient; */ public interface HttpClientFactory { - HttpClient createHttpClient(HttpMethod method, URI uri); + HttpClient create(HttpMethod method, URI uri); + + void close(HttpClient httpClient); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/http/HttpUriRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/http/HttpUriRequestFactory.java index 1687045c8..18b89bd31 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/http/HttpUriRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/http/HttpUriRequestFactory.java @@ -26,5 +26,5 @@ import org.apache.http.client.methods.HttpUriRequest; */ public interface HttpUriRequestFactory { - HttpUriRequest createHttpUriRequest(HttpMethod method, URI uri); + HttpUriRequest create(HttpMethod method, URI uri); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java index 71d5ffdc7..4e8acb136 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java @@ -18,7 +18,6 @@ */ package org.apache.olingo.client.api.v3; -import org.apache.olingo.client.api.CommonConfiguration; import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory; @@ -34,9 +33,6 @@ import org.apache.olingo.commons.api.format.ODataFormat; public interface ODataClient extends CommonODataClient { - @Override - CommonConfiguration getConfiguration(); - @Override ODataDeserializer getDeserializer(ODataFormat format); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java index ee1fe97f6..2c9ba9086 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java @@ -18,7 +18,6 @@ */ package org.apache.olingo.client.api.v4; -import org.apache.olingo.client.api.CommonConfiguration; import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory; @@ -36,9 +35,6 @@ import org.apache.olingo.commons.api.format.ODataFormat; public interface ODataClient extends CommonODataClient { - @Override - CommonConfiguration getConfiguration(); - @Override ODataDeserializer getDeserializer(ODataFormat format); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java index 2f6e860d2..5f04a4bc6 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java @@ -19,6 +19,7 @@ package org.apache.olingo.client.core; import org.apache.olingo.client.api.CommonODataClient; +import org.apache.olingo.client.api.Configuration; import org.apache.olingo.client.api.communication.header.ODataPreferences; import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType; import org.apache.olingo.client.api.serialization.ODataWriter; @@ -26,8 +27,15 @@ import org.apache.olingo.client.core.serialization.ODataWriterImpl; public abstract class AbstractODataClient implements CommonODataClient { + protected final Configuration configuration = new ConfigurationImpl(); + private final ODataWriter writer = new ODataWriterImpl(this); + @Override + public Configuration getConfiguration() { + return configuration; + } + @Override public ODataPreferences newPreferences() { return new ODataPreferences(getServiceVersion()); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/ConfigurationImpl.java similarity index 98% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/ConfigurationImpl.java index 5b8f36b3f..ca8884562 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/Configuration.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/ConfigurationImpl.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.apache.olingo.client.api.CommonConfiguration; +import org.apache.olingo.client.api.Configuration; import org.apache.olingo.client.api.http.HttpClientFactory; import org.apache.olingo.client.api.http.HttpUriRequestFactory; import org.apache.olingo.client.core.http.DefaultHttpClientFactory; @@ -31,7 +31,7 @@ import org.apache.olingo.client.core.http.DefaultHttpUriRequestFactory; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.format.ODataFormat; -public class Configuration implements CommonConfiguration { +public class ConfigurationImpl implements Configuration { private static final String DEFAULT_PUB_FORMAT = "pubFormat"; @@ -48,7 +48,7 @@ public class Configuration implements CommonConfiguration { private static final String USE_XHTTP_METHOD = "useHTTPMethod"; private static final String KEY_AS_SEGMENT = "keyAsSegment"; - + private static final String ADDRESS_DERIVED_TYPE = "addressDerivedType"; private static final String USE_OPERATION_FQN_IN_URL = "useOperationFqnInUrl"; @@ -198,7 +198,7 @@ public class Configuration implements CommonConfiguration { public void setAddressingDerivedTypes(final boolean value) { setProperty(ADDRESS_DERIVED_TYPE, value); } - + @Override public boolean isUseUrlOperationFQN() { return (Boolean) getProperty(USE_OPERATION_FQN_IN_URL, true); @@ -208,7 +208,7 @@ public class Configuration implements CommonConfiguration { public void setUseUrlOperationFQN(final boolean value) { setProperty(USE_OPERATION_FQN_IN_URL, value); } - + @Override public ExecutorService getExecutor() { return executor; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientFactory.java index fd462ff32..ecefb369c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/ODataClientFactory.java @@ -20,7 +20,6 @@ package org.apache.olingo.client.core; import org.apache.olingo.commons.api.format.ODataFormat; - public final class ODataClientFactory { public static org.apache.olingo.client.api.v3.ODataClient getV3() { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java index 58412fc7e..ee3f74f2c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java @@ -84,12 +84,13 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD /** * Constructor. * - * @param odataClient client instance getting this request - * @param method HTTP request method. If configured X-HTTP-METHOD header will be used. - * @param uri OData request URI. + * @param odataClient client instance getting this request + * @param method HTTP request method. If configured X-HTTP-METHOD header will be used. + * @param uri OData request URI. */ protected AbstractODataRequest(final CommonODataClient odataClient, final HttpMethod method, final URI uri) { - + super(); + this.odataClient = odataClient; this.method = method; @@ -99,15 +100,13 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD // target uri this.uri = uri; - HttpClient _httpClient = odataClient.getConfiguration().getHttpClientFactory(). - createHttpClient(this.method, this.uri); + HttpClient _httpClient = odataClient.getConfiguration().getHttpClientFactory().create(this.method, this.uri); if (odataClient.getConfiguration().isGzipCompression()) { _httpClient = new DecompressingHttpClient(_httpClient); } this.httpClient = _httpClient; - this.request = odataClient.getConfiguration().getHttpUriRequestFactory(). - createHttpUriRequest(this.method, this.uri); + this.request = odataClient.getConfiguration().getHttpUriRequestFactory().create(this.method, this.uri); } public abstract ODataFormat getDefaultFormat(); @@ -184,9 +183,9 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD @Override public String getAccept() { final String acceptHead = odataHeaders.getHeader(HeaderName.accept); - return StringUtils.isBlank(acceptHead) ? - getDefaultFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString() : - acceptHead; + return StringUtils.isBlank(acceptHead) + ? getDefaultFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString() + : acceptHead; } @Override @@ -207,9 +206,9 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD @Override public String getContentType() { final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType); - return StringUtils.isBlank(contentTypeHead) ? - getDefaultFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString() : - contentTypeHead; + return StringUtils.isBlank(contentTypeHead) + ? getDefaultFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString() + : contentTypeHead; } @Override @@ -326,21 +325,21 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD /** * Gets an empty response that can be initialized by a stream. - *

+ *
* This method has to be used to build response items about a batch request. * - * @param ODataResppnse type. + * @param ODataResponse type. * @return empty OData response instance. */ @SuppressWarnings("unchecked") public V getResponseTemplate() { - for (Class clazz : this.getClass().getDeclaredClasses()) { if (ODataResponse.class.isAssignableFrom(clazz)) { try { - final Constructor constructor = clazz.getDeclaredConstructor(this.getClass()); + final Constructor constructor = clazz.getDeclaredConstructor( + this.getClass(), CommonODataClient.class, HttpClient.class, HttpResponse.class); constructor.setAccessible(true); - return (V) constructor.newInstance(this); + return (V) constructor.newInstance(this, odataClient, httpClient, null); } catch (Exception e) { LOG.error("Error retrieving response class template instance", e); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchResponseItem.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchResponseItem.java index a21e0aa61..0deaf4368 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchResponseItem.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchResponseItem.java @@ -72,7 +72,7 @@ public abstract class AbstractODataBatchResponseItem implements ODataBatchRespon */ protected ODataResponse current; - protected boolean breakingitem = false; + protected boolean breaking = false; /** * Constructor. @@ -143,15 +143,15 @@ public abstract class AbstractODataBatchResponseItem implements ODataBatchRespon expectedItemsIterator = responses.values().iterator(); } - return !breakingitem && expectedItemsIterator.hasNext(); + return !breaking && expectedItemsIterator.hasNext(); } /** * {@inheritDoc } */ @Override - public boolean isBreakingitem() { - return breakingitem; + public boolean isBreaking() { + return breaking; } /** diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetResponseItem.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetResponseItem.java index 51f3a48a3..0128894bc 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetResponseItem.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetResponseItem.java @@ -63,7 +63,7 @@ public class ODataChangesetResponseItem extends AbstractODataBatchResponseItem { } if (unexpected) { - breakingitem = true; + breaking = true; return nextUnexpected(); } else { return nextExpected(); @@ -107,7 +107,7 @@ public class ODataChangesetResponseItem extends AbstractODataBatchResponseItem { if (current.getStatusCode() >= 400) { // found error .... - breakingitem = true; + breaking = true; } return current; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleRequestImpl.java index 8b915fed9..c69213735 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleRequestImpl.java @@ -27,8 +27,7 @@ import org.apache.olingo.client.core.communication.request.AbstractODataRequest; /** * Retrieve request wrapper for the corresponding batch item. */ -public class ODataSingleRequestImpl extends AbstractODataBatchRequestItem - implements ODataSingleRequest { +public class ODataSingleRequestImpl extends AbstractODataBatchRequestItem implements ODataSingleRequest { private final ODataSingleResponseItem expectedResItem; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleResponseItem.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleResponseItem.java index 12e50f38c..cd53ede9d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleResponseItem.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleResponseItem.java @@ -22,7 +22,6 @@ import java.util.Collection; import java.util.Map; import java.util.NoSuchElementException; import org.apache.olingo.client.api.communication.response.ODataResponse; -import static org.apache.olingo.client.core.communication.request.batch.AbstractODataBatchResponseItem.LOG; import org.apache.olingo.client.core.communication.response.batch.ODataBatchErrorResponse; import org.apache.olingo.client.core.communication.response.v4.AsyncResponseImpl; @@ -62,11 +61,11 @@ public class ODataSingleResponseItem extends AbstractODataBatchResponseItem { if (responseLine.getKey() == 202) { // generate async response current = new AsyncResponseImpl(responseLine, headers, batchLineIterator, boundary); - breakingitem = true; + breaking = true; } else if (responseLine.getKey() >= 400) { // generate error response current = new ODataBatchErrorResponse(responseLine, headers, batchLineIterator, boundary); - breakingitem = true; + breaking = true; } else { if (!hasNext()) { throw new NoSuchElementException("No item found"); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java index 93821daff..8863161ac 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.concurrent.TimeUnit; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; +import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; import org.apache.olingo.client.api.communication.request.ODataStreamedRequest; import org.apache.olingo.client.api.communication.request.batch.BatchManager; @@ -89,7 +90,7 @@ public class ODataBatchRequestImpl @Override protected ODataBatchResponse getResponseInstance(final long timeout, final TimeUnit unit) { - return new ODataBatchResponseImpl(httpClient, getHttpResponse(timeout, unit)); + return new ODataBatchResponseImpl(odataClient, httpClient, getHttpResponse(timeout, unit)); } @Override @@ -107,14 +108,10 @@ public class ODataBatchRequestImpl */ protected class ODataBatchResponseImpl extends AbstractODataResponse implements ODataBatchResponse { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - protected ODataBatchResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + protected ODataBatchResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { + + super(odataClient, httpClient, res); } /** @@ -125,4 +122,4 @@ public class ODataBatchRequestImpl return new ODataBatchResponseManager(this, expectedResItems); } } -} \ No newline at end of file +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java index 8fea8ce81..f7dc70797 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.concurrent.TimeUnit; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; +import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.header.HeaderName; import org.apache.olingo.client.api.communication.header.ODataPreferences; import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; @@ -95,7 +96,7 @@ public class ODataBatchRequestImpl @Override protected ODataBatchResponse getResponseInstance(final long timeout, final TimeUnit unit) { - return new ODataBatchResponseImpl(httpClient, getHttpResponse(timeout, unit)); + return new ODataBatchResponseImpl(odataClient, httpClient, getHttpResponse(timeout, unit)); } @Override @@ -110,17 +111,10 @@ public class ODataBatchRequestImpl */ protected class ODataBatchResponseImpl extends AbstractODataResponse implements ODataBatchResponse { - private ODataBatchResponseImpl() { - } + protected ODataBatchResponseImpl( + final CommonODataClient odataClient, final HttpClient httpClient, final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - protected ODataBatchResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } /** @@ -131,4 +125,4 @@ public class ODataBatchRequestImpl return new ODataBatchResponseManager(this, expectedResItems, continueOnError); } } -} \ No newline at end of file +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataDeleteRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataDeleteRequestImpl.java index 174f73980..c9b2594fb 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataDeleteRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataDeleteRequestImpl.java @@ -35,15 +35,8 @@ import org.apache.olingo.commons.api.format.ODataFormat; * This class implements an OData delete request. */ public class ODataDeleteRequestImpl extends AbstractODataBasicRequest - implements ODataDeleteRequest { + implements ODataDeleteRequest { - /** - * Constructor. - * - * @param odataClient client instance getting this request - * @param method HTTP method to be used - * @param uri URI of the entity to be deleted. - */ ODataDeleteRequestImpl(final CommonODataClient odataClient, final HttpMethod method, final URI uri) { super(odataClient, method, uri); } @@ -63,7 +56,7 @@ public class ODataDeleteRequestImpl extends AbstractODataBasicRequest - * Just to create response templates to be initialized from batch. - */ - private ODataDeleteResponseImpl() { - } + private ODataDeleteResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataDeleteResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); this.close(); } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java index e09236c6d..de514bf60 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java @@ -85,7 +85,7 @@ public class ODataEntityCreateRequestImpl ((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input)); try { - return new ODataEntityCreateResponseImpl(httpClient, doExecute()); + return new ODataEntityCreateResponseImpl(odataClient, httpClient, doExecute()); } finally { IOUtils.closeQuietly(input); } @@ -98,23 +98,10 @@ public class ODataEntityCreateRequestImpl private E entity = null; - /** - * Constructor. - *

- * Just to create response templates to be initialized from batch. - */ - private ODataEntityCreateResponseImpl() { - super(); - } + private ODataEntityCreateResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataEntityCreateResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } /** @@ -125,9 +112,9 @@ public class ODataEntityCreateRequestImpl public E getBody() { if (entity == null) { try { - final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())) - .toEntity(getRawResponse()); - + final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())). + toEntity(getRawResponse()); + entity = (E) odataClient.getBinder().getODataEntity(resource); } catch (final ODataDeserializerException e) { throw new IllegalArgumentException(e); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java index 6acbd2aa4..55f8d87af 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityUpdateRequestImpl.java @@ -45,8 +45,8 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException; * @param concrete ODataEntity implementation */ public class ODataEntityUpdateRequestImpl - extends AbstractODataBasicRequest> - implements ODataEntityUpdateRequest { + extends AbstractODataBasicRequest> + implements ODataEntityUpdateRequest { /** * Changes to be applied. @@ -62,7 +62,7 @@ public class ODataEntityUpdateRequestImpl * @param changes changes to be applied. */ public ODataEntityUpdateRequestImpl(final CommonODataClient odataClient, - final HttpMethod method, final URI uri, final E changes) { + final HttpMethod method, final URI uri, final E changes) { super(odataClient, method, uri); this.changes = changes; @@ -73,18 +73,6 @@ public class ODataEntityUpdateRequestImpl return odataClient.getConfiguration().getDefaultPubFormat(); } - @Override - public ODataEntityUpdateResponse execute() { - final InputStream input = getPayload(); - ((HttpEntityEnclosingRequestBase) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input)); - - try { - return new ODataEntityUpdateResponseImpl(httpClient, doExecute()); - } finally { - IOUtils.closeQuietly(input); - } - } - @Override protected InputStream getPayload() { try { @@ -94,6 +82,18 @@ public class ODataEntityUpdateRequestImpl } } + @Override + public ODataEntityUpdateResponse execute() { + final InputStream input = getPayload(); + ((HttpEntityEnclosingRequestBase) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input)); + + try { + return new ODataEntityUpdateResponseImpl(odataClient, httpClient, doExecute()); + } finally { + IOUtils.closeQuietly(input); + } + } + /** * Response class about an ODataEntityUpdateRequest. */ @@ -104,21 +104,10 @@ public class ODataEntityUpdateRequestImpl */ private E entity = null; - /** - * Constructor. - *

- * Just to create response templates to be initialized from batch. - */ - private ODataEntityUpdateResponseImpl() {} + private ODataEntityUpdateResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataEntityUpdateResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override @@ -126,8 +115,8 @@ public class ODataEntityUpdateRequestImpl public E getBody() { if (entity == null) { try { - final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())) - .toEntity(getRawResponse()); + final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())). + toEntity(getRawResponse()); entity = (E) odataClient.getBinder().getODataEntity(resource); } catch (final ODataDeserializerException e) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java index 738912837..f65cb9485 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java @@ -43,7 +43,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException; * This class implements an OData update entity property request. */ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest - implements ODataPropertyUpdateRequest { + implements ODataPropertyUpdateRequest { /** * Value to be created. @@ -77,7 +77,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest - * Just to create response templates to be initialized from batch. - */ - private ODataPropertyUpdateResponseImpl() { - } + private ODataPropertyUpdateResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataPropertyUpdateResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override public CommonODataProperty getBody() { if (property == null) { try { - final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())) - .toProperty(getRawResponse()); + final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())). + toProperty(getRawResponse()); property = odataClient.getBinder().getODataProperty(resource); } catch (final ODataDeserializerException e) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java index b229052b2..e1ec593cd 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java @@ -41,7 +41,7 @@ import org.apache.olingo.commons.api.format.ODataFormat; * This class implements an OData update entity property value request. */ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest - implements ODataValueUpdateRequest { + implements ODataValueUpdateRequest { /** * Value to be created. @@ -75,7 +75,7 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest - * Just to create response templates to be initialized from batch. - */ - private ODataValueUpdateResponseImpl() { - super(); - } + private ODataValueUpdateResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataValueUpdateResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override @@ -123,7 +110,7 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest - * Just to create response templates to be initialized from batch. - */ - private ODataLinkCreateResponseImpl() { - } + private ODataLinkCreateResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataLinkCreateResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java index aa00574ec..8d4464987 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/v3/ODataLinkUpdateRequestImpl.java @@ -40,7 +40,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException; * This class implements an update link OData request. */ public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest - implements ODataLinkUpdateRequest { + implements ODataLinkUpdateRequest { /** * Entity to be linked. @@ -73,7 +73,7 @@ public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest odataClient, final HttpClient httpClient, + final HttpResponse res) { + + super(odataClient, httpClient, res); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java index 5546778d6..27f40754a 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java @@ -171,7 +171,7 @@ public abstract class AbstractODataInvokeRequest } try { - return new ODataInvokeResponseImpl(httpClient, doExecute()); + return new ODataInvokeResponseImpl(odataClient, httpClient, doExecute()); } finally { IOUtils.closeQuietly(input); } @@ -184,23 +184,10 @@ public abstract class AbstractODataInvokeRequest private T invokeResult = null; - /** - * Constructor. - *

- * Just to create response templates to be initialized from batch. - */ - private ODataInvokeResponseImpl() { - super(); - } + private ODataInvokeResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataInvokeResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } /** @@ -213,19 +200,19 @@ public abstract class AbstractODataInvokeRequest if (ODataNoContent.class.isAssignableFrom(reference)) { invokeResult = reference.cast(new ODataNoContent()); } else { - // avoid getContent() twice:IllegalStateException: Content has been consumed - InputStream responseStream = this.payload == null ? res.getEntity().getContent() : this.payload; - if (CommonODataEntitySet.class.isAssignableFrom(reference)) { - invokeResult = reference.cast(odataClient.getReader().readEntitySet(responseStream, - ODataFormat.fromString(getContentType()))); - } else if (CommonODataEntity.class.isAssignableFrom(reference)) { - invokeResult = reference.cast(odataClient.getReader().readEntity(responseStream, - ODataFormat.fromString(getContentType()))); - } else if (CommonODataProperty.class.isAssignableFrom(reference)) { - invokeResult = reference.cast(odataClient.getReader().readProperty(responseStream, - ODataFormat.fromString(getContentType()))); - } - } + // avoid getContent() twice:IllegalStateException: Content has been consumed + final InputStream responseStream = this.payload == null ? res.getEntity().getContent() : this.payload; + if (CommonODataEntitySet.class.isAssignableFrom(reference)) { + invokeResult = reference.cast(odataClient.getReader().readEntitySet(responseStream, + ODataFormat.fromString(getContentType()))); + } else if (CommonODataEntity.class.isAssignableFrom(reference)) { + invokeResult = reference.cast(odataClient.getReader().readEntity(responseStream, + ODataFormat.fromString(getContentType()))); + } else if (CommonODataProperty.class.isAssignableFrom(reference)) { + invokeResult = reference.cast(odataClient.getReader().readProperty(responseStream, + ODataFormat.fromString(getContentType()))); + } + } } catch (IOException e) { throw new HttpClientException(e); } catch (final ODataDeserializerException e) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java index e84beb98d..537e00ca1 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java @@ -19,17 +19,17 @@ package org.apache.olingo.client.core.communication.request.retrieve; import java.net.URI; -import org.apache.http.entity.ContentType; import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.request.ODataRequest; +import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.format.ODataFormat; public abstract class AbstractMetadataRequestImpl extends AbstractODataRetrieveRequest { public AbstractMetadataRequestImpl(final CommonODataClient odataClient, final URI query) { super(odataClient, query); - super.setAccept(ContentType.APPLICATION_XML.getMimeType()); - super.setContentType(ContentType.APPLICATION_XML.getMimeType()); + super.setAccept(ContentType.APPLICATION_XML.toContentTypeString()); + super.setContentType(ContentType.APPLICATION_XML.toContentTypeString()); } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java index c42832c2d..9c4cf2e10 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java @@ -20,7 +20,6 @@ package org.apache.olingo.client.core.communication.request.retrieve; import java.io.InputStream; import java.net.URI; - import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.olingo.client.api.CommonODataClient; @@ -64,23 +63,10 @@ public abstract class AbstractODataRetrieveRequest protected abstract class AbstractODataRetrieveResponse extends AbstractODataResponse implements ODataRetrieveResponse { - /** - * Constructor. - *

- * Just to create response templates to be initialized from batch. - */ - protected AbstractODataRetrieveResponse() { - super(); - } + protected AbstractODataRetrieveResponse(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - protected AbstractODataRetrieveResponse(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java index 64486fff5..c902eacd4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java @@ -49,11 +49,12 @@ class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl implements final ODataRetrieveResponse> xmlMetadataResponse = odataClient.getRetrieveRequestFactory().getXMLMetadataRequest(serviceRoot).execute(); - return new AbstractODataRetrieveResponse() { + return new AbstractODataRetrieveResponse(odataClient, httpClient, null) { private Edm metadata = null; @Override public void close() { + super.close(); xmlMetadataResponse.close(); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java index 427e5b315..1b8526684 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntityRequestImpl.java @@ -54,7 +54,7 @@ public class ODataEntityRequestImpl @Override public ODataRetrieveResponse execute() { - return new ODataEntityResponseImpl(httpClient, doExecute()); + return new ODataEntityResponseImpl(odataClient, httpClient, doExecute()); } /** @@ -64,23 +64,10 @@ public class ODataEntityRequestImpl private E entity = null; - /** - * Constructor. - *
- * Just to create response templates to be initialized from batch. - */ - private ODataEntityResponseImpl() { - super(); - } + private ODataEntityResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataEntityResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override @@ -88,11 +75,11 @@ public class ODataEntityRequestImpl public E getBody() { if (entity == null) { try { - final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())) - .toEntity(getRawResponse()); + final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())). + toEntity(getRawResponse()); entity = (E) odataClient.getBinder().getODataEntity(resource); - } catch (final ODataDeserializerException e) { + } catch (ODataDeserializerException e) { throw new IllegalArgumentException(e); } finally { this.close(); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java index 5cf1377fe..de4c11dcc 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetIteratorRequestImpl.java @@ -57,7 +57,7 @@ public class ODataEntitySetIteratorRequestImpl> execute() { final HttpResponse res = doExecute(); - return new ODataEntitySetIteratorResponseImpl(httpClient, res); + return new ODataEntitySetIteratorResponseImpl(odataClient, httpClient, res); } /** @@ -65,14 +65,10 @@ public class ODataEntitySetIteratorRequestImpl odataClient, final HttpClient httpClient, + final HttpResponse res) { + + super(odataClient, httpClient, res); } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java index c5605764f..f39d113d1 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java @@ -59,7 +59,7 @@ public class ODataEntitySetRequestImpl @Override public ODataRetrieveResponse execute() { final HttpResponse res = doExecute(); - return new ODataEntitySetResponseImpl(httpClient, res); + return new ODataEntitySetResponseImpl(odataClient, httpClient, res); } /** @@ -67,23 +67,10 @@ public class ODataEntitySetRequestImpl */ protected class ODataEntitySetResponseImpl extends AbstractODataRetrieveResponse { - /** - * Constructor. - *

- * Just to create response templates to be initialized from batch. - */ - private ODataEntitySetResponseImpl() { - super(); - } + private ODataEntitySetResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataEntitySetResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override @@ -91,8 +78,8 @@ public class ODataEntitySetRequestImpl public ES getBody() { if (entitySet == null) { try { - final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())) - .toEntitySet(getRawResponse()); + final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())). + toEntitySet(getRawResponse()); entitySet = (ES) odataClient.getBinder().getODataEntitySet(resource); } catch (final ODataDeserializerException e) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java index ad2263e6c..c24f80a7b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java @@ -61,7 +61,7 @@ public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest execute() { final HttpResponse res = doExecute(); - return new ODataMediaResponseImpl(httpClient, res); + return new ODataMediaResponseImpl(odataClient, httpClient, res); } /** @@ -71,23 +71,10 @@ public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest - * Just to create response templates to be initialized from batch. - */ - private ODataMediaResponseImpl() { - super(); - } + private ODataMediaResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataMediaResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } /** diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java index f13da7d5f..25a9ca6a4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataPropertyRequestImpl.java @@ -37,7 +37,7 @@ import org.apache.olingo.commons.api.serialization.ODataDeserializerException; * This class implements an OData entity property query request. */ public class ODataPropertyRequestImpl - extends AbstractODataRetrieveRequest implements ODataPropertyRequest { + extends AbstractODataRetrieveRequest implements ODataPropertyRequest { /** * Private constructor. @@ -57,29 +57,17 @@ public class ODataPropertyRequestImpl @Override public ODataRetrieveResponse execute() { final HttpResponse res = doExecute(); - return new ODataPropertyResponseImpl(httpClient, res); + return new ODataPropertyResponseImpl(odataClient, httpClient, res); } protected class ODataPropertyResponseImpl extends AbstractODataRetrieveResponse { private T property = null; - /** - * Constructor. - *

- * Just to create response templates to be initialized from batch. - */ - private ODataPropertyResponseImpl() { - } + private ODataPropertyResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataPropertyResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override @@ -88,7 +76,7 @@ public class ODataPropertyRequestImpl if (property == null) { try { final ResWrap resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())) - .toProperty(res.getEntity().getContent()); + .toProperty(res.getEntity().getContent()); property = (T) odataClient.getBinder().getODataProperty(resource); } catch (IOException e) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java index e005c8ba9..35cf07309 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataRawRequestImpl.java @@ -63,29 +63,17 @@ public class ODataRawRequestImpl extends AbstractODataRequest implements ODataRa @Override public ODataRawResponse execute() { - return new ODataRawResponseImpl(httpClient, doExecute()); + return new ODataRawResponseImpl(odataClient, httpClient, doExecute()); } private class ODataRawResponseImpl extends AbstractODataResponse implements ODataRawResponse { private byte[] obj = null; - /** - * Constructor. - *
- * Just to create response templates to be initialized from batch. - */ - private ODataRawResponseImpl() { - } + private ODataRawResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataRawResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override @@ -101,8 +89,7 @@ public class ODataRawRequestImpl extends AbstractODataRequest implements ODataRa } try { - return odataClient.getReader(). - read(new ByteArrayInputStream(obj), getContentType(), reference); + return odataClient.getReader().read(new ByteArrayInputStream(obj), getContentType(), reference); } catch (final ODataDeserializerException e) { throw new IllegalArgumentException(e); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java index d252c6e6f..21dabf9be 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataServiceDocumentRequestImpl.java @@ -35,7 +35,7 @@ import org.apache.olingo.commons.api.serialization.ODataDeserializerException; * This class implements an OData service document request. */ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveRequest - implements ODataServiceDocumentRequest { + implements ODataServiceDocumentRequest { /** * Constructor. @@ -55,7 +55,7 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques @Override public ODataRetrieveResponse execute() { final HttpResponse res = doExecute(); - return new ODataServiceResponseImpl(httpClient, res); + return new ODataServiceResponseImpl(odataClient, httpClient, res); } /** @@ -65,30 +65,18 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques private ODataServiceDocument serviceDocument = null; - /** - * Constructor. - *

- * Just to create response templates to be initialized from batch. - */ - private ODataServiceResponseImpl() {} + private ODataServiceResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataServiceResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override public ODataServiceDocument getBody() { if (serviceDocument == null) { try { - final ResWrap resource = - odataClient.getDeserializer(ODataFormat.fromString(getContentType())) - .toServiceDocument(getRawResponse()); + final ResWrap resource = odataClient. + getDeserializer(ODataFormat.fromString(getContentType())).toServiceDocument(getRawResponse()); serviceDocument = odataClient.getBinder().getODataServiceDocument(resource.getPayload()); } catch (final ODataDeserializerException e) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java index 95cf01643..f417e5d4c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java @@ -35,7 +35,7 @@ import org.apache.olingo.commons.api.format.ODataFormat; * This class implements an OData entity property value query request. */ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest - implements ODataValueRequest { + implements ODataValueRequest { /** * Private constructor. @@ -55,7 +55,7 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest execute() { final HttpResponse res = doExecute(); - return new ODataValueResponseImpl(httpClient, res); + return new ODataValueResponseImpl(odataClient, httpClient, res); } /** @@ -65,23 +65,10 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest - * Just to create response templates to be initialized from batch. - */ - private ODataValueResponseImpl() { - super(); - } + private ODataValueResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataValueResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override @@ -91,8 +78,8 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest - implements ODataLinkCollectionRequest { + implements ODataLinkCollectionRequest { /** * Private constructor. @@ -47,7 +48,7 @@ public class ODataLinkCollectionRequestImpl extends AbstractODataRetrieveRequest */ ODataLinkCollectionRequestImpl(final ODataClient odataClient, final URI targetURI, final String linkName) { super(odataClient, - odataClient.newURIBuilder(targetURI.toASCIIString()).appendLinksSegment(linkName).build()); + odataClient.newURIBuilder(targetURI.toASCIIString()).appendLinksSegment(linkName).build()); } @Override @@ -57,29 +58,17 @@ public class ODataLinkCollectionRequestImpl extends AbstractODataRetrieveRequest @Override public ODataRetrieveResponse execute() { - return new ODataLinkCollectionResponseImpl(httpClient, doExecute()); + return new ODataLinkCollectionResponseImpl(odataClient, httpClient, doExecute()); } protected class ODataLinkCollectionResponseImpl extends AbstractODataRetrieveResponse { private ODataLinkCollection links = null; - /** - * Constructor. - *

- * Just to create response templates to be initialized from batch. - */ - private ODataLinkCollectionResponseImpl() { - } + private ODataLinkCollectionResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataLinkCollectionResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java index 1304b84e4..2b0cd1817 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java @@ -25,6 +25,7 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; +import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest; import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse; import org.apache.olingo.client.api.edm.xml.Schema; @@ -42,30 +43,17 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl> execute() { - return new XMLMetadataResponseImpl(httpClient, doExecute()); + return new XMLMetadataResponseImpl(odataClient, httpClient, doExecute()); } public class XMLMetadataResponseImpl extends AbstractODataRetrieveResponse { private Map schemas; - /** - * Constructor. - *
- * Just to create response templates to be initialized from batch. - */ - private XMLMetadataResponseImpl() { - super(); - } + private XMLMetadataResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private XMLMetadataResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override @@ -73,8 +61,7 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl(); try { - final XMLMetadata metadata = odataClient.getDeserializer(ODataFormat.XML) - .toMetadata(getRawResponse()); + final XMLMetadata metadata = odataClient.getDeserializer(ODataFormat.XML).toMetadata(getRawResponse()); for (Schema schema : metadata.getSchemas()) { schemas.put(schema.getNamespace(), schema); if (StringUtils.isNotBlank(schema.getAlias())) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java index bd32c9e77..dbcfd4a71 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/ODataDeltaRequestImpl.java @@ -36,7 +36,7 @@ import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.serialization.ODataDeserializerException; public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest - implements ODataDeltaRequest { + implements ODataDeltaRequest { public ODataDeltaRequestImpl(final CommonODataClient odataClient, final URI query) { super(odataClient, query); @@ -50,30 +50,26 @@ public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest execute() { final HttpResponse res = doExecute(); - return new ODataDeltaResponseImpl(httpClient, res); + return new ODataDeltaResponseImpl(odataClient, httpClient, res); } protected class ODataDeltaResponseImpl extends AbstractODataRetrieveResponse { private ODataDelta delta = null; - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataDeltaResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + private ODataDeltaResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { + + super(odataClient, httpClient, res); } @Override public ODataDelta getBody() { if (delta == null) { try { - final ResWrap resource = ((ODataClient) odataClient) - .getDeserializer(ODataFormat.fromString(getContentType())) - .toDelta(res.getEntity().getContent()); + final ResWrap resource = ((ODataClient) odataClient). + getDeserializer(ODataFormat.fromString(getContentType())). + toDelta(res.getEntity().getContent()); delta = ((ODataClient) odataClient).getBinder().getODataDelta(resource); } catch (IOException e) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java index 814306cf9..e489c99f7 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java @@ -24,6 +24,8 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest; import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse; import org.apache.olingo.client.api.edm.xml.Schema; @@ -51,7 +53,8 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl rootRes = rootReq.execute(); - final XMLMetadataResponseImpl response = new XMLMetadataResponseImpl(rootReq.getHttpResponse()); + final XMLMetadataResponseImpl response = + new XMLMetadataResponseImpl(odataClient, httpClient, rootReq.getHttpResponse()); final XMLMetadata rootMetadata = rootRes.getBody(); for (Schema schema : rootMetadata.getSchemas()) { @@ -137,7 +140,7 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl execute() { httpResponse = doExecute(); - return new AbstractODataRetrieveResponse(httpClient, httpResponse) { + return new AbstractODataRetrieveResponse(odataClient, httpClient, httpResponse) { @Override public XMLMetadata getBody() { @@ -155,8 +158,10 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl schemas = new HashMap(); - private XMLMetadataResponseImpl(final HttpResponse res) { - super(); + private XMLMetadataResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { + + super(odataClient, httpClient, null); statusCode = res.getStatusLine().getStatusCode(); statusMessage = res.getStatusLine().getReasonPhrase(); @@ -164,11 +169,6 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl getBody() { return schemas; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java index 0f6a18891..d55c27843 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java @@ -28,7 +28,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.entity.ContentType; import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.ODataBatchConstants; import org.apache.olingo.client.api.communication.request.ODataPayloadManager; @@ -40,6 +39,7 @@ import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.client.core.communication.request.AbstractODataRequest; import org.apache.olingo.client.core.communication.request.Wrapper; import org.apache.olingo.client.core.uri.URIUtils; +import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.format.ODataFormat; /** @@ -73,8 +73,8 @@ public abstract class AbstractODataStreamedRequest @Override protected ODataMediaEntityCreateResponse getResponse(final long timeout, final TimeUnit unit) { finalizeBody(); - return new ODataMediaEntityCreateResponseImpl(httpClient, getHttpResponse(timeout, unit)); + return new ODataMediaEntityCreateResponseImpl(odataClient, httpClient, getHttpResponse(timeout, unit)); } } @@ -99,22 +99,10 @@ public class ODataMediaEntityCreateRequestImpl private E entity = null; - /** - * Constructor. - *

- * Just to create response templates to be initialized from batch. - */ - private ODataMediaEntityCreateResponseImpl() { - } + private ODataMediaEntityCreateResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataMediaEntityCreateResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override @@ -122,8 +110,7 @@ public class ODataMediaEntityCreateRequestImpl public E getBody() { if (entity == null) { try { - final ResWrap resource = odataClient.getDeserializer(getFormat()) - .toEntity(getRawResponse()); + final ResWrap resource = odataClient.getDeserializer(getFormat()).toEntity(getRawResponse()); entity = (E) odataClient.getBinder().getODataEntity(resource); } catch (final ODataDeserializerException e) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java index 154d69943..2290d68a0 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java @@ -88,7 +88,7 @@ public class ODataMediaEntityUpdateRequestImpl @Override protected ODataMediaEntityUpdateResponse getResponse(final long timeout, final TimeUnit unit) { finalizeBody(); - return new ODataMediaEntityUpdateResponseImpl(httpClient, getHttpResponse(timeout, unit)); + return new ODataMediaEntityUpdateResponseImpl(odataClient, httpClient, getHttpResponse(timeout, unit)); } } @@ -100,23 +100,10 @@ public class ODataMediaEntityUpdateRequestImpl private E entity = null; - /** - * Constructor. - *
- * Just to create response templates to be initialized from batch. - */ - private ODataMediaEntityUpdateResponseImpl() { - super(); - } + private ODataMediaEntityUpdateResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataMediaEntityUpdateResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataStreamUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataStreamUpdateRequestImpl.java index 216c5214c..c9dcf5e84 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataStreamUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataStreamUpdateRequestImpl.java @@ -85,7 +85,7 @@ public class ODataStreamUpdateRequestImpl @Override protected ODataStreamUpdateResponse getResponse(final long timeout, final TimeUnit unit) { finalizeBody(); - return new ODataStreamUpdateResponseImpl(httpClient, getHttpResponse(timeout, unit)); + return new ODataStreamUpdateResponseImpl(odataClient, httpClient, getHttpResponse(timeout, unit)); } } @@ -96,22 +96,10 @@ public class ODataStreamUpdateRequestImpl private InputStream input = null; - /** - * Constructor. - *

- * Just to create response templates to be initialized from batch. - */ - private ODataStreamUpdateResponseImpl() { - } + private ODataStreamUpdateResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - private ODataStreamUpdateResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } /** diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java index 2ec51e098..98866986c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java @@ -85,13 +85,13 @@ public class AsyncRequestWrapperImpl extends AbstractRe // target uri this.uri = odataRequest.getURI(); - HttpClient _httpClient = odataClient.getConfiguration().getHttpClientFactory().createHttpClient(method, this.uri); + HttpClient _httpClient = odataClient.getConfiguration().getHttpClientFactory().create(method, this.uri); if (odataClient.getConfiguration().isGzipCompression()) { _httpClient = new DecompressingHttpClient(_httpClient); } this.httpClient = _httpClient; - this.request = odataClient.getConfiguration().getHttpUriRequestFactory().createHttpUriRequest(method, this.uri); + this.request = odataClient.getConfiguration().getHttpUriRequestFactory().create(method, this.uri); } @Override @@ -292,7 +292,7 @@ public class AsyncRequestWrapperImpl extends AbstractRe } final HttpUriRequest monitor = odataClient.getConfiguration().getHttpUriRequestFactory(). - createHttpUriRequest(HttpMethod.GET, location); + create(HttpMethod.GET, location); return executeHttpRequest(httpClient, monitor); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java index 3bac01840..3127608d3 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java @@ -33,6 +33,7 @@ import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.HttpClient; +import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.header.HeaderName; import org.apache.olingo.client.api.communication.request.ODataStreamer; import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator; @@ -55,10 +56,12 @@ public abstract class AbstractODataResponse implements ODataResponse { */ protected static final Logger LOG = LoggerFactory.getLogger(ODataResponse.class); + protected final CommonODataClient odataClient; + /** * HTTP client. */ - protected final HttpClient client; + protected final HttpClient httpClient; /** * HTTP response. @@ -96,21 +99,11 @@ public abstract class AbstractODataResponse implements ODataResponse { */ protected ODataBatchController batchInfo = null; - /** - * Constructor. - */ - public AbstractODataResponse() { - this(null, null); - } + public AbstractODataResponse( + final CommonODataClient odataClient, final HttpClient httpclient, final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - public AbstractODataResponse(final HttpClient client, final HttpResponse res) { - this.client = client; + this.odataClient = odataClient; + this.httpClient = httpclient; this.res = res; if (res != null) { initFromHttpResponse(res); @@ -285,11 +278,7 @@ public abstract class AbstractODataResponse implements ODataResponse { */ @Override public void close() { - if (client == null) { - IOUtils.closeQuietly(payload); - } else { - this.client.getConnectionManager().shutdown(); - } + odataClient.getConfiguration().getHttpClientFactory().close(httpClient); if (batchInfo != null) { batchInfo.setValidBatch(false); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchErrorResponse.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchErrorResponse.java index fa41b8226..6305aad57 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchErrorResponse.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchErrorResponse.java @@ -24,21 +24,15 @@ import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIt import org.apache.olingo.client.core.communication.request.batch.ODataBatchController; import org.apache.olingo.client.core.communication.response.AbstractODataResponse; -/** - * Abstract representation of an OData response. - */ public class ODataBatchErrorResponse extends AbstractODataResponse { - /** - * Constructor. - */ public ODataBatchErrorResponse( final Map.Entry responseLine, final Map> headers, final ODataBatchLineIterator batchLineIterator, final String boundary) { - super(); + super(null, null, null); if (hasBeenInitialized) { throw new IllegalStateException("Request already initialized"); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java index 9db555ed1..5f522478e 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java @@ -77,6 +77,7 @@ public class ODataBatchResponseManager implements Iterator expectedItems) { + this(res, expectedItems, false); } @@ -84,6 +85,7 @@ public class ODataBatchResponseManager implements Iterator expectedItems, final boolean continueOnError) { + this.continueOnError = continueOnError; try { @@ -106,7 +108,7 @@ public class ODataBatchResponseManager implements Iterator - * Just to create response templates to be initialized from batch. - */ - public AsyncResponseImpl() { - super(); - } + public AsyncResponseImpl(final CommonODataClient odataClient, final HttpClient httpClient, + final HttpResponse res) { - /** - * Constructor. - * - * @param client HTTP client. - * @param res HTTP response. - */ - public AsyncResponseImpl(final HttpClient client, final HttpResponse res) { - super(client, res); + super(odataClient, httpClient, res); } /** @@ -59,7 +47,8 @@ public class AsyncResponseImpl extends AbstractODataResponse implements AsyncRes final Map> headers, final ODataBatchLineIterator batchLineIterator, final String boundary) { - super(); + + super(null, null, null); if (hasBeenInitialized) { throw new IllegalStateException("Request already initialized"); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/AbstractHttpClientFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/AbstractHttpClientFactory.java new file mode 100644 index 000000000..271dcc68b --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/AbstractHttpClientFactory.java @@ -0,0 +1,50 @@ +/* + * 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.client.core.http; + +import java.io.InputStream; +import java.util.Properties; +import org.apache.commons.io.IOUtils; +import org.apache.olingo.client.api.http.HttpClientFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class AbstractHttpClientFactory implements HttpClientFactory { + + private static final Logger LOG = LoggerFactory.getLogger(AbstractHttpClientFactory.class); + + protected static final String USER_AGENT; + + static { + final StringBuilder userAgent = new StringBuilder("Apache-Olingo"); + + final InputStream input = AbstractHttpClientFactory.class.getResourceAsStream("/client.properties"); + try { + final Properties prop = new Properties(); + prop.load(input); + userAgent.append('/').append(prop.getProperty("version")); + } catch (Exception e) { + LOG.warn("Could not get Apache Olingo version", e); + } finally { + IOUtils.closeQuietly(input); + } + + USER_AGENT = userAgent.toString(); + } +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/BasicAuthHttpClientFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/BasicAuthHttpClientFactory.java index 0f60a3195..b9cd98084 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/BasicAuthHttpClientFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/BasicAuthHttpClientFactory.java @@ -42,8 +42,8 @@ public class BasicAuthHttpClientFactory extends DefaultHttpClientFactory { } @Override - public DefaultHttpClient createHttpClient(final HttpMethod method, final URI uri) { - final DefaultHttpClient httpclient = super.createHttpClient(method, uri); + public DefaultHttpClient create(final HttpMethod method, final URI uri) { + final DefaultHttpClient httpclient = super.create(method, uri); httpclient.getCredentialsProvider().setCredentials( new AuthScope(uri.getHost(), uri.getPort()), diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/DefaultHttpClientFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/DefaultHttpClientFactory.java index 6c5cd4912..fd64c2f8f 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/DefaultHttpClientFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/DefaultHttpClientFactory.java @@ -18,51 +18,29 @@ */ package org.apache.olingo.client.core.http; -import java.io.InputStream; -import java.io.Serializable; import java.net.URI; -import java.util.Properties; -import org.apache.commons.io.IOUtils; - +import org.apache.http.client.HttpClient; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.CoreProtocolPNames; -import org.apache.olingo.client.api.http.HttpClientFactory; import org.apache.olingo.client.api.http.HttpMethod; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Default implementation returning HttpClients with default parameters. */ -public class DefaultHttpClientFactory implements HttpClientFactory, Serializable { +public class DefaultHttpClientFactory extends AbstractHttpClientFactory { private static final long serialVersionUID = -2461355444507227332L; - private static final Logger LOG = LoggerFactory.getLogger(DefaultHttpClientFactory.class); - - private static final String USER_AGENT; - - static { - final StringBuilder userAgent = new StringBuilder("Apache-Olingo"); - - final InputStream input = DefaultHttpClientFactory.class.getResourceAsStream("/client.properties"); - try { - final Properties prop = new Properties(); - prop.load(input); - userAgent.append('/').append(prop.getProperty("version")); - } catch (Exception e) { - LOG.warn("Could not get Apache Olingo version", e); - } finally { - IOUtils.closeQuietly(input); - } - - USER_AGENT = userAgent.toString(); - } - @Override - public DefaultHttpClient createHttpClient(final HttpMethod method, final URI uri) { + public DefaultHttpClient create(final HttpMethod method, final URI uri) { final DefaultHttpClient client = new DefaultHttpClient(); client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, USER_AGENT); return client; } + + @Override + public void close(final HttpClient httpClient) { + httpClient.getConnectionManager().shutdown(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/DefaultHttpUriRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/DefaultHttpUriRequestFactory.java index aaa17c087..c336b22f6 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/DefaultHttpUriRequestFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/DefaultHttpUriRequestFactory.java @@ -34,7 +34,7 @@ import org.apache.olingo.client.api.http.HttpUriRequestFactory; public class DefaultHttpUriRequestFactory implements HttpUriRequestFactory { @Override - public HttpUriRequest createHttpUriRequest(final HttpMethod method, final URI uri) { + public HttpUriRequest create(final HttpMethod method, final URI uri) { HttpUriRequest result; switch (method) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/NTLMAuthHttpClientFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/NTLMAuthHttpClientFactory.java index 5f2578bea..c776bf934 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/NTLMAuthHttpClientFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/NTLMAuthHttpClientFactory.java @@ -58,8 +58,8 @@ public class NTLMAuthHttpClientFactory extends DefaultHttpClientFactory { } @Override - public DefaultHttpClient createHttpClient(final HttpMethod method, final URI uri) { - final DefaultHttpClient httpclient = super.createHttpClient(method, uri); + public DefaultHttpClient create(final HttpMethod method, final URI uri) { + final DefaultHttpClient httpclient = super.create(method, uri); final CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(AuthScope.ANY, diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrapperHttpClientFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrapperHttpClientFactory.java index 29b6fe43e..2ce0b3d82 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrapperHttpClientFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrapperHttpClientFactory.java @@ -68,9 +68,9 @@ public class ProxyWrapperHttpClientFactory implements HttpClientFactory { } @Override - public HttpClient createHttpClient(final HttpMethod method, final URI uri) { + public HttpClient create(final HttpMethod method, final URI uri) { // Use wrapped factory to obtain an httpclient instance for given method and uri - final DefaultHttpClient httpclient = (DefaultHttpClient) wrapped.createHttpClient(method, uri); + final DefaultHttpClient httpclient = (DefaultHttpClient) wrapped.create(method, uri); final HttpHost proxyHost = new HttpHost(proxy.getHost(), proxy.getPort()); @@ -87,4 +87,9 @@ public class ProxyWrapperHttpClientFactory implements HttpClientFactory { return httpclient; } + @Override + public void close(final HttpClient httpClient) { + wrapped.close(httpClient); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/AbstractURIBuilder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/AbstractURIBuilder.java index 7a7c63018..d8c0de6d0 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/AbstractURIBuilder.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/AbstractURIBuilder.java @@ -20,7 +20,6 @@ package org.apache.olingo.client.core.uri; import java.io.UnsupportedEncodingException; import java.net.URI; -import java.net.URISyntaxException; import java.net.URLDecoder; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -32,7 +31,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.http.NameValuePair; import org.apache.http.client.utils.URLEncodedUtils; import org.apache.http.message.BasicNameValuePair; -import org.apache.olingo.client.api.CommonConfiguration; +import org.apache.olingo.client.api.Configuration; import org.apache.olingo.client.api.uri.CommonURIBuilder; import org.apache.olingo.client.api.uri.QueryOption; import org.apache.olingo.client.api.uri.SegmentType; @@ -72,7 +71,7 @@ public abstract class AbstractURIBuilder> impleme private final ODataServiceVersion version; - private final CommonConfiguration configuration; + private final Configuration configuration; protected final List segments = new ArrayList(); @@ -93,7 +92,7 @@ public abstract class AbstractURIBuilder> impleme * service. */ protected AbstractURIBuilder( - final ODataServiceVersion version, final CommonConfiguration configuration, final String serviceRoot) { + final ODataServiceVersion version, final Configuration configuration, final String serviceRoot) { this.version = version; this.configuration = configuration; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v3/URIBuilderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v3/URIBuilderImpl.java index 1d231672e..7f351b2bd 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v3/URIBuilderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v3/URIBuilderImpl.java @@ -19,7 +19,7 @@ package org.apache.olingo.client.core.uri.v3; import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.client.api.CommonConfiguration; +import org.apache.olingo.client.api.Configuration; import org.apache.olingo.client.api.uri.QueryOption; import org.apache.olingo.client.api.uri.SegmentType; import org.apache.olingo.client.api.uri.v3.URIBuilder; @@ -29,7 +29,7 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; public class URIBuilderImpl extends AbstractURIBuilder implements URIBuilder { public URIBuilderImpl( - final ODataServiceVersion version, final CommonConfiguration configuration, final String serviceRoot) { + final ODataServiceVersion version, final Configuration configuration, final String serviceRoot) { super(version, configuration, serviceRoot); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/URIBuilderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/URIBuilderImpl.java index f5ab420cd..e5a156c32 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/URIBuilderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/URIBuilderImpl.java @@ -23,7 +23,7 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; -import org.apache.olingo.client.api.CommonConfiguration; +import org.apache.olingo.client.api.Configuration; import org.apache.olingo.client.api.uri.QueryOption; import org.apache.olingo.client.api.uri.SegmentType; import org.apache.olingo.client.api.uri.v4.URIBuilder; @@ -35,7 +35,7 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; public class URIBuilderImpl extends AbstractURIBuilder implements URIBuilder { public URIBuilderImpl( - final ODataServiceVersion version, final CommonConfiguration configuration, final String serviceRoot) { + final ODataServiceVersion version, final Configuration configuration, final String serviceRoot) { super(version, configuration, serviceRoot); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java index ec8cd3399..caaf423ec 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java @@ -18,7 +18,6 @@ */ package org.apache.olingo.client.core.v3; -import org.apache.olingo.client.api.CommonConfiguration; import org.apache.olingo.client.api.communication.header.HeaderName; import org.apache.olingo.client.api.communication.header.ODataHeaders; import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory; @@ -33,7 +32,6 @@ import org.apache.olingo.client.api.uri.v3.FilterFactory; import org.apache.olingo.client.api.uri.v3.URIBuilder; import org.apache.olingo.client.api.v3.ODataClient; import org.apache.olingo.client.core.AbstractODataClient; -import org.apache.olingo.client.core.Configuration; import org.apache.olingo.client.core.communication.header.ODataHeadersImpl; import org.apache.olingo.client.core.communication.request.batch.v3.BatchRequestFactoryImpl; import org.apache.olingo.client.core.communication.request.cud.v3.CUDRequestFactoryImpl; @@ -54,8 +52,6 @@ import org.apache.olingo.commons.core.serialization.JsonSerializer; public class ODataClientImpl extends AbstractODataClient implements ODataClient { - protected final Configuration configuration = new Configuration(); - private final FilterFactory filterFactory = new FilterFactoryImpl(getServiceVersion()); private final ODataReader reader = new ODataReaderImpl(this); @@ -86,11 +82,6 @@ public class ODataClientImpl extends AbstractODataClient implements return odataHeaders; } - @Override - public CommonConfiguration getConfiguration() { - return configuration; - } - @Override public URIBuilder newURIBuilder(final String serviceRoot) { return new URIBuilderImpl(getServiceVersion(), configuration, serviceRoot); @@ -108,8 +99,8 @@ public class ODataClientImpl extends AbstractODataClient implements @Override public ODataSerializer getSerializer(final ODataFormat format) { - return format == ODataFormat.ATOM || format == ODataFormat.XML ? - new AtomSerializer(getServiceVersion()) : new JsonSerializer(getServiceVersion(), false); + return format == ODataFormat.ATOM || format == ODataFormat.XML + ? new AtomSerializer(getServiceVersion()) : new JsonSerializer(getServiceVersion(), false); } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java index dec4e841f..c1a4f1df7 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java @@ -34,7 +34,6 @@ import org.apache.olingo.client.api.uri.v4.SearchFactory; import org.apache.olingo.client.api.uri.v4.URIBuilder; import org.apache.olingo.client.api.v4.ODataClient; import org.apache.olingo.client.core.AbstractODataClient; -import org.apache.olingo.client.core.Configuration; import org.apache.olingo.client.core.communication.header.ODataHeadersImpl; import org.apache.olingo.client.core.communication.request.batch.v4.BatchRequestFactoryImpl; import org.apache.olingo.client.core.communication.request.cud.v4.CUDRequestFactoryImpl; @@ -56,8 +55,6 @@ import org.apache.olingo.commons.core.serialization.JsonSerializer; public class ODataClientImpl extends AbstractODataClient implements ODataClient { - protected final Configuration configuration = new Configuration(); - private final FilterFactory filterFactory = new FilterFactoryImpl(getServiceVersion()); private final SearchFactory searchFactory = new SearchFactoryImpl(); @@ -91,11 +88,6 @@ public class ODataClientImpl extends AbstractODataClient implements return odataHeaders; } - @Override - public Configuration getConfiguration() { - return configuration; - } - @Override public URIBuilder newURIBuilder(final String serviceRoot) { return new URIBuilderImpl(getServiceVersion(), getConfiguration(), serviceRoot); @@ -118,8 +110,8 @@ public class ODataClientImpl extends AbstractODataClient implements @Override public ODataSerializer getSerializer(final ODataFormat format) { - return format == ODataFormat.ATOM || format == ODataFormat.XML ? - new AtomSerializer(getServiceVersion()) : new JsonSerializer(getServiceVersion(), false); + return format == ODataFormat.ATOM || format == ODataFormat.XML + ? new AtomSerializer(getServiceVersion()) : new JsonSerializer(getServiceVersion(), false); } @Override diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java index 648a0064b..5fa44ce67 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java @@ -1,21 +1,21 @@ -/******************************************************************************* +/* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - ******************************************************************************/ + */ package org.apache.olingo.commons.api.format; import java.util.ArrayList; @@ -30,7 +30,7 @@ import java.util.TreeMap; /** * Internally used {@link ContentType} for OData library. - * + * * For more details on format and content of a {@link ContentType} see * Media Type format as defined in * RFC 7231, chapter 3.1.1.1. @@ -40,35 +40,52 @@ import java.util.TreeMap; * subtype = token * OWS = *( SP / HTAB ) ; optional whitespace * - * + * * Once created a {@link ContentType} is IMMUTABLE. */ -public class ContentType { +public final class ContentType { public static final ContentType APPLICATION_XML = create("application/xml"); + public static final ContentType APPLICATION_ATOM_XML = create("application/atom+xml"); + public static final ContentType APPLICATION_ATOM_XML_ENTRY = create(APPLICATION_ATOM_XML, "type=entry"); + public static final ContentType APPLICATION_ATOM_XML_FEED = create(APPLICATION_ATOM_XML, "type=feed"); + public static final ContentType APPLICATION_ATOM_SVC = create("application/atomsvc+xml"); + public static final ContentType APPLICATION_JSON = create("application/json"); + public static final ContentType APPLICATION_OCTET_STREAM = create("application/octet-stream"); + public static final ContentType TEXT_PLAIN = create("text/plain"); + public static final ContentType MULTIPART_MIXED = create("multipart/mixed"); + public static final ContentType APPLICATION_XHTML_XML = create("application/xhtml+xml"); + public static final ContentType APPLICATION_SVG_XML = create("application/svg+xml"); + public static final ContentType APPLICATION_FORM_URLENCODED = create("application/x-www-form-urlencoded"); + public static final ContentType MULTIPART_FORM_DATA = create("multipart/form-data"); + public static final ContentType TEXT_XML = create("text/xml"); + public static final ContentType TEXT_HTML = create("text/html"); public static final String PARAMETER_CHARSET_UTF8 = "charset=utf-8"; private final String type; + private final String subtype; + private final Map parameters; /** * Creates a content type from type, subtype, and parameters. + * * @param type * @param subtype * @param parameters @@ -105,6 +122,7 @@ public class ContentType { /** * Validates if given format is parseable and can be used as input for {@link #create(String)} method. + * * @param format to be validated string * @return true if format is parseable otherwise false */ @@ -118,6 +136,7 @@ public class ContentType { /** * Creates a content type from format and key-value pairs for parameters + * * @param format for example "application/json" * @param parameters for example "a=b", "c=d" * @return a new ContentType object @@ -126,7 +145,7 @@ public class ContentType { ContentType ct = parse(format); for (String p : parameters) { - String[] keyvalue = p.split("="); + final String[] keyvalue = p.split("="); ct.parameters.put(keyvalue[0], keyvalue[1]); } @@ -135,7 +154,8 @@ public class ContentType { /** * Creates a content type from format and key-value pairs for parameters - * @param format for example "application/json" + * + * @param contentType for example "application/json" * @param parameters for example "a=b", "c=d" * @return a new ContentType object */ @@ -151,8 +171,9 @@ public class ContentType { } /** - * Creates a {@link ContentType} based on given input string (format). - * Supported format is Media Type format as defined in RFC 7231, chapter 3.1.1.1. + * Creates a {@link ContentType} based on given input string (format). Supported format is + * Media Type format as defined in RFC 7231, chapter 3.1.1.1. + * * @param format a string in format as defined in RFC 7231, chapter 3.1.1.1 * @return a new ContentType object * @throws IllegalArgumentException if input string is not parseable @@ -161,8 +182,8 @@ public class ContentType { if (format == null) { throw new IllegalArgumentException("Parameter format MUST NOT be NULL."); } - List typeSubtype = new ArrayList(); - Map parameters = new HashMap(); + final List typeSubtype = new ArrayList(); + final Map parameters = new HashMap(); parse(format, typeSubtype, parameters); return new ContentType(typeSubtype.get(0), typeSubtype.get(1), parameters); } @@ -170,9 +191,9 @@ public class ContentType { /** * Parses the given input string (format) and returns created {@link ContentType} if input was valid or * return NULL if input was not parseable. - * + * * For the definition of the supported format see {@link #create(String)}. - * + * * @param format a string in format as defined in RFC 7231, chapter 3.1.1.1 * @return a new ContentType object */ @@ -184,14 +205,13 @@ public class ContentType { } } - private static void - parse(final String format, final List typeSubtype, final Map parameters) { + private static void parse(final String format, final List typeSubtype, final Map parameters) { final String[] typesAndParameters = format.split(TypeUtil.PARAMETER_SEPARATOR, 2); final String types = typesAndParameters[0]; final String params = (typesAndParameters.length > 1 ? typesAndParameters[1] : null); if (types.contains(TypeUtil.TYPE_SUBTYPE_SEPARATOR)) { - String[] tokens = types.split(TypeUtil.TYPE_SUBTYPE_SEPARATOR); + final String[] tokens = types.split(TypeUtil.TYPE_SUBTYPE_SEPARATOR); if (tokens.length == 2) { if (tokens[0] == null || tokens[0].isEmpty()) { throw new IllegalArgumentException("No type found in format '" + format + "'."); @@ -203,11 +223,11 @@ public class ContentType { } } else { throw new IllegalArgumentException( - "Too many '" + TypeUtil.TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'."); + "Too many '" + TypeUtil.TYPE_SUBTYPE_SEPARATOR + "' in format '" + format + "'."); } } else { throw new IllegalArgumentException("No separator '" + TypeUtil.TYPE_SUBTYPE_SEPARATOR - + "' was found in format '" + format + "'."); + + "' was found in format '" + format + "'."); } TypeUtil.parseParameters(params, parameters); @@ -222,7 +242,7 @@ public class ContentType { } /** - * + * * @return parameters of this {@link ContentType} as unmodifiable map. */ public Map getParameters() { @@ -241,13 +261,13 @@ public class ContentType { *

  • if type and/or subtype is set to "*" (in such a case the parameters are * ignored).
  • * - * + * * @return true if both instances are equal (see definition above), otherwise false. */ @Override public boolean equals(final Object obj) { // NULL validation is done in method 'isEqualWithoutParameters(obj)' - Boolean compatible = isEqualWithoutParameters(obj); + final Boolean compatible = isEqualWithoutParameters(obj); if (compatible == null) { ContentType other = (ContentType) obj; @@ -258,11 +278,11 @@ public class ContentType { return false; } } else if (parameters.size() == other.parameters.size()) { - Iterator> entries = parameters.entrySet().iterator(); - Iterator> otherEntries = other.parameters.entrySet().iterator(); + final Iterator> entries = parameters.entrySet().iterator(); + final Iterator> otherEntries = other.parameters.entrySet().iterator(); while (entries.hasNext()) { - Entry e = entries.next(); - Entry oe = otherEntries.next(); + final Entry e = entries.next(); + final Entry oe = otherEntries.next(); if (!areEqual(e.getKey(), oe.getKey())) { return false; @@ -289,7 +309,7 @@ public class ContentType { * * The set parameters are always ignored (for compare with parameters see {@link #equals(Object)} * ). - * + * * @return true if both instances are equal (see definition above), otherwise false. */ public boolean isCompatible(final ContentType obj) { @@ -301,13 +321,12 @@ public class ContentType { } /** - * Check equal without parameters. - * It is possible that no decision about equal/none equal can be determined a NULL is - * returned. - * + * Check equal without parameters. It is possible that no decision about equal/none equal can be + * determined a NULL is returned. + * * @param obj to checked object - * @return true if both instances are equal (see definition above), otherwise false - * or NULL if no decision about equal/none equal could be determined. + * @return true if both instances are equal (see definition above), otherwise false or + * NULL if no decision about equal/none equal could be determined. */ private Boolean isEqualWithoutParameters(final Object obj) { // basic checks @@ -346,7 +365,7 @@ public class ContentType { /** * Check whether both string are equal ignoring the case of the strings. - * + * * @param first first string * @param second second string * @return true if both strings are equal (by ignoring the case), otherwise false is @@ -357,12 +376,13 @@ public class ContentType { } /** - * Get {@link ContentType} as string as defined in RFC 7231 - * (http://www.ietf.org/rfc/rfc7231.txt, chapter 3.1.1.1: Media Type) + * Get {@link ContentType} as string as defined in RFC 7231 (http://www.ietf.org/rfc/rfc7231.txt, chapter 3.1.1.1: + * Media Type) + * * @return string representation of ContentType object */ public String toContentTypeString() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(type).append(TypeUtil.TYPE_SUBTYPE_SEPARATOR).append(subtype); diff --git a/pom.xml b/pom.xml index 447aaa8ca..213a050a5 100644 --- a/pom.xml +++ b/pom.xml @@ -84,6 +84,8 @@ 4.1 + 4.1.1.4 + 1.7.7 ${project.build.directory}/log @@ -165,6 +167,13 @@ 0.9.9 + + com.google.android + android + ${android.platform.version} + provided + + org.slf4j slf4j-api @@ -248,9 +257,9 @@ - com.keyboardsamurais.maven - maven-timestamp-plugin - 1.0 + com.keyboardsamurais.maven + maven-timestamp-plugin + 1.0 org.apache.rat @@ -344,11 +353,17 @@ + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + org.sonatype.plugins jarjar-maven-plugin - 1.8 + 1.9 From f1f6491a5635f9e0d8115bee0d6fc3316c9330bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= <--global> Date: Sun, 13 Jul 2014 07:56:24 +0200 Subject: [PATCH 07/16] Removing all leaks on Android --- .../request/batch/AbstractODataBatchRequest.java | 12 ++++++------ .../request/batch/ODataSingleResponseItem.java | 9 +++++++++ .../request/batch/v3/ODataBatchRequestImpl.java | 8 ++++++++ .../request/batch/v4/ODataBatchRequestImpl.java | 9 +++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequest.java index df03f49c4..428dbf59c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequest.java @@ -49,10 +49,6 @@ public abstract class AbstractODataBatchRequest expectedResItems = new ArrayList(); - protected void addExpectedResItem(ODataBatchResponseItem item) { - expectedResItems.add(item); - } - /** * Constructor. * @@ -69,6 +65,10 @@ public abstract class AbstractODataBatchRequest getBody() { return new ODataBatchResponseManager(this, expectedResItems); } + + @Override + public void close() { + for (ODataBatchResponseItem resItem : expectedResItems) { + resItem.close(); + } + super.close(); + } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java index f7dc70797..52d5194ad 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java @@ -124,5 +124,14 @@ public class ODataBatchRequestImpl public Iterator getBody() { return new ODataBatchResponseManager(this, expectedResItems, continueOnError); } + + @Override + public void close() { + for (ODataBatchResponseItem resItem : expectedResItems) { + resItem.close(); + } + super.close(); + } + } } From d9c6b08f7d721f3983a0f643e37a14232977e4d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= <--global> Date: Sun, 13 Jul 2014 15:17:27 +0200 Subject: [PATCH 08/16] White noise --- .../client/core/android/http/AndroidHttpClientFactory.java | 2 +- .../olingo/client/core/http/ProxyWrapperHttpClientFactory.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/client-core-android/src/main/java/org/apache/olingo/client/core/android/http/AndroidHttpClientFactory.java b/ext/client-core-android/src/main/java/org/apache/olingo/client/core/android/http/AndroidHttpClientFactory.java index 4baa0c233..b6605e702 100644 --- a/ext/client-core-android/src/main/java/org/apache/olingo/client/core/android/http/AndroidHttpClientFactory.java +++ b/ext/client-core-android/src/main/java/org/apache/olingo/client/core/android/http/AndroidHttpClientFactory.java @@ -29,7 +29,7 @@ public class AndroidHttpClientFactory extends AbstractHttpClientFactory { private static final long serialVersionUID = -5224104561624556177L; @Override - public HttpClient create(final HttpMethod method, final URI uri) { + public AndroidHttpClient create(final HttpMethod method, final URI uri) { return AndroidHttpClient.newInstance(USER_AGENT); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrapperHttpClientFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrapperHttpClientFactory.java index 2ce0b3d82..5926e30c0 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrapperHttpClientFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrapperHttpClientFactory.java @@ -70,7 +70,7 @@ public class ProxyWrapperHttpClientFactory implements HttpClientFactory { @Override public HttpClient create(final HttpMethod method, final URI uri) { // Use wrapped factory to obtain an httpclient instance for given method and uri - final DefaultHttpClient httpclient = (DefaultHttpClient) wrapped.create(method, uri); + final DefaultHttpClient httpclient = wrapped.create(method, uri); final HttpHost proxyHost = new HttpHost(proxy.getHost(), proxy.getPort()); From ded008b75f784f5cff5910e835a95f451800ea0d Mon Sep 17 00:00:00 2001 From: Stephan Klevenz Date: Mon, 14 Jul 2014 16:56:55 +0200 Subject: [PATCH 09/16] [OLINGO-343] work on license files --- fit/pom.xml | 25 +- fit/src/main/resources/META-INF/LICENSE | 1047 +++++++++++++++++ lib/server-tecsvc/pom.xml | 3 + .../src/main/resources/META-INF/LICENSE | 331 ++++++ 4 files changed, 1396 insertions(+), 10 deletions(-) create mode 100644 fit/src/main/resources/META-INF/LICENSE create mode 100644 lib/server-tecsvc/src/main/resources/META-INF/LICENSE diff --git a/fit/pom.xml b/fit/pom.xml index 84d4eacf6..ccb68b4a1 100644 --- a/fit/pom.xml +++ b/fit/pom.xml @@ -113,6 +113,17 @@ + + + + src/main/resources + true + + + target/maven-shared-archive-resources + + + org.apache.maven.plugins @@ -149,9 +160,9 @@ ${project.build.outputDirectory} - - META-INF/DEPENDENCIES* - + + + WEB-INF/classes/esigate.properties,WEB-INF/classes/META-INF/LICENSE*,WEB-INF/classes/META-INF/DEPENDENCIES* @@ -182,7 +193,7 @@ ${cargo.tomcat.ajp.port} ${cargo.rmi.port} - + -noverify -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=256m @@ -239,11 +250,5 @@ - - - src/main/resources - true - - diff --git a/fit/src/main/resources/META-INF/LICENSE b/fit/src/main/resources/META-INF/LICENSE new file mode 100644 index 000000000..55e197210 --- /dev/null +++ b/fit/src/main/resources/META-INF/LICENSE @@ -0,0 +1,1047 @@ +Licenses of FIT artifact + + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed 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. + + + +From: 'ANTLR' (http://www.antlr.org) - ANTLR 4 Runtime +(http://www.antlr.org/antlr4-runtime) org.antlr:antlr4-runtime:jar:4.1 License: +The BSD License (http://www.antlr.org/license.html) + +[The BSD License] +Copyright (c) 2012 Terence Parr and Sam Harwell +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions and + the following disclaimer in the documentation and/or other materials + provided with the distribution. Neither the name of the author nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +From: 'abego Software GmbH, Germany' (http://abego-software.de) - abego +TreeLayout Core (http://code.google.com/p/treelayout/) +org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1 License: BSD 3-Clause +"New" or "Revised" License (BSD-3-Clause) +(http://treelayout.googlecode.com/files/LICENSE.TXT) + +[The "BSD license"] +Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the abego Software GmbH nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + + +From: 'fasterxml.com' (http://fasterxml.com) - Stax2 API +(http://wiki.fasterxml.com/WoodstoxStax2) +org.codehaus.woodstox:stax2-api:bundle:3.1.4 License: The BSD License +(http://www.opensource.org/licenses/bsd-license.php) + +Copyright (c) 2004-2010, Woodstox Project (http://woodstox.codehaus.org/) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the Woodstox XML Processor nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +From: 'QOS.ch' (http://www.qos.ch) + - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + - SLF4J Simple Binding (http://www.slf4j.org) org.slf4j:slf4j-simple:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + + +Copyright (c) 2004-2013 QOS.ch + +All rights reserved. Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + + + - htmlparser (http://about.validator.nu/htmlparser/) + nu.validator.htmlparser:htmlparser:bundle:1.4 License: The MIT License + (http://www.opensource.org/licenses/mit-license.php) License: The (New) BSD + License (http://www.opensource.org/licenses/bsd-license.php) + + +License + +This is for the HTML parser as a whole except the rewindable input stream, +the named character classes and the Live DOM Viewer. +For the copyright notices for individual files, please see individual files. + +/* + * Copyright (c) 2005, 2006, 2007 Henri Sivonen + * Copyright (c) 2007-2011 Mozilla Foundation + * Portions of comments Copyright 2004-2007 Apple Computer, Inc., Mozilla + * Foundation, and Opera Software ASA. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +The following license is for the WHATWG spec from which the named character +data was extracted. + +/* + * Copyright 2004-2010 Apple Computer, Inc., Mozilla Foundation, and Opera + * Software ASA. + * + * You are granted a license to use, reproduce and create derivative works of + * this document. + */ + +The following license is for the rewindable input stream. + +/* + * Copyright (c) 2001-2003 Thai Open Source Software Center Ltd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the Thai Open Source Software Center Ltd nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +The following license applies to the Live DOM Viewer: + +Copyright (c) 2000, 2006, 2008 Ian Hickson and various contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + + - AOP alliance (http://aopalliance.sourceforge.net) + aopalliance:aopalliance:jar:1.0 License: Public Domain + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to + + + - WSDL4J (http://sf.net/projects/wsdl4j) wsdl4j:wsdl4j:jar:1.6.3 + License: CPL (http://www.opensource.org/licenses/cpl1.0.txt) + + + +Common Public License Version 1.0 +[OSI Approved License] + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and such +derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed +Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. +This patent license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other combinations +which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses +to its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other intellectual +property rights of any other entity. Each Contributor disclaims any liability to +Recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby assumes sole +responsibility to secure any other intellectual property rights needed, if any. +For example, if a third party patent license is required to allow Recipient to +distribute the Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license set +forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its +own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title and +non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered +by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on or +through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to +control, and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may participate in +any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its exercise of +rights under this Agreement, including but not limited to the risks and costs of +program errors, compliance with applicable laws, damage to or loss of data, +programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against a Contributor with respect to +a patent applicable to software (including a cross-claim or counterclaim in a +lawsuit), then any patent licenses granted by that Contributor to such Recipient +under this Agreement shall terminate as of the date such litigation is filed. In +addition, if Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the Program +itself (excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +IBM is the initial Agreement Steward. IBM may assign the responsibility to serve +as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the Agreement +is published, Contributor may elect to distribute the Program (including its +Contributions) under the new version. Except as expressly stated in Sections +2(a) and 2(b) above, Recipient receives no rights or licenses to the +intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. + + + +From: 'Oracle Corporation' (http://www.oracle.com/) - JAXB Reference +Implementation (http://jaxb.java.net/) com.sun.xml.bind:jaxb-impl:jar:2.2.6 +License: CDDL 1.1 (https://glassfish.java.net/public/CDDL+GPL_1_1.html) +License: GPL2 w/ CPE (https://glassfish.java.net/public/CDDL+GPL_1_1.html) - +javax.ws.rs-api (http://jax-rs-spec.java.net) +javax.ws.rs:javax.ws.rs-api:jar:2.0-m10 License: CDDL 1.1 +(http://glassfish.java.net/public/CDDL+GPL_1_1.html) License: GPL2 w/ CPE +(http://glassfish.java.net/public/CDDL+GPL_1_1.html) + + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)Version 1.1 + +1. Definitions. + + 1.1. “Contributor” means each individual or entity that creates or + contributes to the creation of Modifications. + + 1.2. “Contributor Version” means the combination of the Original Software, + prior Modifications used by a Contributor (if any), and the Modifications + made by that particular Contributor. + + 1.3. “Covered Software” means (a) the Original Software, or (b) + Modifications, or (c) the combination of files containing Original Software + with files containing Modifications, in each case including portions + thereof. + + 1.4. “Executable” means the Covered Software in any form other than Source + Code. + + 1.5. “Initial Developer” means the individual or entity that first makes + Original Software available under this License. + + 1.6. “Larger Work” means a work which combines Covered Software or portions + thereof with code not governed by the terms of this License. + + 1.7. “License” means this document. + + 1.8. “Licensable” means having the right to grant, to the maximum extent + possible, whether at the time of the initial grant or subsequently + acquired, any and all of the rights conveyed herein. + + 1.9. “Modifications” means the Source Code and Executable form of any of + the following: + + A. Any file that results from an addition to, deletion from or modification + of the contents of a file containing Original Software or previous + Modifications; + + B. Any new file that contains any part of the Original Software or previous + Modification; or + + C. Any new file that is contributed or otherwise made available under the + terms of this License. + + 1.10. “Original Software” means the Source Code and Executable form of + computer software code that is originally released under this License. + + 1.11. “Patent Claims” means any patent claim(s), now owned or hereafter + acquired, including without limitation, method, process, and apparatus + claims, in any patent Licensable by grantor. + + 1.12. “Source Code” means (a) the common form of computer software code in + which modifications are made and (b) associated documentation included in + or with such code. + + 1.13. “You” (or “Your”) means an individual or a legal entity exercising + rights under, and complying with all of the terms of, this License. For + legal entities, “You” includes any entity which controls, is controlled by, + or is under common control with You. For purposes of this definition, + “control” means (a) the power, direct or indirect, to cause the direction + or management of such entity, whether by contract or otherwise, or (b) + ownership of more than fifty percent (50%) of the outstanding shares or + beneficial ownership of such entity. + +2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and subject to + third party intellectual property claims, the Initial Developer hereby + grants You a world-wide, royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than patent or trademark) + Licensable by Initial Developer, to use, reproduce, modify, display, + perform, sublicense and distribute the Original Software (or portions + thereof), with or without Modifications, and/or as part of a Larger Work; + and + + (b) under Patent Claims infringed by the making, using or selling of + Original Software, to make, have made, use, practice, sell, and offer for + sale, and/or otherwise dispose of the Original Software (or portions + thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) are effective on the + date Initial Developer first distributes or otherwise makes the Original + Software available to a third party under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) + for code that You delete from the Original Software, or (2) for + infringements caused by: (i) the modification of the Original Software, or + (ii) the combination of the Original Software with other software or + devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and subject to + third party intellectual property claims, each Contributor hereby grants + You a world-wide, royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than patent or trademark) + Licensable by Contributor to use, reproduce, modify, display, perform, + sublicense and distribute the Modifications created by such Contributor (or + portions thereof), either on an unmodified basis, with other Modifications, + as Covered Software and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or selling of + Modifications made by that Contributor either alone and/or in combination + with its Contributor Version (or portions of such combination), to make, + use, sell, offer for sale, have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions thereof); and (2) the + combination of Modifications made by that Contributor with its Contributor + Version (or portions of such combination). + + (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the + date Contributor first distributes or otherwise makes the Modifications + available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) + for any code that Contributor has deleted from the Contributor Version; (2) + for infringements caused by: (i) third party modifications of Contributor + Version, or (ii) the combination of Modifications made by that Contributor + with other software (except as part of the Contributor Version) or other + devices; or (3) under Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + +3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make available in + Executable form must also be made available in Source Code form and that + Source Code form must be distributed only under the terms of this License. + You must include a copy of this License with every copy of the Source Code + form of the Covered Software You distribute or otherwise make available. + You must inform recipients of any such Covered Software in Executable form + as to how they can obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used for software + exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You contribute are governed + by the terms of this License. You represent that You believe Your + Modifications are Your original creation(s) and/or You have sufficient + rights to grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications that identifies You + as the Contributor of the Modification. You may not remove or alter any + copyright, patent or trademark notices contained within the Covered + Software, or any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered Software in Source + Code form that alters or restricts the applicable version of this License + or the recipients' rights hereunder. You may choose to offer, and to charge + a fee for, warranty, support, indemnity or liability obligations to one or + more recipients of Covered Software. However, you may do so only on Your + own behalf, and not on behalf of the Initial Developer or any Contributor. + You must make it absolutely clear that any such warranty, support, + indemnity or liability obligation is offered by You alone, and You hereby + agree to indemnify the Initial Developer and every Contributor for any + liability incurred by the Initial Developer or such Contributor as a result + of warranty, support, indemnity or liability terms You offer. + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered Software under the + terms of this License or under the terms of a license of Your choice, which + may contain terms different from this License, provided that You are in + compliance with the terms of this License and that the license for the + Executable form does not attempt to limit or alter the recipient's rights + in the Source Code form from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a different + license, You must make it absolutely clear that any terms which differ from + this License are offered by You alone, not by the Initial Developer or + Contributor. You hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial Developer or such + Contributor as a result of any such terms You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software with other code + not governed by the terms of this License and distribute the Larger Work as + a single product. In such a case, You must make sure the requirements of + this License are fulfilled for the Covered Software. + +4. Versions of the License. + + 4.1. New Versions. + + Oracle is the initial license steward and may publish revised and/or new + versions of this License from time to time. Each version will be given a + distinguishing version number. Except as provided in Section 4.3, no one + other than the license steward has the right to modify this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise make the Covered + Software available under the terms of the version of the License under + which You originally received the Covered Software. If the Initial + Developer includes a notice in the Original Software prohibiting it from + being distributed or otherwise made available under any subsequent version + of the License, You must distribute and make the Covered Software available + under the terms of the version of the License under which You originally + received the Covered Software. Otherwise, You may also choose to use, + distribute or otherwise make the Covered Software available under the terms + of any subsequent version of the License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a new license for + Your Original Software, You may create and use a modified version of this + License if You: (a) rename the license and remove any references to the + name of the license steward (except to note that the license differs from + this License); and (b) otherwise make it clear that the license contains + terms which differ from this License. + +5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, + WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF + DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE + ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS + WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU + (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY + NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY + CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED + SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +6. TERMINATION. + + 6.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to cure such + breach within 30 days of becoming aware of the breach. Provisions which, by + their nature, must remain in effect beyond the termination of this License + shall survive. + + 6.2. If You assert a patent infringement claim (excluding declaratory + judgment actions) against Initial Developer or a Contributor (the Initial + Developer or Contributor against whom You assert such claim is referred to + as “Participant”) alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor or the Original + Software where the Participant is the Initial Developer) directly or + indirectly infringes any patent, then any and all rights granted directly + or indirectly to You by such Participant, the Initial Developer (if the + Initial Developer is not the Participant) and all Contributors under + Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from + Participant terminate prospectively and automatically at the expiration of + such 60 day notice period, unless if within such 60 day period You withdraw + Your claim with respect to the Participant Software against such + Participant either unilaterally or pursuant to a written agreement with + Participant. + + 6.3. If You assert a patent infringement claim against Participant alleging + that the Participant Software directly or indirectly infringes any patent + where such claim is resolved (such as by license or settlement) prior to + the initiation of patent infringement litigation, then the reasonable value + of the licenses granted by such Participant under Sections 2.1 or 2.2 shall + be taken into account in determining the amount or value of any payment or + license. + + 6.4. In the event of termination under Sections 6.1 or 6.2 above, all end + user licenses that have been validly granted by You or any distributor + hereunder prior to termination (excluding licenses granted to You by any + distributor) shall survive termination. + +7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING + NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY + OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER + OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, + INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE + OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF + SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. + THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR + PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW + THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS + EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +8. U.S. GOVERNMENT END USERS. + + The Covered Software is a “commercial item,” as that term is defined in 48 + C.F.R. 2.101 (Oct. 1995), consisting of “commercial computer software” (as + that term is defined at 48 C.F.R. § 252.227-7014(a)(1)) and “commercial + computer software documentation” as such terms are used in 48 C.F.R. 12.212 + (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users acquire + Covered Software with only those rights set forth herein. This U.S. + Government Rights clause is in lieu of, and supersedes, any other FAR, + DFAR, or other clause or provision that addresses Government rights in + computer software under this License. + +9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject matter + hereof. If any provision of this License is held to be unenforceable, such + provision shall be reformed only to the extent necessary to make it + enforceable. This License shall be governed by the law of the jurisdiction + specified in a notice contained within the Original Software (except to the + extent applicable law, if any, provides otherwise), excluding such + jurisdiction's conflict-of-law provisions. Any litigation relating to this + License shall be subject to the jurisdiction of the courts located in the + jurisdiction and venue specified in a notice contained within the Original + Software, with the losing party responsible for costs, including, without + limitation, court costs and reasonable attorneys' fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or regulation + which provides that the language of a contract shall be construed against + the drafter shall not apply to this License. You agree that You alone are + responsible for compliance with the United States export administration + regulations (and the export control laws and regulation of any other + countries) when You use, distribute or otherwise make available any Covered + Software. + +10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or indirectly, out of + its utilization of rights under this License and You agree to work with + Initial Developer and Contributors to distribute such responsibility on an + equitable basis. Nothing herein is intended or shall be deemed to + constitute any admission of liability. + +NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE +(CDDL) + +The code released under the CDDL shall be governed by the laws of the State of +California (excluding conflict-of-law provisions). Any litigation relating to +this License shall be subject to the jurisdiction of the Federal Courts of the +Northern District of California and the state courts of the State of +California, with venue lying in Santa Clara County, California. + + diff --git a/lib/server-tecsvc/pom.xml b/lib/server-tecsvc/pom.xml index b5fb60e22..d5b34696c 100644 --- a/lib/server-tecsvc/pom.xml +++ b/lib/server-tecsvc/pom.xml @@ -46,6 +46,9 @@ src/main/resources true + + target/maven-shared-archive-resources + diff --git a/lib/server-tecsvc/src/main/resources/META-INF/LICENSE b/lib/server-tecsvc/src/main/resources/META-INF/LICENSE new file mode 100644 index 000000000..715ff3074 --- /dev/null +++ b/lib/server-tecsvc/src/main/resources/META-INF/LICENSE @@ -0,0 +1,331 @@ +Licenses for TecSvc artifact + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed 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. + + +From: 'abego Software GmbH, Germany' (http://abego-software.de) - abego +TreeLayout Core (http://code.google.com/p/treelayout/) +org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1 License: BSD 3-Clause +"New" or "Revised" License (BSD-3-Clause) +(http://treelayout.googlecode.com/files/LICENSE.TXT) + +[The "BSD license"] +Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the abego Software GmbH nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +From: 'ANTLR' (http://www.antlr.org) - ANTLR 4 Runtime +(http://www.antlr.org/antlr4-runtime) org.antlr:antlr4-runtime:jar:4.1 License: +The BSD License (http://www.antlr.org/license.html) + +[The BSD License] +Copyright (c) 2012 Terence Parr and Sam Harwell +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions and + the following disclaimer in the documentation and/or other materials + provided with the distribution. Neither the name of the author nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +From: 'fasterxml.com' (http://fasterxml.com) - Stax2 API +(http://wiki.fasterxml.com/WoodstoxStax2) +org.codehaus.woodstox:stax2-api:bundle:3.1.4 License: The BSD License +(http://www.opensource.org/licenses/bsd-license.php) + +Copyright (c) 2004-2010, Woodstox Project (http://woodstox.codehaus.org/) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the Woodstox XML Processor nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +From: 'QOS.ch' (http://www.qos.ch) + - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + - SLF4J Simple Binding (http://www.slf4j.org) org.slf4j:slf4j-simple:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + + +Copyright (c) 2004-2013 QOS.ch + +All rights reserved. Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 4a690aa996d28d810608090b606f0ac54edc0159 Mon Sep 17 00:00:00 2001 From: Stephan Klevenz Date: Tue, 15 Jul 2014 13:34:54 +0200 Subject: [PATCH 10/16] [OLINGO-344] build javadoc distribution --- dist/javadoc/pom.xml | 96 +++++++++++++++++++ .../src/main/assembly/javadoc-assembly.xml | 35 +++++++ dist/pom.xml | 56 +++++++++++ dist/server-lib/pom.xml | 53 ++++++++++ pom.xml | 1 + 5 files changed, 241 insertions(+) create mode 100644 dist/javadoc/pom.xml create mode 100644 dist/javadoc/src/main/assembly/javadoc-assembly.xml create mode 100644 dist/pom.xml create mode 100644 dist/server-lib/pom.xml diff --git a/dist/javadoc/pom.xml b/dist/javadoc/pom.xml new file mode 100644 index 000000000..a4f495608 --- /dev/null +++ b/dist/javadoc/pom.xml @@ -0,0 +1,96 @@ + + + + 4.0.0 + + org.apache.olingo + olingo-dist-javadoc + pom + + ${project.artifactId} + + + org.apache.olingo + olingo-dist + 0.1.0-SNAPSHOT + .. + + + + + + target/maven-shared-archive-resources + + META-INF/* + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + + + apache-release + + false + + + + + maven-assembly-plugin + false + + + package-assemblies + package + + single + + + true + true + + + src/main/assembly/javadoc-assembly.xml + + + + + + + + + + + + \ No newline at end of file diff --git a/dist/javadoc/src/main/assembly/javadoc-assembly.xml b/dist/javadoc/src/main/assembly/javadoc-assembly.xml new file mode 100644 index 000000000..4db1d9629 --- /dev/null +++ b/dist/javadoc/src/main/assembly/javadoc-assembly.xml @@ -0,0 +1,35 @@ + + + + javadoc + + zip + + false + + + / + ${project.parent.parent.build.directory}/apidocs + + ** + + + + ${project.build.directory}/maven-shared-archive-resources/META-INF + / + + DEPENDENCIES + + + + diff --git a/dist/pom.xml b/dist/pom.xml new file mode 100644 index 000000000..6ed3e0c8f --- /dev/null +++ b/dist/pom.xml @@ -0,0 +1,56 @@ + + + + 4.0.0 + + org.apache.olingo + olingo-dist + pom + + ${project.artifactId} + + + org.apache.olingo + olingo-parent + 0.1.0-SNAPSHOT + .. + + + + server-lib + javadoc + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + \ No newline at end of file diff --git a/dist/server-lib/pom.xml b/dist/server-lib/pom.xml new file mode 100644 index 000000000..d9a2f7437 --- /dev/null +++ b/dist/server-lib/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.olingo + olingo-dist-server-lib + pom + + ${project.artifactId} + + + org.apache.olingo + olingo-dist + 0.1.0-SNAPSHOT + .. + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 173143d14..79a762502 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,7 @@ lib ext fit + dist From 4701d718d6db40296f875ee2e73254823f19ee4c Mon Sep 17 00:00:00 2001 From: Stephan Klevenz Date: Tue, 15 Jul 2014 13:48:21 +0200 Subject: [PATCH 11/16] [OLINGO-344] build server distribution --- dist/server-lib/pom.xml | 117 ++++-- .../src/main/assembly/lib-assembly.xml | 47 +++ dist/server-lib/src/main/resources/LICENSE | 337 ++++++++++++++++++ dist/server-lib/src/main/resources/NOTICE | 7 + 4 files changed, 481 insertions(+), 27 deletions(-) create mode 100644 dist/server-lib/src/main/assembly/lib-assembly.xml create mode 100644 dist/server-lib/src/main/resources/LICENSE create mode 100644 dist/server-lib/src/main/resources/NOTICE diff --git a/dist/server-lib/pom.xml b/dist/server-lib/pom.xml index d9a2f7437..b955eaaab 100644 --- a/dist/server-lib/pom.xml +++ b/dist/server-lib/pom.xml @@ -1,32 +1,32 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.olingo olingo-dist-server-lib pom - + ${project.artifactId} @@ -36,18 +36,81 @@ .. - + - - - org.apache.maven.plugins - maven-deploy-plugin - - true - - - + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + - + + + + apache-release + + false + + + + + maven-assembly-plugin + false + + + package-assemblies + package + + single + + + true + true + + + src/main/assembly/lib-assembly.xml + + + + + + + + + + + + + + org.apache.olingo + olingo-commons-api + ${project.version} + compile + + + org.apache.olingo + olingo-commons-core + ${project.version} + compile + + + + org.apache.olingo + olingo-server-api + ${project.version} + compile + + + org.apache.olingo + olingo-server-core + ${project.version} + compile + + + \ No newline at end of file diff --git a/dist/server-lib/src/main/assembly/lib-assembly.xml b/dist/server-lib/src/main/assembly/lib-assembly.xml new file mode 100644 index 000000000..7fa3d6297 --- /dev/null +++ b/dist/server-lib/src/main/assembly/lib-assembly.xml @@ -0,0 +1,47 @@ + + + + lib + + zip + + false + + + false + + ${artifact.groupId}-${artifact.artifactId}-${artifact.version}.${artifact.extension} + false + true + true + compile + + org.apache.olingo:olingo-commons-api + org.apache.olingo:olingo-commons-core + org.apache.olingo:olingo-server-api + org.apache.olingo:olingo-server-core + + + + + + ${project.build.directory}/maven-shared-archive-resources/META-INF + / + + LICENSE + NOTICE + + + + src/main/resources + / + + + diff --git a/dist/server-lib/src/main/resources/LICENSE b/dist/server-lib/src/main/resources/LICENSE new file mode 100644 index 000000000..2ba31377d --- /dev/null +++ b/dist/server-lib/src/main/resources/LICENSE @@ -0,0 +1,337 @@ +licenses for server distribution + + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed 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. + + +From: 'abego Software GmbH, Germany' (http://abego-software.de) - abego +TreeLayout Core (http://code.google.com/p/treelayout/) +org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1 License: BSD 3-Clause +"New" or "Revised" License (BSD-3-Clause) +(http://treelayout.googlecode.com/files/LICENSE.TXT) + +[The "BSD license"] +Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the abego Software GmbH nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + + + +From: 'ANTLR' (http://www.antlr.org) - ANTLR 4 Runtime +(http://www.antlr.org/antlr4-runtime) org.antlr:antlr4-runtime:jar:4.1 License: +The BSD License (http://www.antlr.org/license.html) + +[The BSD License] +Copyright (c) 2012 Terence Parr and Sam Harwell +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions and + the following disclaimer in the documentation and/or other materials + provided with the distribution. Neither the name of the author nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +From: 'fasterxml.com' (http://fasterxml.com) - Stax2 API +(http://wiki.fasterxml.com/WoodstoxStax2) +org.codehaus.woodstox:stax2-api:bundle:3.1.4 License: The BSD License +(http://www.opensource.org/licenses/bsd-license.php) + +Copyright (c) 2004-2010, Woodstox Project (http://woodstox.codehaus.org/) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the Woodstox XML Processor nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +From: 'QOS.ch' (http://www.qos.ch) + - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + - SLF4J Simple Binding (http://www.slf4j.org) org.slf4j:slf4j-simple:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + + +Copyright (c) 2004-2013 QOS.ch + +All rights reserved. Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + + diff --git a/dist/server-lib/src/main/resources/NOTICE b/dist/server-lib/src/main/resources/NOTICE new file mode 100644 index 000000000..94eaefe6a --- /dev/null +++ b/dist/server-lib/src/main/resources/NOTICE @@ -0,0 +1,7 @@ + +Apache Olingo +Copyright 2013-2014 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + From 8277130c71e8331b1fcc0ee6d586747cd646cba8 Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Tue, 15 Jul 2014 14:07:30 +0200 Subject: [PATCH 12/16] [OLINGO-348] Move ODataApplication exception to server --- .../api/ODataApplicationException.java | 37 ---------- .../server/api/ODataApplicationException.java | 68 +++++++++++++++++++ .../server/api/ODataTranslatedException.java} | 14 +--- .../expression/ExpressionVisitor.java | 2 +- .../expression/VisitableExpression.java | 2 +- .../uri/queryoption/expression/AliasImpl.java | 2 +- .../queryoption/expression/BinaryImpl.java | 2 +- .../expression/EnumerationImpl.java | 2 +- .../queryoption/expression/LambdaRefImpl.java | 2 +- .../queryoption/expression/LiteralImpl.java | 2 +- .../queryoption/expression/MemberImpl.java | 2 +- .../queryoption/expression/MethodImpl.java | 2 +- .../expression/TypeLiteralImpl.java | 2 +- .../uri/queryoption/expression/UnaryImpl.java | 2 +- .../core/uri/antlr/TestFullResourcePath.java | 2 +- .../expression/ExpressionTest.java | 2 +- .../core/uri/testutil/ExpandValidator.java | 2 +- .../core/uri/testutil/FilterTreeToText.java | 2 +- .../core/uri/testutil/FilterValidator.java | 2 +- .../core/uri/testutil/ResourceValidator.java | 2 +- 20 files changed, 88 insertions(+), 65 deletions(-) delete mode 100644 lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataApplicationException.java create mode 100644 lib/server-api/src/main/java/org/apache/olingo/server/api/ODataApplicationException.java rename lib/{commons-api/src/main/java/org/apache/olingo/commons/api/ODataNotImplementedException.java => server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java} (70%) diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataApplicationException.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataApplicationException.java deleted file mode 100644 index a4a76e0f3..000000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataApplicationException.java +++ /dev/null @@ -1,37 +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.commons.api; - -public class ODataApplicationException extends Exception { - - private static final long serialVersionUID = 5358683245923127425L; - - public ODataApplicationException(final String msg) { - super(msg); - } - - public ODataApplicationException(final String msg, final Throwable cause) { - super(msg, cause); - } - - public ODataApplicationException(final Throwable cause) { - super(cause); - } - -} diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataApplicationException.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataApplicationException.java new file mode 100644 index 000000000..881631616 --- /dev/null +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataApplicationException.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.server.api; + +import java.util.Locale; + +public class ODataApplicationException extends Exception { + + private static final long serialVersionUID = 5358683245923127425L; + private int statusCode = 500; + private Locale locale; + private String oDataErrorCode; + + public ODataApplicationException(final String msg, int statusCode, Locale locale) { + super(msg); + this.statusCode = statusCode; + this.locale = locale; + } + + public ODataApplicationException(final String msg, int statusCode, Locale locale, String oDataErrorCode) { + super(msg); + this.statusCode = statusCode; + this.locale = locale; + this.oDataErrorCode = oDataErrorCode; + } + + public ODataApplicationException(final String msg, int statusCode, Locale locale, final Throwable cause) { + super(msg, cause); + this.statusCode = statusCode; + this.locale = locale; + } + + public ODataApplicationException(final String msg, int statusCode, Locale locale, final Throwable cause, + String oDataErrorCode) { + super(msg, cause); + this.statusCode = statusCode; + this.locale = locale; + this.oDataErrorCode = oDataErrorCode; + } + + public int getStatusCode() { + return statusCode; + } + + public Locale getLocale() { + return locale; + } + + public String getoDataErrorCode() { + return oDataErrorCode; + } +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataNotImplementedException.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java similarity index 70% rename from lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataNotImplementedException.java rename to lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java index de6fc5e75..fabcca027 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataNotImplementedException.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java @@ -16,18 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.commons.api; +package org.apache.olingo.server.api; -public class ODataNotImplementedException extends ODataException { +public class ODataTranslatedException extends Exception{ - private static final long serialVersionUID = 3921772210762644762L; - - public ODataNotImplementedException(final String msg) { - super(msg); - } - - public ODataNotImplementedException() { - super("Not implemented"); - } + private static final long serialVersionUID = -1210541002198287561L; } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/ExpressionVisitor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/ExpressionVisitor.java index c2d76c0ea..83c146b4a 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/ExpressionVisitor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/ExpressionVisitor.java @@ -20,9 +20,9 @@ package org.apache.olingo.server.api.uri.queryoption.expression; import java.util.List; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfoResource; /** diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/VisitableExpression.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/VisitableExpression.java index 9b450acd3..1588dcf44 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/VisitableExpression.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/VisitableExpression.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.server.api.uri.queryoption.expression; -import org.apache.olingo.commons.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataApplicationException; /** * Marks an expression node a visitable by an expression visitor diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/AliasImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/AliasImpl.java index 0c5770fa0..09af93ff7 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/AliasImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/AliasImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.server.core.uri.queryoption.expression; -import org.apache.olingo.commons.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.Alias; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/BinaryImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/BinaryImpl.java index e583a53d3..a28f92c8f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/BinaryImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/BinaryImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.server.core.uri.queryoption.expression; -import org.apache.olingo.commons.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.Binary; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; import org.apache.olingo.server.api.uri.queryoption.expression.Expression; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java index b565973d4..8f7df3a22 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java @@ -21,8 +21,8 @@ package org.apache.olingo.server.core.uri.queryoption.expression; import java.util.ArrayList; import java.util.List; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.EdmEnumType; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.Enumeration; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LambdaRefImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LambdaRefImpl.java index 3fff793bc..8198204f0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LambdaRefImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LambdaRefImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.server.core.uri.queryoption.expression; -import org.apache.olingo.commons.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.server.api.uri.queryoption.expression.LambdaRef; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LiteralImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LiteralImpl.java index c9252df62..d9db0d463 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LiteralImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LiteralImpl.java @@ -18,8 +18,8 @@ */ package org.apache.olingo.server.core.uri.queryoption.expression; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.server.api.uri.queryoption.expression.Literal; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java index 9aad69878..8940bcf13 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java @@ -18,8 +18,8 @@ */ package org.apache.olingo.server.core.uri.queryoption.expression; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfoResource; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MethodImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MethodImpl.java index b3e283e62..7104a9ff8 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MethodImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MethodImpl.java @@ -21,7 +21,7 @@ package org.apache.olingo.server.core.uri.queryoption.expression; import java.util.ArrayList; import java.util.List; -import org.apache.olingo.commons.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.Expression; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java index 5bbe4b275..f5f6f06c0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java @@ -18,8 +18,8 @@ */ package org.apache.olingo.server.core.uri.queryoption.expression; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.server.api.uri.queryoption.expression.TypeLiteral; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/UnaryImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/UnaryImpl.java index 854505c97..796191f6f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/UnaryImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/UnaryImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.server.core.uri.queryoption.expression; -import org.apache.olingo.commons.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.Expression; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java index 4eb475e08..47f118b8e 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java @@ -21,9 +21,9 @@ package org.apache.olingo.server.core.uri.antlr; import java.io.UnsupportedEncodingException; import java.util.Arrays; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.core.Encoder; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfoKind; import org.apache.olingo.server.api.uri.UriResourceKind; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java index de63b4694..6f79060cf 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java @@ -23,12 +23,12 @@ import static org.junit.Assert.assertNotNull; import java.util.Arrays; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmFunction; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfoKind; import org.apache.olingo.server.api.uri.UriInfoResource; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java index fde13c851..0d16c764c 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java @@ -21,10 +21,10 @@ package org.apache.olingo.server.core.uri.testutil; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfoKind; import org.apache.olingo.server.api.uri.queryoption.ExpandItem; import org.apache.olingo.server.api.uri.queryoption.SelectItem; diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java index 06056e015..6574ed70e 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java @@ -20,9 +20,9 @@ package org.apache.olingo.server.core.uri.testutil; import java.util.List; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfoResource; import org.apache.olingo.server.api.uri.UriResource; import org.apache.olingo.server.api.uri.UriResourceLambdaAll; diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java index ba7d3fefd..cd5c4f8cc 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java @@ -23,10 +23,10 @@ import static org.junit.Assert.fail; import java.util.List; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfo; import org.apache.olingo.server.api.uri.UriInfoKind; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java index dfb9a64b5..871c70db9 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java @@ -24,12 +24,12 @@ import static org.junit.Assert.fail; import java.util.List; -import org.apache.olingo.commons.api.ODataApplicationException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmElement; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.http.HttpMethod; +import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfo; import org.apache.olingo.server.api.uri.UriInfoKind; import org.apache.olingo.server.api.uri.UriParameter; From a8202c04b032f439fc227f07307f5bb2737c398b Mon Sep 17 00:00:00 2001 From: Stephan Klevenz Date: Tue, 15 Jul 2014 14:30:27 +0200 Subject: [PATCH 13/16] [OLINGO-344] build client distribution --- dist/client-lib/pom.xml | 123 ++++++++ .../src/main/assembly/lib-assembly.xml | 47 +++ dist/client-lib/src/main/resources/LICENSE | 271 ++++++++++++++++++ dist/pom.xml | 1 + dist/server-lib/pom.xml | 1 - .../src/main/assembly/lib-assembly.xml | 1 - dist/server-lib/src/main/resources/NOTICE | 7 - 7 files changed, 442 insertions(+), 9 deletions(-) create mode 100644 dist/client-lib/pom.xml create mode 100644 dist/client-lib/src/main/assembly/lib-assembly.xml create mode 100644 dist/client-lib/src/main/resources/LICENSE delete mode 100644 dist/server-lib/src/main/resources/NOTICE diff --git a/dist/client-lib/pom.xml b/dist/client-lib/pom.xml new file mode 100644 index 000000000..0e8f6af42 --- /dev/null +++ b/dist/client-lib/pom.xml @@ -0,0 +1,123 @@ + + + + 4.0.0 + + org.apache.olingo + olingo-dist-client-lib + pom + + ${project.artifactId} + + + org.apache.olingo + olingo-dist + 0.1.0-SNAPSHOT + .. + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + + + apache-release + + false + + + + + maven-assembly-plugin + false + + + package-assemblies + package + + single + + + true + true + + + src/main/assembly/lib-assembly.xml + + + + + + + + + + + + + + org.apache.olingo + olingo-commons-api + ${project.version} + compile + + + org.apache.olingo + olingo-commons-core + ${project.version} + compile + + + + org.apache.olingo + olingo-client-api + ${project.version} + compile + + + org.apache.olingo + olingo-client-core + ${project.version} + compile + + + + org.apache.olingo + olingo-client-proxy + ${project.version} + compile + + + + \ No newline at end of file diff --git a/dist/client-lib/src/main/assembly/lib-assembly.xml b/dist/client-lib/src/main/assembly/lib-assembly.xml new file mode 100644 index 000000000..874c4c2dc --- /dev/null +++ b/dist/client-lib/src/main/assembly/lib-assembly.xml @@ -0,0 +1,47 @@ + + + + lib + + zip + + false + + + false + + ${artifact.groupId}-${artifact.artifactId}-${artifact.version}.${artifact.extension} + false + true + true + compile + + org.apache.olingo:olingo-commons-api + org.apache.olingo:olingo-commons-core + org.apache.olingo:olingo-client-api + org.apache.olingo:olingo-client-core + org.apache.olingo:olingo-client-proxy + + + + + + ${project.build.directory}/maven-shared-archive-resources/META-INF + / + + LICENSE + + + + src/main/resources + / + + + diff --git a/dist/client-lib/src/main/resources/LICENSE b/dist/client-lib/src/main/resources/LICENSE new file mode 100644 index 000000000..446377f10 --- /dev/null +++ b/dist/client-lib/src/main/resources/LICENSE @@ -0,0 +1,271 @@ +licenses for client distribution + + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed 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. + + + +From: 'fasterxml.com' (http://fasterxml.com) - Stax2 API +(http://wiki.fasterxml.com/WoodstoxStax2) +org.codehaus.woodstox:stax2-api:bundle:3.1.4 License: The BSD License +(http://www.opensource.org/licenses/bsd-license.php) + +Copyright (c) 2004-2010, Woodstox Project (http://woodstox.codehaus.org/) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the Woodstox XML Processor nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +From: 'QOS.ch' (http://www.qos.ch) + - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + - SLF4J Simple Binding (http://www.slf4j.org) org.slf4j:slf4j-simple:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + + +Copyright (c) 2004-2013 QOS.ch + +All rights reserved. Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + + diff --git a/dist/pom.xml b/dist/pom.xml index 6ed3e0c8f..c9c4dc7c5 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -37,6 +37,7 @@ + client-lib server-lib javadoc diff --git a/dist/server-lib/pom.xml b/dist/server-lib/pom.xml index b955eaaab..69639fe78 100644 --- a/dist/server-lib/pom.xml +++ b/dist/server-lib/pom.xml @@ -112,5 +112,4 @@ compile - \ No newline at end of file diff --git a/dist/server-lib/src/main/assembly/lib-assembly.xml b/dist/server-lib/src/main/assembly/lib-assembly.xml index 7fa3d6297..dd8fe21ab 100644 --- a/dist/server-lib/src/main/assembly/lib-assembly.xml +++ b/dist/server-lib/src/main/assembly/lib-assembly.xml @@ -36,7 +36,6 @@ / LICENSE - NOTICE diff --git a/dist/server-lib/src/main/resources/NOTICE b/dist/server-lib/src/main/resources/NOTICE deleted file mode 100644 index 94eaefe6a..000000000 --- a/dist/server-lib/src/main/resources/NOTICE +++ /dev/null @@ -1,7 +0,0 @@ - -Apache Olingo -Copyright 2013-2014 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). - From 94bdf06cb031ffb2879185a1edc0a108cdce7189 Mon Sep 17 00:00:00 2001 From: Stephan Klevenz Date: Tue, 15 Jul 2014 14:44:31 +0200 Subject: [PATCH 14/16] [OLINGO-344] build android distribution --- dist/android-lib/pom.xml | 103 ++++++++++++++++++ .../src/main/assembly/lib-assembly.xml | 44 ++++++++ dist/android-lib/src/main/resources/LICENSE | 1 + dist/pom.xml | 1 + 4 files changed, 149 insertions(+) create mode 100644 dist/android-lib/pom.xml create mode 100644 dist/android-lib/src/main/assembly/lib-assembly.xml create mode 100644 dist/android-lib/src/main/resources/LICENSE diff --git a/dist/android-lib/pom.xml b/dist/android-lib/pom.xml new file mode 100644 index 000000000..183c7a81e --- /dev/null +++ b/dist/android-lib/pom.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + + org.apache.olingo + olingo-dist-android-lib + pom + + ${project.artifactId} + + + org.apache.olingo + olingo-dist + 0.1.0-SNAPSHOT + .. + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + + + apache-release + + false + + + + + maven-assembly-plugin + false + + + package-assemblies + package + + single + + + true + true + + + src/main/assembly/lib-assembly.xml + + + + + + + + + + + + + + org.apache.olingo + olingo-client-core-android + ${project.version} + compile + + + org.apache.olingo + olingo-client-proxy-android + ${project.version} + compile + + + + \ No newline at end of file diff --git a/dist/android-lib/src/main/assembly/lib-assembly.xml b/dist/android-lib/src/main/assembly/lib-assembly.xml new file mode 100644 index 000000000..27fe115b9 --- /dev/null +++ b/dist/android-lib/src/main/assembly/lib-assembly.xml @@ -0,0 +1,44 @@ + + + + lib + + zip + + false + + + false + + ${artifact.groupId}-${artifact.artifactId}-${artifact.version}.${artifact.extension} + false + true + true + compile + + org.apache.olingo:olingo-client-core-android + org.apache.olingo:olingo-client-proxy-android + + + + + + ${project.build.directory}/maven-shared-archive-resources/META-INF + / + + LICENSE + + + + src/main/resources + / + + + diff --git a/dist/android-lib/src/main/resources/LICENSE b/dist/android-lib/src/main/resources/LICENSE new file mode 100644 index 000000000..35b4b6f13 --- /dev/null +++ b/dist/android-lib/src/main/resources/LICENSE @@ -0,0 +1 @@ +licenses for android distribution diff --git a/dist/pom.xml b/dist/pom.xml index c9c4dc7c5..e2cef9b69 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -37,6 +37,7 @@ + android-lib client-lib server-lib javadoc From b9f4b3c64c893d731d6d6ff326486c6667791388 Mon Sep 17 00:00:00 2001 From: Michael Bolz Date: Tue, 15 Jul 2014 15:38:30 +0200 Subject: [PATCH 15/16] [OLINGO-317] ContextURL integration --- lib/commons-api/pom.xml | 10 +- .../apache/olingo/commons/api/Constants.java | 16 ++- .../olingo/commons/api/data/ContextURL.java | 135 ++++++++++++++---- .../edm/constants/ODataServiceVersion.java | 30 ++-- .../commons/api/data/ContextURLTest.java | 90 ++++++++++++ lib/commons-core/pom.xml | 4 +- .../api/serializer/ODataSerializer.java | 5 +- .../serializer/ODataXmlSerializerImpl.java | 3 +- .../serializer/json/ODataJsonSerializer.java | 30 ++-- .../tecsvc/processor/TechnicalProcessor.java | 11 +- .../tecsvc/data/JsonDataProviderTest.java | 8 +- .../json/ODataJsonSerializerTest.java | 25 ++-- 12 files changed, 281 insertions(+), 86 deletions(-) diff --git a/lib/commons-api/pom.xml b/lib/commons-api/pom.xml index ce6849ae8..6f9768fb2 100644 --- a/lib/commons-api/pom.xml +++ b/lib/commons-api/pom.xml @@ -33,23 +33,27 @@ 0.1.0-SNAPSHOT .. - + org.apache.commons commons-lang3 - org.slf4j slf4j-api - + junit junit test + + org.mockito + mockito-all + test + diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java index 8241457bc..80e56963d 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java @@ -163,11 +163,23 @@ public interface Constants { // JSON stuff public final static String JSON_METADATA = "odata.metadata"; + public final static String JSON_TYPE = "@odata.type"; + public final static String JSON_ID = "@odata.id"; + public final static String JSON_READ_LINK = "@odata.readLink"; + public final static String JSON_EDIT_LINK = "@odata.editLink"; public final static String JSON_CONTEXT = "@odata.context"; - + public final static String JSON_ETAG = "@odata.etag"; + public final static String JSON_MEDIA_ETAG = "@odata.mediaEtag"; + public final static String JSON_MEDIA_CONTENT_TYPE = "@odata.mediaContentType"; + public final static String JSON_MEDIA_READ_LINK = "@odata.mediaReadLink"; + public final static String JSON_MEDIA_EDIT_LINK = "@odata.mediaEditLink"; public final static String JSON_METADATA_ETAG = "@odata.metadataEtag"; - public final static String JSON_BIND_LINK_SUFFIX = "@odata.bind"; + public final static String JSON_ASSOCIATION_LINK = "@odata.associationLink"; + public final static String JSON_NAVIGATION_LINK = "@odata.navigationLink"; + public final static String JSON_COUNT = "@odata.count"; + public final static String JSON_NEXT_LINK = "@odata.nextLink"; + public final static String JSON_DELTA_LINK = "@odata.deltaLink"; public final static String JSON_NULL = "odata.null"; diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ContextURL.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ContextURL.java index 8926cebc9..2628ebd44 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ContextURL.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ContextURL.java @@ -22,6 +22,8 @@ import java.net.URI; import org.apache.commons.lang3.StringUtils; import org.apache.olingo.commons.api.Constants; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.EdmEntityType; /** * High-level representation of a context URL, built from the string value returned by a service; provides access to the @@ -34,24 +36,31 @@ public class ContextURL { private URI uri; private URI serviceRoot; - private String entitySetOrSingletonOrType; - private String derivedEntity; - private String selectList; - private String navOrPropertyPath; - private boolean entity; + public enum Suffix { + ENTITY("$entity"), + REFERENCE("$ref"), + DELTA("$delta"), + DELTA_DELETED_ENTITY("$deletedEntity"), + DELTA_LINK("$link"), + DELTA_DELETED_LINK("$deletedLink"); - private boolean delta; + private final String representation; + private Suffix(final String representation) { + this.representation = representation; + } + public String getRepresentation() { + return representation; + } + } - private boolean deltaDeletedEntity; + private Suffix suffix; - private boolean deltaLink; - - private boolean deltaDeletedLink; + private ContextURL() {} public static ContextURL getInstance(final URI contextURL) { final ContextURL instance = new ContextURL(); @@ -59,21 +68,31 @@ public class ContextURL { String contextURLasString = instance.uri.toASCIIString(); - instance.entity = contextURLasString.endsWith("/$entity") || contextURLasString.endsWith("/@Element"); - contextURLasString = contextURLasString. - replace("/$entity", StringUtils.EMPTY).replace("/@Element", StringUtils.EMPTY); + if (contextURLasString.endsWith("/$entity") || contextURLasString.endsWith("/@Element")) { + instance.suffix = Suffix.ENTITY; + contextURLasString = contextURLasString.replace("/$entity", StringUtils.EMPTY) + .replace("/@Element", StringUtils.EMPTY); - instance.delta = contextURLasString.endsWith("/$delta"); - contextURLasString = contextURLasString.replace("/$delta", StringUtils.EMPTY); + } else if (contextURLasString.endsWith("/$ref")) { + instance.suffix = Suffix.REFERENCE; + contextURLasString = contextURLasString.replace("/$ref", StringUtils.EMPTY); - instance.deltaDeletedEntity = contextURLasString.endsWith("/$deletedEntity"); - contextURLasString = contextURLasString.replace("/$deletedEntity", StringUtils.EMPTY); + } else if (contextURLasString.endsWith("/$delta")) { + instance.suffix = Suffix.DELTA; + contextURLasString = contextURLasString.replace("/$delta", StringUtils.EMPTY); - instance.deltaLink = contextURLasString.endsWith("/$link"); - contextURLasString = contextURLasString.replace("/$link", StringUtils.EMPTY); + } else if (contextURLasString.endsWith("/$deletedEntity")) { + instance.suffix = Suffix.DELTA_DELETED_ENTITY; + contextURLasString = contextURLasString.replace("/$deletedEntity", StringUtils.EMPTY); - instance.deltaDeletedLink = contextURLasString.endsWith("/$deletedLink"); - contextURLasString = contextURLasString.replace("/$deletedLink", StringUtils.EMPTY); + } else if (contextURLasString.endsWith("/$link")) { + instance.suffix = Suffix.DELTA_LINK; + contextURLasString = contextURLasString.replace("/$link", StringUtils.EMPTY); + + } else if (contextURLasString.endsWith("/$deletedLink")) { + instance.suffix = Suffix.DELTA_DELETED_LINK; + contextURLasString = contextURLasString.replace("/$deletedLink", StringUtils.EMPTY); + } instance.serviceRoot = URI.create(StringUtils.substringBefore(contextURLasString, Constants.METADATA)); @@ -150,23 +169,87 @@ public class ContextURL { } public boolean isEntity() { - return entity; + return suffix == Suffix.ENTITY; + } + + public boolean isReference() { + return suffix == Suffix.REFERENCE; } public boolean isDelta() { - return delta; + return suffix == Suffix.DELTA; } public boolean isDeltaDeletedEntity() { - return deltaDeletedEntity; + return suffix == Suffix.DELTA_DELETED_ENTITY; } public boolean isDeltaLink() { - return deltaLink; + return suffix == Suffix.DELTA_LINK; } public boolean isDeltaDeletedLink() { - return deltaDeletedLink; + return suffix == Suffix.DELTA_DELETED_LINK; + } + + public static final class ContextURLBuilder { + private ContextURL contextURL = new ContextURL(); + + private ContextURLBuilder() {} + + public ContextURLBuilder serviceRoot(final URI serviceRoot) { + contextURL.serviceRoot = serviceRoot; + return this; + } + + public ContextURLBuilder entitySet(final EdmEntitySet entitySet) { + contextURL.entitySetOrSingletonOrType = entitySet.getName(); + return this; + } + + public ContextURLBuilder derived(final EdmEntityType derivedType) { + contextURL.derivedEntity = derivedType.getFullQualifiedName().getFullQualifiedNameAsString(); + return this; + } + + public ContextURLBuilder suffix(final Suffix suffix) { + contextURL.suffix = suffix; + return this; + } + + public ContextURL build() { + StringBuilder result = new StringBuilder(); + if (contextURL.serviceRoot != null) { + result.append(contextURL.serviceRoot); + } + result.append(Constants.METADATA); + if (contextURL.entitySetOrSingletonOrType != null) { + result.append('#').append(contextURL.entitySetOrSingletonOrType); + } + if (contextURL.derivedEntity != null) { + if (contextURL.entitySetOrSingletonOrType == null) { + throw new IllegalArgumentException("ContextURL: Derived Type without anything to derive from!"); + } + result.append('/').append(contextURL.derivedEntity); + } + if (contextURL.suffix == Suffix.REFERENCE) { + if (contextURL.entitySetOrSingletonOrType != null) { + throw new IllegalArgumentException("ContextURL: $ref with Entity Set"); + } + result.append('#').append(contextURL.suffix.getRepresentation()); + } else if (contextURL.suffix != null) { + if (contextURL.entitySetOrSingletonOrType == null) { + throw new IllegalArgumentException("ContextURL: Suffix without preceding Entity Set!"); + } + result.append('/').append(contextURL.suffix.getRepresentation()); + } + contextURL.uri = URI.create(result.toString()); + return contextURL; + } + } + + public static final ContextURLBuilder create() { + return new ContextURLBuilder(); } @Override diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/ODataServiceVersion.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/ODataServiceVersion.java index 3b321bc19..862443232 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/ODataServiceVersion.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/ODataServiceVersion.java @@ -24,6 +24,8 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.olingo.commons.api.Constants; + /** * This class is a container for the supported ODataServiceVersions. */ @@ -133,20 +135,20 @@ public enum ODataServiceVersion { private static final long serialVersionUID = 3109256773218160485L; { - put(JSON_TYPE, "@odata.type"); - put(JSON_ID, "@odata.id"); - put(JSON_ETAG, "@odata.etag"); - put(JSON_READ_LINK, "@odata.readLink"); - put(JSON_EDIT_LINK, "@odata.editLink"); - put(JSON_MEDIAREAD_LINK, "@odata.mediaReadLink"); - put(JSON_MEDIAEDIT_LINK, "@odata.mediaEditLink"); - put(JSON_MEDIA_CONTENT_TYPE, "@odata.mediaContentType"); - put(JSON_MEDIA_ETAG, "@odata.mediaEtag"); - put(JSON_ASSOCIATION_LINK, "@odata.associationLink"); - put(JSON_NAVIGATION_LINK, "@odata.navigationLink"); - put(JSON_COUNT, "@odata.count"); - put(JSON_NEXT_LINK, "@odata.nextLink"); - put(JSON_DELTA_LINK, "@odata.deltaLink"); + put(JSON_TYPE, Constants.JSON_TYPE); + put(JSON_ID, Constants.JSON_ID); + put(JSON_ETAG, Constants.JSON_ETAG); + put(JSON_READ_LINK, Constants.JSON_READ_LINK); + put(JSON_EDIT_LINK, Constants.JSON_EDIT_LINK); + put(JSON_MEDIAREAD_LINK, Constants.JSON_MEDIA_READ_LINK); + put(JSON_MEDIAEDIT_LINK, Constants.JSON_MEDIA_EDIT_LINK); + put(JSON_MEDIA_CONTENT_TYPE, Constants.JSON_MEDIA_CONTENT_TYPE); + put(JSON_MEDIA_ETAG, Constants.JSON_MEDIA_ETAG); + put(JSON_ASSOCIATION_LINK, Constants.JSON_ASSOCIATION_LINK); + put(JSON_NAVIGATION_LINK, Constants.JSON_NAVIGATION_LINK); + put(JSON_COUNT, Constants.JSON_COUNT); + put(JSON_NEXT_LINK, Constants.JSON_NEXT_LINK); + put(JSON_DELTA_LINK, Constants.JSON_DELTA_LINK); put(JSON_ERROR, "error"); } }); diff --git a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/data/ContextURLTest.java b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/data/ContextURLTest.java index 84046b214..7575e825c 100644 --- a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/data/ContextURLTest.java +++ b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/data/ContextURLTest.java @@ -25,7 +25,12 @@ import static org.junit.Assert.assertTrue; import java.net.URI; +import org.apache.olingo.commons.api.data.ContextURL.Suffix; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.EdmEntityType; +import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.junit.Test; +import org.mockito.Mockito; public class ContextURLTest { @@ -201,6 +206,16 @@ public class ContextURLTest { assertFalse(contextURL.isEntity()); } + @Test + public void reference() { + ContextURL contextURL = ContextURL.getInstance(URI.create("http://host/service/$metadata#Customers/$ref")); + assertTrue(contextURL.isReference()); + assertNull(contextURL.getSelectList()); + assertNull(contextURL.getNavOrPropertyPath()); + assertFalse(contextURL.isEntity()); + assertFalse(contextURL.isDelta()); + } + @Test public void delta() { ContextURL contextURL = ContextURL.getInstance(URI.create("http://host/service/$metadata#Customers/$delta")); @@ -227,4 +242,79 @@ public class ContextURLTest { assertNull(contextURL.getNavOrPropertyPath()); assertFalse(contextURL.isEntity()); } + + @Test + public void buildServiceDocument() { + ContextURL contextURL = ContextURL.create().serviceRoot(URI.create("http://host/service/")).build(); + assertEquals("http://host/service/$metadata", contextURL.getURI().toASCIIString()); + } + + @Test + public void buildRelative() { + ContextURL contextURL = ContextURL.create().build(); + assertEquals("$metadata", contextURL.getURI().toASCIIString()); + } + + @Test + public void buildEntitySet() { + EdmEntitySet entitySet = Mockito.mock(EdmEntitySet.class); + Mockito.when(entitySet.getName()).thenReturn("Customers"); + ContextURL contextURL = ContextURL.create().serviceRoot(URI.create("http://host/service/")) + .entitySet(entitySet) + .build(); + assertEquals("http://host/service/$metadata#Customers", contextURL.getURI().toASCIIString()); + } + + @Test + public void buildDerivedEntitySet() { + EdmEntitySet entitySet = Mockito.mock(EdmEntitySet.class); + Mockito.when(entitySet.getName()).thenReturn("Customers"); + EdmEntityType derivedType = Mockito.mock(EdmEntityType.class); + Mockito.when(derivedType.getFullQualifiedName()).thenReturn(new FullQualifiedName("Model", "VipCustomer")); + ContextURL contextURL = ContextURL.create().serviceRoot(URI.create("http://host/service/")) + .entitySet(entitySet) + .derived(derivedType) + .build(); + assertEquals("http://host/service/$metadata#Customers/Model.VipCustomer", contextURL.getURI().toASCIIString()); + } + + @Test(expected = IllegalArgumentException.class) + public void buildDerivedEntitySetWithoutEntitySet() { + EdmEntityType derivedType = Mockito.mock(EdmEntityType.class); + Mockito.when(derivedType.getFullQualifiedName()).thenReturn(new FullQualifiedName("Model", "VipCustomer")); + ContextURL.create().derived(derivedType).build(); + } + + @Test + public void buildDerivedEntity() { + EdmEntitySet entitySet = Mockito.mock(EdmEntitySet.class); + Mockito.when(entitySet.getName()).thenReturn("Customers"); + EdmEntityType derivedType = Mockito.mock(EdmEntityType.class); + Mockito.when(derivedType.getFullQualifiedName()).thenReturn(new FullQualifiedName("Model", "VipCustomer")); + ContextURL contextURL = ContextURL.create().serviceRoot(URI.create("http://host/service/")) + .entitySet(entitySet) + .derived(derivedType) + .suffix(Suffix.ENTITY) + .build(); + assertEquals("http://host/service/$metadata#Customers/Model.VipCustomer/$entity", + contextURL.getURI().toASCIIString()); + } + + @Test(expected = IllegalArgumentException.class) + public void buildSuffixWithoutEntitySet() { + ContextURL.create().suffix(Suffix.ENTITY).build(); + } + + @Test + public void buildReference() { + ContextURL contextURL = ContextURL.create().suffix(Suffix.REFERENCE).build(); + assertEquals("$metadata#$ref", contextURL.getURI().toASCIIString()); + } + + @Test(expected = IllegalArgumentException.class) + public void buildReferenceWithEntitySet() { + EdmEntitySet entitySet = Mockito.mock(EdmEntitySet.class); + Mockito.when(entitySet.getName()).thenReturn("Customers"); + ContextURL.create().entitySet(entitySet).suffix(Suffix.REFERENCE).build(); + } } diff --git a/lib/commons-core/pom.xml b/lib/commons-core/pom.xml index 8977822f6..f2b7e0a49 100644 --- a/lib/commons-core/pom.xml +++ b/lib/commons-core/pom.xml @@ -65,14 +65,16 @@ com.fasterxml aalto-xml - + junit junit + test org.mockito mockito-all + test diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java index d1037c588..24e18da98 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java @@ -26,7 +26,6 @@ import org.apache.olingo.commons.api.data.EntitySet; import org.apache.olingo.commons.api.domain.ODataError; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmEntitySet; -import org.apache.olingo.commons.api.edm.EdmEntityType; public interface ODataSerializer { @@ -36,12 +35,12 @@ public interface ODataSerializer { InputStream metadataDocument(Edm edm); - InputStream entity(EdmEntityType edmEntityType, Entity entity, ContextURL contextURL); + InputStream entity(EdmEntitySet edmEntitySet, Entity entity, ContextURL contextURL); InputStream entitySet(EdmEntitySet edmEntitySet, EntitySet entitySet, ContextURL contextURL); /** - * Writes an ODataError into an InputStream + * Writes an ODataError into an InputStream. * @param error the main error * @return inputStream containing the OData formatted error */ diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java index 2f2afeb38..da8380879 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java @@ -31,7 +31,6 @@ import org.apache.olingo.commons.api.data.EntitySet; import org.apache.olingo.commons.api.domain.ODataError; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmEntitySet; -import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.server.api.serializer.ODataSerializer; import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer; import org.apache.olingo.server.core.serializer.xml.MetadataDocumentXmlSerializer; @@ -77,7 +76,7 @@ public class ODataXmlSerializerImpl implements ODataSerializer { } @Override - public InputStream entity(final EdmEntityType edmEntityType, final Entity entity, final ContextURL contextURL) { + public InputStream entity(final EdmEntitySet edmEntitySet, final Entity entity, final ContextURL contextURL) { throw new ODataRuntimeException("Entity serialization not implemented for XML format"); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java index b2025eb5b..e1f1992f8 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java @@ -27,6 +27,7 @@ import java.util.List; import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.commons.api.data.ContextURL; +import org.apache.olingo.commons.api.data.ContextURL.Suffix; import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntitySet; import org.apache.olingo.commons.api.data.LinkedComplexValue; @@ -123,24 +124,27 @@ public class ODataJsonSerializer implements ODataSerializer { @Override public InputStream entitySet(final EdmEntitySet edmEntitySet, final EntitySet entitySet, final ContextURL contextURL) { + final ContextURL entitySetContextURL = contextURL == null ? + ContextURL.create().entitySet(edmEntitySet).build() : + contextURL; CircleStreamBuffer buffer = new CircleStreamBuffer(); try { JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream()); json.writeStartObject(); - if (contextURL != null && format != ODataFormat.JSON_NO_METADATA) { - json.writeStringField(Constants.JSON_CONTEXT, contextURL.getURI().toASCIIString()); + if (entitySetContextURL != null && format != ODataFormat.JSON_NO_METADATA) { + json.writeStringField(Constants.JSON_CONTEXT, entitySetContextURL.getURI().toASCIIString()); } if (entitySet.getCount() != null) { - json.writeNumberField("@odata.count", entitySet.getCount()); + json.writeNumberField(Constants.JSON_COUNT, entitySet.getCount()); } json.writeFieldName(Constants.VALUE); json.writeStartArray(); for (Entity entity : entitySet.getEntities()) { - writeEntity(edmEntitySet.getEntityType(), entity, null, json); + writeEntity(edmEntitySet, entity, null, json); } json.writeEndArray(); if (entitySet.getNext() != null) { - json.writeStringField("@odata.nextLink", entitySet.getNext().toASCIIString()); + json.writeStringField(Constants.JSON_NEXT_LINK, entitySet.getNext().toASCIIString()); } json.close(); } catch (final IOException e) { @@ -152,11 +156,14 @@ public class ODataJsonSerializer implements ODataSerializer { } @Override - public InputStream entity(final EdmEntityType edmEntityType, final Entity entity, final ContextURL contextURL) { + public InputStream entity(final EdmEntitySet edmEntitySet, final Entity entity, final ContextURL contextURL) { + final ContextURL entityContextURL = contextURL == null ? + ContextURL.create().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build() : + contextURL; CircleStreamBuffer buffer = new CircleStreamBuffer(); try { JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream()); - writeEntity(edmEntityType, entity, contextURL, json); + writeEntity(edmEntitySet, entity, entityContextURL, json); json.close(); } catch (final IOException e) { throw new ODataRuntimeException(e); @@ -166,7 +173,7 @@ public class ODataJsonSerializer implements ODataSerializer { return buffer.getInputStream(); } - protected void writeEntity(final EdmEntityType entityType, final Entity entity, final ContextURL contextURL, + protected void writeEntity(final EdmEntitySet entitySet, final Entity entity, final ContextURL contextURL, final JsonGenerator json) throws IOException, EdmPrimitiveTypeException { json.writeStartObject(); if (format != ODataFormat.JSON_NO_METADATA) { @@ -174,15 +181,16 @@ public class ODataJsonSerializer implements ODataSerializer { json.writeStringField(Constants.JSON_CONTEXT, contextURL.getURI().toASCIIString()); } if (entity.getETag() != null) { - json.writeStringField("@odata.etag", entity.getETag()); + json.writeStringField(Constants.JSON_ETAG, entity.getETag()); } if (entity.getMediaETag() != null) { - json.writeStringField("@odata.mediaEtag", entity.getMediaETag()); + json.writeStringField(Constants.JSON_MEDIA_ETAG, entity.getMediaETag()); } if (entity.getMediaContentType() != null) { - json.writeStringField("@odata.mediaContentType", entity.getMediaContentType()); + json.writeStringField(Constants.JSON_MEDIA_CONTENT_TYPE, entity.getMediaContentType()); } } + final EdmEntityType entityType = entitySet.getEntityType(); for (final String propertyName : entityType.getPropertyNames()) { final EdmProperty edmProperty = (EdmProperty) entityType.getProperty(propertyName); final Property property = entity.getProperty(propertyName); diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java index f9d1e5584..2badfab44 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java @@ -26,7 +26,6 @@ import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntitySet; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmEntitySet; -import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.http.HttpHeader; @@ -73,8 +72,7 @@ public class TechnicalProcessor implements CollectionProcessor, EntityProcessor if (entitySet == null) { response.setStatusCode(HttpStatusCode.NOT_FOUND.getStatusCode()); } else { - response.setContent(serializer.entitySet(edmEntitySet, entitySet, - getContextUrl(request, edmEntitySet.getEntityType()))); + response.setContent(serializer.entitySet(edmEntitySet, entitySet, getContextUrl(edmEntitySet))); response.setStatusCode(HttpStatusCode.OK.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString()); } @@ -97,8 +95,7 @@ public class TechnicalProcessor implements CollectionProcessor, EntityProcessor if (entity == null) { response.setStatusCode(HttpStatusCode.NOT_FOUND.getStatusCode()); } else { - response.setContent(serializer.entity(edmEntitySet.getEntityType(), entity, - getContextUrl(request, edmEntitySet.getEntityType()))); + response.setContent(serializer.entity(edmEntitySet, entity, getContextUrl(edmEntitySet))); response.setStatusCode(HttpStatusCode.OK.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString()); } @@ -149,7 +146,7 @@ public class TechnicalProcessor implements CollectionProcessor, EntityProcessor return uriResource.getEntitySet(); } - private ContextURL getContextUrl(final ODataRequest request, final EdmEntityType entityType) { - return ContextURL.getInstance(URI.create(request.getRawBaseUri() + "/" + entityType.getName())); + private ContextURL getContextUrl(final EdmEntitySet entitySet) { + return ContextURL.create().entitySet(entitySet).build(); } } diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/JsonDataProviderTest.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/JsonDataProviderTest.java index 462855c4e..37600f86e 100644 --- a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/JsonDataProviderTest.java +++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/JsonDataProviderTest.java @@ -65,10 +65,10 @@ public class JsonDataProviderTest { @Test public void doRoundTrip() throws Exception { - doRoundTrip(entityContainer.getEntitySet("ESAllPrim"), 1401); - doRoundTrip(entityContainer.getEntitySet("ESCompAllPrim"), 1592); - doRoundTrip(entityContainer.getEntitySet("ESCollAllPrim"), 2855); - doRoundTrip(entityContainer.getEntitySet("ESMixPrimCollComp"), 1032); + doRoundTrip(entityContainer.getEntitySet("ESAllPrim"), 1440); + doRoundTrip(entityContainer.getEntitySet("ESCompAllPrim"), 1635); + doRoundTrip(entityContainer.getEntitySet("ESCollAllPrim"), 2898); + doRoundTrip(entityContainer.getEntitySet("ESMixPrimCollComp"), 1079); } @Test diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java index d3753b400..3eaba5644 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java @@ -23,6 +23,7 @@ import java.net.URI; import org.apache.commons.io.IOUtils; import org.apache.olingo.commons.api.data.ContextURL; +import org.apache.olingo.commons.api.data.ContextURL.Suffix; import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntitySet; import org.apache.olingo.commons.api.edm.Edm; @@ -49,8 +50,8 @@ public class ODataJsonSerializerTest { public void entitySimple() throws Exception { final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim"); final Entity entity = data.readAll(edmEntitySet).getEntities().get(0); - InputStream result = serializer.entity(edmEntitySet.getEntityType(), entity, - ContextURL.getInstance(URI.create("$metadata#ESAllPrim/$entity"))); + InputStream result = serializer.entity(edmEntitySet, entity, + ContextURL.create().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()); final String resultString = IOUtils.toString(result); final String expectedResult = "{" + "\"@odata.context\":\"$metadata#ESAllPrim/$entity\"," @@ -80,8 +81,7 @@ public class ODataJsonSerializerTest { EntitySet entitySet = data.readAll(edmEntitySet); entitySet.setCount(entitySet.getEntities().size()); entitySet.setNext(URI.create("/next")); - InputStream result = serializer.entitySet(edmEntitySet, entitySet, - ContextURL.getInstance(URI.create("$metadata#ESAllPrim"))); + InputStream result = serializer.entitySet(edmEntitySet, entitySet, null); final String resultString = IOUtils.toString(result); Assert.assertTrue(resultString.matches("\\{" @@ -103,11 +103,12 @@ public class ODataJsonSerializerTest { public void entityCollAllPrim() throws Exception { final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCollAllPrim"); final Entity entity = data.readAll(edmEntitySet).getEntities().get(0); - InputStream result = serializer.entity(edmEntitySet.getEntityType(), entity, - ContextURL.getInstance(URI.create("$metadata#ESCollAllPrim/$entity"))); + InputStream result = serializer.entity(edmEntitySet, entity, + ContextURL.create().serviceRoot(URI.create("http://host/service/")) + .entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()); final String resultString = IOUtils.toString(result); final String expectedResult = "{" - + "\"@odata.context\":\"$metadata#ESCollAllPrim/$entity\"," + + "\"@odata.context\":\"http://host/service/$metadata#ESCollAllPrim/$entity\"," + "\"PropertyInt16\":1," + "\"CollPropertyString\":[\"spiderman@comic.com\",\"spidermaus@comic.com\",\"spidergirl@comic.com\"]," + "\"CollPropertyBoolean\":[true,false,true]," @@ -135,8 +136,7 @@ public class ODataJsonSerializerTest { public void entityCompAllPrim() throws Exception { final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompAllPrim"); final Entity entity = data.readAll(edmEntitySet).getEntities().get(0); - InputStream result = serializer.entity(edmEntitySet.getEntityType(), entity, - ContextURL.getInstance(URI.create("$metadata#ESCompAllPrim/$entity"))); + InputStream result = serializer.entity(edmEntitySet, entity, null); final String resultString = IOUtils.toString(result); final String expectedResult = "{" + "\"@odata.context\":\"$metadata#ESCompAllPrim/$entity\"," @@ -166,8 +166,7 @@ public class ODataJsonSerializerTest { public void entityMixPrimCollComp() throws Exception { final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp"); final Entity entity = data.readAll(edmEntitySet).getEntities().get(0); - InputStream result = serializer.entity(edmEntitySet.getEntityType(), entity, - ContextURL.getInstance(URI.create("$metadata#ESMixPrimCollComp/$entity"))); + InputStream result = serializer.entity(edmEntitySet, entity, null); final String resultString = IOUtils.toString(result); final String expectedResult = "{" + "\"@odata.context\":\"$metadata#ESMixPrimCollComp/$entity\"," @@ -186,7 +185,7 @@ public class ODataJsonSerializerTest { final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim"); final Entity entity = data.readAll(edmEntitySet).getEntities().get(0); InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA) - .entity(edmEntitySet.getEntityType(), entity, ContextURL.getInstance(URI.create("contextURL"))); + .entity(edmEntitySet, entity, ContextURL.create().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()); final String resultString = IOUtils.toString(result); final String expectedResult = "{\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}"; Assert.assertEquals(expectedResult, resultString); @@ -197,7 +196,7 @@ public class ODataJsonSerializerTest { final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim"); final EntitySet entitySet = data.readAll(edmEntitySet); InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA) - .entitySet(edmEntitySet, entitySet, ContextURL.getInstance(URI.create("contextURL"))); + .entitySet(edmEntitySet, entitySet, ContextURL.create().entitySet(edmEntitySet).build()); final String resultString = IOUtils.toString(result); final String expectedResult = "{\"value\":[" + "{\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}," From c541d9251b4ee36442cfdf9b18984892c1d2b819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= <--global> Date: Wed, 16 Jul 2014 10:05:04 +0200 Subject: [PATCH 16/16] [OLINGO-362] OAuth2 supporting abstract class provided + concrete CXF-based IT --- LICENSE | 202 ++++ NOTICE | 8 + README | 64 + fit/pom.xml | 44 +- .../apache/olingo/fit/AbstractServices.java | 763 ++++++------ .../fit/UnsupportedMediaTypeException.java | 12 +- .../olingo/fit/V3ActionOverloading.java | 59 +- .../org/apache/olingo/fit/V3KeyAsSegment.java | 105 +- .../org/apache/olingo/fit/V3OpenType.java | 53 +- .../apache/olingo/fit/V3PrimitiveKeys.java | 10 +- .../org/apache/olingo/fit/V3Services.java | 190 +-- .../java/org/apache/olingo/fit/V4Demo.java | 89 +- .../org/apache/olingo/fit/V4KeyAsSegment.java | 76 +- .../org/apache/olingo/fit/V4NorthWind.java | 5 +- .../org/apache/olingo/fit/V4NorthWindExt.java | 9 +- .../java/org/apache/olingo/fit/V4OAuth2.java | 37 + .../org/apache/olingo/fit/V4OpenType.java | 49 +- .../org/apache/olingo/fit/V4Services.java | 8 +- .../org/apache/olingo/fit/V4Vocabularies.java | 25 +- .../olingo/fit/rest/OAuth2InInterceptor.java | 97 ++ .../olingo/fit/rest/OAuth2Provider.java | 133 +++ .../ResolvingReferencesInterceptor.java | 10 +- .../fit/rest/ServiceNameResponseFilter.java | 55 + .../fit/rest/StaticSecurityInterceptor.java | 85 ++ .../XHTTPMethodInterceptor.java | 8 +- .../olingo/fit/utils/AbstractUtilities.java | 2 +- .../olingo/fit/utils/JSONUtilities.java | 68 +- .../apache/olingo/fit/utils/XMLUtilities.java | 3 +- fit/src/main/resources/META-INF/LICENSE | 1047 +++++++++++++++++ .../webapp/WEB-INF/applicationContext.xml | 41 +- .../fit/CXFOAuth2HttpUriRequestFactory.java | 130 ++ .../olingo/fit/v4/AbstractTestITCase.java | 29 +- .../olingo/fit/v4/EntityCreateTestITCase.java | 4 +- .../olingo/fit/v4/KeyAsSegmentTestITCase.java | 14 +- .../olingo/fit/v4/OAuth2TestITCase.java | 107 ++ .../request/AbstractRequest.java | 24 +- .../response/AbstractODataResponse.java | 1 - .../AbstractOAuth2HttpUriRequestFactory.java | 52 + .../client/core/http/OAuth2Exception.java | 29 + lib/server-core/pom.xml | 4 +- lib/server-tecsvc/pom.xml | 3 + .../src/main/resources/META-INF/LICENSE | 331 ++++++ pom.xml | 295 +++-- 43 files changed, 3454 insertions(+), 926 deletions(-) create mode 100644 LICENSE create mode 100644 NOTICE create mode 100644 README create mode 100644 fit/src/main/java/org/apache/olingo/fit/V4OAuth2.java create mode 100644 fit/src/main/java/org/apache/olingo/fit/rest/OAuth2InInterceptor.java create mode 100644 fit/src/main/java/org/apache/olingo/fit/rest/OAuth2Provider.java rename fit/src/main/java/org/apache/olingo/fit/{utils => rest}/ResolvingReferencesInterceptor.java (91%) create mode 100644 fit/src/main/java/org/apache/olingo/fit/rest/ServiceNameResponseFilter.java create mode 100644 fit/src/main/java/org/apache/olingo/fit/rest/StaticSecurityInterceptor.java rename fit/src/main/java/org/apache/olingo/fit/{utils => rest}/XHTTPMethodInterceptor.java (84%) create mode 100644 fit/src/main/resources/META-INF/LICENSE create mode 100644 fit/src/test/java/org/apache/olingo/fit/CXFOAuth2HttpUriRequestFactory.java create mode 100644 fit/src/test/java/org/apache/olingo/fit/v4/OAuth2TestITCase.java create mode 100644 lib/client-core/src/main/java/org/apache/olingo/client/core/http/AbstractOAuth2HttpUriRequestFactory.java create mode 100644 lib/client-core/src/main/java/org/apache/olingo/client/core/http/OAuth2Exception.java create mode 100644 lib/server-tecsvc/src/main/resources/META-INF/LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/NOTICE b/NOTICE new file mode 100644 index 000000000..65d59ef37 --- /dev/null +++ b/NOTICE @@ -0,0 +1,8 @@ + +Apache Olingo +Copyright 2013-2014 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + + diff --git a/README b/README new file mode 100644 index 000000000..85bceaa35 --- /dev/null +++ b/README @@ -0,0 +1,64 @@ +========================== +Apache Olingo +========================== + +Apache Olingo is a Java library and extensions around +the OData specification. + +Apache Olingo supports the specification versions + - OData 4.0 + +Building Apache Olingo +====================== + +You can build Apache Olingo like this: + + mvn clean install + +You need Maven 3 with Java 6 (or higher) for the build. +Set the environment variable MAVEN_OPTS to +'-Xmx1024m -XX:MaxPermSize=256m' to give Maven more memory. + +Documentation +============= + +The project documentation is available here: + +http://olingo.apache.org/ + +License (see also package specific LICENSE files) +================================================= + +Collective work: Copyright 2014 The Apache Software Foundation. + +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. + +Dependencies with "Weak Copyleft" or dual licenses +================================================== + +Apache Olingo uses some libraries with open source licenses that require reciprocal +licensing when modified. These libraries are included in unmodified binary +form and can be redistributed under terms that are compatible with the +Apache License. + +Some libraries used by Apache Olingo are dual-licensed under different open source +licenses. These libraries are redistributed under the license whose terms +are compatible with the Apache License. + +See LICENSE file included in all Apache Olingo packages for +full licensing details. + + diff --git a/fit/pom.xml b/fit/pom.xml index 84d4eacf6..742be223b 100644 --- a/fit/pom.xml +++ b/fit/pom.xml @@ -20,7 +20,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 olingo-fit @@ -48,10 +48,31 @@ + + org.apache.geronimo.specs + geronimo-javamail_1.4_spec + org.apache.cxf cxf-rt-frontend-jaxrs + + org.apache.cxf + cxf-rt-rs-client + + + org.apache.cxf + cxf-rt-rs-security-oauth2 + + + org.apache.cxf + cxf-rt-rs-extension-providers + + + org.codehaus.jettison + jettison + 1.3.5 + com.fasterxml.jackson.core jackson-databind @@ -113,6 +134,17 @@ + + + + src/main/resources + true + + + target/maven-shared-archive-resources + + + org.apache.maven.plugins @@ -149,9 +181,9 @@ ${project.build.outputDirectory} - + WEB-INF/classes/esigate.properties,WEB-INF/classes/META-INF/LICENSE*,WEB-INF/classes/META-INF/DEPENDENCIES* @@ -239,11 +271,5 @@ - - - src/main/resources - true - - 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 dbbb110d6..999ec1db6 100644 --- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java +++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java @@ -125,22 +125,28 @@ public abstract class AbstractServices { private static final Pattern REF_PATTERN = Pattern.compile("([$]\\d+)"); protected static final String BOUNDARY = "batch_243234_25424_ef_892u748"; + protected static final String MULTIPART_MIXED = "multipart/mixed"; - // ContentType.MULTIPART_MIXED.toContentTypeString(); + protected static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; protected final ODataServiceVersion version; + protected final Metadata metadata; protected final ODataDeserializer atomDeserializer; + protected final ODataDeserializer jsonDeserializer; + protected final ODataSerializer atomSerializer; + protected final ODataSerializer jsonSerializer; protected final XMLUtilities xml; + protected final JSONUtilities json; - public AbstractServices(final ODataServiceVersion version, final Metadata metadata) throws Exception { + public AbstractServices(final ODataServiceVersion version, final Metadata metadata) throws IOException { this.version = version; this.metadata = metadata; @@ -155,7 +161,7 @@ public abstract class AbstractServices { /** * Provide sample services. - * + * * @param accept Accept header. * @return OData services. */ @@ -169,9 +175,9 @@ public abstract class AbstractServices { } return xml.createResponse( - null, - FSManager.instance(version).readFile(Constants.get(version, ConstantKey.SERVICES), acceptType), - null, acceptType); + null, + FSManager.instance(version).readFile(Constants.get(version, ConstantKey.SERVICES), acceptType), + null, acceptType); } catch (Exception e) { return xml.createFaultResponse(accept, e); } @@ -179,7 +185,7 @@ public abstract class AbstractServices { /** * Provide sample getMetadata(). - * + * * @return getMetadata(). */ @GET @@ -202,13 +208,13 @@ public abstract class AbstractServices { @Consumes(MULTIPART_MIXED) @Produces(APPLICATION_OCTET_STREAM + ";boundary=" + BOUNDARY) public Response batch( - @HeaderParam("Authorization") @DefaultValue(StringUtils.EMPTY) final String authorization, - @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, - final @Multipart MultipartBody attachment) { + @HeaderParam("Authorization") @DefaultValue(StringUtils.EMPTY) final String authorization, + @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, + final @Multipart MultipartBody attachment) { try { final boolean continueOnError = prefer.contains("odata.continue-on-error"); return xml.createBatchResponse( - exploreMultipart(attachment.getAllAttachments(), BOUNDARY, continueOnError)); + exploreMultipart(attachment.getAllAttachments(), BOUNDARY, continueOnError)); } catch (IOException e) { return xml.createFaultResponse(Accept.XML.toString(version), e); } @@ -258,9 +264,8 @@ public abstract class AbstractServices { } // ---------------------------------------------- - protected Response bodyPartRequest(final MimeBodyPart body) throws Exception { - return bodyPartRequest(body, Collections. emptyMap()); + return bodyPartRequest(body, Collections.emptyMap()); } protected Response bodyPartRequest(final MimeBodyPart body, final Map references) throws Exception { @@ -269,7 +274,7 @@ public abstract class AbstractServices { Header header = en.nextElement(); final String request = - header.getName() + (StringUtils.isNotBlank(header.getValue()) ? ":" + header.getValue() : ""); + header.getName() + (StringUtils.isNotBlank(header.getValue()) ? ":" + header.getValue() : ""); final Matcher matcher = REQUEST_PATTERN.matcher(request); final Matcher matcherRef = BATCH_REQUEST_REF_PATTERN.matcher(request); @@ -323,15 +328,16 @@ public abstract class AbstractServices { } } - client.close(); + // When updating to CXF 3.0.1, uncomment the following line, see CXF-5865 + //client.close(); } return res; } protected abstract InputStream exploreMultipart( - final List attachments, final String boundary, final boolean continueOnError) - throws IOException; + final List attachments, final String boundary, final boolean continueOnError) + throws IOException; protected void addItemIntro(final ByteArrayOutputStream bos) throws IOException { addItemIntro(bos, null); @@ -352,7 +358,7 @@ public abstract class AbstractServices { } protected void addChangesetItemIntro( - final ByteArrayOutputStream bos, final String contentId, final String cboundary) throws IOException { + final ByteArrayOutputStream bos, final String contentId, final String cboundary) throws IOException { bos.write(("--" + cboundary).getBytes()); bos.write(Constants.CRLF); bos.write(("Content-ID: " + contentId).getBytes()); @@ -361,12 +367,14 @@ public abstract class AbstractServices { } protected void addSingleBatchResponse( - final Response response, final ByteArrayOutputStream bos) throws IOException { + final Response response, final ByteArrayOutputStream bos) throws IOException { + addSingleBatchResponse(response, null, bos); } protected void addSingleBatchResponse( - final Response response, final String contentId, final ByteArrayOutputStream bos) throws IOException { + final Response response, final String contentId, final ByteArrayOutputStream bos) throws IOException { + bos.write("HTTP/1.1 ".getBytes()); bos.write(String.valueOf(response.getStatusInfo().getStatusCode()).getBytes()); bos.write(" ".getBytes()); @@ -403,45 +411,47 @@ public abstract class AbstractServices { } protected void addErrorBatchResponse(final Exception e, final ByteArrayOutputStream bos) - throws IOException { + throws IOException { + addErrorBatchResponse(e, null, bos); } protected void addErrorBatchResponse(final Exception e, final String contentId, final ByteArrayOutputStream bos) - throws IOException { + throws IOException { + addSingleBatchResponse(xml.createFaultResponse(Accept.XML.toString(version), e), contentId, bos); } @MERGE @Path("/{entitySetName}({entityId})") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) + @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) 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) { + @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 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 }) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) + @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) 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) { + @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) { try { final Accept acceptType = Accept.parse(accept, version); @@ -465,7 +475,7 @@ public abstract class AbstractServices { throw new UnsupportedMediaTypeException("Unsupported media type"); } else if (contentTypeValue == Accept.ATOM) { entryChanges = atomDeserializer.toEntity( - IOUtils.toInputStream(changes, Constants.ENCODING)).getPayload(); + IOUtils.toInputStream(changes, Constants.ENCODING)).getPayload(); } else { final ResWrap jcont = jsonDeserializer.toEntity(IOUtils.toInputStream(changes, Constants.ENCODING)); entryChanges = jcont.getPayload(); @@ -493,7 +503,7 @@ public abstract class AbstractServices { writer.close(); final InputStream res = xml.addOrReplaceEntity( - entityId, entitySetName, new ByteArrayInputStream(content.toByteArray()), container.getPayload()); + entityId, entitySetName, new ByteArrayInputStream(content.toByteArray()), container.getPayload()); final ResWrap cres = atomDeserializer.toEntity(res); @@ -501,25 +511,25 @@ public abstract class AbstractServices { final String path = Commons.getEntityBasePath(entitySetName, entityId); FSManager.instance(version).putInMemory( - cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY)); + cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY)); final Response response; if ("return-content".equalsIgnoreCase(prefer)) { response = xml.createResponse( - uriInfo.getRequestUri().toASCIIString(), - xml.readEntity(entitySetName, entityId, acceptType).getValue(), - null, acceptType, Response.Status.OK); + uriInfo.getRequestUri().toASCIIString(), + xml.readEntity(entitySetName, entityId, acceptType).getValue(), + null, acceptType, Response.Status.OK); } else { res.close(); response = xml.createResponse( - uriInfo.getRequestUri().toASCIIString(), - null, - null, - acceptType, Response.Status.NO_CONTENT); + uriInfo.getRequestUri().toASCIIString(), + null, + null, + acceptType, Response.Status.NO_CONTENT); } if (StringUtils.isNotBlank(prefer)) { - response.getHeaders().put("Preference-Applied", Collections. singletonList(prefer)); + response.getHeaders().put("Preference-Applied", Collections.singletonList(prefer)); } return response; @@ -530,16 +540,16 @@ public abstract class AbstractServices { @PUT @Path("/{entitySetName}({entityId})") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) + @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) public Response replaceEntity( - @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) { + @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) { try { final Accept acceptType = Accept.parse(accept, version); @@ -549,8 +559,8 @@ public abstract class AbstractServices { } final InputStream res = getUtilities(acceptType).addOrReplaceEntity(entityId, entitySetName, - IOUtils.toInputStream(entity, Constants.ENCODING), - xml.readEntity(acceptType, IOUtils.toInputStream(entity, Constants.ENCODING))); + IOUtils.toInputStream(entity, Constants.ENCODING), + xml.readEntity(acceptType, IOUtils.toInputStream(entity, Constants.ENCODING))); final ResWrap cres; if (acceptType == Accept.ATOM) { @@ -561,28 +571,28 @@ public abstract class AbstractServices { final String path = Commons.getEntityBasePath(entitySetName, entityId); FSManager.instance(version).putInMemory( - cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY)); + cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY)); final Response response; if ("return-content".equalsIgnoreCase(prefer)) { response = xml.createResponse( - uriInfo.getRequestUri().toASCIIString(), - xml.readEntity(entitySetName, entityId, acceptType).getValue(), - null, - acceptType, - Response.Status.OK); + uriInfo.getRequestUri().toASCIIString(), + xml.readEntity(entitySetName, entityId, acceptType).getValue(), + null, + acceptType, + Response.Status.OK); } else { res.close(); response = xml.createResponse( - uriInfo.getRequestUri().toASCIIString(), - null, - null, - acceptType, - Response.Status.NO_CONTENT); + uriInfo.getRequestUri().toASCIIString(), + null, + null, + acceptType, + Response.Status.NO_CONTENT); } if (StringUtils.isNotBlank(prefer)) { - response.getHeaders().put("Preference-Applied", Collections. singletonList(prefer)); + response.getHeaders().put("Preference-Applied", Collections.singletonList(prefer)); } return response; @@ -593,15 +603,15 @@ public abstract class AbstractServices { @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 }) + @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 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) { + @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) { try { final Accept acceptType = Accept.parse(accept, version); @@ -630,8 +640,11 @@ public abstract class AbstractServices { prop.setName(id.getKey()); prop.setType(id.getValue().toString()); prop.setValue(ValueType.PRIMITIVE, - id.getValue() == EdmPrimitiveTypeKind.Int32 ? Integer.parseInt(entityKey) : - id.getValue() == EdmPrimitiveTypeKind.Guid ? UUID.fromString(entityKey) : entityKey); + id.getValue() == EdmPrimitiveTypeKind.Int32 + ? Integer.parseInt(entityKey) + : id.getValue() == EdmPrimitiveTypeKind.Guid + ? UUID.fromString(entityKey) + : entityKey); entry.getProperties().add(prop); } @@ -666,13 +679,13 @@ public abstract class AbstractServices { writer.close(); final InputStream serialization = - xml.addOrReplaceEntity(entityKey, entitySetName, new ByteArrayInputStream(content.toByteArray()), entry); + xml.addOrReplaceEntity(entityKey, entitySetName, new ByteArrayInputStream(content.toByteArray()), entry); ResWrap result = atomDeserializer.toEntity(serialization); result = new ResWrap( - URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) - + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)), - null, result.getPayload()); + URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)), + null, result.getPayload()); final String path = Commons.getEntityBasePath(entitySetName, entityKey); FSManager.instance(version).putInMemory(result, path + Constants.get(version, ConstantKey.ENTITY)); @@ -682,22 +695,22 @@ public abstract class AbstractServices { final Response response; if ("return-no-content".equalsIgnoreCase(prefer)) { response = xml.createResponse( - location, - null, - null, - acceptType, - Response.Status.NO_CONTENT); + location, + null, + null, + acceptType, + Response.Status.NO_CONTENT); } else { response = xml.createResponse( - location, - xml.writeEntity(acceptType, result), - null, - acceptType, - Response.Status.CREATED); + location, + xml.writeEntity(acceptType, result), + null, + acceptType, + Response.Status.CREATED); } if (StringUtils.isNotBlank(prefer)) { - response.getHeaders().put("Preference-Applied", Collections. singletonList(prefer)); + response.getHeaders().put("Preference-Applied", Collections.singletonList(prefer)); } return response; @@ -710,10 +723,10 @@ public abstract class AbstractServices { @POST @Path("/Person({entityId})/{type:.*}/Sack") public Response actionSack( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entityId") final String entityId, - @PathParam("type") final String type, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("entityId") final String entityId, + @PathParam("type") final String type, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { final Map.Entry utils = getUtilities(accept, format); @@ -732,8 +745,8 @@ public abstract class AbstractServices { final FSManager fsManager = FSManager.instance(version); fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container), - fsManager.getAbsolutePath(Commons.getEntityBasePath("Person", entityId) + Constants.get(version, - ConstantKey.ENTITY), Accept.ATOM)); + fsManager.getAbsolutePath(Commons.getEntityBasePath("Person", entityId) + Constants.get(version, + ConstantKey.ENTITY), Accept.ATOM)); return utils.getValue().createResponse(null, null, null, utils.getKey(), Response.Status.NO_CONTENT); } catch (Exception e) { @@ -744,10 +757,10 @@ public abstract class AbstractServices { @POST @Path("/Person/{type:.*}/IncreaseSalaries") public Response actionIncreaseSalaries( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("type") final String type, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - final String body) { + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("type") final String type, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, + final String body) { final String name = "Person"; try { @@ -763,12 +776,12 @@ public abstract class AbstractServices { final int n = tree.get("n").asInt(); final StringBuilder path = new StringBuilder(name). - append(File.separatorChar).append(type). - append(File.separatorChar); + append(File.separatorChar).append(type). + append(File.separatorChar); path.append(metadata.getEntitySet(name).isSingleton() - ? Constants.get(version, ConstantKey.ENTITY) - : Constants.get(version, ConstantKey.FEED)); + ? Constants.get(version, ConstantKey.ENTITY) + : Constants.get(version, ConstantKey.FEED)); final InputStream feed = FSManager.instance(version).readFile(path.toString(), acceptType); @@ -778,20 +791,20 @@ public abstract class AbstractServices { String newContent = new String(copy.toByteArray(), "UTF-8"); final Pattern salary = Pattern.compile(acceptType == Accept.ATOM - ? "\\(-?\\d+)\\" - : "\"Salary\":(-?\\d+),"); + ? "\\(-?\\d+)\\" + : "\"Salary\":(-?\\d+),"); final Matcher salaryMatcher = salary.matcher(newContent); while (salaryMatcher.find()) { final Long newSalary = Long.valueOf(salaryMatcher.group(1)) + n; newContent = newContent. - replaceAll("\"Salary\":" + salaryMatcher.group(1) + ",", - "\"Salary\":" + newSalary + ","). - replaceAll("\\" + salaryMatcher.group(1) + "", - "" + newSalary + ""); + replaceAll("\"Salary\":" + salaryMatcher.group(1) + ",", + "\"Salary\":" + newSalary + ","). + replaceAll("\\" + salaryMatcher.group(1) + "", + "" + newSalary + ""); } FSManager.instance(version).putInMemory(IOUtils.toInputStream(newContent, Constants.ENCODING), - FSManager.instance(version).getAbsolutePath(path.toString(), acceptType)); + FSManager.instance(version).getAbsolutePath(path.toString(), acceptType)); return xml.createResponse(null, null, null, acceptType, Response.Status.NO_CONTENT); } catch (Exception e) { @@ -802,10 +815,10 @@ public abstract class AbstractServices { @POST @Path("/Product({entityId})/ChangeProductDimensions") public Response actionChangeProductDimensions( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entityId") final String entityId, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - final String argument) { + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("entityId") final String entityId, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, + final String argument) { final Map.Entry utils = getUtilities(accept, format); @@ -826,8 +839,8 @@ public abstract class AbstractServices { final FSManager fsManager = FSManager.instance(version); fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container), - fsManager.getAbsolutePath(Commons.getEntityBasePath("Product", entityId) + Constants.get(version, - ConstantKey.ENTITY), Accept.ATOM)); + fsManager.getAbsolutePath(Commons.getEntityBasePath("Product", entityId) + Constants.get(version, + ConstantKey.ENTITY), Accept.ATOM)); return utils.getValue().createResponse(null, null, null, utils.getKey(), Response.Status.NO_CONTENT); } catch (Exception e) { @@ -838,10 +851,10 @@ public abstract class AbstractServices { @POST @Path("/ComputerDetail({entityId})/ResetComputerDetailsSpecifications") public Response actionResetComputerDetailsSpecifications( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entityId") final String entityId, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - final String argument) { + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("entityId") final String entityId, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, + final String argument) { final Map.Entry utils = getUtilities(accept, format); @@ -864,8 +877,8 @@ public abstract class AbstractServices { final FSManager fsManager = FSManager.instance(version); fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container), - fsManager.getAbsolutePath(Commons.getEntityBasePath("ComputerDetail", entityId) + Constants.get(version, - ConstantKey.ENTITY), Accept.ATOM)); + fsManager.getAbsolutePath(Commons.getEntityBasePath("ComputerDetail", entityId) + Constants.get(version, + ConstantKey.ENTITY), Accept.ATOM)); return utils.getValue().createResponse(null, null, null, utils.getKey(), Response.Status.NO_CONTENT); } catch (Exception e) { @@ -875,7 +888,7 @@ public abstract class AbstractServices { /** * Retrieve entities from the given entity set and the given type. - * + * * @param accept Accept header. * @param name entity set. * @param type entity type. @@ -884,9 +897,9 @@ public abstract class AbstractServices { @GET @Path("/{name}/{type:.*}") public Response getEntitySet( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("name") final String name, - @PathParam("type") final String type) { + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("name") final String name, + @PathParam("type") final String type) { try { final Accept acceptType = Accept.parse(accept, version); @@ -896,12 +909,12 @@ public abstract class AbstractServices { final String basePath = name + File.separatorChar; final StringBuilder path = new StringBuilder(name). - append(File.separatorChar).append(type). - append(File.separatorChar); + append(File.separatorChar).append(type). + append(File.separatorChar); path.append(metadata.getEntitySet(name).isSingleton() - ? Constants.get(version, ConstantKey.ENTITY) - : Constants.get(version, ConstantKey.FEED)); + ? Constants.get(version, ConstantKey.ENTITY) + : Constants.get(version, ConstantKey.FEED)); final InputStream feed = FSManager.instance(version).readFile(path.toString(), acceptType); return xml.createResponse(null, feed, Commons.getETag(basePath, version), acceptType); @@ -912,7 +925,7 @@ public abstract class AbstractServices { /** * Retrieve entity set or function execution sample. - * + * * @param accept Accept header. * @param name entity set or function name. * @param format format query option. @@ -925,16 +938,16 @@ public abstract class AbstractServices { @GET @Path("/{name}") public Response getEntitySet( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("name") final String name, - @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) { + @Context final UriInfo uriInfo, + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("name") final String name, + @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) { try { final Accept acceptType; @@ -962,19 +975,19 @@ public abstract class AbstractServices { if (StringUtils.isNotBlank(orderby)) { builder.append(Constants.get(version, ConstantKey.ORDERBY)).append(File.separatorChar). - append(orderby).append(File.separatorChar); + append(orderby).append(File.separatorChar); } if (StringUtils.isNotBlank(filter)) { builder.append(Constants.get(version, ConstantKey.FILTER)).append(File.separatorChar). - append(filter.replaceAll("/", ".")); + append(filter.replaceAll("/", ".")); } else if (StringUtils.isNotBlank(skiptoken)) { builder.append(Constants.get(version, ConstantKey.SKIP_TOKEN)).append(File.separatorChar). - append(skiptoken); + append(skiptoken); } else { builder.append(metadata.getEntitySet(name).isSingleton() - ? Constants.get(version, ConstantKey.ENTITY) - : Constants.get(version, ConstantKey.FEED)); + ? Constants.get(version, ConstantKey.ENTITY) + : Constants.get(version, ConstantKey.FEED)); } final InputStream feed = FSManager.instance(version).readFile(builder.toString(), Accept.ATOM); @@ -1012,10 +1025,10 @@ public abstract class AbstractServices { writer.close(); return xml.createResponse( - location, - new ByteArrayInputStream(content.toByteArray()), - Commons.getETag(basePath, version), - acceptType); + location, + new ByteArrayInputStream(content.toByteArray()), + Commons.getETag(basePath, version), + acceptType); } } catch (Exception e) { return xml.createFaultResponse(accept, e); @@ -1027,29 +1040,29 @@ public abstract class AbstractServices { @GET @Path("/Person({entityId})") public Response getPerson( - @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) { + @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 utils = getUtilities(accept, format); final Response internal = getEntityInternal(uriInfo.getRequestUri().toASCIIString(), - accept, "Person", entityId, format, null, null, false); + accept, "Person", entityId, format, null, null, false); if (internal.getStatus() == 200) { InputStream entity = (InputStream) internal.getEntity(); try { if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) { entity = utils.getValue().addOperation(entity, "Sack", "#DefaultContainer.Sack", - uriInfo.getAbsolutePath().toASCIIString() + uriInfo.getAbsolutePath().toASCIIString() + "/Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee/Sack"); } return utils.getValue().createResponse( - uriInfo.getRequestUri().toASCIIString(), - entity, - internal.getHeaderString("ETag"), - utils.getKey()); + uriInfo.getRequestUri().toASCIIString(), + entity, + internal.getHeaderString("ETag"), + utils.getKey()); } catch (Exception e) { LOG.error("Error retrieving entity", e); return xml.createFaultResponse(accept, e); @@ -1062,29 +1075,29 @@ public abstract class AbstractServices { @GET @Path("/Product({entityId})") 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) { + @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 utils = getUtilities(accept, format); final Response internal = getEntityInternal(uriInfo.getRequestUri().toASCIIString(), - accept, "Product", entityId, format, null, null, false); + accept, "Product", entityId, format, null, null, false); if (internal.getStatus() == 200) { InputStream entity = (InputStream) internal.getEntity(); try { if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) { entity = utils.getValue().addOperation(entity, - "ChangeProductDimensions", "#DefaultContainer.ChangeProductDimensions", - uriInfo.getAbsolutePath().toASCIIString() + "/ChangeProductDimensions"); + "ChangeProductDimensions", "#DefaultContainer.ChangeProductDimensions", + uriInfo.getAbsolutePath().toASCIIString() + "/ChangeProductDimensions"); } return utils.getValue().createResponse( - uriInfo.getRequestUri().toASCIIString(), - entity, - internal.getHeaderString("ETag"), - utils.getKey()); + uriInfo.getRequestUri().toASCIIString(), + entity, + internal.getHeaderString("ETag"), + utils.getKey()); } catch (Exception e) { LOG.error("Error retrieving entity", e); return xml.createFaultResponse(accept, e); @@ -1097,29 +1110,29 @@ public abstract class AbstractServices { @GET @Path("/ComputerDetail({entityId})") public Response getComputerDetail( - @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) { + @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 utils = getUtilities(accept, format); final Response internal = getEntityInternal(uriInfo.getRequestUri().toASCIIString(), - accept, "ComputerDetail", entityId, format, null, null, false); + accept, "ComputerDetail", entityId, format, null, null, false); if (internal.getStatus() == 200) { InputStream entity = (InputStream) internal.getEntity(); try { if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) { entity = utils.getValue().addOperation(entity, - "ResetComputerDetailsSpecifications", "#DefaultContainer.ResetComputerDetailsSpecifications", - uriInfo.getAbsolutePath().toASCIIString() + "/ResetComputerDetailsSpecifications"); + "ResetComputerDetailsSpecifications", "#DefaultContainer.ResetComputerDetailsSpecifications", + uriInfo.getAbsolutePath().toASCIIString() + "/ResetComputerDetailsSpecifications"); } return utils.getValue().createResponse( - uriInfo.getRequestUri().toASCIIString(), - entity, - internal.getHeaderString("ETag"), - utils.getKey()); + uriInfo.getRequestUri().toASCIIString(), + entity, + internal.getHeaderString("ETag"), + utils.getKey()); } catch (Exception e) { LOG.error("Error retrieving entity", e); return xml.createFaultResponse(accept, e); @@ -1131,7 +1144,7 @@ public abstract class AbstractServices { /** * Retrieve entity sample. - * + * * @param accept Accept header. * @param entitySetName Entity set name. * @param entityId entity id. @@ -1143,27 +1156,27 @@ public abstract class AbstractServices { @GET @Path("/{entitySetName}({entityId})") 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) { + @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 getEntityInternal( - uriInfo.getRequestUri().toASCIIString(), accept, entitySetName, entityId, format, expand, select, false); + uriInfo.getRequestUri().toASCIIString(), accept, entitySetName, entityId, format, expand, select, false); } protected Response getEntityInternal( - final String location, - final String accept, - final String entitySetName, - final String entityId, - final String format, - String expand, - final String select, - final boolean keyAsSegment) { + final String location, + final String accept, + final String entitySetName, + final String entityId, + final String format, + String expand, + final String select, + final boolean keyAsSegment) { try { final Map.Entry utils = getUtilities(accept, format); @@ -1173,15 +1186,15 @@ public abstract class AbstractServices { } final Map.Entry entityInfo = - utils.getValue().readEntity(entitySetName, entityId, Accept.ATOM); + utils.getValue().readEntity(entitySetName, entityId, Accept.ATOM); final InputStream entity = entityInfo.getValue(); ResWrap container = atomDeserializer.toEntity(entity); if (container.getContextURL() == null) { container = new ResWrap(URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) - + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)), - container.getMetadataETag(), container.getPayload()); + + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)), + container.getMetadataETag(), container.getPayload()); } final Entity entry = container.getPayload(); @@ -1234,12 +1247,12 @@ public abstract class AbstractServices { if (link.getType().equals(Constants.get(version, ConstantKey.ATOM_LINK_ENTRY))) { // inline entry final Entity inline = atomDeserializer.toEntity( - xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload(); + xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload(); rep.setInlineEntity(inline); } else if (link.getType().equals(Constants.get(version, ConstantKey.ATOM_LINK_FEED))) { // inline feed final EntitySet inline = atomDeserializer.toEntitySet( - xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload(); + xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload(); rep.setInlineEntitySet(inline); } replace.put(link, rep); @@ -1253,10 +1266,10 @@ public abstract class AbstractServices { } return xml.createResponse( - location, - xml.writeEntity(utils.getKey(), container), - Commons.getETag(entityInfo.getKey(), version), - utils.getKey()); + location, + xml.writeEntity(utils.getKey(), container), + Commons.getETag(entityInfo.getKey(), version), + utils.getKey()); } catch (Exception e) { LOG.error("Error retrieving entity", e); return xml.createFaultResponse(accept, e); @@ -1266,10 +1279,10 @@ public abstract class AbstractServices { @GET @Path("/{entitySetName}({entityId})/$value") public Response getMediaEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId) { + @Context final UriInfo uriInfo, + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId) { try { if (!accept.contains("*/*") && !accept.contains("application/octet-stream")) { @@ -1279,10 +1292,10 @@ public abstract class AbstractServices { final AbstractUtilities utils = getUtilities(null); final Map.Entry entityInfo = utils.readMediaEntity(entitySetName, entityId); return utils.createResponse( - uriInfo.getRequestUri().toASCIIString(), - entityInfo.getValue(), - Commons.getETag(entityInfo.getKey(), version), - null); + uriInfo.getRequestUri().toASCIIString(), + entityInfo.getValue(), + Commons.getETag(entityInfo.getKey(), version), + null); } catch (Exception e) { LOG.error("Error retrieving entity", e); @@ -1293,8 +1306,8 @@ public abstract class AbstractServices { @DELETE @Path("/{entitySetName}({entityId})") public Response removeEntity( - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId) { + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId) { try { final String basePath = entitySetName + File.separatorChar + Commons.getEntityKey(entityId); @@ -1308,16 +1321,16 @@ public abstract class AbstractServices { } private Response replaceProperty( - final String location, - final String accept, - final String contentType, - final String prefer, - final String entitySetName, - final String entityId, - final String path, - final String format, - final String changes, - final boolean justValue) { + final String location, + final String accept, + final String contentType, + final String prefer, + final String entitySetName, + final String entityId, + final String path, + final String format, + final String changes, + final boolean justValue) { // if the given path is not about any link then search for property LOG.info("Retrieve property {}", path); @@ -1327,7 +1340,7 @@ public abstract class AbstractServices { final String basePath = Commons.getEntityBasePath(entitySetName, entityId); final ResWrap container = xml.readContainerEntity(Accept.ATOM, - fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM)); + fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM)); final Entity entry = container.getPayload(); @@ -1354,14 +1367,14 @@ public abstract class AbstractServices { toBeReplaced.setValue(ValueType.PRIMITIVE, changes); } else { final Property pchanges = xml.readProperty( - Accept.parse(contentType, version), - IOUtils.toInputStream(changes, Constants.ENCODING)); + Accept.parse(contentType, version), + IOUtils.toInputStream(changes, Constants.ENCODING)); toBeReplaced.setValue(pchanges.getValueType(), pchanges.getValue()); } fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container), - fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM)); + fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM)); final Response response; if ("return-content".equalsIgnoreCase(prefer)) { @@ -1378,7 +1391,7 @@ public abstract class AbstractServices { } if (StringUtils.isNotBlank(prefer)) { - response.getHeaders().put("Preference-Applied", Collections. singletonList(prefer)); + response.getHeaders().put("Preference-Applied", Collections.singletonList(prefer)); } return response; @@ -1388,12 +1401,12 @@ public abstract class AbstractServices { } private Response deletePropertyValue( - final String accept, - final String prefer, - final String entitySetName, - final String entityId, - final String path, - final String format) { + final String accept, + final String prefer, + final String entitySetName, + final String entityId, + final String path, + final String format) { try { Accept acceptType = null; if (StringUtils.isNotBlank(format)) { @@ -1408,10 +1421,10 @@ public abstract class AbstractServices { final AbstractUtilities utils = getUtilities(acceptType); final InputStream changed = utils.deleteProperty( - entitySetName, - entityId, - Arrays.asList(path.split("/")), - acceptType); + entitySetName, + entityId, + Arrays.asList(path.split("/")), + acceptType); final Response response; if ("return-content".equalsIgnoreCase(prefer)) { @@ -1422,7 +1435,7 @@ public abstract class AbstractServices { } if (StringUtils.isNotBlank(prefer)) { - response.getHeaders().put("Preference-Applied", Collections. singletonList(prefer)); + response.getHeaders().put("Preference-Applied", Collections.singletonList(prefer)); } return response; @@ -1434,7 +1447,7 @@ public abstract class AbstractServices { /** * Replace property value. - * + * * @param accept * @param entitySetName * @param entityId @@ -1446,23 +1459,23 @@ public abstract class AbstractServices { @PUT @Path("/{entitySetName}({entityId})/{path:.*}/$value") public Response replacePropertyValue( - @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, - @PathParam("path") final String path, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - final String changes) { + @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, + @PathParam("path") final String path, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, + final String changes) { return replaceProperty(uriInfo.getRequestUri().toASCIIString(), - accept, contentType, prefer, entitySetName, entityId, path, format, changes, true); + accept, contentType, prefer, entitySetName, entityId, path, format, changes, true); } /** * Replace property. - * + * * @param accept * @param entitySetName * @param entityId @@ -1474,23 +1487,23 @@ public abstract class AbstractServices { @MERGE @Path("/{entitySetName}({entityId})/{path:.*}") public Response mergeProperty( - @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, - @PathParam("path") final String path, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - final String changes) { + @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, + @PathParam("path") final String path, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, + final String changes) { return replaceProperty(uriInfo.getRequestUri().toASCIIString(), - accept, contentType, prefer, entitySetName, entityId, path, format, changes, false); + accept, contentType, prefer, entitySetName, entityId, path, format, changes, false); } /** * Replace property. - * + * * @param accept * @param entitySetName * @param entityId @@ -1502,37 +1515,37 @@ public abstract class AbstractServices { @PATCH @Path("/{entitySetName}({entityId})/{path:.*}") public Response patchProperty( - @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, - @PathParam("path") final String path, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - final String changes) { + @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, + @PathParam("path") final String path, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, + final String changes) { return replaceProperty(uriInfo.getRequestUri().toASCIIString(), - accept, contentType, prefer, entitySetName, entityId, path, format, changes, false); + accept, contentType, prefer, entitySetName, entityId, path, format, changes, false); } @PUT - @Produces({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM }) + @Produces({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) + @Consumes({MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM}) @Path("/{entitySetName}({entityId})/$value") public Response replaceMediaEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - final String value) { + @Context final UriInfo uriInfo, + @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, + final String value) { try { final AbstractUtilities utils = getUtilities(null); final InputStream res = utils.putMediaInMemory( - entitySetName, entityId, IOUtils.toInputStream(value, Constants.ENCODING)); + entitySetName, entityId, IOUtils.toInputStream(value, Constants.ENCODING)); final String location = uriInfo.getRequestUri().toASCIIString().replace("/$value", ""); @@ -1545,7 +1558,7 @@ public abstract class AbstractServices { } if (StringUtils.isNotBlank(prefer)) { - response.getHeaders().put("Preference-Applied", Collections. singletonList(prefer)); + response.getHeaders().put("Preference-Applied", Collections.singletonList(prefer)); } return response; @@ -1558,7 +1571,7 @@ public abstract class AbstractServices { /** * Replace property. - * + * * @param accept * @param entitySetName * @param entityId @@ -1570,36 +1583,36 @@ public abstract class AbstractServices { @PUT @Path("/{entitySetName}({entityId})/{path:.*}") public Response replaceProperty( - @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, - @PathParam("path") final String path, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - final String changes) { + @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, + @PathParam("path") final String path, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, + final String changes) { if (xml.isMediaContent(entitySetName + "/" + path)) { return replaceMediaProperty(prefer, entitySetName, entityId, path, changes); } else { return replaceProperty(uriInfo.getRequestUri().toASCIIString(), - accept, contentType, prefer, entitySetName, entityId, path, format, changes, false); + accept, contentType, prefer, entitySetName, entityId, path, format, changes, false); } } private Response replaceMediaProperty( - final String prefer, - final String entitySetName, - final String entityId, - final String path, - final String value) { + final String prefer, + final String entitySetName, + final String entityId, + final String path, + final String value) { try { final AbstractUtilities utils = getUtilities(null); InputStream res = utils.putMediaInMemory( - entitySetName, entityId, path, IOUtils.toInputStream(value, Constants.ENCODING)); + entitySetName, entityId, path, IOUtils.toInputStream(value, Constants.ENCODING)); final Response response; if ("return-content".equalsIgnoreCase(prefer)) { @@ -1610,7 +1623,7 @@ public abstract class AbstractServices { } if (StringUtils.isNotBlank(prefer)) { - response.getHeaders().put("Preference-Applied", Collections. singletonList(prefer)); + response.getHeaders().put("Preference-Applied", Collections.singletonList(prefer)); } return response; @@ -1622,7 +1635,7 @@ public abstract class AbstractServices { /** * Nullify property value. - * + * * @param accept * @param entitySetName * @param entityId @@ -1633,18 +1646,18 @@ public abstract class AbstractServices { @DELETE @Path("/{entitySetName}({entityId})/{path:.*}/$value") public Response deleteProperty( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @PathParam("path") final String path, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId, + @PathParam("path") final String path, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { return deletePropertyValue(accept, prefer, entitySetName, entityId, path, format); } /** * Retrieve property sample. - * + * * @param accept Accept header. * @param entitySetName Entity set name. * @param entityId entity id. @@ -1655,11 +1668,11 @@ public abstract class AbstractServices { @GET @Path("/{entitySetName}({entityId})/{path:.*}/$value") public Response getPathValue( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @PathParam("path") final String path, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId, + @PathParam("path") final String path, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { try { Accept acceptType = null; @@ -1677,7 +1690,7 @@ public abstract class AbstractServices { /** * Retrieve property sample. - * + * * @param accept Accept header. * @param entitySetName Entity set name. * @param entityId entity id. @@ -1688,11 +1701,11 @@ public abstract class AbstractServices { @GET @Path("/{entitySetName}({entityId})/{path:.*}") public Response getPath( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @PathParam("path") final String path, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId, + @PathParam("path") final String path, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { // default utilities final AbstractUtilities utils = xml; @@ -1716,9 +1729,9 @@ public abstract class AbstractServices { final ByteArrayOutputStream content = new ByteArrayOutputStream(); final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING); - final ResWrap container = linkInfo.isFeed() ? - atomDeserializer.toEntitySet(stream) : - atomDeserializer.toEntity(stream); + final ResWrap container = linkInfo.isFeed() + ? atomDeserializer.toEntitySet(stream) + : atomDeserializer.toEntity(stream); if (acceptType == Accept.ATOM) { atomSerializer.write(writer, container); } else { @@ -1730,10 +1743,10 @@ public abstract class AbstractServices { final String basePath = Commons.getEntityBasePath(entitySetName, entityId); return xml.createResponse( - null, - new ByteArrayInputStream(content.toByteArray()), - Commons.getETag(basePath, version), - acceptType); + null, + new ByteArrayInputStream(content.toByteArray()), + Commons.getETag(basePath, version), + acceptType); } catch (NotFoundException e) { // if the given path is not about any link then search for property @@ -1746,9 +1759,9 @@ public abstract class AbstractServices { } private Response navigateStreamedEntity( - final String entitySetName, - final String entityId, - final String path) throws Exception { + final String entitySetName, + final String entityId, + final String path) throws Exception { final AbstractUtilities utils = getUtilities(null); final Map.Entry entityInfo = utils.readMediaEntity(entitySetName, entityId, path); @@ -1756,11 +1769,11 @@ public abstract class AbstractServices { } private Response navigateProperty( - final Accept acceptType, - final String entitySetName, - final String entityId, - final String path, - final boolean searchForValue) throws Exception { + final Accept acceptType, + final String entitySetName, + final String entityId, + final String path, + final boolean searchForValue) throws Exception { if ((searchForValue && acceptType != null && acceptType != Accept.TEXT) || acceptType == Accept.ATOM) { throw new UnsupportedMediaTypeException("Unsupported media type " + acceptType); @@ -1792,29 +1805,29 @@ public abstract class AbstractServices { } final ResWrap container = new ResWrap( - URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) - + (version.compareTo(ODataServiceVersion.V40) >= 0 ? - entitySetName + "(" + entityId + ")/" + path : property.getType())), - entryContainer.getMetadataETag(), - property); + URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + + (version.compareTo(ODataServiceVersion.V40) >= 0 + ? entitySetName + "(" + entityId + ")/" + path : property.getType())), + entryContainer.getMetadataETag(), + property); return xml.createResponse(null, - searchForValue ? - IOUtils.toInputStream( - container.getPayload().isNull() ? StringUtils.EMPTY : stringValue(container.getPayload()), - Constants.ENCODING) : - utils.writeProperty(acceptType, container), - Commons.getETag(Commons.getEntityBasePath(entitySetName, entityId), version), - acceptType); + searchForValue + ? IOUtils.toInputStream( + container.getPayload().isNull() ? StringUtils.EMPTY : stringValue(container.getPayload()), + Constants.ENCODING) + : utils.writeProperty(acceptType, container), + Commons.getETag(Commons.getEntityBasePath(entitySetName, entityId), version), + acceptType); } private String stringValue(final Property property) { EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOfFQN(version, property.getType()); try { return EdmPrimitiveTypeFactory.getInstance(kind) - .valueToString(property.asPrimitive(), null, null, - org.apache.olingo.commons.api.Constants.DEFAULT_PRECISION, - org.apache.olingo.commons.api.Constants.DEFAULT_SCALE, null); + .valueToString(property.asPrimitive(), null, null, + org.apache.olingo.commons.api.Constants.DEFAULT_PRECISION, + org.apache.olingo.commons.api.Constants.DEFAULT_SCALE, null); } catch (final EdmPrimitiveTypeException e) { return property.asPrimitive().toString(); } @@ -1822,7 +1835,7 @@ public abstract class AbstractServices { /** * Count sample. - * + * * @param accept Accept header. * @param entitySetName entity set name. * @return count. @@ -1830,8 +1843,8 @@ public abstract class AbstractServices { @GET @Path("/{entitySetName}/$count") public Response count( - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entitySetName") final String entitySetName) { + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("entitySetName") final String entitySetName) { try { final Accept acceptType = Accept.parse(accept, version, Accept.TEXT); @@ -1892,8 +1905,8 @@ public abstract class AbstractServices { alink.getAnnotations().addAll(property.getAnnotations()); alink.setType(navProperties.get(property.getName()).isEntitySet() - ? Constants.get(version, ConstantKey.ATOM_LINK_FEED) - : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY)); + ? Constants.get(version, ConstantKey.ATOM_LINK_FEED) + : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY)); alink.setRel(Constants.get(version, ConstantKey.ATOM_LINK_REL) + property.getName()); @@ -1910,8 +1923,8 @@ public abstract class AbstractServices { for (Object value : property.asCollection()) { Entity inlineEntity = new EntityImpl(); inlineEntity.setType(navProperties.get(property.getName()).getType()); - for (Property prop : (value instanceof LinkedComplexValue ? - ((LinkedComplexValue) value).getValue() : ((Valuable) value).asComplex())) { + for (Property prop : (value instanceof LinkedComplexValue + ? ((LinkedComplexValue) value).getValue() : ((Valuable) value).asComplex())) { inlineEntity.getProperties().add(prop); } inline.getEntities().add(inlineEntity); @@ -1949,8 +1962,8 @@ public abstract class AbstractServices { final LinkImpl link = new LinkImpl(); link.setTitle(property.getKey()); link.setType(property.getValue().isEntitySet() - ? Constants.get(version, ConstantKey.ATOM_LINK_FEED) - : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY)); + ? Constants.get(version, ConstantKey.ATOM_LINK_FEED) + : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY)); link.setRel(Constants.get(version, ConstantKey.ATOM_LINK_REL) + property.getKey()); link.setHref(entitySetName + "(" + entityKey + ")/" + property.getKey()); entry.getNavigationLinks().add(link); diff --git a/fit/src/main/java/org/apache/olingo/fit/UnsupportedMediaTypeException.java b/fit/src/main/java/org/apache/olingo/fit/UnsupportedMediaTypeException.java index 7b76cd8ab..30a9bcad9 100644 --- a/fit/src/main/java/org/apache/olingo/fit/UnsupportedMediaTypeException.java +++ b/fit/src/main/java/org/apache/olingo/fit/UnsupportedMediaTypeException.java @@ -23,15 +23,15 @@ public class UnsupportedMediaTypeException extends RuntimeException { private static final long serialVersionUID = 9076398602010056960L; /** - * Creates a new instance of - * UnsupportedMediaTypeException without detail message. + * Creates a new instance of UnsupportedMediaTypeException without detail message. */ - public UnsupportedMediaTypeException() {} + public UnsupportedMediaTypeException() { + super(); + } /** - * Constructs an instance of - * UnsupportedMediaTypeException with the specified detail message. - * + * Constructs an instance of UnsupportedMediaTypeException with the specified detail message. + * * @param msg the detail message. */ public UnsupportedMediaTypeException(final String msg) { diff --git a/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java b/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java index 9dd31305b..0132a00b0 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java +++ b/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java @@ -20,6 +20,7 @@ package org.apache.olingo.fit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStream; import java.util.Map; @@ -52,16 +53,16 @@ import org.springframework.stereotype.Service; @Path("/V30/ActionOverloading.svc") public class V3ActionOverloading extends V3Services { - public V3ActionOverloading() throws Exception { + 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)); + "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"); + replaceAll("Static\\.svc", "ActionOverloading.svc"); final Response.ResponseBuilder builder = Response.status(response.getStatus()); for (String headerName : response.getHeaders().keySet()) { @@ -90,15 +91,15 @@ public class V3ActionOverloading extends V3Services { @Override public Response getMetadata() { return super.getMetadata("actionOverloading" - + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA))); + + 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) { + @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)) { @@ -112,7 +113,7 @@ public class V3ActionOverloading extends V3Services { try { final InputStream result = FSManager.instance(ODataServiceVersion.V30). - readFile("actionOverloadingRetrieveProduct", acceptType); + readFile("actionOverloadingRetrieveProduct", acceptType); return replaceServiceName(xml.createResponse(result, null, acceptType)); } catch (Exception e) { return replaceServiceName(xml.createFaultResponse(accept, e)); @@ -123,10 +124,10 @@ public class V3ActionOverloading extends V3Services { @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) { + @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 utils = super.getUtilities(accept, format); @@ -140,12 +141,12 @@ public class V3ActionOverloading extends V3Services { try { if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) { entity = utils.getValue().addOperation(entity, "RetrieveProduct", "#DefaultContainer.RetrieveProduct", - uriInfo.getAbsolutePath().toASCIIString() + uriInfo.getAbsolutePath().toASCIIString() + "/RetrieveProduct"); } return replaceServiceName(utils.getValue().createResponse( - entity, Commons.getETag(entityInfo.getKey(), ODataServiceVersion.V30), utils.getKey())); + entity, Commons.getETag(entityInfo.getKey(), ODataServiceVersion.V30), utils.getKey())); } catch (Exception e) { LOG.error("Error retrieving entity", e); return replaceServiceName(xml.createFaultResponse(accept, e)); @@ -155,9 +156,9 @@ public class V3ActionOverloading extends V3Services { @POST @Path("/Product({entityId})/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) { + @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); } @@ -165,11 +166,11 @@ public class V3ActionOverloading extends V3Services { @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) { + @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 utils = super.getUtilities(accept, format); @@ -178,18 +179,18 @@ public class V3ActionOverloading extends V3Services { } final Map.Entry entityInfo = utils.getValue(). - readEntity("OrderLine", orderId + " " + productId, utils.getKey()); + 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() + uriInfo.getAbsolutePath().toASCIIString() + "/RetrieveProduct"); } return replaceServiceName(utils.getValue().createResponse( - entity, Commons.getETag(entityInfo.getKey(), ODataServiceVersion.V30), utils.getKey())); + entity, Commons.getETag(entityInfo.getKey(), ODataServiceVersion.V30), utils.getKey())); } catch (Exception e) { LOG.error("Error retrieving entity", e); return replaceServiceName(xml.createFaultResponse(accept, e)); @@ -199,9 +200,9 @@ public class V3ActionOverloading extends V3Services { @POST @Path("/OrderLine(OrderId={orderId},ProductId={productId})/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) { + @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); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java b/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java index fb6a4468b..01d908637 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java +++ b/fit/src/main/java/org/apache/olingo/fit/V3KeyAsSegment.java @@ -20,6 +20,7 @@ package org.apache.olingo.fit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStream; import javax.ws.rs.Consumes; @@ -51,14 +52,14 @@ public class V3KeyAsSegment { private final V3Services services; - public V3KeyAsSegment() throws Exception { + public V3KeyAsSegment() throws IOException { services = new V3Services(); } private Response replaceServiceName(final Response response) { try { final String content = IOUtils.toString((InputStream) response.getEntity(), Constants.ENCODING). - replaceAll("Static\\.svc", "KeyAsSegment.svc"); + replaceAll("Static\\.svc", "KeyAsSegment.svc"); final Response.ResponseBuilder builder = Response.status(response.getStatus()); for (String headerName : response.getHeaders().keySet()) { @@ -84,91 +85,91 @@ public class V3KeyAsSegment { @GET @Path("/{entitySetName}/{entityId}") 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) { + @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(services.getEntityInternal(uriInfo.getRequestUri().toASCIIString(), - accept, entitySetName, entityId, format, expand, select, true)); + accept, entitySetName, entityId, format, expand, select, true)); } @DELETE @Path("/{entitySetName}/{entityId}") public Response removeEntity( - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId) { + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId) { return replaceServiceName(services.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 }) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) + @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) 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) { + @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(services.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, - entityId, changes)); + 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 }) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) + @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) 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) { + @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(services.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, - entityId, changes)); + 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 }) + @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) { + @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(services.replaceEntity(uriInfo, accept, contentType, prefer, entitySetName, entityId, - entity)); + 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 }) + @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 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) { + @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(services.postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, entity)); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java b/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java index 55abc3b9b..9452739b1 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java +++ b/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java @@ -20,6 +20,7 @@ package org.apache.olingo.fit; 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; @@ -55,16 +56,16 @@ public class V3OpenType extends V3Services { private static final Pattern GUID = Pattern.compile("guid'(.*)'"); - public V3OpenType() throws Exception { + 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)); + 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"); + replaceAll("Static\\.svc", "OpenType.svc"); final Response.ResponseBuilder builder = Response.status(response.getStatus()); for (String headerName : response.getHeaders().keySet()) { @@ -89,7 +90,7 @@ public class V3OpenType extends V3Services { /** * Provide sample large metadata. - * + * * @return metadata. */ @GET @@ -98,39 +99,39 @@ public class V3OpenType extends V3Services { @Override public Response getMetadata() { return super.getMetadata("openType" + StringUtils.capitalize( - Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA))); + 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) { + @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, false)); + uriInfo.getRequestUri().toASCIIString(), accept, entitySetName, + matcher.matches() ? matcher.group(1) : entityId, format, expand, select, false)); } @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 }) + @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) { + @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)); } @@ -139,11 +140,11 @@ public class V3OpenType extends V3Services { @Path("/{entitySetName}({entityId})") @Override public Response removeEntity( - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId) { + @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)); + matcher.matches() ? matcher.group(1) : entityId)); } } diff --git a/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java b/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java index 2368b1397..623130378 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java +++ b/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java @@ -18,6 +18,7 @@ */ package org.apache.olingo.fit; +import java.io.IOException; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @@ -32,15 +33,10 @@ import org.springframework.stereotype.Service; @Path("/V30/PrimitiveKeys.svc") public class V3PrimitiveKeys extends V3Services { - public V3PrimitiveKeys() throws Exception { + public V3PrimitiveKeys() throws IOException { super(); } - /** - * Provide sample large metadata. - * - * @return metadata. - */ @GET @Path("/$metadata") @Produces(MediaType.APPLICATION_XML) @@ -48,7 +44,7 @@ public class V3PrimitiveKeys extends V3Services { public Response getMetadata() { try { return xml.createResponse( - null, FSManager.instance(version).readRes("primitiveKeysMetadata", Accept.XML), null, Accept.XML); + null, FSManager.instance(version).readRes("primitiveKeysMetadata", Accept.XML), null, Accept.XML); } catch (Exception e) { return xml.createFaultResponse(Accept.XML.toString(version), e); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V3Services.java b/fit/src/main/java/org/apache/olingo/fit/V3Services.java index be2a297aa..975b3d3cd 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V3Services.java +++ b/fit/src/main/java/org/apache/olingo/fit/V3Services.java @@ -62,7 +62,7 @@ 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.apache.olingo.fit.utils.XHTTPMethodInterceptor; +import org.apache.olingo.fit.rest.XHTTPMethodInterceptor; import org.springframework.stereotype.Service; @Service @@ -70,19 +70,19 @@ import org.springframework.stereotype.Service; @InInterceptors(classes = XHTTPMethodInterceptor.class) public class V3Services extends AbstractServices { - public V3Services() throws Exception { + public V3Services() throws IOException { super(ODataServiceVersion.V30, Commons.getMetadata(ODataServiceVersion.V30)); } - protected V3Services(final Metadata metadata) throws Exception { + 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) { + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { final Accept acceptType; if (StringUtils.isNotBlank(format)) { @@ -95,9 +95,9 @@ public class V3Services extends AbstractServices { 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(); + 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"); @@ -109,7 +109,7 @@ public class V3Services extends AbstractServices { /** * Provide sample large metadata. - * + * * @return metadata. */ @GET @@ -128,8 +128,9 @@ public class V3Services extends AbstractServices { @Override public InputStream exploreMultipart( - final List attachments, final String boundary, final boolean contineOnError) - throws IOException { + final List attachments, final String boundary, final boolean contineOnError) + throws IOException { + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); Response res = null; @@ -197,7 +198,6 @@ public class V3Services extends AbstractServices { addSingleBatchResponse(res, bos); } - } catch (Exception e) { if (res == null || res.getStatus() < 400) { addErrorBatchResponse(e, bos); @@ -215,15 +215,15 @@ public class V3Services extends AbstractServices { @GET @Path("/Car/{type:.*}") 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) { + @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); } @@ -231,27 +231,27 @@ public class V3Services extends AbstractServices { @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) { + @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, false); + "Login", StringUtils.remove(entityId, "'"), format, expand, select, false); } @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 }) + @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) { + @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()); @@ -263,14 +263,14 @@ public class V3Services extends AbstractServices { @DELETE @Path("/Login({entityId})") public Response removeLogin( - @PathParam("entityId") final String entityId) { + @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. @@ -281,11 +281,11 @@ public class V3Services extends AbstractServices { @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) { + @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)) { @@ -301,9 +301,9 @@ public class V3Services extends AbstractServices { final LinkInfo links = xml.readLinks(entitySetName, entityId, linkName, acceptType); return xml.createResponse( - links.getLinks(), - links.getEtag(), - acceptType); + links.getLinks(), + links.getEtag(), + acceptType); } catch (Exception e) { return xml.createFaultResponse(accept, e); } @@ -312,13 +312,13 @@ public class V3Services extends AbstractServices { @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) { + @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)) { @@ -348,11 +348,11 @@ public class V3Services extends AbstractServices { } utils.putLinksInMemory( - Commons.getEntityBasePath(entitySetName, entityId), - entitySetName, - entityId, - linkName, - links); + Commons.getEntityBasePath(entitySetName, entityId), + entitySetName, + entityId, + linkName, + links); return xml.createResponse(null, null, null, Response.Status.NO_CONTENT); } catch (Exception e) { @@ -363,39 +363,39 @@ public class V3Services extends AbstractServices { @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) { + @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) { + @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) { + @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)) { @@ -425,10 +425,10 @@ public class V3Services extends AbstractServices { } utils.putLinksInMemory( - Commons.getEntityBasePath(entitySetName, entityId), - entitySetName, - linkName, - links); + Commons.getEntityBasePath(entitySetName, entityId), + entitySetName, + linkName, + links); return xml.createResponse(null, null, null, Response.Status.NO_CONTENT); } catch (Exception e) { @@ -439,13 +439,13 @@ public class V3Services extends AbstractServices { @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) { + @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)) { @@ -461,19 +461,19 @@ public class V3Services extends AbstractServices { final AbstractUtilities utils = getUtilities(acceptType); final Map.Entry> currents = json.extractLinkURIs(utils.readLinks( - entitySetName, entityId, linkName, Accept.JSON_FULLMETA).getLinks()); + entitySetName, entityId, linkName, Accept.JSON_FULLMETA).getLinks()); final Map.Entry> toBeRemoved = json.extractLinkURIs(utils.readLinks( - entitySetName, entityId, linkName + "(" + linkId + ")", Accept.JSON_FULLMETA).getLinks()); + entitySetName, entityId, linkName + "(" + linkId + ")", Accept.JSON_FULLMETA).getLinks()); final List remains = currents.getValue(); remains.removeAll(toBeRemoved.getValue()); utils.putLinksInMemory( - Commons.getEntityBasePath(entitySetName, entityId), - entitySetName, - linkName, - remains); + Commons.getEntityBasePath(entitySetName, entityId), + entitySetName, + linkName, + remains); return xml.createResponse(null, null, null, Response.Status.NO_CONTENT); } catch (Exception e) { diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Demo.java b/fit/src/main/java/org/apache/olingo/fit/V4Demo.java index 1c6f5010f..18e7deb6c 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4Demo.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4Demo.java @@ -20,6 +20,7 @@ package org.apache.olingo.fit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStream; import javax.ws.rs.Consumes; @@ -52,16 +53,16 @@ import org.springframework.stereotype.Service; @Path("/V40/Demo.svc") public class V4Demo extends V4Services { - public V4Demo() throws Exception { + public V4Demo() throws IOException { super(new Metadata(FSManager.instance(ODataServiceVersion.V40). - readRes("demo" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA)), - Accept.XML), ODataServiceVersion.V40)); + readRes("demo" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA)), + Accept.XML), ODataServiceVersion.V40)); } private Response replaceServiceName(final Response response) { try { final String content = IOUtils.toString((InputStream) response.getEntity(), Constants.ENCODING). - replaceAll("Static\\.svc", "Demo.svc"); + replaceAll("Static\\.svc", "Demo.svc"); final Response.ResponseBuilder builder = Response.status(response.getStatus()); for (String headerName : response.getHeaders().keySet()) { @@ -90,84 +91,84 @@ public class V4Demo extends V4Services { @Override public Response getMetadata() { return super.getMetadata( - "demo" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA))); + "demo" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, 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) { + @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, false)); + accept, entitySetName, entityId, format, expand, select, false)); } @GET @Path("/{entitySetName}({entityId})/$value") @Override public Response getMediaEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId) { + @Context final UriInfo uriInfo, + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId) { return super.getMediaEntity(uriInfo, accept, entitySetName, entityId); } @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 }) + @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) { + @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)); } @PATCH @Path("/{entitySetName}({entityId})") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) + @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) { + @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)); + changes)); } @PUT - @Produces({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM }) + @Produces({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON}) + @Consumes({MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM}) @Path("/{entitySetName}({entityId})/$value") @Override public Response replaceMediaEntity( - @Context final UriInfo uriInfo, - @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId, - @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, - final String value) { + @Context final UriInfo uriInfo, + @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, + final String value) { return super.replaceMediaEntity(uriInfo, prefer, entitySetName, entityId, format, value); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V4KeyAsSegment.java b/fit/src/main/java/org/apache/olingo/fit/V4KeyAsSegment.java index 1474c1f24..858bc0167 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4KeyAsSegment.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4KeyAsSegment.java @@ -20,6 +20,7 @@ package org.apache.olingo.fit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStream; import javax.ws.rs.Consumes; @@ -49,14 +50,14 @@ public class V4KeyAsSegment extends V4Services { @Context private UriInfo uriInfo; - public V4KeyAsSegment() throws Exception { + public V4KeyAsSegment() 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"); + replaceAll("Static\\.svc", "KeyAsSegment.svc"); final Response.ResponseBuilder builder = Response.status(response.getStatus()); for (String headerName : response.getHeaders().keySet()) { @@ -82,68 +83,69 @@ public class V4KeyAsSegment extends V4Services { @Override public Response getEntitySet(final String accept, final String name, final String type) { return replaceServiceName(super.getEntityInternal(uriInfo.getRequestUri().toASCIIString(), - accept, name, type, null, null, null, true)); + accept, name, type, null, null, null, true)); } @DELETE @Path("/{entitySetName}/{entityId}") @Override public Response removeEntity( - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId) { + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId) { return replaceServiceName(super.removeEntity(entitySetName, entityId)); } @PATCH @Path("/{entitySetName}/{entityId}") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) + @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) { + @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)); + 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 }) + @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) { + @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)); + 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 }) + @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) { + @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)); + return replaceServiceName( + super.postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, entity)); } } diff --git a/fit/src/main/java/org/apache/olingo/fit/V4NorthWind.java b/fit/src/main/java/org/apache/olingo/fit/V4NorthWind.java index 1fc5eaba7..2a922c5b8 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4NorthWind.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4NorthWind.java @@ -18,13 +18,14 @@ */ package org.apache.olingo.fit; +import java.io.IOException; import javax.ws.rs.Path; import javax.ws.rs.core.Response; import org.apache.cxf.interceptor.InInterceptors; import org.apache.olingo.fit.utils.ConstantKey; import org.apache.olingo.fit.utils.Constants; -import org.apache.olingo.fit.utils.XHTTPMethodInterceptor; +import org.apache.olingo.fit.rest.XHTTPMethodInterceptor; import org.springframework.stereotype.Service; @Service @@ -32,7 +33,7 @@ import org.springframework.stereotype.Service; @InInterceptors(classes = XHTTPMethodInterceptor.class) public class V4NorthWind extends V4Services { - public V4NorthWind() throws Exception { + public V4NorthWind() throws IOException { super(); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V4NorthWindExt.java b/fit/src/main/java/org/apache/olingo/fit/V4NorthWindExt.java index 7daddf8ea..92c9b8ebb 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4NorthWindExt.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4NorthWindExt.java @@ -18,22 +18,23 @@ */ package org.apache.olingo.fit; +import java.io.IOException; import javax.ws.rs.Path; import javax.ws.rs.core.Response; import org.apache.cxf.interceptor.InInterceptors; import org.apache.olingo.fit.utils.ConstantKey; import org.apache.olingo.fit.utils.Constants; -import org.apache.olingo.fit.utils.ResolvingReferencesInterceptor; -import org.apache.olingo.fit.utils.XHTTPMethodInterceptor; +import org.apache.olingo.fit.rest.ResolvingReferencesInterceptor; +import org.apache.olingo.fit.rest.XHTTPMethodInterceptor; import org.springframework.stereotype.Service; @Service @Path("/V40/NorthWindExt.svc") -@InInterceptors(classes = { XHTTPMethodInterceptor.class, ResolvingReferencesInterceptor.class }) +@InInterceptors(classes = {XHTTPMethodInterceptor.class, ResolvingReferencesInterceptor.class}) public class V4NorthWindExt extends V4Services { - public V4NorthWindExt() throws Exception { + public V4NorthWindExt() throws IOException { super(); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V4OAuth2.java b/fit/src/main/java/org/apache/olingo/fit/V4OAuth2.java new file mode 100644 index 000000000..b43b03471 --- /dev/null +++ b/fit/src/main/java/org/apache/olingo/fit/V4OAuth2.java @@ -0,0 +1,37 @@ +/* + * 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 java.io.IOException; + +import javax.ws.rs.Path; +import org.apache.cxf.interceptor.InInterceptors; +import org.apache.olingo.fit.rest.OAuth2InInterceptor; +import org.springframework.stereotype.Service; + +@Service +@Path("/V40/OAuth2.svc") +@InInterceptors(classes = {OAuth2InInterceptor.class}) +public class V4OAuth2 extends V4Services { + + public V4OAuth2() throws IOException { + super(); + } + +} diff --git a/fit/src/main/java/org/apache/olingo/fit/V4OpenType.java b/fit/src/main/java/org/apache/olingo/fit/V4OpenType.java index aac908ab7..b19916b96 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4OpenType.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4OpenType.java @@ -20,6 +20,7 @@ package org.apache.olingo.fit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStream; import javax.ws.rs.Consumes; @@ -51,16 +52,16 @@ import org.springframework.stereotype.Service; @Path("/V40/OpenType.svc") public class V4OpenType extends V4Services { - public V4OpenType() throws Exception { + public V4OpenType() throws IOException { super(new Metadata(FSManager.instance(ODataServiceVersion.V40). - readRes("openType" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA)), - Accept.XML), ODataServiceVersion.V40)); + readRes("openType" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA)), + Accept.XML), ODataServiceVersion.V40)); } private Response replaceServiceName(final Response response) { try { final String content = IOUtils.toString((InputStream) response.getEntity(), Constants.ENCODING). - replaceAll("Static\\.svc", "OpenType.svc"); + replaceAll("Static\\.svc", "OpenType.svc"); final Response.ResponseBuilder builder = Response.status(response.getStatus()); for (String headerName : response.getHeaders().keySet()) { @@ -85,7 +86,7 @@ public class V4OpenType extends V4Services { /** * Provide sample large metadata. - * + * * @return metadata. */ @GET @@ -94,37 +95,37 @@ public class V4OpenType extends V4Services { @Override public Response getMetadata() { return super.getMetadata("openType" + StringUtils.capitalize( - Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA))); + Constants.get(ODataServiceVersion.V40, 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) { + @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, false)); + uriInfo.getRequestUri().toASCIIString(), accept, entitySetName, entityId, format, expand, select, false)); } @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 }) + @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) { + @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)); } @@ -133,8 +134,8 @@ public class V4OpenType extends V4Services { @Path("/{entitySetName}({entityId})") @Override public Response removeEntity( - @PathParam("entitySetName") final String entitySetName, - @PathParam("entityId") final String entityId) { + @PathParam("entitySetName") final String entitySetName, + @PathParam("entityId") final String entityId) { return replaceServiceName(super.removeEntity(entitySetName, entityId)); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java index 978bf5abd..5e32230f7 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java @@ -81,8 +81,8 @@ 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.apache.olingo.fit.utils.ResolvingReferencesInterceptor; -import org.apache.olingo.fit.utils.XHTTPMethodInterceptor; +import org.apache.olingo.fit.rest.ResolvingReferencesInterceptor; +import org.apache.olingo.fit.rest.XHTTPMethodInterceptor; import org.springframework.stereotype.Service; @Service @@ -102,11 +102,11 @@ public class V4Services extends AbstractServices { private final Map providedAsync = new HashMap(); - public V4Services() throws Exception { + public V4Services() throws IOException { super(ODataServiceVersion.V40, Commons.getMetadata(ODataServiceVersion.V40)); } - protected V4Services(final Metadata metadata) throws Exception { + protected V4Services(final Metadata metadata) throws IOException { super(ODataServiceVersion.V40, metadata); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Vocabularies.java b/fit/src/main/java/org/apache/olingo/fit/V4Vocabularies.java index cf20fba59..0691b27d2 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4Vocabularies.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4Vocabularies.java @@ -18,6 +18,7 @@ */ package org.apache.olingo.fit; +import java.io.IOException; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -42,10 +43,10 @@ public class V4Vocabularies { private final XMLUtilities xml; - public V4Vocabularies() throws Exception { + public V4Vocabularies() throws IOException { metadata = new Metadata(FSManager.instance(ODataServiceVersion.V40).readRes( - "vocabularies-" + Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA), Accept.XML), - ODataServiceVersion.V40); + "vocabularies-" + Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA), Accept.XML), + ODataServiceVersion.V40); xml = new XMLUtilities(ODataServiceVersion.V40, metadata); } @@ -55,11 +56,11 @@ public class V4Vocabularies { public Response getMetadata() { try { return xml.createResponse( - null, - FSManager.instance(ODataServiceVersion.V40).readRes( - "vocabularies-" + Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA), Accept.XML), - null, - Accept.XML); + null, + FSManager.instance(ODataServiceVersion.V40).readRes( + "vocabularies-" + Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA), Accept.XML), + null, + Accept.XML); } catch (Exception e) { return xml.createFaultResponse(Accept.XML.toString(ODataServiceVersion.V40), e); } @@ -71,10 +72,10 @@ public class V4Vocabularies { public Response getVocabulary(@PathParam("vocabulary") final String vocabulary) { try { return xml.createResponse( - null, - FSManager.instance(ODataServiceVersion.V40).readFile(vocabulary, null), - null, - Accept.XML); + null, + FSManager.instance(ODataServiceVersion.V40).readFile(vocabulary, null), + null, + Accept.XML); } catch (Exception e) { return xml.createFaultResponse(Accept.XML.toString(ODataServiceVersion.V40), e); } diff --git a/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2InInterceptor.java b/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2InInterceptor.java new file mode 100644 index 000000000..bddc6421f --- /dev/null +++ b/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2InInterceptor.java @@ -0,0 +1,97 @@ +/* + * 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.rest; + +import java.net.URI; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import org.apache.commons.lang3.StringUtils; +import org.apache.cxf.interceptor.Fault; +import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.cxf.message.Message; +import org.apache.cxf.phase.AbstractPhaseInterceptor; +import org.apache.cxf.phase.Phase; +import org.apache.cxf.rs.security.oauth2.client.OAuthClientUtils; +import org.apache.cxf.rs.security.oauth2.common.ClientAccessToken; +import org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeGrant; +import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException; +import org.apache.cxf.transport.http.AbstractHTTPDestination; + +public class OAuth2InInterceptor extends AbstractPhaseInterceptor { + + private static final OAuthClientUtils.Consumer OAUTH2_CONSUMER = + new OAuthClientUtils.Consumer(OAuth2Provider.CLIENT_ID, OAuth2Provider.CLIENT_SECRET); + + public OAuth2InInterceptor() { + super(Phase.PRE_INVOKE); + } + + @Override + public void handleMessage(final Message message) throws Fault { + final String requestURL = (String) message.get(Message.REQUEST_URL); + if (requestURL.contains("V40/OAuth2.svc")) { + @SuppressWarnings("unchecked") + final Map> headers = (Map>) message.get(Message.PROTOCOL_HEADERS); + final List oauth2CodeHeader = headers.get(OAuth2Provider.OAUTH2_CODE_HEADER); + if (oauth2CodeHeader == null || oauth2CodeHeader.isEmpty()) { + message.put(AbstractHTTPDestination.REQUEST_REDIRECTED, Boolean.TRUE); + + final HttpServletResponse response = (HttpServletResponse) message.get(AbstractHTTPDestination.HTTP_RESPONSE); + try { + final String authorizationServiceURI = + StringUtils.substringBefore(requestURL, "V40/OAuth2.svc") + "oauth/authorize"; + + final URI authorizationURI = OAuthClientUtils.getAuthorizationURI( + authorizationServiceURI, + OAuth2Provider.CLIENT_ID, + OAuth2Provider.REDIRECT_URI, + null, + null); + response.addHeader("Location", authorizationURI.toASCIIString()); + response.sendError(303); + } catch (Exception e) { + throw new Fault(e); + } + } else { + try { + final JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); + bean.setAddress(StringUtils.substringBefore(requestURL, "V40/OAuth2.svc") + "oauth/token"); + bean.setUsername("odatajclient"); + bean.setPassword("odatajclient"); + final WebClient accessTokenService = bean.createWebClient(). + type(MediaType.APPLICATION_FORM_URLENCODED_TYPE). + accept(MediaType.APPLICATION_JSON_TYPE); + + final AuthorizationCodeGrant codeGrant = new AuthorizationCodeGrant(oauth2CodeHeader.get(0)); + final ClientAccessToken accessToken = + OAuthClientUtils.getAccessToken(accessTokenService, OAUTH2_CONSUMER, codeGrant); + if (accessToken == null) { + throw new WebApplicationException("No OAuth2 access token"); + } + } catch (OAuthServiceException e) { + throw new Fault(e); + } + } + } + } +} diff --git a/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2Provider.java b/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2Provider.java new file mode 100644 index 000000000..bd355150c --- /dev/null +++ b/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2Provider.java @@ -0,0 +1,133 @@ +/* + * 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.rest; + +import java.util.Collections; +import java.util.List; +import org.apache.cxf.rs.security.oauth2.common.AccessTokenRegistration; +import org.apache.cxf.rs.security.oauth2.common.Client; +import org.apache.cxf.rs.security.oauth2.common.OAuthPermission; +import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken; +import org.apache.cxf.rs.security.oauth2.common.UserSubject; +import org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeDataProvider; +import org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeRegistration; +import org.apache.cxf.rs.security.oauth2.grants.code.ServerAuthorizationCodeGrant; +import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException; +import org.apache.cxf.rs.security.oauth2.tokens.bearer.BearerAccessToken; + +public class OAuth2Provider implements AuthorizationCodeDataProvider { + + public static final String CLIENT_ID = "odataOAuth2SVC"; + + public static final String CLIENT_SECRET = "1234567890"; + + public static final String REDIRECT_URI = "/stub/StaticService/V40/OAuth2.svc/"; + + public static final String OAUTH2_CODE_HEADER = "oauth2.token"; + + private Client client; + + private ServerAuthorizationCodeGrant grant; + + private ServerAccessToken token; + + @Override + public Client getClient(final String string) throws OAuthServiceException { + if (client == null) { + client = new Client(CLIENT_ID, CLIENT_SECRET, true); + client.getRedirectUris().add(REDIRECT_URI); + } + return client; + } + + @Override + public ServerAccessToken getPreauthorizedToken( + final Client client, final List list, final UserSubject us, final String string) + throws OAuthServiceException { + + return null; + } + + @Override + public List convertScopeToPermissions(final Client client, final List list) { + return Collections.singletonList(new OAuthPermission()); + } + + @Override + public ServerAuthorizationCodeGrant createCodeGrant(final AuthorizationCodeRegistration acr) + throws OAuthServiceException { + + grant = new ServerAuthorizationCodeGrant(client, 3600L); + grant.setRedirectUri(acr.getRedirectUri()); + grant.setSubject(acr.getSubject()); + final List scope = acr.getApprovedScope().isEmpty() + ? acr.getRequestedScope() + : acr.getApprovedScope(); + grant.setApprovedScopes(scope); + + return grant; + } + + @Override + public ServerAuthorizationCodeGrant removeCodeGrant(final String code) throws OAuthServiceException { + return grant == null || !grant.getCode().equals(code) + ? null + : grant; + } + + @Override + public ServerAccessToken createAccessToken(final AccessTokenRegistration atr) throws OAuthServiceException { + token = new BearerAccessToken(atr.getClient(), 3600L); + + final List scope = atr.getApprovedScope().isEmpty() + ? atr.getRequestedScope() + : atr.getApprovedScope(); + token.setScopes(convertScopeToPermissions(atr.getClient(), scope)); + token.setSubject(atr.getSubject()); + token.setGrantType(atr.getGrantType()); + + return token; + } + + @Override + public ServerAccessToken getAccessToken(final String tokenId) throws OAuthServiceException { + return token == null || token.getTokenKey().equals(tokenId) ? token : null; + } + + @Override + public ServerAccessToken refreshAccessToken( + final Client client, final String string, final List list) + throws OAuthServiceException { + + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void removeAccessToken(final ServerAccessToken sat) throws OAuthServiceException { + if (token != null && token.getTokenKey().equals(sat.getTokenKey())) { + token = null; + } + } + + @Override + public void revokeToken(final Client client, final String string, final String string1) throws OAuthServiceException { + throw new UnsupportedOperationException("Not supported yet."); + } + +} diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/ResolvingReferencesInterceptor.java b/fit/src/main/java/org/apache/olingo/fit/rest/ResolvingReferencesInterceptor.java similarity index 91% rename from fit/src/main/java/org/apache/olingo/fit/utils/ResolvingReferencesInterceptor.java rename to fit/src/main/java/org/apache/olingo/fit/rest/ResolvingReferencesInterceptor.java index 794e449f8..b4cecbeca 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/ResolvingReferencesInterceptor.java +++ b/fit/src/main/java/org/apache/olingo/fit/rest/ResolvingReferencesInterceptor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.fit.utils; +package org.apache.olingo.fit.rest; import java.io.UnsupportedEncodingException; import java.net.URI; @@ -41,7 +41,8 @@ public class ResolvingReferencesInterceptor extends AbstractPhaseInterceptor { + + private static final String AUTHORIZATION_PROPERTY = "Authorization"; + + private static final String AUTHENTICATION_SCHEME = "Basic"; + + public StaticSecurityInterceptor() { + super(Phase.PRE_PROTOCOL); + } + + @Override + public void handleMessage(final Message message) throws Fault { + final SecurityContext sc = message.get(SecurityContext.class); + if (sc == null || sc.getUserPrincipal() == null) { + @SuppressWarnings("unchecked") + final Map> headers = (Map>) message.get(Message.PROTOCOL_HEADERS); + + final List auth = headers.get(AUTHORIZATION_PROPERTY); + if (auth == null || auth.isEmpty()) { + throw new WebApplicationException(Response.Status.UNAUTHORIZED); + } + + final String encodedUserPassword = auth.get(0).replaceFirst(AUTHENTICATION_SCHEME + " ", ""); + final String usernameAndPassword = new String(Base64.decode(encodedUserPassword)); + + //Split username and password tokens + final StringTokenizer tokenizer = new StringTokenizer(usernameAndPassword, ":"); + final String username = tokenizer.nextToken(); + final String password = tokenizer.nextToken(); + + if (!"odatajclient".equals(username) || !"odatajclient".equals(password)) { + throw new WebApplicationException(Response.Status.UNAUTHORIZED); + } + + final SecurityContext newSc = new SecurityContext() { + + @Override + public Principal getUserPrincipal() { + return new SimplePrincipal("odatajclient"); + } + + @Override + public boolean isUserInRole(final String role) { + return false; + } + }; + message.put(SecurityContext.class, newSc); + } + } + +} diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XHTTPMethodInterceptor.java b/fit/src/main/java/org/apache/olingo/fit/rest/XHTTPMethodInterceptor.java similarity index 84% rename from fit/src/main/java/org/apache/olingo/fit/utils/XHTTPMethodInterceptor.java rename to fit/src/main/java/org/apache/olingo/fit/rest/XHTTPMethodInterceptor.java index 238e155d9..cacb0ea1f 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/XHTTPMethodInterceptor.java +++ b/fit/src/main/java/org/apache/olingo/fit/rest/XHTTPMethodInterceptor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.fit.utils; +package org.apache.olingo.fit.rest; import java.util.List; import java.util.Map; @@ -25,6 +25,8 @@ import org.apache.cxf.interceptor.Fault; import org.apache.cxf.message.Message; import org.apache.cxf.phase.AbstractPhaseInterceptor; import org.apache.cxf.phase.Phase; +import org.apache.olingo.fit.utils.ConstantKey; +import org.apache.olingo.fit.utils.Constants; public class XHTTPMethodInterceptor extends AbstractPhaseInterceptor { @@ -38,8 +40,8 @@ public class XHTTPMethodInterceptor extends AbstractPhaseInterceptor { final Map> headers = (Map>) message.get(Message.PROTOCOL_HEADERS); if (headers.containsKey(Constants.get(ConstantKey.XHTTP_HEADER_NAME))) { - message.put(Message.HTTP_REQUEST_METHOD, headers.get(Constants.get(ConstantKey.XHTTP_HEADER_NAME)) - .iterator().next()); + message.put(Message.HTTP_REQUEST_METHOD, + headers.get(Constants.get(ConstantKey.XHTTP_HEADER_NAME)).iterator().next()); } } } diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java index 55d6733a4..baf2fac59 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java @@ -94,7 +94,7 @@ public abstract class AbstractUtilities { protected final ODataSerializer atomSerializer; protected final ODataSerializer jsonSerializer; - public AbstractUtilities(final ODataServiceVersion version, final Metadata metadata) throws Exception { + public AbstractUtilities(final ODataServiceVersion version, final Metadata metadata) throws IOException { this.version = version; this.metadata = metadata; fsManager = FSManager.instance(version); diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java index 7580ce774..833befd2a 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java @@ -51,18 +51,18 @@ public class JSONUtilities extends AbstractUtilities { private final ObjectMapper mapper; - public JSONUtilities(final ODataServiceVersion version, final Metadata metadata) throws Exception { + public JSONUtilities(final ODataServiceVersion version, final Metadata metadata) throws IOException { super(version, metadata); mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); - mapper.setInjectableValues(new InjectableValues.Std() - .addValue(Boolean.class, Boolean.TRUE) - .addValue(ODataServiceVersion.class, version)); + mapper.setInjectableValues(new InjectableValues.Std(). + addValue(Boolean.class, Boolean.TRUE). + addValue(ODataServiceVersion.class, version)); mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(), - mapper.getSerializationConfig() - .withAttribute(ODataServiceVersion.class, version) - .withAttribute(Boolean.class, Boolean.TRUE), - mapper.getSerializerFactory())); + mapper.getSerializationConfig(). + withAttribute(ODataServiceVersion.class, version). + withAttribute(Boolean.class, Boolean.TRUE), + mapper.getSerializerFactory())); } @Override @@ -72,15 +72,15 @@ public class JSONUtilities extends AbstractUtilities { @Override protected InputStream addLinks( - final String entitySetName, final String entitykey, final InputStream is, final Set links) - throws IOException { + final String entitySetName, final String entitykey, final InputStream is, final Set links) + throws IOException { final ObjectNode srcNode = (ObjectNode) mapper.readTree(is); IOUtils.closeQuietly(is); for (String link : links) { srcNode.set(link + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX), - new TextNode(Commons.getLinksURI(entitySetName, entitykey, link))); + new TextNode(Commons.getLinksURI(entitySetName, entitykey, link))); } return IOUtils.toInputStream(srcNode.toString(), Constants.ENCODING); @@ -99,9 +99,9 @@ public class JSONUtilities extends AbstractUtilities { final String field = fieldIter.next(); if (field.endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_BIND_SUFFIX)) - || field.endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX)) - || field.endsWith(Constants.get(version, ConstantKey.JSON_MEDIA_SUFFIX)) - || field.endsWith(Constants.get(version, ConstantKey.JSON_EDITLINK_NAME))) { + || field.endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX)) + || field.endsWith(Constants.get(version, ConstantKey.JSON_MEDIA_SUFFIX)) + || field.endsWith(Constants.get(version, ConstantKey.JSON_EDITLINK_NAME))) { if (field.indexOf('@') > 0) { links.add(field.substring(0, field.indexOf('@'))); } else { @@ -115,7 +115,7 @@ public class JSONUtilities extends AbstractUtilities { @Override protected NavigationLinks retrieveNavigationInfo(final String entitySetName, final InputStream is) - throws IOException { + throws IOException { final ObjectNode srcNode = (ObjectNode) mapper.readTree(is); IOUtils.closeQuietly(is); @@ -152,8 +152,8 @@ public class JSONUtilities extends AbstractUtilities { @Override protected InputStream normalizeLinks( - final String entitySetName, final String entityKey, final InputStream is, final NavigationLinks links) - throws IOException { + final String entitySetName, final String entityKey, final InputStream is, final NavigationLinks links) + throws IOException { final ObjectNode srcNode = (ObjectNode) mapper.readTree(is); @@ -162,16 +162,16 @@ public class JSONUtilities extends AbstractUtilities { // normalize link srcNode.remove(linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_BIND_SUFFIX)); srcNode.set( - linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX), - new TextNode(String.format("%s(%s)/%s", entitySetName, entityKey, linkTitle))); + linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX), + new TextNode(String.format("%s(%s)/%s", entitySetName, entityKey, linkTitle))); } for (String linkTitle : links.getInlineNames()) { // normalize link if exist; declare a new one if missing srcNode.remove(linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_BIND_SUFFIX)); srcNode.set( - linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX), - new TextNode(String.format("%s(%s)/%s", entitySetName, entityKey, linkTitle))); + linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX), + new TextNode(String.format("%s(%s)/%s", entitySetName, entityKey, linkTitle))); // remove inline srcNode.remove(linkTitle); @@ -182,8 +182,8 @@ public class JSONUtilities extends AbstractUtilities { } srcNode.set( - Constants.get(version, ConstantKey.JSON_EDITLINK_NAME), new TextNode( - Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")")); + Constants.get(version, ConstantKey.JSON_EDITLINK_NAME), new TextNode( + Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")")); return IOUtils.toInputStream(srcNode.toString(), Constants.ENCODING); } @@ -258,8 +258,8 @@ public class JSONUtilities extends AbstractUtilities { @Override public InputStream readEntities( - final List links, final String linkName, final String next, final boolean forceFeed) - throws IOException { + final List links, final String linkName, final String next, final boolean forceFeed) + throws IOException { if (links.isEmpty()) { throw new NotFoundException(); @@ -277,7 +277,7 @@ public class JSONUtilities extends AbstractUtilities { try { final Map.Entry uriMap = Commons.parseEntityURI(link); final Map.Entry entity = - readEntity(uriMap.getKey(), uriMap.getValue(), Accept.JSON_FULLMETA); + readEntity(uriMap.getKey(), uriMap.getValue(), Accept.JSON_FULLMETA); if (bos.size() > 1) { bos.write(",".getBytes()); @@ -295,7 +295,7 @@ public class JSONUtilities extends AbstractUtilities { } node.set(Constants.get(version, ConstantKey.JSON_VALUE_NAME), - mapper.readTree(new ByteArrayInputStream(bos.toByteArray()))); + mapper.readTree(new ByteArrayInputStream(bos.toByteArray()))); if (StringUtils.isNotBlank(next)) { node.set(Constants.get(version, ConstantKey.JSON_NEXTLINK_NAME), new TextNode(next)); @@ -306,8 +306,8 @@ public class JSONUtilities extends AbstractUtilities { @Override protected InputStream replaceLink( - final InputStream toBeChanged, final String linkName, final InputStream replacement) - throws IOException { + final InputStream toBeChanged, final String linkName, final InputStream replacement) + throws IOException { final ObjectNode toBeChangedNode = (ObjectNode) mapper.readTree(toBeChanged); final ObjectNode replacementNode = (ObjectNode) mapper.readTree(replacement); @@ -343,7 +343,7 @@ public class JSONUtilities extends AbstractUtilities { @Override public Map.Entry> extractLinkURIs( - final String entitySetName, final String entityId, final String linkName) throws Exception { + final String entitySetName, final String entityId, final String linkName) throws Exception { final LinkInfo links = readLinks(entitySetName, entityId, linkName, Accept.JSON_FULLMETA); return extractLinkURIs(links.getLinks()); } @@ -376,7 +376,7 @@ public class JSONUtilities extends AbstractUtilities { @Override public InputStream addEditLink( - final InputStream content, final String title, final String href) throws IOException { + final InputStream content, final String title, final String href) throws IOException { final ObjectNode srcNode = (ObjectNode) mapper.readTree(content); IOUtils.closeQuietly(content); @@ -387,7 +387,7 @@ public class JSONUtilities extends AbstractUtilities { @Override public InputStream addOperation(final InputStream content, final String name, final String metaAnchor, - final String href) throws IOException { + final String href) throws IOException { final ObjectNode srcNode = (ObjectNode) mapper.readTree(content); IOUtils.closeQuietly(content); @@ -402,8 +402,8 @@ public class JSONUtilities extends AbstractUtilities { @Override public InputStream replaceProperty( - final InputStream src, final InputStream replacement, final List path, final boolean justValue) - throws IOException { + final InputStream src, final InputStream replacement, final List path, final boolean justValue) + throws IOException { final ObjectNode srcNode = (ObjectNode) mapper.readTree(src); IOUtils.closeQuietly(src); diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java index 7745d3f2b..cb13f7f04 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java @@ -21,6 +21,7 @@ package org.apache.olingo.fit.utils; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; @@ -65,7 +66,7 @@ public class XMLUtilities extends AbstractUtilities { protected static XMLOutputFactory ofactory = null; - public XMLUtilities(final ODataServiceVersion version, final Metadata metadata) throws Exception { + public XMLUtilities(final ODataServiceVersion version, final Metadata metadata) throws IOException { super(version, metadata); } diff --git a/fit/src/main/resources/META-INF/LICENSE b/fit/src/main/resources/META-INF/LICENSE new file mode 100644 index 000000000..55e197210 --- /dev/null +++ b/fit/src/main/resources/META-INF/LICENSE @@ -0,0 +1,1047 @@ +Licenses of FIT artifact + + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed 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. + + + +From: 'ANTLR' (http://www.antlr.org) - ANTLR 4 Runtime +(http://www.antlr.org/antlr4-runtime) org.antlr:antlr4-runtime:jar:4.1 License: +The BSD License (http://www.antlr.org/license.html) + +[The BSD License] +Copyright (c) 2012 Terence Parr and Sam Harwell +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions and + the following disclaimer in the documentation and/or other materials + provided with the distribution. Neither the name of the author nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +From: 'abego Software GmbH, Germany' (http://abego-software.de) - abego +TreeLayout Core (http://code.google.com/p/treelayout/) +org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1 License: BSD 3-Clause +"New" or "Revised" License (BSD-3-Clause) +(http://treelayout.googlecode.com/files/LICENSE.TXT) + +[The "BSD license"] +Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the abego Software GmbH nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + + +From: 'fasterxml.com' (http://fasterxml.com) - Stax2 API +(http://wiki.fasterxml.com/WoodstoxStax2) +org.codehaus.woodstox:stax2-api:bundle:3.1.4 License: The BSD License +(http://www.opensource.org/licenses/bsd-license.php) + +Copyright (c) 2004-2010, Woodstox Project (http://woodstox.codehaus.org/) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the Woodstox XML Processor nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +From: 'QOS.ch' (http://www.qos.ch) + - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + - SLF4J Simple Binding (http://www.slf4j.org) org.slf4j:slf4j-simple:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + + +Copyright (c) 2004-2013 QOS.ch + +All rights reserved. Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + + + - htmlparser (http://about.validator.nu/htmlparser/) + nu.validator.htmlparser:htmlparser:bundle:1.4 License: The MIT License + (http://www.opensource.org/licenses/mit-license.php) License: The (New) BSD + License (http://www.opensource.org/licenses/bsd-license.php) + + +License + +This is for the HTML parser as a whole except the rewindable input stream, +the named character classes and the Live DOM Viewer. +For the copyright notices for individual files, please see individual files. + +/* + * Copyright (c) 2005, 2006, 2007 Henri Sivonen + * Copyright (c) 2007-2011 Mozilla Foundation + * Portions of comments Copyright 2004-2007 Apple Computer, Inc., Mozilla + * Foundation, and Opera Software ASA. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +The following license is for the WHATWG spec from which the named character +data was extracted. + +/* + * Copyright 2004-2010 Apple Computer, Inc., Mozilla Foundation, and Opera + * Software ASA. + * + * You are granted a license to use, reproduce and create derivative works of + * this document. + */ + +The following license is for the rewindable input stream. + +/* + * Copyright (c) 2001-2003 Thai Open Source Software Center Ltd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the Thai Open Source Software Center Ltd nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +The following license applies to the Live DOM Viewer: + +Copyright (c) 2000, 2006, 2008 Ian Hickson and various contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + + - AOP alliance (http://aopalliance.sourceforge.net) + aopalliance:aopalliance:jar:1.0 License: Public Domain + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to + + + - WSDL4J (http://sf.net/projects/wsdl4j) wsdl4j:wsdl4j:jar:1.6.3 + License: CPL (http://www.opensource.org/licenses/cpl1.0.txt) + + + +Common Public License Version 1.0 +[OSI Approved License] + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and such +derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed +Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. +This patent license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other combinations +which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses +to its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other intellectual +property rights of any other entity. Each Contributor disclaims any liability to +Recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby assumes sole +responsibility to secure any other intellectual property rights needed, if any. +For example, if a third party patent license is required to allow Recipient to +distribute the Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license set +forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its +own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title and +non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered +by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on or +through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to +control, and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may participate in +any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its exercise of +rights under this Agreement, including but not limited to the risks and costs of +program errors, compliance with applicable laws, damage to or loss of data, +programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against a Contributor with respect to +a patent applicable to software (including a cross-claim or counterclaim in a +lawsuit), then any patent licenses granted by that Contributor to such Recipient +under this Agreement shall terminate as of the date such litigation is filed. In +addition, if Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the Program +itself (excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +IBM is the initial Agreement Steward. IBM may assign the responsibility to serve +as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the Agreement +is published, Contributor may elect to distribute the Program (including its +Contributions) under the new version. Except as expressly stated in Sections +2(a) and 2(b) above, Recipient receives no rights or licenses to the +intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. + + + +From: 'Oracle Corporation' (http://www.oracle.com/) - JAXB Reference +Implementation (http://jaxb.java.net/) com.sun.xml.bind:jaxb-impl:jar:2.2.6 +License: CDDL 1.1 (https://glassfish.java.net/public/CDDL+GPL_1_1.html) +License: GPL2 w/ CPE (https://glassfish.java.net/public/CDDL+GPL_1_1.html) - +javax.ws.rs-api (http://jax-rs-spec.java.net) +javax.ws.rs:javax.ws.rs-api:jar:2.0-m10 License: CDDL 1.1 +(http://glassfish.java.net/public/CDDL+GPL_1_1.html) License: GPL2 w/ CPE +(http://glassfish.java.net/public/CDDL+GPL_1_1.html) + + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)Version 1.1 + +1. Definitions. + + 1.1. “Contributor” means each individual or entity that creates or + contributes to the creation of Modifications. + + 1.2. “Contributor Version” means the combination of the Original Software, + prior Modifications used by a Contributor (if any), and the Modifications + made by that particular Contributor. + + 1.3. “Covered Software” means (a) the Original Software, or (b) + Modifications, or (c) the combination of files containing Original Software + with files containing Modifications, in each case including portions + thereof. + + 1.4. “Executable” means the Covered Software in any form other than Source + Code. + + 1.5. “Initial Developer” means the individual or entity that first makes + Original Software available under this License. + + 1.6. “Larger Work” means a work which combines Covered Software or portions + thereof with code not governed by the terms of this License. + + 1.7. “License” means this document. + + 1.8. “Licensable” means having the right to grant, to the maximum extent + possible, whether at the time of the initial grant or subsequently + acquired, any and all of the rights conveyed herein. + + 1.9. “Modifications” means the Source Code and Executable form of any of + the following: + + A. Any file that results from an addition to, deletion from or modification + of the contents of a file containing Original Software or previous + Modifications; + + B. Any new file that contains any part of the Original Software or previous + Modification; or + + C. Any new file that is contributed or otherwise made available under the + terms of this License. + + 1.10. “Original Software” means the Source Code and Executable form of + computer software code that is originally released under this License. + + 1.11. “Patent Claims” means any patent claim(s), now owned or hereafter + acquired, including without limitation, method, process, and apparatus + claims, in any patent Licensable by grantor. + + 1.12. “Source Code” means (a) the common form of computer software code in + which modifications are made and (b) associated documentation included in + or with such code. + + 1.13. “You” (or “Your”) means an individual or a legal entity exercising + rights under, and complying with all of the terms of, this License. For + legal entities, “You” includes any entity which controls, is controlled by, + or is under common control with You. For purposes of this definition, + “control” means (a) the power, direct or indirect, to cause the direction + or management of such entity, whether by contract or otherwise, or (b) + ownership of more than fifty percent (50%) of the outstanding shares or + beneficial ownership of such entity. + +2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and subject to + third party intellectual property claims, the Initial Developer hereby + grants You a world-wide, royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than patent or trademark) + Licensable by Initial Developer, to use, reproduce, modify, display, + perform, sublicense and distribute the Original Software (or portions + thereof), with or without Modifications, and/or as part of a Larger Work; + and + + (b) under Patent Claims infringed by the making, using or selling of + Original Software, to make, have made, use, practice, sell, and offer for + sale, and/or otherwise dispose of the Original Software (or portions + thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) are effective on the + date Initial Developer first distributes or otherwise makes the Original + Software available to a third party under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) + for code that You delete from the Original Software, or (2) for + infringements caused by: (i) the modification of the Original Software, or + (ii) the combination of the Original Software with other software or + devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and subject to + third party intellectual property claims, each Contributor hereby grants + You a world-wide, royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than patent or trademark) + Licensable by Contributor to use, reproduce, modify, display, perform, + sublicense and distribute the Modifications created by such Contributor (or + portions thereof), either on an unmodified basis, with other Modifications, + as Covered Software and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or selling of + Modifications made by that Contributor either alone and/or in combination + with its Contributor Version (or portions of such combination), to make, + use, sell, offer for sale, have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions thereof); and (2) the + combination of Modifications made by that Contributor with its Contributor + Version (or portions of such combination). + + (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the + date Contributor first distributes or otherwise makes the Modifications + available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) + for any code that Contributor has deleted from the Contributor Version; (2) + for infringements caused by: (i) third party modifications of Contributor + Version, or (ii) the combination of Modifications made by that Contributor + with other software (except as part of the Contributor Version) or other + devices; or (3) under Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + +3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make available in + Executable form must also be made available in Source Code form and that + Source Code form must be distributed only under the terms of this License. + You must include a copy of this License with every copy of the Source Code + form of the Covered Software You distribute or otherwise make available. + You must inform recipients of any such Covered Software in Executable form + as to how they can obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used for software + exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You contribute are governed + by the terms of this License. You represent that You believe Your + Modifications are Your original creation(s) and/or You have sufficient + rights to grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications that identifies You + as the Contributor of the Modification. You may not remove or alter any + copyright, patent or trademark notices contained within the Covered + Software, or any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered Software in Source + Code form that alters or restricts the applicable version of this License + or the recipients' rights hereunder. You may choose to offer, and to charge + a fee for, warranty, support, indemnity or liability obligations to one or + more recipients of Covered Software. However, you may do so only on Your + own behalf, and not on behalf of the Initial Developer or any Contributor. + You must make it absolutely clear that any such warranty, support, + indemnity or liability obligation is offered by You alone, and You hereby + agree to indemnify the Initial Developer and every Contributor for any + liability incurred by the Initial Developer or such Contributor as a result + of warranty, support, indemnity or liability terms You offer. + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered Software under the + terms of this License or under the terms of a license of Your choice, which + may contain terms different from this License, provided that You are in + compliance with the terms of this License and that the license for the + Executable form does not attempt to limit or alter the recipient's rights + in the Source Code form from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a different + license, You must make it absolutely clear that any terms which differ from + this License are offered by You alone, not by the Initial Developer or + Contributor. You hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial Developer or such + Contributor as a result of any such terms You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software with other code + not governed by the terms of this License and distribute the Larger Work as + a single product. In such a case, You must make sure the requirements of + this License are fulfilled for the Covered Software. + +4. Versions of the License. + + 4.1. New Versions. + + Oracle is the initial license steward and may publish revised and/or new + versions of this License from time to time. Each version will be given a + distinguishing version number. Except as provided in Section 4.3, no one + other than the license steward has the right to modify this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise make the Covered + Software available under the terms of the version of the License under + which You originally received the Covered Software. If the Initial + Developer includes a notice in the Original Software prohibiting it from + being distributed or otherwise made available under any subsequent version + of the License, You must distribute and make the Covered Software available + under the terms of the version of the License under which You originally + received the Covered Software. Otherwise, You may also choose to use, + distribute or otherwise make the Covered Software available under the terms + of any subsequent version of the License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a new license for + Your Original Software, You may create and use a modified version of this + License if You: (a) rename the license and remove any references to the + name of the license steward (except to note that the license differs from + this License); and (b) otherwise make it clear that the license contains + terms which differ from this License. + +5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, + WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF + DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE + ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS + WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU + (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY + NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY + CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED + SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +6. TERMINATION. + + 6.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to cure such + breach within 30 days of becoming aware of the breach. Provisions which, by + their nature, must remain in effect beyond the termination of this License + shall survive. + + 6.2. If You assert a patent infringement claim (excluding declaratory + judgment actions) against Initial Developer or a Contributor (the Initial + Developer or Contributor against whom You assert such claim is referred to + as “Participant”) alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor or the Original + Software where the Participant is the Initial Developer) directly or + indirectly infringes any patent, then any and all rights granted directly + or indirectly to You by such Participant, the Initial Developer (if the + Initial Developer is not the Participant) and all Contributors under + Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from + Participant terminate prospectively and automatically at the expiration of + such 60 day notice period, unless if within such 60 day period You withdraw + Your claim with respect to the Participant Software against such + Participant either unilaterally or pursuant to a written agreement with + Participant. + + 6.3. If You assert a patent infringement claim against Participant alleging + that the Participant Software directly or indirectly infringes any patent + where such claim is resolved (such as by license or settlement) prior to + the initiation of patent infringement litigation, then the reasonable value + of the licenses granted by such Participant under Sections 2.1 or 2.2 shall + be taken into account in determining the amount or value of any payment or + license. + + 6.4. In the event of termination under Sections 6.1 or 6.2 above, all end + user licenses that have been validly granted by You or any distributor + hereunder prior to termination (excluding licenses granted to You by any + distributor) shall survive termination. + +7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING + NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY + OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER + OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, + INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE + OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF + SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. + THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR + PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW + THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS + EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +8. U.S. GOVERNMENT END USERS. + + The Covered Software is a “commercial item,” as that term is defined in 48 + C.F.R. 2.101 (Oct. 1995), consisting of “commercial computer software” (as + that term is defined at 48 C.F.R. § 252.227-7014(a)(1)) and “commercial + computer software documentation” as such terms are used in 48 C.F.R. 12.212 + (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users acquire + Covered Software with only those rights set forth herein. This U.S. + Government Rights clause is in lieu of, and supersedes, any other FAR, + DFAR, or other clause or provision that addresses Government rights in + computer software under this License. + +9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject matter + hereof. If any provision of this License is held to be unenforceable, such + provision shall be reformed only to the extent necessary to make it + enforceable. This License shall be governed by the law of the jurisdiction + specified in a notice contained within the Original Software (except to the + extent applicable law, if any, provides otherwise), excluding such + jurisdiction's conflict-of-law provisions. Any litigation relating to this + License shall be subject to the jurisdiction of the courts located in the + jurisdiction and venue specified in a notice contained within the Original + Software, with the losing party responsible for costs, including, without + limitation, court costs and reasonable attorneys' fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or regulation + which provides that the language of a contract shall be construed against + the drafter shall not apply to this License. You agree that You alone are + responsible for compliance with the United States export administration + regulations (and the export control laws and regulation of any other + countries) when You use, distribute or otherwise make available any Covered + Software. + +10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or indirectly, out of + its utilization of rights under this License and You agree to work with + Initial Developer and Contributors to distribute such responsibility on an + equitable basis. Nothing herein is intended or shall be deemed to + constitute any admission of liability. + +NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE +(CDDL) + +The code released under the CDDL shall be governed by the laws of the State of +California (excluding conflict-of-law provisions). Any litigation relating to +this License shall be subject to the jurisdiction of the Federal Courts of the +Northern District of California and the state courts of the State of +California, with venue lying in Santa Clara County, California. + + diff --git a/fit/src/main/webapp/WEB-INF/applicationContext.xml b/fit/src/main/webapp/WEB-INF/applicationContext.xml index 53605e9f2..2cadd6143 100644 --- a/fit/src/main/webapp/WEB-INF/applicationContext.xml +++ b/fit/src/main/webapp/WEB-INF/applicationContext.xml @@ -36,24 +36,33 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fit/src/test/java/org/apache/olingo/fit/CXFOAuth2HttpUriRequestFactory.java b/fit/src/test/java/org/apache/olingo/fit/CXFOAuth2HttpUriRequestFactory.java new file mode 100644 index 000000000..6102d8c3b --- /dev/null +++ b/fit/src/test/java/org/apache/olingo/fit/CXFOAuth2HttpUriRequestFactory.java @@ -0,0 +1,130 @@ +/* + * 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 com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import java.net.URI; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.Header; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.client.params.ClientPNames; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpParams; +import org.apache.http.util.EntityUtils; +import org.apache.olingo.client.core.http.AbstractOAuth2HttpUriRequestFactory; +import org.apache.olingo.client.core.http.OAuth2Exception; +import org.apache.olingo.fit.rest.OAuth2Provider; + +public class CXFOAuth2HttpUriRequestFactory extends AbstractOAuth2HttpUriRequestFactory { + + private String code; + + public CXFOAuth2HttpUriRequestFactory(final URI redirectURI) { + super(redirectURI); + } + + @Override + protected boolean isInited() { + return code != null; + } + + @Override + protected void init() throws OAuth2Exception { + // 1. Disable automatic redirects handling + final HttpParams params = new BasicHttpParams(); + params.setParameter(ClientPNames.HANDLE_REDIRECTS, false); + final DefaultHttpClient httpClient = new DefaultHttpClient(params); + + // 2. Try to access the redirect URI without any special header: get redirected to the OAuth2 service + URI location = null; + try { + final HttpResponse response = httpClient.execute(new HttpGet(redirectURI)); + + final Header locationHeader = response.getFirstHeader("Location"); + if (response.getStatusLine().getStatusCode() != 303 || locationHeader == null) { + throw new IllegalStateException("OAuth flow is broken"); + } + + location = new URI(locationHeader.getValue()); + + EntityUtils.consumeQuietly(response.getEntity()); + } catch (Exception e) { + throw new OAuth2Exception(e); + } + + JsonNode oAuthAuthorizationData = null; + String authenticityCookie = null; + try { + // 3. Need to (basic) authenticate against the OAuth2 service + final HttpGet method = new HttpGet(location); + method.addHeader("Authorization", "Basic " + Base64.encodeBase64String("odatajclient:odatajclient".getBytes())); + final HttpResponse response = httpClient.execute(method); + + // 4. Pull out OAuth2 authorization data and "authenticity" cookie (CXF specific) + oAuthAuthorizationData = new XmlMapper().readTree(EntityUtils.toString(response.getEntity())); + + final Header setCookieHeader = response.getFirstHeader("Set-Cookie"); + if (setCookieHeader == null) { + throw new IllegalStateException("OAuth flow is broken"); + } + authenticityCookie = setCookieHeader.getValue(); + } catch (Exception e) { + throw new OAuth2Exception(e); + } + + try { + // 5. Submit the HTTP form for allowing access to the application + location = new URIBuilder(oAuthAuthorizationData.get("replyTo").asText()). + addParameter("session_authenticity_token", oAuthAuthorizationData.get("authenticityToken").asText()). + addParameter("client_id", oAuthAuthorizationData.get("clientId").asText()). + addParameter("redirect_uri", oAuthAuthorizationData.get("redirectUri").asText()). + addParameter("oauthDecision", "allow"). + build(); + final HttpGet method = new HttpGet(location); + method.addHeader("Authorization", "Basic " + Base64.encodeBase64String("odatajclient:odatajclient".getBytes())); + method.addHeader("Cookie", authenticityCookie); + + final HttpResponse response = httpClient.execute(method); + + final Header locationHeader = response.getFirstHeader("Location"); + if (response.getStatusLine().getStatusCode() != 303 || locationHeader == null) { + throw new IllegalStateException("OAuth flow is broken"); + } + + // 6. Finally get the code value out of this last redirect + code = StringUtils.substringAfterLast(locationHeader.getValue(), "="); + + EntityUtils.consumeQuietly(response.getEntity()); + } catch (Exception e) { + throw new OAuth2Exception(e); + } + } + + @Override + protected void sign(final HttpUriRequest request) { + request.addHeader(OAuth2Provider.OAUTH2_CODE_HEADER, code); + } + +} diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java index 1ecd4bb66..22733680d 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java @@ -69,6 +69,8 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase { protected static String testAuthServiceRootURL; + protected static String testOAuth2ServiceRootURL; + @BeforeClass public static void setUpODataServiceRoot() throws IOException { testStaticServiceRootURL = "http://localhost:9080/stub/StaticService/V40/Static.svc"; @@ -79,6 +81,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase { testOpenTypeServiceRootURL = "http://localhost:9080/stub/StaticService/V40/OpenType.svc"; testLargeModelServiceRootURL = "http://localhost:9080/stub/StaticService/V40/Static.svc/large"; testAuthServiceRootURL = "http://localhost:9080/stub/DefaultService.svc/V40/Static.svc"; + testOAuth2ServiceRootURL = "http://localhost:9080/stub/StaticService/V40/OAuth2.svc"; edmClient = ODataClientFactory.getEdmEnabledV4(testStaticServiceRootURL); @@ -107,48 +110,46 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase { return entity; } - protected void createAndDeleteOrder(final ODataFormat format, final int id) { + protected void createAndDeleteOrder(final String serviceRoot, final ODataFormat format, final int id) { final ODataEntity order = new ODataEntityImpl( - new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order")); + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order")); final ODataProperty orderId = getClient().getObjectFactory().newPrimitiveProperty("OrderID", - getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id)); + getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id)); order.getProperties().add(orderId); Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")); dateTime.set(2011, 2, 4, 16, 3, 57); final ODataProperty orderDate = getClient().getObjectFactory().newPrimitiveProperty("OrderDate", - getClient().getObjectFactory().newPrimitiveValueBuilder() + getClient().getObjectFactory().newPrimitiveValueBuilder() .setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(dateTime).build()); order.getProperties().add(orderDate); final ODataProperty shelfLife = getClient().getObjectFactory().newPrimitiveProperty("ShelfLife", - getClient().getObjectFactory().newPrimitiveValueBuilder(). + getClient().getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.Duration).setValue(BigDecimal.TEN.scaleByPowerOfTen(7)).build()); order.getProperties().add(shelfLife); final ODataCollectionValue orderShelfLifesValue = getClient().getObjectFactory(). - newCollectionValue("Collection(Duration)"); + newCollectionValue("Collection(Duration)"); orderShelfLifesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder(). - setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000001")).build()); + setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000001")).build()); orderShelfLifesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder(). - setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build()); + setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build()); final ODataProperty orderShelfLifes = getClient().getObjectFactory(). - newCollectionProperty("OrderShelfLifes", orderShelfLifesValue); + newCollectionProperty("OrderShelfLifes", orderShelfLifesValue); order.getProperties().add(orderShelfLifes); final ODataEntityCreateRequest req = getClient().getCUDRequestFactory().getEntityCreateRequest( - getClient().newURIBuilder(testStaticServiceRootURL). + getClient().newURIBuilder(serviceRoot). appendEntitySetSegment("Orders").build(), order); req.setFormat(format); final ODataEntity created = req.execute().getBody(); assertNotNull(created); assertEquals(2, created.getProperty("OrderShelfLifes").getCollectionValue().size()); - final URI deleteURI = created.getEditLink() == null - ? getClient().newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Orders").appendKeySegment(id).build() - : created.getEditLink(); + final URI deleteURI = getClient().newURIBuilder(serviceRoot). + appendEntitySetSegment("Orders").appendKeySegment(id).build(); final ODataDeleteRequest deleteReq = getClient().getCUDRequestFactory().getDeleteRequest(deleteURI); final ODataDeleteResponse deleteRes = deleteReq.execute(); assertEquals(204, deleteRes.getStatusCode()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java index 2b6c901b0..167b68f47 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java @@ -42,12 +42,12 @@ public class EntityCreateTestITCase extends AbstractTestITCase { @Test public void atomCreateAndDelete() { - createAndDeleteOrder(ODataFormat.ATOM, 1000); + createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.ATOM, 1000); } @Test public void jsonCreateAndDelete() { - createAndDeleteOrder(ODataFormat.JSON, 1001); + createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.JSON, 1001); } private void onContained(final ODataFormat format) { diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java index 91da2c5b0..27a15aff1 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java @@ -52,7 +52,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase { private void read(final ODataFormat format) { final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL). - appendEntitySetSegment("Accounts").appendKeySegment(101); + appendEntitySetSegment("Accounts").appendKeySegment(101); final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); @@ -80,25 +80,25 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase { @Test public void atomCreateAndDelete() { - createAndDeleteOrder(ODataFormat.ATOM, 1000); + createAndDeleteOrder(testKeyAsSegmentServiceRootURL, ODataFormat.ATOM, 1000); } @Test public void jsonCreateAndDelete() { - createAndDeleteOrder(ODataFormat.JSON_FULL_METADATA, 1001); + createAndDeleteOrder(testKeyAsSegmentServiceRootURL, ODataFormat.JSON_FULL_METADATA, 1001); } private void update(final ODataFormat format) { final ODataEntity changes = getClient().getObjectFactory().newEntity( - new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer")); + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer")); final ODataProperty middleName = getClient().getObjectFactory().newPrimitiveProperty("MiddleName", - getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("middle")); + getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("middle")); changes.getProperties().add(middleName); final URI uri = getClient().newURIBuilder(testKeyAsSegmentServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5).build(); + appendEntitySetSegment("People").appendKeySegment(5).build(); final ODataEntityUpdateRequest req = getClient().getCUDRequestFactory(). - getEntityUpdateRequest(uri, UpdateType.PATCH, changes); + getEntityUpdateRequest(uri, UpdateType.PATCH, changes); req.setFormat(format); final ODataEntityUpdateResponse res = req.execute(); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/OAuth2TestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/OAuth2TestITCase.java new file mode 100644 index 000000000..0eb054ff1 --- /dev/null +++ b/fit/src/test/java/org/apache/olingo/fit/v4/OAuth2TestITCase.java @@ -0,0 +1,107 @@ +/* + * 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.v4; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.net.URI; +import org.apache.commons.lang3.StringUtils; +import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest; +import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse; +import org.apache.olingo.client.api.uri.v4.URIBuilder; +import org.apache.olingo.client.api.v4.EdmEnabledODataClient; +import org.apache.olingo.client.api.v4.ODataClient; +import org.apache.olingo.client.core.ODataClientFactory; +import org.apache.olingo.client.core.http.DefaultHttpUriRequestFactory; +import org.apache.olingo.commons.api.domain.v4.ODataEntity; +import org.apache.olingo.commons.api.format.ODataFormat; +import org.apache.olingo.fit.CXFOAuth2HttpUriRequestFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class OAuth2TestITCase extends AbstractTestITCase { + + private EdmEnabledODataClient _edmClient; + + @BeforeClass + public static void enableOAuth2() { + client.getConfiguration().setHttpUriRequestFactory( + new CXFOAuth2HttpUriRequestFactory(URI.create(testOAuth2ServiceRootURL))); + } + + @AfterClass + public static void disableOAuth2() { + client.getConfiguration().setHttpUriRequestFactory(new DefaultHttpUriRequestFactory()); + } + + protected EdmEnabledODataClient getEdmClient() { + if (_edmClient == null) { + _edmClient = ODataClientFactory.getEdmEnabledV4(testOAuth2ServiceRootURL); + _edmClient.getConfiguration().setHttpUriRequestFactory( + new CXFOAuth2HttpUriRequestFactory(URI.create(testOAuth2ServiceRootURL))); + } + + return _edmClient; + } + + private void read(final ODataClient client, final ODataFormat format) { + final URIBuilder uriBuilder = + client.newURIBuilder(testOAuth2ServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8); + + final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); + req.setFormat(format); + + final ODataRetrieveResponse res = req.execute(); + assertEquals(200, res.getStatusCode()); + + final String etag = res.getETag(); + assertTrue(StringUtils.isNotBlank(etag)); + + final ODataEntity order = res.getBody(); + assertEquals(etag, order.getETag()); + assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Order", order.getTypeName().toString()); + assertEquals("Edm.Int32", order.getProperty("OrderID").getPrimitiveValue().getTypeName()); + assertEquals("Edm.DateTimeOffset", order.getProperty("OrderDate").getPrimitiveValue().getTypeName()); + assertEquals("Edm.Duration", order.getProperty("ShelfLife").getPrimitiveValue().getTypeName()); + assertEquals("Collection(Edm.Duration)", order.getProperty("OrderShelfLifes").getCollectionValue().getTypeName()); + } + + @Test + public void readAsAtom() { + read(client, ODataFormat.ATOM); + } + + @Test + public void readAsFullJSON() { + read(client, ODataFormat.JSON_FULL_METADATA); + } + + @Test + public void readAsJSON() { + read(getEdmClient(), ODataFormat.JSON); + } + + @Test + public void createAndDelete() { + createAndDeleteOrder(testOAuth2ServiceRootURL, ODataFormat.JSON, 1002); + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java index 8d75a3170..53963954a 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java @@ -48,18 +48,18 @@ public abstract class AbstractRequest { protected void checkRequest(final CommonODataClient odataClient, final HttpUriRequest request) { // If using and Edm enabled client, checks that the cached service root matches the request URI if (odataClient instanceof CommonEdmEnabledODataClient - && !request.getURI().toASCIIString().startsWith( - ((CommonEdmEnabledODataClient) odataClient).getServiceRoot())) { + && !request.getURI().toASCIIString().startsWith( + ((CommonEdmEnabledODataClient) odataClient).getServiceRoot())) { throw new IllegalArgumentException( - String.format("The current request URI %s does not match the configured service root %s", - request.getURI().toASCIIString(), - ((CommonEdmEnabledODataClient) odataClient).getServiceRoot())); + String.format("The current request URI %s does not match the configured service root %s", + request.getURI().toASCIIString(), + ((CommonEdmEnabledODataClient) odataClient).getServiceRoot())); } } protected void checkResponse( - final CommonODataClient odataClient, final HttpResponse response, final String accept) { + final CommonODataClient odataClient, final HttpResponse response, final String accept) { if (response.getStatusLine().getStatusCode() >= 400) { try { @@ -67,7 +67,7 @@ public abstract class AbstractRequest { if (httpEntity == null) { throw new ODataClientErrorException(response.getStatusLine()); } else { - ODataFormat format = accept.contains("xml") ? ODataFormat.XML : ODataFormat.JSON; + final ODataFormat format = accept.contains("xml") ? ODataFormat.XML : ODataFormat.JSON; ODataError error; try { @@ -75,13 +75,13 @@ public abstract class AbstractRequest { } catch (final RuntimeException e) { LOG.warn("Error deserializing error response", e); error = getGenericError( - response.getStatusLine().getStatusCode(), - response.getStatusLine().getReasonPhrase()); + response.getStatusLine().getStatusCode(), + response.getStatusLine().getReasonPhrase()); } catch (final ODataDeserializerException e) { LOG.warn("Error deserializing error response", e); error = getGenericError( - response.getStatusLine().getStatusCode(), - response.getStatusLine().getReasonPhrase()); + response.getStatusLine().getStatusCode(), + response.getStatusLine().getReasonPhrase()); } if (response.getStatusLine().getStatusCode() >= 500) { @@ -92,7 +92,7 @@ public abstract class AbstractRequest { } } catch (IOException e) { throw new HttpClientException( - "Received '" + response.getStatusLine() + "' but could not extract error body", e); + "Received '" + response.getStatusLine() + "' but could not extract error body", e); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java index 3127608d3..8cb148198 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java @@ -313,7 +313,6 @@ public abstract class AbstractODataResponse implements ODataResponse { } } }).start(); - } catch (IOException e) { LOG.error("Error streaming payload response", e); throw new IllegalStateException(e); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/AbstractOAuth2HttpUriRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/AbstractOAuth2HttpUriRequestFactory.java new file mode 100644 index 000000000..543d4e4a6 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/AbstractOAuth2HttpUriRequestFactory.java @@ -0,0 +1,52 @@ +/* + * 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.client.core.http; + +import java.net.URI; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.olingo.client.api.http.HttpMethod; + +public abstract class AbstractOAuth2HttpUriRequestFactory extends DefaultHttpUriRequestFactory { + + protected final URI redirectURI; + + public AbstractOAuth2HttpUriRequestFactory(final URI redirectURI) { + this.redirectURI = redirectURI; + } + + protected abstract boolean isInited(); + + protected abstract void init() throws OAuth2Exception; + + protected abstract void sign(HttpUriRequest request); + + @Override + public HttpUriRequest create(final HttpMethod method, final URI uri) { + if (!isInited()) { + init(); + } + + final HttpUriRequest request = super.create(method, uri); + + sign(request); + + return request; + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/OAuth2Exception.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/OAuth2Exception.java new file mode 100644 index 000000000..8158a517f --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/OAuth2Exception.java @@ -0,0 +1,29 @@ +/* + * 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.client.core.http; + +public class OAuth2Exception extends RuntimeException { + + private static final long serialVersionUID = 5695438980473040134L; + + public OAuth2Exception(final Throwable cause) { + super(cause); + } + +} diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml index 6bf11a243..51c24f02f 100644 --- a/lib/server-core/pom.xml +++ b/lib/server-core/pom.xml @@ -81,7 +81,6 @@ org.codehaus.mojo build-helper-maven-plugin - 1.7 generate-sources @@ -97,9 +96,8 @@ - org.antlr + org.antlr antlr4-maven-plugin - ${antlr.version} diff --git a/lib/server-tecsvc/pom.xml b/lib/server-tecsvc/pom.xml index b5fb60e22..d5b34696c 100644 --- a/lib/server-tecsvc/pom.xml +++ b/lib/server-tecsvc/pom.xml @@ -46,6 +46,9 @@ src/main/resources true + + target/maven-shared-archive-resources + diff --git a/lib/server-tecsvc/src/main/resources/META-INF/LICENSE b/lib/server-tecsvc/src/main/resources/META-INF/LICENSE new file mode 100644 index 000000000..715ff3074 --- /dev/null +++ b/lib/server-tecsvc/src/main/resources/META-INF/LICENSE @@ -0,0 +1,331 @@ +Licenses for TecSvc artifact + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed 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. + + +From: 'abego Software GmbH, Germany' (http://abego-software.de) - abego +TreeLayout Core (http://code.google.com/p/treelayout/) +org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1 License: BSD 3-Clause +"New" or "Revised" License (BSD-3-Clause) +(http://treelayout.googlecode.com/files/LICENSE.TXT) + +[The "BSD license"] +Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the abego Software GmbH nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +From: 'ANTLR' (http://www.antlr.org) - ANTLR 4 Runtime +(http://www.antlr.org/antlr4-runtime) org.antlr:antlr4-runtime:jar:4.1 License: +The BSD License (http://www.antlr.org/license.html) + +[The BSD License] +Copyright (c) 2012 Terence Parr and Sam Harwell +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions and + the following disclaimer in the documentation and/or other materials + provided with the distribution. Neither the name of the author nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +From: 'fasterxml.com' (http://fasterxml.com) - Stax2 API +(http://wiki.fasterxml.com/WoodstoxStax2) +org.codehaus.woodstox:stax2-api:bundle:3.1.4 License: The BSD License +(http://www.opensource.org/licenses/bsd-license.php) + +Copyright (c) 2004-2010, Woodstox Project (http://woodstox.codehaus.org/) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the Woodstox XML Processor nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +From: 'QOS.ch' (http://www.qos.ch) + - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + - SLF4J Simple Binding (http://www.slf4j.org) org.slf4j:slf4j-simple:jar:1.7.7 + License: MIT License (http://www.opensource.org/licenses/mit-license.php) + + +Copyright (c) 2004-2013 QOS.ch + +All rights reserved. Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/pom.xml b/pom.xml index 213a050a5..0b991cf30 100644 --- a/pom.xml +++ b/pom.xml @@ -68,19 +68,20 @@ 2.4 3.3.2 - 1.1.3 + 1.2 2.0 4.3 - 3.0.1 - 2.7.11 - 4.0.3.RELEASE + 3.1.0 + 3.0.0 + 4.0.6.RELEASE 1.7 - 3.1.0 - 3.2 + 3.2.2 + 3.3 4.2.6 - 2.3.3 + 2.4.1 + 0.9.9 4.1 @@ -144,7 +145,7 @@ com.fasterxml.jackson.core jackson-databind - ${jackson.version} + ${jackson.version}.1 com.fasterxml.jackson.core @@ -164,7 +165,7 @@ com.fasterxml aalto-xml - 0.9.9 + ${aalto-xml.version} @@ -195,11 +196,31 @@ javax.servlet-api ${servlet.version} + + org.apache.geronimo.specs + geronimo-javamail_1.4_spec + 1.7.1 + org.apache.cxf cxf-rt-frontend-jaxrs ${cxf.version} + + org.apache.cxf + cxf-rt-rs-client + ${cxf.version} + + + org.apache.cxf + cxf-rt-rs-security-oauth2 + ${cxf.version} + + + org.apache.cxf + cxf-rt-rs-extension-providers + ${cxf.version} + org.springframework spring-web @@ -256,6 +277,16 @@ + + org.codehaus.mojo + build-helper-maven-plugin + 1.9 + + + org.antlr + antlr4-maven-plugin + ${antlr.version} + com.keyboardsamurais.maven maven-timestamp-plugin @@ -274,130 +305,177 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 - - true - true - -Xlint:unchecked - + 2.3.2 - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 - - - - org.codehaus.cargo - cargo-maven2-plugin - 1.4.8 - - - tomcat7x - - http://archive.apache.org/dist/tomcat/tomcat-7/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip - ${settings.localRepository}/org/codehaus/cargo/cargo-container-archives - ${project.build.directory}/cargo/extract - - ${cargo.log} - ${cargo.output} - - - - org.apache.maven.plugins maven-surefire-plugin 2.17 - - true - alphabetical - UTF-8 - UTF-8 - UTF-8 - -Dfile.encoding=UTF-8 - org.apache.maven.plugins maven-failsafe-plugin 2.17 - - true - alphabetical - UTF-8 - UTF-8 - UTF-8 - -Dfile.encoding=UTF-8 - - - - integration-test - - integration-test - verify - - - - org.apache.maven.plugins maven-resources-plugin 2.6 - - UTF-8 - false - - ${*} - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.8 - - + org.sonatype.plugins jarjar-maven-plugin 1.9 - org.apache.maven.plugins maven-war-plugin 2.4 - org.apache.maven.plugins maven-invoker-plugin 1.8 - org.apache.maven.plugins maven-javadoc-plugin 2.9.1 + + org.codehaus.cargo + cargo-maven2-plugin + 1.4.8 + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + verify + + jar-no-fork + + + + + + maven-remote-resources-plugin + + + + process + + + + Apache Olingo + + + org.apache:apache-jar-resource-bundle:1.4 + + + + + + + maven-war-plugin + + + + + ${project.build.directory}/maven-shared-archive-resources + + META-INF/* + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + alphabetical + UTF-8 + UTF-8 + UTF-8 + -Dfile.encoding=UTF-8 + + + + org.apache.maven.plugins + maven-failsafe-plugin + + true + alphabetical + UTF-8 + UTF-8 + UTF-8 + -Dfile.encoding=UTF-8 + + + + integration-test + + integration-test + verify + + + + + + org.apache.maven.plugins + maven-resources-plugin + + UTF-8 + false + + ${*} + + + + + org.codehaus.cargo + cargo-maven2-plugin + + + tomcat7x + + http://archive.apache.org/dist/tomcat/tomcat-7/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip + ${settings.localRepository}/org/codehaus/cargo/cargo-container-archives + ${project.build.directory}/cargo/extract + + ${cargo.log} + ${cargo.output} + + + org.apache.maven.plugins maven-compiler-plugin 1.6 1.6 + true + true + -Xlint:unchecked org.apache.maven.plugins maven-eclipse-plugin + 2.9 true true @@ -486,30 +564,43 @@ - javadocs - + apache-release - javadoc:aggregate - org.apache.maven.plugins maven-javadoc-plugin - true - - javadocs - true - true - - http://docs.oracle.com/javaee/6/api/ - http://www.slf4j.org/api/ - http://commons.apache.org/proper/commons-lang/javadocs/api-release/ - http://commons.apache.org/proper/commons-io/javadocs/api-release/ - http://commons.apache.org/proper/commons-codec/archives/1.9/apidocs/ - http://www.viste.com/Java/Language/http-client/httpcomponents-client-4.2.3-bin/httpcomponents-client-4.2.3/javadoc/ - http://fasterxml.github.io/jackson-databind/javadoc/2.3.0/ - - + + + javadoc-jar + package + + aggregate-jar + + + + org.apache.olingo.commons.core:org.apache.olingo.commons.core.*:org.apache.olingo.client.core:org.apache.olingo.client.core.*:org.apache.olingo.server.core:org.apache.olingo.server.core.*:org.apache.olingo.fit:org.apache.olingo.fit.* + + + -quiet + + + + OData Client + org.apache.olingo.client.api:org.apache.olingo.client.api.* + + + OData Server + org.apache.olingo.server.api:org.apache.olingo.server.api.* + + + OData Commons + org.apache.olingo.commons.api:org.apache.olingo.commons.api.* + + + + +