Commit fc0e1308 authored by Pietro Braghieri's avatar Pietro Braghieri

remove quotes from --xml-fei because seems to be not supported

parent 369195a4
/*******************************************************************************
* Copyright (C) 2019 Fondazione Bruno Kessler.
* All rights reserved.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package eu.fbk.tools.adapter.xsap;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import eu.fbk.tools.adapter.ToolCommand;
import eu.fbk.tools.adapter.ToolFunction;
import eu.fbk.tools.adapter.ToolFunctionParameter;
import eu.fbk.tools.adapter.ToolParameterConstants;
/**
* The Class ExpandFei.
*
* @author braghieri
*/
public class ExpandFei extends ToolFunction
{
private static final Logger logger = LoggerFactory.getLogger(ExpandFei.class);
public static final String FUNCTION_NAME = "expand_fault_extensions";
public final static String TOOL_NAME = "FaultExtensionExpander";
private URI faultExtensions;
public ExpandFei() {
this(null);
}
public ExpandFei(URI faultExtensions) {
super(FUNCTION_NAME);
setFaultExtensions(faultExtensions);
}
@Override
public String getToolName() {
return TOOL_NAME;
}
public URI getFaultExtensions() {
return faultExtensions;
}
public void setFaultExtensions(URI faultExtensions)
{
if( faultExtensions != null && StringUtils.isBlank(faultExtensions.getScheme()) )
{
this.faultExtensions = new File(faultExtensions.getPath()).toURI();
}
else
{
this.faultExtensions = faultExtensions;
}
}
@Override
public List<ToolFunctionParameter> getParameters()
{
final List<ToolFunctionParameter> parameters = super.getParameters();
if( faultExtensions != null )
{
parameters.add(new ToolFunctionParameter(ToolParameterConstants.PARAM_FAULT_EXTENSIONS, faultExtensions.toString(), true));
}
return parameters;
}
@Override
protected void setParameter(ToolFunctionParameter parameter)
{
switch( parameter.name )
{
case ToolParameterConstants.PARAM_FAULT_EXTENSIONS:
try
{
faultExtensions = new URI(parameter.value);
}
catch (URISyntaxException e)
{
logger.error("Invalid " + parameter.name +": " + parameter.value == null ? "null value" : parameter.value);
}
break;
default:
super.setParameter(parameter);
break;
}
}
@Override
protected void prepareCommands()
{
final ToolCommand command = new ToolCommand();
command.addArgument("-p","dummy");
command.addArgument("--xml-fei",quote(getLocalFile(faultExtensions)));
command.addArgument("-d",".");
commands.add(command);
final String faultExtensionsFileName = "expanded_" + new File(getLocalFile(faultExtensions)).getName().replace(".fei", ".xml");
final File faultExtensionsFile = new File(getSessionWorkspaceDir(),faultExtensionsFileName);
setResultFile(faultExtensionsFile.toString());
}
@Override
public boolean validateParameters()
{
// try
// {
// final DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
// final Document document = parser.parse(new File(faultExtensions));
//
// // create a SchemaFactory capable of understanding WXS schemas
// final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
//
// final InputStream is = getClass().getResourceAsStream("/fe.xsd");
//
// // load a WXS schema, represented by a Schema instance
// final Source schemaFile = new StreamSource(is);
// final Schema schema = factory.newSchema(schemaFile);
//
// // create a Validator instance, which can be used to validate an instance document
// final Validator validator = schema.newValidator();
//
// // validate the DOM tree
// validator.validate(new DOMSource(document));
// }
// catch (SAXException | ParserConfigurationException | IOException e)
// {
// return false;
// }
return super.validateParameters();
}
}
/*******************************************************************************
* Copyright (C) 2019 Fondazione Bruno Kessler.
* All rights reserved.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package eu.fbk.tools.adapter.xsap;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import eu.fbk.tools.adapter.ToolCommand;
import eu.fbk.tools.adapter.ToolFunction;
import eu.fbk.tools.adapter.ToolFunctionParameter;
import eu.fbk.tools.adapter.ToolParameterConstants;
/**
* The Class ExpandFei.
*
* @author braghieri
*/
public class ExpandFei extends ToolFunction
{
private static final Logger logger = LoggerFactory.getLogger(ExpandFei.class);
public static final String FUNCTION_NAME = "expand_fault_extensions";
public final static String TOOL_NAME = "FaultExtensionExpander";
private URI faultExtensions;
public ExpandFei() {
this(null);
}
public ExpandFei(URI faultExtensions) {
super(FUNCTION_NAME);
setFaultExtensions(faultExtensions);
}
@Override
public String getToolName() {
return TOOL_NAME;
}
public URI getFaultExtensions() {
return faultExtensions;
}
public void setFaultExtensions(URI faultExtensions)
{
if( faultExtensions != null && StringUtils.isBlank(faultExtensions.getScheme()) )
{
this.faultExtensions = new File(faultExtensions.getPath()).toURI();
}
else
{
this.faultExtensions = faultExtensions;
}
}
@Override
public List<ToolFunctionParameter> getParameters()
{
final List<ToolFunctionParameter> parameters = super.getParameters();
if( faultExtensions != null )
{
parameters.add(new ToolFunctionParameter(ToolParameterConstants.PARAM_FAULT_EXTENSIONS, faultExtensions.toString(), true));
}
return parameters;
}
@Override
protected void setParameter(ToolFunctionParameter parameter)
{
switch( parameter.name )
{
case ToolParameterConstants.PARAM_FAULT_EXTENSIONS:
try
{
faultExtensions = new URI(parameter.value);
}
catch (URISyntaxException e)
{
logger.error("Invalid " + parameter.name +": " + parameter.value == null ? "null value" : parameter.value);
}
break;
default:
super.setParameter(parameter);
break;
}
}
@Override
protected void prepareCommands()
{
final ToolCommand command = new ToolCommand();
command.addArgument("-p","dummy");
command.addArgument("--xml-fei",getLocalFile(faultExtensions));
command.addArgument("-d",".");
commands.add(command);
final String faultExtensionsFileName = "expanded_" + new File(getLocalFile(faultExtensions)).getName().replace(".fei", ".xml");
final File faultExtensionsFile = new File(getSessionWorkspaceDir(),faultExtensionsFileName);
setResultFile(faultExtensionsFile.toString());
}
@Override
public boolean validateParameters()
{
// try
// {
// final DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
// final Document document = parser.parse(new File(faultExtensions));
//
// // create a SchemaFactory capable of understanding WXS schemas
// final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
//
// final InputStream is = getClass().getResourceAsStream("/fe.xsd");
//
// // load a WXS schema, represented by a Schema instance
// final Source schemaFile = new StreamSource(is);
// final Schema schema = factory.newSchema(schemaFile);
//
// // create a Validator instance, which can be used to validate an instance document
// final Validator validator = schema.newValidator();
//
// // validate the DOM tree
// validator.validate(new DOMSource(document));
// }
// catch (SAXException | ParserConfigurationException | IOException e)
// {
// return false;
// }
return super.validateParameters();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment