Compare commits

...

11 Commits

Author SHA1 Message Date
Giancarlo Panichi beb6950af0 Updated VREs in JUnit Test 2020-09-25 16:18:40 +02:00
Giancarlo Panichi 96e12ce706 Updated JUnit test for create the resource on Prod 2020-09-25 13:59:08 +02:00
Giancarlo Panichi eb4f094d16 Updated CHANGELOG.md 2020-06-18 15:37:02 +02:00
Giancarlo Panichi c9ed703475 Updated CHANGELOG.md 2020-06-18 15:36:22 +02:00
Giancarlo Panichi ae50538c43 Updated CHANGELOG.md 2020-06-18 15:35:38 +02:00
Giancarlo Panichi 2827116984 Fixed CHANGELOG.md 2020-06-18 15:28:30 +02:00
Giancarlo Panichi 1045787b99 Fixed CHANGELOG.md 2020-06-18 15:26:53 +02:00
Giancarlo Panichi 5bcb672007 Updated descriptor.xml
Updated descriptor.xml
2020-06-18 15:04:09 +02:00
Francesco Mangiacrapa 0af97deb46 removed -SNAPSHOT to be released 2020-06-15 14:37:50 +02:00
Francesco Mangiacrapa 046a7036b6 merged with #19440 2020-06-15 14:36:59 +02:00
Francesco Mangiacrapa 0b17e8377f only added junit to classpath 2020-06-15 14:35:25 +02:00
10 changed files with 260 additions and 18 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/detachedres-library-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/detachedres-library-1.1.0/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/detachedres-library-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/detachedres-library-1.1.0/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -33,5 +33,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/detachedres-library-1.0.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="target/detachedres-library-1.1.0/WEB-INF/classes"/>
</classpath>

15
CHANGELOG.md Normal file
View File

