Browse Source

REPORT-8881 com.fr.file.FileNodeFILE#listFiles有问题

master
ju 6 years ago
parent
commit
f6048da455
  1. 4
      designer-base/src/com/fr/design/extra/WebViewDlgHelper.java
  2. 4
      designer-base/src/com/fr/file/FILEChooserPane.java
  3. 4
      designer-base/src/com/fr/file/FILEFactory.java
  4. 38
      designer-base/src/com/fr/file/FileNodeFILE.java

4
designer-base/src/com/fr/design/extra/WebViewDlgHelper.java

@ -44,7 +44,7 @@ public class WebViewDlgHelper {
private static final String LATEST = "latest"; private static final String LATEST = "latest";
private static final String SHOP_SCRIPTS = "shop_scripts"; private static final String SHOP_SCRIPTS = "shop_scripts";
private static final int VERSION_8 = 8; private static final int VERSION_8 = 8;
private static String installHome = FRContext.getCommonOperator().getWebReportPath(); private static String installHome = FRContext.getCommonOperator().getWebRootPath();
private static final String MAIN_JS_PATH = "/scripts/plugin.html"; private static final String MAIN_JS_PATH = "/scripts/plugin.html";
private static final String ENV_VERSION = "ENV_VERSION"; private static final String ENV_VERSION = "ENV_VERSION";
@ -52,7 +52,7 @@ public class WebViewDlgHelper {
GeneralContext.addEnvChangedListener(new EnvChangedListener() { GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override @Override
public void envChanged() { public void envChanged() {
installHome = FRContext.getCommonOperator().getWebReportPath(); installHome = FRContext.getCommonOperator().getWebRootPath();
} }
}); });
} }

4
designer-base/src/com/fr/file/FILEChooserPane.java

@ -787,7 +787,7 @@ public class FILEChooserPane extends BasicPane {
if (FILEChooserPane.this.showWebReport) { if (FILEChooserPane.this.showWebReport) {
// webReportFILE = new FileFILE(new // webReportFILE = new FileFILE(new
// File(FRContext.getCommonOperator().getWebReportPath())); // File(FRContext.getCommonOperator().getWebReportPath()));
webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebReportPath()); webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebRootPath());
// String webReportPath = // String webReportPath =
// FRContext.getCommonOperator().getWebReportPath(); // FRContext.getCommonOperator().getWebReportPath();
// String webReportParentPath = new // String webReportParentPath = new
@ -1108,7 +1108,7 @@ public class FILEChooserPane extends BasicPane {
((DefaultListModel) subFileList.getModel()).removeAllElements(); ((DefaultListModel) subFileList.getModel()).removeAllElements();
for (int i = 0; i < res_array.length; i++) { for (int i = 0; i < res_array.length; i++) {
if (filter == null || filter.accept(res_array[i])) { if (filter == null || filter.accept(res_array[i])) {
((DefaultListModel) subFileList.getModel()).addElement(res_array[i]); ((DefaultListModel) subFileList.getModel()).addElement( res_array[i]);
} }
} }
String[] name_array = new String[res_array.length]; String[] name_array = new String[res_array.length];

4
designer-base/src/com/fr/file/FILEFactory.java

@ -31,7 +31,7 @@ public class FILEFactory {
return new FileNodeFILE(new FileNode(path.substring(envPath.length() + 1), false)); return new FileNodeFILE(new FileNode(path.substring(envPath.length() + 1), false));
} else if (path.startsWith(WEBREPORT_PREFIX)) { } else if (path.startsWith(WEBREPORT_PREFIX)) {
return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), false), return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), false),
FRContext.getCommonOperator().getWebReportPath()); FRContext.getCommonOperator().getWebRootPath());
} else if (path.startsWith(FILE_PREFIX)) { } else if (path.startsWith(FILE_PREFIX)) {
return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length())));
} else { } else {
@ -48,7 +48,7 @@ public class FILEFactory {
return new FileNodeFILE(new FileNode(path.substring(ENV_PREFIX.length()), true)); return new FileNodeFILE(new FileNode(path.substring(ENV_PREFIX.length()), true));
} else if (path.startsWith(WEBREPORT_PREFIX)) { } else if (path.startsWith(WEBREPORT_PREFIX)) {
return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true), return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true),
FRContext.getCommonOperator().getWebReportPath()); FRContext.getCommonOperator().getWebRootPath());
} else if (path.startsWith(FILE_PREFIX)) { } else if (path.startsWith(FILE_PREFIX)) {
return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length())));
} else { } else {

38
designer-base/src/com/fr/file/FileNodeFILE.java

@ -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() : "");
} }
} }
Loading…
Cancel
Save