added user agent check

This commit is contained in:
Francesco Mangiacrapa 2024-04-19 12:42:20 +02:00
parent 1f33e820d5
commit df64963bc3
1 changed files with 7 additions and 29 deletions

View File

@ -98,35 +98,13 @@ public class GeoportalExporter {
Geoportal_PDF_Exporter pdfExporter = new Geoportal_PDF_Exporter();
boolean checked = pdfExporter.checkConfig();
// ExporterProjectSource exporterSource = new ExporterProjectSource();
// RESOLVE_AS resolveAs = RESOLVE_AS.PUBLIC;
// // #NB SET USERNAME = null to export with PUBLIC ACCESS
// if (!cm.getUser().isApplication()) {
// // here the token is of an user
// resolveAs = RESOLVE_AS.PRIVATE;
// exporterSource.setAccountname(user.getUsername());
// }
//
// exporterSource.setScope(context);
// exporterSource.setProjectID(projectID);
// exporterSource.setProfileID(ucdID);
//
// String vreName = context.substring(context.lastIndexOf("/") + 1, context.length());
// LOG.info("Requesting gis link to vre {}", vreName);
// Response theReponseWithLink = new GeoportalResolver().genericResolveLink(req,
// TargetAppGeoportalCodes.GEO_DV, vreName, ucdID, projectID, resolveAs.name());
// String theGisLink = theReponseWithLink.getEntity().toString();
// LOG.info("Gis link returned {}", theGisLink);
// exporterSource.setGisLink(theGisLink);
if (checked) {
String pdfURL = null;
// if (userAgentName != null) {
// 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();
// } else {
if (userAgentName != null) {
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();
} else {
LOG.info("Serving request as client...");
FileReference pdfRef = exportAsPDF(req, ucdID, projectID, null, context, user);
@ -138,7 +116,7 @@ public class GeoportalExporter {
"inline; filename=\"" + pdfRef.getFileName() + "\"")
.header("Content-Type", pdfRef.getContentType());
return response.build();
// }
}
} else {
return Response.status(Status.NOT_FOUND)
.entity(GeoportalExporter.class.getSimpleName() + " Config not found in the context " + context)