export_to_pdf #8
9
pom.xml
9
pom.xml
|
@ -20,7 +20,7 @@
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jersey.version>2.24.1</jersey.version>
|
<jersey.version>2.25.1</jersey.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<enunciate.version>2.14.0</enunciate.version>
|
<enunciate.version>2.14.0</enunciate.version>
|
||||||
|
@ -137,7 +137,12 @@
|
||||||
<version>${jersey.version}</version>
|
<version>${jersey.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.ext</groupId>
|
||||||
|
<artifactId>jersey-mvc-jsp</artifactId>
|
||||||
|
<version>${jersey.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.core</groupId>
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
<artifactId>jersey-server</artifactId>
|
<artifactId>jersey-server</artifactId>
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.datatransfer.resolver.services.CatalogueResolver;
|
||||||
import org.gcube.datatransfer.resolver.services.tobackward.BackCatalogueResolver;
|
import org.gcube.datatransfer.resolver.services.tobackward.BackCatalogueResolver;
|
||||||
import org.gcube.smartgears.annotations.ManagedBy;
|
import org.gcube.smartgears.annotations.ManagedBy;
|
||||||
import org.glassfish.jersey.server.ResourceConfig;
|
import org.glassfish.jersey.server.ResourceConfig;
|
||||||
|
import org.glassfish.jersey.server.mvc.jsp.JspMvcFeature;
|
||||||
|
|
||||||
@Path("uri-resolver")
|
@Path("uri-resolver")
|
||||||
@ManagedBy(UriResolverSmartGearManagerInit.class)
|
@ManagedBy(UriResolverSmartGearManagerInit.class)
|
||||||
|
@ -18,6 +19,8 @@ public class UriResolver extends ResourceConfig {
|
||||||
// Register all resources present under the package.
|
// Register all resources present under the package.
|
||||||
packages(CatalogueResolver.class.getPackage().getName(), RequestHandler.class.getPackage().getName(), BackCatalogueResolver.class.getPackage().getName());
|
packages(CatalogueResolver.class.getPackage().getName(), RequestHandler.class.getPackage().getName(), BackCatalogueResolver.class.getPackage().getName());
|
||||||
packages(DataMinerInvocation.class.getPackage().getName());
|
packages(DataMinerInvocation.class.getPackage().getName());
|
||||||
|
register(JspMvcFeature.class);
|
||||||
|
property(JspMvcFeature.TEMPLATE_BASE_PATH, "/WEB-INF/jsp");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class UriResolverServletContextListener implements ServletContextListener
|
||||||
public void contextInitialized(ServletContextEvent event) {
|
public void contextInitialized(ServletContextEvent event) {
|
||||||
|
|
||||||
servletContext = event.getServletContext();
|
servletContext = event.getServletContext();
|
||||||
log.info("Context Initialized at context path: "+servletContext.getContextPath());
|
log.info("Context Initialized at context path: "+servletContext.getContext("/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,6 +14,7 @@ import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
|
|
||||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
|
import org.glassfish.jersey.server.mvc.Viewable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ public class DocsGenerator {
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/{any: .*}")
|
@Path("/{any: .*}")
|
||||||
public InputStream toDoc(@Context HttpServletRequest req) throws WebApplicationException {
|
public Viewable toDoc(@Context HttpServletRequest req) throws WebApplicationException {
|
||||||
logger.info(DocsGenerator.class.getSimpleName() + " toDoc called");
|
logger.info(DocsGenerator.class.getSimpleName() + " toDoc called");
|
||||||
|
|
||||||
String pathInfo = req.getPathInfo();
|
String pathInfo = req.getPathInfo();
|
||||||
|
@ -51,8 +52,10 @@ public class DocsGenerator {
|
||||||
|
|
||||||
logger.info("going to {}", pathInfo);
|
logger.info("going to {}", pathInfo);
|
||||||
|
|
||||||
String realPath = req.getServletContext().getRealPath(pathInfo);
|
//String realPath = req.getServletContext().getRealPath(pathInfo);
|
||||||
return new FileInputStream(new File(realPath));
|
//return new FileInputStream(new File(realPath));
|
||||||
|
|
||||||
|
return new Viewable(pathInfo);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.gcube.datatransfer.resolver.ConstantsResolver;
|
||||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
import org.gcube.datatransfer.resolver.services.exceptions.BadRequestException;
|
import org.gcube.datatransfer.resolver.services.exceptions.BadRequestException;
|
||||||
import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput;
|
import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput;
|
||||||
|
import org.glassfish.jersey.server.mvc.Viewable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -131,6 +132,68 @@ public class GeoportalExporter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve geoportal no app def.
|
||||||
|
*
|
||||||
|
* @param req the req
|
||||||
|
* @param vreName the vre name
|
||||||
|
* @param exportType the export type
|
||||||
|
* @param ucdID the ucd ID
|
||||||
|
* @param projectID the project ID
|
||||||
|
* @return the response
|
||||||
|
* @throws WebApplicationException the web application exception
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/export/{type}/view/{usecase_id}/{project_id}")
|
||||||
|
@Produces({ MediaType.TEXT_HTML })
|
||||||
|
public Viewable exportView(@Context HttpServletRequest req, @PathParam(EXPORT_TYPE) String export_type,
|
||||||
|
@PathParam(PATH_USECASE_ID) String ucdID, @PathParam(PATH_PROJECT_ID) String projectID)
|
||||||
|
throws WebApplicationException {
|
||||||
|
|
||||||
|
String userAgentName = req.getHeader("User-Agent");
|
||||||
|
|
||||||
|
LOG.info(this.getClass().getSimpleName() + " export view - GET starts...");
|
||||||
|
LOG.debug("params are: exportType: {}, ucdID: {}, projectID: {}", export_type, ucdID, projectID);
|
||||||
|
|
||||||
|
checkPathParameterNotNull(req, EXPORT_TYPE, export_type);
|
||||||
|
checkPathParameterNotNull(req, PATH_USECASE_ID, ucdID);
|
||||||
|
checkPathParameterNotNull(req, PATH_PROJECT_ID, projectID);
|
||||||
|
|
||||||
|
checkExportType(req, export_type);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
SecretManager cm = SecretManagerProvider.instance.get();
|
||||||
|
String context = cm.getContext();
|
||||||
|
if (context == null) {
|
||||||
|
throw ExceptionManager.forbiddenException(req, "Cannot determine context (the scope)", this.getClass(),
|
||||||
|
helpURI);
|
||||||
|
}
|
||||||
|
org.gcube.common.authorization.utils.user.User user = cm.getUser();
|
||||||
|
LOG.info("Identified caller {} in context {}", user.getUsername(), context);
|
||||||
|
|
||||||
|
Geoportal_PDF_Exporter pdfExporter = new Geoportal_PDF_Exporter();
|
||||||
|
boolean checked = pdfExporter.checkConfig();
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
LOG.info("Serving request as User-Agent {}", userAgentName);
|
||||||
|
//String entity = entityHTMLMessage("Exporting as PDF...", "The project with " + projectID, true);
|
||||||
|
// return Response.ok(entity).encoding("UTF-8").header(ConstantsResolver.CONTENT_TYPE, "text/html")
|
||||||
|
// .build();
|
||||||
|
return new Viewable("/geoportal_exporter");
|
||||||
|
} else {
|
||||||
|
throw ExceptionManager.notFoundException(req, this.getClass().getSimpleName()+ " not found in the context: "+context,
|
||||||
|
this.getClass(), helpURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Error on performing export", e);
|
||||||
|
throw ExceptionManager.internalErrorException(req, "Sorry, error occurred when exporting the project",
|
||||||
|
this.getClass(), helpURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/export/{type}/healthcheck")
|
@Path("/export/{type}/healthcheck")
|
||||||
@Produces({ MediaType.TEXT_HTML, MediaType.TEXT_PLAIN })
|
@Produces({ MediaType.TEXT_HTML, MediaType.TEXT_PLAIN })
|
||||||
|
|
|
@ -16,6 +16,7 @@ import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
|
import org.glassfish.jersey.server.mvc.Viewable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -31,6 +32,8 @@ public class UriResolverIndex {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(UriResolverIndex.class);
|
private static Logger logger = LoggerFactory.getLogger(UriResolverIndex.class);
|
||||||
|
|
||||||
|
private String indexFile = "/index";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index.
|
* Index.
|
||||||
*
|
*
|
||||||
|
@ -41,14 +44,15 @@ public class UriResolverIndex {
|
||||||
@GET
|
@GET
|
||||||
@Produces({ MediaType.TEXT_HTML })
|
@Produces({ MediaType.TEXT_HTML })
|
||||||
@Path("")
|
@Path("")
|
||||||
public InputStream index(@Context HttpServletRequest req) throws WebApplicationException {
|
public Viewable index(@Context HttpServletRequest req) throws WebApplicationException {
|
||||||
|
|
||||||
String indexFile = "/WEB-INF/jsp/index.jsp";
|
//String indexFile = "/WEB-INF/jsp/index.jsp";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info(UriResolverIndex.class.getSimpleName() + " called");
|
logger.info(UriResolverIndex.class.getSimpleName() + " called");
|
||||||
String realPath = req.getServletContext().getRealPath(indexFile);
|
//String realPath = req.getServletContext().getRealPath(indexFile);
|
||||||
return new FileInputStream(new File(realPath));
|
return new Viewable(indexFile);
|
||||||
|
//return new FileInputStream(new File(realPath));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
if (!(e instanceof WebApplicationException)) {
|
if (!(e instanceof WebApplicationException)) {
|
||||||
|
|
|
@ -13,6 +13,8 @@ import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.glassfish.jersey.server.mvc.Viewable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The UriResolverInfo get index.
|
* The UriResolverInfo get index.
|
||||||
*
|
*
|
||||||
|
@ -33,7 +35,7 @@ public class UriResolverInfo {
|
||||||
@GET
|
@GET
|
||||||
@Produces({ MediaType.TEXT_HTML })
|
@Produces({ MediaType.TEXT_HTML })
|
||||||
@Path("")
|
@Path("")
|
||||||
public InputStream info(@Context HttpServletRequest req) throws WebApplicationException {
|
public Viewable info(@Context HttpServletRequest req) throws WebApplicationException {
|
||||||
return new UriResolverIndex().index(req);
|
return new UriResolverIndex().index(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
import org.gcube.datatransfer.resolver.services.exceptions.NotFoundException;
|
import org.gcube.datatransfer.resolver.services.exceptions.NotFoundException;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
|
import org.glassfish.jersey.server.mvc.Viewable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -190,14 +191,15 @@ public class WekeoResolver {
|
||||||
@GET
|
@GET
|
||||||
@Produces({ MediaType.TEXT_HTML })
|
@Produces({ MediaType.TEXT_HTML })
|
||||||
@Path("")
|
@Path("")
|
||||||
public InputStream index(@Context HttpServletRequest req) throws WebApplicationException {
|
public Viewable index(@Context HttpServletRequest req) throws WebApplicationException {
|
||||||
|
|
||||||
String indexFile = "/WEB-INF/jsp/wekeo.jsp";
|
String indexFile = "/WEB-INF/jsp/wekeo.jsp";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info(this.getClass().getSimpleName() + " index called");
|
// logger.info(this.getClass().getSimpleName() + " index called");
|
||||||
String realPath = req.getServletContext().getRealPath(indexFile);
|
// String realPath = req.getServletContext().getRealPath(indexFile);
|
||||||
return new FileInputStream(new File(realPath));
|
// return new FileInputStream("/wekeo");
|
||||||
|
return new Viewable(indexFile);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
if (!(e instanceof WebApplicationException)) {
|
if (!(e instanceof WebApplicationException)) {
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
||||||
|
<meta content="utf-8" http-equiv="encoding">
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
margin: 10px;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: table
|
||||||
|
}
|
||||||
|
|
||||||
|
#content {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
-webkit-transform: translate(-50%, -50%);
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#message {
|
||||||
|
color: gray;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<title>D4Science Geoportal - Action</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<img alt="D4Science Logo"
|
||||||
|
src="https://services.d4science.org/image/layout_set_logo?img_id=32727">
|
||||||
|
<br />
|
||||||
|
<div id="content">
|
||||||
|
<p style="font-size: 18px;">Exporting as PDF...</p>
|
||||||
|
<img alt="D4Science Geoportal Loading..."
|
||||||
|
src="uri-resolver/img/loading-gears.gif"><br />
|
||||||
|
<br />
|
||||||
|
<p id="message">The project with 661d2c6f8804530afb90b132</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue