Skip to content

Commit

Permalink
ExportPdf uses interal mets file and does not create a export Mets (with
Browse files Browse the repository at this point in the history
potentially wrong image urls)
  • Loading branch information
Florian Alpers committed Jan 15, 2025
1 parent 4b2a839 commit a10367b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/main/java/de/sub/goobi/export/download/ExportPdf.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import de.sub.goobi.config.ConfigurationHelper;
import de.sub.goobi.forms.HelperForm;
import de.sub.goobi.helper.FacesContextHelper;
import de.sub.goobi.helper.Helper;
import de.sub.goobi.helper.NIOFileUtils;
import de.sub.goobi.helper.StorageProvider;
import de.sub.goobi.helper.exceptions.DAOException;
Expand All @@ -56,7 +55,6 @@
import de.sub.goobi.helper.exceptions.UghHelperException;
import de.sub.goobi.helper.tasks.CreatePdfFromServletThread;
import lombok.extern.log4j.Log4j2;
import ugh.dl.Fileformat;
import ugh.exceptions.DocStructHasNoTypeException;
import ugh.exceptions.MetadataTypeNotAllowedException;
import ugh.exceptions.PreferencesException;
Expand All @@ -75,19 +73,13 @@ public boolean startExport(Process myProzess, String inZielVerzeichnis) throws I
/*
* -------------------------------- Read Document --------------------------------
*/
Fileformat gdzfile = myProzess.readMetadataFile();
String zielVerzeichnis = prepareUserDirectory(inZielVerzeichnis);
this.myPrefs = myProzess.getRegelsatz().getPreferences();

/*
* -------------------------------- first of all write mets-file in images-Folder of process --------------------------------
*/

Path metsTempFile = StorageProvider.getInstance().createTemporaryFile(myProzess.getTitel(), ".xml");
writeMetsFile(myProzess, metsTempFile.toString(), gdzfile, true);
Helper.setMeldung(null, myProzess.getTitel() + ": ", "mets file created");
Helper.setMeldung(null, myProzess.getTitel() + ": ", "start pdf generation now");
log.debug("METS file created: " + metsTempFile);
FacesContext context = FacesContextHelper.getCurrentFacesContext();
HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest();
String fullpath = req.getRequestURL().toString();
Expand All @@ -107,7 +99,7 @@ public boolean startExport(Process myProzess, String inZielVerzeichnis) throws I
* -------------------------------- use contentserver api for creation of pdf-file --------------------------------
*/
CreatePdfFromServletThread pdf = new CreatePdfFromServletThread();
pdf.setMetsURL(metsTempFile.toUri().toURL());
pdf.setMetsURL(Path.of(myProzess.getMetadataFilePath()).toUri().toURL());
pdf.setTargetFolder(Paths.get(zielVerzeichnis));
pdf.setInternalServletPath(myBasisUrl);
pdf.setImagePath(imagesPath);
Expand All @@ -129,18 +121,19 @@ public boolean startExport(Process myProzess, String inZielVerzeichnis) throws I
* -------------------------------- using mets file --------------------------------
*/

if (StorageProvider.getInstance().isFileExists(metsTempFile)) {
if (StorageProvider.getInstance().isFileExists(Path.of(myProzess.getMetadataFilePath()))) {

goobiContentServerUrl = UriBuilder.fromUri(new HelperForm().getServletPathWithHostAsUrl())
.path("api")
.path("process")
.path("pdf")
.path(Integer.toString(myProzess.getId()))
.path(myProzess.getTitel() + ".pdf")
.queryParam("metsFile", metsTempFile)
.queryParam("metsFile", Path.of(myProzess.getMetadataFilePath()).toUri().toString())
.queryParam("imageSource", imagesPath.toUri())
.queryParam("pdfSource", pdfPath.toUri())
.queryParam("altoSource", altoPath.toUri())
.queryParam("goobiMetsFile", "true")
.build()
.toURL();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public void run() {
.queryParam("imageSource", getImagePath().toUri())
.queryParam("pdfSource", getPdfPath().toUri())
.queryParam("altoSource", getAltoPath().toUri())
.queryParam("goobiMetsFile", "true")
.build()
.toURL();

Expand Down

0 comments on commit a10367b

Please sign in to comment.