Fabio Sinibaldi 2017-12-06 18:21:00 +00:00
parent 99b29024e8
commit c56a8acbb5
6 changed files with 162 additions and 26 deletions

View File

@ -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<ThreddsCatalog> linkedCatalogs;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<DataSetScan> declaredDataSetScan;
private CatalogCollection subCatalogs;
}

View File

@ -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<ThreddsCatalog> catalogs;
private ThreddsCatalog catalog;
}

View File

@ -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<DataSetScan>());
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>());
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<DataSetScan>());
subCatalog.getDeclaredDataSetScan().add(new DataSetScan("tuna scan","/tuna","vres/tunaScanned","TUNA-DatasetScan"));
collection.getLinkedCatalogs().add(subCatalog);
mainCatalog.setSubCatalogs(collection);
info.setCatalog(mainCatalog);
return info;
}
}