|
|
|
@ -6,10 +6,11 @@ import java.util.Map;
|
|
|
|
|
import org.apache.sis.storage.DataStoreException;
|
|
|
|
|
import org.apache.sis.storage.DataStores;
|
|
|
|
|
import org.apache.sis.storage.UnsupportedStorageException;
|
|
|
|
|
import org.apache.sis.xml.XML;
|
|
|
|
|
import org.gcube.data.transfer.model.ExecutionReport;
|
|
|
|
|
import org.gcube.data.transfer.model.ExecutionReport.ExecutionReportFlag;
|
|
|
|
|
import org.gcube.data.transfer.model.PluginInvocation;
|
|
|
|
|
import org.gcube.data.transfer.plugin.AbstractPlugin;
|
|
|
|
|
import org.gcube.data.transfer.plugin.ExecutionReport;
|
|
|
|
|
import org.gcube.data.transfer.plugin.ExecutionReport.ExecutionReportFlag;
|
|
|
|
|
import org.gcube.data.transfer.plugin.fails.PluginCleanupException;
|
|
|
|
|
import org.gcube.data.transfer.plugin.fails.PluginExecutionException;
|
|
|
|
|
import org.gcube.spatial.data.geonetwork.GeoNetwork;
|
|
|
|
@ -35,7 +36,7 @@ public class SisPlugin extends AbstractPlugin {
|
|
|
|
|
@Override
|
|
|
|
|
public ExecutionReport run() throws PluginExecutionException {
|
|
|
|
|
try{
|
|
|
|
|
log.debug("Checking parameters for {} ",invocation);
|
|
|
|
|
|
|
|
|
|
Map<String,String> params=invocation.getParameters();
|
|
|
|
|
String dataStorePath=params.get(SISPluginFactory.SOURCE_PARAMETER);
|
|
|
|
|
String category=params.containsKey(SISPluginFactory.GEONETWORK_CATEGORY)?params.get(SISPluginFactory.GEONETWORK_CATEGORY):"Dataset";
|
|
|
|
@ -64,10 +65,16 @@ public class SisPlugin extends AbstractPlugin {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static final long publishMetadata(Metadata meta,String category, String stylesheet) throws Exception{
|
|
|
|
|
File tmp=File.createTempFile("tmp_meta_", ".xml");
|
|
|
|
|
|
|
|
|
|
XML.marshal(meta,tmp);
|
|
|
|
|
|
|
|
|
|
GeoNetworkPublisher publisher=GeoNetwork.get();
|
|
|
|
|
publisher.login(LoginLevel.DEFAULT);
|
|
|
|
|
GNInsertConfiguration config=publisher.getCurrentUserConfiguration(category, stylesheet);
|
|
|
|
|
config.setValidate(false);
|
|
|
|
|
return publisher.insertMetadata(config, meta);
|
|
|
|
|
long toReturn= publisher.insertMetadata(config, tmp);
|
|
|
|
|
tmp.delete();
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|