Compare commits

..

No commits in common. "master" and "v2.3.0" have entirely different histories.

13 changed files with 71 additions and 407 deletions

1
.gitignore vendored
View File

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

View File

@ -2,29 +2,18 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for gCube Catalogue (gCat) Client
## [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
## [v2.3.0]
- Removed service discovery to to old service class
- Using renamed constant from gcat-api
## [v2.2.0] [r5.11.0] - 2022-05-12
## [v2.2.0]
- Added support to manage configurations [#22658]
- Migrated to ServiceClass corresponding to Maven groupId
## [v2.1.0] [r5.7.0] - 2022-01-27
## [v2.1.0]
- Added query parameter social_post_notification to override default VRE behaviour [#21345]
- Added support for moderation [#21342]
@ -32,12 +21,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Added empty trash API [#13322]
## [v2.0.0] [r5.2.0] - 2021-05-04
## [v2.0.0]
- Changed service class
## [v1.2.2] [r5.0.0] - 2021-02-24
## [v1.2.2]
- Added count method for Item collection [#20627]
- Added count method for Organization, Group and Profile collection [#20629]
@ -48,12 +37,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-20
## [v1.2.0] [r4.15.0] - 2019-11-06
- Enforce Content-Type in requests [#16774]
## [v1.1.0] [r4.14.0] - 2019-05-16
## [v1.1.0] [r4.14.0] - 2019-05-27
- Added the possibility to enforce gCat service URL
- Added the possibility to disable social post [#13335]

View File

@ -1,26 +0,0 @@
# 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 REST APIs exposed by the gCat Service.
gCube Catalogue (gCat) Client is a library designed to interact with gCat Service exposed REST API
## Built With
@ -25,13 +25,15 @@ Tell people how to cite this software.
* Cite an associated paper?
* Use a specific BibTeX entry for the software?
@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}
}
@Manual{,
title = {gCube Catalogue (gCat) Client},
author = {{Frosini, Luca}},
organization = {ISTI - CNR},
address = {Pisa, Italy},
year = 2019,
url = {http://www.gcube-system.org/}
}
## License
@ -44,6 +46,26 @@ 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 see [FUNDING.md](FUNDING.md)
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);

View File

@ -1,21 +0,0 @@
{
"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

@ -1,236 +0,0 @@
{
"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.4.1</version>
<version>2.3.0</version>
<name>gCube Catalogue (gCat) Client</name>
<description>gCube Catalogue (gCat) Client is a library designed to interact with REST APIs exposed by the gCat Service.</description>
<description>gCube Catalogue (gCat) Client is a library designed to interact with gCat Service exposed REST API</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.2.0</version>
<version>2.0.2</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.3.2,3.0.0-SNAPSHOT)</version>
<version>[2.0.0,3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
@ -63,23 +63,11 @@
<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>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
@ -94,25 +82,4 @@
<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,7 +22,6 @@ 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;
/**
@ -35,8 +34,6 @@ abstract class GCatClient {
protected GXHTTPStringRequest gxhttpStringRequest;
protected Map<String, String> headers;
public void enforceServiceURL(URL enforcedServiceURL) {
this.serviceURL = enforcedServiceURL;
}
@ -46,15 +43,13 @@ 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(GCatClientDiscovery.getServiceURL(), basePath, basePaths);
}
public void addHeader(String name, String value) {
headers.put(name, value);
this.serviceURL = GCatClientDiscovery.getServiceURL();
this.basePaths = new ArrayList<>();
this.basePaths.add(basePath);
this.basePaths.addAll(Arrays.asList(basePaths));
}
protected static StringBuilder getStringBuilder(InputStream inputStream) throws IOException {
@ -105,10 +100,7 @@ abstract class GCatClient {
}
protected void initRequest() throws UnsupportedEncodingException {
gxhttpStringRequest = GXHTTPUtility.getGXHTTPStringRequest(serviceURL.toString());
for(String name : headers.keySet()) {
gxhttpStringRequest.header(name, headers.get(name));
}
gxhttpStringRequest = GXHTTPStringRequest.newRequest(serviceURL.toString());
gxhttpStringRequest.from(GCatClient.class.getSimpleName());
for(String p : basePaths) {
gxhttpStringRequest.path(p);
@ -122,7 +114,6 @@ 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,9 +8,10 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import org.gcube.common.context.ContextUtility;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
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;
@ -32,7 +33,7 @@ public class GCatClientDiscovery {
protected static void forceToURL(String adddress) throws MalformedURLException {
if(adddress!=null && adddress.compareTo("")!=0) {
String context = ContextUtility.getCurrentContextFullName();
String context = getContext();
URL url = new URL(adddress);
clients.put(context, url);
}
@ -87,8 +88,24 @@ 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 = ContextUtility.getCurrentContextFullName();
String context = getContext();
URL url = clients.get(context);
if(url==null){

View File

@ -151,16 +151,9 @@ 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);
@ -177,16 +170,7 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
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);
return moderate(name, moderationContent);
}
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(VRE);
ContextTest.setContextByName(VO);
Item item = new Item();
String itemsString = item.list(10, 0, "devvre");

View File

@ -4,13 +4,9 @@ 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;
@ -26,7 +22,7 @@ public class LicenseTest extends ContextTest {
private static final String ID_KEY = "id";
@Test
public void testList() throws IOException {
public void safeTest() throws IOException {
ObjectMapper mapper = new ObjectMapper();
JavaType licenseArrayType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, JsonNode.class);
@ -40,21 +36,4 @@ 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,3 +1,2 @@
/token.properties
/gcat.properties
/config.ini