From 517e4a45071d258fe60fc51c10d0279babdbbb38 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Sun, 12 Nov 2017 02:06:41 +0100 Subject: [PATCH] Closes #150: Display file name in audit log --- .../com/sismics/docs/core/model/jpa/File.java | 15 +++++---------- .../com/sismics/docs/core/model/jpa/Loggable.java | 4 ++-- .../com/sismics/docs/core/util/AuditLogUtil.java | 7 ++++--- .../src/partial/docs/directive.auditlog.html | 5 ++++- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/File.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/File.java index 36143622..243e0386 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/File.java +++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/File.java @@ -1,18 +1,12 @@ package com.sismics.docs.core.model.jpa; -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Lob; -import javax.persistence.Table; -import javax.persistence.Transient; - import com.google.common.base.MoreObjects; import com.google.common.base.Strings; import com.sismics.util.mime.MimeTypeUtil; +import javax.persistence.*; +import java.util.Date; + /** * File entity. * @@ -176,7 +170,8 @@ public class File implements Loggable { @Override public String toMessage() { - return documentId; + // Attached document ID and name concatenated + return documentId + name; } /** diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Loggable.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Loggable.java index 3b7e1837..554c77c8 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Loggable.java +++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Loggable.java @@ -14,12 +14,12 @@ public interface Loggable { * * @return Entity message */ - public String toMessage(); + String toMessage(); /** * Loggable are soft deletable. * * @return deleteDate */ - public Date getDeleteDate(); + Date getDeleteDate(); } diff --git a/docs-core/src/main/java/com/sismics/docs/core/util/AuditLogUtil.java b/docs-core/src/main/java/com/sismics/docs/core/util/AuditLogUtil.java index 259c11d7..d2d0913c 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/util/AuditLogUtil.java +++ b/docs-core/src/main/java/com/sismics/docs/core/util/AuditLogUtil.java @@ -1,13 +1,13 @@ package com.sismics.docs.core.util; -import javax.persistence.EntityManager; - import com.sismics.docs.core.constant.AuditLogType; import com.sismics.docs.core.dao.jpa.AuditLogDao; import com.sismics.docs.core.model.jpa.AuditLog; import com.sismics.docs.core.model.jpa.Loggable; import com.sismics.util.context.ThreadLocalContext; +import javax.persistence.EntityManager; + /** * Audit log utilities. * @@ -17,8 +17,9 @@ public class AuditLogUtil { /** * Create an audit log. * - * @param entity Entity + * @param loggable Loggable * @param type Audit log type + * @param userId User ID */ public static void create(Loggable loggable, AuditLogType type, String userId) { // Get the entity ID diff --git a/docs-web/src/main/webapp/src/partial/docs/directive.auditlog.html b/docs-web/src/main/webapp/src/partial/docs/directive.auditlog.html index 04bbcab8..554a9dc1 100644 --- a/docs-web/src/main/webapp/src/partial/docs/directive.auditlog.html +++ b/docs-web/src/main/webapp/src/partial/docs/directive.auditlog.html @@ -21,7 +21,10 @@ {{ log.message }} - {{ 'open' | translate }} + + {{ log.message | limitTo: 1000 : 36 }} + {{ 'open' | translate }} + {{ 'open' | translate }}