ref 19213: Reinforce the information in the Service Profile tab

https://support.d4science.org/issues/19213

Updated to include new info
This commit is contained in:
Giancarlo Panichi 2021-10-06 12:08:32 +02:00
parent 0e4357bdc2
commit fc3c48a570
3 changed files with 83 additions and 66 deletions

View File

@ -4,11 +4,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [v1.14.2-SNAPSHOT] - 2021-05-18 ## [v1.14.2-SNAPSHOT] - 2021-10-06
### Fixes ### Features
- Updated to support new veriosn of StorageHub - Added cluster description in Service Info [#19213]
## [v1.14.1] - 2020-05-20 ## [v1.14.1] - 2020-05-20

View File

@ -67,10 +67,10 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
@Override @Override
public void init() throws ServletException { public void init() throws ServletException {
super.init(); super.init();
System.out.println("Fix JAXP: jdk.xml.entityExpansionLimit=0"); logger.info("Fix JAXP: jdk.xml.entityExpansionLimit=0");
System.setProperty("jdk.xml.entityExpansionLimit", "0"); System.setProperty("jdk.xml.entityExpansionLimit", "0");
System.out.println("initializing StatAlgoImporterService"); logger.info("initializing StatAlgoImporterService");
String notificationRecipientsFile = "/statalgoimporter/properties/NotificationRecipients.txt"; String notificationRecipientsFile = "/statalgoimporter/properties/NotificationRecipients.txt";
InputStream notificationRecipientsInputStream = this.getServletContext() InputStream notificationRecipientsInputStream = this.getServletContext()
.getResourceAsStream(notificationRecipientsFile); .getResourceAsStream(notificationRecipientsFile);
@ -78,25 +78,29 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
try { try {
text = IOUtils.toString(notificationRecipientsInputStream, StandardCharsets.UTF_8.name()); text = IOUtils.toString(notificationRecipientsInputStream, StandardCharsets.UTF_8.name());
} catch (IOException e) { } catch (IOException e) {
System.out.println(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage(),e);
System.out.println(e.getStackTrace().toString());
} }
ArrayList<Recipient> recipients = new ArrayList<Recipient>(); ArrayList<Recipient> recipients = new ArrayList<Recipient>();
JSONObject obj = new JSONObject(text); try {
System.out.println("" + obj); JSONObject obj = new JSONObject(text);
JSONArray arr = obj.getJSONArray("recipients"); logger.info("" + obj);
for (int i = 0; i < arr.length(); i++) { JSONArray arr = obj.getJSONArray("recipients");
JSONObject dest = arr.getJSONObject(i); for (int i = 0; i < arr.length(); i++) {
System.out.println("" + dest); JSONObject dest = arr.getJSONObject(i);
String user = dest.getString("user"); logger.info("" + dest);
String surname = dest.getString("surname"); String user = dest.getString("user");
String name = dest.getString("name"); String surname = dest.getString("surname");
Recipient rec = new Recipient(user, surname, name); String name = dest.getString("name");
recipients.add(rec); Recipient rec = new Recipient(user, surname, name);
recipients.add(rec);
}
} catch (Exception e) {
logger.error(e.getLocalizedMessage(),e);
logger.info("Recipients not set");
} }
System.out.println("Recipients: " + recipients); logger.info("Recipients: " + recipients);
SessionUtil.setDefaultRecipients(this.getServletContext(), recipients); SessionUtil.setDefaultRecipients(this.getServletContext(), recipients);
} }

View File

@ -79,7 +79,8 @@ public class InformationSystemUtils {
+ ". " + "Resource parsing failed!"; + ". " + "Resource parsing failed!";
logger.error(error); logger.error(error);
logger.error( logger.error(
"Error {resource=" + genericResource + ", error=" + e.getLocalizedMessage() + "}",e); "Error {resource=" + genericResource + ", error=" + e.getLocalizedMessage() + "}",
e);
throw new StatAlgoImporterServiceException(error, e); throw new StatAlgoImporterServiceException(error, e);
} }
break; break;
@ -88,12 +89,12 @@ public class InformationSystemUtils {
} }
} }
if(saiDescriptorJaxB==null){ if (saiDescriptorJaxB == null) {
String error = "Error in discovery SAI generic resource on IS in scope " + scope; String error = "Error in discovery SAI generic resource on IS in scope " + scope;
logger.error(error); logger.error(error);
throw new StatAlgoImporterServiceException(error); throw new StatAlgoImporterServiceException(error);
} }
return saiDescriptorJaxB; return saiDescriptorJaxB;
@ -109,7 +110,7 @@ public class InformationSystemUtils {
public static String retrieveDataMinerPoolManager(String scope) throws StatAlgoImporterServiceException { public static String retrieveDataMinerPoolManager(String scope) throws StatAlgoImporterServiceException {
try { try {
logger.info("Retrieve dataminer-pool-manager in scope: "+scope); logger.info("Retrieve dataminer-pool-manager in scope: " + scope);
if (scope == null || scope.length() == 0) if (scope == null || scope.length() == 0)
return null; return null;
@ -155,7 +156,7 @@ public class InformationSystemUtils {
} }
} catch (Throwable e) { } catch (Throwable e) {
String error = "Error in discovery DataMiner PoolManager gCubeEndpoint resource on IS in scope: " String error = "Error in discovery DataMiner PoolManager gCoreEndpoint resource on IS in scope: "
+ scope; + scope;
logger.error(error); logger.error(error);
logger.error( logger.error(
@ -171,7 +172,7 @@ public class InformationSystemUtils {
} }
logger.debug("DataMiner PoolManager URI: " + poolManagerURI); logger.debug("DataMiner PoolManager URI: " + poolManagerURI);
if(poolManagerURI==null||poolManagerURI.isEmpty()){ if (poolManagerURI == null || poolManagerURI.isEmpty()) {
String error = "Error in discovery DataMiner PoolManager gCubeEndpoint resource on IS in scope: " String error = "Error in discovery DataMiner PoolManager gCubeEndpoint resource on IS in scope: "
+ scope; + scope;
logger.error(error); logger.error(error);
@ -191,7 +192,7 @@ public class InformationSystemUtils {
public static String retrieveSocialNetworkingService(String scope) throws StatAlgoImporterServiceException { public static String retrieveSocialNetworkingService(String scope) throws StatAlgoImporterServiceException {
try { try {
logger.info("Retrieve SocialNetworkingService in scope: "+scope); logger.info("Retrieve SocialNetworkingService in scope: " + scope);
if (scope == null || scope.length() == 0) if (scope == null || scope.length() == 0)
return null; return null;
@ -250,14 +251,13 @@ public class InformationSystemUtils {
} }
logger.debug("SocialNetworking URI: " + socialNetworkingURI); logger.debug("SocialNetworking URI: " + socialNetworkingURI);
if(socialNetworkingURI==null||socialNetworkingResources.isEmpty()){ if (socialNetworkingURI == null || socialNetworkingResources.isEmpty()) {
String error = "Error in discovery SocialNetworking gCubeEndpoint resource on IS in scope: " String error = "Error in discovery SocialNetworking gCubeEndpoint resource on IS in scope: " + scope;
+ scope;
logger.error(error); logger.error(error);
throw new StatAlgoImporterServiceException(error); throw new StatAlgoImporterServiceException(error);
} }
return socialNetworkingURI; return socialNetworkingURI;
} catch (StatAlgoImporterServiceException e) { } catch (StatAlgoImporterServiceException e) {
@ -270,14 +270,12 @@ public class InformationSystemUtils {
} }
} }
public static ServiceInfo retrieveServiceInfo(String category, String name, String scope) throws Exception {
public static ServiceInfo retrieveServiceInfo(String category, String name, String scope)
throws Exception {
try { try {
logger.debug("Retrieve DataMiner Service Properties"); logger.debug("Retrieve DataMiner Service Properties");
if (scope == null || scope.length() == 0){ if (scope == null || scope.length() == 0) {
logger.error("Invalid request scope: "+scope); logger.error("Invalid request scope: " + scope);
return null; return null;
} }
@ -289,42 +287,57 @@ public class InformationSystemUtils {
.setResult("$resource/Profile/AccessPoint"); .setResult("$resource/Profile/AccessPoint");
DiscoveryClient<AccessPoint> client = ICFactory.clientFor(AccessPoint.class); DiscoveryClient<AccessPoint> client = ICFactory.clientFor(AccessPoint.class);
List<AccessPoint> accessPointList = client.submit(query); List<AccessPoint> accessPointList = client.submit(query);
String serviceAddress=null; String serviceAddress = null;
ArrayList<ServiceInfoData> serviceProperties = new ArrayList<>(); ArrayList<ServiceInfoData> serviceProperties = new ArrayList<>();
if (accessPointList != null && !accessPointList.isEmpty()) { if (accessPointList != null && !accessPointList.isEmpty()) {
AccessPoint accessPoint = accessPointList.get(0); for (int i = 0; i < accessPointList.size(); i++) {
if (accessPoint.address() != null && !accessPoint.address().isEmpty()) { AccessPoint accessPoint = accessPointList.get(i);
String accessPointAddress = accessPoint.address(); if (accessPoint != null) {
int wpsWebProcessingServiceIndex = accessPointAddress.indexOf(Constants.WPSWebProcessingService); if (i == 0) {
if (wpsWebProcessingServiceIndex > 0) { if (accessPoint.address() != null && !accessPoint.address().isEmpty()) {
serviceAddress = accessPointAddress.substring(0, wpsWebProcessingServiceIndex); String accessPointAddress = accessPoint.address();
} int wpsWebProcessingServiceIndex = accessPointAddress
} .indexOf(Constants.WPSWebProcessingService);
if (wpsWebProcessingServiceIndex > 0) {
if (accessPoint.properties() != null && !accessPoint.propertyMap().isEmpty()) { serviceAddress = accessPointAddress.substring(0, wpsWebProcessingServiceIndex);
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(), Constants.DATA_MINER_DEFAULT_SERVICE_INFO_CATEGORY));
} }
} else {
serviceProperties.add(new ServiceInfoData(property.name(), property.value(), Constants.DATA_MINER_DEFAULT_SERVICE_INFO_CATEGORY));
} }
} }
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); ServiceInfo serviceInfo = new ServiceInfo(serviceAddress, serviceProperties);
logger.debug("DataMiner Service Info: " + serviceInfo); logger.debug("DataMiner Service Info: " + serviceInfo);
return serviceInfo; return serviceInfo;