moved to FWS

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@81983 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-09-25 13:51:00 +00:00
parent d5341e41cf
commit cd13164bbe
4 changed files with 53 additions and 34 deletions

View File

@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1

19
pom.xml
View File

@ -30,23 +30,26 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties> </properties>
<dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.gcube.core</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>gcf</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>[1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> <version>1.3.0-SNAPSHOT</version>
<scope>provided</scope> <type>pom</type>
<scope>import</scope>
</dependency> </dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency> <dependency>
<groupId>org.gcube.applicationsupportlayer</groupId> <groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId> <artifactId>aslcore</artifactId>
<version>[3.2.1-SNAPSHOT, 4.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>home-library</artifactId> <artifactId>home-library</artifactId>
<version>[4.3.0-SNAPSHOT, 5.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -57,13 +60,11 @@
<dependency> <dependency>
<groupId>org.gcube.dvos</groupId> <groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId> <artifactId>usermanagement-core</artifactId>
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId> <artifactId>custom-portal-handler</artifactId>
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -74,7 +75,6 @@
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
<version>1.2.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-net</groupId> <groupId>commons-net</groupId>
@ -90,7 +90,6 @@
<dependency> <dependency>
<groupId>javax.portlet</groupId> <groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId> <artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -46,6 +46,7 @@ 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}

View File

@ -1,20 +1,30 @@
package org.gcube.applicationsupportlayer.social; package org.gcube.applicationsupportlayer.social;
import static org.gcube.resources.discovery.icclient.ICFactory.client;
import java.io.StringReader;
import java.util.List; import java.util.List;
import javax.xml.parsers.DocumentBuilder;
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.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.XMLResult;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBEClientLog; import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
import org.gcube.portal.databook.server.DatabookStore; import org.gcube.portal.databook.server.DatabookStore;
import org.gcube.portal.databook.shared.ApplicationProfile; import org.gcube.portal.databook.shared.ApplicationProfile;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;
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.w3c.dom.Node;
import org.xml.sax.InputSource;
/** /**
* *
* @author Massimiliano Assante, ISTI-CNR * @author Massimiliano Assante, ISTI-CNR
@ -93,57 +103,63 @@ public class SocialPortalBridge {
* @return the applicationProfile profile * @return the applicationProfile profile
*/ */
private ApplicationProfile getProfileFromInfrastrucure(String portletClassName) { private ApplicationProfile getProfileFromInfrastrucure(String portletClassName) {
GCUBEScope scope = aslSession.getScope(); ScopeBean scope = new ScopeBean(aslSession.getScope());
_log.debug("Trying to fetch applicationProfile profile from the infrastructure for " + portletClassName + " scope: " + scope); _log.debug("Trying to fetch applicationProfile profile from the infrastructure for " + portletClassName + " scope: " + scope);
try { try {
ApplicationProfile toReturn = new ApplicationProfile(); ApplicationProfile toReturn = new ApplicationProfile();
ISClient client = GHNContext.getImplementation(ISClient.class); Query q = new QueryBox("for $profile in collection('/db/Profiles/GenericResource')//Resource " +
GCUBEGenericQuery query = client.getQuery(GCUBEGenericQuery.class);
query.setExpression("for $profile in collection('/db/Profiles/GenericResource')//Resource " +
"where $profile/Profile/SecondaryType/string() eq 'ApplicationProfile' and $profile/Profile/Body/AppId/string() " + "where $profile/Profile/SecondaryType/string() eq 'ApplicationProfile' and $profile/Profile/Body/AppId/string() " +
" eq '" + portletClassName + "'" + " eq '" + portletClassName + "'" +
"return $profile"); "return $profile");
List<XMLResult> appProfile = client.execute(query, scope.getInfrastructure()); String currScope = ScopeProvider.instance.get();
String scopeToQuery = PortalContext.getConfiguration().getInfrastructureName();
ScopeProvider.instance.set("/"+scopeToQuery);
DiscoveryClient<String> client = client();
List<String> appProfile = client.submit(q);
if (appProfile == null || appProfile.size() == 0) if (appProfile == null || appProfile.size() == 0)
throw new ApplicationProfileNotFoundException("Your applicationProfile is not registered in the infrastructure"); throw new ApplicationProfileNotFoundException("Your applicationProfile is not registered in the infrastructure");
else { else {
XMLResult node = appProfile.get(0); String elem = appProfile.get(0);
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node node = docBuilder.parse(new InputSource(new StringReader(elem))).getDocumentElement();
XPathHelper helper = new XPathHelper(node);
List<String> currValue = null; List<String> currValue = null;
currValue = node.evaluate("/Resource/Profile/Name/text()"); currValue = helper.evaluate("/Resource/Profile/Name/text()");
if (currValue != null && currValue.size() > 0) { if (currValue != null && currValue.size() > 0) {
toReturn.setName(currValue.get(0)); toReturn.setName(currValue.get(0));
} }
else throw new ApplicationProfileNotFoundException("Your applicationProfile NAME was not found in the profile"); else throw new ApplicationProfileNotFoundException("Your applicationProfile NAME was not found in the profile");
currValue = node.evaluate("/Resource/Profile/Description/text()"); currValue = helper.evaluate("/Resource/Profile/Description/text()");
if (currValue != null && currValue.size() > 0) { if (currValue != null && currValue.size() > 0) {
toReturn.setDescription(currValue.get(0)); toReturn.setDescription(currValue.get(0));
} }
else _log.warn("No Description exists for " + toReturn.getName()); else _log.warn("No Description exists for " + toReturn.getName());
currValue = node.evaluate("/Resource/Profile/Body/AppId/text()"); currValue = helper.evaluate("/Resource/Profile/Body/AppId/text()");
if (currValue != null && currValue.size() > 0) { if (currValue != null && currValue.size() > 0) {
toReturn.setKey(currValue.get(0)); toReturn.setKey(currValue.get(0));
} }
else throw new ApplicationProfileNotFoundException("Your applicationProfile ID n was not found in the profile, consider adding <AppId> element in <Body>"); else throw new ApplicationProfileNotFoundException("Your applicationProfile ID n was not found in the profile, consider adding <AppId> element in <Body>");
currValue = node.evaluate("/Resource/Profile/Body/ThumbnailURL/text()"); currValue = helper.evaluate("/Resource/Profile/Body/ThumbnailURL/text()");
if (currValue != null && currValue.size() > 0) { if (currValue != null && currValue.size() > 0) {
toReturn.setImageUrl(currValue.get(0)); toReturn.setImageUrl(currValue.get(0));
} }
else throw new ApplicationProfileNotFoundException("Your applicationProfile Image Url was not found in the profile, consider adding <ThumbnailURL> element in <Body>"); else throw new ApplicationProfileNotFoundException("Your applicationProfile Image Url was not found in the profile, consider adding <ThumbnailURL> element in <Body>");
currValue = node.evaluate("/Resource/Profile/Body/EndPoint/Scope/text()"); currValue = helper.evaluate("/Resource/Profile/Body/EndPoint/Scope/text()");
if (currValue != null && currValue.size() > 0) { if (currValue != null && currValue.size() > 0) {
List<String> scopes = currValue; List<String> scopes = currValue;
boolean foundUrl = false; boolean foundUrl = false;
for (int i = 0; i < scopes.size(); i++) { for (int i = 0; i < scopes.size(); i++) {
if (currValue.get(i).trim().compareTo(scope.toString()) == 0) { if (currValue.get(i).trim().compareTo(scope.toString()) == 0) {
toReturn.setUrl(node.evaluate("/Resource/Profile/Body/EndPoint/URL/text()").get(i)); toReturn.setUrl(helper.evaluate("/Resource/Profile/Body/EndPoint/URL/text()").get(i));
toReturn.setScope(scope.toString()); toReturn.setScope(scope.toString());
foundUrl = true; foundUrl = true;
break; break;
@ -154,6 +170,7 @@ public class SocialPortalBridge {
} }
else throw new ApplicationProfileNotFoundException("Your applicationProfile EndPoint was not found in the profile, consider adding <EndPoint><Scope> element in <Body>"); else throw new ApplicationProfileNotFoundException("Your applicationProfile EndPoint was not found in the profile, consider adding <EndPoint><Scope> element in <Body>");
_log.debug("Returning " + toReturn); _log.debug("Returning " + toReturn);
ScopeProvider.instance.set(currScope);
return toReturn; return toReturn;
} }