|
|
@ -22,10 +22,12 @@ import java.io.OutputStream; |
|
|
|
public class FileNodeFILE implements FILE { |
|
|
|
public class FileNodeFILE implements FILE { |
|
|
|
|
|
|
|
|
|
|
|
private FileNode node; |
|
|
|
private FileNode node; |
|
|
|
|
|
|
|
|
|
|
|
// carl:记录下FILE对应的运行环境,每次创建都设置下当前的运行环境
|
|
|
|
// carl:记录下FILE对应的运行环境,每次创建都设置下当前的运行环境
|
|
|
|
private String envPath; |
|
|
|
private String envPath; |
|
|
|
|
|
|
|
|
|
|
|
public FileNodeFILE(FileNodeFILE parent, String name, boolean isDir) { |
|
|
|
public FileNodeFILE(FileNodeFILE parent, String name, boolean isDir) { |
|
|
|
|
|
|
|
|
|
|
|
FileNode fn = parent.node; |
|
|
|
FileNode fn = parent.node; |
|
|
|
String parentDir; |
|
|
|
String parentDir; |
|
|
|
if (fn.isDirectory()) { |
|
|
|
if (fn.isDirectory()) { |
|
|
@ -39,16 +41,19 @@ public class FileNodeFILE implements FILE { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public FileNodeFILE(FileNode node) { |
|
|
|
public FileNodeFILE(FileNode node) { |
|
|
|
|
|
|
|
|
|
|
|
this.node = node; |
|
|
|
this.node = node; |
|
|
|
this.envPath = WorkContext.getCurrent().getPath(); |
|
|
|
this.envPath = WorkContext.getCurrent().getPath(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public FileNodeFILE(String envPath) { |
|
|
|
public FileNodeFILE(String envPath) { |
|
|
|
|
|
|
|
|
|
|
|
this.node = null; |
|
|
|
this.node = null; |
|
|
|
this.envPath = envPath; |
|
|
|
this.envPath = envPath; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public FileNodeFILE(FileNode node, String envPath) { |
|
|
|
public FileNodeFILE(FileNode node, String envPath) { |
|
|
|
|
|
|
|
|
|
|
|
this.node = node; |
|
|
|
this.node = node; |
|
|
|
this.envPath = envPath; |
|
|
|
this.envPath = envPath; |
|
|
|
} |
|
|
|
} |
|
|
@ -59,7 +64,8 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 返回后缀 |
|
|
|
* @return 返回后缀 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String prefix() { |
|
|
|
public String prefix() { |
|
|
|
if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebReportPath())) { |
|
|
|
|
|
|
|
|
|
|
|
if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebRootPath())) { |
|
|
|
return FILEFactory.WEBREPORT_PREFIX; |
|
|
|
return FILEFactory.WEBREPORT_PREFIX; |
|
|
|
} |
|
|
|
} |
|
|
|
return FILEFactory.ENV_PREFIX; |
|
|
|
return FILEFactory.ENV_PREFIX; |
|
|
@ -69,6 +75,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String getEnvPath() { |
|
|
|
public String getEnvPath() { |
|
|
|
|
|
|
|
|
|
|
|
return this.envPath; |
|
|
|
return this.envPath; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -78,6 +85,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 是则返回true |
|
|
|
* @return 是则返回true |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isDirectory() { |
|
|
|
public boolean isDirectory() { |
|
|
|
|
|
|
|
|
|
|
|
return ComparatorUtils.equals(node, null) ? true : node.isDirectory(); |
|
|
|
return ComparatorUtils.equals(node, null) ? true : node.isDirectory(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -85,6 +93,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String getName() { |
|
|
|
public String getName() { |
|
|
|
|
|
|
|
|
|
|
|
if (node == null) { |
|
|
|
if (node == null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
@ -100,6 +109,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Icon getIcon() { |
|
|
|
public Icon getIcon() { |
|
|
|
|
|
|
|
|
|
|
|
if (node == null) { |
|
|
|
if (node == null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
@ -115,6 +125,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String getPath() { |
|
|
|
public String getPath() { |
|
|
|
|
|
|
|
|
|
|
|
if (node == null) { |
|
|
|
if (node == null) { |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
@ -126,6 +137,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @param path |
|
|
|
* @param path |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setPath(String path) { |
|
|
|
public void setPath(String path) { |
|
|
|
|
|
|
|
|
|
|
|
node.setEnvPath(path); |
|
|
|
node.setEnvPath(path); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -133,6 +145,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public FILE getParent() { |
|
|
|
public FILE getParent() { |
|
|
|
|
|
|
|
|
|
|
|
if (node == null) { |
|
|
|
if (node == null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
@ -146,6 +159,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 文件组 |
|
|
|
* @return 文件组 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public FILE[] listFiles() { |
|
|
|
public FILE[] listFiles() { |
|
|
|
|
|
|
|
|
|
|
|
if (ComparatorUtils.equals(node, null)) { |
|
|
|
if (ComparatorUtils.equals(node, null)) { |
|
|
|
node = new FileNode(CoreConstants.SEPARATOR, true); |
|
|
|
node = new FileNode(CoreConstants.SEPARATOR, true); |
|
|
|
//return new FILE[0];
|
|
|
|
//return new FILE[0];
|
|
|
@ -178,10 +192,16 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 返回文件节点 |
|
|
|
* @return 返回文件节点 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private FileNode[] listFile(String rootFilePath) { |
|
|
|
private FileNode[] listFile(String rootFilePath) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
if (ComparatorUtils.equals(envPath, FRContext.getCommonOperator().getWebRootPath())) { |
|
|
|
|
|
|
|
return FRContext.getFileNodes().listWebRootFile(rootFilePath); |
|
|
|
|
|
|
|
} else { |
|
|
|
return FRContext.getFileNodes().list(rootFilePath); |
|
|
|
return FRContext.getFileNodes().list(rootFilePath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
return new FileNode[0]; |
|
|
|
return new FileNode[0]; |
|
|
|
} |
|
|
|
} |
|
|
@ -193,6 +213,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 创建成功返回true |
|
|
|
* @return 创建成功返回true |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean createFolder(String name) { |
|
|
|
public boolean createFolder(String name) { |
|
|
|
|
|
|
|
|
|
|
|
if (ComparatorUtils.equals(node, null) || !node.isDirectory()) { |
|
|
|
if (ComparatorUtils.equals(node, null) || !node.isDirectory()) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -211,6 +232,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 文件被锁返回true |
|
|
|
* @return 文件被锁返回true |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isLocked() { |
|
|
|
public boolean isLocked() { |
|
|
|
|
|
|
|
|
|
|
|
if (node == null) { |
|
|
|
if (node == null) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -229,6 +251,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 文件存在返回 true |
|
|
|
* @return 文件存在返回 true |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean exists() { |
|
|
|
public boolean exists() { |
|
|
|
|
|
|
|
|
|
|
|
if (node == null) { |
|
|
|
if (node == null) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -251,6 +274,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 是报表当前环境返回true |
|
|
|
* @return 是报表当前环境返回true |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isCurrentEnv() { |
|
|
|
public boolean isCurrentEnv() { |
|
|
|
|
|
|
|
|
|
|
|
return ComparatorUtils.equals(WorkContext.getCurrent().getPath(), envPath); |
|
|
|
return ComparatorUtils.equals(WorkContext.getCurrent().getPath(), envPath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -260,6 +284,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 成功返回true |
|
|
|
* @return 成功返回true |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean mkfile() { |
|
|
|
public boolean mkfile() { |
|
|
|
|
|
|
|
|
|
|
|
if (node == null) { |
|
|
|
if (node == null) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -279,6 +304,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public InputStream asInputStream() throws Exception { |
|
|
|
public InputStream asInputStream() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
if (node == null) { |
|
|
|
if (node == null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
@ -302,6 +328,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public OutputStream asOutputStream() throws Exception { |
|
|
|
public OutputStream asOutputStream() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
if (ComparatorUtils.equals(node, null)) { |
|
|
|
if (ComparatorUtils.equals(node, null)) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
@ -323,6 +350,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void closeTemplate() throws Exception { |
|
|
|
public void closeTemplate() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
if (node == null) { |
|
|
|
if (node == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -343,6 +371,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String getEnvFullName() { |
|
|
|
public String getEnvFullName() { |
|
|
|
|
|
|
|
|
|
|
|
return this.node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1); |
|
|
|
return this.node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -352,6 +381,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 是则返回true |
|
|
|
* @return 是则返回true |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isMemFile() { |
|
|
|
public boolean isMemFile() { |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -361,6 +391,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 是则返回true |
|
|
|
* @return 是则返回true |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isEnvFile() { |
|
|
|
public boolean isEnvFile() { |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -371,6 +402,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean equals(Object obj) { |
|
|
|
public boolean equals(Object obj) { |
|
|
|
|
|
|
|
|
|
|
|
if (!(obj instanceof FileNodeFILE)) { |
|
|
|
if (!(obj instanceof FileNodeFILE)) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -384,6 +416,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return 返回hash码 |
|
|
|
* @return 返回hash码 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int hashCode() { |
|
|
|
public int hashCode() { |
|
|
|
|
|
|
|
|
|
|
|
int hash = 5; |
|
|
|
int hash = 5; |
|
|
|
hash = 61 * hash + (this.node != null ? this.node.hashCode() : 0); |
|
|
|
hash = 61 * hash + (this.node != null ? this.node.hashCode() : 0); |
|
|
|
hash = 61 * hash + (this.envPath != null ? this.envPath.hashCode() : 0); |
|
|
|
hash = 61 * hash + (this.envPath != null ? this.envPath.hashCode() : 0); |
|
|
@ -396,6 +429,7 @@ public class FileNodeFILE implements FILE { |
|
|
|
* @return String 字符串 |
|
|
|
* @return String 字符串 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String toString() { |
|
|
|
public String toString() { |
|
|
|
|
|
|
|
|
|
|
|
return prefix() + (this.node != null ? this.node.getEnvPath() : ""); |
|
|
|
return prefix() + (this.node != null ? this.node.getEnvPath() : ""); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |