diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java index 38e8785..084af68 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNewsManager.java @@ -12,6 +12,7 @@ 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.portal.databook.shared.Application; import org.gcube.portal.databook.shared.Feed; import org.gcube.portal.databook.shared.FeedType; @@ -54,7 +55,9 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa " eq '" + applicationClass.getName() + "'" + "return $profile"); - List appProfile = client.execute(query, aslSession.getScope().getInfrastructure()); + GCUBEScope scope = aslSession.getScope(); + + List appProfile = client.execute(query, scope.getInfrastructure()); if (appProfile == null || appProfile.size() == 0) throw new ApplicationProfileNotFoundException("Your application is not registered in the infrastructure"); else { @@ -83,6 +86,17 @@ public class ApplicationNewsManager extends SocialPortalBridge implements NewsMa toReturn.setImageUrl(currValue.get(0)); } else throw new ApplicationProfileNotFoundException("Your application Image Url was not found in the profile, consider adding element in "); + currValue = node.evaluate("/Resource/Profile/Body/EndPoint/Scope/text()"); + if (currValue != null && currValue.size() > 0) { + List scopes = currValue; + 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.setScope(scope.toString()); + } else + throw new ApplicationProfileNotFoundException("Your application EndPoint URL was not found in the profile, consider adding $scopeMyAppurl element in "); + } + else throw new ApplicationProfileNotFoundException("Your application EndPoint was not found in the profile, consider adding element in "); return toReturn; }