Compare commits
58 Commits
Author | SHA1 | Date |
---|---|---|
luca.frosini | a4174b0da2 | |
Luca Frosini | 54d291a142 | |
Luca Frosini | 00f3a8d718 | |
Luca Frosini | a207cb0043 | |
Luca Frosini | 4cce5ee2eb | |
Luca Frosini | 4f1734de8a | |
Luca Frosini | ecc108a8b7 | |
Luca Frosini | e62f17bc8e | |
Luca Frosini | 038e49dd36 | |
Luca Frosini | 4bbc5bebbb | |
Luca Frosini | 848f4e3119 | |
Luca Frosini | 930d1d2b34 | |
Luca Frosini | 563affadff | |
Luca Frosini | bcafe2b401 | |
Luca Frosini | 0d0fc4cc1e | |
Luca Frosini | 9b876b5d6f | |
Luca Frosini | 56fab9178c | |
Luca Frosini | d82cdafea4 | |
Luca Frosini | e5538eba59 | |
Luca Frosini | c88254bfe9 | |
Luca Frosini | b2bc868ffc | |
Luca Frosini | b356991974 | |
Luca Frosini | 8c4485d88a | |
Luca Frosini | 8143eee364 | |
Luca Frosini | 61d57e8360 | |
Luca Frosini | 4f56b412b0 | |
Luca Frosini | 136f740b61 | |
Luca Frosini | f39a50e6fa | |
Luca Frosini | 73efe34e05 | |
Luca Frosini | 3559bd2d69 | |
Luca Frosini | 5dfa001306 | |
Luca Frosini | d0ff1423f5 | |
Luca Frosini | bd67e461f5 | |
Luca Frosini | 647c8e33be | |
Luca Frosini | a64cef5113 | |
Luca Frosini | 2269b20f8d | |
Luca Frosini | c55988cc8a | |
Luca Frosini | 03ac8f4fb6 | |
Luca Frosini | 623d474384 | |
Luca Frosini | e2c84401f2 | |
Luca Frosini | b32ff04e97 | |
Luca Frosini | b48046aea2 | |
Luca Frosini | e2c0cbbee4 | |
Luca Frosini | 7f3ea5da14 | |
Luca Frosini | eb9a3028fe | |
Luca Frosini | 08e3e7acbe | |
Luca Frosini | e63a76fff9 | |
Luca Frosini | 4b1be3b2d4 | |
Luca Frosini | 12275c8e73 | |
Luca Frosini | 44cb99380e | |
Luca Frosini | 152a211f0a | |
Luca Frosini | bc50f0b1e5 | |
Luca Frosini | 1fcea2b14b | |
Luca Frosini | e28e49438f | |
Luca Frosini | 0d5c48ce35 | |
Luca Frosini | 6b32bc1245 | |
Luca Frosini | f931293c8c | |
Luca Frosini | 395220a652 |
|
@ -1,3 +1,4 @@
|
||||||
target
|
target
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
|
/.DS_Store
|
||||||
|
|
38
CHANGELOG.md
38
CHANGELOG.md
|
@ -2,12 +2,42 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
|
|
||||||
# Changelog for gCube Catalogue (gCat) Client
|
# Changelog for gCube Catalogue (gCat) Client
|
||||||
|
|
||||||
|
## [v2.4.1]
|
||||||
|
|
||||||
## [v2.0.0]
|
- Added support for JSON:API on 'licenses' collection [#24601]
|
||||||
|
- Added usage of common-utility to overcome issues with different Smartgears version (i.e. 3 and 4)
|
||||||
|
|
||||||
|
|
||||||
|
## [v2.4.0] [r5.14.0] - 2022-12-07
|
||||||
|
|
||||||
|
- Added dependency to be able to compile with JDK 11
|
||||||
|
|
||||||
|
|
||||||
|
## [v2.3.0] [r5.13.1] - 2022-09-19
|
||||||
|
|
||||||
|
- Removed service discovery to to old service class
|
||||||
|
- Using renamed constant from gcat-api
|
||||||
|
|
||||||
|
|
||||||
|
## [v2.2.0] [r5.11.0] - 2022-05-12
|
||||||
|
|
||||||
|
- Added support to manage configurations [#22658]
|
||||||
|
- Migrated to ServiceClass corresponding to Maven groupId
|
||||||
|
|
||||||
|
## [v2.1.0] [r5.7.0] - 2022-01-27
|
||||||
|
|
||||||
|
- Added query parameter social_post_notification to override default VRE behaviour [#21345]
|
||||||
|
- Added support for moderation [#21342]
|
||||||
|
- Added items bulk delete/purge [#21685]
|
||||||
|
- Added empty trash API [#13322]
|
||||||
|
|
||||||
|
|
||||||
|
## [v2.0.0] [r5.2.0] - 2021-05-04
|
||||||
|
|
||||||
- Changed service class
|
- Changed service class
|
||||||
|
|
||||||
## [v1.2.2]
|
|
||||||
|
## [v1.2.2] [r5.0.0] - 2021-02-24
|
||||||
|
|
||||||
- Added count method for Item collection [#20627]
|
- Added count method for Item collection [#20627]
|
||||||
- Added count method for Organization, Group and Profile collection [#20629]
|
- Added count method for Organization, Group and Profile collection [#20629]
|
||||||
|
@ -18,12 +48,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
- Fixed distro files and pom according to new release procedure
|
- Fixed distro files and pom according to new release procedure
|
||||||
|
|
||||||
|
|
||||||
## [v1.2.0] [r4.15.0] - 2019-11-06
|
## [v1.2.0] [r4.15.0] - 2019-11-20
|
||||||
|
|
||||||
- Enforce Content-Type in requests [#16774]
|
- Enforce Content-Type in requests [#16774]
|
||||||
|
|
||||||
|
|
||||||
## [v1.1.0] [r4.14.0] - 2019-05-27
|
## [v1.1.0] [r4.14.0] - 2019-05-16
|
||||||
|
|
||||||
- Added the possibility to enforce gCat service URL
|
- Added the possibility to enforce gCat service URL
|
||||||
- Added the possibility to disable social post [#13335]
|
- Added the possibility to disable social post [#13335]
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Acknowledgments
|
||||||
|
|
||||||
|
The projects leading to this software have received funding from a series of European Union programmes including:
|
||||||
|
|
||||||
|
- the Sixth Framework Programme for Research and Technological Development
|
||||||
|
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
|
||||||
|
- the Seventh Framework Programme for research, technological development and demonstration
|
||||||
|
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
|
||||||
|
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
|
||||||
|
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
|
||||||
|
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
|
||||||
|
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
|
||||||
|
- the H2020 research and innovation programme
|
||||||
|
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
|
||||||
|
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
|
||||||
|
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
|
||||||
|
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
|
||||||
|
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
|
||||||
|
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
|
||||||
|
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
|
||||||
|
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
|
||||||
|
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
|
||||||
|
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
|
||||||
|
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
|
||||||
|
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
|
||||||
|
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);
|
36
README.md
36
README.md
|
@ -1,6 +1,6 @@
|
||||||
# gCube Catalogue (gCat) Client
|
# gCube Catalogue (gCat) Client
|
||||||
|
|
||||||
gCube Catalogue (gCat) Client is a library designed to interact with gCat Service exposed REST API
|
gCube Catalogue (gCat) Client is a library designed to interact with REST APIs exposed by the gCat Service.
|
||||||
|
|
||||||
## Built With
|
## Built With
|
||||||
|
|
||||||
|
@ -25,14 +25,12 @@ Tell people how to cite this software.
|
||||||
* Cite an associated paper?
|
* Cite an associated paper?
|
||||||
* Use a specific BibTeX entry for the software?
|
* Use a specific BibTeX entry for the software?
|
||||||
|
|
||||||
|
@software{gcat-client,
|
||||||
@Manual{,
|
author = {{Luca Frosini}},
|
||||||
title = {gCube Catalogue (gCat) Client},
|
title = {gCube Catalogue (gCat) Client},
|
||||||
author = {{Frosini, Luca}},
|
abstract = {gCube Catalogue (gCat) Client is a library designed to interact with REST APIs exposed by the gCat Service.},
|
||||||
organization = {ISTI - CNR},
|
url = {https://doi.org/10.5281/zenodo.7447655},
|
||||||
address = {Pisa, Italy},
|
keywords = {Catalogue, D4Science, gCube}
|
||||||
year = 2019,
|
|
||||||
url = {http://www.gcube-system.org/}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
@ -46,26 +44,6 @@ open-source software toolkit used for building and operating Hybrid Data
|
||||||
Infrastructures enabling the dynamic deployment of Virtual Research Environments
|
Infrastructures enabling the dynamic deployment of Virtual Research Environments
|
||||||
by favouring the realisation of reuse oriented policies.
|
by favouring the realisation of reuse oriented policies.
|
||||||
|
|
||||||
The projects leading to this software have received funding from a series of European Union programmes including:
|
The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md)
|
||||||
|
|
||||||
- the Sixth Framework Programme for Research and Technological Development
|
|
||||||
- DILIGENT (grant no. 004260).
|
|
||||||
- the Seventh Framework Programme for research, technological development and demonstration
|
|
||||||
- D4Science (grant no. 212488);
|
|
||||||
- D4Science-II (grant no.239019);
|
|
||||||
- ENVRI (grant no. 283465);
|
|
||||||
- iMarine(grant no. 283644);
|
|
||||||
- EUBrazilOpenBio (grant no. 288754).
|
|
||||||
- the H2020 research and innovation programme
|
|
||||||
- SoBigData (grant no. 654024);
|
|
||||||
- PARTHENOS (grant no. 654119);
|
|
||||||
- EGIEngage (grant no. 654142);
|
|
||||||
- ENVRIplus (grant no. 654182);
|
|
||||||
- BlueBRIDGE (grant no. 675680);
|
|
||||||
- PerformFish (grant no. 727610);
|
|
||||||
- AGINFRAplus (grant no. 731001);
|
|
||||||
- DESIRA (grant no. 818194);
|
|
||||||
- ARIADNEplus (grant no. 823914);
|
|
||||||
- RISIS2 (grant no. 824091);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"name": "${project.artifactId}",
|
||||||
|
"title": "${project.name} ${project.version}",
|
||||||
|
"version": "${project.version}",
|
||||||
|
"date": "${build.date}",
|
||||||
|
"packaging": "${project.packaging}",
|
||||||
|
"concept_doi_url": "https://doi.org/10.5281/zenodo.7447655",
|
||||||
|
"version_doi_url": null,
|
||||||
|
"group": "data-catalogue",
|
||||||
|
"description": "${project.description}",
|
||||||
|
"html_description": "<p>${project.description}</p>",
|
||||||
|
"keywords": ["gCube", "Catalogue", "D4Science"],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"affiliation": "Istituto di Scienza e Tecnologie dell'Informazione \"A. Faedo\" - CNR, Italy",
|
||||||
|
"name": "Frosini, Luca",
|
||||||
|
"orcid": "0000-0003-3183-2291"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,236 @@
|
||||||
|
{
|
||||||
|
"global": {
|
||||||
|
"name": "gcat-client",
|
||||||
|
"group": "data-catalogue",
|
||||||
|
"title": "gCube Catalogue (gCat) Client {{version}}",
|
||||||
|
"license": {
|
||||||
|
"id": "EUPL-1.1",
|
||||||
|
"url": "https://opensource.org/licenses/EUPL-1.1"
|
||||||
|
},
|
||||||
|
"keywords": ["gCube", "Catalogue", "D4Science"],
|
||||||
|
"description": "gCube Catalogue (gCat) Client is a library designed to interact with REST APIs exposed by the gCat Service.",
|
||||||
|
"html_description": "<p><a href=\"https://www.gcube-system.org/\">gCube</a> Catalogue (gCat) Client is a library designed to interact with REST APIs exposed by the gCat Service.</p>",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"affiliation": "Istituto di Scienza e Tecnologie dell'Informazione \"A. Faedo\" - CNR, Italy",
|
||||||
|
"name": "Frosini, Luca",
|
||||||
|
"orcid": "0000-0003-3183-2291"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"url": "https://code-repo.d4science.org/gCubeSystem/{{name}}/archive/v{{version}}.zip",
|
||||||
|
"desired_name": "{{name}}-v{{version}}.zip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://code-repo.d4science.org/gCubeSystem/{{name}}/archive/v{{version}}.tar.gz",
|
||||||
|
"desired_name": "{{name}}-v{{version}}.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://nexus.d4science.org/nexus/service/local/repo_groups/gcube-releases-all/content/org/gcube/{{group}}/{{name}}/{{version}}/{{name}}-{{version}}.jar",
|
||||||
|
"desired_name": "{{name}}-v{{version}}.jar"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}",
|
||||||
|
"grants": [
|
||||||
|
{
|
||||||
|
"id": "004260",
|
||||||
|
"name": "DILIGENT",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/004260"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "212488",
|
||||||
|
"name": "D4Science",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/212488"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "239019",
|
||||||
|
"name": "D4Science-II",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/239019"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "283465",
|
||||||
|
"name": "ENVRI",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/283465"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "283644",
|
||||||
|
"name": "iMarine",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/283644"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "288754",
|
||||||
|
"name": "EUBrazilOpenBio",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/288754"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "654024",
|
||||||
|
"name": "SoBigData",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/654024"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "654119",
|
||||||
|
"name": "PARTHENOS",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/654119"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "654142",
|
||||||
|
"name": "EGI-Engage",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/654142"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "654182",
|
||||||
|
"name": "ENVRI PLUS",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/654182"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "675680",
|
||||||
|
"name": "BlueBRIDGE",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/675680"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "727610",
|
||||||
|
"name": "PerformFISH",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/727610"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "731001",
|
||||||
|
"name": "AGINFRA PLUS",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/731001"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "818194",
|
||||||
|
"name": "DESIRA",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/818194"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "823914",
|
||||||
|
"name": "ARIADNEplus",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/823914"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "824091",
|
||||||
|
"name": "RISIS 2",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/824091"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "857650",
|
||||||
|
"name": "EOSC-Pillar",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/857650"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "862409",
|
||||||
|
"name": "Blue Cloud",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/862409"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "871042",
|
||||||
|
"name": "SoBigData-PlusPlus",
|
||||||
|
"url": "https://cordis.europa.eu/project/id/871042"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"publishers": {
|
||||||
|
"ZenodoSoftwareVersionPublisher": {
|
||||||
|
"elaboration": "NONE",
|
||||||
|
"additional_html_description": "\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> is an open-source software toolkit used for building and operating Hybrid Data Infrastructures enabling the dynamic deployment of Virtual Research Environments, such as the <a href=\"https://www.d4science.org/\">D4Science Infrastructure</a>, by favouring the realisation of reuse-oriented policies.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> has been used to successfully build and operate infrastructures and virtual research environments for application domains ranging from biodiversity to environmental data management and cultural heritage.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> offers components supporting typical data management workflows including data access, curation, processing, and visualisation on a large set of data typologies ranging from primary biodiversity data to geospatial and tabular data.</p>\n\n<p><a href=\"https://www.d4science.org/\">D4Science</a> is a Hybrid Data Infrastructure combining over 500 software components and integrating data from more than 50 different data providers into a coherent and managed system of hardware, software, and data resources. The D4Science infrastructure drastically reduces the cost of ownership, maintenance, and operation thanks to the exploitation of gCube.</p>\n\n<p> </p>\n\n<p>The official source code location of this software version is available at:</p>\n\n<p><a href=\"{{code_location}}\">{{code_location}}</a></p>",
|
||||||
|
"skip_grants": ["004260"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"exporters": {
|
||||||
|
"BibLaTeXSoftwareVersionExporter": {
|
||||||
|
"elaboration": "ALL"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"export_filename": "{{name}}"
|
||||||
|
},
|
||||||
|
"versions": [
|
||||||
|
{
|
||||||
|
"version": "1.0.0",
|
||||||
|
"date": "2019-02-26",
|
||||||
|
"group": "data-publishing",
|
||||||
|
"gcube_release_version": "4.13.1",
|
||||||
|
"gcube_release_ticket": "https://support.d4science.org/issues/13242",
|
||||||
|
"concept_doi_url": null,
|
||||||
|
"version_doi_url": null,
|
||||||
|
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.1.0",
|
||||||
|
"date": "2019-05-27",
|
||||||
|
"group": "data-publishing",
|
||||||
|
"gcube_release_version": "4.14.0",
|
||||||
|
"gcube_release_ticket": "https://support.d4science.org/issues/16357",
|
||||||
|
"concept_doi_url": "PREVIOUS",
|
||||||
|
"version_doi_url": null,
|
||||||
|
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.2.0",
|
||||||
|
"date": "2019-11-06",
|
||||||
|
"group": "data-publishing",
|
||||||
|
"gcube_release_version": "4.15.0",
|
||||||
|
"gcube_release_ticket": "https://support.d4science.org/issues/16746",
|
||||||
|
"concept_doi_url": "PREVIOUS",
|
||||||
|
"version_doi_url": null,
|
||||||
|
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.2.1",
|
||||||
|
"date": "2019-12-20",
|
||||||
|
"group": "data-publishing",
|
||||||
|
"gcube_release_version": "4.18.0",
|
||||||
|
"gcube_release_ticket": "https://support.d4science.org/issues/18337",
|
||||||
|
"version_doi_url": null,
|
||||||
|
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.2.2",
|
||||||
|
"date": "2021-02-24",
|
||||||
|
"group": "data-publishing",
|
||||||
|
"gcube_release_version": "5.0.0",
|
||||||
|
"gcube_release_ticket": "https://support.d4science.org/issues/20649",
|
||||||
|
"version_doi_url": null,
|
||||||
|
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"date": "2021-05-04",
|
||||||
|
"gcube_release_version": "5.2.0",
|
||||||
|
"gcube_release_ticket": "https://support.d4science.org/issues/19740",
|
||||||
|
"concept_doi_url": "https://doi.org/10.5281/zenodo.7447655",
|
||||||
|
"version_doi_url": "https://doi.org/10.5281/zenodo.7447656"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "2.1.0",
|
||||||
|
"date": "2022-01-27",
|
||||||
|
"gcube_release_version": "5.7.0",
|
||||||
|
"gcube_release_ticket": "https://support.d4science.org/issues/22542",
|
||||||
|
"concept_doi_url": "https://doi.org/10.5281/zenodo.7447655",
|
||||||
|
"version_doi_url": "https://doi.org/10.5281/zenodo.7447661"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "2.2.0",
|
||||||
|
"date": "2022-05-12",
|
||||||
|
"gcube_release_version": "5.11.0",
|
||||||
|
"gcube_release_ticket": "https://support.d4science.org/issues/22945",
|
||||||
|
"concept_doi_url": "https://doi.org/10.5281/zenodo.7447655",
|
||||||
|
"version_doi_url": "https://doi.org/10.5281/zenodo.7448594"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "2.3.0",
|
||||||
|
"date": "2022-09-19",
|
||||||
|
"gcube_release_version": "5.13.1",
|
||||||
|
"gcube_release_ticket": "https://support.d4science.org/issues/23698",
|
||||||
|
"concept_doi_url": "https://doi.org/10.5281/zenodo.7447655",
|
||||||
|
"version_doi_url": "https://doi.org/10.5281/zenodo.7448639"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "2.4.0",
|
||||||
|
"date": "2022-12-07",
|
||||||
|
"gcube_release_version": "5.14.0",
|
||||||
|
"gcube_release_ticket": "https://support.d4science.org/issues/23999",
|
||||||
|
"concept_doi_url": "https://doi.org/10.5281/zenodo.7447655",
|
||||||
|
"version_doi_url": "https://doi.org/10.5281/zenodo.7467199"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
47
pom.xml
47
pom.xml
|
@ -9,9 +9,9 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.data-catalogue</groupId>
|
<groupId>org.gcube.data-catalogue</groupId>
|
||||||
<artifactId>gcat-client</artifactId>
|
<artifactId>gcat-client</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>2.4.1</version>
|
||||||
<name>gCube Catalogue (gCat) Client</name>
|
<name>gCube Catalogue (gCat) Client</name>
|
||||||
<description>gCube Catalogue (gCat) Client is a library designed to interact with gCat Service exposed REST API</description>
|
<description>gCube Catalogue (gCat) Client is a library designed to interact with REST APIs exposed by the gCat Service.</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>gcube-bom</artifactId>
|
<artifactId>gcube-bom</artifactId>
|
||||||
<version>2.0.1</version>
|
<version>2.2.0</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.data-catalogue</groupId>
|
<groupId>org.gcube.data-catalogue</groupId>
|
||||||
<artifactId>gcat-api</artifactId>
|
<artifactId>gcat-api</artifactId>
|
||||||
<version>[2.0.0,3.0.0-SNAPSHOT)</version>
|
<version>[2.3.2,3.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.resources.discovery</groupId>
|
<groupId>org.gcube.resources.discovery</groupId>
|
||||||
|
@ -63,7 +63,25 @@
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>gcube-jackson-databind</artifactId>
|
<artifactId>gcube-jackson-databind</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>common-utility-sg3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Added to support Java 11 JDK -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.xml.ws</groupId>
|
||||||
|
<artifactId>jaxws-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- END Added to support Java 11 JDK -->
|
||||||
|
|
||||||
<!-- Test Dependencies -->
|
<!-- Test Dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>authorization-utils</artifactId>
|
||||||
|
<version>[2.1.0, 3.0.0-SNAPSHOT)</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -76,4 +94,25 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build.date</id>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>create-timestamp</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<timestampFormat>yyyy-MM-dd</timestampFormat>
|
||||||
|
<timestampPropertyName>build.date</timestampPropertyName>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,74 @@
|
||||||
|
package org.gcube.gcat.client;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import javax.xml.ws.WebServiceException;
|
||||||
|
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*/
|
||||||
|
public class Configuration extends GCatClient implements org.gcube.gcat.api.interfaces.Configuration<CatalogueConfiguration,Void> {
|
||||||
|
|
||||||
|
protected ObjectMapper mapper;
|
||||||
|
|
||||||
|
public Configuration() throws MalformedURLException {
|
||||||
|
super(CONFIGURATIONS);
|
||||||
|
mapper = new ObjectMapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Configuration(URL enforcedServiceURL) throws MalformedURLException {
|
||||||
|
super(enforcedServiceURL, CONFIGURATIONS);
|
||||||
|
mapper = new ObjectMapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CatalogueConfiguration getCatalogueConfigurationFromString(String json) throws WebServiceException {
|
||||||
|
try {
|
||||||
|
return mapper.readValue(json, CatalogueConfiguration.class);
|
||||||
|
} catch (WebServiceException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new WebServiceException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CatalogueConfiguration create(String json) throws WebServiceException {
|
||||||
|
String ret = super.create(json);
|
||||||
|
return getCatalogueConfigurationFromString(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CatalogueConfiguration read() throws WebServiceException {
|
||||||
|
String ret = super.read(CURRENT_CONTEXT_PATH_PARAMETER);
|
||||||
|
return getCatalogueConfigurationFromString(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CatalogueConfiguration update(String json) throws WebServiceException {
|
||||||
|
String ret = super.update(json, CURRENT_CONTEXT_PATH_PARAMETER);
|
||||||
|
return getCatalogueConfigurationFromString(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CatalogueConfiguration patch(String json) throws WebServiceException {
|
||||||
|
String ret = super.patch(json, CURRENT_CONTEXT_PATH_PARAMETER);
|
||||||
|
return getCatalogueConfigurationFromString(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void delete() throws WebServiceException {
|
||||||
|
super.delete(false, CURRENT_CONTEXT_PATH_PARAMETER);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void purge() throws WebServiceException {
|
||||||
|
super.delete(true, CURRENT_CONTEXT_PATH_PARAMETER);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
|
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
|
||||||
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||||
|
import org.gcube.common.http.GXHTTPUtility;
|
||||||
import org.gcube.gcat.api.GCatConstants;
|
import org.gcube.gcat.api.GCatConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,6 +35,8 @@ abstract class GCatClient {
|
||||||
|
|
||||||
protected GXHTTPStringRequest gxhttpStringRequest;
|
protected GXHTTPStringRequest gxhttpStringRequest;
|
||||||
|
|
||||||
|
protected Map<String, String> headers;
|
||||||
|
|
||||||
public void enforceServiceURL(URL enforcedServiceURL) {
|
public void enforceServiceURL(URL enforcedServiceURL) {
|
||||||
this.serviceURL = enforcedServiceURL;
|
this.serviceURL = enforcedServiceURL;
|
||||||
}
|
}
|
||||||
|
@ -43,13 +46,15 @@ abstract class GCatClient {
|
||||||
this.basePaths = new ArrayList<>();
|
this.basePaths = new ArrayList<>();
|
||||||
this.basePaths.add(basePath);
|
this.basePaths.add(basePath);
|
||||||
this.basePaths.addAll(Arrays.asList(basePaths));
|
this.basePaths.addAll(Arrays.asList(basePaths));
|
||||||
|
this.headers = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GCatClient(String basePath, String... basePaths) throws MalformedURLException {
|
public GCatClient(String basePath, String... basePaths) throws MalformedURLException {
|
||||||
this.serviceURL = GCatClientDiscovery.getServiceURL();
|
this(GCatClientDiscovery.getServiceURL(), basePath, basePaths);
|
||||||
this.basePaths = new ArrayList<>();
|
}
|
||||||
this.basePaths.add(basePath);
|
|
||||||
this.basePaths.addAll(Arrays.asList(basePaths));
|
public void addHeader(String name, String value) {
|
||||||
|
headers.put(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static StringBuilder getStringBuilder(InputStream inputStream) throws IOException {
|
protected static StringBuilder getStringBuilder(InputStream inputStream) throws IOException {
|
||||||
|
@ -100,7 +105,10 @@ abstract class GCatClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initRequest() throws UnsupportedEncodingException {
|
protected void initRequest() throws UnsupportedEncodingException {
|
||||||
gxhttpStringRequest = GXHTTPStringRequest.newRequest(serviceURL.toString());
|
gxhttpStringRequest = GXHTTPUtility.getGXHTTPStringRequest(serviceURL.toString());
|
||||||
|
for(String name : headers.keySet()) {
|
||||||
|
gxhttpStringRequest.header(name, headers.get(name));
|
||||||
|
}
|
||||||
gxhttpStringRequest.from(GCatClient.class.getSimpleName());
|
gxhttpStringRequest.from(GCatClient.class.getSimpleName());
|
||||||
for(String p : basePaths) {
|
for(String p : basePaths) {
|
||||||
gxhttpStringRequest.path(p);
|
gxhttpStringRequest.path(p);
|
||||||
|
@ -114,6 +122,7 @@ abstract class GCatClient {
|
||||||
gxhttpStringRequest.path(p);
|
gxhttpStringRequest.path(p);
|
||||||
}
|
}
|
||||||
gxhttpStringRequest.queryParams(queryParams);
|
gxhttpStringRequest.queryParams(queryParams);
|
||||||
|
gxhttpStringRequest.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
|
||||||
HttpURLConnection httpURLConnection = gxhttpStringRequest.get();
|
HttpURLConnection httpURLConnection = gxhttpStringRequest.get();
|
||||||
return parseHttpURLConnection(httpURLConnection);
|
return parseHttpURLConnection(httpURLConnection);
|
||||||
}catch (WebApplicationException e) {
|
}catch (WebApplicationException e) {
|
||||||
|
|
|
@ -8,10 +8,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.context.ContextUtility;
|
||||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.gcat.api.GCatConstants;
|
import org.gcube.gcat.api.GCatConstants;
|
||||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
import org.gcube.resources.discovery.icclient.ICFactory;
|
import org.gcube.resources.discovery.icclient.ICFactory;
|
||||||
|
@ -33,7 +32,7 @@ public class GCatClientDiscovery {
|
||||||
|
|
||||||
protected static void forceToURL(String adddress) throws MalformedURLException {
|
protected static void forceToURL(String adddress) throws MalformedURLException {
|
||||||
if(adddress!=null && adddress.compareTo("")!=0) {
|
if(adddress!=null && adddress.compareTo("")!=0) {
|
||||||
String context = getContext();
|
String context = ContextUtility.getCurrentContextFullName();
|
||||||
URL url = new URL(adddress);
|
URL url = new URL(adddress);
|
||||||
clients.put(context, url);
|
clients.put(context, url);
|
||||||
}
|
}
|
||||||
|
@ -51,9 +50,9 @@ public class GCatClientDiscovery {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static SimpleQuery queryForService(){
|
private static SimpleQuery queryForService(String serviceClass){
|
||||||
return ICFactory.queryFor(GCoreEndpoint.class)
|
return ICFactory.queryFor(GCoreEndpoint.class)
|
||||||
.addCondition(String.format(classFormat, GCatConstants.SERVICE_CLASS))
|
.addCondition(String.format(classFormat, serviceClass))
|
||||||
.addCondition(String.format(nameFormat, GCatConstants.SERVICE_NAME))
|
.addCondition(String.format(nameFormat, GCatConstants.SERVICE_NAME))
|
||||||
.addCondition(String.format(statusFormat))
|
.addCondition(String.format(statusFormat))
|
||||||
.addVariable("$entry","$resource/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint")
|
.addVariable("$entry","$resource/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint")
|
||||||
|
@ -61,9 +60,9 @@ public class GCatClientDiscovery {
|
||||||
.setResult("$entry/text()");
|
.setResult("$entry/text()");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SimpleQuery queryForProxy(){
|
private static SimpleQuery queryForProxy(String serviceClass){
|
||||||
return ICFactory.queryFor(ServiceEndpoint.class)
|
return ICFactory.queryFor(ServiceEndpoint.class)
|
||||||
.addCondition(String.format(serviceEndpointCategoryFormat, GCatConstants.SERVICE_CLASS))
|
.addCondition(String.format(serviceEndpointCategoryFormat, serviceClass))
|
||||||
.addCondition(String.format(serviceEndpointNameFormat, GCatConstants.SERVICE_NAME))
|
.addCondition(String.format(serviceEndpointNameFormat, GCatConstants.SERVICE_NAME))
|
||||||
.addCondition(String.format(serviceEndpointstatusFormat))
|
.addCondition(String.format(serviceEndpointstatusFormat))
|
||||||
.addVariable("$entry","$resource/Profile/AccessPoint/Interface/Endpoint")
|
.addVariable("$entry","$resource/Profile/AccessPoint/Interface/Endpoint")
|
||||||
|
@ -74,40 +73,22 @@ public class GCatClientDiscovery {
|
||||||
|
|
||||||
protected static List<String> getAddresses(){
|
protected static List<String> getAddresses(){
|
||||||
List<String> addresses = new ArrayList<>();
|
List<String> addresses = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SimpleQuery proxyQuery = queryForProxy();
|
SimpleQuery proxyQuery = queryForProxy(GCatConstants.SERVICE_CLASS);
|
||||||
addresses = ICFactory.client().submit(proxyQuery);
|
addresses = ICFactory.client().submit(proxyQuery);
|
||||||
if(addresses==null || addresses.isEmpty()){
|
if(addresses==null || addresses.isEmpty()){
|
||||||
throw new Exception("No ResourceRegistry Proxy Found");
|
throw new Exception("No ResourceRegistry Proxy Found");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.debug("{}. Looking for RunningInstance.", e.getMessage());
|
logger.debug("{}. Looking for RunningInstance.", e.getMessage());
|
||||||
SimpleQuery serviceQuery = queryForService();
|
SimpleQuery serviceQuery = queryForService(GCatConstants.SERVICE_CLASS);
|
||||||
addresses = ICFactory.client().submit(serviceQuery);
|
addresses = ICFactory.client().submit(serviceQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
return addresses;
|
return addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static String getContext() {
|
|
||||||
String context = null;
|
|
||||||
if (SecurityTokenProvider.instance.get() == null) {
|
|
||||||
if (ScopeProvider.instance.get() == null) {
|
|
||||||
throw new RuntimeException(
|
|
||||||
"Null Token and Scope. Please set your token first.");
|
|
||||||
}
|
|
||||||
context = ScopeProvider.instance.get();
|
|
||||||
} else {
|
|
||||||
context = SecurityTokenProvider.instance.get();
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static URL getServiceURL() throws MalformedURLException {
|
public static URL getServiceURL() throws MalformedURLException {
|
||||||
|
String context = ContextUtility.getCurrentContextFullName();
|
||||||
String context = getContext();
|
|
||||||
URL url = clients.get(context);
|
URL url = clients.get(context);
|
||||||
|
|
||||||
if(url==null){
|
if(url==null){
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class Group extends GCatClient implements org.gcube.gcat.api.interfaces.G
|
||||||
@Override
|
@Override
|
||||||
public int count() throws WebServiceException {
|
public int count() throws WebServiceException {
|
||||||
Map<String, String> queryParams = new HashMap<>();
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.COUNT_PARAMETER, String.valueOf(true));
|
queryParams.put(GCatConstants.COUNT_QUERY_PARAMETER, String.valueOf(true));
|
||||||
String ret = this.list(queryParams);
|
String ret = this.list(queryParams);
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
try {
|
try {
|
||||||
|
@ -44,8 +44,8 @@ public class Group extends GCatClient implements org.gcube.gcat.api.interfaces.G
|
||||||
@Override
|
@Override
|
||||||
public String list(int limit, int offset) throws WebApplicationException {
|
public String list(int limit, int offset) throws WebApplicationException {
|
||||||
Map<String, String> queryParams = new HashMap<>();
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.LIMIT_PARAMETER, String.valueOf(limit));
|
queryParams.put(GCatConstants.LIMIT_QUERY_PARAMETER, String.valueOf(limit));
|
||||||
queryParams.put(GCatConstants.OFFSET_PARAMETER, String.valueOf(offset));
|
queryParams.put(GCatConstants.OFFSET_QUERY_PARAMETER, String.valueOf(offset));
|
||||||
return super.list(queryParams);
|
return super.list(queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.gcat.client;
|
package org.gcube.gcat.client;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -11,6 +12,8 @@ import javax.xml.ws.WebServiceException;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.gcube.gcat.api.GCatConstants;
|
import org.gcube.gcat.api.GCatConstants;
|
||||||
|
import org.gcube.gcat.api.moderation.CMItemStatus;
|
||||||
|
import org.gcube.gcat.api.moderation.ModerationContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
@ -25,10 +28,9 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
|
||||||
super(enforcedServiceURL, ITEMS);
|
super(enforcedServiceURL, ITEMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count() throws WebServiceException {
|
public int count() throws WebServiceException {
|
||||||
Map<String, String> queryParams = new HashMap<>();
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.COUNT_PARAMETER, String.valueOf(true));
|
queryParams.put(GCatConstants.COUNT_QUERY_PARAMETER, String.valueOf(true));
|
||||||
String ret = this.list(queryParams);
|
String ret = this.list(queryParams);
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
try {
|
try {
|
||||||
|
@ -50,12 +52,11 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
|
||||||
@Override
|
@Override
|
||||||
public String list(int limit, int offset) throws WebApplicationException {
|
public String list(int limit, int offset) throws WebApplicationException {
|
||||||
Map<String, String> queryParams = new HashMap<>();
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.LIMIT_PARAMETER, String.valueOf(limit));
|
queryParams.put(GCatConstants.LIMIT_QUERY_PARAMETER, String.valueOf(limit));
|
||||||
queryParams.put(GCatConstants.OFFSET_PARAMETER, String.valueOf(offset));
|
queryParams.put(GCatConstants.OFFSET_QUERY_PARAMETER, String.valueOf(offset));
|
||||||
return this.list(queryParams);
|
return this.list(queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String list(Map<String,String> queryParams) throws WebApplicationException {
|
public String list(Map<String,String> queryParams) throws WebApplicationException {
|
||||||
return super.list(queryParams);
|
return super.list(queryParams);
|
||||||
}
|
}
|
||||||
|
@ -66,8 +67,8 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
|
||||||
*/
|
*/
|
||||||
public String list(int limit, int offset, String organizationName) throws WebApplicationException {
|
public String list(int limit, int offset, String organizationName) throws WebApplicationException {
|
||||||
Map<String, String> queryParams = new HashMap<>();
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.LIMIT_PARAMETER, String.valueOf(limit));
|
queryParams.put(GCatConstants.LIMIT_QUERY_PARAMETER, String.valueOf(limit));
|
||||||
queryParams.put(GCatConstants.OFFSET_PARAMETER, String.valueOf(offset));
|
queryParams.put(GCatConstants.OFFSET_QUERY_PARAMETER, String.valueOf(offset));
|
||||||
queryParams.put(GCatConstants.Q_KEY, String.format(GCatConstants.ORGANIZATION_FILTER_TEMPLATE, organizationName));
|
queryParams.put(GCatConstants.Q_KEY, String.format(GCatConstants.ORGANIZATION_FILTER_TEMPLATE, organizationName));
|
||||||
return super.list(queryParams);
|
return super.list(queryParams);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +76,7 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
|
||||||
public String create(String json, boolean socialPost) throws WebApplicationException {
|
public String create(String json, boolean socialPost) throws WebApplicationException {
|
||||||
try {
|
try {
|
||||||
Map<String,String> queryParams = new HashMap<>();
|
Map<String,String> queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.SOCIAL_POST_PARAMETER, String.valueOf(socialPost));
|
queryParams.put(GCatConstants.SOCIAL_POST_QUERY_PARAMETER, String.valueOf(socialPost));
|
||||||
return super.create(json, queryParams);
|
return super.create(json, queryParams);
|
||||||
}catch (WebApplicationException e) {
|
}catch (WebApplicationException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -122,4 +123,84 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Void bulkDelete(Map<String,String> queryParams, boolean purge) throws WebServiceException{
|
||||||
|
try {
|
||||||
|
initRequest();
|
||||||
|
if(queryParams==null) {
|
||||||
|
queryParams = new HashMap<>();
|
||||||
|
}
|
||||||
|
queryParams.put(GCatConstants.PURGE_QUERY_PARAMETER, String.valueOf(purge));
|
||||||
|
gxhttpStringRequest.queryParams(queryParams);
|
||||||
|
HttpURLConnection httpURLConnection = gxhttpStringRequest.delete();
|
||||||
|
parseHttpURLConnection(httpURLConnection);
|
||||||
|
return null;
|
||||||
|
}catch (WebApplicationException e) {
|
||||||
|
throw e;
|
||||||
|
}catch (Exception e) {
|
||||||
|
throw new WebApplicationException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Void bulkDelete(boolean purge) throws WebServiceException{
|
||||||
|
return bulkDelete(null, purge);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Void bulkPurge() throws WebServiceException {
|
||||||
|
return bulkDelete(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String moderate(String name, ModerationContent moderationContent) {
|
||||||
|
return moderate(name, moderationContent, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String moderate(String name, ModerationContent moderationContent, Map<String,String> queryParams) {
|
||||||
|
try {
|
||||||
|
initRequest();
|
||||||
|
gxhttpStringRequest.path(name);
|
||||||
|
if(queryParams!=null && queryParams.size()>0) {
|
||||||
|
gxhttpStringRequest.queryParams(queryParams);
|
||||||
|
}
|
||||||
|
String moderationContentString = (new ObjectMapper()).writeValueAsString(moderationContent);
|
||||||
|
gxhttpStringRequest.header("Content-Type", GCatConstants.APPLICATION_JSON_CHARSET_UTF_8);
|
||||||
|
gxhttpStringRequest.withBody(moderationContentString);
|
||||||
|
HttpURLConnection httpURLConnection = gxhttpStringRequest.post();
|
||||||
|
return parseHttpURLConnection(httpURLConnection);
|
||||||
|
}catch (WebApplicationException e) {
|
||||||
|
throw e;
|
||||||
|
}catch (Exception e) {
|
||||||
|
throw new WebApplicationException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String approve(String name, String moderatorMessage) {
|
||||||
|
ModerationContent moderationContent = new ModerationContent();
|
||||||
|
moderationContent.setCMItemStatus(CMItemStatus.APPROVED);
|
||||||
|
moderationContent.setMessage(moderatorMessage);
|
||||||
|
return approve(name, moderatorMessage, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String approve(String name, String moderatorMessage, boolean socialPost) {
|
||||||
|
ModerationContent moderationContent = new ModerationContent();
|
||||||
|
moderationContent.setCMItemStatus(CMItemStatus.APPROVED);
|
||||||
|
moderationContent.setMessage(moderatorMessage);
|
||||||
|
Map<String,String> queryParams = new HashMap<>();
|
||||||
|
queryParams.put(GCatConstants.SOCIAL_POST_QUERY_PARAMETER, String.valueOf(socialPost));
|
||||||
|
return moderate(name, moderationContent, queryParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String reject(String name, String moderatorMessage) {
|
||||||
|
ModerationContent moderationContent = new ModerationContent();
|
||||||
|
moderationContent.setCMItemStatus(CMItemStatus.REJECTED);
|
||||||
|
moderationContent.setMessage(moderatorMessage);
|
||||||
|
return moderate(name, moderationContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void message(String name, String message) {
|
||||||
|
ModerationContent moderationContent = new ModerationContent();
|
||||||
|
moderationContent.setMessage(message);
|
||||||
|
moderate(name, moderationContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class Organization extends GCatClient implements org.gcube.gcat.api.inter
|
||||||
@Override
|
@Override
|
||||||
public int count() throws WebServiceException {
|
public int count() throws WebServiceException {
|
||||||
Map<String, String> queryParams = new HashMap<>();
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.COUNT_PARAMETER, String.valueOf(true));
|
queryParams.put(GCatConstants.COUNT_QUERY_PARAMETER, String.valueOf(true));
|
||||||
String ret = this.list(queryParams);
|
String ret = this.list(queryParams);
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
try {
|
try {
|
||||||
|
@ -44,8 +44,8 @@ public class Organization extends GCatClient implements org.gcube.gcat.api.inter
|
||||||
@Override
|
@Override
|
||||||
public String list(int limit, int offset) throws WebApplicationException {
|
public String list(int limit, int offset) throws WebApplicationException {
|
||||||
Map<String, String> queryParams = new HashMap<>();
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.LIMIT_PARAMETER, String.valueOf(limit));
|
queryParams.put(GCatConstants.LIMIT_QUERY_PARAMETER, String.valueOf(limit));
|
||||||
queryParams.put(GCatConstants.OFFSET_PARAMETER, String.valueOf(offset));
|
queryParams.put(GCatConstants.OFFSET_QUERY_PARAMETER, String.valueOf(offset));
|
||||||
return super.list(queryParams);
|
return super.list(queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class Profile extends GCatClient implements org.gcube.gcat.api.interfaces
|
||||||
@Override
|
@Override
|
||||||
public int count() throws WebServiceException {
|
public int count() throws WebServiceException {
|
||||||
Map<String, String> queryParams = new HashMap<>();
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.COUNT_PARAMETER, String.valueOf(true));
|
queryParams.put(GCatConstants.COUNT_QUERY_PARAMETER, String.valueOf(true));
|
||||||
String ret = this.list(queryParams);
|
String ret = this.list(queryParams);
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.gcube.gcat.client;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
import javax.xml.ws.WebServiceException;
|
||||||
|
|
||||||
|
import org.gcube.gcat.api.GCatConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI-CNR)
|
||||||
|
*/
|
||||||
|
public class Trash extends GCatClient implements org.gcube.gcat.api.interfaces.Trash<Void> {
|
||||||
|
|
||||||
|
public Trash() throws MalformedURLException {
|
||||||
|
super(TRASH);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String list(Boolean ownOnly) throws WebServiceException {
|
||||||
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
|
queryParams.put(GCatConstants.OWN_ONLY_QUERY_PARAMETER, String.valueOf(ownOnly));
|
||||||
|
String ret = this.list(queryParams);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void empty(Boolean ownOnly) throws WebServiceException {
|
||||||
|
try {
|
||||||
|
initRequest();
|
||||||
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
|
queryParams.put(GCatConstants.OWN_ONLY_QUERY_PARAMETER, String.valueOf(ownOnly));
|
||||||
|
gxhttpStringRequest.queryParams(queryParams);
|
||||||
|
HttpURLConnection httpURLConnection = gxhttpStringRequest.delete();
|
||||||
|
parseHttpURLConnection(httpURLConnection);
|
||||||
|
return null;
|
||||||
|
}catch (WebApplicationException e) {
|
||||||
|
throw e;
|
||||||
|
}catch (Exception e) {
|
||||||
|
throw new WebApplicationException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,14 +5,10 @@ import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.gcube.common.authorization.client.Constants;
|
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
import org.gcube.common.authorization.utils.secret.GCubeSecret;
|
||||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
import org.gcube.common.authorization.utils.secret.Secret;
|
||||||
import org.gcube.common.authorization.library.provider.ClientInfo;
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
||||||
import org.gcube.common.authorization.library.utils.Caller;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -24,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class ContextTest {
|
public class ContextTest {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ContextTest.class);
|
private static Logger logger = LoggerFactory.getLogger(ContextTest.class);
|
||||||
|
|
||||||
protected static Properties properties;
|
protected static Properties properties;
|
||||||
protected static final String PROPERTIES_FILENAME = "token.properties";
|
protected static final String PROPERTIES_FILENAME = "token.properties";
|
||||||
|
@ -33,8 +29,9 @@ public class ContextTest {
|
||||||
public static final String GCAT_URL_PROPERTY = "GCAT_URL_PROPERTY";
|
public static final String GCAT_URL_PROPERTY = "GCAT_URL_PROPERTY";
|
||||||
public static String GCAT_URL;
|
public static String GCAT_URL;
|
||||||
|
|
||||||
|
public static final String ROOT;
|
||||||
public static final String DEFAULT_TEST_CONTEXT_NAME;
|
public static final String VO;
|
||||||
|
public static final String VRE;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
|
@ -47,14 +44,9 @@ public class ContextTest {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//DEFAULT_TEST_CONTEXT_NAME = "/pred4s/preprod/preVRE";
|
ROOT = "/gcube";
|
||||||
DEFAULT_TEST_CONTEXT_NAME = "/gcube/devsec/devVRE";
|
VO = ROOT + "/devsec";
|
||||||
|
VRE = VO + "/devVRE";
|
||||||
try {
|
|
||||||
setContextByName(DEFAULT_TEST_CONTEXT_NAME);
|
|
||||||
} catch(Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Properties gcatProperties = new Properties();
|
Properties gcatProperties = new Properties();
|
||||||
input = ContextTest.class.getClassLoader().getResourceAsStream(GCAT_PROPERTIES_FILENAME);
|
input = ContextTest.class.getClassLoader().getResourceAsStream(GCAT_PROPERTIES_FILENAME);
|
||||||
|
@ -76,47 +68,45 @@ public class ContextTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCurrentContextFullName() {
|
public static void set(Secret secret) throws Exception {
|
||||||
String token = SecurityTokenProvider.instance.get();
|
SecretManagerProvider.instance.reset();
|
||||||
AuthorizationEntry authorizationEntry = null;
|
SecretManager secretManager = new SecretManager();
|
||||||
try {
|
SecretManagerProvider.instance.set(secretManager);
|
||||||
authorizationEntry = Constants.authorizationService().get(token);
|
secretManager.addSecret(secret);
|
||||||
} catch(Exception e) {
|
secretManager.set();
|
||||||
return ScopeProvider.instance.get();
|
String username = secretManager.getUser().getUsername();
|
||||||
}
|
String context = secretManager.getContext();
|
||||||
return authorizationEntry.getContext();
|
logger.debug("Set authorization for user {} in context {}", username, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getContextFullName(String token) throws ObjectNotFound, Exception {
|
public static void setContext(String token) throws Exception {
|
||||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
Secret secret = getSecret(token);
|
||||||
return authorizationEntry.getContext();
|
set(secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setContextByName(String fullContextName) throws ObjectNotFound, Exception {
|
public static void setContextByName(String fullContextName) throws Exception {
|
||||||
|
Secret secret = getSecretByContextName(fullContextName);
|
||||||
|
set(secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Secret getSecret(String token) throws Exception {
|
||||||
|
GCubeSecret secret = new GCubeSecret(token);
|
||||||
|
return secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Secret getSecretByContextName(String fullContextName) throws Exception {
|
||||||
String token = ContextTest.properties.getProperty(fullContextName);
|
String token = ContextTest.properties.getProperty(fullContextName);
|
||||||
setContext(token);
|
return getSecret(token);
|
||||||
}
|
|
||||||
|
|
||||||
public static void setContext(String token) throws ObjectNotFound, Exception {
|
|
||||||
SecurityTokenProvider.instance.set(token);
|
|
||||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
|
||||||
ClientInfo clientInfo = authorizationEntry.getClientInfo();
|
|
||||||
logger.debug("User : {} - Type : {}", clientInfo.getId(), clientInfo.getType().name());
|
|
||||||
String qualifier = authorizationEntry.getQualifier();
|
|
||||||
Caller caller = new Caller(clientInfo, qualifier);
|
|
||||||
AuthorizationProvider.instance.set(caller);
|
|
||||||
ScopeProvider.instance.set(getContextFullName(token));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
setContextByName(DEFAULT_TEST_CONTEXT_NAME);
|
setContextByName(VRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
SecurityTokenProvider.instance.reset();
|
SecretManagerProvider.instance.reset();
|
||||||
ScopeProvider.instance.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.gcube.gcat.client;
|
package org.gcube.gcat.client;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -12,8 +11,10 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JavaType;
|
import org.gcube.com.fasterxml.jackson.databind.JavaType;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||||
import org.gcube.gcat.api.GCatConstants;
|
import org.gcube.gcat.api.GCatConstants;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -26,7 +27,7 @@ public class ItemTest extends ContextTest {
|
||||||
private static Logger logger = LoggerFactory.getLogger(ItemTest.class);
|
private static Logger logger = LoggerFactory.getLogger(ItemTest.class);
|
||||||
|
|
||||||
private static final String NAME_KEY = "name";
|
private static final String NAME_KEY = "name";
|
||||||
private static final String NAME_VALUE = "00";
|
public static final String NAME_VALUE = "00";
|
||||||
|
|
||||||
private static final String TITLE_KEY = "title";
|
private static final String TITLE_KEY = "title";
|
||||||
private static final String TITLE_VALUE = "00 Title";
|
private static final String TITLE_VALUE = "00 Title";
|
||||||
|
@ -49,49 +50,14 @@ public class ItemTest extends ContextTest {
|
||||||
|
|
||||||
private static final String ID_KEY = "id";
|
private static final String ID_KEY = "id";
|
||||||
|
|
||||||
// @Test
|
|
||||||
public void deleteAllItems() throws Exception {
|
|
||||||
// ContextTest.setContext("");
|
|
||||||
/*
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
JavaType listType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, String.class);
|
|
||||||
|
|
||||||
Item item = new Item();
|
|
||||||
String itemsString = item.list(1000, 0);
|
|
||||||
logger.debug("Got items {}", itemsString);
|
|
||||||
|
|
||||||
List<String> items = mapper.readValue(itemsString, listType);
|
|
||||||
logger.debug("Going to purge {} items", items.size());
|
|
||||||
for(String name : items) {
|
|
||||||
logger.debug("Going to purge item with name : {}", name);
|
|
||||||
try {
|
|
||||||
item.purge(name);
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("Error while purging item with name {}", name, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCount() throws MalformedURLException {
|
public void testCount() throws MalformedURLException {
|
||||||
Item item = new Item();
|
Item item = new Item();
|
||||||
int count = item.count();
|
int count = item.count();
|
||||||
logger.debug("The items published in the organization corresponding to the VRE {} are {}", ContextTest.getCurrentContextFullName(), count);
|
logger.debug("The items published in the organization corresponding to the VRE {} are {}", SecretManagerProvider.instance.get().getContext(), count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public String createItem(ObjectMapper mapper, String licenseID) throws Exception {
|
||||||
public void completeTest() throws IOException {
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
JavaType listType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, String.class);
|
|
||||||
|
|
||||||
JavaType licenseArrayType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, JsonNode.class);
|
|
||||||
License license = new License();
|
|
||||||
String licencesStrings = license.list();
|
|
||||||
logger.debug("Got licenses {}", licencesStrings);
|
|
||||||
List<JsonNode> licences = mapper.readValue(licencesStrings, licenseArrayType);
|
|
||||||
JsonNode licenseJsonNode = licences.get(0);
|
|
||||||
String licenseID = licenseJsonNode.get(ID_KEY).asText();
|
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String,Object> map = new HashMap<>();
|
||||||
map.put(NAME_KEY, NAME_VALUE);
|
map.put(NAME_KEY, NAME_VALUE);
|
||||||
|
@ -115,7 +81,42 @@ public class ItemTest extends ContextTest {
|
||||||
Item item = new Item();
|
Item item = new Item();
|
||||||
String json = mapper.writeValueAsString(map);
|
String json = mapper.writeValueAsString(map);
|
||||||
logger.debug("Going to create {}", json);
|
logger.debug("Going to create {}", json);
|
||||||
item.create(json);
|
return item.create(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLicenseID(ObjectMapper mapper) throws Exception {
|
||||||
|
JavaType licenseArrayType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, JsonNode.class);
|
||||||
|
License license = new License();
|
||||||
|
String licencesStrings = license.list();
|
||||||
|
logger.debug("Got licenses {}", licencesStrings);
|
||||||
|
List<JsonNode> licences = mapper.readValue(licencesStrings, licenseArrayType);
|
||||||
|
JsonNode licenseJsonNode = licences.get(0);
|
||||||
|
String licenseID = licenseJsonNode.get(ID_KEY).asText();
|
||||||
|
return licenseID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String createItem() throws Exception {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
String licenseID = getLicenseID(mapper);
|
||||||
|
return createItem(mapper, licenseID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteItem(boolean purge) throws Exception {
|
||||||
|
Item item = new Item();
|
||||||
|
item.delete(NAME_VALUE, purge);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Ignore
|
||||||
|
@Test
|
||||||
|
public void completeTest() throws Exception {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
JavaType listType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, String.class);
|
||||||
|
|
||||||
|
String licenseID = getLicenseID(mapper);
|
||||||
|
|
||||||
|
createItem(mapper, licenseID);
|
||||||
|
Item item = new Item();
|
||||||
try {
|
try {
|
||||||
String itemsString = item.list(10, 0);
|
String itemsString = item.list(10, 0);
|
||||||
logger.debug("Got items {}", itemsString);
|
logger.debug("Got items {}", itemsString);
|
||||||
|
@ -154,30 +155,34 @@ public class ItemTest extends ContextTest {
|
||||||
String itemsString = item.list(10, 0);
|
String itemsString = item.list(10, 0);
|
||||||
logger.debug("Got list", itemsString);
|
logger.debug("Got list", itemsString);
|
||||||
List<String> items = mapper.readValue(itemsString, listType);
|
List<String> items = mapper.readValue(itemsString, listType);
|
||||||
|
if(items.size()>0) {
|
||||||
String name = items.get(0);
|
String name = items.get(0);
|
||||||
Assert.assertTrue(name.compareTo(NAME_VALUE) != 0);
|
Assert.assertTrue(name.compareTo(NAME_VALUE) != 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Ignore
|
||||||
@Test
|
@Test
|
||||||
public void listOnVOTest() throws Exception {
|
public void listOnVOTest() throws Exception {
|
||||||
ContextTest.setContextByName("/gcube/devNext");
|
ContextTest.setContextByName(VRE);
|
||||||
|
|
||||||
Item item = new Item();
|
Item item = new Item();
|
||||||
String itemsString = item.list(10, 0, "dorne");
|
String itemsString = item.list(10, 0, "devvre");
|
||||||
logger.debug("Got list {}", itemsString);
|
logger.debug("Got list {}", itemsString);
|
||||||
|
|
||||||
|
/*
|
||||||
Map<String,String> queryParams = new HashMap<>();
|
Map<String,String> queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.Q_KEY, "organization:dorne OR organization:ckand4scienceharvest");
|
queryParams.put(GCatConstants.Q_KEY, "organization:org1 OR organization:org2");
|
||||||
itemsString = item.list(queryParams);
|
itemsString = item.list(queryParams);
|
||||||
logger.debug("Got list {}", itemsString);
|
logger.debug("Got list {}", itemsString);
|
||||||
|
|
||||||
queryParams = new HashMap<>();
|
queryParams = new HashMap<>();
|
||||||
queryParams.put(GCatConstants.Q_KEY, "organization:ckand4scienceharvest");
|
queryParams.put(GCatConstants.Q_KEY, "organization:org3");
|
||||||
queryParams.put("rows", "4");
|
queryParams.put("rows", "4");
|
||||||
queryParams.put("start", "4");
|
queryParams.put("start", "4");
|
||||||
itemsString = item.list(queryParams);
|
itemsString = item.list(queryParams);
|
||||||
logger.debug("Got list {}", itemsString);
|
logger.debug("Got list {}", itemsString);
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
@ -196,6 +201,7 @@ public class ItemTest extends ContextTest {
|
||||||
logger.debug("Got list {}", itemsString);
|
logger.debug("Got list {}", itemsString);
|
||||||
|
|
||||||
List<String> items = mapper.readValue(itemsString, listType);
|
List<String> items = mapper.readValue(itemsString, listType);
|
||||||
|
if(items.size()>0) {
|
||||||
String name = items.get(0);
|
String name = items.get(0);
|
||||||
|
|
||||||
String ret = item.read(name);
|
String ret = item.read(name);
|
||||||
|
@ -205,10 +211,12 @@ public class ItemTest extends ContextTest {
|
||||||
String gotName = jsonNode.get(NAME_KEY).asText();
|
String gotName = jsonNode.get(NAME_KEY).asText();
|
||||||
Assert.assertTrue(name.compareTo(gotName) == 0);
|
Assert.assertTrue(name.compareTo(gotName) == 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected static final String SEARCHABLE_KEY = "searchable";
|
protected static final String SEARCHABLE_KEY = "searchable";
|
||||||
public static final String GCAT_URL_STRING = "https://gcat.d4science.org/gcat";
|
public static final String GCAT_URL_STRING = "https://gcat.d4science.org/gcat";
|
||||||
|
|
||||||
|
@Ignore
|
||||||
// @Test
|
// @Test
|
||||||
public void findNotSearchable() throws Exception {
|
public void findNotSearchable() throws Exception {
|
||||||
ContextTest.setContextByName("/d4science.research-infrastructures.eu/SoBigData/ResourceCatalogue");
|
ContextTest.setContextByName("/d4science.research-infrastructures.eu/SoBigData/ResourceCatalogue");
|
||||||
|
@ -233,6 +241,7 @@ public class ItemTest extends ContextTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
// @Test
|
// @Test
|
||||||
public void purgeAll() throws Exception {
|
public void purgeAll() throws Exception {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
@ -250,4 +259,22 @@ public class ItemTest extends ContextTest {
|
||||||
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
|
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Ignore
|
||||||
|
@Test
|
||||||
|
public void testBulkPurge() throws Exception {
|
||||||
|
Item item = new Item();
|
||||||
|
Map<String,String> queryParams = new HashMap<>();
|
||||||
|
queryParams.put(GCatConstants.OWN_ONLY_QUERY_PARAMETER, "false");
|
||||||
|
item.bulkDelete(queryParams, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testModeration() throws Exception {
|
||||||
|
ContextTest.setContextByName("/pred4s/preprod/Dorne");
|
||||||
|
Item item = new Item();
|
||||||
|
item.reject("my_first_restful_transaction_model_private", "Questo item non mi piace");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,13 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JavaType;
|
import org.gcube.com.fasterxml.jackson.databind.JavaType;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
|
import org.gcube.gcat.api.GCatConstants;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -22,7 +26,7 @@ public class LicenseTest extends ContextTest {
|
||||||
private static final String ID_KEY = "id";
|
private static final String ID_KEY = "id";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void safeTest() throws IOException {
|
public void testList() throws IOException {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
JavaType licenseArrayType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, JsonNode.class);
|
JavaType licenseArrayType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, JsonNode.class);
|
||||||
|
@ -36,4 +40,21 @@ public class LicenseTest extends ContextTest {
|
||||||
logger.debug("License : {}", licenseID);
|
logger.debug("License : {}", licenseID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListAsJSONAPI() throws IOException {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
License license = new License();
|
||||||
|
license.addHeader(HttpHeaders.ACCEPT, GCatConstants.APPLICATION_JSON_API);
|
||||||
|
String licencesStrings = license.list();
|
||||||
|
logger.debug("Got licenses {}", licencesStrings);
|
||||||
|
JsonNode licencesWrapper = mapper.readTree(licencesStrings);
|
||||||
|
ArrayNode licences = (ArrayNode) licencesWrapper.get(GCatConstants.JSON_API_DATA_FIELD_NAME);
|
||||||
|
Assert.assertTrue(licences.size()>0);
|
||||||
|
for(JsonNode licenseJsonNode : licences) {
|
||||||
|
String licenseID = licenseJsonNode.get(ID_KEY).asText();
|
||||||
|
logger.debug("License : {}", licenseID);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class ProfileTest extends ContextTest {
|
||||||
Profile profile = new Profile();
|
Profile profile = new Profile();
|
||||||
profile.create(PROFILE_NAME, String.format(PROFILE_XML, PROFILE_NAME));
|
profile.create(PROFILE_NAME, String.format(PROFILE_XML, PROFILE_NAME));
|
||||||
|
|
||||||
|
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
|
||||||
String list = profile.list();
|
String list = profile.list();
|
||||||
logger.debug("Got Profiles {}\n", list);
|
logger.debug("Got Profiles {}\n", list);
|
||||||
|
|
||||||
|
@ -105,15 +105,21 @@ public class ProfileTest extends ContextTest {
|
||||||
throw new NotFoundException(String.format("%s not found after %d retries", PROFILE_NAME, count));
|
throw new NotFoundException(String.format("%s not found after %d retries", PROFILE_NAME, count));
|
||||||
}
|
}
|
||||||
if(!found) {
|
if(!found) {
|
||||||
Thread.sleep(TimeUnit.SECONDS.toMillis(2*count));
|
Thread.sleep(TimeUnit.SECONDS.toMillis(5*count));
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list = profile.list();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.read(PROFILE_NAME);
|
profile.read(PROFILE_NAME);
|
||||||
|
|
||||||
profile.delete(PROFILE_NAME);
|
profile.delete(PROFILE_NAME);
|
||||||
|
|
||||||
|
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
|
||||||
|
list = profile.list();
|
||||||
|
|
||||||
while(found) {
|
while(found) {
|
||||||
List<String> profiles = mapper.readValue(list, arrayType);
|
List<String> profiles = mapper.readValue(list, arrayType);
|
||||||
if(!profiles.contains(PROFILE_NAME)) {
|
if(!profiles.contains(PROFILE_NAME)) {
|
||||||
|
@ -123,9 +129,12 @@ public class ProfileTest extends ContextTest {
|
||||||
throw new Exception(String.format("%s still found after %d retries", PROFILE_NAME, count));
|
throw new Exception(String.format("%s still found after %d retries", PROFILE_NAME, count));
|
||||||
}
|
}
|
||||||
if(found) {
|
if(found) {
|
||||||
Thread.sleep(TimeUnit.SECONDS.toMillis(2*count));
|
Thread.sleep(TimeUnit.SECONDS.toMillis(5*count));
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list = profile.list();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,8 +154,10 @@ public class ResourceTest extends ContextTest {
|
||||||
String itemsString = item.list(10, 0);
|
String itemsString = item.list(10, 0);
|
||||||
logger.debug("Got list", itemsString);
|
logger.debug("Got list", itemsString);
|
||||||
List<String> items = mapper.readValue(itemsString, listType);
|
List<String> items = mapper.readValue(itemsString, listType);
|
||||||
|
if(items.size()>0) {
|
||||||
String name = items.get(0);
|
String name = items.get(0);
|
||||||
Assert.assertTrue(name.compareTo(NAME_VALUE) != 0);
|
Assert.assertTrue(name.compareTo(NAME_VALUE) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,237 @@
|
||||||
|
package org.gcube.gcat.client;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI-CNR)
|
||||||
|
*/
|
||||||
|
public class TrashTest extends ContextTest {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(TrashTest.class);
|
||||||
|
|
||||||
|
protected boolean find(ArrayNode ids, String name) {
|
||||||
|
boolean found = false;
|
||||||
|
for (int i = 0; i < ids.size(); i++) {
|
||||||
|
if (name.compareTo(ids.get(i).asText()) == 0) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemTest cleanEnv() throws Exception {
|
||||||
|
// Cleanign the env
|
||||||
|
ContextTest.setContextByName(VRE);
|
||||||
|
ItemTest itemTest = new ItemTest();
|
||||||
|
try {
|
||||||
|
itemTest.deleteItem(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// It is expected. the env was clean
|
||||||
|
}
|
||||||
|
return itemTest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testList() throws Exception {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
ItemTest itemTest = cleanEnv();
|
||||||
|
|
||||||
|
ContextTest.setContextByName(VRE);
|
||||||
|
itemTest.createItem();
|
||||||
|
itemTest.deleteItem(false);
|
||||||
|
|
||||||
|
Trash trash = new Trash();
|
||||||
|
String jsonArray = trash.list(true);
|
||||||
|
ArrayNode ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
boolean found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(found);
|
||||||
|
|
||||||
|
jsonArray = trash.list(false);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(found);
|
||||||
|
|
||||||
|
|
||||||
|
itemTest.deleteItem(true);
|
||||||
|
jsonArray = trash.list(true);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(!found);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListAndEmptyTrash() throws Exception {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
ItemTest itemTest = cleanEnv();
|
||||||
|
|
||||||
|
ContextTest.setContextByName(VRE);
|
||||||
|
itemTest.createItem();
|
||||||
|
itemTest.deleteItem(false);
|
||||||
|
|
||||||
|
Trash trash = new Trash();
|
||||||
|
String jsonArray = trash.list(true);
|
||||||
|
ArrayNode ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
boolean found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(found);
|
||||||
|
|
||||||
|
jsonArray = trash.list(false);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(found);
|
||||||
|
|
||||||
|
|
||||||
|
trash.empty(true);
|
||||||
|
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
|
||||||
|
jsonArray = trash.list(true);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(!found);
|
||||||
|
|
||||||
|
trash.empty(false);
|
||||||
|
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
|
||||||
|
jsonArray = trash.list(false);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
Assert.assertTrue(ids.size()==0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final String NON_CATALOGUE_ADMIN_USER = "lucio.lelii";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListFromAdmin() throws Exception {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
ItemTest itemTest = cleanEnv();
|
||||||
|
|
||||||
|
ContextTest.setContextByName(NON_CATALOGUE_ADMIN_USER + "_" + VRE);
|
||||||
|
itemTest = new ItemTest();
|
||||||
|
String ret = itemTest.createItem();
|
||||||
|
logger.debug(ret);
|
||||||
|
itemTest.deleteItem(false);
|
||||||
|
|
||||||
|
// I'm admin
|
||||||
|
ContextTest.setContextByName(VRE);
|
||||||
|
Trash trash = new Trash();
|
||||||
|
|
||||||
|
String jsonArray = trash.list(false);
|
||||||
|
ArrayNode ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
boolean found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(found);
|
||||||
|
|
||||||
|
|
||||||
|
jsonArray = trash.list(true);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(!found);
|
||||||
|
|
||||||
|
|
||||||
|
ContextTest.setContextByName(NON_CATALOGUE_ADMIN_USER + "_" + VRE);
|
||||||
|
itemTest.deleteItem(true);
|
||||||
|
|
||||||
|
// I'm admin
|
||||||
|
ContextTest.setContextByName(VRE);
|
||||||
|
jsonArray = trash.list(false);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(!found);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListFromNonAdmin() throws Exception {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
ItemTest itemTest = cleanEnv();
|
||||||
|
|
||||||
|
ContextTest.setContextByName(VRE);
|
||||||
|
itemTest.createItem();
|
||||||
|
itemTest.deleteItem(false);
|
||||||
|
|
||||||
|
// He is not admin
|
||||||
|
ContextTest.setContextByName(NON_CATALOGUE_ADMIN_USER + "_" + VRE);
|
||||||
|
Trash trash = new Trash();
|
||||||
|
|
||||||
|
String jsonArray = trash.list(false);
|
||||||
|
ArrayNode ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
boolean found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(!found);
|
||||||
|
|
||||||
|
|
||||||
|
jsonArray = trash.list(true);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(!found);
|
||||||
|
|
||||||
|
|
||||||
|
ContextTest.setContextByName(VRE);
|
||||||
|
jsonArray = trash.list(false);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(found);
|
||||||
|
|
||||||
|
|
||||||
|
jsonArray = trash.list(true);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(found);
|
||||||
|
|
||||||
|
|
||||||
|
itemTest.deleteItem(true);
|
||||||
|
|
||||||
|
|
||||||
|
jsonArray = trash.list(false);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(!found);
|
||||||
|
|
||||||
|
jsonArray = trash.list(true);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(!found);
|
||||||
|
|
||||||
|
|
||||||
|
ContextTest.setContextByName(NON_CATALOGUE_ADMIN_USER + "_" + VRE);
|
||||||
|
jsonArray = trash.list(false);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(!found);
|
||||||
|
|
||||||
|
|
||||||
|
jsonArray = trash.list(true);
|
||||||
|
ids = (ArrayNode) mapper.readTree(jsonArray);
|
||||||
|
logger.debug("{}", ids);
|
||||||
|
found = find(ids, ItemTest.NAME_VALUE);
|
||||||
|
Assert.assertTrue(!found);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,2 +1,3 @@
|
||||||
/token.properties
|
/token.properties
|
||||||
/gcat.properties
|
/gcat.properties
|
||||||
|
/config.ini
|
||||||
|
|
Loading…
Reference in New Issue