[New] XmlExportModelService can now export to absolute path
This commit is contained in:
parent
193b76ed60
commit
f46e72bbdb
|
@ -24,6 +24,7 @@ public class XmlExportModelArgument extends ServiceArgument {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public String modelFileName;
|
public String modelFileName;
|
||||||
|
public boolean external;
|
||||||
public boolean overwrite;
|
public boolean overwrite;
|
||||||
public boolean multiFile;
|
public boolean multiFile;
|
||||||
public boolean doOrders = true;
|
public boolean doOrders = true;
|
||||||
|
@ -36,6 +37,9 @@ public class XmlExportModelArgument extends ServiceArgument {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("XmlExportModelArgument [ ");
|
builder.append("XmlExportModelArgument [ ");
|
||||||
|
|
||||||
|
builder.append("external=");
|
||||||
|
builder.append(this.external);
|
||||||
|
|
||||||
builder.append("modelFileName=");
|
builder.append("modelFileName=");
|
||||||
builder.append(this.modelFileName);
|
builder.append(this.modelFileName);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.io.File;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import li.strolch.command.XmlExportModelCommand;
|
import li.strolch.command.XmlExportModelCommand;
|
||||||
import li.strolch.exception.StrolchException;
|
|
||||||
import li.strolch.model.ModelStatistics;
|
import li.strolch.model.ModelStatistics;
|
||||||
import li.strolch.persistence.api.StrolchTransaction;
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
import li.strolch.service.api.AbstractService;
|
import li.strolch.service.api.AbstractService;
|
||||||
|
@ -43,14 +42,32 @@ public class XmlExportModelService extends AbstractService<XmlExportModelArgumen
|
||||||
|
|
||||||
DBC.PRE.assertNotEmpty("Modelfile must be set!", arg.modelFileName);
|
DBC.PRE.assertNotEmpty("Modelfile must be set!", arg.modelFileName);
|
||||||
|
|
||||||
File dataPath = getRuntimeConfiguration().getDataPath();
|
File modelFile;
|
||||||
File modelFile = new File(dataPath, arg.modelFileName);
|
|
||||||
if (modelFile.exists()) {
|
|
||||||
|
|
||||||
|
File dataPath = getRuntimeConfiguration().getDataPath();
|
||||||
|
File modelFileName = new File(arg.modelFileName);
|
||||||
|
if (modelFileName.isAbsolute()) {
|
||||||
|
if (!arg.external)
|
||||||
|
return ServiceResult.error("Model file is absolute, yet service argument is not marked as external!");
|
||||||
|
modelFile = modelFileName;
|
||||||
|
} else {
|
||||||
|
if (arg.external)
|
||||||
|
return ServiceResult.error("Model file is not absolute, yet service argument is marked as externa!");
|
||||||
|
|
||||||
|
modelFile = new File(dataPath, arg.modelFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelFile.exists()) {
|
||||||
if (!arg.overwrite) {
|
if (!arg.overwrite) {
|
||||||
String msg = "Model File already exists with name {0} in data path {1}"; //$NON-NLS-1$
|
if (modelFileName.isAbsolute()) {
|
||||||
msg = MessageFormat.format(msg, arg.modelFileName, dataPath);
|
String msg = "Model File already exists at path {0}"; //$NON-NLS-1$
|
||||||
throw new StrolchException(msg);
|
msg = MessageFormat.format(msg, arg.modelFileName);
|
||||||
|
return ServiceResult.error(msg);
|
||||||
|
} else {
|
||||||
|
String msg = "Model File already exists with name {0} in data path {1}"; //$NON-NLS-1$
|
||||||
|
msg = MessageFormat.format(msg, arg.modelFileName, dataPath);
|
||||||
|
return ServiceResult.error(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue