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; /** * The WorkspaceEvent super class */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, 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; /** * optional, set to true if the idsToNotify are contexts, default is false */ @JsonProperty("idsAsGroup") 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; } }