diff --git a/build.sh b/build.sh deleted file mode 100755 index cd55f467..00000000 --- a/build.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -docker build -t sismics/docs . diff --git a/docs-core/src/main/java/com/sismics/docs/core/util/PdfUtil.java b/docs-core/src/main/java/com/sismics/docs/core/util/PdfUtil.java index 86d22da2..f1268545 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/util/PdfUtil.java +++ b/docs-core/src/main/java/com/sismics/docs/core/util/PdfUtil.java @@ -64,7 +64,7 @@ public class PdfUtil { PDFTextStripper stripper = new PDFTextStripper(); pdfDocument = PDDocument.load(inputStream); content = stripper.getText(pdfDocument); - } catch (IOException e) { + } catch (Exception e) { log.error("Error while extracting text from the PDF", e); } finally { if (pdfDocument != null) { diff --git a/docs-core/src/main/java/com/sismics/util/mime/MimeType.java b/docs-core/src/main/java/com/sismics/util/mime/MimeType.java index b85517ef..b844aced 100644 --- a/docs-core/src/main/java/com/sismics/util/mime/MimeType.java +++ b/docs-core/src/main/java/com/sismics/util/mime/MimeType.java @@ -19,4 +19,6 @@ public class MimeType { public static final String OPEN_DOCUMENT_TEXT = "application/vnd.oasis.opendocument.text"; public static final String OFFICE_DOCUMENT = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + + public static final String DEFAULT = "application/octet-stream"; } diff --git a/docs-core/src/main/java/com/sismics/util/mime/MimeTypeUtil.java b/docs-core/src/main/java/com/sismics/util/mime/MimeTypeUtil.java index 2eb5f079..c784de77 100644 --- a/docs-core/src/main/java/com/sismics/util/mime/MimeTypeUtil.java +++ b/docs-core/src/main/java/com/sismics/util/mime/MimeTypeUtil.java @@ -60,7 +60,7 @@ public class MimeTypeUtil { return MimeType.APPLICATION_PDF; } - return null; + return MimeType.DEFAULT; } /** diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java index f27c87f7..8734fea7 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java @@ -41,6 +41,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.text.MessageFormat; @@ -129,10 +130,7 @@ public class FileResource extends BaseResource { } catch (IOException e) { throw new ServerException("ErrorGuessMime", "Error guessing mime type", e); } - if (mimeType == null) { - throw new ClientException("InvalidFileType", "File type not recognized"); - } - + // Validate quota if (user.getStorageCurrent() + fileData.length > user.getStorageQuota()) { throw new ClientException("QuotaReached", "Quota limit reached"); @@ -535,7 +533,11 @@ public class FileResource extends BaseResource { mimeType = MimeType.IMAGE_JPEG; // Thumbnails are JPEG decrypt = true; // Thumbnails are encrypted if (!Files.exists(storedFile)) { - storedFile = Paths.get(getClass().getResource("/image/file.png").getFile()); + try { + storedFile = Paths.get(getClass().getResource("/image/file.png").toURI()); + } catch (URISyntaxException e) { + // Ignore + } mimeType = MimeType.IMAGE_PNG; decrypt = false; } diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js index e13839f9..fa007e67 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js @@ -94,6 +94,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ // Upload files after edition promise.then(function(data) { + console.log('document created, adding file', $scope.newFiles); $scope.fileProgress = 0; // When all files upload are over, attach orphan files and move on @@ -133,6 +134,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ }; // Build the payload + console.log('sending file', key, $scope.newFiles[key], data); var file = $scope.newFiles[key]; var formData = new FormData(); formData.append('id', data.id); @@ -147,6 +149,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ contentType: false, processData: false, success: function(response) { + console.log('file uploaded successfully', formData); deferred.resolve(response); }, error: function(jqXHR) { @@ -192,11 +195,13 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ var then = function() { key++; if ($scope.newFiles[key]) { + console.log('sending new file'); sendFile(key).then(then); } else { $scope.fileIsUploading = false; $scope.fileProgress = 0; $rootScope.pageTitle = 'Sismics Docs'; + console.log('finished sending files, bye'); navigateNext(); } }; diff --git a/docs-web/src/main/webapp/src/partial/docs/document.edit.html b/docs-web/src/main/webapp/src/partial/docs/document.edit.html index 049c0d77..68fca1e4 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.edit.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.edit.html @@ -40,9 +40,7 @@