support for catalogue notifications first test ok
This commit is contained in:
parent
cf37f90b4d
commit
7d63f420c8
|
@ -1,11 +1,13 @@
|
|||
package org.gcube.applicationsupportlayer.social;
|
||||
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.applicationsupportlayer.social.ex.UnsupportedNotificationException;
|
||||
import org.gcube.applicationsupportlayer.social.mailing.EmailPlugin;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
||||
|
@ -829,7 +831,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean notifyNewCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate) {
|
||||
SimpleDateFormat spf = new SimpleDateFormat("EEE dd MMMMM, yyyy");
|
||||
|
||||
|
@ -863,7 +865,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean notifyEditedCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate) {
|
||||
SimpleDateFormat spf = new SimpleDateFormat("EEE dd MMMMM, yyyy");
|
||||
|
||||
|
@ -896,7 +898,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean notifyDeletedCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate) {
|
||||
SimpleDateFormat spf = new SimpleDateFormat("EEE dd MMMMM, yyyy");
|
||||
|
||||
|
@ -929,7 +931,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean notifyTDMTabularResourceSharing(String userIdToNotify, String tabularResourceName, String encodedTabularResourceParams) throws Exception {
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
|
@ -949,7 +951,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean notifyTDMObjectSharing(String userIdToNotify, NotificationType type, String tdmObjectName, String encodedTabularResourceParams) throws Exception {
|
||||
if (! (type == NotificationType.TDM_RULE_SHARE || type == NotificationType.TDM_TEMPLATE_SHARE))
|
||||
throw new IllegalArgumentException("Type must be either TDM_RULE_SHARE or TDM_TEMPLATE_SHARE");
|
||||
|
@ -977,4 +979,27 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
|
||||
return saveNotification(not);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean notifyCatalogueEvent(NotificationType type, String userIdToNotify, String itemId, String notifyText, URL url) throws Exception {
|
||||
final String prefix = "CAT_";
|
||||
if (! type.toString().startsWith(prefix)) {
|
||||
throw new UnsupportedNotificationException("The type of notification is not belonging to the catalogue ones, must start with " + prefix);
|
||||
}
|
||||
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
type,
|
||||
userIdToNotify, //user no notify
|
||||
itemId, //the
|
||||
new Date(),
|
||||
url.toString(),
|
||||
notifyText,
|
||||
false,
|
||||
currUser.getUsername(),
|
||||
currUser.getFullname(),
|
||||
currUser.getUserAvatarId());
|
||||
|
||||
return saveNotification(not);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.applicationsupportlayer.social;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -148,33 +149,26 @@ public interface NotificationsManager {
|
|||
*/
|
||||
boolean notifyMessageReceived(String userIdToNotify, String messageUniqueIdentifier, String subject, String messageText, String ... otherRecipientsFullNames);
|
||||
/**
|
||||
*
|
||||
* use to notify a catalogue moderators someone submitted an item for consideration
|
||||
* @param type the notification type
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param eventTitle the title of the event
|
||||
* @param eventType the type of the event
|
||||
* @param startDate staring date
|
||||
* @param endingDate ending date
|
||||
* @param itemId the item unique identifier
|
||||
* @param notifyText the text of the notification
|
||||
* @param the resolver URL pointing to the item
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
*/
|
||||
boolean notifyCatalogueEvent(NotificationType type, String userIdToNotify, String itemId, String notifyText, URL url) throws Exception;
|
||||
|
||||
/**
|
||||
* @deprecated no longer supported
|
||||
*/
|
||||
boolean notifyNewCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate);
|
||||
/**
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param eventTitle the title of the event
|
||||
* @param eventType the type of the event
|
||||
* @param startDate staring date
|
||||
* @param endingDate ending date
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
* @deprecated no longer supported
|
||||
*/
|
||||
boolean notifyEditedCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate);
|
||||
/**
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param eventTitle the title of the event
|
||||
* @param eventType the type of the event
|
||||
* @param startDate staring date
|
||||
* @param endingDate ending date
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
* @deprecated no longer supported
|
||||
*/
|
||||
boolean notifyDeletedCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate);
|
||||
|
||||
|
@ -280,16 +274,12 @@ public interface NotificationsManager {
|
|||
* @return true if the notification is correctly delivered, false otherwise
|
||||
*/
|
||||
boolean notifyJobStatus(String userIdToNotify, RunningJob job);
|
||||
|
||||
/**
|
||||
* @deprecated no longer supported
|
||||
*/
|
||||
boolean notifyTDMTabularResourceSharing(String userIdToNotify, String tabularResourceName, String encodedTabularResourceParams) throws Exception;
|
||||
/**
|
||||
* use to notify a user he got a Tabular Data Resource shared
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param type type of the shared tdm object (TDM Rule or TDM Template at the moment)
|
||||
* @param tdmObjectName the name
|
||||
* @param encodedTabularResourceParams the parameters to be placed in the HTTP GET Request (must be encoded)
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
* @deprecated no longer supported
|
||||
*/
|
||||
boolean notifyTDMObjectSharing(String userIdToNotify, NotificationType type, String tdmObjectName, String encodedTabularResourceParams) throws Exception;
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.applicationsupportlayer.social.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class UnsupportedNotificationException extends Exception {
|
||||
public UnsupportedNotificationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -249,6 +249,12 @@ public class SocialMailingUtil {
|
|||
toReturn += " " + hashtag;
|
||||
}
|
||||
return toReturn;
|
||||
case CAT_ITEM_DELETE:
|
||||
case CAT_ITEM_PUBLISHED:
|
||||
case CAT_ITEM_REJECTED:
|
||||
case CAT_ITEM_SUBMITTED:
|
||||
case CAT_ITEM_UPDATED:
|
||||
return "[D4Science Catalogue] " + notification2Save.getSubjectid();
|
||||
case REQUEST_CONNECTION:
|
||||
return "Connection request";
|
||||
case JOB_COMPLETED_NOK:
|
||||
|
@ -306,6 +312,14 @@ public class SocialMailingUtil {
|
|||
case POST_ALERT:
|
||||
actionLink.append("\">").append("See this Post").append("</a>");
|
||||
break;
|
||||
case CAT_ITEM_DELETE:
|
||||
case CAT_ITEM_PUBLISHED:
|
||||
case CAT_ITEM_REJECTED:
|
||||
case CAT_ITEM_SUBMITTED:
|
||||
case CAT_ITEM_UPDATED:
|
||||
StringBuilder myLink = new StringBuilder("<br/><br/><a style=\"color:#3B5998; text-decoration:none\" target=\"_blank\" href=\"");
|
||||
myLink.append(notification2Save.getUri()).append("\">").append(" See this on Catalogue").append("</a>");
|
||||
return myLink.toString();
|
||||
case REQUEST_CONNECTION:
|
||||
actionLink.append("\">").append(" Go to Contacts Center").append("</a>");
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue