Browse Source

REPORT-6700 列表过滤

master
yaoh.wu 7 years ago
parent
commit
6779e3e6c0
  1. 84
      designer-base/src/com/fr/env/RemoteEnv.java
  2. 93
      designer-base/src/com/fr/env/RemoteEnvUtils.java

84
designer-base/src/com/fr/env/RemoteEnv.java vendored

@ -1,6 +1,13 @@
package com.fr.env;
import com.fr.base.*;
import com.fr.base.AbstractEnv;
import com.fr.base.EnvException;
import com.fr.base.FRContext;
import com.fr.base.ModifiedTable;
import com.fr.base.Parameter;
import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData;
import com.fr.base.Utils;
import com.fr.base.remote.RemoteDeziConstants;
import com.fr.data.TableDataSource;
import com.fr.data.core.DataCoreUtils;
@ -22,7 +29,11 @@ import com.fr.file.CacheManager;
import com.fr.file.ConnectionConfig;
import com.fr.file.TableDataConfig;
import com.fr.file.filetree.FileNode;
import com.fr.general.*;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.LogRecordTime;
import com.fr.general.LogUtils;
import com.fr.general.http.HttpClient;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.json.JSONArray;
@ -32,7 +43,14 @@ import com.fr.license.function.VT4FR;
import com.fr.regist.License;
import com.fr.report.DesignAuthority;
import com.fr.share.ShareConstants;
import com.fr.stable.*;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.Filter;
import com.fr.stable.JavaCompileInfo;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.SvgProvider;
import com.fr.stable.file.XMLFileManagerProvider;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.xml.XMLPrintWriter;
@ -40,19 +58,38 @@ import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLableReader;
import com.fr.web.ResourceConstants;
import javax.swing.*;
import javax.xml.transform.*;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.awt.*;
import java.io.*;
import java.awt.Component;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.NoRouteToHostException;
import java.net.Socket;
import java.net.URLEncoder;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.regex.Pattern;
@ -1141,36 +1178,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
}
private FileNode[] listFile(String rootFilePath, boolean isWebReport) throws Exception {
FileNode[] fileNodes;
HashMap<String, String> para = new HashMap<>();
para.put("op", "fs_remote_design");
para.put("cmd", "design_list_file");
para.put("file_path", rootFilePath);
para.put("currentUserName", this.getUser());
para.put("currentUserId", this.createUserID());
para.put("isWebReport", isWebReport ? "true" : "false");
HttpClient client = createHttpMethod(para);
InputStream input = execute4InputStream(client);
if (input == null) {
return new FileNode[0];
}
// 远程环境下左侧目录树暂不需要打开xlsx,xls文件
fileNodes = DavXMLUtils.readXMLFileNodes(input);
ArrayList<FileNode> al = new ArrayList<>();
for (int i = 0; i < fileNodes.length; i++) {
al.add(fileNodes[i]);
}
FileNode[] fileNodes2 = new FileNode[al.size()];
for (int i = 0; i < al.size(); i++) {
fileNodes2[i] = al.get(i);
}
return fileNodes2;
return RemoteEnvUtils.listFile(rootFilePath, isWebReport, this);
}

93
designer-base/src/com/fr/env/RemoteEnvUtils.java vendored

@ -1,6 +1,8 @@
package com.fr.env;
import com.fr.base.FRContext;
import com.fr.dav.DavXMLUtils;
import com.fr.file.filetree.FileNode;
import com.fr.general.IOUtils;
import com.fr.report.DesignAuthority;
import com.fr.stable.EncodeConstants;
@ -26,30 +28,26 @@ public class RemoteEnvUtils {
public static boolean updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) {
String path = env.getPath();
// 远程设计临时用户id
String userID = env.getUserID();
String res = null;
CloseableHttpClient httpClient = HttpClients.createDefault();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream);
InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML);
HttpUriRequest request = RequestBuilder.post(path)
.addParameter("id", userID)
.addParameter("op", "remote_design_authority")
.addParameter("cmd", "update_authorities")
.setEntity(reqEntity)
.build();
try {
CloseableHttpResponse response = httpClient.execute(request);
HttpEntity entity = response.getEntity();
res = IOUtils.inputStream2String(entity.getContent(), EncodeConstants.ENCODING_UTF_8);
EntityUtils.consume(entity);
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpUriRequest request = RequestBuilder.post(path)
.addParameter("id", userID)
.addParameter("op", "remote_design_authority")
.addParameter("cmd", "update_authorities")
.setEntity(reqEntity)
.build();
try (CloseableHttpResponse response = httpClient.execute(request)) {
HttpEntity entity = response.getEntity();
res = IOUtils.inputStream2String(entity.getContent(), EncodeConstants.ENCODING_UTF_8);
EntityUtils.consume(entity);
}
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage());
}
@ -60,27 +58,60 @@ public class RemoteEnvUtils {
public static DesignAuthority[] getAuthorities(RemoteEnv env) {
String path = env.getPath();
// 远程设计临时用户id
String userID = env.getUserID();
DesignAuthority[] authorities = null;
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpUriRequest request = RequestBuilder.get(path)
.addParameter("id", userID)
.addParameter("op", "remote_design_authority")
.addParameter("cmd", "get_authorities")
.build();
try {
CloseableHttpResponse response = httpClient.execute(request);
HttpEntity entity = response.getEntity();
authorities = AuthorityXMLUtils.readDesignAuthoritiesXML(entity.getContent());
EntityUtils.consume(entity);
} catch (Exception e) {
try (CloseableHttpClient httpClient = HttpClients.createDefault();) {
HttpUriRequest request = RequestBuilder.get(path)
.addParameter("id", userID)
.addParameter("op", "remote_design_authority")
.addParameter("cmd", "get_authorities")
.build();
try (CloseableHttpResponse response = httpClient.execute(request)) {
HttpEntity entity = response.getEntity();
authorities = AuthorityXMLUtils.readDesignAuthoritiesXML(entity.getContent());
EntityUtils.consume(entity);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage());
}
return authorities;
}
public static FileNode[] listFile(String pFilePath, boolean isWebReport, RemoteEnv env) {
String path = env.getPath();
// 远程设计临时用户id
String userID = env.getUserID();
String username = env.getUser();
FileNode[] fileNodes = null;
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpUriRequest request = RequestBuilder.get(path)
.addParameter("op", "fs_remote_design")
.addParameter("cmd", "design_list_file")
.addParameter("file_path", pFilePath)
.addParameter("currentUserName", username)
.addParameter("currentUserId", userID)
.addParameter("isWebReport", Boolean.toString(isWebReport))
.build();
try (CloseableHttpResponse response = httpClient.execute(request)) {
HttpEntity entity = response.getEntity();
fileNodes = DavXMLUtils.readXMLFileNodes((entity.getContent()));
EntityUtils.consume(entity);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage());
}
return fileNodes != null ? fileNodes : new FileNode[0];
}
}

Loading…
Cancel
Save