@ -0,0 +1,15 @@
# Changelog
## [v1.1.0] [r4.24.0] - 2020-06-05
### Features
- Added the property cataloguePortletURL and the method [#19440]
## [v1.0.0] - 2020-04-01
First release
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

View File

@ -1,4 +1,9 @@
<ReleaseNotes>
<Changeset
component="org.gcube.infrastructure.detachedres.detachedres-library.1-1-0"
date="2020-06-18">
<Change>Added the property cataloguePortletURL and the method [#19440]</Change>
</Changeset>
<Changeset
component="org.gcube.infrastructure.detachedres.detachedres-library.1-0-0"
date="2020-04-01">

View File

@ -14,6 +14,7 @@
<includes>
<include>README.md</include>
<include>LICENSE.md</include>
<include>CHANGELOG.md</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.infrastructure.detachedres</groupId>
<artifactId>detachedres-library</artifactId>
<name>detachedres-library</name>
<version>1.0.0</version>
<version>1.1.0</version>
<description>Detached Resource Entities Library</description>

View File

@ -7,14 +7,18 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.DetachedREsBuilder;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.Constants;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.Gateway;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VO;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* The Class DetachedREsClient.
*
* @author Giancarlo Panichi
*
*
*
* @author updated by Francesco Mangiacrapa at ISTI-CNR
*/
public class DetachedREsClient {
@ -24,16 +28,27 @@ public class DetachedREsClient {
private String scope;
/**
*
* Instantiates a new detached R es client.
*/
public DetachedREsClient() {
}
/**
* Instantiates a new detached R es client.
*
* @param token the token
*/
public DetachedREsClient(String token) {
this.token = token;
}
/**
* Gets the detached R es.
*
* @return the detached R es
* @throws Exception the exception
*/
public DetachedREs getDetachedREs() throws Exception {
retrieveAuthInfo();
logger.debug("Use: [userName={}, scope={}, token={}]",userName,scope,token);
@ -41,6 +56,13 @@ public class DetachedREsClient {
}
/**
* Gets the detached R es in scope.
*
* @param scope the scope
* @return the detached R es in scope
* @throws Exception the exception
*/
public DetachedREs getDetachedREsInScope(String scope) throws Exception {
retrieveAuthInfo();
this.scope=scope;
@ -49,6 +71,11 @@ public class DetachedREsClient {
}
/**
* Retrieve auth info.
*
* @throws Exception the exception
*/
private void retrieveAuthInfo() throws Exception {
if (Constants.DEBUG_MODE) {
logger.debug("Debug Mode");
@ -77,5 +104,39 @@ public class DetachedREsClient {
}
/**
* Find detached VRE for VRE name.
*
* @param vreName the vre name
* @return the vre detached if it is found.
*/
public VRE findDetachedVREforVREName(String vreName) {
logger.debug("Find the VRE name: "+vreName+" called");
try {
DetachedREs detachedREs = getDetachedREs();
for (Gateway gateway : detachedREs.getGateways().values()) {
for (VO vo : gateway.getVos().values()) {
for (VRE vre : vo.getVres().values()) {
logger.trace("Does the scope: "+vre.getScope() +" ends with "+vreName +"?");
if(vre.getScope().toLowerCase().endsWith(vreName)){
logger.info("The scope: "+vre.getScope() +" ends with: "+vreName);
return vre;
}
}
}
}
logger.info("The VRE name "+vreName+" was not found in the detached VREs");
return null;
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
return null;
}
}
}

View File

@ -192,6 +192,7 @@ public class DetachedREsBuilder {
}
}
vre.setCatalogUrl(vreJAXB.getCatalogUrl());
vre.setCatalogPortletURL(vreJAXB.getCatalogPortletURL());
vre.setManagers(vreJAXB.getManagers());
vres.put(key,vre);
}

View File

@ -13,8 +13,8 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
*
* @author Giancarlo Panichi
*
*
*
* @author updated by Francesco Mangiacrapa at ISTI-CNR
*/
@XmlRootElement(name = "vre")
@XmlAccessorType(XmlAccessType.FIELD)
@ -43,6 +43,9 @@ public class VREJAXB {
@XmlElement(name = "catalogurl", required = false)
private String catalogUrl;
@XmlElement(name = "catalogportleturl", required = false)
private String catalogPortletURL;
public String getScope() {
return scope;
}
@ -99,10 +102,19 @@ public class VREJAXB {
this.catalogUrl = catalogUrl;
}
public String getCatalogPortletURL() {
return catalogPortletURL;
}
public void setCatalogPortletURL(String catalogPortletURL) {
this.catalogPortletURL = catalogPortletURL;
}
@Override
public String toString() {
return "VREJAXB [scope=" + scope + ", name=" + name + ", description=" + description + ", managers=" + managers
+ ", startDate=" + startDate + ", endDate=" + endDate + ", catalogUrl=" + catalogUrl + "]";
+ ", startDate=" + startDate + ", endDate=" + endDate + ", catalogUrl=" + catalogUrl
+ ", catalogPortletURL=" + catalogPortletURL + "]";
}
}

View File

@ -18,6 +18,7 @@ public class VRE implements Serializable, Comparable<VRE> {
private String startDate;
private String endDate;
private String catalogUrl;
private String catalogPortletURL;
public VRE() {
super();
@ -92,6 +93,16 @@ public class VRE implements Serializable, Comparable<VRE> {
this.catalogUrl = catalogUrl;
}
public String getCatalogPortletURL() {
return catalogPortletURL;
}
public void setCatalogPortletURL(String catalogPortletURL) {
this.catalogPortletURL = catalogPortletURL;
}
@Override
public int compareTo(VRE vre) {
if (name == null) {
@ -108,7 +119,10 @@ public class VRE implements Serializable, Comparable<VRE> {
@Override
public String toString() {
return "VRE [scope=" + scope + ", name=" + name + ", description=" + description + ", managers=" + managers
+ ", startDate=" + startDate + ", endDate=" + endDate + ", catalogUrl=" + catalogUrl + "]";
+ ", startDate=" + startDate + ", endDate=" + endDate + ", catalogUrl=" + catalogUrl
+ ", catalogPortletURL=" + catalogPortletURL + "]";
}
}

View File

@ -16,6 +16,8 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.DetachedREsClient;
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.DetachedREsJAXB;
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.GatewayJAXB;
@ -23,6 +25,9 @@ import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.VOJ
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.VREJAXB;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.Constants;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.Gateway;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VO;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -45,9 +50,57 @@ public class DetachedREsTest extends TestCase {
logger.debug("Test Enabled");
try {
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
SecurityTokenProvider.instance.set(Constants.DEFAULT_TOKEN);
DetachedREsClient detachedREsClient = new DetachedREsClient();
DetachedREs detachedREs = detachedREsClient.getDetachedREs();
logger.debug("DetachedREs: " + detachedREs);
int totalVREDimissed = 0;
for (Gateway gateway : detachedREs.getGateways().values()) {
logger.debug("\n\n");
logger.debug("Gateway: " + gateway.getName());
int vreDismissedPerGatew = 0;
for (VO vo : gateway.getVos().values()) {
logger.debug("VO: " + vo.getName());
for (VRE vre : vo.getVres().values()) {
logger.debug("VRE name: " + vre.getName() + " scope: " + vre.getScope()
+ " VRE catalogue url: " + vre.getCatalogUrl() + " VRE catalog Portlet URL: "
+ vre.getCatalogPortletURL());
vreDismissedPerGatew++;
}
}
logger.debug("\n\t\t\t******** VREs dismissed per " + gateway.getName() + " are: "
+ vreDismissedPerGatew);
totalVREDimissed += vreDismissedPerGatew;
}
logger.debug("\n\nTotal VREs dismissed: " + totalVREDimissed);
assertTrue(true);
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
assertTrue("Error searching the resource!", false);
}
} else {
logger.debug("Test Disabled");
assertTrue(true);
}
}
@Test
public void testFindDetachedVREForVREName() {
if (Constants.TEST_ENABLE) {
logger.debug("Test Enabled");
try {
String vreName = "bluebridgeproject";
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
SecurityTokenProvider.instance.set(Constants.DEFAULT_TOKEN);
DetachedREsClient detachedREsClient = new DetachedREsClient();
VRE vre = detachedREsClient.findDetachedVREforVREName(vreName);
logger.debug("The detached VRE for name: " + vreName + " found as: " + vre);
assertTrue(true);
} catch (Exception e) {
@ -186,6 +239,13 @@ public class DetachedREsTest extends TestCase {
createEOSCSecretariatDetachedGateway(eoscSecretariatDetachedGateway);
// ------ DESCRAMBLE Gateway begin
GatewayJAXB descrambleGateway = new GatewayJAXB();
descrambleGateway.setScope("-6");
descrambleGateway.setName("DESCRAMBLE Gateway");
createDescrambleGateway(descrambleGateway);
// Gateway Add
// -------------------
@ -195,6 +255,7 @@ public class DetachedREsTest extends TestCase {
gateways.put("-3", parthenosDetachedGateway);
gateways.put("-4", aginfraPlusDetachedGateway);
gateways.put("-5", eoscSecretariatDetachedGateway);
gateways.put("-6", descrambleGateway);
DetachedREsJAXB detachedREs = new DetachedREsJAXB();
detachedREs.setEnabled(true);
@ -216,13 +277,14 @@ public class DetachedREsTest extends TestCase {
logger.info("Check Unmarshalling");
Path path = Files.createTempFile("DetachedREsData", ".xml");
logger.info("Create file: " + path.toAbsolutePath());
File file = path.toFile();
jaxbMarshaller.marshal(detachedREs, file);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
DetachedREsJAXB configUnmarshalled = (DetachedREsJAXB) jaxbUnmarshaller.unmarshal(file);
logger.debug("DetachedREs unmarshallded: " + configUnmarshalled);
file.delete();
// file.delete();
logger.info("Success!");
assertTrue(true);
@ -382,7 +444,17 @@ public class DetachedREsTest extends TestCase {
gCubeAppsVREJAXB.setName(new String(vre).replace("_", " "));
gCubeAppsVREJAXB.setStartDate(new GregorianCalendar(2018, GregorianCalendar.JANUARY, 1).getTime());
gCubeAppsVREJAXB.setEndDate(new GregorianCalendar(2020, GregorianCalendar.MARCH, 3).getTime());
gCubeAppsVREJAXB.setCatalogUrl("http://data.d4science.org/ctlg/" + vre);
// UPDATED BY FRANCESCO
if (vre.compareToIgnoreCase("BlueBridgeProject") == 0 || vre.compareToIgnoreCase("SIASPA") == 0) {
gCubeAppsVREJAXB.setCatalogUrl("https://ckan-imarine.d4science.org");
gCubeAppsVREJAXB
.setCatalogPortletURL("https://i-marine.d4science.org/group/imarine-gateway/data-catalogue");
} else {
// not usable
gCubeAppsVREJAXB.setCatalogUrl("http://data.d4science.org/ctlg/" + vre);
}
gCubeAppsVREJAXB.setManagers(new ArrayList<String>(Arrays.asList("Leonardo Candela", "Pasquale Pagano")));
gCubeAppsVREsOfBlueBridgeGateway.put(
"/d4science.research-infrastructures.eu/" + VOProduction.GCUBEAPPS.getId() + "/" + vre,
@ -464,7 +536,8 @@ public class DetachedREsTest extends TestCase {
LinkedHashMap<String, VREJAXB> gCubeAppsVREsOfD4ScienceOrgDetachedGateway = new LinkedHashMap<>();
String[] gCubeAppsVREsOfD4ScienceOrgDetachedGatewayArray = { "CNR_OpenScienceTF", "EGIEngage", "ICOS_ETC" };
String[] gCubeAppsVREsOfD4ScienceOrgDetachedGatewayArray = { "CNR_OpenScienceTF", "EcologicalModelling",
"EGIEngage", "EGIP", "ICOS_ETC", "IGDI", "rScience", "TCom" };
for (String vre : gCubeAppsVREsOfD4ScienceOrgDetachedGatewayArray) {
VREJAXB gCubeAppsVREJAXB = new VREJAXB();
@ -513,8 +586,8 @@ public class DetachedREsTest extends TestCase {
LinkedHashMap<String, VREJAXB> d4ResearchVREsOfD4ScienceOrgDetachedGateway = new LinkedHashMap<>();
String[] d4ResearchVREsOfD4ScienceOrgDetachedGatewayArray = { "EOSC_Services", "FAIR_DM",
"FisheriesAndEcosystemAtMii", "ISTIOpenAccess" };
String[] d4ResearchVREsOfD4ScienceOrgDetachedGatewayArray = { "EISCAT", "ENVRI", "EOSC_Services", "FAIR_DM",
"FisheriesAndEcosystemAtMii", "ICOSEddyCovarianceProcessing", "ISTIOpenAccess", "QCAPI" };
for (String vre : d4ResearchVREsOfD4ScienceOrgDetachedGatewayArray) {
VREJAXB d4ResearchVREJAXB = new VREJAXB();
@ -531,7 +604,33 @@ public class DetachedREsTest extends TestCase {
}
d4ResearchOfD4ScienceOrgDetachedGateway.setVres(d4ResearchVREsOfD4ScienceOrgDetachedGateway);
// D4OS
VOJAXB d4osOfD4ScienceOrgDetachedGateway = new VOJAXB();
d4osOfD4ScienceOrgDetachedGateway
.setScope("/d4science.research-infrastructures.eu/" + VOProduction.D4OS.getId());
d4osOfD4ScienceOrgDetachedGateway.setName(VOProduction.D4OS.getId());
LinkedHashMap<String, VREJAXB> d4osVREsOfD4ScienceOrgDetachedGateway = new LinkedHashMap<>();
String[] d4osVREsOfD4ScienceOrgDetachedGatewayArray = { "CNROutreach", "RicAt" };
for (String vre : d4osVREsOfD4ScienceOrgDetachedGatewayArray) {
VREJAXB d4osVREJAXB = new VREJAXB();
d4osVREJAXB.setScope("/d4science.research-infrastructures.eu/" + VOProduction.D4OS.getId() + "/" + vre);
d4osVREJAXB.setName(new String(vre).replace("_", " "));
d4osVREJAXB.setStartDate(new GregorianCalendar(2018, GregorianCalendar.JANUARY, 1).getTime());
d4osVREJAXB.setEndDate(new GregorianCalendar(2020, GregorianCalendar.MARCH, 3).getTime());
d4osVREJAXB.setCatalogUrl("http://data.d4science.org/ctlg/" + vre);
d4osVREJAXB.setManagers(new ArrayList<String>(Arrays.asList("Leonardo Candela", "Pasquale Pagano")));
d4osVREsOfD4ScienceOrgDetachedGateway.put(
"/d4science.research-infrastructures.eu/" + VOProduction.D4OS.getId() + "/" + vre, d4osVREJAXB);
}
d4osOfD4ScienceOrgDetachedGateway.setVres(d4osVREsOfD4ScienceOrgDetachedGateway);
//
LinkedHashMap<String, VOJAXB> vosOfD4ScienceOrgDetachedGateway = new LinkedHashMap<>();
vosOfD4ScienceOrgDetachedGateway.put("/d4science.research-infrastructures.eu/" + VOProduction.D4OS.getId(),
d4osOfD4ScienceOrgDetachedGateway);
vosOfD4ScienceOrgDetachedGateway.put(
"/d4science.research-infrastructures.eu/" + VOProduction.D4RESEARCH.getId(),
d4ResearchOfD4ScienceOrgDetachedGateway);
@ -543,4 +642,37 @@ public class DetachedREsTest extends TestCase {
d4ScienceOrgDetachedGateway.setVos(vosOfD4ScienceOrgDetachedGateway);
}
private void createDescrambleGateway(GatewayJAXB descrambleGateway) {
// gCubeApps
VOJAXB gCubeAppsOfDescrambleGateway = new VOJAXB();
gCubeAppsOfDescrambleGateway
.setScope("/d4science.research-infrastructures.eu/" + VOProduction.GCUBEAPPS.getId());
gCubeAppsOfDescrambleGateway.setName(VOProduction.GCUBEAPPS.getId());
LinkedHashMap<String, VREJAXB> gCubeAppsVREsOfDescrambleGateway = new LinkedHashMap<>();
String[] gCubeAppsVREsOfDescrambleGatewayArray = { "DESCRAMBLE" };
for (String vre : gCubeAppsVREsOfDescrambleGatewayArray) {
VREJAXB gCubeAppsVREJAXB = new VREJAXB();
gCubeAppsVREJAXB
.setScope("/d4science.research-infrastructures.eu/" + VOProduction.GCUBEAPPS.getId() + "/" + vre);
gCubeAppsVREJAXB.setName(new String(vre).replace("_", " "));
gCubeAppsVREJAXB.setStartDate(new GregorianCalendar(2014, GregorianCalendar.JANUARY, 1).getTime());
gCubeAppsVREJAXB.setEndDate(new GregorianCalendar(2020, GregorianCalendar.SEPTEMBER, 25).getTime());
gCubeAppsVREJAXB.setCatalogUrl("http://data.d4science.org/ctlg/" + vre);
gCubeAppsVREJAXB.setManagers(new ArrayList<String>(Arrays.asList("Leonardo Candela", "Pasquale Pagano")));
gCubeAppsVREsOfDescrambleGateway.put(
"/d4science.research-infrastructures.eu/" + VOProduction.GCUBEAPPS.getId() + "/" + vre,
gCubeAppsVREJAXB);
}
gCubeAppsOfDescrambleGateway.setVres(gCubeAppsVREsOfDescrambleGateway);
LinkedHashMap<String, VOJAXB> vosOfDescrambleGateway = new LinkedHashMap<>();
vosOfDescrambleGateway.put("/d4science.research-infrastructures.eu/" + VOProduction.GCUBEAPPS.getId(),
gCubeAppsOfDescrambleGateway);
descrambleGateway.setVos(vosOfDescrambleGateway);
}
}