Compare commits
60 Commits
Author | SHA1 | Date |
---|---|---|
|
eec32da4d7 | |
|
b3af1e29f8 | |
|
74cb5bdaa5 | |
|
0d7b341f8e | |
|
88d588b29c | |
|
4bd280b1c5 | |
|
d615a454bb | |
|
1da0e27c42 | |
|
2be6f3b7fd | |
|
8573d2c6e3 | |
|
66ce9b8a23 | |
|
b4bbaf8816 | |
|
6ef9d93725 | |
|
f4c942ddb6 | |
|
e9af3d2d23 | |
|
2ea1c4f820 | |
|
a26f583a0e | |
|
86509bb7c3 | |
|
60b9690890 | |
|
744a92db82 | |
|
b565aab839 | |
|
b84ac8b29b | |
|
3a6e2fc2ef | |
|
5b8695ba58 | |
|
ef270edbd5 | |
|
f027923cdf | |
|
93569cd265 | |
|
8948534883 | |
|
9b4ff9774b | |
|
3308729be3 | |
|
a2b242d631 | |
|
d92bc514f0 | |
|
2cb8acd620 | |
|
e538b00c52 | |
|
8b1325cb1d | |
|
8fd1bbf4f4 | |
|
6ea1ce9eb6 | |
|
cba7557176 | |
|
8fd96259d1 | |
|
ceb65c5016 | |
|
2299ba14ca | |
|
bed2e8a839 | |
|
956d8f1b15 | |
|
74d55bc5ba | |
|
842aaee8fb | |
|
5313355ec4 | |
|
f0ac9586b7 | |
|
b0037e99f7 | |
|
202d342696 | |
|
555a101888 | |
|
84bf1513c4 | |
|
29b6095d54 | |
|
b262824bfa | |
|
bdcb217e65 | |
|
a019b08860 | |
|
dcd653c36a | |
|
30fbd2cca5 | |
|
0811c73896 | |
|
e3c4cdac3b | |
|
bf6dc1970b |
|
@ -1,5 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
token.*
|
||||||
|
.svn
|
||||||
|
target
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
/.DS_Store
|
23
.project
23
.project
|
@ -1,23 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>gxREST</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,2 +0,0 @@
|
||||||
eclipse.preferences.version=1
|
|
||||||
encoding/<project>=UTF-8
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
# Changelog for gxREST
|
||||||
|
|
||||||
|
## [v2.0.0-SNAPSHOT]
|
||||||
|
|
||||||
|
- removed all the old providers
|
||||||
|
- removed set of gcube headers
|
||||||
|
- removed isExtCall because authorization headers are not added automatically anymore
|
||||||
|
|
||||||
|
## [v1.2.0]
|
||||||
|
|
||||||
|
- Managing new UMA token and not only old authz gcube token [#21525]
|
||||||
|
- Switched JSON management to gcube-jackson [#19737]
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.3] [r4.20.0] - 2019-10-19
|
||||||
|
|
||||||
|
- Allow clients to set secure protocol
|
||||||
|
- Switch from TLSv1 to TLSv1.2
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.2] [r4.20.0] - 2019-10-19
|
||||||
|
|
||||||
|
- Migration to Git
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.1] [r4.0.0] - 2019-03-30
|
||||||
|
|
||||||
|
- Allow to set the media type for the returned entity in the Error Response.
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.0] [r4.13.1] - 2019-02-26
|
||||||
|
|
||||||
|
- ...
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.0.1] [r4.13.0] - 2018-11-20
|
||||||
|
|
||||||
|
- ...
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.0.0] [r4.12.0] - 2018-06-20
|
||||||
|
|
||||||
|
- First Release
|
||||||
|
|
|
@ -0,0 +1,312 @@
|
||||||
|
# European Union Public Licence V. 1.1
|
||||||
|
|
||||||
|
|
||||||
|
EUPL © the European Community 2007
|
||||||
|
|
||||||
|
|
||||||
|
This European Union Public Licence (the “EUPL”) applies to the Work or Software
|
||||||
|
(as defined below) which is provided under the terms of this Licence. Any use of
|
||||||
|
the Work, other than as authorised under this Licence is prohibited (to the
|
||||||
|
extent such use is covered by a right of the copyright holder of the Work).
|
||||||
|
|
||||||
|
The Original Work is provided under the terms of this Licence when the Licensor
|
||||||
|
(as defined below) has placed the following notice immediately following the
|
||||||
|
copyright notice for the Original Work:
|
||||||
|
|
||||||
|
Licensed under the EUPL V.1.1
|
||||||
|
|
||||||
|
or has expressed by any other mean his willingness to license under the EUPL.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 1. Definitions
|
||||||
|
|
||||||
|
In this Licence, the following terms have the following meaning:
|
||||||
|
|
||||||
|
- The Licence: this Licence.
|
||||||
|
|
||||||
|
- The Original Work or the Software: the software distributed and/or
|
||||||
|
communicated by the Licensor under this Licence, available as Source Code and
|
||||||
|
also as Executable Code as the case may be.
|
||||||
|
|
||||||
|
- Derivative Works: the works or software that could be created by the Licensee,
|
||||||
|
based upon the Original Work or modifications thereof. This Licence does not
|
||||||
|
define the extent of modification or dependence on the Original Work required
|
||||||
|
in order to classify a work as a Derivative Work; this extent is determined by
|
||||||
|
copyright law applicable in the country mentioned in Article 15.
|
||||||
|
|
||||||
|
- The Work: the Original Work and/or its Derivative Works.
|
||||||
|
|
||||||
|
- The Source Code: the human-readable form of the Work which is the most
|
||||||
|
convenient for people to study and modify.
|
||||||
|
|
||||||
|
- The Executable Code: any code which has generally been compiled and which is
|
||||||
|
meant to be interpreted by a computer as a program.
|
||||||
|
|
||||||
|
- The Licensor: the natural or legal person that distributes and/or communicates
|
||||||
|
the Work under the Licence.
|
||||||
|
|
||||||
|
- Contributor(s): any natural or legal person who modifies the Work under the
|
||||||
|
Licence, or otherwise contributes to the creation of a Derivative Work.
|
||||||
|
|
||||||
|
- The Licensee or “You”: any natural or legal person who makes any usage of the
|
||||||
|
Software under the terms of the Licence.
|
||||||
|
|
||||||
|
- Distribution and/or Communication: any act of selling, giving, lending,
|
||||||
|
renting, distributing, communicating, transmitting, or otherwise making
|
||||||
|
available, on-line or off-line, copies of the Work or providing access to its
|
||||||
|
essential functionalities at the disposal of any other natural or legal
|
||||||
|
person.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 2. Scope of the rights granted by the Licence
|
||||||
|
|
||||||
|
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive,
|
||||||
|
sub-licensable licence to do the following, for the duration of copyright vested
|
||||||
|
in the Original Work:
|
||||||
|
|
||||||
|
- use the Work in any circumstance and for all usage, reproduce the Work, modify
|
||||||
|
- the Original Work, and make Derivative Works based upon the Work, communicate
|
||||||
|
- to the public, including the right to make available or display the Work or
|
||||||
|
- copies thereof to the public and perform publicly, as the case may be, the
|
||||||
|
- Work, distribute the Work or copies thereof, lend and rent the Work or copies
|
||||||
|
- thereof, sub-license rights in the Work or copies thereof.
|
||||||
|
|
||||||
|
Those rights can be exercised on any media, supports and formats, whether now
|
||||||
|
known or later invented, as far as the applicable law permits so.
|
||||||
|
|
||||||
|
In the countries where moral rights apply, the Licensor waives his right to
|
||||||
|
exercise his moral right to the extent allowed by law in order to make effective
|
||||||
|
the licence of the economic rights here above listed.
|
||||||
|
|
||||||
|
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to
|
||||||
|
any patents held by the Licensor, to the extent necessary to make use of the
|
||||||
|
rights granted on the Work under this Licence.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 3. Communication of the Source Code
|
||||||
|
|
||||||
|
The Licensor may provide the Work either in its Source Code form, or as
|
||||||
|
Executable Code. If the Work is provided as Executable Code, the Licensor
|
||||||
|
provides in addition a machine-readable copy of the Source Code of the Work
|
||||||
|
along with each copy of the Work that the Licensor distributes or indicates, in
|
||||||
|
a notice following the copyright notice attached to the Work, a repository where
|
||||||
|
the Source Code is easily and freely accessible for as long as the Licensor
|
||||||
|
continues to distribute and/or communicate the Work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 4. Limitations on copyright
|
||||||
|
|
||||||
|
Nothing in this Licence is intended to deprive the Licensee of the benefits from
|
||||||
|
any exception or limitation to the exclusive rights of the rights owners in the
|
||||||
|
Original Work or Software, of the exhaustion of those rights or of other
|
||||||
|
applicable limitations thereto.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 5. Obligations of the Licensee
|
||||||
|
|
||||||
|
The grant of the rights mentioned above is subject to some restrictions and
|
||||||
|
obligations imposed on the Licensee. Those obligations are the following:
|
||||||
|
|
||||||
|
Attribution right: the Licensee shall keep intact all copyright, patent or
|
||||||
|
trademarks notices and all notices that refer to the Licence and to the
|
||||||
|
disclaimer of warranties. The Licensee must include a copy of such notices and a
|
||||||
|
copy of the Licence with every copy of the Work he/she distributes and/or
|
||||||
|
communicates. The Licensee must cause any Derivative Work to carry prominent
|
||||||
|
notices stating that the Work has been modified and the date of modification.
|
||||||
|
|
||||||
|
Copyleft clause: If the Licensee distributes and/or communicates copies of the
|
||||||
|
Original Works or Derivative Works based upon the Original Work, this
|
||||||
|
Distribution and/or Communication will be done under the terms of this Licence
|
||||||
|
or of a later version of this Licence unless the Original Work is expressly
|
||||||
|
distributed only under this version of the Licence. The Licensee (becoming
|
||||||
|
Licensor) cannot offer or impose any additional terms or conditions on the Work
|
||||||
|
or Derivative Work that alter or restrict the terms of the Licence.
|
||||||
|
|
||||||
|
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative
|
||||||
|
Works or copies thereof based upon both the Original Work and another work
|
||||||
|
licensed under a Compatible Licence, this Distribution and/or Communication can
|
||||||
|
be done under the terms of this Compatible Licence. For the sake of this clause,
|
||||||
|
“Compatible Licence” refers to the licences listed in the appendix attached to
|
||||||
|
this Licence. Should the Licensee’s obligations under the Compatible Licence
|
||||||
|
conflict with his/her obligations under this Licence, the obligations of the
|
||||||
|
Compatible Licence shall prevail.
|
||||||
|
|
||||||
|
Provision of Source Code: When distributing and/or communicating copies of the
|
||||||
|
Work, the Licensee will provide a machine-readable copy of the Source Code or
|
||||||
|
indicate a repository where this Source will be easily and freely available for
|
||||||
|
as long as the Licensee continues to distribute and/or communicate the Work.
|
||||||
|
|
||||||
|
Legal Protection: This Licence does not grant permission to use the trade names,
|
||||||
|
trademarks, service marks, or 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 copyright notice.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 6. Chain of Authorship
|
||||||
|
|
||||||
|
The original Licensor warrants that the copyright in the Original Work granted
|
||||||
|
hereunder is owned by him/her or licensed to him/her and that he/she has the
|
||||||
|
power and authority to grant the Licence.
|
||||||
|
|
||||||
|
Each Contributor warrants that the copyright in the modifications he/she brings
|
||||||
|
to the Work are owned by him/her or licensed to him/her and that he/she has the
|
||||||
|
power and authority to grant the Licence.
|
||||||
|
|
||||||
|
Each time You accept the Licence, the original Licensor and subsequent
|
||||||
|
Contributors grant You a licence to their contributions to the Work, under the
|
||||||
|
terms of this Licence.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 7. Disclaimer of Warranty
|
||||||
|
|
||||||
|
The Work is a work in progress, which is continuously improved by numerous
|
||||||
|
contributors. It is not a finished work and may therefore contain defects or
|
||||||
|
“bugs” inherent to this type of software development.
|
||||||
|
|
||||||
|
For the above reason, the Work is provided under the Licence on an “as is” basis
|
||||||
|
and without warranties of any kind concerning the Work, including without
|
||||||
|
limitation merchantability, fitness for a particular purpose, absence of defects
|
||||||
|
or errors, accuracy, non-infringement of intellectual property rights other than
|
||||||
|
copyright as stated in Article 6 of this Licence.
|
||||||
|
|
||||||
|
This disclaimer of warranty is an essential part of the Licence and a condition
|
||||||
|
for the grant of any rights to the Work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 8. Disclaimer of Liability
|
||||||
|
|
||||||
|
Except in the cases of wilful misconduct or damages directly caused to natural
|
||||||
|
persons, the Licensor will in no event be liable for any direct or indirect,
|
||||||
|
material or moral, damages of any kind, arising out of the Licence or of the use
|
||||||
|
of the Work, including without limitation, damages for loss of goodwill, work
|
||||||
|
stoppage, computer failure or malfunction, loss of data or any commercial
|
||||||
|
damage, even if the Licensor has been advised of the possibility of such
|
||||||
|
damage. However, the Licensor will be liable under statutory product liability
|
||||||
|
laws as far such laws apply to the Work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 9. Additional agreements
|
||||||
|
|
||||||
|
While distributing the Original Work or Derivative Works, You may choose to
|
||||||
|
conclude an additional agreement to offer, and charge a fee for, acceptance of
|
||||||
|
support, warranty, indemnity, or other liability obligations and/or services
|
||||||
|
consistent with this Licence. However, in accepting such obligations, You may
|
||||||
|
act only on your own behalf and on your sole responsibility, not on behalf of
|
||||||
|
the original Licensor or 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 the fact You have accepted
|
||||||
|
any such warranty or additional liability.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 10. Acceptance of the Licence
|
||||||
|
|
||||||
|
The provisions of this Licence can be accepted by clicking on an icon “I agree”
|
||||||
|
placed under the bottom of a window displaying the text of this Licence or by
|
||||||
|
affirming consent in any other similar way, in accordance with the rules of
|
||||||
|
applicable law. Clicking on that icon indicates your clear and irrevocable
|
||||||
|
acceptance of this Licence and all of its terms and conditions.
|
||||||
|
|
||||||
|
Similarly, you irrevocably accept this Licence and all of its terms and
|
||||||
|
conditions by exercising any rights granted to You by Article 2 of this Licence,
|
||||||
|
such as the use of the Work, the creation by You of a Derivative Work or the
|
||||||
|
Distribution and/or Communication by You of the Work or copies thereof.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 11. Information to the public
|
||||||
|
|
||||||
|
In case of any Distribution and/or Communication of the Work by means of
|
||||||
|
electronic communication by You (for example, by offering to download the Work
|
||||||
|
from a remote location) the distribution channel or media (for example, a
|
||||||
|
website) must at least provide to the public the information requested by the
|
||||||
|
applicable law regarding the Licensor, the Licence and the way it may be
|
||||||
|
accessible, concluded, stored and reproduced by the Licensee.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 12. Termination of the Licence
|
||||||
|
|
||||||
|
The Licence and the rights granted hereunder will terminate automatically upon
|
||||||
|
any breach by the Licensee of the terms of the Licence.
|
||||||
|
|
||||||
|
Such a termination will not terminate the licences of any person who has
|
||||||
|
received the Work from the Licensee under the Licence, provided such persons
|
||||||
|
remain in full compliance with the Licence.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 13. Miscellaneous
|
||||||
|
|
||||||
|
Without prejudice of Article 9 above, the Licence represents the complete
|
||||||
|
agreement between the Parties as to the Work licensed hereunder.
|
||||||
|
|
||||||
|
If any provision of the Licence is invalid or unenforceable under applicable
|
||||||
|
law, this will not affect the validity or enforceability of the Licence as a
|
||||||
|
whole. Such provision will be construed and/or reformed so as necessary to make
|
||||||
|
it valid and enforceable.
|
||||||
|
|
||||||
|
The European Commission may publish other linguistic versions and/or new
|
||||||
|
versions of this Licence, so far this is required and reasonable, without
|
||||||
|
reducing the scope of the rights granted by the Licence. New versions of the
|
||||||
|
Licence will be published with a unique version number.
|
||||||
|
|
||||||
|
All linguistic versions of this Licence, approved by the European Commission,
|
||||||
|
have identical value. Parties can take advantage of the linguistic version of
|
||||||
|
their choice.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 14. Jurisdiction
|
||||||
|
|
||||||
|
Any litigation resulting from the interpretation of this License, arising
|
||||||
|
between the European Commission, as a Licensor, and any Licensee, will be
|
||||||
|
subject to the jurisdiction of the Court of Justice of the European Communities,
|
||||||
|
as laid down in article 238 of the Treaty establishing the European Community.
|
||||||
|
|
||||||
|
Any litigation arising between Parties, other than the European Commission, and
|
||||||
|
resulting from the interpretation of this License, will be subject to the
|
||||||
|
exclusive jurisdiction of the competent court where the Licensor resides or
|
||||||
|
conducts its primary business.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 15. Applicable Law
|
||||||
|
|
||||||
|
This Licence shall be governed by the law of the European Union country where
|
||||||
|
the Licensor resides or has his registered office.
|
||||||
|
|
||||||
|
This licence shall be governed by the Belgian law if:
|
||||||
|
|
||||||
|
- a litigation arises between the European Commission, as a Licensor, and any
|
||||||
|
- Licensee; the Licensor, other than the European Commission, has no residence
|
||||||
|
- or registered office inside a European Union country.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Appendix
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
“Compatible Licences” according to article 5 EUPL are:
|
||||||
|
|
||||||
|
|
||||||
|
- GNU General Public License (GNU GPL) v. 2
|
||||||
|
|
||||||
|
- Open Software License (OSL) v. 2.1, v. 3.0
|
||||||
|
|
||||||
|
- Common Public License v. 1.0
|
||||||
|
|
||||||
|
- Eclipse Public License v. 1.0
|
||||||
|
|
||||||
|
- Cecill v. 2.0
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
# gxREST
|
||||||
|
|
||||||
|
|
||||||
|
The gCube eXtensions to the Rest Protocol (gxRest) is a set of Java libraries designed to provide convenient round-trip interaction between a Restful web application (also known as "service") and its clients.
|
||||||
|
|
||||||
|
gxRest has the flexibility for different degrees of exploitation:
|
||||||
|
* it can be entirely adopted both at client and service side with full benefit of its conventions;
|
||||||
|
* it can be used to send REST requests based only on plain HTTP;
|
||||||
|
* it can be used only to return HTTP code/messagess from the service;
|
||||||
|
* it can be used only to throw Exceptions from the service to the client.
|
||||||
|
|
||||||
|
## Examples of use
|
||||||
|
|
||||||
|
Sending a request:
|
||||||
|
```java
|
||||||
|
GXHTTPRequest request = GXHTTPRequest.newRequest("http://host:port/service/").from("GXRequestTest");
|
||||||
|
|
||||||
|
//prepare some parameters
|
||||||
|
String context ="...";
|
||||||
|
Map<String,String> queryParams = new WeakHashMap<>();
|
||||||
|
queryParams.put("param name", "param value");
|
||||||
|
GXInboundResponse response = request.path("context")
|
||||||
|
.queryParams(queryParams).withBody(context).post();
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Returning a success response:
|
||||||
|
```java
|
||||||
|
@POST
|
||||||
|
public Response create(...) {
|
||||||
|
|
||||||
|
//Resource successfully created
|
||||||
|
|
||||||
|
URI location = ... //URI of the new resource
|
||||||
|
return GXOutboundSuccessResponse.newCREATEResponse(location)
|
||||||
|
.withMessage("Resource successfully created.")
|
||||||
|
.ofType(MediaType.APPLICATION_JSON)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Throwing an exception:
|
||||||
|
```java
|
||||||
|
@POST
|
||||||
|
public Response create(...) {
|
||||||
|
|
||||||
|
//Oh no, something failed here
|
||||||
|
GXOutboundErrorResponse.throwException(new MyCustomException("Resource already exists."));
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Parsing a response
|
||||||
|
```java
|
||||||
|
// invoke the remote method and get a response.
|
||||||
|
GXInboundResponse response = ...;
|
||||||
|
if (response.hasException())
|
||||||
|
throw response.getException();
|
||||||
|
//assuming a created (200) code was expected
|
||||||
|
if (response.hasCREATEDCode()) {
|
||||||
|
System.out.println("Resource successfully created!");
|
||||||
|
}
|
||||||
|
//access content as string
|
||||||
|
String value = response.getStreamedContentAsString();
|
||||||
|
//unmasharll content as json
|
||||||
|
Context returnedContext = response.tryConvertStreamedContentFromJson(Context.class);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Modules
|
||||||
|
* [gxHTTP](https://wiki.gcube-system.org/gcube/GxRest/GxHTTP)
|
||||||
|
* [gxJRS](https://wiki.gcube-system.org/gcube/GxRest/GxJRS)
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
Notes about how to deploy this component on an infrastructure or link to wiki doc (if any).
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
See gxRest on [Wiki](https://wiki.gcube-system.org/gcube/GxRest).
|
||||||
|
|
||||||
|
## Built With
|
||||||
|
|
||||||
|
* [JAX-RS](https://github.com/eclipse-ee4j/jaxrs-api) - Java™ API for RESTful Web Services
|
||||||
|
* [Jersey](https://jersey.github.io/) - JAX-RS runtime
|
||||||
|
* [Maven](https://maven.apache.org/) - Dependency Management
|
||||||
|
|
||||||
|
## License
|
||||||
|
TBP
|
|
@ -1,36 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
|
||||||
</classpath>
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
/.classpath
|
||||||
|
/bin/
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
target/
|
|
@ -1,23 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>gxHTTP</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,6 +0,0 @@
|
||||||
eclipse.preferences.version=1
|
|
||||||
encoding//src/main/java=UTF-8
|
|
||||||
encoding//src/main/resources=UTF-8
|
|
||||||
encoding//src/test/java=UTF-8
|
|
||||||
encoding//src/test/resources=UTF-8
|
|
||||||
encoding/<project>=UTF-8
|
|
|
@ -1,5 +0,0 @@
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
# Changelog for gxHTTP
|
||||||
|
|
||||||
|
## [v2.0.0-SNAPSHOT]
|
||||||
|
|
||||||
|
- removed all the old providers
|
||||||
|
- removed set of gcube headers
|
||||||
|
- removed isExtCall because authorization headers are not added automatically anymore
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.2.0]
|
||||||
|
|
||||||
|
- Managing new UMA token and not only old authz gcube token [#21525]
|
||||||
|
- Switched JSON management to gcube-jackson [#19737]
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.3] [r4.20.0] - 2019-10-19
|
||||||
|
|
||||||
|
- Allow clients to set secure protocol
|
||||||
|
- Switch from TLSv1 to TLSv1.2
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.2] [r4.20.0] - 2019-10-19
|
||||||
|
|
||||||
|
- Migration to Git
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.1] [r4.0.0] - 2019-03-30
|
||||||
|
|
||||||
|
- Allow to set the media type for the returned entity in the Error Response.
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.0] [r4.13.1] - 2019-02-26
|
||||||
|
|
||||||
|
- ...
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.0.1] [r4.13.0] - 2018-11-20
|
||||||
|
|
||||||
|
- ...
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.0.0] [r4.12.0] - 2018-06-20
|
||||||
|
|
||||||
|
- First Release
|
|
@ -0,0 +1,312 @@
|
||||||
|
# European Union Public Licence V. 1.1
|
||||||
|
|
||||||
|
|
||||||
|
EUPL © the European Community 2007
|
||||||
|
|
||||||
|
|
||||||
|
This European Union Public Licence (the “EUPL”) applies to the Work or Software
|
||||||
|
(as defined below) which is provided under the terms of this Licence. Any use of
|
||||||
|
the Work, other than as authorised under this Licence is prohibited (to the
|
||||||
|
extent such use is covered by a right of the copyright holder of the Work).
|
||||||
|
|
||||||
|
The Original Work is provided under the terms of this Licence when the Licensor
|
||||||
|
(as defined below) has placed the following notice immediately following the
|
||||||
|
copyright notice for the Original Work:
|
||||||
|
|
||||||
|
Licensed under the EUPL V.1.1
|
||||||
|
|
||||||
|
or has expressed by any other mean his willingness to license under the EUPL.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 1. Definitions
|
||||||
|
|
||||||
|
In this Licence, the following terms have the following meaning:
|
||||||
|
|
||||||
|
- The Licence: this Licence.
|
||||||
|
|
||||||
|
- The Original Work or the Software: the software distributed and/or
|
||||||
|
communicated by the Licensor under this Licence, available as Source Code and
|
||||||
|
also as Executable Code as the case may be.
|
||||||
|
|
||||||
|
- Derivative Works: the works or software that could be created by the Licensee,
|
||||||
|
based upon the Original Work or modifications thereof. This Licence does not
|
||||||
|
define the extent of modification or dependence on the Original Work required
|
||||||
|
in order to classify a work as a Derivative Work; this extent is determined by
|
||||||
|
copyright law applicable in the country mentioned in Article 15.
|
||||||
|
|
||||||
|
- The Work: the Original Work and/or its Derivative Works.
|
||||||
|
|
||||||
|
- The Source Code: the human-readable form of the Work which is the most
|
||||||
|
convenient for people to study and modify.
|
||||||
|
|
||||||
|
- The Executable Code: any code which has generally been compiled and which is
|
||||||
|
meant to be interpreted by a computer as a program.
|
||||||
|
|
||||||
|
- The Licensor: the natural or legal person that distributes and/or communicates
|
||||||
|
the Work under the Licence.
|
||||||
|
|
||||||
|
- Contributor(s): any natural or legal person who modifies the Work under the
|
||||||
|
Licence, or otherwise contributes to the creation of a Derivative Work.
|
||||||
|
|
||||||
|
- The Licensee or “You”: any natural or legal person who makes any usage of the
|
||||||
|
Software under the terms of the Licence.
|
||||||
|
|
||||||
|
- Distribution and/or Communication: any act of selling, giving, lending,
|
||||||
|
renting, distributing, communicating, transmitting, or otherwise making
|
||||||
|
available, on-line or off-line, copies of the Work or providing access to its
|
||||||
|
essential functionalities at the disposal of any other natural or legal
|
||||||
|
person.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 2. Scope of the rights granted by the Licence
|
||||||
|
|
||||||
|
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive,
|
||||||
|
sub-licensable licence to do the following, for the duration of copyright vested
|
||||||
|
in the Original Work:
|
||||||
|
|
||||||
|
- use the Work in any circumstance and for all usage, reproduce the Work, modify
|
||||||
|
- the Original Work, and make Derivative Works based upon the Work, communicate
|
||||||
|
- to the public, including the right to make available or display the Work or
|
||||||
|
- copies thereof to the public and perform publicly, as the case may be, the
|
||||||
|
- Work, distribute the Work or copies thereof, lend and rent the Work or copies
|
||||||
|
- thereof, sub-license rights in the Work or copies thereof.
|
||||||
|
|
||||||
|
Those rights can be exercised on any media, supports and formats, whether now
|
||||||
|
known or later invented, as far as the applicable law permits so.
|
||||||
|
|
||||||
|
In the countries where moral rights apply, the Licensor waives his right to
|
||||||
|
exercise his moral right to the extent allowed by law in order to make effective
|
||||||
|
the licence of the economic rights here above listed.
|
||||||
|
|
||||||
|
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to
|
||||||
|
any patents held by the Licensor, to the extent necessary to make use of the
|
||||||
|
rights granted on the Work under this Licence.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 3. Communication of the Source Code
|
||||||
|
|
||||||
|
The Licensor may provide the Work either in its Source Code form, or as
|
||||||
|
Executable Code. If the Work is provided as Executable Code, the Licensor
|
||||||
|
provides in addition a machine-readable copy of the Source Code of the Work
|
||||||
|
along with each copy of the Work that the Licensor distributes or indicates, in
|
||||||
|
a notice following the copyright notice attached to the Work, a repository where
|
||||||
|
the Source Code is easily and freely accessible for as long as the Licensor
|
||||||
|
continues to distribute and/or communicate the Work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 4. Limitations on copyright
|
||||||
|
|
||||||
|
Nothing in this Licence is intended to deprive the Licensee of the benefits from
|
||||||
|
any exception or limitation to the exclusive rights of the rights owners in the
|
||||||
|
Original Work or Software, of the exhaustion of those rights or of other
|
||||||
|
applicable limitations thereto.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 5. Obligations of the Licensee
|
||||||
|
|
||||||
|
The grant of the rights mentioned above is subject to some restrictions and
|
||||||
|
obligations imposed on the Licensee. Those obligations are the following:
|
||||||
|
|
||||||
|
Attribution right: the Licensee shall keep intact all copyright, patent or
|
||||||
|
trademarks notices and all notices that refer to the Licence and to the
|
||||||
|
disclaimer of warranties. The Licensee must include a copy of such notices and a
|
||||||
|
copy of the Licence with every copy of the Work he/she distributes and/or
|
||||||
|
communicates. The Licensee must cause any Derivative Work to carry prominent
|
||||||
|
notices stating that the Work has been modified and the date of modification.
|
||||||
|
|
||||||
|
Copyleft clause: If the Licensee distributes and/or communicates copies of the
|
||||||
|
Original Works or Derivative Works based upon the Original Work, this
|
||||||
|
Distribution and/or Communication will be done under the terms of this Licence
|
||||||
|
or of a later version of this Licence unless the Original Work is expressly
|
||||||
|
distributed only under this version of the Licence. The Licensee (becoming
|
||||||
|
Licensor) cannot offer or impose any additional terms or conditions on the Work
|
||||||
|
or Derivative Work that alter or restrict the terms of the Licence.
|
||||||
|
|
||||||
|
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative
|
||||||
|
Works or copies thereof based upon both the Original Work and another work
|
||||||
|
licensed under a Compatible Licence, this Distribution and/or Communication can
|
||||||
|
be done under the terms of this Compatible Licence. For the sake of this clause,
|
||||||
|
“Compatible Licence” refers to the licences listed in the appendix attached to
|
||||||
|
this Licence. Should the Licensee’s obligations under the Compatible Licence
|
||||||
|
conflict with his/her obligations under this Licence, the obligations of the
|
||||||
|
Compatible Licence shall prevail.
|
||||||
|
|
||||||
|
Provision of Source Code: When distributing and/or communicating copies of the
|
||||||
|
Work, the Licensee will provide a machine-readable copy of the Source Code or
|
||||||
|
indicate a repository where this Source will be easily and freely available for
|
||||||
|
as long as the Licensee continues to distribute and/or communicate the Work.
|
||||||
|
|
||||||
|
Legal Protection: This Licence does not grant permission to use the trade names,
|
||||||
|
trademarks, service marks, or 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 copyright notice.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 6. Chain of Authorship
|
||||||
|
|
||||||
|
The original Licensor warrants that the copyright in the Original Work granted
|
||||||
|
hereunder is owned by him/her or licensed to him/her and that he/she has the
|
||||||
|
power and authority to grant the Licence.
|
||||||
|
|
||||||
|
Each Contributor warrants that the copyright in the modifications he/she brings
|
||||||
|
to the Work are owned by him/her or licensed to him/her and that he/she has the
|
||||||
|
power and authority to grant the Licence.
|
||||||
|
|
||||||
|
Each time You accept the Licence, the original Licensor and subsequent
|
||||||
|
Contributors grant You a licence to their contributions to the Work, under the
|
||||||
|
terms of this Licence.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 7. Disclaimer of Warranty
|
||||||
|
|
||||||
|
The Work is a work in progress, which is continuously improved by numerous
|
||||||
|
contributors. It is not a finished work and may therefore contain defects or
|
||||||
|
“bugs” inherent to this type of software development.
|
||||||
|
|
||||||
|
For the above reason, the Work is provided under the Licence on an “as is” basis
|
||||||
|
and without warranties of any kind concerning the Work, including without
|
||||||
|
limitation merchantability, fitness for a particular purpose, absence of defects
|
||||||
|
or errors, accuracy, non-infringement of intellectual property rights other than
|
||||||
|
copyright as stated in Article 6 of this Licence.
|
||||||
|
|
||||||
|
This disclaimer of warranty is an essential part of the Licence and a condition
|
||||||
|
for the grant of any rights to the Work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 8. Disclaimer of Liability
|
||||||
|
|
||||||
|
Except in the cases of wilful misconduct or damages directly caused to natural
|
||||||
|
persons, the Licensor will in no event be liable for any direct or indirect,
|
||||||
|
material or moral, damages of any kind, arising out of the Licence or of the use
|
||||||
|
of the Work, including without limitation, damages for loss of goodwill, work
|
||||||
|
stoppage, computer failure or malfunction, loss of data or any commercial
|
||||||
|
damage, even if the Licensor has been advised of the possibility of such
|
||||||
|
damage. However, the Licensor will be liable under statutory product liability
|
||||||
|
laws as far such laws apply to the Work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 9. Additional agreements
|
||||||
|
|
||||||
|
While distributing the Original Work or Derivative Works, You may choose to
|
||||||
|
conclude an additional agreement to offer, and charge a fee for, acceptance of
|
||||||
|
support, warranty, indemnity, or other liability obligations and/or services
|
||||||
|
consistent with this Licence. However, in accepting such obligations, You may
|
||||||
|
act only on your own behalf and on your sole responsibility, not on behalf of
|
||||||
|
the original Licensor or 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 the fact You have accepted
|
||||||
|
any such warranty or additional liability.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 10. Acceptance of the Licence
|
||||||
|
|
||||||
|
The provisions of this Licence can be accepted by clicking on an icon “I agree”
|
||||||
|
placed under the bottom of a window displaying the text of this Licence or by
|
||||||
|
affirming consent in any other similar way, in accordance with the rules of
|
||||||
|
applicable law. Clicking on that icon indicates your clear and irrevocable
|
||||||
|
acceptance of this Licence and all of its terms and conditions.
|
||||||
|
|
||||||
|
Similarly, you irrevocably accept this Licence and all of its terms and
|
||||||
|
conditions by exercising any rights granted to You by Article 2 of this Licence,
|
||||||
|
such as the use of the Work, the creation by You of a Derivative Work or the
|
||||||
|
Distribution and/or Communication by You of the Work or copies thereof.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 11. Information to the public
|
||||||
|
|
||||||
|
In case of any Distribution and/or Communication of the Work by means of
|
||||||
|
electronic communication by You (for example, by offering to download the Work
|
||||||
|
from a remote location) the distribution channel or media (for example, a
|
||||||
|
website) must at least provide to the public the information requested by the
|
||||||
|
applicable law regarding the Licensor, the Licence and the way it may be
|
||||||
|
accessible, concluded, stored and reproduced by the Licensee.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 12. Termination of the Licence
|
||||||
|
|
||||||
|
The Licence and the rights granted hereunder will terminate automatically upon
|
||||||
|
any breach by the Licensee of the terms of the Licence.
|
||||||
|
|
||||||
|
Such a termination will not terminate the licences of any person who has
|
||||||
|
received the Work from the Licensee under the Licence, provided such persons
|
||||||
|
remain in full compliance with the Licence.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 13. Miscellaneous
|
||||||
|
|
||||||
|
Without prejudice of Article 9 above, the Licence represents the complete
|
||||||
|
agreement between the Parties as to the Work licensed hereunder.
|
||||||
|
|
||||||
|
If any provision of the Licence is invalid or unenforceable under applicable
|
||||||
|
law, this will not affect the validity or enforceability of the Licence as a
|
||||||
|
whole. Such provision will be construed and/or reformed so as necessary to make
|
||||||
|
it valid and enforceable.
|
||||||
|
|
||||||
|
The European Commission may publish other linguistic versions and/or new
|
||||||
|
versions of this Licence, so far this is required and reasonable, without
|
||||||
|
reducing the scope of the rights granted by the Licence. New versions of the
|
||||||
|
Licence will be published with a unique version number.
|
||||||
|
|
||||||
|
All linguistic versions of this Licence, approved by the European Commission,
|
||||||
|
have identical value. Parties can take advantage of the linguistic version of
|
||||||
|
their choice.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 14. Jurisdiction
|
||||||
|
|
||||||
|
Any litigation resulting from the interpretation of this License, arising
|
||||||
|
between the European Commission, as a Licensor, and any Licensee, will be
|
||||||
|
subject to the jurisdiction of the Court of Justice of the European Communities,
|
||||||
|
as laid down in article 238 of the Treaty establishing the European Community.
|
||||||
|
|
||||||
|
Any litigation arising between Parties, other than the European Commission, and
|
||||||
|
resulting from the interpretation of this License, will be subject to the
|
||||||
|
exclusive jurisdiction of the competent court where the Licensor resides or
|
||||||
|
conducts its primary business.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 15. Applicable Law
|
||||||
|
|
||||||
|
This Licence shall be governed by the law of the European Union country where
|
||||||
|
the Licensor resides or has his registered office.
|
||||||
|
|
||||||
|
This licence shall be governed by the Belgian law if:
|
||||||
|
|
||||||
|
- a litigation arises between the European Commission, as a Licensor, and any
|
||||||
|
- Licensee; the Licensor, other than the European Commission, has no residence
|
||||||
|
- or registered office inside a European Union country.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Appendix
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
“Compatible Licences” according to article 5 EUPL are:
|
||||||
|
|
||||||
|
|
||||||
|
- GNU General Public License (GNU GPL) v. 2
|
||||||
|
|
||||||
|
- Open Software License (OSL) v. 2.1, v. 3.0
|
||||||
|
|
||||||
|
- Common Public License v. 1.0
|
||||||
|
|
||||||
|
- Eclipse Public License v. 1.0
|
||||||
|
|
||||||
|
- Cecill v. 2.0
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
gxHTTP
|
||||||
|
----
|
||||||
|
The gCube eXtensions to the HTTP protocol.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
* [gxHTTP](https://wiki.gcube-system.org/gcube/GxRest/GxHTTP)
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
Notes about how to deploy this component on an infrastructure or link to wiki doc (if any).
|
||||||
|
|
||||||
|
## Built With
|
||||||
|
|
||||||
|
* [Jersey](https://jersey.github.io/) - JAX-RS runtime
|
||||||
|
* [Maven](https://maven.apache.org/) - Dependency Management
|
||||||
|
|
||||||
|
## License
|
||||||
|
See [LICENSE.md](LICENSE.md)
|
|
@ -7,11 +7,11 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>gxREST</artifactId>
|
<artifactId>gxREST</artifactId>
|
||||||
<version>1.1.2-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
<artifactId>gxHTTP</artifactId>
|
<artifactId>gxHTTP</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
<name>gCube eXtensions to REST with HTTP</name>
|
<name>gCube eXtensions to REST with HTTP</name>
|
||||||
<description>gCube eXtensions to REST based on HTTP</description>
|
<description>gCube eXtensions to REST based on HTTP</description>
|
||||||
|
|
||||||
|
@ -22,21 +22,15 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${parent.artifactId}/${project.artifactId}</connection>
|
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/gx-rest</connection>
|
||||||
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${parent.artifactId}/${project.artifactId}</developerConnection>
|
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/gx-rest</developerConnection>
|
||||||
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${parent.artifactId}/${project.artifactId}</url>
|
<url>https://code-repo.d4science.org/gCubeSystem/gx-rest</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
<artifactId>authorization-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -45,19 +39,5 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>make-servicearchive</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
||||||
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -52,8 +51,7 @@ public class GXConnection {
|
||||||
private String body;
|
private String body;
|
||||||
private InputStream bodyAsStream;
|
private InputStream bodyAsStream;
|
||||||
private Map<String, String> properties = new HashMap<>();
|
private Map<String, String> properties = new HashMap<>();
|
||||||
private boolean extCall = false;
|
|
||||||
|
|
||||||
public GXConnection(String address) {
|
public GXConnection(String address) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
@ -118,17 +116,12 @@ public class GXConnection {
|
||||||
public HttpURLConnection send(HTTPMETHOD method) throws Exception {
|
public HttpURLConnection send(HTTPMETHOD method) throws Exception {
|
||||||
return send(this.buildURL(), method);
|
return send(this.buildURL(), method);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpURLConnection send(URL url, HTTPMETHOD method) throws Exception {
|
private HttpURLConnection send(URL url, HTTPMETHOD method) throws Exception {
|
||||||
HttpURLConnection uConn = (HttpURLConnection) url.openConnection();
|
HttpURLConnection uConn = (HttpURLConnection) url.openConnection();
|
||||||
if (!this.extCall) {
|
|
||||||
String token = SecurityTokenProvider.instance.get();
|
//uConn = addGCubeAuthorizationToken(uConn);
|
||||||
if (Objects.isNull(token) || token.isEmpty())
|
|
||||||
throw new IllegalStateException("The security token in the current environment is null.");
|
|
||||||
|
|
||||||
uConn.setRequestProperty(org.gcube.common.authorization.client.Constants.TOKEN_HEADER_ENTRY,
|
|
||||||
token);
|
|
||||||
}
|
|
||||||
uConn.setDoOutput(true);
|
uConn.setDoOutput(true);
|
||||||
// uConn.setRequestProperty("Content-type", APPLICATION_JSON_CHARSET_UTF_8);
|
// uConn.setRequestProperty("Content-type", APPLICATION_JSON_CHARSET_UTF_8);
|
||||||
if(this.agent!=null) {
|
if(this.agent!=null) {
|
||||||
|
@ -172,7 +165,7 @@ public class GXConnection {
|
||||||
}
|
}
|
||||||
return uConn;
|
return uConn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private URL getURL(String urlString) throws MalformedURLException {
|
private URL getURL(String urlString) throws MalformedURLException {
|
||||||
URL url = new URL(urlString);
|
URL url = new URL(urlString);
|
||||||
if (url.getProtocol().equals("https")) {
|
if (url.getProtocol().equals("https")) {
|
||||||
|
@ -245,19 +238,5 @@ public class GXConnection {
|
||||||
public void setProperty(String name, String value) {
|
public void setProperty(String name, String value) {
|
||||||
this.properties.put(name, value);
|
this.properties.put(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param extCall the extCall to set
|
|
||||||
*/
|
|
||||||
public void setExtCall(boolean extCall) {
|
|
||||||
this.extCall = extCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the extCall
|
|
||||||
*/
|
|
||||||
public boolean isExtCall() {
|
|
||||||
return extCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,17 +85,6 @@ public interface GXHTTP<BODY,RESPONSE> {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
RESPONSE connect() throws Exception;
|
RESPONSE connect() throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* Overrides the default security token.
|
|
||||||
* @param token the new token
|
|
||||||
*/
|
|
||||||
void setSecurityToken(String token);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* States if the service being called in an external service (not gCube).
|
|
||||||
* @param ext true if external, false otherwise
|
|
||||||
*/
|
|
||||||
void isExternalCall(boolean ext);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import java.io.UnsupportedEncodingException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
|
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
|
||||||
* Builder for GXHTTP Requests.
|
* Builder for GXHTTP Requests.
|
||||||
*
|
*
|
||||||
* @author Manuele Simi (ISTI CNR)
|
* @author Manuele Simi (ISTI CNR)
|
||||||
|
* @author Luca Frosini (ISTI-CNR)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GXHTTPRequestBuilder {
|
public class GXHTTPRequestBuilder {
|
||||||
|
@ -74,19 +75,9 @@ public class GXHTTPRequestBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String UUID_REGEX = "^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}-[a-fA-F0-9]{8,9}){1}$";
|
||||||
|
|
||||||
/**
|
|
||||||
* Overrides the default security token.
|
|
||||||
*
|
|
||||||
* @param token
|
|
||||||
*/
|
|
||||||
public void setSecurityToken(String token) {
|
|
||||||
if (!this.connection.isExtCall())
|
|
||||||
this.connection.setProperty(org.gcube.common.authorization.client.Constants.TOKEN_HEADER_ENTRY, token);
|
|
||||||
else
|
|
||||||
throw new UnsupportedOperationException("Cannot set the security token on an external call");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add headers to the request.
|
* Add headers to the request.
|
||||||
*
|
*
|
||||||
|
@ -196,12 +187,4 @@ public class GXHTTPRequestBuilder {
|
||||||
return this.connection.send(HTTPMETHOD.CONNECT);
|
return this.connection.send(HTTPMETHOD.CONNECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.gcube.common.gxrest.request.GXHTTP#isExternalCall(boolean)
|
|
||||||
*/
|
|
||||||
public void isExternalCall(boolean ext) {
|
|
||||||
this.connection.setExtCall(ext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,20 +83,6 @@ class GXHTTPCommonRequest {
|
||||||
public HttpURLConnection connect() throws Exception {
|
public HttpURLConnection connect() throws Exception {
|
||||||
return builder.connect();
|
return builder.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.common.gxhttp.reference.GXHTTP#setSecurityToken(java.lang.String)
|
|
||||||
*/
|
|
||||||
public void setSecurityToken(String token) {
|
|
||||||
builder.setSecurityToken(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.common.gxhttp.reference.GXHTTP#isExternalCall(boolean)
|
|
||||||
*/
|
|
||||||
public void isExternalCall(boolean ext) {
|
|
||||||
builder.isExternalCall(ext);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear up the request.
|
* Clear up the request.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.common.gxhttp;
|
package org.gcube.common.gxhttp;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -9,15 +10,9 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.gcube.common.authorization.client.Constants;
|
|
||||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
||||||
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||||
import org.gcube.common.gxhttp.util.ContentUtils;
|
import org.gcube.common.gxhttp.util.ContentUtils;
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,30 +50,6 @@ public class GXHTTPStringRequestTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void beforeClass() throws Exception {
|
|
||||||
setContext(DEFAULT_TEST_SCOPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setContext(String token) throws ObjectNotFound, Exception {
|
|
||||||
if (DEFAULT_TEST_SCOPE.isEmpty()) {
|
|
||||||
skipTest = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SecurityTokenProvider.instance.set(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
|
||||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
|
||||||
String context = authorizationEntry.getContext();
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void afterClass() throws Exception {
|
|
||||||
SecurityTokenProvider.instance.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link org.gcube.common.gxhttp.request.GXHTTPStringRequest#newRequest(java.lang.String)}.
|
* Test method for {@link org.gcube.common.gxhttp.request.GXHTTPStringRequest#newRequest(java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
|
||||||
</classpath>
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
/.classpath
|
||||||
|
/bin/
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
target/
|
|
@ -1,23 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>gxRest</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,6 +0,0 @@
|
||||||
eclipse.preferences.version=1
|
|
||||||
encoding//src/main/java=UTF-8
|
|
||||||
encoding//src/main/resources=UTF-8
|
|
||||||
encoding//src/test/java=UTF-8
|
|
||||||
encoding//src/test/resources=UTF-8
|
|
||||||
encoding/<project>=UTF-8
|
|
|
@ -1,5 +0,0 @@
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
# Changelog for gxJRS
|
||||||
|
|
||||||
|
## [v2.0.0-SNAPSHOT]
|
||||||
|
|
||||||
|
- removed all the old providers
|
||||||
|
- removed set of gcube headers
|
||||||
|
- removed isExtCall because authorization headers are not added automatically anymore
|
||||||
|
|
||||||
|
## [v1.2.0]
|
||||||
|
|
||||||
|
- Managing new UMA token and not only old authz gcube token [#21525]
|
||||||
|
- Switched JSON management to gcube-jackson [#19737]
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.3] [r4.20.0] - 2019-10-19
|
||||||
|
|
||||||
|
- Allow clients to set secure protocol
|
||||||
|
- Switch from TLSv1 to TLSv1.2
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.2] [r4.20.0] - 2019-10-19
|
||||||
|
|
||||||
|
- Migration to Git
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.1] [r4.0.0] - 2019-03-30
|
||||||
|
|
||||||
|
- Allow to set the media type for the returned entity in the Error Response.
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.1.0] [r4.13.1] - 2019-02-26
|
||||||
|
|
||||||
|
- ...
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.0.1] [r4.13.0] - 2018-11-20
|
||||||
|
|
||||||
|
- ...
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.0.0] [r4.12.0] - 2018-06-20
|
||||||
|
|
||||||
|
- First Release
|
|
@ -0,0 +1,312 @@
|
||||||
|
# European Union Public Licence V. 1.1
|
||||||
|
|
||||||
|
|
||||||
|
EUPL © the European Community 2007
|
||||||
|
|
||||||
|
|
||||||
|
This European Union Public Licence (the “EUPL”) applies to the Work or Software
|
||||||
|
(as defined below) which is provided under the terms of this Licence. Any use of
|
||||||
|
the Work, other than as authorised under this Licence is prohibited (to the
|
||||||
|
extent such use is covered by a right of the copyright holder of the Work).
|
||||||
|
|
||||||
|
The Original Work is provided under the terms of this Licence when the Licensor
|
||||||
|
(as defined below) has placed the following notice immediately following the
|
||||||
|
copyright notice for the Original Work:
|
||||||
|
|
||||||
|
Licensed under the EUPL V.1.1
|
||||||
|
|
||||||
|
or has expressed by any other mean his willingness to license under the EUPL.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 1. Definitions
|
||||||
|
|
||||||
|
In this Licence, the following terms have the following meaning:
|
||||||
|
|
||||||
|
- The Licence: this Licence.
|
||||||
|
|
||||||
|
- The Original Work or the Software: the software distributed and/or
|
||||||
|
communicated by the Licensor under this Licence, available as Source Code and
|
||||||
|
also as Executable Code as the case may be.
|
||||||
|
|
||||||
|
- Derivative Works: the works or software that could be created by the Licensee,
|
||||||
|
based upon the Original Work or modifications thereof. This Licence does not
|
||||||
|
define the extent of modification or dependence on the Original Work required
|
||||||
|
in order to classify a work as a Derivative Work; this extent is determined by
|
||||||
|
copyright law applicable in the country mentioned in Article 15.
|
||||||
|
|
||||||
|
- The Work: the Original Work and/or its Derivative Works.
|
||||||
|
|
||||||
|
- The Source Code: the human-readable form of the Work which is the most
|
||||||
|
convenient for people to study and modify.
|
||||||
|
|
||||||
|
- The Executable Code: any code which has generally been compiled and which is
|
||||||
|
meant to be interpreted by a computer as a program.
|
||||||
|
|
||||||
|
- The Licensor: the natural or legal person that distributes and/or communicates
|
||||||
|
the Work under the Licence.
|
||||||
|
|
||||||
|
- Contributor(s): any natural or legal person who modifies the Work under the
|
||||||
|
Licence, or otherwise contributes to the creation of a Derivative Work.
|
||||||
|
|
||||||
|
- The Licensee or “You”: any natural or legal person who makes any usage of the
|
||||||
|
Software under the terms of the Licence.
|
||||||
|
|
||||||
|
- Distribution and/or Communication: any act of selling, giving, lending,
|
||||||
|
renting, distributing, communicating, transmitting, or otherwise making
|
||||||
|
available, on-line or off-line, copies of the Work or providing access to its
|
||||||
|
essential functionalities at the disposal of any other natural or legal
|
||||||
|
person.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 2. Scope of the rights granted by the Licence
|
||||||
|
|
||||||
|
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive,
|
||||||
|
sub-licensable licence to do the following, for the duration of copyright vested
|
||||||
|
in the Original Work:
|
||||||
|
|
||||||
|
- use the Work in any circumstance and for all usage, reproduce the Work, modify
|
||||||
|
- the Original Work, and make Derivative Works based upon the Work, communicate
|
||||||
|
- to the public, including the right to make available or display the Work or
|
||||||
|
- copies thereof to the public and perform publicly, as the case may be, the
|
||||||
|
- Work, distribute the Work or copies thereof, lend and rent the Work or copies
|
||||||
|
- thereof, sub-license rights in the Work or copies thereof.
|
||||||
|
|
||||||
|
Those rights can be exercised on any media, supports and formats, whether now
|
||||||
|
known or later invented, as far as the applicable law permits so.
|
||||||
|
|
||||||
|
In the countries where moral rights apply, the Licensor waives his right to
|
||||||
|
exercise his moral right to the extent allowed by law in order to make effective
|
||||||
|
the licence of the economic rights here above listed.
|
||||||
|
|
||||||
|
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to
|
||||||
|
any patents held by the Licensor, to the extent necessary to make use of the
|
||||||
|
rights granted on the Work under this Licence.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 3. Communication of the Source Code
|
||||||
|
|
||||||
|
The Licensor may provide the Work either in its Source Code form, or as
|
||||||
|
Executable Code. If the Work is provided as Executable Code, the Licensor
|
||||||
|
provides in addition a machine-readable copy of the Source Code of the Work
|
||||||
|
along with each copy of the Work that the Licensor distributes or indicates, in
|
||||||
|
a notice following the copyright notice attached to the Work, a repository where
|
||||||
|
the Source Code is easily and freely accessible for as long as the Licensor
|
||||||
|
continues to distribute and/or communicate the Work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 4. Limitations on copyright
|
||||||
|
|
||||||
|
Nothing in this Licence is intended to deprive the Licensee of the benefits from
|
||||||
|
any exception or limitation to the exclusive rights of the rights owners in the
|
||||||
|
Original Work or Software, of the exhaustion of those rights or of other
|
||||||
|
applicable limitations thereto.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 5. Obligations of the Licensee
|
||||||
|
|
||||||
|
The grant of the rights mentioned above is subject to some restrictions and
|
||||||
|
obligations imposed on the Licensee. Those obligations are the following:
|
||||||
|
|
||||||
|
Attribution right: the Licensee shall keep intact all copyright, patent or
|
||||||
|
trademarks notices and all notices that refer to the Licence and to the
|
||||||
|
disclaimer of warranties. The Licensee must include a copy of such notices and a
|
||||||
|
copy of the Licence with every copy of the Work he/she distributes and/or
|
||||||
|
communicates. The Licensee must cause any Derivative Work to carry prominent
|
||||||
|
notices stating that the Work has been modified and the date of modification.
|
||||||
|
|
||||||
|
Copyleft clause: If the Licensee distributes and/or communicates copies of the
|
||||||
|
Original Works or Derivative Works based upon the Original Work, this
|
||||||
|
Distribution and/or Communication will be done under the terms of this Licence
|
||||||
|
or of a later version of this Licence unless the Original Work is expressly
|
||||||
|
distributed only under this version of the Licence. The Licensee (becoming
|
||||||
|
Licensor) cannot offer or impose any additional terms or conditions on the Work
|
||||||
|
or Derivative Work that alter or restrict the terms of the Licence.
|
||||||
|
|
||||||
|
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative
|
||||||
|
Works or copies thereof based upon both the Original Work and another work
|
||||||
|
licensed under a Compatible Licence, this Distribution and/or Communication can
|
||||||
|
be done under the terms of this Compatible Licence. For the sake of this clause,
|
||||||
|
“Compatible Licence” refers to the licences listed in the appendix attached to
|
||||||
|
this Licence. Should the Licensee’s obligations under the Compatible Licence
|
||||||
|
conflict with his/her obligations under this Licence, the obligations of the
|
||||||
|
Compatible Licence shall prevail.
|
||||||
|
|
||||||
|
Provision of Source Code: When distributing and/or communicating copies of the
|
||||||
|
Work, the Licensee will provide a machine-readable copy of the Source Code or
|
||||||
|
indicate a repository where this Source will be easily and freely available for
|
||||||
|
as long as the Licensee continues to distribute and/or communicate the Work.
|
||||||
|
|
||||||
|
Legal Protection: This Licence does not grant permission to use the trade names,
|
||||||
|
trademarks, service marks, or 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 copyright notice.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 6. Chain of Authorship
|
||||||
|
|
||||||
|
The original Licensor warrants that the copyright in the Original Work granted
|
||||||
|
hereunder is owned by him/her or licensed to him/her and that he/she has the
|
||||||
|
power and authority to grant the Licence.
|
||||||
|
|
||||||
|
Each Contributor warrants that the copyright in the modifications he/she brings
|
||||||
|
to the Work are owned by him/her or licensed to him/her and that he/she has the
|
||||||
|
power and authority to grant the Licence.
|
||||||
|
|
||||||
|
Each time You accept the Licence, the original Licensor and subsequent
|
||||||
|
Contributors grant You a licence to their contributions to the Work, under the
|
||||||
|
terms of this Licence.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 7. Disclaimer of Warranty
|
||||||
|
|
||||||
|
The Work is a work in progress, which is continuously improved by numerous
|
||||||
|
contributors. It is not a finished work and may therefore contain defects or
|
||||||
|
“bugs” inherent to this type of software development.
|
||||||
|
|
||||||
|
For the above reason, the Work is provided under the Licence on an “as is” basis
|
||||||
|
and without warranties of any kind concerning the Work, including without
|
||||||
|
limitation merchantability, fitness for a particular purpose, absence of defects
|
||||||
|
or errors, accuracy, non-infringement of intellectual property rights other than
|
||||||
|
copyright as stated in Article 6 of this Licence.
|
||||||
|
|
||||||
|
This disclaimer of warranty is an essential part of the Licence and a condition
|
||||||
|
for the grant of any rights to the Work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 8. Disclaimer of Liability
|
||||||
|
|
||||||
|
Except in the cases of wilful misconduct or damages directly caused to natural
|
||||||
|
persons, the Licensor will in no event be liable for any direct or indirect,
|
||||||
|
material or moral, damages of any kind, arising out of the Licence or of the use
|
||||||
|
of the Work, including without limitation, damages for loss of goodwill, work
|
||||||
|
stoppage, computer failure or malfunction, loss of data or any commercial
|
||||||
|
damage, even if the Licensor has been advised of the possibility of such
|
||||||
|
damage. However, the Licensor will be liable under statutory product liability
|
||||||
|
laws as far such laws apply to the Work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 9. Additional agreements
|
||||||
|
|
||||||
|
While distributing the Original Work or Derivative Works, You may choose to
|
||||||
|
conclude an additional agreement to offer, and charge a fee for, acceptance of
|
||||||
|
support, warranty, indemnity, or other liability obligations and/or services
|
||||||
|
consistent with this Licence. However, in accepting such obligations, You may
|
||||||
|
act only on your own behalf and on your sole responsibility, not on behalf of
|
||||||
|
the original Licensor or 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 the fact You have accepted
|
||||||
|
any such warranty or additional liability.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 10. Acceptance of the Licence
|
||||||
|
|
||||||
|
The provisions of this Licence can be accepted by clicking on an icon “I agree”
|
||||||
|
placed under the bottom of a window displaying the text of this Licence or by
|
||||||
|
affirming consent in any other similar way, in accordance with the rules of
|
||||||
|
applicable law. Clicking on that icon indicates your clear and irrevocable
|
||||||
|
acceptance of this Licence and all of its terms and conditions.
|
||||||
|
|
||||||
|
Similarly, you irrevocably accept this Licence and all of its terms and
|
||||||
|
conditions by exercising any rights granted to You by Article 2 of this Licence,
|
||||||
|
such as the use of the Work, the creation by You of a Derivative Work or the
|
||||||
|
Distribution and/or Communication by You of the Work or copies thereof.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 11. Information to the public
|
||||||
|
|
||||||
|
In case of any Distribution and/or Communication of the Work by means of
|
||||||
|
electronic communication by You (for example, by offering to download the Work
|
||||||
|
from a remote location) the distribution channel or media (for example, a
|
||||||
|
website) must at least provide to the public the information requested by the
|
||||||
|
applicable law regarding the Licensor, the Licence and the way it may be
|
||||||
|
accessible, concluded, stored and reproduced by the Licensee.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 12. Termination of the Licence
|
||||||
|
|
||||||
|
The Licence and the rights granted hereunder will terminate automatically upon
|
||||||
|
any breach by the Licensee of the terms of the Licence.
|
||||||
|
|
||||||
|
Such a termination will not terminate the licences of any person who has
|
||||||
|
received the Work from the Licensee under the Licence, provided such persons
|
||||||
|
remain in full compliance with the Licence.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 13. Miscellaneous
|
||||||
|
|
||||||
|
Without prejudice of Article 9 above, the Licence represents the complete
|
||||||
|
agreement between the Parties as to the Work licensed hereunder.
|
||||||
|
|
||||||
|
If any provision of the Licence is invalid or unenforceable under applicable
|
||||||
|
law, this will not affect the validity or enforceability of the Licence as a
|
||||||
|
whole. Such provision will be construed and/or reformed so as necessary to make
|
||||||
|
it valid and enforceable.
|
||||||
|
|
||||||
|
The European Commission may publish other linguistic versions and/or new
|
||||||
|
versions of this Licence, so far this is required and reasonable, without
|
||||||
|
reducing the scope of the rights granted by the Licence. New versions of the
|
||||||
|
Licence will be published with a unique version number.
|
||||||
|
|
||||||
|
All linguistic versions of this Licence, approved by the European Commission,
|
||||||
|
have identical value. Parties can take advantage of the linguistic version of
|
||||||
|
their choice.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 14. Jurisdiction
|
||||||
|
|
||||||
|
Any litigation resulting from the interpretation of this License, arising
|
||||||
|
between the European Commission, as a Licensor, and any Licensee, will be
|
||||||
|
subject to the jurisdiction of the Court of Justice of the European Communities,
|
||||||
|
as laid down in article 238 of the Treaty establishing the European Community.
|
||||||
|
|
||||||
|
Any litigation arising between Parties, other than the European Commission, and
|
||||||
|
resulting from the interpretation of this License, will be subject to the
|
||||||
|
exclusive jurisdiction of the competent court where the Licensor resides or
|
||||||
|
conducts its primary business.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 15. Applicable Law
|
||||||
|
|
||||||
|
This Licence shall be governed by the law of the European Union country where
|
||||||
|
the Licensor resides or has his registered office.
|
||||||
|
|
||||||
|
This licence shall be governed by the Belgian law if:
|
||||||
|
|
||||||
|
- a litigation arises between the European Commission, as a Licensor, and any
|
||||||
|
- Licensee; the Licensor, other than the European Commission, has no residence
|
||||||
|
- or registered office inside a European Union country.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Appendix
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
“Compatible Licences” according to article 5 EUPL are:
|
||||||
|
|
||||||
|
|
||||||
|
- GNU General Public License (GNU GPL) v. 2
|
||||||
|
|
||||||
|
- Open Software License (OSL) v. 2.1, v. 3.0
|
||||||
|
|
||||||
|
- Common Public License v. 1.0
|
||||||
|
|
||||||
|
- Eclipse Public License v. 1.0
|
||||||
|
|
||||||
|
- Cecill v. 2.0
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
gxRest
|
||||||
|
----
|
||||||
|
The gCube eXtensions to the Rest Protocol (gxRest) is a set of Java libraries designed to provide convenient round-trip interaction between a Restful web application (also known as "service") and its clients.
|
||||||
|
|
||||||
|
gxRest has the flexibility for different degrees of exploitation:
|
||||||
|
* it can be entirely adopted both at client and service side with full benefit of its conventions;
|
||||||
|
* it can be used to send REST requests based only on plain HTTP;
|
||||||
|
* it can be used only to return HTTP code/messagess from the service;
|
||||||
|
* it can be used only to throw Exceptions from the service to the client.
|
||||||
|
|
||||||
|
## Examples of use
|
||||||
|
|
||||||
|
Sending a request:
|
||||||
|
```java
|
||||||
|
GXHTTPRequest request = GXHTTPRequest.newRequest("http://host:port/service/").from("GXRequestTest");
|
||||||
|
|
||||||
|
//prepare some parameters
|
||||||
|
String context ="...";
|
||||||
|
Map<String,String> queryParams = new WeakHashMap<>();
|
||||||
|
queryParams.put("param name", "param value");
|
||||||
|
GXInboundResponse response = request.path("context")
|
||||||
|
.queryParams(queryParams).withBody(context).post();
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Returning a success response:
|
||||||
|
```java
|
||||||
|
@POST
|
||||||
|
public Response create(...) {
|
||||||
|
|
||||||
|
//Resource successfully created
|
||||||
|
|
||||||
|
URI location = ... //URI of the new resource
|
||||||
|
return GXOutboundSuccessResponse.newCREATEResponse(location)
|
||||||
|
.withMessage("Resource successfully created.")
|
||||||
|
.ofType(MediaType.APPLICATION_JSON)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Throwing an exception:
|
||||||
|
```java
|
||||||
|
@POST
|
||||||
|
public Response create(...) {
|
||||||
|
|
||||||
|
//Oh no, something failed here
|
||||||
|
GXOutboundErrorResponse.throwException(new MyCustomException("Resource already exists."));
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Parsing a response
|
||||||
|
```java
|
||||||
|
// invoke the remote method and get a response.
|
||||||
|
GXInboundResponse response = ...;
|
||||||
|
if (response.hasException())
|
||||||
|
throw response.getException();
|
||||||
|
//assuming a created (200) code was expected
|
||||||
|
if (response.hasCREATEDCode()) {
|
||||||
|
System.out.println("Resource successfully created!");
|
||||||
|
}
|
||||||
|
//access content as string
|
||||||
|
String value = response.getStreamedContentAsString();
|
||||||
|
//unmasharll content as json
|
||||||
|
Context returnedContext = response.tryConvertStreamedContentFromJson(Context.class);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
* [gxJRS](https://wiki.gcube-system.org/gcube/GxRest/GxJRS)
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
Notes about how to deploy this component on an infrastructure or link to wiki doc (if any).
|
||||||
|
|
||||||
|
## Built With
|
||||||
|
|
||||||
|
* [JAX-RS](https://github.com/eclipse-ee4j/jaxrs-api) - Java™ API for RESTful Web Services
|
||||||
|
* [Jersey](https://jersey.github.io/) - JAX-RS runtime
|
||||||
|
* [Maven](https://maven.apache.org/) - Dependency Management
|
||||||
|
|
||||||
|
## License
|
||||||
|
See [LICENSE.md](LICENSE.md)
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Maven: javax.ws.rs:javax.ws.rs-api:2.0.1" level="project" />
|
||||||
|
<orderEntry type="module" module-name="gxHTTP" />
|
||||||
|
<orderEntry type="library" name="Maven: org.gcube.common:authorization-client:2.0.7" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.gcube.common:common-authorization:2.3.0-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.gcube.core:common-scope:1.3.0-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.gcube.core:common-configuration-scanner:1.1.0-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.gcube.core:common-scope-maps:1.2.2-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.6.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.6.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.6.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.jersey.core:jersey-client:2.25.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.jersey.core:jersey-common:2.25.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: javax.annotation:javax.annotation-api:1.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.jersey.bundles.repackaged:jersey-guava:2.25.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.hk2:osgi-resource-locator:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.hk2:hk2-api:2.5.0-b32" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.hk2:hk2-utils:2.5.0-b32" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.hk2.external:aopalliance-repackaged:2.5.0-b32" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.hk2.external:javax.inject:2.5.0-b32" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.hk2:hk2-locator:2.5.0-b32" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.jersey.inject:jersey-hk2:2.27" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: ch.qos.logback:logback-classic:1.0.13" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: ch.qos.logback:logback-core:1.0.13" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>gxREST</artifactId>
|
<artifactId>gxREST</artifactId>
|
||||||
<version>1.1.2-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>gxJRS</artifactId>
|
<artifactId>gxJRS</artifactId>
|
||||||
|
@ -19,10 +19,11 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${parent.artifactId}/${project.artifactId}</connection>
|
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/gx-rest</connection>
|
||||||
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${parent.artifactId}/${project.artifactId}</developerConnection>
|
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/gx-rest</developerConnection>
|
||||||
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${parent.artifactId}/${project.artifactId}</url>
|
<url>https://code-repo.d4science.org/gCubeSystem/gx-rest</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey/jersey-bom -->
|
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey/jersey-bom -->
|
||||||
|
@ -36,14 +37,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>gcube-bom</artifactId>
|
<artifactId>gcube-bom</artifactId>
|
||||||
<version>LATEST</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.information-system</groupId>
|
|
||||||
<artifactId>information-system-bom</artifactId>
|
|
||||||
<version>LATEST</version>
|
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -55,32 +49,24 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.ws.rs</groupId>
|
<groupId>javax.ws.rs</groupId>
|
||||||
<artifactId>javax.ws.rs-api</artifactId>
|
<artifactId>javax.ws.rs-api</artifactId>
|
||||||
<version>${jaxrs.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>gxHTTP</artifactId>
|
<artifactId>gxHTTP</artifactId>
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>authorization-client</artifactId>
|
<artifactId>gcube-jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>gcube-jackson-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Test Dependency -->
|
<!-- Test Dependency -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -103,25 +89,9 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<version>1.0.13</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>make-servicearchive</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -137,22 +137,6 @@ public class GXHTTPStreamRequest implements GXHTTP<InputStream,GXInboundResponse
|
||||||
return new GXInboundResponse(builder.connect());
|
return new GXInboundResponse(builder.connect());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.common.gxrest.request.GXHTTP#setSecurityToken(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setSecurityToken(String token) {
|
|
||||||
builder.setSecurityToken(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.common.gxrest.request.GXHTTP#isExternalCall(boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void isExternalCall(boolean ext) {
|
|
||||||
builder.isExternalCall(ext);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @return the request
|
* @return the request
|
||||||
|
|
|
@ -155,22 +155,6 @@ public class GXHTTPStringRequest implements GXHTTP<String,GXInboundResponse> {
|
||||||
return new GXInboundResponse(builder.connect());
|
return new GXInboundResponse(builder.connect());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.common.gxrest.request.GXHTTP#setSecurityToken(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setSecurityToken(String token) {
|
|
||||||
builder.setSecurityToken(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.common.gxrest.request.GXHTTP#isExternalCall(boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void isExternalCall(boolean ext) {
|
|
||||||
builder.isExternalCall(ext);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
|
|
|
@ -7,8 +7,8 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
import javax.net.ssl.HostnameVerifier;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
|
@ -25,7 +25,6 @@ import javax.ws.rs.core.MultivaluedHashMap;
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
import javax.ws.rs.core.MultivaluedMap;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
||||||
import org.gcube.common.gxhttp.reference.GXConnection;
|
import org.gcube.common.gxhttp.reference.GXConnection;
|
||||||
import org.gcube.common.gxhttp.reference.GXHTTP;
|
import org.gcube.common.gxhttp.reference.GXHTTP;
|
||||||
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
||||||
|
@ -45,7 +44,6 @@ public class GXWebTargetAdapterRequest implements GXHTTP<Entity<?>,GXInboundResp
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GXWebTargetAdapterRequest.class);
|
private static final Logger logger = LoggerFactory.getLogger(GXWebTargetAdapterRequest.class);
|
||||||
private MediaType[] mediaType;
|
private MediaType[] mediaType;
|
||||||
MultivaluedMap<String, Object> headers = new MultivaluedHashMap<String, Object>();
|
MultivaluedMap<String, Object> headers = new MultivaluedHashMap<String, Object>();
|
||||||
private boolean extCall = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new request.
|
* Creates a new request.
|
||||||
|
@ -55,22 +53,42 @@ public class GXWebTargetAdapterRequest implements GXHTTP<Entity<?>,GXInboundResp
|
||||||
* @return the request
|
* @return the request
|
||||||
*/
|
*/
|
||||||
public static GXWebTargetAdapterRequest newRequest(String address) {
|
public static GXWebTargetAdapterRequest newRequest(String address) {
|
||||||
return new GXWebTargetAdapterRequest(address, false);
|
return new GXWebTargetAdapterRequest(address, false, "Default");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new secure request.
|
||||||
|
*
|
||||||
|
* @param address
|
||||||
|
* the address of the web app to call
|
||||||
|
* @param tslprotocol
|
||||||
|
* the secure socket protocol to use in the call
|
||||||
|
* @return the request
|
||||||
|
*/
|
||||||
|
public static GXWebTargetAdapterRequest newHTTPSRequest(String address, String tslprotocol) {
|
||||||
|
return new GXWebTargetAdapterRequest(address, false, tslprotocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new request.
|
||||||
|
*
|
||||||
|
* @param address
|
||||||
|
* the address of the web app to call
|
||||||
|
|
||||||
|
* @return the request
|
||||||
|
*/
|
||||||
public static GXWebTargetAdapterRequest newHTTPSRequest(String address) {
|
public static GXWebTargetAdapterRequest newHTTPSRequest(String address) {
|
||||||
return new GXWebTargetAdapterRequest(address, true);
|
return new GXWebTargetAdapterRequest(address, true,"Default");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param address
|
* @param address
|
||||||
*/
|
*/
|
||||||
private GXWebTargetAdapterRequest(String address, boolean withHTTPS) {
|
private GXWebTargetAdapterRequest(String address, boolean withHTTPS, String tslprotocol ) {
|
||||||
Client client = ClientBuilder.newClient();
|
Client client = ClientBuilder.newClient();
|
||||||
if (withHTTPS) {
|
if (withHTTPS) {
|
||||||
try {
|
try {
|
||||||
SSLContext sc = SSLContext.getInstance("TLSv1");
|
SSLContext sc = SSLContext.getInstance(tslprotocol);
|
||||||
System.setProperty("https.protocols", "TLSv1");
|
|
||||||
TrustManager[] certs = new TrustManager[] { new X509TrustManager() {
|
TrustManager[] certs = new TrustManager[] { new X509TrustManager() {
|
||||||
@Override
|
@Override
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
@ -101,26 +119,9 @@ public class GXWebTargetAdapterRequest implements GXHTTP<Entity<?>,GXInboundResp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.adaptee = client.target(address);
|
this.adaptee = client.target(address);
|
||||||
this.headers.add(org.gcube.common.authorization.client.Constants.TOKEN_HEADER_ENTRY,
|
|
||||||
SecurityTokenProvider.instance.get());
|
|
||||||
this.headers.add("User-Agent", this.getClass().getSimpleName());
|
this.headers.add("User-Agent", this.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Overrides the default security token.
|
|
||||||
*
|
|
||||||
* @param token
|
|
||||||
* the new token
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setSecurityToken(String token) {
|
|
||||||
if (!this.extCall)
|
|
||||||
this.headers.add(org.gcube.common.authorization.client.Constants.TOKEN_HEADER_ENTRY, token);
|
|
||||||
|
|
||||||
else
|
|
||||||
throw new UnsupportedOperationException("Cannot set the security token on an external call");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the identity user agent associated to the request.
|
* Sets the identity user agent associated to the request.
|
||||||
*
|
*
|
||||||
|
@ -385,13 +386,4 @@ public class GXWebTargetAdapterRequest implements GXHTTP<Entity<?>,GXInboundResp
|
||||||
throw new UnsupportedOperationException("WebTarget does not support CONNECT");
|
throw new UnsupportedOperationException("WebTarget does not support CONNECT");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.gcube.common.gxrest.request.GXHTTP#isExternalCall(boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void isExternalCall(boolean ext) {
|
|
||||||
this.extCall = ext;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ package org.gcube.common.gxrest.response.entity;
|
||||||
* of an ETag response header.
|
* of an ETag response header.
|
||||||
*
|
*
|
||||||
* @author Manuele Simi (ISTI CNR)
|
* @author Manuele Simi (ISTI CNR)
|
||||||
* @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP/1.1 section 3.11</a>
|
* @see <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP/1.1 section 3.11</a>
|
||||||
*/
|
*/
|
||||||
public final class EntityTag {
|
public final class EntityTag {
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,8 @@ public class SerializableErrorEntityTextReader implements MessageBodyReader<Seri
|
||||||
* @return the string read from the stream
|
* @return the string read from the stream
|
||||||
*/
|
*/
|
||||||
private static String convertStreamToString(InputStream is) {
|
private static String convertStreamToString(InputStream is) {
|
||||||
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
|
try (java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A")) {
|
||||||
return s.hasNext() ? s.next() : "";
|
return s.hasNext() ? s.next() : "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class GXInboundResponse {
|
||||||
// ContentUtils.toByteArray(connection.getInputStream());
|
// ContentUtils.toByteArray(connection.getInputStream());
|
||||||
if (this.contentType.equals(MediaType.TEXT_PLAIN)
|
if (this.contentType.equals(MediaType.TEXT_PLAIN)
|
||||||
|| this.contentType.equals(MediaType.APPLICATION_JSON)) {
|
|| this.contentType.equals(MediaType.APPLICATION_JSON)) {
|
||||||
this.body = ContentUtils.toString(ContentUtils.toByteArray(connection.getInputStream()));
|
this.body = ContentUtils.toString(ContentUtils.toByteArray(getInputStream()));
|
||||||
logger.trace("Response's content: " + this.body);
|
logger.trace("Response's content: " + this.body);
|
||||||
this.contentAlreadyConsumed = true;
|
this.contentAlreadyConsumed = true;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ public class GXInboundResponse {
|
||||||
if(!this.contentAlreadyConsumed) {
|
if(!this.contentAlreadyConsumed) {
|
||||||
if (this.fromConnection) {
|
if (this.fromConnection) {
|
||||||
contentAlreadyConsumed = true;
|
contentAlreadyConsumed = true;
|
||||||
return connection.getInputStream();
|
return isSuccessResponse() ? connection.getInputStream() : connection.getErrorStream();
|
||||||
} else if (this.fromResponse) {
|
} else if (this.fromResponse) {
|
||||||
contentAlreadyConsumed = true;
|
contentAlreadyConsumed = true;
|
||||||
return (InputStream) source.getEntity();
|
return (InputStream) source.getEntity();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.common.gxrest.response.inbound;
|
package org.gcube.common.gxrest.response.inbound;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manipulation of an {@link GXInboundResponse}'s content.
|
* Manipulation of an {@link GXInboundResponse}'s content.
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.gcube.common.gxrest.response.outbound;
|
package org.gcube.common.gxrest.response.outbound;
|
||||||
|
|
||||||
import javax.print.attribute.standard.Media;
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.common.gxrest.request;
|
package org.gcube.common.gxrest.request;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -8,10 +9,7 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.gcube.common.authorization.client.Constants;
|
import org.gcube.com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
||||||
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -20,8 +18,6 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.BlockJUnit4ClassRunner;
|
import org.junit.runners.BlockJUnit4ClassRunner;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cases for {@link GXHTTPStringRequest}
|
* Test cases for {@link GXHTTPStringRequest}
|
||||||
*
|
*
|
||||||
|
@ -62,23 +58,17 @@ public class GXHTTPStringRequestTest {
|
||||||
setContext(DEFAULT_TEST_SCOPE);
|
setContext(DEFAULT_TEST_SCOPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setContext(String token) throws ObjectNotFound, Exception {
|
public static void setContext(String token) throws Exception {
|
||||||
if (DEFAULT_TEST_SCOPE.isEmpty()) {
|
if (DEFAULT_TEST_SCOPE.isEmpty()) {
|
||||||
skipTest = true;
|
skipTest = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SecurityTokenProvider.instance.set(token);
|
//SecurityTokenProvider.instance.set(token);
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
|
||||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
|
||||||
String context = authorizationEntry.getContext();
|
|
||||||
return context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
SecurityTokenProvider.instance.reset();
|
//SecurityTokenProvider.instance.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +112,8 @@ public class GXHTTPStringRequestTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=com.fasterxml.jackson.databind.JsonMappingException.class)
|
@SuppressWarnings("deprecation")
|
||||||
|
@Test(expected=org.gcube.com.fasterxml.jackson.databind.JsonMappingException.class)
|
||||||
public void testPostNoBody() throws Exception {
|
public void testPostNoBody() throws Exception {
|
||||||
if (skipTest)
|
if (skipTest)
|
||||||
throw new JsonMappingException("");
|
throw new JsonMappingException("");
|
||||||
|
|
|
@ -0,0 +1,173 @@
|
||||||
|
package org.gcube.common.gxrest.request;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.Entity;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.BlockJUnit4ClassRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test cases for {@link GXWebTargetAdapterRequest#newHTTPSRequest(String)}
|
||||||
|
*
|
||||||
|
* @author Manuele Simi (ISTI-CNR)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@RunWith(BlockJUnit4ClassRunner.class)
|
||||||
|
public class GXWebTargetAdapterHTTPSRequestTest {
|
||||||
|
|
||||||
|
private GXWebTargetAdapterRequest request;
|
||||||
|
|
||||||
|
// private GXWebTargetAdapterRequest requestWithProtocol;
|
||||||
|
|
||||||
|
|
||||||
|
public static String DEFAULT_TEST_SCOPE = "";
|
||||||
|
|
||||||
|
static String DEFAULT_RM_URL = "";
|
||||||
|
|
||||||
|
static String DEFAULT_RR_URL = "";
|
||||||
|
|
||||||
|
private static boolean skipTest = false;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
try (InputStream input = GXWebTargetAdapterRequest.class.getClassLoader().getResourceAsStream("token.props")) {
|
||||||
|
// load the properties file
|
||||||
|
properties.load(input);
|
||||||
|
DEFAULT_TEST_SCOPE = properties.getProperty("DEFAULT_SCOPE_TOKEN");
|
||||||
|
if (DEFAULT_TEST_SCOPE.isEmpty())
|
||||||
|
skipTest = true;
|
||||||
|
DEFAULT_RM_URL = properties.getProperty("RM_URL");
|
||||||
|
DEFAULT_RR_URL = properties.getProperty("RR_URL");
|
||||||
|
} catch (IOException | NullPointerException e) {
|
||||||
|
skipTest = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@BeforeClass
|
||||||
|
public static void beforeClass() throws Exception {
|
||||||
|
if (!skipTest)
|
||||||
|
setContext(DEFAULT_TEST_SCOPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setContext(String token) throws Exception {
|
||||||
|
if (skipTest || DEFAULT_TEST_SCOPE.isEmpty()) {
|
||||||
|
skipTest = true;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
//SecurityTokenProvider.instance.set(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void afterClass() throws Exception {
|
||||||
|
//SecurityTokenProvider.instance.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link GXHTTPStringRequest#newRequest(String)}.
|
||||||
|
*/
|
||||||
|
@Before
|
||||||
|
public void testNewRequest() {
|
||||||
|
request = GXWebTargetAdapterRequest.newHTTPSRequest(DEFAULT_RM_URL).from("GXRequestTest");
|
||||||
|
// requestWithProtocol = GXWebTargetAdapterRequest.newHTTPSRequest(DEFAULT_RM_URL, "").from("GXRequestTest");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link GXWebTargetAdapterRequest#put()}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPut() {
|
||||||
|
if (skipTest)
|
||||||
|
return;
|
||||||
|
//fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link GXWebTargetAdapterRequest#delete()}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDelete() {
|
||||||
|
if (skipTest)
|
||||||
|
return;
|
||||||
|
//fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link GXWebTargetAdapterRequest#post()}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPost() {
|
||||||
|
if (skipTest)
|
||||||
|
return;
|
||||||
|
String context ="{\"@class\":\"Context\",\"header\":{\"@class\":\"Header\",\"uuid\":\"6f86dc81-2f59-486b-8aa9-3ab5486313c4\",\"creator\":null,\"modifiedBy\":\"gxRestTest\",\"creationTime\":null,\"lastUpdateTime\":null},\"name\":\"gxTest\",\"parent\":null,\"children\":[]}";
|
||||||
|
Map<String,Object[]> queryParams = new WeakHashMap<>();
|
||||||
|
queryParams.put("rrURL", new String[]{DEFAULT_RR_URL});
|
||||||
|
try {
|
||||||
|
GXInboundResponse response = request.path("gxrest")
|
||||||
|
.header("User-Agent", this.getClass().getSimpleName())
|
||||||
|
.header("Another header", "another value")
|
||||||
|
.queryParams(queryParams).post(Entity.entity(context, MediaType.APPLICATION_JSON + ";charset=UTF-8"));
|
||||||
|
assertTrue("Unexpected returned code.", response.hasCREATEDCode());
|
||||||
|
if (response.hasGXError()) {
|
||||||
|
if (response.hasException()) {
|
||||||
|
try {
|
||||||
|
throw response.getException();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
//that's OK, we can tolerate this
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (response.hasCREATEDCode()) {
|
||||||
|
System.out.println("Resource successfully created!");
|
||||||
|
System.out.println("Returned message: " + response.getStreamedContentAsString());
|
||||||
|
} else {
|
||||||
|
System.out.println("Resource creation failed. Returned status:" + response.getHTTPCode());
|
||||||
|
//if you want to use the original responser
|
||||||
|
response.getSource();
|
||||||
|
//then consume the response
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
fail("Failed to send a POST request");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link GXWebTargetAdapterRequest#head()}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testHead() {
|
||||||
|
if (skipTest)
|
||||||
|
return;
|
||||||
|
//fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link GXWebTargetAdapterRequest#get()}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGet() {
|
||||||
|
if (skipTest)
|
||||||
|
return;
|
||||||
|
//fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.common.gxrest.request;
|
package org.gcube.common.gxrest.request;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -11,10 +12,6 @@ import java.util.WeakHashMap;
|
||||||
import javax.ws.rs.client.Entity;
|
import javax.ws.rs.client.Entity;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.gcube.common.authorization.client.Constants;
|
|
||||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
||||||
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -62,24 +59,19 @@ public class GXWebTargetAdapterRequestTest {
|
||||||
setContext(DEFAULT_TEST_SCOPE);
|
setContext(DEFAULT_TEST_SCOPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setContext(String token) throws ObjectNotFound, Exception {
|
public static void setContext(String token) throws Exception {
|
||||||
if (skipTest || DEFAULT_TEST_SCOPE.isEmpty()) {
|
if (skipTest || DEFAULT_TEST_SCOPE.isEmpty()) {
|
||||||
skipTest = true;
|
skipTest = true;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
SecurityTokenProvider.instance.set(token);
|
//SecurityTokenProvider.instance.set(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
|
||||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
|
||||||
String context = authorizationEntry.getContext();
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
SecurityTokenProvider.instance.reset();
|
//SecurityTokenProvider.instance.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
gxREST
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerConfiguration">
|
|
||||||
<annotationProcessing>
|
|
||||||
<profile name="Maven default annotation processors profile" enabled="true">
|
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
|
||||||
<outputRelativeToContentRoot value="true" />
|
|
||||||
<module name="gxHTTP" />
|
|
||||||
<module name="gxJRS" />
|
|
||||||
</profile>
|
|
||||||
</annotationProcessing>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding">
|
|
||||||
<file url="file://$PROJECT_DIR$/.." charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/../gxHTTP" charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/../gxJRS" charset="UTF-8" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,35 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
|
||||||
<component name="MavenProjectsManager">
|
|
||||||
<option name="originalFiles">
|
|
||||||
<list>
|
|
||||||
<option value="$PROJECT_DIR$/../pom.xml" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
|
||||||
</component>
|
|
||||||
<component name="SvnBranchConfigurationManager">
|
|
||||||
<option name="myConfigurationMap">
|
|
||||||
<map>
|
|
||||||
<entry key="$PROJECT_DIR$/..">
|
|
||||||
<value>
|
|
||||||
<SvnBranchConfiguration>
|
|
||||||
<option name="branchUrls">
|
|
||||||
<list>
|
|
||||||
<option value="https://svn.d4science.research-infrastructures.eu/gcube/branches" />
|
|
||||||
<option value="https://svn.d4science.research-infrastructures.eu/gcube/misc" />
|
|
||||||
<option value="https://svn.d4science.research-infrastructures.eu/gcube/private" />
|
|
||||||
<option value="https://svn.d4science.research-infrastructures.eu/gcube/tags" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
<option name="trunkUrl" value="https://svn.d4science.research-infrastructures.eu/gcube/trunk" />
|
|
||||||
</SvnBranchConfiguration>
|
|
||||||
</value>
|
|
||||||
</entry>
|
|
||||||
</map>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$/.." vcs="svn" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
19
pom.xml
19
pom.xml
|
@ -5,12 +5,12 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.gcube.tools</groupId>
|
<groupId>org.gcube.tools</groupId>
|
||||||
<artifactId>maven-parent</artifactId>
|
<artifactId>maven-parent</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.2.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>gxREST</artifactId>
|
<artifactId>gxREST</artifactId>
|
||||||
<version>1.1.2-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>gCube eXtensions to REST</name>
|
<name>gCube eXtensions to REST</name>
|
||||||
<description>gCube eXtensions to REST</description>
|
<description>gCube eXtensions to REST</description>
|
||||||
|
@ -28,9 +28,9 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${project.artifactId}</connection>
|
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/gx-rest</connection>
|
||||||
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${project.artifactId}</developerConnection>
|
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/gx-rest</developerConnection>
|
||||||
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${project.artifactId}</url>
|
<url>https://code-repo.d4science.org/gCubeSystem/gx-rest</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,14 +47,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>gcube-bom</artifactId>
|
<artifactId>gcube-bom</artifactId>
|
||||||
<version>LATEST</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.information-system</groupId>
|
|
||||||
<artifactId>information-system-bom</artifactId>
|
|
||||||
<version>LATEST</version>
|
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
Loading…
Reference in New Issue