|
|
@ -91,7 +91,7 @@ public class TemplateUtils { |
|
|
|
protected Void doInBackground() throws Exception { |
|
|
|
protected Void doInBackground() throws Exception { |
|
|
|
// 读取模板数据
|
|
|
|
// 读取模板数据
|
|
|
|
byte[] content = getTemplateData(createByEditingTemplate, oldPath); |
|
|
|
byte[] content = getTemplateData(createByEditingTemplate, oldPath); |
|
|
|
try(OutputStream out = file.asOutputStream()) { |
|
|
|
try (OutputStream out = file.asOutputStream()) { |
|
|
|
// 加锁
|
|
|
|
// 加锁
|
|
|
|
WorkContext.getCurrent().get(TplOperator.class).saveAs(file.getPath()); |
|
|
|
WorkContext.getCurrent().get(TplOperator.class).saveAs(file.getPath()); |
|
|
|
out.write(content); |
|
|
|
out.write(content); |
|
|
@ -126,17 +126,18 @@ public class TemplateUtils { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param readCurrentEditingTemplate 是否读取当前编辑模板 |
|
|
|
* @param readCurrentEditingTemplate 是否读取当前编辑模板 |
|
|
|
* @param path 模板路径 |
|
|
|
* @param path 模板路径 |
|
|
|
* @return |
|
|
|
* @return 模板文件数据 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static byte[] getTemplateData(boolean readCurrentEditingTemplate, String path) throws Exception { |
|
|
|
private static byte[] getTemplateData(boolean readCurrentEditingTemplate, String path) throws Exception { |
|
|
|
byte[] content = new byte[0]; |
|
|
|
byte[] content = new byte[0]; |
|
|
|
if (readCurrentEditingTemplate) { |
|
|
|
if (readCurrentEditingTemplate) { |
|
|
|
// 从当前编辑模板中生成备份文件
|
|
|
|
// 从当前编辑模板中读取模板文件数据
|
|
|
|
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
if (JTemplate.isValid(template)) { |
|
|
|
if (JTemplate.isValid(template)) { |
|
|
|
content = template.exportData(); |
|
|
|
content = template.exportData(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
// 从给定的模板路径中读取模板文件数据
|
|
|
|
content = WorkContext.getWorkResource().readFully(path); |
|
|
|
content = WorkContext.getWorkResource().readFully(path); |
|
|
|
} |
|
|
|
} |
|
|
|
if (ArrayUtils.isEmpty(content)) { |
|
|
|
if (ArrayUtils.isEmpty(content)) { |
|
|
|