From 1b3a33104a66f24ec0775814d243309fe729db43 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Mon, 2 Apr 2018 10:47:43 +0200 Subject: [PATCH] richer acl event + upgrade json lib --- .../docs/core/event/AclCreatedAsyncEvent.java | 24 +------ .../docs/core/event/AclDeletedAsyncEvent.java | 24 +------ .../com/sismics/docs/core/event/AclEvent.java | 62 +++++++++++++++++++ .../docs/rest/resource/AclResource.java | 4 ++ pom.xml | 2 +- 5 files changed, 69 insertions(+), 47 deletions(-) create mode 100644 docs-core/src/main/java/com/sismics/docs/core/event/AclEvent.java diff --git a/docs-core/src/main/java/com/sismics/docs/core/event/AclCreatedAsyncEvent.java b/docs-core/src/main/java/com/sismics/docs/core/event/AclCreatedAsyncEvent.java index 6e589039..2470a8ea 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/event/AclCreatedAsyncEvent.java +++ b/docs-core/src/main/java/com/sismics/docs/core/event/AclCreatedAsyncEvent.java @@ -1,31 +1,9 @@ package com.sismics.docs.core.event; -import com.google.common.base.MoreObjects; - /** * ACL created event. * * @author bgamard */ -public class AclCreatedAsyncEvent extends UserEvent { - /** - * Source ID. - */ - private String sourceId; - - public String getSourceId() { - return sourceId; - } - - public AclCreatedAsyncEvent setSourceId(String sourceId) { - this.sourceId = sourceId; - return this; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("sourceId", sourceId) - .toString(); - } +public class AclCreatedAsyncEvent extends AclEvent { } \ No newline at end of file diff --git a/docs-core/src/main/java/com/sismics/docs/core/event/AclDeletedAsyncEvent.java b/docs-core/src/main/java/com/sismics/docs/core/event/AclDeletedAsyncEvent.java index 4b5970ff..87ae3b4f 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/event/AclDeletedAsyncEvent.java +++ b/docs-core/src/main/java/com/sismics/docs/core/event/AclDeletedAsyncEvent.java @@ -1,31 +1,9 @@ package com.sismics.docs.core.event; -import com.google.common.base.MoreObjects; - /** * ACL deleted event. * * @author bgamard */ -public class AclDeletedAsyncEvent extends UserEvent { - /** - * Source ID. - */ - private String sourceId; - - public String getSourceId() { - return sourceId; - } - - public AclDeletedAsyncEvent setSourceId(String sourceId) { - this.sourceId = sourceId; - return this; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("sourceId", sourceId) - .toString(); - } +public class AclDeletedAsyncEvent extends AclEvent { } \ No newline at end of file diff --git a/docs-core/src/main/java/com/sismics/docs/core/event/AclEvent.java b/docs-core/src/main/java/com/sismics/docs/core/event/AclEvent.java new file mode 100644 index 00000000..768fea4a --- /dev/null +++ b/docs-core/src/main/java/com/sismics/docs/core/event/AclEvent.java @@ -0,0 +1,62 @@ +package com.sismics.docs.core.event; + +import com.google.common.base.MoreObjects; +import com.sismics.docs.core.constant.PermType; + +/** + * ACL event. + * + * @author bgamard + */ +public abstract class AclEvent extends UserEvent { + /** + * Source ID. + */ + private String sourceId; + + /** + * Permission type. + */ + private PermType perm; + + /** + * Target ID. + */ + private String targetId; + + public String getSourceId() { + return sourceId; + } + + public AclEvent setSourceId(String sourceId) { + this.sourceId = sourceId; + return this; + } + + public PermType getPerm() { + return perm; + } + + public AclEvent setPerm(PermType permType) { + this.perm = permType; + return this; + } + + public String getTargetId() { + return targetId; + } + + public AclEvent setTargetId(String targetId) { + this.targetId = targetId; + return this; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("sourceId", sourceId) + .add("perm", perm) + .add("targetId", targetId) + .toString(); + } +} diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/AclResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/AclResource.java index b850ae3e..6e327553 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/AclResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/AclResource.java @@ -104,6 +104,8 @@ public class AclResource extends BaseResource { AclCreatedAsyncEvent event = new AclCreatedAsyncEvent(); event.setUserId(principal.getId()); event.setSourceId(sourceId); + event.setPerm(perm); + event.setTargetId(targetId); ThreadLocalContext.get().addAsyncEvent(event); // Returns the ACL @@ -181,6 +183,8 @@ public class AclResource extends BaseResource { AclDeletedAsyncEvent event = new AclDeletedAsyncEvent(); event.setUserId(principal.getId()); event.setSourceId(sourceId); + event.setPerm(perm); + event.setTargetId(targetId); ThreadLocalContext.get().addAsyncEvent(event); // Always return OK diff --git a/pom.xml b/pom.xml index 87ede494..199d15ca 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 4.12 1.4.191 2.22.2 - 1.0.4 + 1.1.2 0.3m 5.5.0 4.2