diff --git a/src/main/java/org/gcube/data/transfer/model/plugins/thredds/CatalogCollection.java b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/CatalogCollection.java new file mode 100644 index 0000000..64141ac --- /dev/null +++ b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/CatalogCollection.java @@ -0,0 +1,28 @@ +package org.gcube.data.transfer.model.plugins.thredds; + +import java.util.HashSet; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class CatalogCollection { + + private String name; + private String ID; + + private HashSet linkedCatalogs; +} diff --git a/src/main/java/org/gcube/data/transfer/model/plugins/thredds/DataSetRoot.java b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/DataSetRoot.java new file mode 100644 index 0000000..9b3b239 --- /dev/null +++ b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/DataSetRoot.java @@ -0,0 +1,25 @@ +package org.gcube.data.transfer.model.plugins.thredds; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class DataSetRoot { + + private String path; + private String location; + private long count; +} diff --git a/src/main/java/org/gcube/data/transfer/model/plugins/thredds/DataSetScan.java b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/DataSetScan.java new file mode 100644 index 0000000..0f9b2a7 --- /dev/null +++ b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/DataSetScan.java @@ -0,0 +1,27 @@ +package org.gcube.data.transfer.model.plugins.thredds; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class DataSetScan { + + private String name; + private String path; + private String location; + private String ID; + +} diff --git a/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsCatalog.java b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsCatalog.java new file mode 100644 index 0000000..53a6e21 --- /dev/null +++ b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsCatalog.java @@ -0,0 +1,32 @@ +package org.gcube.data.transfer.model.plugins.thredds; + +import java.util.HashSet; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class ThreddsCatalog{ + private String ID; + private String catalogFile; + private String title; + private String name; + + private DataSetRoot declaredDataSetRoot; + private HashSet declaredDataSetScan; + private CatalogCollection subCatalogs; + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/data/transfer/model/plugins/ThreddsInfo.java b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsInfo.java similarity index 52% rename from src/main/java/org/gcube/data/transfer/model/plugins/ThreddsInfo.java rename to src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsInfo.java index b8daa66..90a0902 100644 --- a/src/main/java/org/gcube/data/transfer/model/plugins/ThreddsInfo.java +++ b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsInfo.java @@ -1,6 +1,4 @@ -package org.gcube.data.transfer.model.plugins; - -import java.util.HashSet; +package org.gcube.data.transfer.model.plugins.thredds; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -21,26 +19,8 @@ import lombok.ToString; @XmlAccessorType(XmlAccessType.FIELD) public class ThreddsInfo { - @Getter - @Setter - @ToString - @NoArgsConstructor - @AllArgsConstructor - @XmlRootElement - @XmlAccessorType(XmlAccessType.FIELD) - public static class ThreddsCatalog{ - private String ID; - private String name; - private String title; - private String catalogFile; - private String localPath; - private String catalogUrl; - private String catalogFileUrl; - } - - private String hostname; private String localBasePath; private String instanceBaseUrl; - private HashSet catalogs; + private ThreddsCatalog catalog; } diff --git a/src/test/java/org/gcube/data/transfer/test/MarshallUnmarshalTest.java b/src/test/java/org/gcube/data/transfer/test/MarshallUnmarshalTest.java index 503d434..e1f80c5 100644 --- a/src/test/java/org/gcube/data/transfer/test/MarshallUnmarshalTest.java +++ b/src/test/java/org/gcube/data/transfer/test/MarshallUnmarshalTest.java @@ -12,6 +12,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.UUID; import javax.xml.bind.JAXBContext; @@ -25,18 +26,23 @@ import javax.xml.transform.stream.StreamSource; import org.gcube.data.transfer.model.Destination; import org.gcube.data.transfer.model.ExecutionReport; +import org.gcube.data.transfer.model.ExecutionReport.ExecutionReportFlag; import org.gcube.data.transfer.model.PluginDescription; import org.gcube.data.transfer.model.PluginInvocation; import org.gcube.data.transfer.model.TransferCapabilities; import org.gcube.data.transfer.model.TransferRequest; import org.gcube.data.transfer.model.TransferTicket; -import org.gcube.data.transfer.model.ExecutionReport.ExecutionReportFlag; import org.gcube.data.transfer.model.TransferTicket.Status; import org.gcube.data.transfer.model.options.DirectTransferOptions; import org.gcube.data.transfer.model.options.FileUploadOptions; import org.gcube.data.transfer.model.options.HttpDownloadOptions; import org.gcube.data.transfer.model.options.TransferOptions; import org.gcube.data.transfer.model.options.TransferOptions.TransferMethod; +import org.gcube.data.transfer.model.plugins.thredds.CatalogCollection; +import org.gcube.data.transfer.model.plugins.thredds.DataSetRoot; +import org.gcube.data.transfer.model.plugins.thredds.DataSetScan; +import org.gcube.data.transfer.model.plugins.thredds.ThreddsCatalog; +import org.gcube.data.transfer.model.plugins.thredds.ThreddsInfo; import org.gcube.data.transfer.model.settings.DirectTransferSettings; import org.gcube.data.transfer.model.settings.FileUploadSettings; import org.gcube.data.transfer.model.settings.HttpDownloadSettings; @@ -44,8 +50,6 @@ import org.gcube.data.transfer.model.utils.DateWrapper; import org.junit.BeforeClass; import org.junit.Test; -import junit.framework.Assert; - public class MarshallUnmarshalTest { static JAXBContext ctx =null; @@ -55,7 +59,8 @@ public class MarshallUnmarshalTest { ctx = JAXBContext.newInstance( TransferRequest.class, TransferTicket.class, - TransferCapabilities.class); + TransferCapabilities.class, + ThreddsInfo.class); } @@ -69,6 +74,8 @@ public class MarshallUnmarshalTest { print(createTicket(createRequest(TransferMethod.HTTPDownload))); print(createTicket(createRequest(TransferMethod.DirectTransfer))); print(createTicket(createRequest(TransferMethod.FileUpload))); + + print(getThreddsInfo()); } @Test @@ -80,6 +87,7 @@ public class MarshallUnmarshalTest { assertTrue(roundTrip(createTicket(createRequest(TransferMethod.HTTPDownload)))); assertTrue(roundTrip(createTicket(createRequest(TransferMethod.DirectTransfer)))); assertTrue(roundTrip(createTicket(createRequest(TransferMethod.FileUpload)))); + } @@ -92,6 +100,7 @@ public class MarshallUnmarshalTest { System.out.println(createTicket(createRequest(TransferMethod.HTTPDownload))); System.out.println(createTicket(createRequest(TransferMethod.DirectTransfer))); System.out.println(createTicket(createRequest(TransferMethod.FileUpload))); + System.out.println(getThreddsInfo()); } public static boolean roundTrip(Object obj){ @@ -248,4 +257,39 @@ public class MarshallUnmarshalTest { private ExecutionReport createExecutionReport(){ return new ExecutionReport(createPluginInvocation(), "Executed", ExecutionReportFlag.SUCCESS); } + + + private ThreddsInfo getThreddsInfo() { + ThreddsInfo info=new ThreddsInfo(); + info.setHostname("somehwere.over.the.rainbow"); + info.setInstanceBaseUrl("http://"+info.getHostname()+"/thredds"); + info.setLocalBasePath("/tmp"); + + ThreddsCatalog mainCatalog=new ThreddsCatalog(); + mainCatalog.setCatalogFile("catalog.xml"); + mainCatalog.setDeclaredDataSetRoot(new DataSetRoot("public","public/genericRoot",1000l)); + mainCatalog.setDeclaredDataSetScan(new HashSet()); + mainCatalog.getDeclaredDataSetScan().add(new DataSetScan("generic scan","/public","public/genericScanned","ROOT-DatasetScan")); + + CatalogCollection collection=new CatalogCollection(); + collection.setID("Catalog_VREs"); + collection.setName("Catalogs for VRE"); + collection.setLinkedCatalogs(new HashSet()); + ThreddsCatalog subCatalog=new ThreddsCatalog(); + //info from catalogRef + subCatalog.setCatalogFile("linked.xml"); + subCatalog.setID("TUNA_ATLAS_VRE_CATALOG"); + subCatalog.setName("ThreddsCatalog for tuna atlas"); + subCatalog.setTitle("This is a catalog bla bla"); + //info from catalog file + subCatalog.setDeclaredDataSetRoot(new DataSetRoot("/tuna","vres/tuna",1000l)); + subCatalog.setDeclaredDataSetScan(new HashSet()); + subCatalog.getDeclaredDataSetScan().add(new DataSetScan("tuna scan","/tuna","vres/tunaScanned","TUNA-DatasetScan")); + collection.getLinkedCatalogs().add(subCatalog); + mainCatalog.setSubCatalogs(collection); + + info.setCatalog(mainCatalog); + return info; + } + }