diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 0000000..04cad8c
--- /dev/null
+++ b/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,2 @@
+disabled=06target
+eclipse.preferences.version=1
diff --git a/pom.xml b/pom.xml
index 8c32a48..d9f1f5d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,23 +30,26 @@
UTF-8
UTF-8
-
-
- org.gcube.core
- gcf
- [1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT)
- provided
-
+
+
+
+ org.gcube.distribution
+ maven-portal-bom
+ 1.3.0-SNAPSHOT
+ pom
+ import
+
+
+
+
org.gcube.applicationsupportlayer
aslcore
- [3.2.1-SNAPSHOT, 4.0.0-SNAPSHOT)
provided
org.gcube.portlets.user
home-library
- [4.3.0-SNAPSHOT, 5.0.0-SNAPSHOT)
provided
@@ -57,24 +60,21 @@
org.gcube.dvos
usermanagement-core
- [1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)
provided
org.gcube.portal
custom-portal-handler
- [1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)
provided
- com.liferay.portal
+ com.liferay.portal
portal-service
6.0.6
log4j
log4j
- 1.2.6
commons-net
@@ -90,7 +90,6 @@
javax.portlet
portlet-api
- 2.0
provided
diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java
index fb3d523..adca886 100644
--- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java
+++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java
@@ -46,6 +46,7 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa
*/
public ApplicationNewsManager(ASLSession session, String portletClassName) {
super(session, portletClassName);
+ GCUBEScope.getScope("");
}
/**
* {@inheritDoc}
diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java b/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java
index f81b92b..32725ca 100644
--- a/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java
+++ b/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java
@@ -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 appProfile = client.execute(query, scope.getInfrastructure());
+
+ String currScope = ScopeProvider.instance.get();
+ String scopeToQuery = PortalContext.getConfiguration().getInfrastructureName();
+ ScopeProvider.instance.set("/"+scopeToQuery);
+
+ DiscoveryClient client = client();
+ List 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 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 element in ");
- 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 element in ");
- 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 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 element in ");
_log.debug("Returning " + toReturn);
+ ScopeProvider.instance.set(currScope);
return toReturn;
}