|
|
@ -3,9 +3,16 @@ package com.fr.design.file.impl; |
|
|
|
import com.fr.file.FILE; |
|
|
|
import com.fr.file.FILE; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.server.lock.TplOperator; |
|
|
|
import com.fr.workspace.server.lock.TplOperator; |
|
|
|
|
|
|
|
import com.fr.workspace.server.repository.template.TemplateRepository; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.fr.workspace.server.repository.template.AbstractTemplateSource.FROM_KEY; |
|
|
|
|
|
|
|
import static com.fr.workspace.server.repository.template.AbstractTemplateSource.TO_KEY; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author hades |
|
|
|
* @author hades |
|
|
@ -16,7 +23,7 @@ public class DefaultTemplateResource extends AbstractTemplateResource { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public InputStream readTemplate(String path) throws Exception { |
|
|
|
public InputStream readTemplate(String path) throws Exception { |
|
|
|
return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path)); |
|
|
|
return new ByteArrayInputStream(TemplateRepository.getInstance().open(path)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -26,17 +33,20 @@ public class DefaultTemplateResource extends AbstractTemplateResource { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean closeTemplate(String path) { |
|
|
|
public boolean closeTemplate(String path) { |
|
|
|
return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path); |
|
|
|
return TemplateRepository.getInstance().close(path); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean delete(FILE file) { |
|
|
|
public boolean delete(FILE file) { |
|
|
|
return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath()); |
|
|
|
return TemplateRepository.getInstance().delete(file.getPath()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean rename(String from, String to) { |
|
|
|
public boolean rename(String from, String to) { |
|
|
|
return WorkContext.getCurrent().get(TplOperator.class).rename(from, to); |
|
|
|
Map<String, String> fromTo = new HashMap<>(); |
|
|
|
|
|
|
|
fromTo.put(FROM_KEY, from); |
|
|
|
|
|
|
|
fromTo.put(TO_KEY, to); |
|
|
|
|
|
|
|
return TemplateRepository.getInstance().rename(fromTo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|