Integrated GeoportalExporterAPI

This commit is contained in:
Francesco Mangiacrapa 2024-04-23 12:33:40 +02:00
parent ef116da956
commit ddda2bd4e6
7 changed files with 120 additions and 9 deletions

View File

@ -28,7 +28,7 @@
<classpathentry kind="lib" path="/home/francescomangiacrapa/config-work-isti/log4jconfiguration"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="owner.project.facets" value="java"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

View File

@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [v1.8.0-SNAPSHOT]
- Enhanced the Geoportal-Resolver. Supported share links to Geoportal Data-Entry app [#27160]
- Provided the new endpoint: GeoportalExporter [#27308]
## [v1.7.0]

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.user.uriresolvermanager.geoportal;
import java.net.MalformedURLException;
import java.net.URL;
import org.gcube.portlets.user.uriresolvermanager.entity.ServiceAccessPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GeoportalExporterAPI {
private GeoportalExporterEndpoint endpoint;
private ServiceAccessPoint serviceAccessPoint;
private final String QUERY_PARAMETER_AS_URL = "as-url";
public static final Logger LOG = LoggerFactory.getLogger(GeoportalExporterAPI.class);
public static String DEFAULT_TYPE = "pdf";
public GeoportalExporterAPI() throws Exception {
this.endpoint = new GeoportalExporterEndpoint();
this.serviceAccessPoint = this.endpoint.getServiceAccessPoint();
}
public URL exportProject(String type, String ucdID, String projectID, boolean asURL) throws MalformedURLException {
if (type == null || type.isEmpty())
type = DEFAULT_TYPE;
String api = String.format("%s/export/%s/%s/%s", serviceAccessPoint.getServiceUrl(), type, ucdID, projectID);
if(asURL)
api+="?"+QUERY_PARAMETER_AS_URL+"="+asURL;
LOG.info("returning exportProject API: " + api);
return new URL(api);
}
public URL viewJob(String jobCode) throws MalformedURLException {
String api = String.format("%s/view/%s", serviceAccessPoint.getServiceUrl(), jobCode);
LOG.info("returning viewJob API: " + api);
return new URL(api);
}
public URL healthcheck(String type) throws MalformedURLException {
if (type == null || type.isEmpty())
type = DEFAULT_TYPE;
String api = String.format("%s/export/%s/healthcheck", serviceAccessPoint.getServiceUrl(), type);
LOG.info("returning healthcheck API: " + api);
return new URL(api);
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.uriresolvermanager.geoportal;
import org.gcube.portlets.user.uriresolvermanager.entity.ServiceAccessPoint;
import org.gcube.portlets.user.uriresolvermanager.readers.RuntimeResourceReader;
public class GeoportalExporterEndpoint {
public final String URI_RESOLVER_RESOURCE_NAME = "HTTP-URI-Resolver";
public final String ENTRY_POINT_NAME = "geoportal_exp";
public GeoportalExporterEndpoint() {
}
public ServiceAccessPoint getServiceAccessPoint()throws Exception {
RuntimeResourceReader runtimeRR = new RuntimeResourceReader(URI_RESOLVER_RESOURCE_NAME);
return runtimeRR.getServiceAccessPointForEntryName(ENTRY_POINT_NAME);
}
}

View File

@ -92,21 +92,18 @@ public class RuntimeResourceReader {
while (acIt.hasNext()) {
AccessPoint ap = acIt.next();
Group<Property> properties = ap.properties();
if (properties.size() == 0) {
logger.warn("Properties in resource " + resourceName + " not found");
logger.warn("Properties in resource " + resourceName + " not found for ap: "+ap.name());
serviceAccessPoints.add(new ServiceAccessPoint(ap.name(), ap.address(), null));
} else {
List<ServiceParameter> serviceParameters = new ArrayList<ServiceParameter>(properties.size());
Iterator<Property> iter = properties.iterator();
while (iter.hasNext()) {
Property prop = iter.next();
serviceParameters.add(new ServiceParameter(prop.value(), true));
}

View File

@ -0,0 +1,42 @@
import java.net.URL;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
import org.gcube.portlets.user.uriresolvermanager.exception.IllegalArgumentException;
import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
import org.gcube.portlets.user.uriresolvermanager.geoportal.GeoportalExporterAPI;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Oct 20, 2014
*
*/
public class GeoportalExporterTest {
//@Test
public void testGeoportalExporterEndppoint() {
UriResolverManager manager;
try {
ScopeProvider.instance.set("/gcube/devsec/devVRE");
GeoportalExporterAPI geAPI = new GeoportalExporterAPI();
boolean asURL = true;
URL exportProjectURL = geAPI.exportProject("pdf", "profiledConcessioni", "661d2c6f8804530afb90b132", asURL);
System.out.println("exportProjectURL: "+exportProjectURL);
URL healthcheckURL = geAPI.healthcheck("pdf");
System.out.println("healthcheckURL: "+healthcheckURL);
} catch (UriResolverMapException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@ -12,7 +12,6 @@ import org.gcube.portlets.user.uriresolvermanager.resolvers.query.CatalogueResol
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder;
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.RESOLVE_AS;
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.TARGET_GEOPORTAL_APP;
import org.junit.Test;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
@ -27,7 +26,7 @@ public class UriResolverManagerTest {
try {
ScopeProvider.instance.set("/gcube/devsec/devVRE");
manager = new UriResolverManager();
System.out.println("Capabiities: " + manager.getCapabilities());
System.out.println("Capabilities: " + manager.getCapabilities());
System.out.println("ApplicationTypes: " + manager.getApplicationTypes());
for (String applicationType : manager.getApplicationTypes()) {
Resolver resolver = manager.getResolver(applicationType);