From 66cd4abd8bb7e54b74e0f6300a52ee4be0b1330e Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Thu, 22 Feb 2018 11:42:41 +0100 Subject: [PATCH] #177: truncate data to fit the database --- .../src/main/java/com/sismics/docs/core/util/FileUtil.java | 3 ++- .../com/sismics/docs/rest/resource/DocumentResource.java | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs-core/src/main/java/com/sismics/docs/core/util/FileUtil.java b/docs-core/src/main/java/com/sismics/docs/core/util/FileUtil.java index df7b799b..8d6db868 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/util/FileUtil.java +++ b/docs-core/src/main/java/com/sismics/docs/core/util/FileUtil.java @@ -14,6 +14,7 @@ import com.sismics.util.ImageUtil; import com.sismics.util.Scalr; import com.sismics.util.context.ThreadLocalContext; import com.sismics.util.mime.MimeTypeUtil; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -228,7 +229,7 @@ public class FileUtil { File file = new File(); file.setOrder(order); file.setDocumentId(documentId); - file.setName(name); + file.setName(StringUtils.abbreviate(name, 200)); file.setMimeType(mimeType); file.setUserId(userId); String fileId = fileDao.create(file, userId); diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java index e7f08aa6..54194e92 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java @@ -31,6 +31,7 @@ import com.sismics.util.EmailUtil; import com.sismics.util.JsonUtil; import com.sismics.util.context.ThreadLocalContext; import com.sismics.util.mime.MimeType; +import org.apache.commons.lang.StringUtils; import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataParam; import org.joda.time.DateTime; @@ -824,10 +825,10 @@ public class DocumentResource extends BaseResource { if (mailContent.getSubject() == null) { document.setTitle("Imported email from EML file"); } else { - document.setTitle(mailContent.getSubject()); + document.setTitle(StringUtils.abbreviate(mailContent.getSubject(), 100)); } - document.setDescription(mailContent.getMessage()); - document.setSubject(mailContent.getSubject()); + document.setDescription(StringUtils.abbreviate(mailContent.getMessage(), 4000)); + document.setSubject(StringUtils.abbreviate(mailContent.getSubject(), 500)); document.setFormat("EML"); document.setSource("Email"); document.setLanguage("eng");