#177: truncate data to fit the database

This commit is contained in:
Benjamin Gamard 2018-02-22 11:42:41 +01:00
parent ba4470f155
commit 66cd4abd8b
2 changed files with 6 additions and 4 deletions

View File

@ -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);

View File

@ -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");