Fixed facet type used how identity

This commit is contained in:
Giancarlo Panichi 2022-12-21 14:03:22 +01:00
parent 4e27d2fc0b
commit ff5d706554
3 changed files with 53 additions and 52 deletions

View File

@ -195,7 +195,6 @@ public class RegistryClientRequester {
for (String k : list) { for (String k : list) {
sortedretval.put(k, retval.get(k)); sortedretval.put(k, retval.get(k));
} }
return sortedretval; return sortedretval;
} }
@ -203,12 +202,12 @@ public class RegistryClientRequester {
// list string (xml formatted) for table // list string (xml formatted) for table
public static final List<String> getResourcesByTypeSubType(String scope, String type, String subType) public static final List<String> getResourcesByTypeSubType(String scope, String type, String subType)
throws Exception { throws Exception {
// CacheList.resourceid.clear(); // CacheList.resourceid.clear();
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(getTokenForContext(scope)); AccessTokenProvider.instance.set(getTokenForContext(scope));
try { try {
logger.info("GetResourcesByTypeSubType: [Scope:{}, Type:{}]", scope, type); logger.info("GetResourcesByTypeSubType: [Scope: {}, Type: {}, SubType: {}]",new String[]{ scope, type, subType });
resourceRegistryClient = ResourceRegistryClientFactory.create(); resourceRegistryClient = ResourceRegistryClientFactory.create();
List<String> resources = new ArrayList<String>(); List<String> resources = new ArrayList<String>();

View File

@ -22,12 +22,10 @@ import java.io.File;
import java.io.StringReader; import java.io.StringReader;
import java.security.InvalidParameterException; import java.security.InvalidParameterException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Vector; import java.util.Vector;
import java.util.stream.Collectors;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
@ -39,7 +37,6 @@ import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.portlets.admin.resourcemanagement.client.remote.ServiceProxy; import org.gcube.portlets.admin.resourcemanagement.client.remote.ServiceProxy;
import org.gcube.portlets.admin.resourcemanagement.server.gcube.services.StatusHandler; import org.gcube.portlets.admin.resourcemanagement.server.gcube.services.StatusHandler;
import org.gcube.portlets.admin.resourcemanagement.server.gcube.services.configuration.ConfigurationLoader; import org.gcube.portlets.admin.resourcemanagement.server.gcube.services.configuration.ConfigurationLoader;
import org.gcube.portlets.admin.resourcemanagement.shared.resource.UtilityResource;
import org.gcube.portlets.admin.resourcemanagement.shared.utils.BCrypt; import org.gcube.portlets.admin.resourcemanagement.shared.utils.BCrypt;
import org.gcube.resourcemanagement.support.client.utils.CurrentStatus; import org.gcube.resourcemanagement.support.client.utils.CurrentStatus;
import org.gcube.resourcemanagement.support.client.views.ResourceTypeDecorator; import org.gcube.resourcemanagement.support.client.views.ResourceTypeDecorator;
@ -65,6 +62,8 @@ import org.gcube.resourcemanagement.support.shared.util.Configuration;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.impl.QueryTemplate; import org.gcube.resources.discovery.client.queries.impl.QueryTemplate;
import org.gcube.vremanagement.resourcemanager.client.RMReportingLibrary; import org.gcube.vremanagement.resourcemanager.client.RMReportingLibrary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -78,6 +77,9 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ServiceProxyImpl extends RemoteServiceServlet implements ServiceProxy { public class ServiceProxyImpl extends RemoteServiceServlet implements ServiceProxy {
private static Logger logger = LoggerFactory.getLogger(ServiceProxyImpl.class);
private static final String LOG_PREFIX = "[SERVICE-IMPL]"; private static final String LOG_PREFIX = "[SERVICE-IMPL]";
public final void emptyCache() { public final void emptyCache() {
@ -287,7 +289,7 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
HashMap<String, ArrayList<String>> results = RegistryClientRequester.getResourcesTree(scope); HashMap<String, ArrayList<String>> results = RegistryClientRequester.getResourcesTree(scope);
System.out.println("get result type tree: ("+results.size()+") /n" logger.info("get result type tree: ("+results.size()+") /n"
+ results.keySet() ); + results.keySet() );
@ -303,7 +305,7 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
public final List<String> getResourcesByType(final String scope, final String type) public final List<String> getResourcesByType(final String scope, final String type)
{ {
try { try {
System.out.println("---------------->getResourcesByType"); logger.info("---------------->getResourcesByType: [Scope: {}, type: {}]",scope,type);
List<String> request=RegistryClientRequester.getResourcesByTypeSubType(scope, type,null); List<String> request=RegistryClientRequester.getResourcesByTypeSubType(scope, type,null);
return request; return request;
@ -319,7 +321,7 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
private ResourceDescriptor getDescriptor(final ScopeBean scope, final String resID) throws Exception { private ResourceDescriptor getDescriptor(final ScopeBean scope, final String resID) throws Exception {
System.out.println("---------------->getDescriptor"); logger.info("---------------->getDescriptor");
//set the scope //set the scope
String currScope = ScopeProvider.instance.get(); String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set(scope.toString()); ScopeProvider.instance.set(scope.toString());
@ -403,7 +405,7 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
public final List<String> getResourcesBySubType(final String scope, final String type, final String subType) { public final List<String> getResourcesBySubType(final String scope, final String type, final String subType) {
try { try {
System.out.println("---------------->getResourcesBySubType type:"+type+ "- subtype:"+subType); logger.info("---------------->getResourcesBySubType: [type: {}, subtype: {}]",type,subType);
//Old code //Old code
//List<String> request=ISClientRequester.getResourcesByType(getCacheManager(this.getCurrentStatus()), new ScopeBean(scope), type, subType); //List<String> request=ISClientRequester.getResourcesByType(getCacheManager(this.getCurrentStatus()), new ScopeBean(scope), type, subType);
@ -422,18 +424,18 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
try { try {
ScopeBean gscope = new ScopeBean(scope); ScopeBean gscope = new ScopeBean(scope);
System.out.println("---------------->getResourceByID scope:"+scope+" type:"+type+" resID:"+resID); logger.info("---------------->getResourceByID scope:"+scope+" type:"+type+" resID:"+resID);
System.out.println("---------------->getResourceByID this.getXML2HTMLMapping():"+this.getXML2HTMLMapping()); logger.info("---------------->getResourceByID this.getXML2HTMLMapping():"+this.getXML2HTMLMapping());
//OLD CODE //OLD CODE
//CompleteResourceProfile profile = ISClientRequester.getResourceByID(this.getXML2HTMLMapping(), new ScopeBean(scope), type, resID); //CompleteResourceProfile profile = ISClientRequester.getResourceByID(this.getXML2HTMLMapping(), new ScopeBean(scope), type, resID);
//NEW CODE //NEW CODE
CompleteResourceProfile profile = RegistryClientRequester.getResourceByID(this.getXML2HTMLMapping(), scope, type, resID); CompleteResourceProfile profile = RegistryClientRequester.getResourceByID(this.getXML2HTMLMapping(), scope, type, resID);
System.out.println("****\n\n\n CompleteResourceProfile getResourceByID(final String scope, final String type, final String resID) *****"); logger.info("****\n\n\n CompleteResourceProfile getResourceByID(final String scope, final String type, final String resID) *****");
System.out.println("****CompleteResourceProfile getResourceByID("+scope+","+type+","+resID+") *****\n\n"); logger.info("****CompleteResourceProfile getResourceByID("+scope+","+type+","+resID+") *****\n\n");
System.out.println("---------------->getResourceByID profile:"+profile.toString()); logger.info("---------------->getResourceByID profile:"+profile.toString());
return profile; return profile;
} catch (Exception e) { } catch (Exception e) {

View File

@ -123,20 +123,20 @@ public class UtilityResource {
break; break;
case "Dataset": case "Dataset":
if (f instanceof SoftwareFacet) { if (f instanceof IdentifierFacet) {
logger.info("------------Dataset--SoftwareFacet"); logger.info("------------Dataset--IdentifierFacet");
SoftwareFacet sf = (SoftwareFacet) f; IdentifierFacet sf = (IdentifierFacet) f;
if (!list.contains(sf.getGroup())) { if (!list.contains(sf.getType().toString())) {
list.add(sf.getGroup()); list.add(sf.getType().toString());
} }
} }
break; break;
case "ConcreteDataset": case "ConcreteDataset":
if (f instanceof SoftwareFacet) { if (f instanceof IdentifierFacet) {
logger.info("------------ConcreteDataset--SoftwareFacet"); logger.info("------------ConcreteDataset--IdentifierFacet");
SoftwareFacet sf = (SoftwareFacet) f; IdentifierFacet sf = (IdentifierFacet) f;
if (!list.contains(sf.getGroup())) { if (!list.contains(sf.getType().toString())) {
list.add(sf.getGroup()); list.add(sf.getType().toString());
} }
} }
break; break;
@ -188,11 +188,11 @@ public class UtilityResource {
} }
break; break;
case "Site": case "Site":
if (f instanceof SoftwareFacet) { if (f instanceof IdentifierFacet) {
logger.info("------------Site--SoftwareFacet"); logger.info("------------Site--IdentifierFacet");
SoftwareFacet sf = (SoftwareFacet) f; IdentifierFacet sf = (IdentifierFacet) f;
if (!list.contains(sf.getGroup())) if (!list.contains(sf.getType().toString()))
list.add(sf.getGroup()); list.add(sf.getType().toString());
} }
break; break;
@ -253,12 +253,12 @@ public class UtilityResource {
identifiedFacet = "IdentifierFacet"; identifiedFacet = "IdentifierFacet";
break; break;
case "Dataset": case "Dataset":
field = "group"; field = "type";
identifiedFacet = "SoftwareFacet"; identifiedFacet = "IdentifierFacet";
break; break;
case "ConcreteDataset": case "ConcreteDataset":
field = "group"; field = "type";
identifiedFacet = "SoftwareFacet"; identifiedFacet = "IdentifierFacet";
break; break;
case "Schema": case "Schema":
field = "name"; field = "name";
@ -281,8 +281,8 @@ public class UtilityResource {
identifiedFacet = "SoftwareFacet"; identifiedFacet = "SoftwareFacet";
break; break;
case "Site": case "Site":
field = "group"; field = "type";
identifiedFacet = "SoftwareFacet"; identifiedFacet = "IdentifierFacet";
break; break;
case "Software": case "Software":
field = "group"; field = "group";
@ -521,7 +521,7 @@ public class UtilityResource {
String name = ""; String name = "";
String description = ""; String description = "";
List<ConfigurationTemplate> configurationTemplates = (List<ConfigurationTemplate>) resourceRegistryClient List<ConfigurationTemplate> configurationTemplates = (List<ConfigurationTemplate>) resourceRegistryClient
.getInstances(ConfigurationTemplate.class, false); .getInstances(ConfigurationTemplate.class, true);
if (configurationTemplates != null) { if (configurationTemplates != null) {
logger.info("ConfigurationTemplate found: {}", configurationTemplates.size()); logger.info("ConfigurationTemplate found: {}", configurationTemplates.size());
} else { } else {
@ -654,13 +654,13 @@ public class UtilityResource {
List<? extends Facet> facets = dataset.getIdentificationFacets(); List<? extends Facet> facets = dataset.getIdentificationFacets();
for (Facet f : facets) { for (Facet f : facets) {
if (f instanceof SoftwareFacet) { if (f instanceof IdentifierFacet) {
SoftwareFacet sf = (SoftwareFacet) f; IdentifierFacet sf = (IdentifierFacet) f;
// version = sf.getVersion(); // version = sf.getVersion();
serviceName = sf.getName(); serviceName = sf.getValue();
serviceClass = sf.getGroup(); serviceClass = sf.getType().toString();
subType = sf.getGroup(); subType = sf.getType().toString();
} }
} }
CacheList.resourceid.put(id, new ResourceObject(serviceName, dataset.toString())); CacheList.resourceid.put(id, new ResourceObject(serviceName, dataset.toString()));
@ -711,13 +711,13 @@ public class UtilityResource {
List<? extends Facet> facets = concreteDataset.getIdentificationFacets(); List<? extends Facet> facets = concreteDataset.getIdentificationFacets();
for (Facet f : facets) { for (Facet f : facets) {
if (f instanceof SoftwareFacet) { if (f instanceof IdentifierFacet) {
SoftwareFacet sf = (SoftwareFacet) f; IdentifierFacet sf = (IdentifierFacet) f;
// version = sf.getVersion(); // version = sf.getVersion();
serviceName = sf.getName(); serviceName = sf.getValue();
serviceClass = sf.getGroup(); serviceClass = sf.getType().toString();
subType = sf.getGroup(); subType = sf.getType().toString();
} }
} }
CacheList.resourceid.put(id, new ResourceObject(serviceName, concreteDataset.toString())); CacheList.resourceid.put(id, new ResourceObject(serviceName, concreteDataset.toString()));
@ -1142,13 +1142,13 @@ public class UtilityResource {
List<? extends Facet> facets = site.getIdentificationFacets(); List<? extends Facet> facets = site.getIdentificationFacets();
for (Facet f : facets) { for (Facet f : facets) {
if (f instanceof SoftwareFacet) { if (f instanceof IdentifierFacet) {
SoftwareFacet sf = (SoftwareFacet) f; IdentifierFacet sf = (IdentifierFacet) f;
// version = sf.getVersion(); // version = sf.getVersion();
serviceName = sf.getName(); serviceName = sf.getValue();
serviceClass = sf.getGroup(); serviceClass = sf.getType().toString();
subType = sf.getGroup(); subType = sf.getType().toString();
} }
} }
CacheList.resourceid.put(id, new ResourceObject(serviceName, site.toString())); CacheList.resourceid.put(id, new ResourceObject(serviceName, site.toString()));