This commit is contained in:
Massimiliano Assante 2022-05-04 16:35:59 +02:00
parent 5e87b5acd7
commit fe48cac2c0
6 changed files with 244 additions and 72 deletions

View File

@ -9,35 +9,45 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeName("ITEM_NEW")
public class AddedItemEvent extends WorkspaceEvent {
/**
* the username of the user you wish to notify
*/
@JsonProperty("userIdToNotify")
@NotNull(message="recipient cannot be missing")
private String userIdToNotify;
private static final WorkspaceEventType TYPE = WorkspaceEventType.ITEM_NEW;
@JsonProperty("fileItem")
@NotNull(message="fileItem cannot be missing")
private FileItemBean item;
public AddedItemEvent() {
super(WorkspaceEventType.ITEM_NEW);
// TODO Auto-generated constructor stub
}
public AddedItemEvent(String userIdToNotify, FileItemBean item) {
super(WorkspaceEventType.ITEM_NEW);
this.userIdToNotify = userIdToNotify;
/**
*
* @param idsToNotify usernames or contexts
* @param idsAsGroup true if idsToNotify are groups (members of contexts)
* @param item
*/
public AddedItemEvent(String[] idsToNotify, boolean idsAsGroup, FileItemBean item) {
super(TYPE);
this.idsToNotify = idsToNotify;
this.idsAsGroup = idsAsGroup;
this.item = item;
}
public String getUserIdToNotify() {
return userIdToNotify;
/**
*
* @param idsToNotify usernames
* @param item
*/
public AddedItemEvent(String[] idsToNotify, FileItemBean item) {
super(TYPE);
this.idsToNotify = idsToNotify;
this.item = item;
}
public void setUserIdToNotify(String userIdToNotify) {
this.userIdToNotify = userIdToNotify;
}
public FileItemBean getItem() {
return item;
@ -47,10 +57,7 @@ public class AddedItemEvent extends WorkspaceEvent {
this.item = item;
}
@Override
public String toString() {
return "AddedItemEvent [userIdToNotify=" + userIdToNotify + ", item=" + item + "]";
}
}

View File

@ -0,0 +1,99 @@
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeName("FOLDER_RENAME")
public class RenamedFolderEvent extends WorkspaceEvent {
private static final WorkspaceEventType TYPE = WorkspaceEventType.FOLDER_RENAME;
@JsonProperty("previousName")
@NotNull(message="previousName cannot be missing")
private String previousName;
@JsonProperty("newName")
@NotNull(message="newName cannot be missing")
private String newName;
@JsonProperty("renamedFolderId")
@NotNull(message="renamedFolderId cannot be missing")
private String renamedFolderId;
public RenamedFolderEvent() {
super(TYPE);
}
/**
* @param idsToNotify usernames or contexts
* @param idsAsGroup true if idsToNotify are groups (members of contexts)
* @param previousName
* @param newName
* @param renamedFolderId
*/
public RenamedFolderEvent(String[] idsToNotify, boolean idsAsGroup, String previousName, String newName, String renamedFolderId) {
super(TYPE);
this.idsToNotify = idsToNotify;
this.idsAsGroup = idsAsGroup;
this.previousName = previousName;
this.newName = newName;
this.renamedFolderId = renamedFolderId;
}
/**
* @param idsToNotify usernames
* @param previousName
* @param newName
* @param renamedFolderId
*/
public RenamedFolderEvent(String[] idsToNotify, String previousName, String newName, String renamedFolderId) {
super(TYPE);
this.idsToNotify = idsToNotify;
this.previousName = previousName;
this.newName = newName;
this.renamedFolderId = renamedFolderId;
}
public String getPreviousName() {
return previousName;
}
public void setPreviousName(String previousName) {
this.previousName = previousName;
}
public String getNewName() {
return newName;
}
public void setNewName(String newName) {
this.newName = newName;
}
public String getRenamedFolderId() {
return renamedFolderId;
}
public void setRenamedFolderId(String renamedFolderId) {
this.renamedFolderId = renamedFolderId;
}
@Override
public String toString() {
return "RenamedFolderEvent [previousName=" + previousName + ", newName=" + newName + ", renamedFolderId="
+ renamedFolderId + "]";
}
}

View File

@ -1,5 +1,7 @@
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
import java.util.Arrays;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@ -10,36 +12,38 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeName("FOLDER_SHARE")
public class SharedFolderEvent extends WorkspaceEvent {
/**
* the username of the user you wish to notify
*/
@JsonProperty("userIdToNotify")
@NotNull(message="recipient cannot be missing")
private String userIdToNotify;
private static final WorkspaceEventType TYPE = WorkspaceEventType.FOLDER_SHARE;
@JsonProperty("folderItem")
@NotNull(message="folderItem cannot be missing")
private FolderBean folder;
public SharedFolderEvent() {
super(WorkspaceEventType.FOLDER_SHARE);
}
public SharedFolderEvent(String userIdToNotify, FolderBean folder) {
super(WorkspaceEventType.FOLDER_SHARE);
this.userIdToNotify = userIdToNotify;
/**
*
* @param idsToNotify usernames
* @param idsAsGroup true if idsToNotify are groups (members of contexts)
* @param FolderBean the folder
*/
public SharedFolderEvent(String[] idsToNotify, boolean idsAsGroup, String userIdToNotify, FolderBean folder) {
super(TYPE);
this.idsToNotify = idsToNotify;
this.idsAsGroup = idsAsGroup;
this.folder = folder;
}
/**
*
* @param idsToNotify usernames
* @param FolderBean the folder
*/
public SharedFolderEvent(String[] idsToNotify, String userIdToNotify, FolderBean folder) {
super(TYPE);
this.idsToNotify = idsToNotify;
this.folder = folder;
}
public String getUserIdToNotify() {
return userIdToNotify;
}
public void setUserIdToNotify(String userIdToNotify) {
this.userIdToNotify = userIdToNotify;
}
public FolderBean getFolder() {
return folder;
@ -48,9 +52,11 @@ public class SharedFolderEvent extends WorkspaceEvent {
public void setFolder(FolderBean folder) {
this.folder = folder;
}
@Override
public String toString() {
return "SharedFolderEvent [userIdToNotify=" + userIdToNotify + ", folder=" + folder + "]";
}
return "SharedFolderEvent [folder=" + folder + ", TYPE=" + TYPE + ", idsToNotify="
+ Arrays.toString(idsToNotify) + ", idsAsGroup=" + idsAsGroup + "]";
}
}

View File

@ -1,5 +1,7 @@
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
import java.util.Arrays;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@ -9,14 +11,8 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeName("FOLDER_UNSHARE")
public class UnsharedFolderEvent extends WorkspaceEvent {
/**
* the username of the user you wish to notify
*/
@JsonProperty("userIdToNotify")
@NotNull(message="recipient cannot be missing")
private String userIdToNotify;
private static final WorkspaceEventType TYPE = WorkspaceEventType.FOLDER_UNSHARE;
@JsonProperty("unsharedFolderId")
@NotNull(message="folderid cannot be missing")
@ -28,39 +24,43 @@ public class UnsharedFolderEvent extends WorkspaceEvent {
public UnsharedFolderEvent() {
super(WorkspaceEventType.FOLDER_UNSHARE);
// TODO Auto-generated constructor stub
super(TYPE);
}
public UnsharedFolderEvent(String userIdToNotify, String unsharedFolderId, String unsharedFolderName) {
super(WorkspaceEventType.FOLDER_UNSHARE);
this.userIdToNotify = userIdToNotify;
/**
*
* @param idsToNotify usernames or contexts
* @param idsAsGroup true if idsToNotify are groups (members of contexts)
* @param unsharedFolderId
* @param unsharedFolderName
*/
public UnsharedFolderEvent(String[] idsToNotify, boolean idsAsGroup, String unsharedFolderId, String unsharedFolderName) {
super(TYPE);
this.idsToNotify = idsToNotify;
this.idsAsGroup = idsAsGroup;
this.unsharedFolderId = unsharedFolderId;
this.unsharedFolderName = unsharedFolderName;
}
/**
*
* @param idsToNotify usernames
* @param unsharedFolderId
* @param unsharedFolderName
*/
public UnsharedFolderEvent(String[] idsToNotify, String unsharedFolderId, String unsharedFolderName) {
super(TYPE);
this.idsToNotify = idsToNotify;
this.unsharedFolderId = unsharedFolderId;
this.unsharedFolderName = unsharedFolderName;
}
@Override
public String toString() {
return "UnsharedFolderEvent [userIdToNotify=" + userIdToNotify + ", unsharedFolderId="
+ unsharedFolderId + ", unsharedFolderName=" + unsharedFolderName + ", Type=" + TYPE + "]";
}
public String getUserIdToNotify() {
return userIdToNotify;
}
public void setUserIdToNotify(String userIdToNotify) {
this.userIdToNotify = userIdToNotify;
}
public String getUnsharedFolderId() {
return unsharedFolderId;
}
public void setUnsharedFolderId(String unsharedFolderId) {
this.unsharedFolderId = unsharedFolderId;
}
@ -72,5 +72,15 @@ public class UnsharedFolderEvent extends WorkspaceEvent {
public void setUnsharedFolderName(String unsharedFolderName) {
this.unsharedFolderName = unsharedFolderName;
}
@Override
public String toString() {
return "UnsharedFolderEvent [unsharedFolderId=" + unsharedFolderId + ", unsharedFolderName="
+ unsharedFolderName + ", TYPE=" + TYPE + ", idsToNotify=" + Arrays.toString(idsToNotify)
+ ", idsAsGroup=" + idsAsGroup + "]";
}
}

View File

@ -1,6 +1,9 @@
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
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;
@ -13,16 +16,59 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
include = As.PROPERTY, property = "type") @JsonSubTypes({
@JsonSubTypes.Type(value = SharedFolderEvent.class, name = "FOLDER_SHARE"),
@JsonSubTypes.Type(value = UnsharedFolderEvent.class, name = "FOLDER_UNSHARE"),
@JsonSubTypes.Type(value = RenamedFolderEvent.class, name = "FOLDER_RENAME"),
@JsonSubTypes.Type(value = AddedItemEvent.class, name = "ITEM_NEW")
})
public abstract class WorkspaceEvent {
protected final WorkspaceEventType TYPE;
/**
* the username of the user you wish to notify
*/
@JsonProperty("idsToNotify")
@NotNull(message="recipients cannot be missing, use usernames or contexts")
protected String[] idsToNotify;
protected boolean idsAsGroup = false;
WorkspaceEvent(WorkspaceEventType TYPE) {
this.TYPE = TYPE;
}
/**
* @param tYPE
* @param idsToNotify usernames or contexts
* @param idsAsGroup true whether the idsToNotify have to be interpreted as groups and not usernames, false is default
*/
WorkspaceEvent(WorkspaceEventType tYPE, String[] idsToNotify, boolean idsAsGroup) {
super();
TYPE = tYPE;
this.idsToNotify = idsToNotify;
this.idsAsGroup = idsAsGroup;
}
public WorkspaceEventType getType() {
return TYPE;
}
public String[] getIdsToNotify() {
return idsToNotify;
}
public void setIdsToNotify(String[] idsToNotify) {
this.idsToNotify = idsToNotify;
}
/**
*
* @return true whether the idsToNotify have to be interpreted as groups and not usernames
*/
public boolean idsAsGroup() {
return idsAsGroup;
}
/**
*
* @param idsAsGroup set true whether the idsToNotify have to be interpreted as groups and not usernames, false otherwise
*/
public void setIdsAsGroup(boolean idsAsGroup) {
this.idsAsGroup = idsAsGroup;
}
}

View File

@ -13,7 +13,11 @@ public enum WorkspaceEventType {
/**
* use to notify a user he got a workspace folder Unshared
*/
FOLDER_UNSHARE(UnsharedFolderEvent.class);
FOLDER_UNSHARE(UnsharedFolderEvent.class),
/**
* use to notify a user he got a workspace folder renamed
*/
FOLDER_RENAME(RenamedFolderEvent.class);