diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java
index 136200d..0ed39d8 100644
--- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java
+++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java
@@ -14,6 +14,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.gcube.application.framework.core.session.ASLSession;
+import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.resources.gcore.ServiceEndpoint;
@@ -45,13 +46,23 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
private static String RUNTIME_RESOURCE_NAME = "SocialPortalStorage";
private static String CATEGORY_NAME = "FTPServer";
/**
- *
+ * deprecated
* @param aslSession the ASLSession instance
* @param portletClassName your portlet class name will be used ad unique identifier for your applicationProfile
*/
+ @Deprecated
public ApplicationNewsManager(ASLSession session, String portletClassName) {
super(session, portletClassName);
}
+ /**
+ *
+ * @param scope the current scope
+ * @param currUser an instance of {@link SocialNetworkingUser} filled with the required user data
+ * @param portletClassName your portlet class name will be used ad unique identifier for your applicationProfile
+ */
+ public ApplicationNewsManager(String scope, SocialNetworkingUser currUser, String portletClassName) {
+ super(scope, currUser, portletClassName);
+ }
/**
* {@inheritDoc}
*/
@@ -98,9 +109,7 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
//add the GET params if necessary
if (uriParams != null && uriParams.compareTo("") != 0)
uri += "?"+uriParams;
- //String scope = getScopeByOrganizationId(""+aslSession.getGroupId());
- String scope = aslSession.getScopeName();
- System.out.println("scope: " + aslSession.getScopeName());
+ String scope = currScope;
Feed toReturn = new Feed(
UUID.randomUUID().toString(),
FeedType.PUBLISH,
diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java
index 60ebacb..cb2ba42 100644
--- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java
+++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java
@@ -7,6 +7,7 @@ import java.util.UUID;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.applicationsupportlayer.social.mailing.EmailPlugin;
+import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
@@ -37,27 +38,58 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
private String portalName;
private String senderEmail;
/**
+ * deprecated method:please use ApplicationNotificationsManager(String scope, {@link SocialNetworkingUser} currUser, String portletClassName)
* Use this constructor if you do not need notifications to point back to your applications
- * @param aslSession the ASLSession instance
+ * @param ASLSession the ASLSession instance
*/
+ @Deprecated
public ApplicationNotificationsManager(ASLSession session) {
super(session);
- portalName = PortalContext.getPortalInstanceName();
+ portalName = PortalContext.getConfiguration().getGatewayName();
senderEmail = PortalContext.getConfiguration().getSenderEmail();
_log.warn("Asked for Simple Notification (without redirect to creator)");
}
/**
+ * deprecated method: please use ApplicationNotificationsManager(String scope, {@link SocialNetworkingUser} currUser, String portletClassName)
* Use this constructor if you do need notifications to point back to your applications,
* make sure you create your application profile on the infrastructure.
*
- * @see http://gcube.wiki.gcube-system.org/gcube/index.php/Social_Networking_Library#Create_Your_Application_Profile
+ * @see http://wiki.gcube-system.org/gcube/index.php/Social_Networking_Library#Create_Your_Application_Profile
*
- * @param aslSession the ASLSession instance
+ * @param ASLSession the ASLSession instance
* @param portletClassName your portlet class name will be used ad unique identifier for your applicationProfile
*/
+ @Deprecated
public ApplicationNotificationsManager(ASLSession session, String portletClassName) {
super(session, portletClassName);
- portalName = PortalContext.getPortalInstanceName();
+ portalName = PortalContext.getConfiguration().getGatewayName();
+ senderEmail = PortalContext.getConfiguration().getSenderEmail();
+ }
+ /**
+ * Use this constructor if you do not need notifications to point back to your applications
+ * @param scope the current scope
+ * @param currUser an instance of {@link SocialNetworkingUser} filled with the required user data
+ */
+ public ApplicationNotificationsManager(String scope, SocialNetworkingUser currUser) {
+ super(scope, currUser);
+ portalName = PortalContext.getConfiguration().getGatewayName();
+ senderEmail = PortalContext.getConfiguration().getSenderEmail();
+ _log.warn("Asked for Simple Notification (without redirect to creator)");
+ }
+ /**
+ *
+ * Use this constructor if you do need notifications to point back to your applications,
+ * make sure you create your application profile on the infrastructure.
+ *
+ * @see http://wiki.gcube-system.org/gcube/index.php/Social_Networking_Library#Create_Your_Application_Profile
+ *
+ * @param scope the current scope
+ * @param currUser an instance of {@link SocialNetworkingUser} filled with the required user data
+ * @param portletClassName your portlet class name will be used ad unique identifier for your applicationProfile
+ */
+ public ApplicationNotificationsManager(String scope, SocialNetworkingUser currUser, String portletClassName) {
+ super(scope, currUser, portletClassName);
+ portalName = PortalContext.getConfiguration().getGatewayName();
senderEmail = PortalContext.getConfiguration().getSenderEmail();
}
/**
@@ -85,9 +117,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
else
_log.error("Error While trying to save Notification");
}
- if (channels.contains(NotificationChannelType.EMAIL))
- EmailPlugin.getInstance().sendNotification(notification2Save, aslSession.getGroupName(), portalName, senderEmail, hashtags);
-
+ if (channels.contains(NotificationChannelType.EMAIL))
+ EmailPlugin.getInstance().sendNotification(notification2Save, currGroupName, portalName, senderEmail, hashtags);
+
if (channels.isEmpty()) {
_log.info("Notification was not needed as "+ notification2Save.getUserid() +" decided not to be notified for " + notification2Save.getType());
result = true;
@@ -130,9 +162,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
"shared the workspace folder \""+ sharedFolderName +"\" with you",
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -151,9 +183,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+unsharedFolderId,
"unshared the workspace folder \""+ unsharedFolderName+"\"",
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -173,9 +205,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
"upgraded you to Administrator of the workspace folder \""+ sharedFolderName+"\"",
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -195,9 +227,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
"downgraded you from Administrator of the workspace folder \""+ sharedFolderName+"\"",
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -217,9 +249,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+renamedFolderId,
"renamed your shared folder \""+ previousName +"\" as \"" + newName+"\"",
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -242,9 +274,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
"added "+ user.getFullname() +" to your workspace shared folder \""+ sharedFolder.getName()+"\"",
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -273,9 +305,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
"added "+ addedUsersFullNames +" to your workspace shared folder \""+ sharedFolder.getName()+"\"",
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -296,9 +328,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
"unshared his shared folder \""+ sharedFolder.getName() + "\" from your workspace",
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -321,9 +353,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+item.getParent().getId(),
notifyText,
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -345,9 +377,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
notifyText,
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -369,9 +401,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
notifyText,
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -393,9 +425,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+item.getParent().getId(),
notifyText,
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -417,9 +449,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?itemid="+renamedItem.getParent().getId(),
notifyText,
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not);
}
@@ -451,9 +483,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
+ messageText +""
+ otherRecipientNames + attachmentsNotice,
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not, optionalParams);
}
@@ -462,9 +494,8 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
*/
@Override
public boolean notifyPost(String userIdToNotify, String feedid, String feedText, String ... hashtags) {
-
StringBuilder notificationText = new StringBuilder();
- notificationText.append("posted a news on ").append(aslSession.getGroupName()).append(":") // has done something
+ notificationText.append("posted a news on ").append(currGroupName).append(":") // has done something
.append("
").append(feedText).append(" ")
.append("
");
@@ -477,9 +508,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
getApplicationUrl()+"?oid="+feedid,
notificationText.toString(),
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId());
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId());
return saveNotification(not, hashtags);
}
/**
@@ -499,9 +530,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
+ "border-left: 3px solid #ccc; font-style: italic;\">\""
+ feedText +"\"",
false,
- aslSession.getUsername(),
- aslSession.getUserFullName(),
- aslSession.getUserAvatarId(),
+ currUser.getUsername(),
+ currUser.getFullname(),
+ currUser.getUserAvatarId(),
commentKey);
return saveNotification(not);
}
@@ -510,7 +541,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
*/
@Override
public boolean notifyCommentReply(String userIdToNotify, String feedid, String commentText, String feedOwnerFullName, String feedOwnerId, String commentKey) {
- String notificationText = (aslSession.getUsername().compareTo(feedOwnerId) == 0) ?
+ String notificationText = (currUser.getUsername().compareTo(feedOwnerId) == 0) ?
"also commented on his post: "
+ "