Compare commits

...

58 Commits

Author SHA1 Message Date
luca.frosini a4174b0da2 Ignored MacOs File 2023-06-21 11:38:21 +02:00
Luca Frosini 54d291a142 Removed -SNAPSHOT to release the component 2023-03-03 12:18:22 +01:00
Luca Frosini 00f3a8d718 Added 'Accept' HTTP header in list 2023-02-28 15:45:27 +01:00
Luca Frosini a207cb0043 Fixed changelog 2023-02-24 14:56:00 +01:00
Luca Frosini 4cce5ee2eb common-utility 1.X.X has been renamed to common-utility-sg3 2023-02-24 14:54:10 +01:00
Luca Frosini 4f1734de8a Added use of context-utility to be ready to comply both with SG 3 and 4 2023-02-23 12:24:11 +01:00
Luca Frosini ecc108a8b7 Updated gcube-bom version 2023-02-23 12:18:04 +01:00
Luca Frosini e62f17bc8e Enhanced gcat-api dependency range 2023-02-23 11:56:53 +01:00
Luca Frosini 038e49dd36 Fixed changelog 2023-02-17 15:18:21 +01:00
Luca Frosini 4bbc5bebbb Added possibility to specify custom HTTP headers to every request 2023-02-17 15:10:58 +01:00
Luca Frosini 848f4e3119 Add possibility to support social post in approve 2023-02-06 14:51:15 +01:00
Luca Frosini 930d1d2b34 Fixed json 2023-02-03 14:24:21 +01:00
Luca Frosini 563affadff renamed file 2023-01-31 17:55:48 +01:00
Luca Frosini bcafe2b401 Removed uneeded fields 2023-01-31 11:05:18 +01:00
Luca Frosini 0d0fc4cc1e Fixing json for zenodo export 2023-01-30 19:07:18 +01:00
Luca Frosini 9b876b5d6f Fixing zenodo export file 2023-01-30 18:29:55 +01:00
Luca Frosini 56fab9178c Fixed README and added FUNDING 2023-01-16 19:17:06 +01:00
Luca Frosini d82cdafea4 Merge branch 'master' of
gitea@code-repo.d4science.org:gCubeSystem/gcat-client.git

Conflicts:
	CHANGELOG.md
