use of io.goobi.workflow.xslt.XsltPreparatorDocket in project goobi-workflow by intranda.
the class GoobiScriptExportDatabaseInformation method execute.
@Override
public void execute(GoobiScriptResult gsr) {
Process p = ProcessManager.getProcessById(gsr.getProcessId());
try {
gsr.setProcessTitle(p.getTitel());
gsr.setResultType(GoobiScriptResultType.RUNNING);
gsr.updateTimestamp();
Path dest = null;
try {
dest = Paths.get(p.getProcessDataDirectoryIgnoreSwapping(), p.getId() + "_db_export.xml");
} catch (IOException | InterruptedException | SwapException | DAOException e) {
log.error(e);
gsr.setResultMessage("Cannot read process folder " + e.getMessage());
gsr.setResultType(GoobiScriptResultType.ERROR);
}
OutputStream os = null;
try {
os = Files.newOutputStream(dest);
} catch (IOException e) {
log.error(e);
gsr.setResultMessage("Cannot write into export file " + e.getMessage());
gsr.setResultType(GoobiScriptResultType.ERROR);
}
try {
Document doc = new XsltPreparatorDocket().createExtendedDocument(p);
XMLOutputter outp = new XMLOutputter();
outp.setFormat(Format.getPrettyFormat());
outp.output(doc, os);
} catch (IOException e) {
log.error(e);
gsr.setResultMessage("Cannot write into export file " + e.getMessage());
gsr.setResultType(GoobiScriptResultType.ERROR);
} finally {
if (os != null) {
os.close();
}
}
if (gsr.getResultType() != GoobiScriptResultType.ERROR) {
gsr.setResultMessage("Export done successfully");
gsr.setResultType(GoobiScriptResultType.OK);
}
} catch (NoSuchMethodError | Exception e) {
gsr.setResultMessage(e.getMessage());
gsr.setResultType(GoobiScriptResultType.ERROR);
gsr.setErrorText(e.getMessage());
log.error("Exception during the export of database information for id " + p.getId(), e);
}
gsr.updateTimestamp();
}
use of io.goobi.workflow.xslt.XsltPreparatorDocket in project goobi-workflow by intranda.
the class ProcessBean method downloadProcessDatebaseInformation.
/**
* Create the database information xml file and send it to the servlet output stream
*/
public void downloadProcessDatebaseInformation() {
FacesContext facesContext = FacesContextHelper.getCurrentFacesContext();
if (!facesContext.getResponseComplete()) {
org.jdom2.Document doc = new XsltPreparatorDocket().createExtendedDocument(myProzess);
String outputFileName = myProzess.getId() + "_db_export.xml";
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
String contentType = servletContext.getMimeType(outputFileName);
response.setContentType(contentType);
response.setHeader("Content-Disposition", "attachment;filename=\"" + outputFileName + "\"");
try {
ServletOutputStream out = response.getOutputStream();
XMLOutputter outp = new XMLOutputter();
outp.setFormat(Format.getPrettyFormat());
outp.output(doc, out);
out.flush();
} catch (IOException e) {
Helper.setFehlerMeldung("could not export database information: ", e);
}
facesContext.responseComplete();
}
}
use of io.goobi.workflow.xslt.XsltPreparatorDocket in project goobi-workflow by intranda.
the class ProcessBean method CreateXML.
/**
* starts generation of xml logfile for current process
*/
public void CreateXML() {
XsltPreparatorDocket xmlExport = new XsltPreparatorDocket();
try {
String ziel = Helper.getCurrentUser().getHomeDir() + this.myProzess.getTitel() + "_log.xml";
xmlExport.startExport(this.myProzess, ziel);
} catch (IOException e) {
Helper.setFehlerMeldung("could not write logfile to home directory: ", e);
} catch (InterruptedException e) {
Helper.setFehlerMeldung("could not execute command to write logfile to home directory", e);
}
}
use of io.goobi.workflow.xslt.XsltPreparatorDocket in project goobi-workflow by intranda.
the class Process method downloadDocket.
public String downloadDocket() {
if (log.isDebugEnabled()) {
log.debug("generate docket for process " + this.id);
}
String rootpath = ConfigurationHelper.getInstance().getXsltFolder();
Path xsltfile = Paths.get(rootpath, "docket.xsl");
if (docket != null) {
xsltfile = Paths.get(rootpath, docket.getFile());
if (!StorageProvider.getInstance().isFileExists(xsltfile)) {
Helper.setFehlerMeldung("docketMissing");
return "";
}
}
FacesContext facesContext = FacesContextHelper.getCurrentFacesContext();
if (!facesContext.getResponseComplete()) {
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
String fileName = this.titel + ".pdf";
ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
String contentType = servletContext.getMimeType(fileName);
response.setContentType(contentType);
response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
// write run note to servlet output stream
try {
ServletOutputStream out = response.getOutputStream();
XsltToPdf ern = new XsltToPdf();
ern.startExport(this, out, xsltfile.toString(), new XsltPreparatorDocket());
out.flush();
} catch (IOException e) {
log.error("IOException while exporting run note", e);
}
facesContext.responseComplete();
}
return "";
}
use of io.goobi.workflow.xslt.XsltPreparatorDocket in project goobi-workflow by intranda.
the class Process method downloadLogFile.
/**
* download xml logfile for current process
*/
public void downloadLogFile() {
XsltPreparatorDocket xmlExport = new XsltPreparatorDocket();
FacesContext facesContext = FacesContextHelper.getCurrentFacesContext();
if (!facesContext.getResponseComplete()) {
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
String fileName = getTitel() + "_log.xml";
ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
String contentType = servletContext.getMimeType(fileName);
response.setContentType(contentType);
response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
// write to servlet output stream
try {
ServletOutputStream out = response.getOutputStream();
xmlExport.startExport(this, out);
out.flush();
} catch (IOException e) {
log.error("IOException while exporting run note", e);
}
facesContext.responseComplete();
}
return;
}
Aggregations