Removed all dependencies to gcf and ghn-client-runtime from pom.xml in order to drop old gCore stack (replaced by FeatherWeight stack).

Re-coded large parts of the component in order to use featherweight stack.
Changed to version 4.0.0.

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerCore@80835 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
nikolas.laskaris 2013-08-22 10:28:07 +00:00
parent 199ac6e994
commit 948345c7e6
11 changed files with 528 additions and 310 deletions

63
pom.xml
View File

@ -9,7 +9,7 @@
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
<name>Application Support Layer Core</name>
@ -32,11 +32,13 @@
<artifactId>accesslogger</artifactId>
<version>[1.2.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<!--
<dependency>
<groupId>org.gcube.informationsystem</groupId>
<artifactId>iscache</artifactId>
<version>[1.2.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
-->
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>voms-admin-stubs</artifactId>
@ -62,12 +64,19 @@
<artifactId>ghn-core-runtime</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<!--
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>gcf</artifactId>
<version>[1.6.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
-->
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>common-gcore-resources</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@ -90,11 +99,61 @@
<artifactId>backport-util-concurrent</artifactId>
<version>3.1</version>
</dependency>
<!--
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>ghn-client-runtime</artifactId>
<version>[2.1.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
</dependency>
-->
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>[1.0.1-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-gcore-stubs</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>common-gcore-resources</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>registry-publisher</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>
<version>1.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.gcube.dvos.soa3</groupId>
<artifactId>common-security</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.gcube.dvos.soa3</groupId>
<artifactId>gcube-security-utils</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.sf.kxml</groupId>
<artifactId>kxml2</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>

View File

@ -1,77 +1,86 @@
package org.gcube.application.framework.core.cache;
import java.util.HashMap;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.informationsystem.cache.ISCache;
import org.gcube.informationsystem.cache.ISCacheManager;
/**
* This class manages the running harvester threads.
*
* @author Valia Tsagkalidou (KNUA)
*
*/
public class RIsManager {
/**
* Defines the manager's instance
*/
private static RIsManager instance = null;
/**
* keeps the ISCache per scope
*/
protected HashMap<GCUBEScope, ISCache> isCaches;
/** Object logger. */
protected final GCUBELog logger = new GCUBELog(this);
/**
* Initializes RIsManager
*/
private RIsManager() {
isCaches = new HashMap<GCUBEScope, ISCache>();
}
/**
* Retrieves the singleton
* @return the only instance of RIsManager
*/
synchronized public static RIsManager getInstance() {
if (instance == null)
instance = new RIsManager();
return instance;
}
/**
* @param scope the GGUBEScope for which the RIs are requested
* @return the ISCache for this specific scope
*/
public synchronized ISCache getISCache(GCUBEScope scope)
{
ISCache isInfo = isCaches.get(scope);
if(isInfo == null)
{
// If the ISCache in not already created, then it creates a new instance and adds it to the HashMap
try {
ISCacheManager.addManager(scope);
isInfo = ISCacheManager.getManager(scope).getCache();
isCaches.put(scope, isInfo);
try {
Thread.sleep(5000);
} catch (InterruptedException e1) {
logger.error("", e1);
}
} catch (Exception e) {
logger.error("", e);
}
}
return isInfo;
}
}
//package org.gcube.application.framework.core.cache;
//
//import java.util.HashMap;
////import org.gcube.common.core.scope.GCUBEScope;
////import org.gcube.common.core.utils.logging.GCUBELog;
////import org.gcube.informationsystem.cache.ISCache;
////import org.gcube.informationsystem.cache.ISCacheManager;
//import net.sf.ehcache.Cache;
//import net.sf.ehcache.CacheManager;
//
//import org.gcube.resources.discovery.icclient.ICClient;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//
///**
// * This class manages the running harvester threads.
// *
// * @author Valia Tsagkalidou (KNUA)
// *
// */
//
//public class RIsManager {
//
//
// /**
// * Defines the manager's instance
// */
// private static RIsManager instance = null;
//
// /**
// * keeps the ISCache per scope
// */
//
//// protected HashMap<String, ISCache> isCaches;
//
// protected HashMap<String, Cache> caches; //(scope,iccache) pairs
//
// /** Object logger. */
//
// protected static final Logger logger = LoggerFactory.getLogger(RIsManager.class);
//
// /**
// * Initializes RIsManager
// */
// private RIsManager() {
// caches = new HashMap<String, Cache>();
// }
//
// /**
// * Retrieves the singleton
// * @return the only instance of RIsManager
// */
// synchronized public static RIsManager getInstance() {
// if (instance == null)
// instance = new RIsManager();
// return instance;
// }
//
// /**
// * @param scope the GGUBEScope for which the RIs are requested
// * @return the ISCache for this specific scope
// */
// public synchronized Cache getISCache(String scope)
// {
// Cache info = caches.get(scope);
// if(info == null)
// {
// // If the ISCache in not already created, then it creates a new instance and adds it to the HashMap
// try {
// CacheManager. //addManager(scope);
// info = CacheManager.getCacheManager(scope). .getManager(scope).getCache();
// caches.put(scope, info);
// try {
// Thread.sleep(5000);
// } catch (InterruptedException e1) {
// logger.error("", e1);
// }
// } catch (Exception e) {
// logger.error("", e);
// }
// }
// return info;
// }
//
//}

View File

@ -5,7 +5,7 @@ import java.util.HashMap;
import org.gcube.application.framework.core.security.PortalSecurityManager;
import org.gcube.application.framework.core.security.VOMSAdminManager;
import org.gcube.application.framework.core.util.UserCredential;
import org.gcube.common.core.scope.GCUBEScope;
//import org.gcube.common.core.scope.GCUBEScope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.gcube.vomanagement.vomsapi.VOMSAdmin;
@ -50,7 +50,7 @@ public class ApplicationCredentials {
*/
public ExtendedGSSCredential getCredential(String VREname)
{
PortalSecurityManager secMan = new PortalSecurityManager(GCUBEScope.getScope(VREname));
PortalSecurityManager secMan = new PortalSecurityManager(VREname);//GCUBEScope.getScope(VREname));
if(!secMan.isSecurityEnabled())
return null;
ExtendedGSSCredential cred = creds.get(VREname);

View File

@ -4,21 +4,28 @@ package org.gcube.application.framework.core.cache.factories;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.gcube.application.framework.core.genericresources.model.ISGenericResource;
import org.gcube.application.framework.core.util.CacheEntryConstants;
import org.gcube.application.framework.core.util.QueryString;
import org.gcube.application.framework.core.util.SessionConstants;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
import org.gcube.common.core.resources.GCUBEGenericResource;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.scope.GCUBEScope.Type;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.ScopeGroup;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.resources.discovery.icclient.ICClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import org.gcube.common.core.contexts.GHNContext;
//import org.gcube.common.core.informationsystem.client.AtomicCondition;
//import org.gcube.common.core.informationsystem.client.ISClient;
//import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
//import org.gcube.common.core.resources.GCUBEGenericResource;
//import org.gcube.common.core.scope.GCUBEScope;
//import org.gcube.common.core.scope.GCUBEScope.Type;
import static org.gcube.resources.discovery.icclient.ICFactory.*;
import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
/**
@ -27,7 +34,9 @@ import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
*/
public class GenericResourceCacheEntryFactory implements CacheEntryFactory {
static ISClient client = null;
// static ISClient client = null;
static DiscoveryClient<GenericResource> client = null;
/** The logger. */
private static final Logger logger = LoggerFactory.getLogger(GenericResourceCacheEntryFactory.class);
@ -40,16 +49,14 @@ public class GenericResourceCacheEntryFactory implements CacheEntryFactory {
if(client == null)
{
try {
client = GHNContext.getImplementation(ISClient.class);
// client = GHNContext.getImplementation(ISClient.class);
client = clientFor(GenericResource.class);
} catch (Exception e) {
logger.error("",e);
}
}
}
/**
* @param key a QueryString representing pairs of keys and values: needed keys are "vre" and one of "id" or "name"
* @return a list containing the Generic Resources that correspond to the query
@ -57,14 +64,17 @@ public class GenericResourceCacheEntryFactory implements CacheEntryFactory {
public List<ISGenericResource> createEntry(Object key) throws Exception {
QueryString querySt = (QueryString) key;
logger.info("query: " + querySt.toString());
GCUBEScope scope = GCUBEScope.getScope(querySt.get(CacheEntryConstants.vre));
GCUBEGenericResourceQuery query = client.getQuery(GCUBEGenericResourceQuery.class);
String scope = ScopeProvider.instance.get();
// GCUBEScope scope = GCUBEScope.getScope(querySt.get(CacheEntryConstants.vre));
SimpleQuery query = queryFor(GenericResource.class);
// GCUBEGenericResourceQuery query = client.getQuery(GCUBEGenericResourceQuery.class);
logger.info("In generic resources cache entry factory");
if(querySt.containsKey(CacheEntryConstants.id))
{ //Retrieving generic resources based on their ID
query.addAtomicConditions(new AtomicCondition("/ID", querySt.get(CacheEntryConstants.id)));
query.addCondition("$resource/ID eq '"+querySt.get(CacheEntryConstants.id)+"'");
// query.addAtomicConditions(new AtomicCondition("/ID", querySt.get(CacheEntryConstants.id)));
}
// else if(querySt.containsKey(CacheEntryConstants.name) && querySt.get(CacheEntryConstants.name).equals(SessionConstants.ScenarioSchemaInfo))
@ -74,41 +84,52 @@ public class GenericResourceCacheEntryFactory implements CacheEntryFactory {
// }
else if(querySt.containsKey(CacheEntryConstants.name))
{ //Retrieving generic resources based on their name
query.addAtomicConditions(new AtomicCondition("/Profile/Name", querySt.get(CacheEntryConstants.name)));
query.addCondition("$resource/Profile/Name eq '"+querySt.get(CacheEntryConstants.name)+"'");
// query.addAtomicConditions(new AtomicCondition("/Profile/Name", querySt.get(CacheEntryConstants.name)));
}
else if(querySt.containsKey(CacheEntryConstants.vreResource))
{
String secondaryType = new String();
if (scope.getType() == Type.VRE)
secondaryType = GCUBEGenericResource.SECONDARYTYPE_VRE;
else if (scope.getType() == Type.VO)
secondaryType = GCUBEGenericResource.SECONDARYTYPE_VO;
else
secondaryType = GCUBEGenericResource.SECONDARYTYPE_INFRASTRUCTURE;
query.addAtomicConditions(new AtomicCondition("/Profile/SecondaryType", secondaryType), new AtomicCondition("//Body/Scope", scope.toString()));
ScopeBean sb = new ScopeBean(ScopeProvider.instance.get());
if(sb.is(ScopeBean.Type.VRE))
secondaryType = ScopeBean.Type.VRE.name();
else if (sb.is(ScopeBean.Type.VO))
secondaryType = ScopeBean.Type.VO.name();
else
secondaryType = ScopeBean.Type.INFRASTRUCTURE.name();
query.addCondition("$resource/Profile/SecondaryType eq '"+secondaryType+"'")
.addCondition("$resource/Scopes eq '"+scope+"'");
// if (scope.getType() == Type.VRE)
// secondaryType = GCUBEGenericResource.SECONDARYTYPE_VRE;
// else if (scope.getType() == Type.VO)
// secondaryType = GCUBEGenericResource.SECONDARYTYPE_VO;
// else
// secondaryType = GCUBEGenericResource.SECONDARYTYPE_INFRASTRUCTURE;
// query.addAtomicConditions(new AtomicCondition("/Profile/SecondaryType", secondaryType), new AtomicCondition("//Body/Scope", scope.toString()));
}
try{
List<GCUBEGenericResource> result = client.execute(query, scope);
List<ISGenericResource> res = new ArrayList<ISGenericResource>();
List<GenericResource> results = client.submit(query);
if (querySt.containsKey(CacheEntryConstants.name) && querySt.get(CacheEntryConstants.name).equals(SessionConstants.ScenarioSchemaInfo)) {
logger.info("The number of generic Resources for ScenarioSchemaInfo returned is: " + result.size());
List<GCUBEGenericResource> newResult = new ArrayList<GCUBEGenericResource>();
for (GCUBEGenericResource resource : result) {
Map<String, GCUBEScope> scopes = resource.getScopes();
logger.info("Number of scopes for ScenarioSchemaInfo: " + scopes.values().size());
logger.info(scopes.values().toString());
if (scopes.containsValue(scope)) {
logger.info("The number of generic Resources for ScenarioSchemaInfo returned is: " + results.size());
List<GenericResource> newResult = new ArrayList<GenericResource>();
for (GenericResource resource : results) {
ScopeGroup<String> scopes = resource.scopes();
logger.info("Number of scopes for ScenarioSchemaInfo: " + scopes.size());
String [] sc = (String[]) scopes.toArray();
logger.info(sc.toString());
if(scopes.contains(scope))
newResult.add(resource);
}
}
if (newResult.size() > 1) {
GCUBEGenericResource voResource = null;
for (GCUBEGenericResource resource:newResult) {
if (resource.getScopes().size() == 1) {
GenericResource voResource = null;
for (GenericResource resource : newResult) {
if(resource.scopes().size()==1){
voResource = resource;
break;
}
@ -117,12 +138,13 @@ public class GenericResourceCacheEntryFactory implements CacheEntryFactory {
newResult.add(voResource);
}
logger.info("Number of genericResources for ScenarioSchemaInfo left after the pruning" + newResult.size());
result = newResult;
results = newResult;
}
logger.debug("size of results: " + result.size());
for(GCUBEGenericResource resource : result)
logger.debug("size of results: " + results.size());
List<ISGenericResource> res = new ArrayList<ISGenericResource>();
for(GenericResource resource : results)
{
ISGenericResource genResource = new ISGenericResource(resource.getID(), resource.getName(), resource.getDescription(), resource.getBody(), resource.getSecondaryType());
ISGenericResource genResource = new ISGenericResource(resource.id(), resource.profile().name(),resource.profile().description(),resource.profile().body().toString(),resource.profile().type());
res.add(genResource);
}
return res;
@ -130,6 +152,47 @@ public class GenericResourceCacheEntryFactory implements CacheEntryFactory {
logger.error("",e);
return null;
}
// List<GCUBEGenericResource> result = client.execute(query, scope);
// List<ISGenericResource> res = new ArrayList<ISGenericResource>();
// if (querySt.containsKey(CacheEntryConstants.name) && querySt.get(CacheEntryConstants.name).equals(SessionConstants.ScenarioSchemaInfo)) {
// logger.info("The number of generic Resources for ScenarioSchemaInfo returned is: " + result.size());
// List<GCUBEGenericResource> newResult = new ArrayList<GCUBEGenericResource>();
// for (GCUBEGenericResource resource : result) {
// Map<String, GCUBEScope> scopes = resource.getScopes();
// logger.info("Number of scopes for ScenarioSchemaInfo: " + scopes.values().size());
// logger.info(scopes.values().toString());
// if (scopes.containsValue(scope)) {
// newResult.add(resource);
// }
// }
//
//
// if (newResult.size() > 1) {
// GCUBEGenericResource voResource = null;
// for (GCUBEGenericResource resource:newResult) {
// if (resource.getScopes().size() == 1) {
// voResource = resource;
// break;
// }
// }
// newResult.clear();
// newResult.add(voResource);
// }
// logger.info("Number of genericResources for ScenarioSchemaInfo left after the pruning" + newResult.size());
// result = newResult;
// }
// logger.debug("size of results: " + result.size());
// for(GCUBEGenericResource resource : result)
// {
// ISGenericResource genResource = new ISGenericResource(resource.getID(), resource.getName(), resource.getDescription(), resource.getBody(), resource.getSecondaryType());
// res.add(genResource);
// }
// return res;
// }catch (Exception e) {
// logger.error("",e);
// return null;
// }
}
}

View File

@ -9,21 +9,27 @@ import org.gcube.application.framework.core.genericresources.model.ISGenericReso
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.util.CacheEntryConstants;
import org.gcube.application.framework.core.util.QueryString;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.soa3.connector.common.security.CredentialManager;
import org.kxml2.io.KXmlParser;
//import org.gcube.common.core.scope.GCUBEScope;
//import org.gcube.common.core.security.GCUBESecurityManagerImpl;
//import org.gcube.common.core.utils.logging.GCUBELog;
import org.kxml2.io.KXmlParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Valia Tsagkalidou (KNUA)
*
*/
public class PortalSecurityManager extends GCUBESecurityManagerImpl {
public class PortalSecurityManager {//extends GCUBESecurityManagerImpl {
/** Object logger. */
protected final GCUBELog logger = new GCUBELog(this);
// protected final GCUBELog logger = new GCUBELog(this);
private static Logger logger = LoggerFactory.getLogger(PortalSecurityManager.class);
public PortalSecurityManager(GCUBEScope scope) {
public PortalSecurityManager(String scope) {
super();
this.scope = scope;
}
@ -33,10 +39,9 @@ public class PortalSecurityManager extends GCUBESecurityManagerImpl {
this.scope = session.getScope();
}
GCUBEScope scope;
// GCUBEScope scope;
String scope;
@Override
public boolean isSecurityEnabled() {
QueryString query = new QueryString();
query.put(CacheEntryConstants.vreResource, "true");

View File

@ -3,17 +3,28 @@ package org.gcube.application.framework.core.security;
import java.rmi.Remote;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.scope.GCUBEScope.MalformedScopeExpressionException;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.soa3.connector.common.security.CredentialManager;
import org.gcube.soa3.connector.common.security.Credentials;
//import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
//import org.gcube.common.core.scope.GCUBEScope;
//import org.gcube.common.core.scope.GCUBEScope.MalformedScopeExpressionException;
//import org.gcube.common.core.security.GCUBESecurityManager;
import org.ietf.jgss.GSSCredential;
public class ServiceContextManager<PORTTYPE extends Remote> {
public static <PORTTYPE extends Remote> PORTTYPE applySecurity(PORTTYPE stub, ASLSession session) throws MalformedScopeExpressionException, Exception
/*
public static <PORTTYPE extends Remote> PORTTYPE applySecurity(PORTTYPE stub, ASLSession session) throws Exception
{
Credentials credentials = CredentialManager.instance.get();
secController =
GCUBESecurityManager secManager = new PortalSecurityManager(session);
if(secManager.isSecurityEnabled())
{
secManager.useCredentials(session.getCredential());
@ -22,9 +33,10 @@ public class ServiceContextManager<PORTTYPE extends Remote> {
}
public static <PORTTYPE extends Remote> PORTTYPE applySecurity(PORTTYPE stub, GCUBEScope scope, GSSCredential cred) throws MalformedScopeExpressionException, Exception
public static <PORTTYPE extends Remote> PORTTYPE applySecurity(PORTTYPE stub, String scope, GSSCredential cred) throws Exception
{
GCUBESecurityManager secManager = new PortalSecurityManager(scope);
if(secManager.isSecurityEnabled())
{
@ -33,5 +45,6 @@ public class ServiceContextManager<PORTTYPE extends Remote> {
return GCUBERemotePortTypeContext.getProxy(stub , scope, secManager);
}
*/
}

View File

@ -22,7 +22,7 @@ import org.gcube.application.framework.core.util.ASLGroupModel;
import org.gcube.application.framework.core.util.GenderType;
import org.gcube.application.framework.core.util.SessionConstants;
import org.gcube.application.framework.core.util.UserCredential;
import org.gcube.common.core.scope.GCUBEScope;
//import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.scope.api.ScopeProvider;
import org.gridforum.jgss.ExtendedGSSCredential;
@ -41,7 +41,8 @@ public class ASLSession{
private String externalSessionID;
private String username;
private ExtendedGSSCredential credential;
private GCUBEScope scope;
// private GCUBEScope scope; //to be deleted
private String scope;
private HashMap<String, Notifier> notifiers;
String scopeName;
private ASLGroupModel groupModel;
@ -93,10 +94,8 @@ public class ASLSession{
* @throws ParserConfigurationException
*/
public long getSessionTimeoutMillis() throws IOException, ParserConfigurationException {
if(sessionTimeout > 0){ //means that is already set to a value !
logger.info("Session timeout already known to be: " + sessionTimeout);
if(sessionTimeout > 0) //means that is already set to a value !
return sessionTimeout;
}
int timeoutSecs;
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = null;
@ -273,9 +272,9 @@ public class ASLSession{
/**
* @return the scope
*/
public GCUBEScope getScope() {
public String getScope() {
if (scope != null)
logger.debug("Returning scope with name --> " + scope.getName());
logger.debug("Returning scope with name --> " + scope);
return scope;
}
@ -287,7 +286,7 @@ public class ASLSession{
if (scope != null) {
logger.debug("Scope --> " + scope);
logger.debug("Username --> " + username);
return scope.toString();
return scope;
}
else
return null;
@ -299,16 +298,20 @@ public class ASLSession{
public void setScope(String scope) {
logger.info("The scope about to set is: " + scope);
lastUsedTime = System.currentTimeMillis();
/*
String[] split = scope.trim().substring(1).split("/",2);
//Uncomment this and comment the line bellow for devsec
//String vo = "/" + split[0].toLowerCase();
String vo = "/" + split[0];
if(split.length > 1)
vo += "/" + split[1];
logger.info("GCube scope returns: " + GCUBEScope.getScope(vo));
this.scope = GCUBEScope.getScope(vo);
String previousScopeName = scopeName;
scopeName = vo;
*/
// String currentScope = ScopeProvider.instance.get();
// logger.info("GCube scope returns: " + currentScope);
String previousScopeName = this.scopeName;
this.scope = scope;
this.scopeName = scope;
ScopeProvider.instance.set(scope);
if(new PortalSecurityManager(this.scope).isSecurityEnabled())
this.credential = UserCredential.getCredential(username, scope);

View File

@ -26,36 +26,46 @@ import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.application.framework.core.util.CacheEntryConstants;
import org.gcube.application.framework.core.util.QueryString;
import org.gcube.application.framework.core.util.SessionConstants;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.QueryParameter;
import org.gcube.common.core.informationsystem.client.XMLResult;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
import org.gcube.common.core.informationsystem.publisher.ISPublisherException;
import org.gcube.common.core.resources.GCUBEGenericResource;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.resources.gcore.Resources;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.informationsystem.publisher.ScopedPublisher;
import org.gcube.informationsystem.publisher.stubs.registry.faults.PublisherException;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.resources.discovery.icclient.ICClient;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.gcube.resources.discovery.icclient.ICFactory.*;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.Resource;
import org.gcube.common.resources.gcore.Resource.Type;
import org.gcube.common.resources.gcore.Resources;
/**
* @author Valia Tsaqgkalidou (NKUA)
* @author Valia Tsagkalidou (NKUA)
* @author Nikolas Laskaris (NKUA) -- refactored August 2013 to conform to FeatherWeight stack standards
*/
public class GenericResource implements GenericResourceInfoI {
public class ASLGenericResource implements GenericResourceInfoI {
/** The logger. */
private static final Logger logger = LoggerFactory.getLogger(GenericResource.class);
private static final Logger logger = LoggerFactory.getLogger(ASLGenericResource.class);
/**
* A static IS publisher in order to communicate with IS
* A static IS publisher in order to communicate with IS (FeatherWeight)
*/
protected static ISPublisher publisher = null;
protected static ISClient client = null;
// protected static ISPublisher publisher = null;
// protected static ISClient client = null;
protected static ScopedPublisher scopedPublisher = null;
protected static RegistryPublisher publisher = null;
protected static DiscoveryClient<GenericResource> client = null;
/**
* The D4Science session to be used
*/
@ -66,18 +76,21 @@ public class GenericResource implements GenericResourceInfoI {
* @param extrenalSessionID the external session id which is used for the D4ScienceSession (usually the session.getId() of the HttpSession or PortletSession)
* @param username the username of the user that called this constructor
*/
public GenericResource(String extrenalSessionID, String username)
public ASLGenericResource(String extrenalSessionID, String username)
{
session = SessionManager.getInstance().getASLSession(extrenalSessionID, username);
try {
publisher = GHNContext.getImplementation(ISPublisher.class);
ScopeProvider.instance.set(session.getScope());
scopedPublisher = RegistryPublisherFactory.scopedPublisher();
publisher = RegistryPublisherFactory.create();
} catch (Exception e) {
logger.error("Exception:", e);
}
if(client == null)
{
try {
client = GHNContext.getImplementation(ISClient.class);
client = clientFor(GenericResource.class); //GHNContext.getImplementation(ISClient.class);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
@ -92,18 +105,20 @@ public class GenericResource implements GenericResourceInfoI {
* Constructs a GenericReosurce object
* @param session the D4Science session to be used for retrieving information needed
*/
public GenericResource(ASLSession session) {
public ASLGenericResource(ASLSession session) {
super();
this.session = session;
try {
publisher = GHNContext.getImplementation(ISPublisher.class);
ScopeProvider.instance.set(session.getScope());
scopedPublisher = RegistryPublisherFactory.scopedPublisher();
publisher = RegistryPublisherFactory.create();
} catch (Exception e) {
logger.error("Exception:", e);
}
if(client == null)
{
try {
client = GHNContext.getImplementation(ISClient.class);
client = clientFor(GenericResource.class);
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
@ -140,78 +155,65 @@ public class GenericResource implements GenericResourceInfoI {
* @return the ID of the newly created resource
* @throws RemoteException when an error has occurred while communicating with IS
*/
public String createGenericResource(ISGenericResource genericResource)
throws RemoteException {
public String createGenericResource(ISGenericResource genericResource) throws RemoteException {
try {
GCUBEGenericResource gCubeRes = GHNContext.getImplementation(GCUBEGenericResource.class);
gCubeRes.setID("");
gCubeRes.setName(genericResource.getName());
gCubeRes.setDescription(genericResource.getDescription());
gCubeRes.setBody(genericResource.getBody());
gCubeRes.setSecondaryType(genericResource.getSecondaryType());
gCubeRes.addScope(session.getScope());
String Gr = publisher.registerGCUBEResource(gCubeRes, session.getScope(), new PortalSecurityManager(session));
Document doc = parseXMLFileToDOM(Gr);
XPath xpath = XPathFactory.newInstance().newXPath();
try {
return (String) xpath.evaluate("/Resource/ID/text()", doc, XPathConstants.STRING);
} catch (XPathExpressionException e) {
logger.error("Exception:", e);
throw new RemoteException();
}
//maybe should add the ScopeProvider.instance.set(session.getScope()); here and not in the constructors.
GenericResource gCubeRes = Resources.unmarshal(GenericResource.class, ASLGenericResource.class.getClassLoader().getResourceAsStream("generic.xml"));
gCubeRes.profile().name(genericResource.getName());
gCubeRes.profile().description(genericResource.getDescription());
gCubeRes.profile().body().setTextContent(genericResource.getBody());
gCubeRes.profile().type(genericResource.getSecondaryType());
//maybe should change the visibility (into public) of addScope() within the Resource class of common-gcore-resources package in order to use it here.
List<String> scopes=new ArrayList<String>();
scopes.add(session.getScope());
Resource res = scopedPublisher.create(gCubeRes, scopes);
logger.trace("Created Generic Resource with id: "+res.id()+" on scope: "+scopes.toString());
return res.id();
} catch (Exception e) {
logger.error("Exception:", e);
throw new RemoteException();
}
}
/**
* Updates a generic resource based on it's ID
* @param genericResource the generic resource to be updated
* @throws RemoteException when an error has occurred while communicating with IS
*/
public void updateGenericResourceByID(ISGenericResource genericResource)
throws RemoteException {
public void updateGenericResourceByID(ISGenericResource genericResource) throws RemoteException {
try {
//GCUBEGenericResource gCubeRes = GHNContext.getImplementation(GCUBEGenericResource.class);
//maybe should add the ScopeProvider.instance.set(session.getScope()); here and not in the constructors.
logger.info("Updating generic resource by ID");
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/ID eq '"+genericResource.getId()+"'");
logger.info("In updateGenericResourceByID!");
GCUBEGenericResourceQuery query = client.getQuery(GCUBEGenericResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/ID", genericResource.getId()));
List<GCUBEGenericResource> result = client.execute(query, session.getScope());
List <GenericResource> result = client.submit(query);
if (result == null || result.size() == 0) {
logger.info("Error in updateGenericResourceByID: The generic resources list is null");
logger.info("Error during updateGenericResourceByID: Couldn't find the resource to update");
return;
}
GCUBEGenericResource gCubeRes = result.get(0);
// gCubeRes.setID(genericResource.getId());
gCubeRes.setName(genericResource.getName());
gCubeRes.setDescription(genericResource.getDescription());
gCubeRes.setBody(genericResource.getBody());
gCubeRes.setSecondaryType(genericResource.getSecondaryType());
// gCubeRes.addScope(session.getScope());
GenericResource gCubeRes = result.get(0);
gCubeRes.profile().name(genericResource.getName());
gCubeRes.profile().description(genericResource.getDescription());
gCubeRes.profile().body().setTextContent(genericResource.getBody());
gCubeRes.profile().type(genericResource.getSecondaryType());
try {
//SOS!!!! uncomment this and erase the two lines bellow
//publisher.updateGCUBEResource(gCubeRes, session.getScope(), new PortalSecurityManager(session));
String resultIS = publisher.registerGCUBEResource(gCubeRes, session.getScope(), new PortalSecurityManager(session));
logger.info ("ISPublisher returned: " + resultIS);
List<String> scopes = new ArrayList<String>();
for(String scope : gCubeRes.scopes().asCollection())
scopes.add(scope);
Resource res = scopedPublisher.update(gCubeRes, scopes);
// Resource res = publisher.update(gCubeRes); //alternative of the above, if we don't want to define a scope -- better use scopedPublisher
logger.info("Updated generic resource ! New ID: "+res.id());
}catch (Exception e) {
logger.error("Exception:", e);
logger.error("Exception during update of generic resource:", e);
}
List<ISGenericResource> genRes = new ArrayList<ISGenericResource>();
genRes.add(genericResource);
QueryString query1 = new QueryString();
@ -230,47 +232,27 @@ public class GenericResource implements GenericResourceInfoI {
else {
logger.info("The generic resource was not found");
}
} catch (Exception e) {
logger.error("Exception:", e);
throw new RemoteException();
}
}
/**
* @return a list containing pairs of (name, id) of the available generic resources
* @throws RemoteException when an error has occurred while communicating with IS
*/
public List<Pair> getAvailableGenericResourceNames() throws RemoteException {
//maybe should add the ScopeProvider.instance.set(session.getScope()); here and not in the constructors.
List<Pair> pairs = new ArrayList<Pair>();
String xquery = "for $query in collection(\"/db/Profiles/GenericResource\")//Document/Data/child::*[local-name()='Profile']/Resource return <Result>{$query/ID}{$query/Profile/Name}</Result>"; // order by $query/Profile/Name
GCUBEGenericQuery queryMan;
SimpleQuery queryMan = null;
try {
queryMan = client.getQuery(GCUBEGenericQuery.class);
queryMan.setExpression(xquery);
List<XMLResult> res = client.execute(queryMan, session.getScope());
String id, name;
for(XMLResult xml : res)
{
try
{
id = xml.evaluate("//ID/text()").get(0);
List<String> var = xml.evaluate("//Name/text()");
if(var.size() > 0)
name = var.get(0);
else
name = "";
logger.info(id + " " + name);
pairs.add(new Pair(name, id));
}
catch(Exception e)
{
}
}
queryMan = queryFor(GenericResource.class);
List <GenericResource> results = client.submit(queryMan);
for(GenericResource gr : results)
pairs.add(new Pair(gr.profile().name(), gr.id()));
return pairs;
} catch (Exception e) {
logger.error("Exception:", e);
@ -324,30 +306,36 @@ public class GenericResource implements GenericResourceInfoI {
* @param genericResource the generic resource to be removed
* @throws RemoteException when an error has occurred while communicating with IS
*/
public void removeGenericResource(ISGenericResource genericResource)
throws RemoteException {
public void removeGenericResource(ISGenericResource genericResource) throws RemoteException {
try {
publisher.removeGCUBEResource(genericResource.getId(), GCUBEGenericResource.TYPE, session.getScope(), new PortalSecurityManager(session));
QueryString query = new QueryString();
query.addParameter(CacheEntryConstants.id, genericResource.getId());
query.addParameter(CacheEntryConstants.vre, session.getOriginalScopeName());
if(CachesManager.getInstance().getGenericResourceCache().isElementInMemory(query) || CachesManager.getInstance().getGenericResourceCache().isElementOnDisk(query))
{
genericResource = ((List<ISGenericResource>)CachesManager.getInstance().getGenericResourceCache().get(query).getValue()).get(0);
//TODO
CachesManager.getInstance().getGenericResourceCache().get(query).setTimeToLive(0);
//maybe should add the ScopeProvider.instance.set(session.getScope()); here and not in the constructors.
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/ID eq '"+genericResource.getId()+"'");
List <GenericResource> result = client.submit(query);
if (result == null || result.size() == 0) {
logger.error("Couldn't find the resource to delete! Returning...");
return;
}
query.clear();
query.put(CacheEntryConstants.name, genericResource.getName());
query.addParameter(CacheEntryConstants.vre, session.getOriginalScopeName());
if(CachesManager.getInstance().getGenericResourceCache().isElementInMemory(query) || CachesManager.getInstance().getGenericResourceCache().isElementOnDisk(query))
{
GenericResource gCubeRes = result.get(0);
publisher = RegistryPublisherFactory.create();
Resource res = publisher.remove(gCubeRes);
logger.info("Removed generic resource from IS");
QueryString queryString = new QueryString();
queryString.addParameter(CacheEntryConstants.id, genericResource.getId());
queryString.addParameter(CacheEntryConstants.vre, session.getOriginalScopeName());
if(CachesManager.getInstance().getGenericResourceCache().isElementInMemory(queryString) || CachesManager.getInstance().getGenericResourceCache().isElementOnDisk(queryString)){
genericResource = ((List<ISGenericResource>)CachesManager.getInstance().getGenericResourceCache().get(queryString).getValue()).get(0);
//TODO
CachesManager.getInstance().getGenericResourceCache().get(query).setTimeToLive(0);
CachesManager.getInstance().getGenericResourceCache().get(queryString).setTimeToLive(0);
}
} catch (ISPublisherException e) {
queryString.clear();
queryString.put(CacheEntryConstants.name, genericResource.getName());
queryString.addParameter(CacheEntryConstants.vre, session.getOriginalScopeName());
if(CachesManager.getInstance().getGenericResourceCache().isElementInMemory(queryString) || CachesManager.getInstance().getGenericResourceCache().isElementOnDisk(queryString)){
//TODO
CachesManager.getInstance().getGenericResourceCache().get(queryString).setTimeToLive(0);
}
} catch (PublisherException e) {
logger.error("Exception:", e);
throw new RemoteException();
}
@ -384,10 +372,9 @@ public class GenericResource implements GenericResourceInfoI {
Vector<String[]> xslts = null;
List<String[]> result = null;
try {
result = retrieveGenericResourcesFromNameParts(xsltType, session.getScope());
result = ASLGenericResource.retrieveGenericResourcesFromNameParts(xsltType, session.getScope());
} catch (Exception e) {
logger.error("Exception:", e);
}
@ -453,27 +440,25 @@ public class GenericResource implements GenericResourceInfoI {
// }
}
private static List<String[]> retrieveGenericResourcesFromNameParts(String nameParts, GCUBEScope scope) throws Exception {
String condition = "contains($result/Profile/Name/string(), '" + nameParts + "')";
GCUBEGenericQuery query = client.getQuery("GCUBEResourceQuery");
query.addParameters(new QueryParameter("FILTER", condition),
new QueryParameter("TYPE", GCUBEGenericResource.TYPE),
new QueryParameter("RESULT", "<Result>{$result/ID}{$result/Profile/Name}</Result>"));
List<XMLResult> result = client.execute(query, scope);
List<String[]> ret = new LinkedList<String[]>();
if (result==null || result.size()==0)
throw new Exception("No generic resources were found.");
for(XMLResult r : result){
String[] nameAndID = { r.evaluate("//Name/text()").get(0), r.evaluate("//ID/text()").get(0) };
logger.info("Inside retrieveGenericResourcesFromNameParts name: " + nameAndID[0]);
logger.info("Inside retrieveGenericResourcesFromNameParts id: " + nameAndID[1]);
ret.add(nameAndID);
}
return ret;
private static List<String[]> retrieveGenericResourcesFromNameParts(String nameParts, String scope) throws Exception {
ScopeProvider.instance.set(scope);
System.out.println("retrieveGenericResourcesFromNameParts");
SimpleQuery query = queryFor(GenericResource.class);
//READ COMMENT BELOW !!!
query.addCondition("$resource/Profile/Name eq '"+nameParts+"'");
// on the above, we check if it is equal. what we want in order to have the previous functionality is to seaarch "like", not "eq"
List <GenericResource> queryResults = null;
queryResults = client.submit(query);
if (queryResults == null || queryResults.size() == 0) {
logger.error("Couldn't find the resource from name! Returning null");
return null;
}
List<String[]> results = new LinkedList<String[]>();
for(GenericResource gr : queryResults){
String[] nameAndID = { gr.profile().name() , gr.id() };
results.add(nameAndID);
}
return results;
}

View File

@ -22,6 +22,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.xalan.processor.TransformerFactoryImpl;
import org.gcube.application.framework.core.session.ASLSession;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -29,7 +30,6 @@ import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -0,0 +1,16 @@
package org.gcube.application.framework.core.util;
/**
* Valid service types
*
* @author Nikolas Laskaris
*
*/
public enum ServiceType {
/** simple web service */
SIMPLE,
/** factory service */
FACTORY,
/** statefull service - WS-resource */
STATEFULL
}

View File

@ -1,13 +1,22 @@
package org.gcube.application.framework.core.util;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.apache.axis.message.addressing.EndpointReference;
import org.gcube.application.framework.core.cache.RIsManager;
import org.apache.axis.types.URI.MalformedURIException;
//import org.gcube.application.framework.core.cache.RIsManager;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.informationsystem.cache.SrvType;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.common.resources.gcore.GCoreEndpoint.Profile.Endpoint;
import org.gcube.common.resources.gcore.ServiceInstance;
import org.gcube.common.scope.api.ScopeProvider;
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;
import static org.gcube.resources.discovery.icclient.ICFactory.*;
public class ServiceUtils {
@ -22,22 +31,78 @@ public class ServiceUtils {
* @param session
* @return the epr Address
*/
public static String getEprAddressOfService(String srvClass, String srvName, String srvType, ASLSession session) {
EndpointReference[] eprs;
try {
eprs = RIsManager.getInstance().getISCache(
session.getScope()).getEPRsFor(srvClass, srvName,
srvType);
Random rand = new Random();
int random = rand.nextInt(eprs.length);
return eprs[random].getAddress().toString();
} catch (Exception e) {
logger.error("Exception:", e);
// public static String getEprAddressOfServiceOLD(String srvClass, String srvName, String srvType, ASLSession session) {
// EndpointReference[] eprs;
// try {
//
// eprs = RIsManager.getInstance().getISCache(session.getScope()).getEPRsFor(srvClass, srvName,srvType);
//
// Random rand = new Random();
// int random = rand.nextInt(eprs.length);
//
// return eprs[random].getAddress().toString();
// } catch (Exception e) {
// logger.error("Exception:", e);
// }
// return null;
// }
/**
*
* @param srvClass The service class
* @param srvName The service name
* @param srvType The service type (SIMPLE, FACTORY or STATEFULL)
* @param session
* @return the epr Address
*/
/*synchronized ?*/
public static String getEprAddressOfService(String srvClass, String srvName, String srvType, ASLSession session){
return getEprAddressOfService(srvClass, srvName, srvType, session.getScope());
}
/*synchronized ?*/
public static String getEprAddressOfService(String srvClass, String srvName, String srvType, String scope){
ScopeProvider.instance.set(scope);
ArrayList <String> endpoints = new ArrayList<String>();
if (srvType == ServiceType.STATEFULL.name()) {
logger.debug("Performing query for stateful services with serviceClass="+srvClass+" serviceName="+srvName+" serviceType="+srvType);
DiscoveryClient<ServiceInstance> client = clientFor(ServiceInstance.class);
SimpleQuery query = queryFor(ServiceInstance.class);
query.addCondition("$resource/Profile/ServiceClass/text() eq '"+srvClass+"'")
.addCondition("$resource/Profile/ServiceName/text() eq '"+srvName+"'");
List<ServiceInstance> endpointsList = client.submit(query);
// logger.debug("Found " + endpointsList.size() + " endpoints.");
for (ServiceInstance endpoint : endpointsList) // normally it's only one endpoint per instance
endpoints.add(endpoint.endpoint().toString()); //maybe here we should use the endpoint.endpoint().toASCIIString()
}
return null;
else{ // srvType = SIMPLE or FACTORY
logger.debug("Performing SIMPLE or FACTORY query with serviceClass="+srvClass+" serviceName="+srvName+" serviceType="+srvType);
DiscoveryClient<GCoreEndpoint> client = clientFor(GCoreEndpoint.class);
SimpleQuery query = queryFor(GCoreEndpoint.class);
query.addCondition("$resource/Profile/ServiceClass/text() eq '"+srvClass+"'")
.addCondition("$resource/Profile/ServiceName/text() eq '"+srvName+"'");
List <GCoreEndpoint> endpointsList = client.submit(query);
// logger.debug("Found " + endpointsList.size() + " endpoints.");
if (srvType == ServiceType.FACTORY.name()){ //if it's FACTORY, add only URIs which contain 'Factory'
for (GCoreEndpoint endpoint : endpointsList) // normally it's only one endpoint per instance
for (Endpoint ep : endpoint.profile().endpoints())
if(ep.uri().toString().indexOf("Factory") != -1)
endpoints.add(ep.uri().toString()); //maybe here we should use the ep.uri().toASCIIString()
}
else{ //it's SIMPLE, so add all URIs
for (GCoreEndpoint endpoint : endpointsList) // normally it's only one endpoint per instance
for (Endpoint ep : endpoint.profile().endpoints())
endpoints.add(ep.uri().toString()); //maybe here we should use the ep.uri().toASCIIString()
}
// logger.debug("Number of Endpoint URIs: "+endpoints.size());
}
//now return just one from all, at random
Random rand = new Random();
int random = rand.nextInt(endpoints.size());
logger.debug("Returning Endpoint URI: "+endpoints.get(random));
return endpoints.get(random);
}
}