git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/sis-geotk-plugin@149181 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6de8f2e69b
commit
726811b0bd
|
@ -1,7 +1,6 @@
|
||||||
package org.gcube.data.transfer.plugins.sis;
|
package org.gcube.data.transfer.plugins.sis;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -25,7 +24,6 @@ public class SISPluginFactory extends AbstractPluginFactory<SisPlugin> {
|
||||||
static final Map<String,String> PARAMETERS_DESCRIPTION= new HashMap<String,String>();
|
static final Map<String,String> PARAMETERS_DESCRIPTION= new HashMap<String,String>();
|
||||||
|
|
||||||
static{
|
static{
|
||||||
PARAMETERS_DESCRIPTION.put(SOURCE_PARAMETER, "[String value] Absolute path of source archive file.");
|
|
||||||
PARAMETERS_DESCRIPTION.put(GEONETWORK_CATEGORY, "[String value] GeoNetwork category for publiehd metadata. Default is 'Dataset'.");
|
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_'.");
|
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
|
@Override
|
||||||
public void checkInvocation(PluginInvocation arg0) throws ParameterException {
|
public PluginInvocation checkInvocation(PluginInvocation arg0,String transferredFile) throws ParameterException {
|
||||||
log.debug("Checking parameters for {} ",arg0);
|
log.debug("Setting default parameters for {} ",arg0);
|
||||||
Map<String,String> params=arg0.getParameters();
|
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);
|
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.");
|
if(source==null||source.length()==0) throw new ParameterException(SOURCE_PARAMETER+" cannot be null.");
|
||||||
try{
|
try{
|
||||||
File f=new File(source);
|
File f=new File(source);
|
||||||
|
@ -52,6 +55,10 @@ public class SISPluginFactory extends AbstractPluginFactory<SisPlugin> {
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
throw new ParameterException("Unable to access source file ",e);
|
throw new ParameterException("Unable to access source file ",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arg0.setParameters(params);
|
||||||
|
return arg0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class SisPlugin extends AbstractPlugin {
|
||||||
|
|
||||||
Map<String,String> params=invocation.getParameters();
|
Map<String,String> params=invocation.getParameters();
|
||||||
String dataStorePath=params.get(SISPluginFactory.SOURCE_PARAMETER);
|
String dataStorePath=params.get(SISPluginFactory.SOURCE_PARAMETER);
|
||||||
String category=params.containsKey(SISPluginFactory.GEONETWORK_CATEGORY)?params.get(SISPluginFactory.GEONETWORK_CATEGORY):"Dataset";
|
String category=params.get(SISPluginFactory.GEONETWORK_CATEGORY);
|
||||||
String stylesheet=params.containsKey(SISPluginFactory.GEONETWORK_STYLESHEET)?params.get(SISPluginFactory.GEONETWORK_STYLESHEET):"_none_";
|
String stylesheet=params.get(SISPluginFactory.GEONETWORK_STYLESHEET);
|
||||||
File dataStore=new File(dataStorePath);
|
File dataStore=new File(dataStorePath);
|
||||||
log.debug("Extracting meta from {} ",dataStore.getAbsolutePath());
|
log.debug("Extracting meta from {} ",dataStore.getAbsolutePath());
|
||||||
Metadata meta=getMetaFromFile(dataStore);
|
Metadata meta=getMetaFromFile(dataStore);
|
||||||
|
|
Loading…
Reference in New Issue