Integrated GeoportalExporterAPI
This commit is contained in:
parent
ef116da956
commit
ddda2bd4e6
|
@ -28,7 +28,7 @@
|
||||||
<classpathentry kind="lib" path="/home/francescomangiacrapa/config-work-isti/log4jconfiguration"/>
|
<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">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="owner.project.facets" value="java"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
|
|
@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
## [v1.8.0-SNAPSHOT]
|
## [v1.8.0-SNAPSHOT]
|
||||||
|
|
||||||
- Enhanced the Geoportal-Resolver. Supported share links to Geoportal Data-Entry app [#27160]
|
- Enhanced the Geoportal-Resolver. Supported share links to Geoportal Data-Entry app [#27160]
|
||||||
|
- Provided the new endpoint: GeoportalExporter [#27308]
|
||||||
|
|
||||||
## [v1.7.0]
|
## [v1.7.0]
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -92,21 +92,18 @@ public class RuntimeResourceReader {
|
||||||
while (acIt.hasNext()) {
|
while (acIt.hasNext()) {
|
||||||
|
|
||||||
AccessPoint ap = acIt.next();
|
AccessPoint ap = acIt.next();
|
||||||
|
|
||||||
Group<Property> properties = ap.properties();
|
Group<Property> properties = ap.properties();
|
||||||
|
|
||||||
if (properties.size() == 0) {
|
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 {
|
} else {
|
||||||
|
|
||||||
List<ServiceParameter> serviceParameters = new ArrayList<ServiceParameter>(properties.size());
|
List<ServiceParameter> serviceParameters = new ArrayList<ServiceParameter>(properties.size());
|
||||||
|
|
||||||
Iterator<Property> iter = properties.iterator();
|
Iterator<Property> iter = properties.iterator();
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
|
||||||
Property prop = iter.next();
|
Property prop = iter.next();
|
||||||
|
|
||||||
serviceParameters.add(new ServiceParameter(prop.value(), true));
|
serviceParameters.add(new ServiceParameter(prop.value(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.RESOLVE_AS;
|
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.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.TARGET_GEOPORTAL_APP;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
@ -27,7 +26,7 @@ public class UriResolverManagerTest {
|
||||||
try {
|
try {
|
||||||
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
||||||
manager = new UriResolverManager();
|
manager = new UriResolverManager();
|
||||||
System.out.println("Capabiities: " + manager.getCapabilities());
|
System.out.println("Capabilities: " + manager.getCapabilities());
|
||||||
System.out.println("ApplicationTypes: " + manager.getApplicationTypes());
|
System.out.println("ApplicationTypes: " + manager.getApplicationTypes());
|
||||||
for (String applicationType : manager.getApplicationTypes()) {
|
for (String applicationType : manager.getApplicationTypes()) {
|
||||||
Resolver resolver = manager.getResolver(applicationType);
|
Resolver resolver = manager.getResolver(applicationType);
|
||||||
|
|
Loading…
Reference in New Issue