Compare commits

...

43 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
18 changed files with 532 additions and 100 deletions

1
.gitignore vendored
View File

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

View File

@ -2,8 +2,29 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for gCube Catalogue (gCat) Client
## [v2.4.1]
## [v2.1.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]
@ -11,12 +32,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Added empty trash API [#13322]
## [v2.0.0]
## [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]
@ -27,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"
}
]
}

52
pom.xml
View File

@ -9,9 +9,9 @@
</parent>
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>gcat-client</artifactId>
<version>2.1.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,12 +41,7 @@
<dependency>
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>gcat-api</artifactId>
<version>[2.0.0,3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-utils</artifactId>
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
<version>[2.3.2,3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
@ -68,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>
@ -81,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

@ -30,7 +30,7 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
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 {
@ -52,8 +52,8 @@ 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);
}
@ -67,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);
}
@ -151,10 +151,18 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
}
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);
@ -169,7 +177,16 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
ModerationContent moderationContent = new ModerationContent();
moderationContent.setCMItemStatus(CMItemStatus.APPROVED);
moderationContent.setMessage(moderatorMessage);
return moderate(name, moderationContent);
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) {

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

@ -6,6 +6,7 @@ import java.net.MalformedURLException;
import java.util.Properties;
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;
@ -68,10 +69,13 @@ public class ContextTest {
}
public static void set(Secret secret) throws Exception {
SecretManager.instance.get().reset();
secret.set();
String username = secret.getUsername();
String context = secret.getContext();
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);
}
@ -102,7 +106,7 @@ public class ContextTest {
@AfterClass
public static void afterClass() throws Exception {
SecretManager.instance.get().reset();
SecretManagerProvider.instance.reset();
}
}

View File

@ -11,7 +11,7 @@ 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.SecretManager;
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.gcat.api.GCatConstants;
import org.junit.Assert;
import org.junit.Ignore;
@ -54,7 +54,7 @@ public class ItemTest extends ContextTest {
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 {}", SecretManager.instance.get().getContext(), count);
logger.debug("The items published in the organization corresponding to the VRE {} are {}", SecretManagerProvider.instance.get().getContext(), count);
}
public String createItem(ObjectMapper mapper, String licenseID) throws Exception {
@ -164,7 +164,7 @@ public class ItemTest extends ContextTest {
// @Ignore
@Test
public void listOnVOTest() throws Exception {
ContextTest.setContextByName(VO);
ContextTest.setContextByName(VRE);
Item item = new Item();
String itemsString = item.list(10, 0, "devvre");
@ -269,4 +269,12 @@ public class ItemTest extends ContextTest {
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

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