Always ensure that filename and name of the file inside the xml are

consistent!
Issue FDA-35
This commit is contained in:
2013-09-23 10:56:20 +02:00
parent a5da9a2527
commit 73107a4799
2 changed files with 21 additions and 1 deletions

View File

@@ -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);
}

View 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());
}
/**