Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating server to return full url #7

Merged
merged 3 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -6,7 +6,7 @@
<groupId>com.idrsolutions</groupId>
<artifactId>buildvu-microservice-example</artifactId>
<packaging>war</packaging>
<version>1.0.1-alpha</version>
<version>2.0.0-alpha</version>
<name>BuildVu Microservice Example</name>

<dependencies>
Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>com.idrsolutions</groupId>
<artifactId>base-microservice-example</artifactId>
<version>1.0.1-alpha</version>
<version>2.0.0-alpha</version>
</dependency>
<dependency>
<groupId>buildvu</groupId>
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/conversion/BuildVuServlet.java
Expand Up @@ -40,9 +40,9 @@ public class BuildVuServlet extends BaseServlet {

private static final Logger LOG = Logger.getLogger(BuildVuServlet.class.getName());

protected void convert(final Individual individual, final Map<String, String[]> parameterMap, final String fileName,
final String inputDirectory, final String outputDirectory,
final String fileNameWithoutExt, final String ext) {
void convert(final Individual individual, final Map<String, String[]> parameterMap, final String fileName,
final String inputDirectory, final String outputDirectory,
final String fileNameWithoutExt, final String ext, final String contextURL) {

final String[] settings = parameterMap.get("settings");
final String[] conversionParams = settings != null ? getConversionParams(settings[0]) : null;
Expand Down Expand Up @@ -89,13 +89,12 @@ protected void convert(final Individual individual, final Map<String, String[]>
final PDFtoHTML5Converter html = new PDFtoHTML5Converter(inFile, outDir, options, new IDRViewerOptions());
html.convert();


ZipHelper.zipFolder(outputDirectory + "/" + fileNameWithoutExt, outputDirectory + "/" + fileNameWithoutExt + ".zip");

final String outputDir = individual.uuid + "/" + fileNameWithoutExt;

individual.setValue("previewPath", "output/" + outputDir + "/index.html");
individual.setValue("downloadPath", "output/" + outputDir + ".zip");
individual.setValue("previewPath", contextURL + "/output/" + outputDir + "/index.html");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we change these to previewUrl and downloadUrl? Seeing as we're breaking backwards compatibility anyway, now would be the time to do it. Any thoughts @RFoley?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I think that would be a good idea, although we'd obviously have to update all the clients again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea, would make more sense now.

Could even just drop 'path' and have 'preview' & 'download'.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference would be to include Url as it is more descriptive

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point - @patricksheppard-IDR would you like to update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will have to work on it tomorrow as it is getting late, but I can update that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have updated to url

individual.setValue("downloadPath", contextURL + "/output/" + outputDir + ".zip");

individual.state = "processed";

Expand All @@ -122,9 +121,11 @@ private void setErrorCode(final Individual individual, final int errorCode) {

/**
* Converts an office file to PDF
*
* @param fileName Name of the office file to convert
* @param directory Directory where the office file exists
* @return 0 if success, 1 if libreoffice timed out, 2 if process error occurs
* @return 0 if success, 1 if libreoffice timed out, 2 if process error
* occurs
*/
private static int convertToPDF(final String fileName, final String directory) {
final ProcessBuilder pb = new ProcessBuilder("soffice", "--headless", "--convert-to", "pdf", fileName);
Expand Down