Fabio Sinibaldi 7 years ago
parent 6de8f2e69b
commit 726811b0bd

@ -1,7 +1,6 @@
package org.gcube.data.transfer.plugins.sis;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@ -24,8 +23,7 @@ public class SISPluginFactory extends AbstractPluginFactory<SisPlugin> {
static final Map<String,String> PARAMETERS_DESCRIPTION= new HashMap<String,String>();
static{
PARAMETERS_DESCRIPTION.put(SOURCE_PARAMETER, "[String value] Absolute path of source archive file.");
static{
PARAMETERS_DESCRIPTION.put(GEONETWORK_CATEGORY, "[String value] GeoNetwork category for publiehd metadata. Default is 'Dataset'.");
PARAMETERS_DESCRIPTION.put(GEONETWORK_STYLESHEET, "[String value] GeoNetwork stylesheet for publiehd metadata. Default is '_none_'.");
}
@ -36,12 +34,17 @@ public class SISPluginFactory extends AbstractPluginFactory<SisPlugin> {
}
@Override
public void checkInvocation(PluginInvocation arg0) throws ParameterException {
log.debug("Checking parameters for {} ",arg0);
public PluginInvocation checkInvocation(PluginInvocation arg0,String transferredFile) throws ParameterException {
log.debug("Setting default parameters for {} ",arg0);
Map<String,String> params=arg0.getParameters();
if(params==null||params.isEmpty()||(!params.containsKey(SOURCE_PARAMETER)))
throw new ParameterException(SOURCE_PARAMETER+" is mandatory");
if(params==null||params.isEmpty()) params=new HashMap<String,String>();
if(!params.containsKey(SOURCE_PARAMETER)) params.put(SOURCE_PARAMETER, transferredFile);
if(!params.containsKey(GEONETWORK_CATEGORY)) params.put(GEONETWORK_CATEGORY, "Dataset");
if(!params.containsKey(GEONETWORK_STYLESHEET)) params.put(GEONETWORK_STYLESHEET, "_none_");
String source=params.get(SOURCE_PARAMETER);
log.debug("Checking access to source {} ",source);
if(source==null||source.length()==0) throw new ParameterException(SOURCE_PARAMETER+" cannot be null.");
try{
File f=new File(source);
@ -52,6 +55,10 @@ public class SISPluginFactory extends AbstractPluginFactory<SisPlugin> {
}catch(Exception e){
throw new ParameterException("Unable to access source file ",e);
}
arg0.setParameters(params);
return arg0;
}
@Override

@ -39,8 +39,8 @@ public class SisPlugin extends AbstractPlugin {
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";
String stylesheet=params.containsKey(SISPluginFactory.GEONETWORK_STYLESHEET)?params.get(SISPluginFactory.GEONETWORK_STYLESHEET):"_none_";
String category=params.get(SISPluginFactory.GEONETWORK_CATEGORY);
String stylesheet=params.get(SISPluginFactory.GEONETWORK_STYLESHEET);
File dataStore=new File(dataStorePath);
log.debug("Extracting meta from {} ",dataStore.getAbsolutePath());
Metadata meta=getMetaFromFile(dataStore);

Loading…
Cancel
Save