Added IS SSD support
parent
563082a36f
commit
5cf3a0ec16
@ -1,4 +1,6 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
@ -0,0 +1,83 @@
|
||||
package org.gcube.portlets.admin.systemservicedefinition.is;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
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;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class InformationSystemUtils {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(InformationSystemUtils.class);
|
||||
|
||||
public static void retrieveSSD(String category, String scope, String token) throws Exception {
|
||||
try {
|
||||
logger.debug("Retrieve System Services Definition on IS");
|
||||
|
||||
if (scope == null || scope.isEmpty())
|
||||
throw new Exception("Invalid scope: " + scope);
|
||||
|
||||
if (token == null || token.isEmpty())
|
||||
throw new Exception("Invalid token: " + scope);
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
|
||||
//
|
||||
|
||||
SimpleQuery query = ICFactory.queryFor(ServiceEndpoint.class);
|
||||
query.addCondition("$resource/Profile/Category/text() eq '" + category + "'");
|
||||
DiscoveryClient<ServiceEndpoint> client = ICFactory.clientFor(ServiceEndpoint.class);
|
||||
|
||||
List<ServiceEndpoint> resources = client.submit(query);
|
||||
|
||||
logger.debug("Retrieved: " + resources);
|
||||
|
||||
/*
|
||||
* String serviceAddress = null; ArrayList<ServiceInfoData> serviceProperties =
|
||||
* new ArrayList<>();
|
||||
*
|
||||
* if (accessPointList != null && !accessPointList.isEmpty()) { for (int i = 0;
|
||||
* i < accessPointList.size(); i++) { AccessPoint accessPoint =
|
||||
* accessPointList.get(i); if (accessPoint != null) { if (i == 0) { if
|
||||
* (accessPoint.address() != null && !accessPoint.address().isEmpty()) { String
|
||||
* accessPointAddress = accessPoint.address(); int wpsWebProcessingServiceIndex
|
||||
* = accessPointAddress .indexOf(Constants.WPSWebProcessingService); if
|
||||
* (wpsWebProcessingServiceIndex > 0) { serviceAddress =
|
||||
* accessPointAddress.substring(0, wpsWebProcessingServiceIndex); } } }
|
||||
*
|
||||
* String categoryDescription; if (accessPoint.description() == null &&
|
||||
* accessPoint.description().isEmpty()) { categoryDescription =
|
||||
* Constants.DATA_MINER_DEFAULT_SERVICE_INFO_CATEGORY; } else {
|
||||
* categoryDescription = accessPoint.description(); }
|
||||
*
|
||||
* if (accessPoint.properties() != null && !accessPoint.propertyMap().isEmpty())
|
||||
* { for (String key : accessPoint.propertyMap().keySet()) { Property property =
|
||||
* accessPoint.propertyMap().get(key); if (property != null && property.name()
|
||||
* != null && !property.name().isEmpty()) { if (property.name().contains(":")) {
|
||||
* String[] propertyWithCategory = property.name().split(":"); if
|
||||
* (propertyWithCategory.length >= 2) { serviceProperties.add(new
|
||||
* ServiceInfoData(propertyWithCategory[1], property.value(),
|
||||
* propertyWithCategory[0])); } else { serviceProperties.add(new
|
||||
* ServiceInfoData(property.name(), property.value(), categoryDescription)); } }
|
||||
* else { serviceProperties.add(new ServiceInfoData(property.name(),
|
||||
* property.value(), categoryDescription)); } }
|
||||
*
|
||||
* } } } } } ServiceInfo serviceInfo = new ServiceInfo(serviceAddress,
|
||||
* serviceProperties);
|
||||
*
|
||||
* logger.debug("DataMiner Service Info: " + serviceInfo); return serviceInfo;
|
||||
*/
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in discovery System Services Endpoint in scope: " + scope);
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.gcube.portlets.admin.systemservicedefinition.shared;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
public static final boolean DEBUG_MODE = false;
|
||||
public static final boolean TEST_ENABLE = false;
|
||||
|
||||
public static final String DEFAULT_USER = "giancarlo.panichi";
|
||||
public static final String DEFAULT_SCOPE = "/gcube";
|
||||
public static final String DEFAULT_TOKEN = "";
|
||||
public static final String DEFAULT_ROLE = "OrganizationMember";
|
||||
|
||||
// Session
|
||||
public static final String CURR_GROUP_ID = "CURR_GROUP_ID";
|
||||
|
||||
// Social Resource
|
||||
public static final String SOCIAL_NETWORKING_NAME = "SocialNetworking";
|
||||
public static final String SOCIAL_NETWORKING_CATEGORY = "Portal";
|
||||
|
||||
// SSD Services Endpoint
|
||||
public static final String SYSTEM_SERVICE_CATEGORY = "SystemService";
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
package org.gcube.portlets.admin.systemservicedefinition;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.resources.gcore.GenericResource;
|
||||
import org.gcube.portlets.admin.systemservicedefinition.is.InformationSystemUtils;
|
||||
import org.gcube.portlets.admin.systemservicedefinition.shared.Constants;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ISTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ISTest.class);
|
||||
|
||||
@Test
|
||||
public void findAlgoInVRE() {
|
||||
|
||||
try {
|
||||
InformationSystemUtils.retrieveSSD(Constants.SYSTEM_SERVICE_CATEGORY,
|
||||
Constants.DEFAULT_SCOPE, Constants.DEFAULT_TOKEN);
|
||||
assertTrue(true);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
assertTrue("Error searching the resource!",false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
/FARM.gcubekey
|
||||
/d4science.research-infrastructures.eu.gcubekey
|
||||
/devNext.gcubekey
|
||||
/devsec.gcubekey
|
||||
/gCubeApps.gcubekey
|
||||
/gcube.gcubekey
|
||||
/howto.txt
|
||||
/log4j.properties
|
||||
/symm.key
|
Loading…
Reference in New Issue