Browse Source

REPORT-44644 设计器接口开放 fix实现层级

feature/big-screen
hades 4 years ago
parent
commit
d9a770f847
  1. 37
      designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java
  2. 42
      designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java

37
designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java

@ -14,41 +14,6 @@ import java.io.OutputStream;
* @version 10.0
* Created by hades on 2020/12/23
*/
public class AbstractTemplateResource implements TemplateResource {
@Override
public InputStream readTemplate(String path) throws Exception {
return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path));
}
@Override
public OutputStream saveTemplate(FILE file) throws Exception {
return file.asOutputStream();
}
@Override
public boolean closeTemplate(String path) {
return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path);
}
@Override
public boolean delete(FILE file) {
return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath());
}
@Override
public boolean rename(String from, String to) {
return WorkContext.getCurrent().get(TplOperator.class).rename(from, to);
}
@Override
public boolean exist(String path) {
return WorkContext.getWorkResource().exist(path);
}
@Override
public boolean mkdir(String path) {
return WorkContext.getWorkResource().createDirectory(path);
}
public abstract class AbstractTemplateResource implements TemplateResource {
}

42
designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java

@ -1,5 +1,12 @@
package com.fr.design.file.impl;
import com.fr.file.FILE;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author hades
* @version 10.0
@ -7,4 +14,39 @@ package com.fr.design.file.impl;
*/
public class DefaultTemplateResource extends AbstractTemplateResource {
@Override
public InputStream readTemplate(String path) throws Exception {
return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path));
}
@Override
public OutputStream saveTemplate(FILE file) throws Exception {
return file.asOutputStream();
}
@Override
public boolean closeTemplate(String path) {
return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path);
}
@Override
public boolean delete(FILE file) {
return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath());
}
@Override
public boolean rename(String from, String to) {
return WorkContext.getCurrent().get(TplOperator.class).rename(from, to);
}
@Override
public boolean exist(String path) {
return WorkContext.getWorkResource().exist(path);
}
@Override
public boolean mkdir(String path) {
return WorkContext.getWorkResource().createDirectory(path);
}
}

Loading…
Cancel
Save