Compare commits

...

24 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
13 changed files with 407 additions and 71 deletions

1
.gitignore vendored
View File

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

View File

@ -2,18 +2,29 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for gCube Catalogue (gCat) Client
## [v2.3.0]
## [v2.4.1]
- 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]
## [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]
## [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]
@ -21,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]
@ -37,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"
}
]
}

43
pom.xml
View File

@ -9,9 +9,9 @@
</parent>
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>gcat-client</artifactId>
<version>2.3.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.2</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,11 +63,23 @@
<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.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<version>[2.1.0, 3.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
@ -82,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

@ -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);
}
@ -88,24 +87,8 @@ public class GCatClientDiscovery {
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

@ -151,9 +151,16 @@ 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);
@ -170,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

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

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