Merge branch 'master' of https://code-repo.d4science.org/gCubeSystem/resource-registry-management.git
This commit is contained in:
commit
5e85a182ac
|
@ -12,12 +12,14 @@ import java.util.Set;
|
||||||
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
||||||
import org.gcube.common.keycloak.KeycloakClient;
|
import org.gcube.common.keycloak.KeycloakClient;
|
||||||
import org.gcube.common.keycloak.KeycloakClientFactory;
|
import org.gcube.common.keycloak.KeycloakClientFactory;
|
||||||
|
import org.gcube.common.keycloak.model.AccessToken.Access;
|
||||||
import org.gcube.common.keycloak.model.ModelUtils;
|
import org.gcube.common.keycloak.model.ModelUtils;
|
||||||
import org.gcube.common.keycloak.model.TokenResponse;
|
import org.gcube.common.keycloak.model.TokenResponse;
|
||||||
import org.gcube.common.keycloak.model.AccessToken.Access;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
||||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
||||||
import org.gcube.informationsystem.types.reference.Type;
|
import org.gcube.informationsystem.types.reference.Type;
|
||||||
|
@ -25,6 +27,7 @@ import org.gcube.portlets.admin.resourcemanagement.shared.resource.CacheList;
|
||||||
import org.gcube.portlets.admin.resourcemanagement.shared.resource.UtilityResource;
|
import org.gcube.portlets.admin.resourcemanagement.shared.resource.UtilityResource;
|
||||||
import org.gcube.resourcemanagement.support.client.views.ResourceTypeDecorator;
|
import org.gcube.resourcemanagement.support.client.views.ResourceTypeDecorator;
|
||||||
import org.gcube.resourcemanagement.support.shared.types.datamodel.CompleteResourceProfile;
|
import org.gcube.resourcemanagement.support.shared.types.datamodel.CompleteResourceProfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author pieve mail:alessandro.pieve@isti.cnr.it
|
* @author pieve mail:alessandro.pieve@isti.cnr.it
|
||||||
|
@ -32,7 +35,7 @@ import org.gcube.resourcemanagement.support.shared.types.datamodel.CompleteResou
|
||||||
*/
|
*/
|
||||||
public class RegistryClientRequester {
|
public class RegistryClientRequester {
|
||||||
|
|
||||||
private static ResourceRegistryClient resourceRegistryClient = ResourceRegistryClientFactory.create();
|
private static ResourceRegistryClient resourceRegistryClient;
|
||||||
|
|
||||||
private static KeycloakClient client = KeycloakClientFactory.newInstance();
|
private static KeycloakClient client = KeycloakClientFactory.newInstance();
|
||||||
|
|
||||||
|
@ -40,21 +43,26 @@ public class RegistryClientRequester {
|
||||||
private static final String clientID = "resource-registry-portlet-expieve";
|
private static final String clientID = "resource-registry-portlet-expieve";
|
||||||
private static final String secret = "179bd3bc-5cc4-11ec-bf63-0242ac130001";
|
private static final String secret = "179bd3bc-5cc4-11ec-bf63-0242ac130001";
|
||||||
|
|
||||||
|
private static final String rootScope = "/gcube";
|
||||||
|
|
||||||
public static final Set<String> getAvailableContexts() throws Exception {
|
public static final Set<String> getAvailableContexts() throws Exception {
|
||||||
Set<String> contexts = new HashSet<String>();
|
Set<String> contextList = new HashSet<String>();
|
||||||
|
ScopeProvider.instance.set(rootScope);
|
||||||
|
AccessTokenProvider.instance.set(getTokenForContext(rootScope));
|
||||||
try {
|
try {
|
||||||
TokenResponse response = client.queryOIDCToken(new URL(endpoint), clientID, secret);
|
resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||||
Map<String, Access> resourceAccess = ModelUtils.getAccessTokenFrom(response).getResourceAccess();
|
|
||||||
for (String context : resourceAccess.keySet()) {
|
ContextCache contextCache = ContextCache.getInstance();
|
||||||
try {
|
|
||||||
ScopeBean scope = new ScopeBean(context.replaceAll("%2F", "/"));
|
contextList = contextCache.getContextFullNameToUUIDAssociation().keySet();
|
||||||
contexts.add(scope.toString());
|
|
||||||
}catch (IllegalArgumentException e) { }
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
|
}finally {
|
||||||
|
AccessTokenProvider.instance.reset();
|
||||||
|
ScopeProvider.instance.reset();
|
||||||
}
|
}
|
||||||
return contexts;
|
return contextList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTokenForContext(String context) {
|
private static String getTokenForContext(String context) {
|
||||||
|
@ -84,9 +92,14 @@ public class RegistryClientRequester {
|
||||||
ScopeProvider.instance.set(scope);
|
ScopeProvider.instance.set(scope);
|
||||||
AccessTokenProvider.instance.set(getTokenForContext(scope));
|
AccessTokenProvider.instance.set(getTokenForContext(scope));
|
||||||
try {
|
try {
|
||||||
|
resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||||
List<Type> types = resourceRegistryClient.getType(Resource.class, true);
|
List<Type> types = resourceRegistryClient.getType(Resource.class, true);
|
||||||
|
|
||||||
|
System.out.println("resource type returned "+types.size());
|
||||||
|
|
||||||
for (Type t : types) {
|
for (Type t : types) {
|
||||||
|
System.out.println("resource type found "+t.getName()+ " in "+scope);
|
||||||
|
|
||||||
String val = null;
|
String val = null;
|
||||||
if (t.getName().equals("EService"))
|
if (t.getName().equals("EService"))
|
||||||
val= "RunningInstance";
|
val= "RunningInstance";
|
||||||
|
@ -94,7 +107,15 @@ public class RegistryClientRequester {
|
||||||
val = "GenericResource";
|
val = "GenericResource";
|
||||||
if (t.getName().equals("HostingNode"))
|
if (t.getName().equals("HostingNode"))
|
||||||
val = "GHN";
|
val = "GHN";
|
||||||
retval.put(val, UtilityResource.getSubResourcesTreeQuery(resourceRegistryClient, t.getName()));
|
try {
|
||||||
|
if (val!=null) {
|
||||||
|
ArrayList<String> subtrees = UtilityResource.getSubResourcesTreeQuery(resourceRegistryClient, t.getName());
|
||||||
|
if (!subtrees.isEmpty())
|
||||||
|
retval.put(val, subtrees);
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -117,7 +138,7 @@ public class RegistryClientRequester {
|
||||||
AccessTokenProvider.instance.set(getTokenForContext(scope));
|
AccessTokenProvider.instance.set(getTokenForContext(scope));
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||||
List<String>resource=new ArrayList<String>();
|
List<String>resource=new ArrayList<String>();
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
|
@ -260,7 +260,7 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
|
||||||
ServerConsole.trace(LOG_PREFIX, "[GET-SCOPES] getting available scopes");
|
ServerConsole.trace(LOG_PREFIX, "[GET-SCOPES] getting available scopes");
|
||||||
Vector<String> retval = new Vector<String>();
|
Vector<String> retval = new Vector<String>();
|
||||||
try {
|
try {
|
||||||
//TODO
|
retval.addAll(RegistryClientRequester.getAvailableContexts());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
retval.add("/gcube");
|
retval.add("/gcube");
|
||||||
retval.add("/gcube/devsec");
|
retval.add("/gcube/devsec");
|
||||||
|
|
|
@ -130,7 +130,12 @@ public class UtilityResource {
|
||||||
identifiedFacet="SoftwareFacet";
|
identifiedFacet="SoftwareFacet";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return new ArrayList<>(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String query="SELECT DISTINCT("+field+") AS "+field+" "
|
String query="SELECT DISTINCT("+field+") AS "+field+" "
|
||||||
+ "FROM (TRAVERSE outE('IsIdentifiedBy'),inV('"+identifiedFacet+"') FROM "+entity+")";
|
+ "FROM (TRAVERSE outE('IsIdentifiedBy'),inV('"+identifiedFacet+"') FROM "+entity+")";
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<inherits name='com.google.gwt.user.User' />
|
<inherits name='com.google.gwt.user.User' />
|
||||||
|
|
||||||
<!-- To Comment out -->
|
<!-- To Comment out -->
|
||||||
<!-- <set-property name="user.agent" value="safari,gecko1_8" /> -->
|
<set-property name="user.agent" value="safari,gecko1_8" />
|
||||||
|
|
||||||
<!-- Other module inherits -->
|
<!-- Other module inherits -->
|
||||||
<inherits name='com.extjs.gxt.ui.GXT' />
|
<inherits name='com.extjs.gxt.ui.GXT' />
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
|
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
|
||||||
<portlet>
|
<portlet>
|
||||||
<portlet-name>resources-management</portlet-name>
|
<portlet-name>resources-management</portlet-name>
|
||||||
<display-name>Resources Management</display-name>
|
<display-name>Resource Registry Management</display-name>
|
||||||
<portlet-class>org.gcube.portlets.admin.resourcemanagement.server.portlet.ResourceManagementPortlet</portlet-class>
|
<portlet-class>org.gcube.portlets.admin.resourcemanagement.server.portlet.ResourceManagementPortlet</portlet-class>
|
||||||
<init-param>
|
<init-param>
|
||||||
<name>view-jsp</name>
|
<name>view-jsp</name>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
<mime-type>text/html</mime-type>
|
<mime-type>text/html</mime-type>
|
||||||
</supports>
|
</supports>
|
||||||
<portlet-info>
|
<portlet-info>
|
||||||
<title>Resources Management</title>
|
<title>Resource Registry Management</title>
|
||||||
<short-title>Resources Management</short-title>
|
<short-title>Resources Management</short-title>
|
||||||
<keywords>Resources Management</keywords>
|
<keywords>Resources Management</keywords>
|
||||||
</portlet-info>
|
</portlet-info>
|
||||||
|
|
|
@ -14,16 +14,6 @@
|
||||||
<src>ServiceMap_devsec.xml</src>
|
<src>ServiceMap_devsec.xml</src>
|
||||||
<scope>/gcube/devsec</scope>
|
<scope>/gcube/devsec</scope>
|
||||||
</vo>
|
</vo>
|
||||||
<vo>
|
|
||||||
<name>gcube/devNext</name>
|
|
||||||
<src>ServiceMap_devNext.xml</src>
|
|
||||||
<scope>/gcube/devNext</scope>
|
|
||||||
</vo>
|
|
||||||
<vo>
|
|
||||||
<name>gcube/preprod</name>
|
|
||||||
<src>ServiceMap_preprod.xml</src>
|
|
||||||
<scope>/gcube/preprod</scope>
|
|
||||||
</vo>
|
|
||||||
</vos>
|
</vos>
|
||||||
</infrastructure>
|
</infrastructure>
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ RUNNING_MODE = STANDALONE
|
||||||
DEFAULT_USER = massimiliano.assante
|
DEFAULT_USER = massimiliano.assante
|
||||||
|
|
||||||
# The scope that will be used as default
|
# The scope that will be used as default
|
||||||
DEFAULT_SCOPE =/gcube/devNext
|
DEFAULT_SCOPE =/gcube
|
||||||
# the target of update notification (if in singleton mode)
|
# the target of update notification (if in singleton mode)
|
||||||
# mails MUST be separated by ;
|
# mails MUST be separated by ;
|
||||||
USERMAIL_TO = m.assante@gmail.com
|
USERMAIL_TO = m.assante@gmail.com
|
||||||
|
|
Loading…
Reference in New Issue