data-miner-manager-tester/src/main/java/org/gcube/portlets/user/dataminermanagertester/server/is/InformationSystemUtils.java

56 lines
1.5 KiB
Java
Raw Normal View History

2020-06-11 12:25:52 +02:00
package org.gcube.portlets.user.dataminermanagertester.server.is;
import java.util.ArrayList;
2023-01-18 14:07:08 +01:00
import java.util.List;
2020-06-11 12:25:52 +02:00
import org.gcube.common.resources.gcore.ServiceEndpoint;
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.gcube.resources.discovery.icclient.ICFactory;
2023-01-18 14:07:08 +01:00
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
2020-06-11 12:25:52 +02:00
/**
*
* @author Giancarlo Panichi
*
*
*/
public class InformationSystemUtils {
private static Logger logger = LoggerFactory
.getLogger(InformationSystemUtils.class);
public static List<String> retrieveServiceAddress(String category,
String name, String scope) throws Exception {
2023-01-18 14:07:08 +01:00
try {
2020-06-11 12:25:52 +02:00
if (scope == null || scope.length() == 0)
return new ArrayList<String>();
ScopeProvider.instance.set(scope);
SimpleQuery query = ICFactory.queryFor(ServiceEndpoint.class);
query.addCondition(
"$resource/Profile/Category/text() eq '" + category + "'")
.addCondition(
"$resource/Profile/Name/text() eq '" + name + "'")
.setResult(
"$resource/Profile/AccessPoint/Interface/Endpoint/text()");
DiscoveryClient<String> client = ICFactory.client();
List<String> addresses = client.submit(query);
return addresses;
2023-01-18 14:07:08 +01:00
} catch (Throwable e) {
2020-06-11 12:25:52 +02:00
logger.error("Error in discovery DataMiner Service Endpoint in scope: "
+ scope);
logger.error("Error: " + e.getLocalizedMessage());
2023-01-18 14:07:08 +01:00
e.printStackTrace();
2020-06-11 12:25:52 +02:00
throw e;
2023-01-18 14:07:08 +01:00
}
}
2020-06-11 12:25:52 +02:00
2023-01-18 14:07:08 +01:00
}