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:
parent
d5341e41cf
commit
cd13164bbe
|
@ -0,0 +1,2 @@
|
|||
disabled=06target
|
||||
eclipse.preferences.version=1
|
19
pom.xml
19
pom.xml
|
@ -30,23 +30,26 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>gcf</artifactId>
|
||||
<version>[1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslcore</artifactId>
|
||||
<version>[3.2.1-SNAPSHOT, 4.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<version>[4.3.0-SNAPSHOT, 5.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -57,13 +60,11 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -74,7 +75,6 @@
|
|||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
|
@ -90,7 +90,6 @@
|
|||
<dependency>
|
||||
<groupId>javax.portlet</groupId>
|
||||
<artifactId>portlet-api</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -46,6 +46,7 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
|
|||
*/
|
||||
public ApplicationNewsManager(ASLSession session, String portletClassName) {
|
||||
super(session, portletClassName);
|
||||
GCUBEScope.getScope("");
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
|
|
@ -1,20 +1,30 @@
|
|||
package org.gcube.applicationsupportlayer.social;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.client;
|
||||
|
||||
import java.io.StringReader;
|
||||
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.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.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.DatabookStore;
|
||||
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.impl.liferay.LiferayGroupManager;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.InputSource;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
|
@ -93,57 +103,63 @@ public class SocialPortalBridge {
|
|||
* @return the applicationProfile profile
|
||||
*/
|
||||
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);
|
||||
try {
|
||||
ApplicationProfile toReturn = new ApplicationProfile();
|
||||
ISClient client = GHNContext.getImplementation(ISClient.class);
|
||||
GCUBEGenericQuery query = client.getQuery(GCUBEGenericQuery.class);
|
||||
|
||||
|
||||
query.setExpression("for $profile in collection('/db/Profiles/GenericResource')//Resource " +
|
||||
Query q = new QueryBox("for $profile in collection('/db/Profiles/GenericResource')//Resource " +
|
||||
"where $profile/Profile/SecondaryType/string() eq 'ApplicationProfile' and $profile/Profile/Body/AppId/string() " +
|
||||
" eq '" + portletClassName + "'" +
|
||||
"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)
|
||||
throw new ApplicationProfileNotFoundException("Your applicationProfile is not registered in the infrastructure");
|
||||
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;
|
||||
currValue = node.evaluate("/Resource/Profile/Name/text()");
|
||||
currValue = helper.evaluate("/Resource/Profile/Name/text()");
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
toReturn.setName(currValue.get(0));
|
||||
}
|
||||
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) {
|
||||
toReturn.setDescription(currValue.get(0));
|
||||
}
|
||||
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) {
|
||||
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>");
|
||||
|
||||
currValue = node.evaluate("/Resource/Profile/Body/ThumbnailURL/text()");
|
||||
currValue = helper.evaluate("/Resource/Profile/Body/ThumbnailURL/text()");
|
||||
if (currValue != null && currValue.size() > 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>");
|
||||
currValue = node.evaluate("/Resource/Profile/Body/EndPoint/Scope/text()");
|
||||
currValue = helper.evaluate("/Resource/Profile/Body/EndPoint/Scope/text()");
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
List<String> scopes = currValue;
|
||||
boolean foundUrl = false;
|
||||
for (int i = 0; i < scopes.size(); i++) {
|
||||
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());
|
||||
foundUrl = true;
|
||||
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>");
|
||||
_log.debug("Returning " + toReturn);
|
||||
ScopeProvider.instance.set(currScope);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue