removed httpservlet request param, created bean for getting needed data

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@128671 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-05-18 22:13:50 +00:00
parent ed362867d0
commit d8e9cfb085
2 changed files with 79 additions and 13 deletions

View File

@ -5,15 +5,13 @@ import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.gcube.applicationsupportlayer.social.mailing.EmailPlugin;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
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;
import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext;
import org.gcube.portal.databook.shared.ApplicationProfile;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType;
@ -48,10 +46,11 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* 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
* @param site an instance of {@link SocialNetworkingSite} filled with the required data
*/
public ApplicationNotificationsManager(HttpServletRequest request, String scope, SocialNetworkingUser currUser) {
public ApplicationNotificationsManager(SocialNetworkingSite site, String scope, SocialNetworkingUser currUser) {
super(scope, currUser);
setContext(request);
setContext(site);
_log.warn("Asked for Simple Notification (without redirect to creator)");
}
@ -64,11 +63,12 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
*
* @param scope the current scope
* @param currUser an instance of {@link SocialNetworkingUser} filled with the required user data
* @param site an instance of {@link SocialNetworkingSite} filled with the required data
* @param portletClassName your portlet class name will be used ad unique identifier for your applicationProfile
*/
public ApplicationNotificationsManager(HttpServletRequest request, String scope, SocialNetworkingUser currUser, String portletClassName) {
public ApplicationNotificationsManager(SocialNetworkingSite site, String scope, SocialNetworkingUser currUser, String portletClassName) {
super(scope, currUser, portletClassName);
setContext(request);
setContext(site);
}
/**
* set the current portal context (name, emal, url)
@ -76,12 +76,11 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* @throws SystemException
* @throws PortalException
*/
private void setContext(HttpServletRequest request) {
PortalContext context = PortalContext.getConfiguration();
siteLandingPagePath = context.getSiteLandingPagePath(request);
portalName = context.getGatewayName(request);
senderEmail = context.getSenderEmail(request);
portalURL = context.getGatewayURL(request);
private void setContext(SocialNetworkingSite site) {
siteLandingPagePath = site.getSiteLandingPagePath();
portalName = site.getName();
senderEmail = site.getSenderEmail();
portalURL = site.getSiteURL();
}
/**
* actually save the notification to the store

View File

@ -0,0 +1,67 @@
package org.gcube.applicationsupportlayer.social.shared;
import java.io.Serializable;
import javax.servlet.http.HttpServletRequest;
import org.gcube.common.portal.PortalContext;
@SuppressWarnings("serial")
public class SocialNetworkingSite implements Serializable{
private String siteName;
private String senderEmail;
private String siteURL;
private String siteLandingPagePath;
public SocialNetworkingSite(HttpServletRequest request) {
super();
PortalContext context = PortalContext.getConfiguration();
siteLandingPagePath = context.getSiteLandingPagePath(request);
siteName = context.getGatewayName(request);
senderEmail = context.getSenderEmail(request);
siteURL = context.getGatewayURL(request);
}
public SocialNetworkingSite(String siteName, String senderEmail,
String siteURL, String siteLandingPagePath) {
super();
this.siteName = siteName;
this.senderEmail = senderEmail;
this.siteURL = siteURL;
this.siteLandingPagePath = siteLandingPagePath;
}
public String getName() {
return siteName;
}
public void setName(String siteName) {
this.siteName = siteName;
}
public String getSenderEmail() {
return senderEmail;
}
public void setSenderEmail(String senderEmail) {
this.senderEmail = senderEmail;
}
public String getSiteURL() {
return siteURL;
}
public void setSiteURL(String siteURL) {
this.siteURL = siteURL;
}
public String getSiteLandingPagePath() {
return siteLandingPagePath;
}
public void setSiteLandingPagePath(String siteLandingPagePath) {
this.siteLandingPagePath = siteLandingPagePath;
}
}