2023-01-16 19:03:08 +01:00
Luca Frosini e5538eba59 Fixed changelog and added json to publish/export software 2023-01-16 19:00:39 +01:00
Luca Frosini c88254bfe9 Enhanced version 2022-12-23 11:00:02 +01:00
Luca Frosini b2bc868ffc Removed -SNAPSHOT to release the component 2022-10-20 17:17:42 +02:00
Luca Frosini b356991974 Fixed dependency range 2022-10-20 16:51:47 +02:00
Luca Frosini 8c4485d88a Added dependency to be able to compile with JDK 11 2022-10-20 16:51:14 +02:00
Luca Frosini 8143eee364 Switching to the latest gcube-bom 2022-10-19 17:21:44 +02:00
Luca Frosini 61d57e8360 Removed -SNAPSHOT to release the component 2022-08-01 15:12:14 +02:00
Luca Frosini 4f56b412b0 Fixed service discovery 2022-08-01 10:19:07 +02:00
Luca Frosini 136f740b61 Using renamed constant from gcat-api 2022-07-26 11:47:30 +02:00
Luca Frosini f39a50e6fa Removed service discovery to to old service class 2022-07-26 11:47:13 +02:00
Luca Frosini 73efe34e05 Downgraded gcube-bom 2022-05-04 15:05:49 +02:00
Luca Frosini 3559bd2d69 Removed -SNAPSHOT to release the component 2022-04-28 17:29:48 +02:00
Luca Frosini 5dfa001306 Added authorization-utils version range 2022-03-31 11:31:54 +02:00
Luca Frosini d0ff1423f5 Fixed Changelog 2022-03-11 14:55:45 +01:00
Luca Frosini bd67e461f5 Fixed test 2022-03-08 10:19:51 +01:00
Luca Frosini 647c8e33be authorization-utils are used only as test dependecies 2022-03-02 10:07:58 +01:00
Luca Frosini a64cef5113 Refactoring code due to changes in authorization-utils 2022-02-28 13:21:36 +01:00
Luca Frosini 2269b20f8d Upgraded gcube-bom version 2022-02-25 17:31:18 +01:00
Luca Frosini c55988cc8a Service discovery query now supports both old and new service class 2022-02-24 11:42:19 +01:00
Luca Frosini 03ac8f4fb6 fixed configuration path 2022-02-22 10:46:23 +01:00
Luca Frosini 623d474384 fixed changelog 2022-02-21 13:43:50 +01:00
Luca Frosini e2c84401f2 Returns object instead of string 2022-02-21 13:17:14 +01:00
Luca Frosini b32ff04e97 Added facility for configuration 2022-02-21 13:04:56 +01:00
Luca Frosini b48046aea2 upgraded version 2022-02-21 12:00:49 +01:00
Luca Frosini e2c0cbbee4 Fixed reject/approve 2022-02-21 11:33:38 +01:00
Luca Frosini 7f3ea5da14 Removed -SNAPSHOT for release 2022-01-11 16:31:53 +01:00
Luca Frosini eb9a3028fe Removed -SNAPSHOT for release 2022-01-11 16:25:47 +01:00
Luca Frosini 08e3e7acbe fixed test 2021-12-21 14:10:06 +01:00
Luca Frosini e63a76fff9 fixed test 2021-12-21 13:56:35 +01:00
Luca Frosini 4b1be3b2d4 Added/fixed tests 2021-12-21 13:51:37 +01:00
Luca Frosini 12275c8e73 Fixed CHANGELOG 2021-12-20 14:23:58 +01:00
Luca Frosini 44cb99380e Added empty trash API 2021-12-20 14:07:17 +01:00
Luca Frosini 152a211f0a Fixed CHANGELOG 2021-12-15 18:49:43 +01:00
Luca Frosini bc50f0b1e5 Fixed bulk delete/purge 2021-12-07 16:46:16 +01:00
Luca Frosini 1fcea2b14b Fixed bulkDelete/Purge API 2021-12-07 12:30:43 +01:00
Luca Frosini e28e49438f Fixed APIs 2021-12-03 17:40:41 +01:00
Luca Frosini 0d5c48ce35 Implemented methods 2021-12-02 15:44:33 +01:00
Luca Frosini 6b32bc1245 Fixed interface 2021-12-02 11:51:33 +01:00
Luca Frosini f931293c8c Added missing methods (still to be implemented) 2021-11-23 17:55:03 +01:00
Luca Frosini 395220a652 Adding support for moderation 2021-06-16 14:50:43 +02:00
22 changed files with 1006 additions and 196 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
target
.classpath
.project
/.DS_Store

View File

@ -2,12 +2,42 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# 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
## [v1.2.2]
## [v1.2.2] [r5.0.0] - 2021-02-24
- Added count method for Item collection [#20627]
- 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
## [v1.2.0] [r4.15.0] - 2019-11-06
## [v1.2.0] [r4.15.0] - 2019-11-20
- 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 disable social post [#13335]

26
FUNDING.md Normal file
View File

@ -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);

View File

@ -1,6 +1,6 @@
# 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
@ -25,15 +25,13 @@ Tell people how to cite this software.
* Cite an associated paper?
* Use a specific BibTeX entry for the software?
@Manual{,
title = {gCube Catalogue (gCat) Client},
author = {{Frosini, Luca}},
organization = {ISTI - CNR},
address = {Pisa, Italy},
year = 2019,
url = {http://www.gcube-system.org/}
}
@software{gcat-client,
author = {{Luca Frosini}},
title = {gCube Catalogue (gCat) Client},
abstract = {gCube Catalogue (gCat) Client is a library designed to interact with REST APIs exposed by the gCat Service.},
url = {https://doi.org/10.5281/zenodo.7447655},
keywords = {Catalogue, D4Science, gCube}
}
## 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
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 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);
The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md)

View File

@ -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"
}
]
}

View File

@ -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>&nbsp;</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
View File

@ -9,9 +9,9 @@
</parent>
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>gcat-client</artifactId>
<version>2.0.0</version>
<version>2.4.1</version>
<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>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -30,7 +30,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>2.0.1</version>
<version>2.2.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -41,7 +41,7 @@
<dependency>
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>gcat-api</artifactId>
<version>[2.0.0,3.0.0-SNAPSHOT)</version>
<version>[2.3.2,3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
@ -63,7 +63,25 @@
<groupId>org.gcube.common</groupId>
<artifactId>gcube-jackson-databind</artifactId>
</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 -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-utils</artifactId>
<version>[2.1.0, 3.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -76,4 +94,25 @@
<scope>test</scope>
</dependency>
</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>

View File

@ -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;
}
}

View File

@ -22,6 +22,7 @@ import javax.ws.rs.core.MediaType;
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
import org.gcube.common.http.GXHTTPUtility;
import org.gcube.gcat.api.GCatConstants;
/**
@ -34,6 +35,8 @@ abstract class GCatClient {
protected GXHTTPStringRequest gxhttpStringRequest;
protected Map<String, String> headers;
public void enforceServiceURL(URL enforcedServiceURL) {
this.serviceURL = enforcedServiceURL;
}
@ -43,13 +46,15 @@ abstract class GCatClient {
this.basePaths = new ArrayList<>();
this.basePaths.add(basePath);
this.basePaths.addAll(Arrays.asList(basePaths));
this.headers = new HashMap<>();
}
public GCatClient(String basePath, String... basePaths) throws MalformedURLException {
this.serviceURL = GCatClientDiscovery.getServiceURL();
this.basePaths = new ArrayList<>();
this.basePaths.add(basePath);
this.basePaths.addAll(Arrays.asList(basePaths));
this(GCatClientDiscovery.getServiceURL(), basePath, basePaths);
}
public void addHeader(String name, String value) {
headers.put(name, value);
}
protected static StringBuilder getStringBuilder(InputStream inputStream) throws IOException {
@ -100,7 +105,10 @@ abstract class GCatClient {
}
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());
for(String p : basePaths) {
gxhttpStringRequest.path(p);
@ -114,6 +122,7 @@ abstract class GCatClient {
gxhttpStringRequest.path(p);
}
gxhttpStringRequest.queryParams(queryParams);
gxhttpStringRequest.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
HttpURLConnection httpURLConnection = gxhttpStringRequest.get();
return parseHttpURLConnection(httpURLConnection);
}catch (WebApplicationException e) {

View File

@ -8,10 +8,9 @@ import java.util.List;
import java.util.Map;
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.ServiceEndpoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.gcat.api.GCatConstants;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.resources.discovery.icclient.ICFactory;
@ -33,7 +32,7 @@ public class GCatClientDiscovery {
protected static void forceToURL(String adddress) throws MalformedURLException {
if(adddress!=null && adddress.compareTo("")!=0) {
String context = getContext();
String context = ContextUtility.getCurrentContextFullName();
URL url = new URL(adddress);
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)
.addCondition(String.format(classFormat, GCatConstants.SERVICE_CLASS))
.addCondition(String.format(classFormat, serviceClass))
.addCondition(String.format(nameFormat, GCatConstants.SERVICE_NAME))
.addCondition(String.format(statusFormat))
.addVariable("$entry","$resource/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint")
@ -61,9 +60,9 @@ public class GCatClientDiscovery {
.setResult("$entry/text()");
}
private static SimpleQuery queryForProxy(){
private static SimpleQuery queryForProxy(String serviceClass){
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(serviceEndpointstatusFormat))
.addVariable("$entry","$resource/Profile/AccessPoint/Interface/Endpoint")
@ -74,40 +73,22 @@ public class GCatClientDiscovery {
protected static List<String> getAddresses(){
List<String> addresses = new ArrayList<>();
try {
SimpleQuery proxyQuery = queryForProxy();
SimpleQuery proxyQuery = queryForProxy(GCatConstants.SERVICE_CLASS);
addresses = ICFactory.client().submit(proxyQuery);
if(addresses==null || addresses.isEmpty()){
throw new Exception("No ResourceRegistry Proxy Found");
}
} catch (Exception e) {
logger.debug("{}. Looking for RunningInstance.", e.getMessage());
SimpleQuery serviceQuery = queryForService();
SimpleQuery serviceQuery = queryForService(GCatConstants.SERVICE_CLASS);
addresses = ICFactory.client().submit(serviceQuery);
}
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 {
String context = getContext();
String context = ContextUtility.getCurrentContextFullName();
URL url = clients.get(context);
if(url==null){

View File

@ -28,7 +28,7 @@ public class Group extends GCatClient implements org.gcube.gcat.api.interfaces.G
@Override
public int count() throws WebServiceException {
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);
ObjectMapper objectMapper = new ObjectMapper();
try {
@ -44,8 +44,8 @@ public class Group extends GCatClient implements org.gcube.gcat.api.interfaces.G
@Override
public String list(int limit, int offset) throws WebApplicationException {
Map<String, String> queryParams = new HashMap<>();
queryParams.put(GCatConstants.LIMIT_PARAMETER, String.valueOf(limit));
queryParams.put(GCatConstants.OFFSET_PARAMETER, String.valueOf(offset));
queryParams.put(GCatConstants.LIMIT_QUERY_PARAMETER, String.valueOf(limit));
queryParams.put(GCatConstants.OFFSET_QUERY_PARAMETER, String.valueOf(offset));
return super.list(queryParams);
}

View File

@ -1,5 +1,6 @@
package org.gcube.gcat.client;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
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.ObjectMapper;
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)
@ -25,10 +28,9 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
super(enforcedServiceURL, ITEMS);
}
@Override
public int count() throws WebServiceException {
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);
ObjectMapper objectMapper = new ObjectMapper();
try {
@ -50,12 +52,11 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
@Override
public String list(int limit, int offset) throws WebApplicationException {
Map<String, String> queryParams = new HashMap<>();
queryParams.put(GCatConstants.LIMIT_PARAMETER, String.valueOf(limit));
queryParams.put(GCatConstants.OFFSET_PARAMETER, String.valueOf(offset));
queryParams.put(GCatConstants.LIMIT_QUERY_PARAMETER, String.valueOf(limit));
queryParams.put(GCatConstants.OFFSET_QUERY_PARAMETER, String.valueOf(offset));
return this.list(queryParams);
}
public String list(Map<String,String> queryParams) throws WebApplicationException {
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 {
Map<String, String> queryParams = new HashMap<>();
queryParams.put(GCatConstants.LIMIT_PARAMETER, String.valueOf(limit));
queryParams.put(GCatConstants.OFFSET_PARAMETER, String.valueOf(offset));
queryParams.put(GCatConstants.LIMIT_QUERY_PARAMETER, String.valueOf(limit));
queryParams.put(GCatConstants.OFFSET_QUERY_PARAMETER, String.valueOf(offset));
queryParams.put(GCatConstants.Q_KEY, String.format(GCatConstants.ORGANIZATION_FILTER_TEMPLATE, organizationName));
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 {
try {
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);
}catch (WebApplicationException e) {
throw e;
@ -121,5 +122,85 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
super.delete(true, name);
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);
}
}

View File

@ -28,7 +28,7 @@ public class Organization extends GCatClient implements org.gcube.gcat.api.inter
@Override
public int count() throws WebServiceException {
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);
ObjectMapper objectMapper = new ObjectMapper();
try {
@ -44,8 +44,8 @@ public class Organization extends GCatClient implements org.gcube.gcat.api.inter
@Override
public String list(int limit, int offset) throws WebApplicationException {
Map<String, String> queryParams = new HashMap<>();
queryParams.put(GCatConstants.LIMIT_PARAMETER, String.valueOf(limit));
queryParams.put(GCatConstants.OFFSET_PARAMETER, String.valueOf(offset));
queryParams.put(GCatConstants.LIMIT_QUERY_PARAMETER, String.valueOf(limit));
queryParams.put(GCatConstants.OFFSET_QUERY_PARAMETER, String.valueOf(offset));
return super.list(queryParams);
}

View File

@ -31,7 +31,7 @@ public class Profile extends GCatClient implements org.gcube.gcat.api.interfaces
@Override
public int count() throws WebServiceException {
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);
ObjectMapper objectMapper = new ObjectMapper();
try {

View File

@ -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);
}
}
}

View File

@ -5,14 +5,10 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.Properties;
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.AuthorizationProvider;
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.gcube.common.authorization.utils.manager.SecretManager;
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.authorization.utils.secret.GCubeSecret;
import org.gcube.common.authorization.utils.secret.Secret;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.slf4j.Logger;
@ -24,7 +20,7 @@ import org.slf4j.LoggerFactory;
*/
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 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 String GCAT_URL;
public static final String DEFAULT_TEST_CONTEXT_NAME;
public static final String ROOT;
public static final String VO;
public static final String VRE;
static {
properties = new Properties();
@ -46,15 +43,10 @@ public class ContextTest {
} catch(IOException e) {
throw new RuntimeException(e);
}
//DEFAULT_TEST_CONTEXT_NAME = "/pred4s/preprod/preVRE";
DEFAULT_TEST_CONTEXT_NAME = "/gcube/devsec/devVRE";
try {
setContextByName(DEFAULT_TEST_CONTEXT_NAME);
} catch(Exception e) {
throw new RuntimeException(e);
}
ROOT = "/gcube";
VO = ROOT + "/devsec";
VRE = VO + "/devVRE";
Properties gcatProperties = new Properties();
input = ContextTest.class.getClassLoader().getResourceAsStream(GCAT_PROPERTIES_FILENAME);
@ -76,47 +68,45 @@ public class ContextTest {
}
}
public static String getCurrentContextFullName() {
String token = SecurityTokenProvider.instance.get();
AuthorizationEntry authorizationEntry = null;
try {
authorizationEntry = Constants.authorizationService().get(token);
} catch(Exception e) {
return ScopeProvider.instance.get();
}
return authorizationEntry.getContext();
public static void set(Secret secret) throws Exception {
SecretManagerProvider.instance.reset();
SecretManager secretManager = new SecretManager();
SecretManagerProvider.instance.set(secretManager);
secretManager.addSecret(secret);
secretManager.set();
String username = secretManager.getUser().getUsername();
String context = secretManager.getContext();
logger.debug("Set authorization for user {} in context {}", username, context);
}
public static String getContextFullName(String token) throws ObjectNotFound, Exception {
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
return authorizationEntry.getContext();
public static void setContext(String token) throws Exception {
Secret secret = getSecret(token);
set(secret);
}
public static void setContextByName(String fullContextName) throws Exception {
Secret secret = getSecretByContextName(fullContextName);
set(secret);
}
public static void setContextByName(String fullContextName) throws ObjectNotFound, Exception {
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);
setContext(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));
return getSecret(token);
}
@BeforeClass
public static void beforeClass() throws Exception {
setContextByName(DEFAULT_TEST_CONTEXT_NAME);
setContextByName(VRE);
}
@AfterClass
public static void afterClass() throws Exception {
SecurityTokenProvider.instance.reset();
ScopeProvider.instance.reset();
SecretManagerProvider.instance.reset();
}
}

View File

@ -1,6 +1,5 @@
package org.gcube.gcat.client;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
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.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.gcat.api.GCatConstants;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -26,7 +27,7 @@ public class ItemTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(ItemTest.class);
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_VALUE = "00 Title";
@ -49,49 +50,14 @@ public class ItemTest extends ContextTest {
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
public void testCount() throws MalformedURLException {
Item item = new Item();
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 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();
public String createItem(ObjectMapper mapper, String licenseID) throws Exception {
Map<String,Object> map = new HashMap<>();
map.put(NAME_KEY, NAME_VALUE);
@ -115,7 +81,42 @@ public class ItemTest extends ContextTest {
Item item = new Item();
String json = mapper.writeValueAsString(map);
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 {
String itemsString = item.list(10, 0);
logger.debug("Got items {}", itemsString);
@ -154,30 +155,34 @@ public class ItemTest extends ContextTest {
String itemsString = item.list(10, 0);
logger.debug("Got list", itemsString);
List<String> items = mapper.readValue(itemsString, listType);
String name = items.get(0);
Assert.assertTrue(name.compareTo(NAME_VALUE) != 0);
if(items.size()>0) {
String name = items.get(0);
Assert.assertTrue(name.compareTo(NAME_VALUE) != 0);
}
}
// @Ignore
@Test
public void listOnVOTest() throws Exception {
ContextTest.setContextByName("/gcube/devNext");
ContextTest.setContextByName(VRE);
Item item = new Item();
String itemsString = item.list(10, 0, "dorne");
String itemsString = item.list(10, 0, "devvre");
logger.debug("Got list {}", itemsString);
/*
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);
logger.debug("Got list {}", itemsString);
queryParams = new HashMap<>();
queryParams.put(GCatConstants.Q_KEY, "organization:ckand4scienceharvest");
queryParams.put(GCatConstants.Q_KEY, "organization:org3");
queryParams.put("rows", "4");
queryParams.put("start", "4");
itemsString = item.list(queryParams);
logger.debug("Got list {}", itemsString);
*/
/*
ObjectMapper mapper = new ObjectMapper();
@ -196,19 +201,22 @@ public class ItemTest extends ContextTest {
logger.debug("Got list {}", itemsString);
List<String> items = mapper.readValue(itemsString, listType);
String name = items.get(0);
String ret = item.read(name);
logger.debug("Got item {}", ret);
JsonNode jsonNode = mapper.readTree(ret);
String gotName = jsonNode.get(NAME_KEY).asText();
Assert.assertTrue(name.compareTo(gotName) == 0);
if(items.size()>0) {
String name = items.get(0);
String ret = item.read(name);
logger.debug("Got item {}", ret);
JsonNode jsonNode = mapper.readTree(ret);
String gotName = jsonNode.get(NAME_KEY).asText();
Assert.assertTrue(name.compareTo(gotName) == 0);
}
}
protected static final String SEARCHABLE_KEY = "searchable";
public static final String GCAT_URL_STRING = "https://gcat.d4science.org/gcat";
@Ignore
// @Test
public void findNotSearchable() throws Exception {
ContextTest.setContextByName("/d4science.research-infrastructures.eu/SoBigData/ResourceCatalogue");
@ -233,6 +241,7 @@ public class ItemTest extends ContextTest {
}
}
@Ignore
// @Test
public void purgeAll() throws Exception {
ObjectMapper mapper = new ObjectMapper();
@ -250,4 +259,22 @@ public class ItemTest extends ContextTest {
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");
}
}

View File

@ -4,9 +4,13 @@ import java.io.IOException;
import java.util.ArrayList;
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.JsonNode;
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.Test;
import org.slf4j.Logger;
@ -22,7 +26,7 @@ public class LicenseTest extends ContextTest {
private static final String ID_KEY = "id";
@Test
public void safeTest() throws IOException {
public void testList() throws IOException {
ObjectMapper mapper = new ObjectMapper();
JavaType licenseArrayType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, JsonNode.class);
@ -36,4 +40,21 @@ public class LicenseTest extends ContextTest {
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);
}
}
}

View File

@ -89,7 +89,7 @@ public class ProfileTest extends ContextTest {
Profile profile = new Profile();
profile.create(PROFILE_NAME, String.format(PROFILE_XML, PROFILE_NAME));
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
String list = profile.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));
}
if(!found) {
Thread.sleep(TimeUnit.SECONDS.toMillis(2*count));
Thread.sleep(TimeUnit.SECONDS.toMillis(5*count));
++count;
}
list = profile.list();
}
profile.read(PROFILE_NAME);
profile.delete(PROFILE_NAME);
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
list = profile.list();
while(found) {
List<String> profiles = mapper.readValue(list, arrayType);
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));
}
if(found) {
Thread.sleep(TimeUnit.SECONDS.toMillis(2*count));
Thread.sleep(TimeUnit.SECONDS.toMillis(5*count));
++count;
}
list = profile.list();
}
}

View File

@ -154,8 +154,10 @@ public class ResourceTest extends ContextTest {
String itemsString = item.list(10, 0);
logger.debug("Got list", itemsString);
List<String> items = mapper.readValue(itemsString, listType);
String name = items.get(0);
Assert.assertTrue(name.compareTo(NAME_VALUE) != 0);
if(items.size()>0) {
String name = items.get(0);
Assert.assertTrue(name.compareTo(NAME_VALUE) != 0);
}
}

View File

@ -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);
}
}

View File

@ -1,2 +1,3 @@
/token.properties
/gcat.properties
/config.ini