Always ensure that filename and name of the file inside the xml are
consistent! Issue FDA-35
This commit is contained in:
@@ -112,6 +112,15 @@ public class ModelManager {
|
||||
|
||||
try{
|
||||
Configuration model = (Configuration) u.unmarshal(bsource, Configuration.class).getValue();
|
||||
|
||||
// Ensure that the filename inside the xml file is always the file name
|
||||
Data d = model.getData();
|
||||
if(d==null){
|
||||
d = new Data();
|
||||
model.setData(d);
|
||||
}
|
||||
d.setFileName(file.getName().replaceAll("\\.xml$", ""));
|
||||
|
||||
return (model);
|
||||
}
|
||||
catch(UnmarshalException e){
|
||||
@@ -143,6 +152,15 @@ public class ModelManager {
|
||||
|
||||
try{
|
||||
Configuration model = (Configuration) u.unmarshal(new StreamSource(file), Configuration.class).getValue();
|
||||
|
||||
// Ensure that the filename inside the xml file is always the file name
|
||||
Data d = model.getData();
|
||||
if(d==null){
|
||||
d = new Data();
|
||||
model.setData(d);
|
||||
}
|
||||
d.setFileName(file.getName().replaceAll("\\.xml$", ""));
|
||||
|
||||
return (model);
|
||||
}
|
||||
catch(UnmarshalException e){
|
||||
@@ -180,7 +198,7 @@ public class ModelManager {
|
||||
d = new Data();
|
||||
model.setData(d);
|
||||
}
|
||||
d.setFileName(file.getName());
|
||||
d.setFileName(file.getName().replaceAll("\\.xml$", ""));
|
||||
|
||||
m.marshal( new JAXBElement<Configuration>(qname, Configuration.class, model ), file);
|
||||
}
|
||||
|
||||
@@ -75,6 +75,8 @@ public class ModelManagerTest {
|
||||
URL url = this.getClass().getClassLoader().getResource("home/scans/templates/scan1d.xml");
|
||||
Configuration c = ModelManager.unmarshall(new File(new URI(url.toString())));
|
||||
logger.info(""+c.getData().getFormat());
|
||||
|
||||
logger.info("FILENAME: "+c.getData().getFileName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user