From 9f77b168aaf783892d57854a12b86e94475f7f70 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Tue, 3 May 2022 16:42:30 +0200 Subject: [PATCH] fixed bug --- .../model/beans/WorkspaceNotification.java | 15 ++++++++++----- .../beans/WorkspaceNotificationAddedItem.java | 5 ++--- .../beans/WorkspaceNotificationSharedFolder.java | 8 ++++++-- .../WorkspaceNotificationUnsharedFolder.java | 13 +++++++++---- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotification.java b/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotification.java index 90ce9a0..014366d 100644 --- a/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotification.java +++ b/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotification.java @@ -1,6 +1,9 @@ package org.gcube.social_networking.socialnetworking.model.beans; +import javax.validation.constraints.NotNull; + import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; @@ -16,11 +19,13 @@ include = As.PROPERTY, property = "type") @JsonSubTypes({ @JsonSubTypes.Type(value = WorkspaceNotificationAddedItem.class, name = "ITEM_NEW") }) public abstract class WorkspaceNotification { - WorkspaceNotificationType type; - - public WorkspaceNotificationType getType() { - return type; + protected final WorkspaceNotificationType TYPE; + + WorkspaceNotification(WorkspaceNotificationType TYPE) { + this.TYPE = TYPE; } - + public WorkspaceNotificationType TYPE() { + return TYPE; + } } diff --git a/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationAddedItem.java b/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationAddedItem.java index eb93af8..627a63b 100644 --- a/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationAddedItem.java +++ b/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationAddedItem.java @@ -25,16 +25,15 @@ public class WorkspaceNotificationAddedItem extends WorkspaceNotification { private WorkspaceFolderBean folder; public WorkspaceNotificationAddedItem() { - super(); + super(WorkspaceNotificationType.ITEM_NEW); // TODO Auto-generated constructor stub } public WorkspaceNotificationAddedItem(String userIdToNotify, WorkspaceFileItemBean item, WorkspaceFolderBean folder) { - super(); + super(WorkspaceNotificationType.ITEM_NEW); this.userIdToNotify = userIdToNotify; this.item = item; this.folder = folder; - this.type = WorkspaceNotificationType.ITEM_NEW; } public String getUserIdToNotify() { diff --git a/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationSharedFolder.java b/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationSharedFolder.java index 6abbc4a..05e6fda 100644 --- a/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationSharedFolder.java +++ b/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationSharedFolder.java @@ -21,12 +21,16 @@ public class WorkspaceNotificationSharedFolder extends WorkspaceNotification { @JsonProperty("folderItem") @NotNull(message="folderItem cannot be missing") private WorkspaceFolderBean folder; + + + public WorkspaceNotificationSharedFolder(WorkspaceNotificationType TYPE) { + super(WorkspaceNotificationType.FOLDER_SHARE); + } public WorkspaceNotificationSharedFolder(String userIdToNotify, WorkspaceFolderBean folder) { - super(); + super(WorkspaceNotificationType.FOLDER_SHARE); this.userIdToNotify = userIdToNotify; this.folder = folder; - this.type = WorkspaceNotificationType.FOLDER_SHARE; } public String getUserIdToNotify() { diff --git a/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationUnsharedFolder.java b/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationUnsharedFolder.java index 6ce35e6..b7899d6 100644 --- a/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationUnsharedFolder.java +++ b/src/main/java/org/gcube/social_networking/socialnetworking/model/beans/WorkspaceNotificationUnsharedFolder.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName; @JsonIgnoreProperties(ignoreUnknown=true) @JsonTypeName("UNSHARED_FOLDER") public class WorkspaceNotificationUnsharedFolder extends WorkspaceNotification { + /** * the username of the user you wish to notify @@ -24,25 +25,29 @@ public class WorkspaceNotificationUnsharedFolder extends WorkspaceNotification { @JsonProperty("unsharedFolderName") @NotNull(message="unsharedFolderName cannot be missing") private String unsharedFolderName; + public WorkspaceNotificationUnsharedFolder() { - super(); + super(WorkspaceNotificationType.FOLDER_UNSHARE); // TODO Auto-generated constructor stub } public WorkspaceNotificationUnsharedFolder(String userIdToNotify, String unsharedFolderId, String unsharedFolderName) { - super(); + super(WorkspaceNotificationType.FOLDER_UNSHARE); this.userIdToNotify = userIdToNotify; this.unsharedFolderId = unsharedFolderId; this.unsharedFolderName = unsharedFolderName; - this.type = WorkspaceNotificationType.FOLDER_UNSHARE; } + + + + @Override public String toString() { return "WorkspaceNotificationUnsharedFolder [userIdToNotify=" + userIdToNotify + ", unsharedFolderId=" - + unsharedFolderId + ", unsharedFolderName=" + unsharedFolderName + "]"; + + unsharedFolderId + ", unsharedFolderName=" + unsharedFolderName + ", Type=" + TYPE + "]"; } public String getUserIdToNotify() {