Compare commits
1 Commits
main
...
Feature/27
Author | SHA1 | Date |
---|---|---|
Biniam Abraha Masa | 97eacac020 |
13
.classpath
13
.classpath
|
@ -14,8 +14,20 @@
|
|||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
|
@ -24,6 +36,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
|
@ -1,17 +1,9 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.processAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -4,3 +4,4 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
## [v1.0.0-SNAPSHOT]
|
||||
- First commit with project structure
|
||||
- Branch Feature-27440
|
18
pom.xml
18
pom.xml
|
@ -3,6 +3,12 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.vremanagement</groupId>
|
||||
<artifactId>vre-removed-publisher</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
@ -21,12 +27,6 @@
|
|||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
<version>2.13.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
|
@ -62,12 +62,8 @@
|
|||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.opencsv</groupId>
|
||||
<artifactId>opencsv</artifactId>
|
||||
<version>5.5.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
|
|
@ -3,86 +3,53 @@ package org.gcube.vremanagement;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
String csvFilePath = "src/main/resources/updated_VREDecommisioned-240326.csv";
|
||||
String xmlFilePath = "src/main/resources/doc.xml";
|
||||
|
||||
|
||||
// Initialize managers
|
||||
CsvManager csvManager = new CsvManager(csvFilePath);
|
||||
XmlManager xmlManager = new XmlManager(xmlFilePath);
|
||||
|
||||
// Parse CSV and XML files
|
||||
HashMap<String, Gateway> xmlMap = xmlManager.parse();
|
||||
HashMap<String, Gateway> csvMap = csvManager.parseCsvToMap(csvFilePath);
|
||||
putAll(xmlMap,csvMap);
|
||||
|
||||
|
||||
//Merging csvMap into the xmlMap
|
||||
//Note that: in case of duplicate elements, the csvMap elements will overwrite the xmlMap
|
||||
//this is ok for us because the csv elements are mode recent than xml element
|
||||
//check this behaviour in the final xml doc
|
||||
|
||||
|
||||
xmlManager.writeXml(xmlMap, "finalDoc.xml");
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Methods to query and print information
|
||||
//xmlManager.getGatewaysInfo();
|
||||
//xmlManager.getVosInfo("D4Science.org Detached Gateway");
|
||||
//xmlManager.findVo("D4Science.org Detached Gateway", "gCubeApps");
|
||||
//xmlManager.findVre("D4Science.org Detached Gateway", "D4OS", "CNROutreach");
|
||||
}
|
||||
|
||||
//This method checks duplicates and merge
|
||||
public static void putAll(HashMap<String, Gateway> xmlMap, HashMap<String, Gateway> csvMap) {
|
||||
for (String csvKey : csvMap.keySet()) {
|
||||
Gateway csvGateway = csvMap.get(csvKey);
|
||||
|
||||
// Normalize the CSV gateway name
|
||||
String csvGatewayNameNormalized = csvGateway.getName().toLowerCase();
|
||||
XmlManager xmlManager = new XmlManager();
|
||||
String csvgatewayName = xmlManager.extractGatewayName(csvGatewayNameNormalized);
|
||||
// Check for duplicates by gateway name (case insensitive)
|
||||
boolean foundDuplicate = false;
|
||||
for (String xmlKey : xmlMap.keySet()) {
|
||||
Gateway xmlGateway = xmlMap.get(xmlKey);
|
||||
String xmlGatewayNameNormalized = xmlGateway.getName().toLowerCase();
|
||||
|
||||
if (xmlGatewayNameNormalized.equalsIgnoreCase(csvgatewayName)) {
|
||||
// Merge VOs and VREs
|
||||
for (Vos csvVos : csvGateway.getVosList()) {
|
||||
Vos xmlVos = xmlGateway.getVosByName(csvVos.getName());
|
||||
if (xmlVos != null) {
|
||||
for (Vres csvVres : csvVos.getVresList()) {
|
||||
if (xmlVos.getVresByName(csvVres.getName()) == null) {
|
||||
xmlVos.addVres(csvVres);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
xmlGateway.addVos(csvVos);
|
||||
}
|
||||
}
|
||||
foundDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If no duplicate found, add the CSV gateway to the XML map
|
||||
if (!foundDuplicate) {
|
||||
xmlMap.put(csvKey, csvGateway);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Create here the CSV and XML managers object to parse and sync the XML with the CSV file
|
||||
//CsvManager csvManager = new CsvManager("/home/biniam/eclipse-workspace/vre-removed-publisher/src/main/resources/updated_VREDecommisioned-240326.csv");
|
||||
String filePath = "src/main/resources";
|
||||
String filename = "doc.xml";
|
||||
XmlManager xmlManager = new XmlManager(filePath+File.separator+filename);
|
||||
|
||||
// Parse CSV and XML files
|
||||
//csvManager.parse();
|
||||
xmlManager.parse();
|
||||
|
||||
// Parse XML to HashMap
|
||||
// HashMap<String, ArrayList<Gateway>> gatewayMap = xmlManager.parseToHashMap();
|
||||
|
||||
/*for (String gatewayName: gatewayMap.keySet())
|
||||
{
|
||||
ArrayList<Gateway> listGateway = gatewayMap.get(gatewayName);
|
||||
for (Gateway gate : listGateway)
|
||||
{
|
||||
System.out.println("Gateway name: "+gate.getName());
|
||||
System.out.println("Gateway description: "+gate.getDescription());
|
||||
ArrayList<Vos> vosList = gate.getVosList();
|
||||
for (Vos voTemp: vosList)
|
||||
{
|
||||
ArrayList<Vres> vreList = voTemp.getVresList();
|
||||
System.out.println("VO name:" +voTemp.getName());
|
||||
System.out.println("VO description: "+voTemp.getDescription());
|
||||
for(Vres vreTemp:vreList)
|
||||
{
|
||||
System.out.println("VRE name: "+vreTemp.getName());
|
||||
System.out.println("Vre description: "+vreTemp.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}*/
|
||||
// methods to query and print information
|
||||
//xmlManager.getGatewaysInfo();
|
||||
xmlManager.getVosInfo("D4Science.org Detached Gateway");
|
||||
//xmlManager.findVo("D4Science.org Detached Gateway", "gCubeApps");
|
||||
xmlManager.findVre("D4Science.org Detached Gateway", "D4OS", "CNROutreach");
|
||||
|
||||
}
|
||||
}
|
|
@ -1,77 +1,65 @@
|
|||
package org.gcube.vremanagement;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.opencsv.CSVReader;
|
||||
import com.opencsv.CSVReaderBuilder;
|
||||
|
||||
public class CsvManager {
|
||||
private String csvFilePath;
|
||||
private HashMap<String, Gateway> gatewayMap;
|
||||
|
||||
public CsvManager(String csvFilePath) {
|
||||
this.csvFilePath = csvFilePath;
|
||||
this.gatewayMap = new HashMap<>();
|
||||
|
||||
import com.opencsv.CSVParser;
|
||||
|
||||
|
||||
public class CsvManager implements VreRemPubInterface {
|
||||
private String filePath;
|
||||
private ArrayList<String[]> dataList;
|
||||
|
||||
public CsvManager(String filePath) {
|
||||
this.filePath = filePath;
|
||||
System.out.println("CSV manager created!");
|
||||
this.dataList = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parse() {
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] values = line.split(",");
|
||||
dataList.add(values);
|
||||
}
|
||||
System.out.println("CSV file parsed successfully.");
|
||||
// Optionally, print the data here
|
||||
System.out.println("Parsed CSV data: " + dataList);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
// Implement update logic if needed
|
||||
}
|
||||
|
||||
@Override
|
||||
public void find() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String, Gateway> parseCsvToMap(String csvFilePath) {
|
||||
HashMap<String, Gateway> csvMap = new HashMap<>();
|
||||
try {
|
||||
FileReader filereader = new FileReader(csvFilePath);
|
||||
CSVReader csvReader = new CSVReaderBuilder(filereader).withSkipLines(1).build();
|
||||
|
||||
List<String[]> allData = csvReader.readAll();
|
||||
|
||||
for (String[] row : allData) {
|
||||
XmlManager xmlManager = new XmlManager();
|
||||
String gatewayName = row[5];
|
||||
String csvgatewayName = xmlManager.extractGatewayName(gatewayName)+ " Gateway";
|
||||
String description = row[10];
|
||||
String voName = row[4];
|
||||
String vreName = row[3];
|
||||
String manager = row[9];
|
||||
String startDate = row[7];
|
||||
String endDate = row[8];
|
||||
|
||||
|
||||
Gateway gateway = csvMap.getOrDefault(csvgatewayName.toLowerCase(), new Gateway(csvgatewayName, description));
|
||||
Vos vos = gateway.getVosByName(voName);
|
||||
if (vos == null) {
|
||||
vos = new Vos(voName, voName, voName);
|
||||
gateway.addVos(vos);
|
||||
}
|
||||
|
||||
Vres vres = vos.getVresByName(vreName);
|
||||
if (vres == null) {
|
||||
vres = new Vres(vreName, vreName, description, manager, startDate, endDate);
|
||||
vos.addVres(vres);
|
||||
}
|
||||
|
||||
csvMap.put(csvgatewayName.toLowerCase(), gateway);
|
||||
}
|
||||
|
||||
|
||||
csvReader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return csvMap;
|
||||
}
|
||||
|
||||
private String extractGatewayName(String gateways) {
|
||||
if (gateways.startsWith("https://")) {
|
||||
return gateways.substring(8, gateways.indexOf("."));
|
||||
} else if (gateways.startsWith("http://")) {
|
||||
return gateways.substring(7, gateways.indexOf("."));
|
||||
} else {
|
||||
return gateways; // fallback
|
||||
}
|
||||
@Override
|
||||
public void read() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
// Other methods...
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,28 +3,28 @@ package org.gcube.vremanagement;
|
|||
import java.util.ArrayList;
|
||||
|
||||
public class Gateway {
|
||||
private String name;
|
||||
private String description;
|
||||
private ArrayList<Vos>listOfVos;
|
||||
public Gateway(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.listOfVos= new ArrayList<Vos>();
|
||||
}
|
||||
private String name;
|
||||
private String description;
|
||||
private ArrayList<Vos>listOfVos;
|
||||
public Gateway(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.listOfVos= new ArrayList<Vos>();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
// Method to print gateway information
|
||||
public void printInfo() {
|
||||
System.out.println("Gateway Name: " + name);
|
||||
System.out.println("Gateway Description: " + description);
|
||||
}
|
||||
// Method to print gateway information
|
||||
public void printInfo() {
|
||||
System.out.println("Gateway Name: " + name);
|
||||
System.out.println("Gateway Description: " + description);
|
||||
}
|
||||
|
||||
public ArrayList<Vos> getVosList() {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -33,14 +33,7 @@ public class Gateway {
|
|||
|
||||
// In the Gateway class
|
||||
public void addVos(Vos vos) {
|
||||
listOfVos.add(vos);
|
||||
listOfVos.add(vos);
|
||||
}
|
||||
public Vos getVosByName(String name) {
|
||||
for (Vos vos : listOfVos) {
|
||||
if (vos.getName().equals(name)) {
|
||||
return vos;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,51 +4,37 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
|
||||
public class Vos {
|
||||
private String key;
|
||||
private String name;
|
||||
private String scope;
|
||||
private ArrayList<Vres>listOfVres;
|
||||
public Vos(String key,String scope,String name) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.scope = scope;
|
||||
this.listOfVres=new ArrayList<Vres>();
|
||||
private String key;
|
||||
private String name;
|
||||
private String scope;
|
||||
private ArrayList<Vres>listOfVres;
|
||||
public Vos(String key,String scope,String name) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.scope = scope;
|
||||
this.listOfVres=new ArrayList<Vres>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Vos(String string, String vo) {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
// Method to print VO information
|
||||
public void printInfo() {
|
||||
System.out.println("VO Key: " + key);
|
||||
System.out.println("VO Name: " + name);
|
||||
System.out.println("VO Scope: " + scope);
|
||||
System.out.println("VRES Names:");
|
||||
if (!listOfVres.isEmpty()) {
|
||||
for (Vres vres : listOfVres) {
|
||||
System.out.println("VRES Name: " + vres.getName());
|
||||
}
|
||||
} else {
|
||||
System.out.println("No VRES found for this VO.");
|
||||
}
|
||||
}
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
// Method to print VO information
|
||||
public void printInfo() {
|
||||
System.out.println("VO Key: " + key);
|
||||
System.out.println("VO Name: " + name);
|
||||
System.out.println("VO Scope: " + scope);
|
||||
}
|
||||
|
||||
public ArrayList<Vres> getVresList() {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -64,12 +50,5 @@ public class Vos {
|
|||
// TODO Auto-generated method stub
|
||||
listOfVres.add(vres);
|
||||
}
|
||||
public Vres getVresByName(String name) {
|
||||
for (Vres vres : listOfVres) {
|
||||
if (vres.getName().equals(name)) {
|
||||
return vres;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package org.gcube.vremanagement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface VreRemPubInterface {
|
||||
|
||||
HashMap<String, Gateway> parse(); //method used to parse the file (e.g., xml or csv) in a data structure
|
||||
void parse(); //method used to parse the file (e.g., xml or csv) in a data structure
|
||||
void update(); //method used to update the file (e.g., xml or csv)
|
||||
//add here other common methods needed by both Csv and Xml Manager
|
||||
void find();
|
||||
|
|
|
@ -1,65 +1,59 @@
|
|||
package org.gcube.vremanagement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Vres {
|
||||
private String key;
|
||||
private String name;
|
||||
private String description;
|
||||
private String manager;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private String key;
|
||||
private String name;
|
||||
private String description;
|
||||
private String manager;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
|
||||
public Vres(String key, String name, String description, String manager, String startDate, String endDate) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.manager = manager;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
public Vres(String key, String name, String description, String manager, String startDate, String endDate) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.manager = manager;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public Vres() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public Vres(String string, String vreNames) {
|
||||
public Vres() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getManager() {
|
||||
return manager;
|
||||
}
|
||||
public String getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
// Method to print VRE information
|
||||
public void printInfo() {
|
||||
System.out.println("VRE Key: " + key);
|
||||
System.out.println("VRE Name: " + name);
|
||||
System.out.println("VRE Description: " + description);
|
||||
System.out.println("VRE Manager: " + manager);
|
||||
System.out.println("VRE Start Date: " + startDate);
|
||||
System.out.println("VRE End Date: " + endDate);
|
||||
}
|
||||
// Method to print VRE information
|
||||
public void printInfo() {
|
||||
System.out.println("VRE Key: " + key);
|
||||
System.out.println("VRE Name: " + name);
|
||||
System.out.println("VRE Description: " + description);
|
||||
System.out.println("VRE Manager: " + manager);
|
||||
System.out.println("VRE Start Date: " + startDate);
|
||||
System.out.println("VRE End Date: " + endDate);
|
||||
}
|
||||
|
||||
public String getManagers() {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -70,25 +64,4 @@ public class Vres {
|
|||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setDescription(String description2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setManagers(ArrayList<String> arrayList) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setStartDate(String startTime) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setEndDate(String endTime) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.gcube.vremanagement;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -12,20 +11,12 @@ import java.util.stream.Collectors;
|
|||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
|
||||
public class XmlManager implements VreRemPubInterface {
|
||||
private String filePath;
|
||||
private HashMap<String, Gateway> gatewaysMap;
|
||||
|
@ -35,12 +26,8 @@ public class XmlManager implements VreRemPubInterface {
|
|||
this.gatewaysMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public XmlManager() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Gateway> parse() {
|
||||
public void parse() {
|
||||
try {
|
||||
File xmlFile = new File(filePath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
|
@ -48,7 +35,7 @@ public class XmlManager implements VreRemPubInterface {
|
|||
Document doc = dBuilder.parse(xmlFile);
|
||||
doc.getDocumentElement().normalize();
|
||||
NodeList gatewayNodes = doc.getElementsByTagName("gateways");
|
||||
|
||||
|
||||
NodeList gatewayList = gatewayNodes.item(0).getChildNodes();
|
||||
|
||||
for (int i = 0; i < gatewayList.getLength(); i++) {
|
||||
|
@ -59,6 +46,8 @@ public class XmlManager implements VreRemPubInterface {
|
|||
String gatewayDescription = gatewayElement.getElementsByTagName("description").item(0)
|
||||
.getTextContent().trim();
|
||||
|
||||
//System.out.println("gateway name:"+gatewayName);
|
||||
//System.out.println("Gateway descr:"+gatewayDescription);
|
||||
Gateway gateway = new Gateway(gatewayName, gatewayDescription);
|
||||
|
||||
// Find the <vos> element within the gateway entry
|
||||
|
@ -67,78 +56,93 @@ public class XmlManager implements VreRemPubInterface {
|
|||
Node vosNode = vosList.item(j);
|
||||
if (vosNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element vosElement = (Element) vosNode;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String voKey = vosElement.getElementsByTagName("key").item(0).getTextContent().trim();
|
||||
String voName = vosElement.getElementsByTagName("name").item(0).getTextContent().trim();
|
||||
String voScope = vosElement.getElementsByTagName("scope").item(0).getTextContent().trim();
|
||||
|
||||
|
||||
//getting vo
|
||||
Vos vos = new Vos(voKey,voScope, voName);
|
||||
|
||||
//vos.printInfo();
|
||||
|
||||
// Iterate on the vres..
|
||||
//NodeList vreList = vosElement.getElementsByTagName("vres");
|
||||
//
|
||||
//for (int k = 0; k < vreList.getLength(); k++) {
|
||||
// Node voNode = voList.item(k);
|
||||
// if (voNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
// Element voElement = (Element) voNode;
|
||||
|
||||
|
||||
// String voName = voElement.getElementsByTagName("name").item(0).getTextContent().trim();
|
||||
// String voScope = voElement.getElementsByTagName("scope").item(0).getTextContent().trim();
|
||||
// String voKey = voElement.getElementsByTagName("key").item(0).getTextContent().trim();
|
||||
|
||||
// Create a new Vos object and add it to the gateway's vosList
|
||||
// Vos vos = new Vos(voKey, voScope, voName);
|
||||
|
||||
// Find the <vres> element within the VO entry
|
||||
NodeList vresList = vosElement.getElementsByTagName("vres");
|
||||
for (int l = 0; l < vresList.getLength(); l++) {
|
||||
Node vresNode = vresList.item(l);
|
||||
if (vresNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element vresElement = (Element) vresNode;
|
||||
// Iterate through <entry> elements representing VREs within <vres>
|
||||
NodeList vreEntryList = vresElement.getElementsByTagName("entry");
|
||||
for (int m = 0; m < vreEntryList.getLength(); m++) {
|
||||
Node vreEntryNode = vreEntryList.item(m);
|
||||
if (vreEntryNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element vreEntryElement = (Element) vreEntryNode;
|
||||
String vreKey = vreEntryElement.getElementsByTagName("key").item(0)
|
||||
.getTextContent().trim();
|
||||
String vreName = vreEntryElement.getElementsByTagName("name")
|
||||
.item(0).getTextContent().trim();
|
||||
String vreDescription = vreEntryElement
|
||||
.getElementsByTagName("description").item(0)
|
||||
.getTextContent().trim();
|
||||
String vreManager = vreEntryElement.getElementsByTagName("managers")
|
||||
.item(0).getTextContent().trim();
|
||||
String vreStartDate = vreEntryElement
|
||||
.getElementsByTagName("startdate").item(0).getTextContent().trim();
|
||||
String vreEndDate = vreEntryElement.getElementsByTagName("enddate")
|
||||
.item(0).getTextContent().trim();
|
||||
|
||||
// Create a new Vres object and add it to the Vos's vreList
|
||||
Vres vres = new Vres(vreKey, vreName, vreDescription, vreManager,
|
||||
vreStartDate, vreEndDate);
|
||||
vos.addVres(vres);
|
||||
|
||||
// Find the <vres> element within the VO entry
|
||||
NodeList vresList = vosElement.getElementsByTagName("vres");
|
||||
for (int l = 0; l < vresList.getLength(); l++) {
|
||||
Node vresNode = vresList.item(l);
|
||||
if (vresNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element vresElement = (Element) vresNode;
|
||||
// Iterate through <entry> elements representing VREs within <vres>
|
||||
NodeList vreEntryList = vresElement.getElementsByTagName("entry");
|
||||
for (int m = 0; m < vreEntryList.getLength(); m++) {
|
||||
Node vreEntryNode = vreEntryList.item(m);
|
||||
if (vreEntryNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element vreEntryElement = (Element) vreEntryNode;
|
||||
String vreKey = vreEntryElement.getElementsByTagName("key").item(0)
|
||||
.getTextContent().trim();
|
||||
String vreName = vreEntryElement.getElementsByTagName("name")
|
||||
.item(0).getTextContent().trim();
|
||||
String vreDescription = vreEntryElement
|
||||
.getElementsByTagName("description").item(0)
|
||||
.getTextContent().trim();
|
||||
String vreManager = vreEntryElement.getElementsByTagName("managers")
|
||||
.item(0).getTextContent().trim();
|
||||
String vreStartDate = vreEntryElement
|
||||
.getElementsByTagName("startdate").item(0).getTextContent().trim();
|
||||
String vreEndDate = vreEntryElement.getElementsByTagName("enddate")
|
||||
.item(0).getTextContent().trim();
|
||||
|
||||
// Create a new Vres object and add it to the Vos's vreList
|
||||
Vres vres = new Vres(vreKey, vreName, vreDescription, vreManager,
|
||||
vreStartDate, vreEndDate);
|
||||
vos.addVres(vres);
|
||||
|
||||
//vres.printInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the Vos object to the gateway's vosList
|
||||
gateway.addVos(vos);
|
||||
//}
|
||||
// Add the Vos object to the gateway's vosList
|
||||
gateway.addVos(vos);
|
||||
//}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
// Store the gateway object in the gateways map
|
||||
|
||||
|
||||
gatewaysMap.put(gatewayName, gateway);
|
||||
//computeIfAbsent(gatewayName, k -> new ArrayList<>()).add(gateway);
|
||||
}
|
||||
}
|
||||
return gatewaysMap;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void getGatewaysInfo() {
|
||||
System.out.println("Name of the Gateway:");
|
||||
gatewaysMap.keySet().stream().filter(gatewayName -> gatewayName.endsWith("Gateway"))
|
||||
.forEach(System.out::println);
|
||||
.forEach(System.out::println);
|
||||
}
|
||||
// Other methods...
|
||||
|
||||
|
@ -162,18 +166,21 @@ public class XmlManager implements VreRemPubInterface {
|
|||
// Implement write logic if needed
|
||||
}
|
||||
|
||||
|
||||
|
||||
//public HashMap<String, ArrayList<Gateway>> parseToHashMap() {
|
||||
// return gatewaysMap;
|
||||
// }
|
||||
|
||||
|
||||
public void getVosInfo(String _gateway) {
|
||||
System.out.println("VOs Information for Gateway: " + _gateway);
|
||||
|
||||
|
||||
if (gatewaysMap.containsKey(_gateway)) {
|
||||
Gateway gatewayItem = gatewaysMap.get(_gateway);
|
||||
//Gateway gateway = gatewayList.get(0); // Get the first gateway with the specified name
|
||||
ArrayList<Vos> vosList = gatewayItem.getVosList();
|
||||
if (vosList != null) {
|
||||
for (Vos vos : vosList) {
|
||||
vos.printInfo();
|
||||
vos.printInfo();
|
||||
//System.out.println("Name of VREs: ");
|
||||
//ArrayList<Vres> vresList = vos.getVresList();
|
||||
//if (vresList != null && !vresList.isEmpty()) {
|
||||
|
@ -181,9 +188,9 @@ public class XmlManager implements VreRemPubInterface {
|
|||
// vre.printInfo();
|
||||
// }
|
||||
//} else {
|
||||
// System.out.println("No VREs found for this VOS.");
|
||||
// }
|
||||
// System.out.println("----------------------------------------");
|
||||
// System.out.println("No VREs found for this VOS.");
|
||||
// }
|
||||
// System.out.println("----------------------------------------");
|
||||
}
|
||||
} else {
|
||||
//System.out.println("No VOS found for this gateway.");
|
||||
|
@ -200,16 +207,16 @@ public class XmlManager implements VreRemPubInterface {
|
|||
{
|
||||
Gateway gatewayItem = gatewaysMap.get(_gateway);
|
||||
boolean found = false;
|
||||
ArrayList<Vos> vosList = gatewayItem.getVosList();
|
||||
ArrayList<Vos> vosList = gatewayItem.getVosList();
|
||||
if (vosList != null) {
|
||||
for (Vos vos : vosList) {
|
||||
if (vos.getName().equals(_vo)) {
|
||||
found = true;
|
||||
System.out.println("VO info for " + _vo + " in " + _gateway + ":");
|
||||
System.out.println("Name of VOS: " + vos.getName());
|
||||
}
|
||||
for (Vos vos : vosList) {
|
||||
if (vos.getName().equals(_vo)) {
|
||||
found = true;
|
||||
System.out.println("VO info for " + _vo + " in " + _gateway + ":");
|
||||
System.out.println("Name of VOS: " + vos.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (!found) {
|
||||
System.out.println("VO " + _vo + " not found in the gateway " + _gateway + ".");
|
||||
|
@ -220,239 +227,38 @@ public class XmlManager implements VreRemPubInterface {
|
|||
}
|
||||
|
||||
public void findVre(String _gateway, String _vo, String _vre) {
|
||||
//System.out.println("VRE Information for VO: " + _vo + " in Gateway:\n " + _gateway);
|
||||
boolean vreFound = false; // Flag to track if VRE exists
|
||||
//ArrayList<Gateway> gatewayList = gatewaysMap.get(_gateway);
|
||||
|
||||
if (gatewaysMap.containsKey(_gateway)) {
|
||||
|
||||
Gateway gatewayItem = gatewaysMap.get(_gateway);
|
||||
ArrayList<Vos> vosList = gatewayItem.getVosList();
|
||||
if (vosList != null) {
|
||||
for (Vos vos : vosList) {
|
||||
if (vos.getName().equals(_vo)) {
|
||||
ArrayList<Vres> vresList = vos.getVresList();
|
||||
if (vresList != null) {
|
||||
for (Vres vre : vresList) {
|
||||
if (vre.getName().equals(_vre)) {
|
||||
// Print VRE information
|
||||
vre.printInfo();
|
||||
vreFound = true; // Set flag to true
|
||||
// return; // Exit method after printing information
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If execution reaches here and VRE not found, print message
|
||||
if (!vreFound) {
|
||||
System.out.println("VRE does not exist in the " + _vo + " of the " + _gateway);
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<String, ArrayList<Gateway>> parseToHashMap() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
public void writeXml(HashMap<String, Gateway> map, String outputXmlFilePath) throws Exception {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document document = builder.newDocument();
|
||||
|
||||
// Create root element <genericResources>
|
||||
Element genericResourcesElement = document.createElement("genericResources");
|
||||
document.appendChild(genericResourcesElement);
|
||||
|
||||
// Create <Resource> element with version attribute
|
||||
Element resourceElement = document.createElement("Resource");
|
||||
resourceElement.setAttribute("version", "0.4.x");
|
||||
genericResourcesElement.appendChild(resourceElement);
|
||||
|
||||
// Create <ID> element
|
||||
Element idElement = document.createElement("ID");
|
||||
idElement.appendChild(document.createTextNode("68322b8f-b916-44b9-9c93-bad8cceb9106"));
|
||||
resourceElement.appendChild(idElement);
|
||||
|
||||
// Create <Type> element
|
||||
Element typeElement = document.createElement("Type");
|
||||
typeElement.appendChild(document.createTextNode("GenericResource"));
|
||||
resourceElement.appendChild(typeElement);
|
||||
|
||||
// Create <Scopes> element
|
||||
Element scopesElement = document.createElement("Scopes");
|
||||
resourceElement.appendChild(scopesElement);
|
||||
|
||||
// Create <Scope> element within <Scopes>
|
||||
Element scopeElement = document.createElement("Scope");
|
||||
scopeElement.appendChild(document.createTextNode("/d4science.research-infrastructures.eu"));
|
||||
scopesElement.appendChild(scopeElement);
|
||||
|
||||
// Create <Profile> element
|
||||
Element profileElement = document.createElement("Profile");
|
||||
resourceElement.appendChild(profileElement);
|
||||
|
||||
// Create <SecondaryType> element
|
||||
Element secondaryTypeElement = document.createElement("SecondaryType");
|
||||
secondaryTypeElement.appendChild(document.createTextNode("DetachedREs"));
|
||||
profileElement.appendChild(secondaryTypeElement);
|
||||
|
||||
// Create <Name> element
|
||||
Element nameElement = document.createElement("Name");
|
||||
nameElement.appendChild(document.createTextNode("DetachedREsData"));
|
||||
profileElement.appendChild(nameElement);
|
||||
|
||||
// Create <Description> element
|
||||
Element descriptionElement1 = document.createElement("Description");
|
||||
descriptionElement1.appendChild(document.createTextNode("Contains the information relating to dismissed Gateways, VOs and VREs."));
|
||||
profileElement.appendChild(descriptionElement1);
|
||||
|
||||
// Create <Body> element
|
||||
Element bodyElement = document.createElement("Body");
|
||||
profileElement.appendChild(bodyElement);
|
||||
|
||||
// Create <detachedres> element
|
||||
Element detachedResElement = document.createElement("detachedres");
|
||||
bodyElement.appendChild(detachedResElement);
|
||||
|
||||
// Create <enabled> element within <detachedres>
|
||||
Element enabledElement = document.createElement("enabled");
|
||||
enabledElement.appendChild(document.createTextNode("true"));
|
||||
detachedResElement.appendChild(enabledElement);
|
||||
|
||||
// Create <gateways> element within <detachedres>
|
||||
Element gatewaysElement = document.createElement("gateways");
|
||||
detachedResElement.appendChild(gatewaysElement);
|
||||
|
||||
int gatewayKey = -1;
|
||||
|
||||
// Iterate through the map entries to populate <entry> elements under <gateways>
|
||||
for (Map.Entry<String, Gateway> entry : map.entrySet()) {
|
||||
Gateway gateway = entry.getValue();
|
||||
|
||||
// Create <entry> element
|
||||
Element entryElement = document.createElement("entry");
|
||||
gatewaysElement.appendChild(entryElement);
|
||||
|
||||
// Create <key> element within <entry>
|
||||
Element keyElement = document.createElement("key");
|
||||
keyElement.appendChild(document.createTextNode(String.valueOf(gatewayKey)));
|
||||
entryElement.appendChild(keyElement);
|
||||
|
||||
// Create <value> element within <entry>
|
||||
Element valueElement = document.createElement("value");
|
||||
entryElement.appendChild(valueElement);
|
||||
|
||||
// Create <scope> element within <value>
|
||||
Element scopeValueElement = document.createElement("scope");
|
||||
scopeValueElement.appendChild(document.createTextNode(String.valueOf(gatewayKey)));
|
||||
valueElement.appendChild(scopeValueElement);
|
||||
|
||||
// Create <name> element within <value>
|
||||
Element nameValueElement = document.createElement("name");
|
||||
String gatewayName = extractGatewayName(gateway.getName());
|
||||
nameValueElement.appendChild(document.createTextNode(gatewayName));
|
||||
valueElement.appendChild(nameValueElement);
|
||||
|
||||
// Create <description> element within <value>
|
||||
Element descriptionElement = document.createElement("description");
|
||||
descriptionElement.appendChild(document.createTextNode("No description for gateway"));
|
||||
valueElement.appendChild(descriptionElement);
|
||||
|
||||
Element vosElement = document.createElement("vos");
|
||||
valueElement.appendChild(vosElement);
|
||||
|
||||
// Collect VREs under their respective VOs
|
||||
Map<String, Element> voElements = new HashMap<>();
|
||||
|
||||
for (Vos vos : gateway.getVosList()) {
|
||||
Element vosEntryElement;
|
||||
Element vosValueElement;
|
||||
if (voElements.containsKey(vos.getName())) {
|
||||
vosEntryElement = voElements.get(vos.getName());
|
||||
vosValueElement = (Element) vosEntryElement.getElementsByTagName("value").item(0);
|
||||
} else {
|
||||
vosEntryElement = document.createElement("entry");
|
||||
vosElement.appendChild(vosEntryElement);
|
||||
|
||||
Element vosKeyElement = document.createElement("key");
|
||||
vosKeyElement.appendChild(document.createTextNode("/d4science.research-infrastructures.eu/" + vos.getName()));
|
||||
vosEntryElement.appendChild(vosKeyElement);
|
||||
|
||||
vosValueElement = document.createElement("value");
|
||||
vosEntryElement.appendChild(vosValueElement);
|
||||
|
||||
Element vosScopeElement = document.createElement("scope");
|
||||
vosScopeElement.appendChild(document.createTextNode("/d4science.research-infrastructures.eu/" + vos.getName()));
|
||||
vosValueElement.appendChild(vosScopeElement);
|
||||
|
||||
Element vosNameElement = document.createElement("name");
|
||||
vosNameElement.appendChild(document.createTextNode(vos.getName()));
|
||||
vosValueElement.appendChild(vosNameElement);
|
||||
|
||||
voElements.put(vos.getName(), vosEntryElement);
|
||||
}
|
||||
|
||||
Element vresElement = document.createElement("vres");
|
||||
vosValueElement.appendChild(vresElement);
|
||||
|
||||
for (Vres vres : vos.getVresList()) {
|
||||
Element vresEntryElement = document.createElement("entry");
|
||||
vresElement.appendChild(vresEntryElement);
|
||||
|
||||
Element vresKeyElement = document.createElement("key");
|
||||
vresKeyElement.appendChild(document.createTextNode("/d4science.research-infrastructures.eu/" + vos.getName() + "/" + vres.getName()));
|
||||
vresEntryElement.appendChild(vresKeyElement);
|
||||
|
||||
Element vresValueElement = document.createElement("value");
|
||||
vresEntryElement.appendChild(vresValueElement);
|
||||
|
||||
Element vreScopeElement = document.createElement("scope");
|
||||
vreScopeElement.appendChild(document.createTextNode("/d4science.research-infrastructures.eu/" + vos.getName() + "/" + vres.getName()));
|
||||
vresValueElement.appendChild(vreScopeElement);
|
||||
|
||||
Element vresNameElement = document.createElement("name");
|
||||
vresNameElement.appendChild(document.createTextNode(vres.getName()));
|
||||
vresValueElement.appendChild(vresNameElement);
|
||||
|
||||
Element vresDescriptionElement = document.createElement("description");
|
||||
vresDescriptionElement.appendChild(document.createTextNode(vres.getDescription()));
|
||||
vresValueElement.appendChild(vresDescriptionElement);
|
||||
|
||||
Element vresManagerElement = document.createElement("managers");
|
||||
vresManagerElement.appendChild(document.createTextNode(vres.getManager()));
|
||||
vresValueElement.appendChild(vresManagerElement);
|
||||
|
||||
Element vresStartDateElement = document.createElement("startdate");
|
||||
vresStartDateElement.appendChild(document.createTextNode(vres.getStartDate()));
|
||||
vresValueElement.appendChild(vresStartDateElement);
|
||||
|
||||
Element vresEndDateElement = document.createElement("enddate");
|
||||
vresEndDateElement.appendChild(document.createTextNode(vres.getEndDate()));
|
||||
vresValueElement.appendChild(vresEndDateElement);
|
||||
}
|
||||
}
|
||||
gatewayKey--;
|
||||
}
|
||||
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
DOMSource source = new DOMSource(document);
|
||||
StreamResult result = new StreamResult(new File(outputXmlFilePath));
|
||||
transformer.transform(source, result);
|
||||
}
|
||||
// Other methods...
|
||||
public String extractGatewayName(String gateways) {
|
||||
if (gateways.startsWith("https://")) {
|
||||
return gateways.substring(8, gateways.indexOf("."));
|
||||
} else if (gateways.startsWith("http://")) {
|
||||
return gateways.substring(7, gateways.indexOf("."));
|
||||
} else {
|
||||
return gateways; // fallback
|
||||
}
|
||||
//System.out.println("VRE Information for VO: " + _vo + " in Gateway:\n " + _gateway);
|
||||
boolean vreFound = false; // Flag to track if VRE exists
|
||||
//ArrayList<Gateway> gatewayList = gatewaysMap.get(_gateway);
|
||||
|
||||
if (gatewaysMap.containsKey(_gateway)) {
|
||||
|
||||
Gateway gatewayItem = gatewaysMap.get(_gateway);
|
||||
ArrayList<Vos> vosList = gatewayItem.getVosList();
|
||||
if (vosList != null) {
|
||||
for (Vos vos : vosList) {
|
||||
if (vos.getName().equals(_vo)) {
|
||||
ArrayList<Vres> vresList = vos.getVresList();
|
||||
if (vresList != null) {
|
||||
for (Vres vre : vresList) {
|
||||
if (vre.getName().equals(_vre)) {
|
||||
// Print VRE information
|
||||
vre.printInfo();
|
||||
vreFound = true; // Set flag to true
|
||||
// return; // Exit method after printing information
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If execution reaches here and VRE not found, print message
|
||||
if (!vreFound) {
|
||||
System.out.println("VRE does not exist in the " + _vo + " of the " + _gateway);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Other methods...
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><genericResources>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<genericResources>
|
||||
<Resource version="0.4.x">
|
||||
<ID>68322b8f-b916-44b9-9c93-bad8cceb9106</ID>
|
||||
<Type>GenericResource</Type>
|
||||
|
@ -1090,7 +1091,7 @@
|
|||
</vos>
|
||||
</value>
|
||||
</entry>
|
||||
</gateways>
|
||||
</gateways>
|
||||
</detachedres>
|
||||
</Body>
|
||||
</Profile>
|
||||
|
|
Loading…
Reference in New Issue