updated to the new HL ans FWS

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@82148 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-09-30 13:43:29 +00:00
parent 0096e39262
commit c9bd224764
6 changed files with 88 additions and 38 deletions

38
pom.xml
View File

@ -10,7 +10,7 @@
<groupId>org.gcube.applicationsupportlayer</groupId> <groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId> <artifactId>aslsocial</artifactId>
<version>0.7.0-SNAPSHOT</version> <version>0.7.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Social Portal ASL Extension</name> <name>Social Portal ASL Extension</name>
<description> <description>
@ -42,14 +42,21 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<version>[0.1.0-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.applicationsupportlayer</groupId> <groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId> <artifactId>aslcore</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId> <artifactId>home-library</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -67,6 +74,23 @@
<artifactId>custom-portal-handler</artifactId> <artifactId>custom-portal-handler</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- FWS DEPS -->
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>com.liferay.portal</groupId> <groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId> <artifactId>portal-service</artifactId>
@ -75,6 +99,14 @@
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-net</groupId> <groupId>commons-net</groupId>

View File

@ -1,38 +1,43 @@
package org.gcube.applicationsupportlayer.social; package org.gcube.applicationsupportlayer.social;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPClient;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.core.informationsystem.client.AtomicCondition; import org.gcube.common.portal.PortalContext;
import org.gcube.common.core.informationsystem.client.ISClient; import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.core.informationsystem.client.queries.GCUBERuntimeResourceQuery; import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.core.resources.GCUBERuntimeResource; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.portal.databook.shared.Feed; import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.FeedType; import org.gcube.portal.databook.shared.FeedType;
import org.gcube.portal.databook.shared.ImageType; import org.gcube.portal.databook.shared.ImageType;
import org.gcube.portal.databook.shared.PrivacyLevel; import org.gcube.portal.databook.shared.PrivacyLevel;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author Massimiliano Assante, ISTI-CNR * @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Dec 2012
* *
* use to share updates from within your applicationProfile, the update will be published in the Users News Feed belonging to the VRE your applicationProfile runs into * use to share updates from within your applicationProfile, the update will be published in the Users News Feed belonging to the VRE your applicationProfile runs into
*/ */
public class ApplicationNewsManager extends SocialPortalBridge implements NewsManager { public class ApplicationNewsManager extends SocialPortalBridge implements NewsManager {
static GCUBEClientLog _log = new GCUBEClientLog(ApplicationNewsManager.class); private static final Logger _log = LoggerFactory.getLogger(ApplicationNewsManager.class);
/** /**
* the FTP Server RuntimeResource coordinates * the FTP Server RuntimeResource coordinates
@ -46,7 +51,6 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
*/ */
public ApplicationNewsManager(ASLSession session, String portletClassName) { public ApplicationNewsManager(ASLSession session, String portletClassName) {
super(session, portletClassName); super(session, portletClassName);
GCUBEScope.getScope("");
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -132,11 +136,12 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
String httpBaseURL = ""; String httpBaseURL = "";
String fileName = UUID.randomUUID() + "." + imageExtension.toString().toLowerCase(); String fileName = UUID.randomUUID() + "." + imageExtension.toString().toLowerCase();
try { try {
GCUBERuntimeResource res = getConfigurationFromIS(); ServiceEndpoint res = getConfigurationFromIS();
ftpUrl = res.getAccessPoints().get(0).getEndpoint(); AccessPoint ac = res.profile().accessPoints().iterator().next();
httpBaseURL = res.getHostedOn(); ftpUrl = ac.address();
user = res.getAccessPoints().get(0).getUsername(); httpBaseURL = res.profile().runtime().hostedOn();
pwd = res.getAccessPoints().get(0).getPassword(); user = ac.username();
pwd = StringEncrypter.getEncrypter().decrypt(ac.password());
// Connect to the FTP server as anonymous // Connect to the FTP server as anonymous
client.connect(ftpUrl); client.connect(ftpUrl);
@ -173,13 +178,21 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
* @return the runtime resource of the FTP Server node * @return the runtime resource of the FTP Server node
* @throws Exception * @throws Exception
*/ */
private GCUBERuntimeResource getConfigurationFromIS() throws Exception { private ServiceEndpoint getConfigurationFromIS() throws Exception {
ISClient client = GHNContext.getImplementation(ISClient.class);
GHNContext ctx = GHNContext.getContext(); //set the scope
String scope = "/" + (String) ctx.getProperty(GHNContext.INFRASTRUCTURE_NAME, true); String currScope = ScopeProvider.instance.get();
GCUBERuntimeResourceQuery query = client.getQuery(GCUBERuntimeResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/Name", RUNTIME_RESOURCE_NAME)); ScopeProvider.instance.set("/"+PortalContext.getConfiguration().getInfrastructureName());
query.addAtomicConditions(new AtomicCondition("/Profile/Category", CATEGORY_NAME));
return client.execute(query, GCUBEScope.getScope(scope)).get(0); SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_RESOURCE_NAME +"'");
query.addCondition("$resource/Profile/Category/text() eq '"+ CATEGORY_NAME +"'");
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> conf = client.submit(query);
ScopeProvider.instance.set(currScope);
return conf.get(0);
} }
} }

View File

@ -7,21 +7,22 @@ import java.util.UUID;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.applicationsupportlayer.social.mailing.EmailPlugin; import org.gcube.applicationsupportlayer.social.mailing.EmailPlugin;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.portal.databook.shared.ApplicationProfile; import org.gcube.portal.databook.shared.ApplicationProfile;
import org.gcube.portal.databook.shared.Notification; import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType; import org.gcube.portal.databook.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType; import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.RunningJob; import org.gcube.portal.databook.shared.RunningJob;
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException; import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager; import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.UserModel; import org.gcube.vomanagement.usermanagement.model.UserModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
@ -30,7 +31,8 @@ import org.gcube.vomanagement.usermanagement.model.UserModel;
* use to notify users from within your application * use to notify users from within your application
*/ */
public class ApplicationNotificationsManager extends SocialPortalBridge implements NotificationsManager { public class ApplicationNotificationsManager extends SocialPortalBridge implements NotificationsManager {
static GCUBEClientLog _log = new GCUBEClientLog(ApplicationNotificationsManager.class); private static final Logger _log = LoggerFactory.getLogger(ApplicationNotificationsManager.class);
/** /**
* Use this constructor if you do not need notifications to point back to your applications * 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

View File

@ -5,8 +5,8 @@ import java.util.List;
import org.gcube.portal.databook.shared.ApplicationProfile; import org.gcube.portal.databook.shared.ApplicationProfile;
import org.gcube.portal.databook.shared.RunningJob; import org.gcube.portal.databook.shared.RunningJob;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
/** /**
* *
* @author Massimiliano Assante, ISTI-CNR * @author Massimiliano Assante, ISTI-CNR

View File

@ -10,7 +10,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.applicationsupportlayer.social.ex.ApplicationProfileNotFoundException; import org.gcube.applicationsupportlayer.social.ex.ApplicationProfileNotFoundException;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.resources.gcore.utils.XPathHelper; import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
@ -23,18 +22,20 @@ import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox; import org.gcube.resources.discovery.client.queries.impl.QueryBox;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
/** /**
* *
* @author Massimiliano Assante, ISTI-CNR * @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Dec 2012
* *
* superclass for notifications, posting news and so on * superclass for notifications, posting news and so on
*/ */
public class SocialPortalBridge { public class SocialPortalBridge {
protected static GCUBEClientLog _log = new GCUBEClientLog(SocialPortalBridge.class); private static final Logger _log = LoggerFactory.getLogger(SocialPortalBridge.class);
protected ASLSession aslSession; protected ASLSession aslSession;
protected ApplicationProfile applicationProfile; protected ApplicationProfile applicationProfile;
//unique instance //unique instance

View File

@ -10,10 +10,11 @@ import javax.mail.Transport;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil; import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portal.databook.shared.Notification; import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationType; import org.gcube.portal.databook.shared.NotificationType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.liferay.portal.model.UserModel; import com.liferay.portal.model.UserModel;
import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil;
@ -25,7 +26,8 @@ import com.liferay.portal.util.PortalUtil;
* *
*/ */
public class EmailPlugin { public class EmailPlugin {
private static GCUBEClientLog _log = new GCUBEClientLog(EmailPlugin.class);
private static final Logger _log = LoggerFactory.getLogger(EmailPlugin.class);
private static String getHTMLEmail(Notification notification2Save, String userFirstName, String portalURL, String email) { private static String getHTMLEmail(Notification notification2Save, String userFirstName, String portalURL, String email) {