added classes for catalogue notifications

This commit is contained in:
Massimiliano Assante 2022-05-06 17:15:48 +02:00
parent 27942f89bb
commit 9012b0bc58
5 changed files with 183 additions and 3 deletions

View File

@ -0,0 +1,164 @@
package org.gcube.social_networking.socialnetworking.model.beans.catalogue;
import java.net.URL;
import java.util.Arrays;
import javax.validation.constraints.NotNull;
import javax.ws.rs.DefaultValue;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* The CatalogueEvent super class
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class CatalogueEvent {
protected CatalogueEventType 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;
/**
* the item identifier or name
*/
@JsonProperty("itemId")
protected String itemId;
/**
* the text that you want to write in the notification (text/plain)
*/
@JsonProperty("notifyText")
protected String notifyText;
/**
* the URL to redirect when clicking on the notification
*/
@JsonProperty("itemURL")
protected URL itemURL;
/**
* optionl field, set to true if the idsToNotify are contexts, default is false
*/
@JsonProperty("idsAsGroup")
@DefaultValue("false")
protected boolean idsAsGroup = false;
public CatalogueEvent() {
}
/**
* for sending to users or groups
* @param type
* @param idsToNotify
* @param itemId
* @param notifyText
* @param itemURL
* @param idsAsGroup
*/
public CatalogueEvent(CatalogueEventType type, String[] idsToNotify, String itemId, String notifyText, URL itemURL,
boolean idsAsGroup) {
super();
this.type = type;
this.idsToNotify = idsToNotify;
this.itemId = itemId;
this.notifyText = notifyText;
this.itemURL = itemURL;
this.idsAsGroup = idsAsGroup;
}
/**
* for sending to users
* @param type
* @param idsToNotify
* @param itemId
* @param notifyText
* @param itemURL
*/
public CatalogueEvent(CatalogueEventType type, String[] idsToNotify, String itemId, String notifyText, URL itemURL) {
super();
this.type = type;
this.idsToNotify = idsToNotify;
this.itemId = itemId;
this.notifyText = notifyText;
this.itemURL = itemURL;
this.idsAsGroup = false;
}
public CatalogueEventType getType() {
return type;
}
public void setType(CatalogueEventType type) {
this.type = 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;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getNotifyText() {
return notifyText;
}
public void setNotifyText(String notifyText) {
this.notifyText = notifyText;
}
public URL getItemURL() {
return itemURL;
}
public void setItemURL(URL itemURL) {
this.itemURL = itemURL;
}
public boolean isIdsAsGroup() {
return idsAsGroup;
}
@Override
public String toString() {
return "CatalogueEvent [type=" + type + ", idsToNotify=" + Arrays.toString(idsToNotify) + ", itemId=" + itemId
+ ", notifyText=" + notifyText + ", itemURL=" + itemURL + ", idsAsGroup=" + idsAsGroup + "]";
}
}

View File

@ -0,0 +1,10 @@
package org.gcube.social_networking.socialnetworking.model.beans.catalogue;
public enum CatalogueEventType {
/**
* use to notify a user she got a workspace item new in some of her workspace shared folder
*/
ITEM_PUBLISHED;
}

View File

@ -61,7 +61,7 @@ public class AddedItemEvent extends WorkspaceEvent {
@Override
public String toString() {
return "AddedItemEvent [item=" + item + ", TYPE=" + TYPE + ", idsToNotify=" + Arrays.toString(idsToNotify)
return "PublishedItemEvent [item=" + item + ", TYPE=" + TYPE + ", idsToNotify=" + Arrays.toString(idsToNotify)
+ ", idsAsGroup=" + idsAsGroup + "]";
}

View File

@ -29,7 +29,13 @@ public class FileItemBean {
public FileItemBean() {
super();
}
/**
* @param id
* @param name
* @param title
* @param path
* @param parent
*/
public FileItemBean(String id, String name, String title, String path, FolderBean parent) {
super();
this.id = id;

View File

@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
/**
* The WorkspaceEvent super class
* The CatalogueEvent super class
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME,