Browse Source

REPORT-6700 远程设计权限

master
yaoh.wu 7 years ago
parent
commit
bab0b9db35
  1. 4
      designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java
  2. 14
      designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java
  3. 5
      designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java
  4. 9
      designer-base/src/com/fr/design/remote/RemoteMember.java
  5. 4
      designer-base/src/com/fr/design/remote/Utils.java
  6. 12
      designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java
  7. 55
      designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java
  8. 50
      designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java
  9. 12
      designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java
  10. 22
      designer-base/src/com/fr/design/remote/ui/UserManagerPane.java
  11. 10
      designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java
  12. 15
      designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java
  13. 57
      designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java
  14. 10
      designer-base/src/com/fr/env/DesignAuthorityConfigurable.java
  15. 57
      designer-base/src/com/fr/env/RemoteEnv.java

4
designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -284,7 +284,7 @@ public class EnvFileTree extends RefreshableJTree {
/**
* currentTreeNode下面如果是PENDING的节点,加载之...
*/
private void loadPendingChildTreeNode(ExpandMutableTreeNode currentTreeNode) {
protected void loadPendingChildTreeNode(ExpandMutableTreeNode currentTreeNode) {
if (currentTreeNode.isLeaf()) {
return;
}
@ -342,7 +342,7 @@ public class EnvFileTree extends RefreshableJTree {
/*
* 是否是父子关系的文件.
*/
private static boolean isParentFile(String parentFilePath, String childFilePath) {
protected static boolean isParentFile(String parentFilePath, String childFilePath) {
File parentFile = new File(parentFilePath);
File childFile = new File(childFilePath);

14
designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java

@ -1,14 +0,0 @@
package com.fr.design.remote;
public class RemoteDesignAuthority {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

5
designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java

@ -1,6 +1,7 @@
package com.fr.design.remote;
import com.fr.design.beans.BasicBeanPane;
import com.fr.report.DesignAuthority;
import javax.swing.Icon;
@ -39,7 +40,7 @@ public class RemoteDesignAuthorityCreator {
return editorClazz;
}
public void saveUpdatedBean(RemoteDesignAuthority authority, Object bean) {
public void saveUpdatedBean(DesignAuthority authority, Object bean) {
authority.setItems(((DesignAuthority) bean).getItems());
}
}

9
designer-base/src/com/fr/design/remote/RemoteMember.java

@ -11,10 +11,19 @@ public class RemoteMember {
private boolean selected;
public RemoteMember() {
}
public RemoteMember(String username) {
this.username = username;
}
public RemoteMember username(String username) {
this.username = username;
return this;
}
public RemoteMember realName(String realName) {
this.realName = realName;
return this;

4
designer-base/src/com/fr/design/remote/Utils.java

@ -28,7 +28,9 @@ public class Utils {
List<RemoteMember> res = new ArrayList<>();
for (UserAdditionBean userBean : userBeans) {
res.add(new RemoteMember(userBean.getUsername())
res.add(
new RemoteMember()
.username(userBean.getUsername())
.realName(userBean.getRealName())
.userId(userBean.getId())
);

12
designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java

@ -1,11 +1,14 @@
package com.fr.design.remote.action;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.remote.ui.AuthorityManagerPane;
import com.fr.env.RemoteEnv;
import com.fr.report.DesignAuthority;
import java.awt.event.ActionEvent;
@ -34,7 +37,14 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
managerPane.update();
DesignAuthority[] authorities = managerPane.update();
if (!FRContext.getCurrentEnv().isLocalEnv()) {
try {
((RemoteEnv) FRContext.getCurrentEnv()).updateAuthorities(authorities);
} catch (Exception exception) {
FRContext.getLogger().error(exception.getMessage());
}
}
}
@Override

55
designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java

@ -4,16 +4,22 @@ import com.fr.base.FRContext;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.remote.RemoteDesignAuthority;
import com.fr.design.remote.ui.tree.FileAuthorityTree;
import com.fr.file.filetree.FileNode;
import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.report.DesignAuthority;
import com.fr.stable.CoreConstants;
import javax.swing.BorderFactory;
import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class AuthorityEditorPane extends BasicBeanPane<RemoteDesignAuthority> {
public class AuthorityEditorPane extends BasicBeanPane<DesignAuthority> {
private UILabel label = new UILabel();
@ -29,6 +35,7 @@ public class AuthorityEditorPane extends BasicBeanPane<RemoteDesignAuthority> {
tree.setFileNodeFilter(filter);
this.add(new UIScrollPane(tree), BorderLayout.CENTER);
tree.refreshEnv(FRContext.getCurrentEnv());
}
@Override
@ -37,15 +44,45 @@ public class AuthorityEditorPane extends BasicBeanPane<RemoteDesignAuthority> {
}
@Override
public void populateBean(RemoteDesignAuthority ob) {
label.setText(ob.getName());
// todo 选中树的结点
public void populateBean(DesignAuthority ob) {
if (ob == null) {
return;
}
label.setText(ob.getUsername());
DesignAuthority.Item[] items = ob.getItems();
if (items == null) {
return;
}
String[] paths = new String[items.length];
for (int i = 0; i < items.length; i++) {
paths[i] = items[i].getPath();
}
tree.selectCheckBoxPaths(paths);
}
@Override
public RemoteDesignAuthority updateBean() {
// todo 更新权限信息
System.out.println(Arrays.toString(tree.getCheckBoxTreeSelectionModel().getSelectionPaths()));
return new RemoteDesignAuthority();
public DesignAuthority updateBean() {
DesignAuthority da = new DesignAuthority();
TreePath[] treePaths = tree.getCheckBoxTreeSelectionModel().getSelectionPaths();
List<DesignAuthority.Item> items = new ArrayList<>();
for (TreePath treePath : treePaths) {
StringBuilder tempSpot = new StringBuilder();
boolean type = true;
for (int counter = 1, maxCounter = treePath.getPathCount(); counter < maxCounter;
counter++) {
if (counter > 1) {
tempSpot.append(CoreConstants.SEPARATOR);
}
FileNode fileNode = (FileNode) ((ExpandMutableTreeNode) treePath.getPathComponent(counter)).getUserObject();
type = type && fileNode.isDirectory();
tempSpot.append(fileNode.getName());
}
items.add(new DesignAuthority.Item(tempSpot.toString(), type));
}
da.setItems(items.toArray(new DesignAuthority.Item[0]));
System.out.println(Arrays.toString(da.getItems()));
return da;
}
}

50
designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java

@ -14,7 +14,6 @@ import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.remote.RemoteDesignAuthority;
import com.fr.design.remote.RemoteDesignAuthorityCreator;
import com.fr.design.remote.RemoteMember;
import com.fr.design.remote.ui.list.AuthorityList;
@ -22,6 +21,7 @@ import com.fr.design.remote.ui.list.AuthorityListCellRenderer;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.report.DesignAuthority;
import com.fr.stable.ArrayUtils;
import javax.swing.BorderFactory;
@ -79,7 +79,7 @@ public class AuthorityListControlPane extends BasicPane {
new RemoteDesignAuthorityCreator(
"远程设计用户",
BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"),
RemoteDesignAuthority.class,
DesignAuthority.class,
AuthorityEditorPane.class)
};
editorCtrl = new ListEditorControlPane();
@ -147,7 +147,7 @@ public class AuthorityListControlPane extends BasicPane {
}
private AuthorityList createList() {
AuthorityList list = new AuthorityList(new DefaultListModel<RemoteDesignAuthority>());
AuthorityList list = new AuthorityList(new DefaultListModel<DesignAuthority>());
list.setCellRenderer(new AuthorityListCellRenderer());
return list;
}
@ -162,24 +162,24 @@ public class AuthorityListControlPane extends BasicPane {
}
public RemoteDesignAuthority[] update() {
List<RemoteDesignAuthority> res = new ArrayList<>();
public DesignAuthority[] update() {
List<DesignAuthority> res = new ArrayList<>();
this.editorCtrl.update();
DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel();
for (int i = 0, len = listModel.getSize(); i < len; i++) {
res.add((RemoteDesignAuthority) listModel.getElementAt(i));
res.add((DesignAuthority) listModel.getElementAt(i));
}
return res.toArray(new RemoteDesignAuthority[0]);
return res.toArray(new DesignAuthority[0]);
}
public void populate(RemoteDesignAuthority[] authorities) {
DefaultListModel<RemoteDesignAuthority> listModel = (DefaultListModel<RemoteDesignAuthority>) this.authorityList.getModel();
public void populate(DesignAuthority[] authorities) {
DefaultListModel<DesignAuthority> listModel = (DefaultListModel<DesignAuthority>) this.authorityList.getModel();
listModel.removeAllElements();
if (ArrayUtils.isEmpty(authorities)) {
return;
}
for (RemoteDesignAuthority authority : authorities) {
for (DesignAuthority authority : authorities) {
listModel.addElement(authority);
}
@ -205,8 +205,8 @@ public class AuthorityListControlPane extends BasicPane {
public void setSelectedName(String name) {
DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel();
for (int i = 0, len = listModel.getSize(); i < len; i++) {
RemoteDesignAuthority authority = (RemoteDesignAuthority) listModel.getElementAt(i);
if (ComparatorUtils.equals(name, authority.getName())) {
DesignAuthority authority = (DesignAuthority) listModel.getElementAt(i);
if (ComparatorUtils.equals(name, authority.getUsername())) {
this.authorityList.setSelectedIndex(i);
break;
}
@ -218,8 +218,8 @@ public class AuthorityListControlPane extends BasicPane {
* 获取选中的名字
*/
public String getSelectedName() {
RemoteDesignAuthority authority = this.authorityList.getSelectedValue();
return authority == null ? null : authority.getName();
DesignAuthority authority = this.authorityList.getSelectedValue();
return authority == null ? null : authority.getUsername();
}
/**
@ -228,8 +228,8 @@ public class AuthorityListControlPane extends BasicPane {
* @param authority authority
* @param index 序号
*/
public void addAuthority(RemoteDesignAuthority authority, int index) {
DefaultListModel<RemoteDesignAuthority> model = (DefaultListModel<RemoteDesignAuthority>) authorityList.getModel();
public void addAuthority(DesignAuthority authority, int index) {
DefaultListModel<DesignAuthority> model = (DefaultListModel<DesignAuthority>) authorityList.getModel();
model.add(index, authority);
authorityList.setSelectedIndex(index);
@ -240,8 +240,8 @@ public class AuthorityListControlPane extends BasicPane {
}
protected DefaultListModel<RemoteDesignAuthority> getModel() {
return (DefaultListModel<RemoteDesignAuthority>) this.authorityList.getModel();
protected DefaultListModel<DesignAuthority> getModel() {
return (DefaultListModel<DesignAuthority>) this.authorityList.getModel();
}
@ -353,7 +353,7 @@ public class AuthorityListControlPane extends BasicPane {
private ShortCut4JControlPane[] createShortcuts() {
return new ShortCut4JControlPane[]{
new AbsoluteEnableShortCut(new AddItemUpdateAction(authorityCreators)),
new AbsoluteEnableShortCut(new AddItemUpdateAction()),
new NormalEnableShortCut(new RemoveItemAction())
};
}
@ -397,7 +397,7 @@ public class AuthorityListControlPane extends BasicPane {
private JPanel cardPane;
private BasicBeanPane[] editorPanes;
private RemoteDesignAuthority authority;
private DesignAuthority authority;
ListEditorControlPane() {
initUpdatePane();
@ -460,10 +460,8 @@ public class AuthorityListControlPane extends BasicPane {
* 添加按钮
*/
private class AddItemUpdateAction extends UpdateAction {
private RemoteDesignAuthorityCreator creator;
AddItemUpdateAction(RemoteDesignAuthorityCreator[] creators) {
this.creator = creators[0];
AddItemUpdateAction() {
this.setName(Inter.getLocText("FR-Action_Add"));
this.setMnemonic('A');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
@ -480,8 +478,10 @@ public class AuthorityListControlPane extends BasicPane {
// 获取添加的用户到权限编辑面板
List<RemoteMember> members = userManagerPane.update();
for (RemoteMember member : members) {
RemoteDesignAuthority authority = new RemoteDesignAuthority();
authority.setName(member.getUsername());
DesignAuthority authority = new DesignAuthority();
authority.setUsername(member.getUsername());
authority.setUserId(member.getUserId());
authority.setRealName(member.getRealName());
AuthorityListControlPane.this.addAuthority(authority, getModel().getSize());
}
}

12
designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java

@ -1,11 +1,12 @@
package com.fr.design.remote.ui;
import com.fr.design.dialog.BasicPane;
import com.fr.design.remote.RemoteDesignAuthority;
import com.fr.general.Inter;
import com.fr.report.DesignAuthority;
import javax.swing.BorderFactory;
import java.awt.BorderLayout;
import java.util.Arrays;
public class AuthorityManagerPane extends BasicPane {
@ -26,12 +27,13 @@ public class AuthorityManagerPane extends BasicPane {
return Inter.getLocText("远程设计权限管理");
}
public void populate(RemoteDesignAuthority[] authorities) {
public void populate(DesignAuthority[] authorities) {
list.populate(authorities);
}
public RemoteDesignAuthority[] update() {
return list.update();
public DesignAuthority[] update() {
DesignAuthority[] authorities = list.update();
System.out.println(Arrays.toString(authorities));
return authorities;
}
}

22
designer-base/src/com/fr/design/remote/ui/UserManagerPane.java

@ -10,14 +10,25 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.remote.RemoteMember;
import com.fr.design.remote.Utils;
import com.fr.design.remote.ui.list.*;
import com.fr.design.remote.ui.list.AddedMemberList;
import com.fr.design.remote.ui.list.AddedMemberListCellRender;
import com.fr.design.remote.ui.list.AddingMemberList;
import com.fr.design.remote.ui.list.AddingMemberListCellRender;
import com.fr.design.remote.ui.list.MemberListSelectedChangeListener;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import com.fr.third.guava.collect.ImmutableList;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import javax.swing.SwingWorker;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
@ -234,11 +245,6 @@ public class UserManagerPane extends BasicPane {
protected List<RemoteMember> doInBackground() {
addingMembers.clear();
addingMembers.addAll(Utils.getRemoteMember(keyword));
try {
Thread.sleep(2000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
return addingMembers;
}

10
designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java

@ -1,27 +1,27 @@
package com.fr.design.remote.ui.list;
import com.fr.design.remote.RemoteDesignAuthority;
import com.fr.report.DesignAuthority;
import javax.swing.JList;
import javax.swing.ListModel;
import java.util.Vector;
public class AuthorityList extends JList<RemoteDesignAuthority> {
public class AuthorityList extends JList<DesignAuthority> {
public AuthorityList() {
super();
}
public AuthorityList(ListModel<RemoteDesignAuthority> dataModel) {
public AuthorityList(ListModel<DesignAuthority> dataModel) {
super(dataModel);
}
public AuthorityList(final RemoteDesignAuthority[] listData) {
public AuthorityList(final DesignAuthority[] listData) {
super(listData);
}
public AuthorityList(final Vector<? extends RemoteDesignAuthority> listData) {
public AuthorityList(final Vector<? extends DesignAuthority> listData) {
super(listData);
}

15
designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java

@ -1,16 +1,19 @@
package com.fr.design.remote.ui.list;
import com.fr.base.BaseUtils;
import com.fr.design.remote.RemoteDesignAuthority;
import com.fr.report.DesignAuthority;
import sun.swing.DefaultLookup;
import javax.swing.*;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.Color;
import java.awt.Component;
public class AuthorityListCellRenderer extends
JLabel implements ListCellRenderer<RemoteDesignAuthority> {
JLabel implements ListCellRenderer<DesignAuthority> {
/**
* An empty <code>Border</code>. This field might not be used. To change the
@ -35,7 +38,7 @@ public class AuthorityListCellRenderer extends
}
@Override
public Component getListCellRendererComponent(JList list, RemoteDesignAuthority authority,
public Component getListCellRendererComponent(JList list, DesignAuthority authority,
int index, boolean isSelected, boolean cellHasFocus) {
setComponentOrientation(list.getComponentOrientation());
@ -79,7 +82,7 @@ public class AuthorityListCellRenderer extends
setBorder(border);
this.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
this.setText(authority.getName());
this.setText(authority.getUsername());
return this;
}

57
designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java

@ -1,8 +1,17 @@
package com.fr.design.remote.ui.tree;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class FileAuthorityTree extends TemplateFileTree {
@ -12,4 +21,52 @@ public class FileAuthorityTree extends TemplateFileTree {
}
public void selectCheckBoxPaths(String[] paths) {
if (paths == null || paths.length == 0) {
return;
}
DefaultTreeModel model = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode treeNode = (ExpandMutableTreeNode) model.getRoot();
List<TreePath> res = new ArrayList<>();
for (int i = 0, len = treeNode.getChildCount(); i < len; i++) {
ExpandMutableTreeNode childTreeNode = (ExpandMutableTreeNode) treeNode.getChildAt(i);
for (String path : paths) {
TreePath tPath = getSelectingPath(childTreeNode, StringUtils.EMPTY, path, model);
if (tPath != null) {
res.add(tPath);
}
}
}
// 勾选中这些结点
this.getCheckBoxTreeSelectionModel().setSelectionPaths(res.toArray(new TreePath[0]));
}
private TreePath getSelectingPath(ExpandMutableTreeNode currentTreeNode, String prefix, String filePath, DefaultTreeModel model) {
FileNode fileNode = (FileNode) currentTreeNode.getUserObject();
String nodePath = fileNode.getName();
String currentTreePath = prefix + nodePath;
TreePath res;
// 判断是否是希望选中的
if (ComparatorUtils.equals(new File(currentTreePath), new File(filePath))) {
return new TreePath(model.getPathToRoot(currentTreeNode));
}
// 如果当前路径是currentFilePath的ParentFile,则expandTreeNode,并继续往下找
else if (isParentFile(currentTreePath, filePath)) {
loadPendingChildTreeNode(currentTreeNode);
prefix = currentTreePath + CoreConstants.SEPARATOR;
for (int i = 0, len = currentTreeNode.getChildCount(); i < len; i++) {
ExpandMutableTreeNode childTreeNode = (ExpandMutableTreeNode) currentTreeNode.getChildAt(i);
// 继续在子结点里面找
res = getSelectingPath(childTreeNode, prefix, filePath, model);
if (res != null) {
return res;
}
}
return null;
}
return null;
}
}

10
designer-base/src/com/fr/env/DesignAuthorityConfigurable.java vendored

@ -0,0 +1,10 @@
package com.fr.env;
import com.fr.report.DesignAuthority;
public interface DesignAuthorityConfigurable {
DesignAuthority[] getAuthorities();
boolean updateAuthorities(DesignAuthority[] authorities) throws Exception;
}

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

@ -41,6 +41,7 @@ import com.fr.json.JSONException;
import com.fr.json.JSONObject;
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.ArrayUtils;
import com.fr.stable.EncodeConstants;
@ -56,6 +57,7 @@ import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLableReader;
import com.fr.web.ResourceConstants;
import com.fr.web.utils.AuthorityXMLUtils;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
@ -95,7 +97,7 @@ import java.util.regex.Pattern;
/**
* @author null
*/
public class RemoteEnv extends AbstractEnv {
public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurable {
private static final int TIME_OUT = 30 * 1000;
private static final int PLAIN_SOCKET_PORT = 80;
private static final int SSL_PORT = 443;
@ -228,7 +230,13 @@ public class RemoteEnv extends AbstractEnv {
if (!isSignIn) {
methodPath = methodPath + "?id=" + createUserID();
}
HttpClient client = new HttpClient(methodPath,para);
HttpClient client = new HttpClient(methodPath, para);
/*
todo post 方法好象过去不了
但是get方法也会有一些url参数问题尤其是图表部分
比如:
op=fr_remote_design&cmd=design_get_plugin_service_data&serviceID=plugin.phantomjs&req=
*/
client.asGet();
return client;
}
@ -236,9 +244,20 @@ public class RemoteEnv extends AbstractEnv {
/**
* 根据nameValuePairs,也就是参数对,生成PostMethod,不同之处在于,参数拼在path后面,不是method.addParameters
*/
private HttpClient createHttpMethod2(HashMap<String, String> para) throws EnvException {
private HttpClient createHttpMethod2(HashMap<String, String> para) throws EnvException, UnsupportedEncodingException {
String methodPath = path + '?' + "id=" + createUserID();
return new HttpClient(methodPath, para, true);
StringBuilder pathBuilder = new StringBuilder();
pathBuilder.append(methodPath);
pathBuilder.append('&');
for (Object o : para.entrySet()) {
Map.Entry entry = (Map.Entry) o;
pathBuilder.append('&');
pathBuilder.append(URLEncoder.encode((String) entry.getKey(), "UTF-8"));
pathBuilder.append('=');
pathBuilder.append(URLEncoder.encode((String) entry.getValue(), "UTF-8"));
}
methodPath = pathBuilder.toString();
return new HttpClient(methodPath);
}
@ -826,6 +845,27 @@ public class RemoteEnv extends AbstractEnv {
return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8));
}
@Override
public boolean updateAuthorities(DesignAuthority[] authorities) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
// 序列化到输出流
AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, out);
HashMap<String, String> para = new HashMap<>();
para.put("op", "remote_design_authority");
para.put("cmd", "update_authorities");
InputStream input = postBytes2ServerB(out.toByteArray(), para);
return input != null && Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8));
}
@Override
public DesignAuthority[] getAuthorities() {
return new DesignAuthority[0];
}
/**
* ben:取schema
*/
@ -1366,6 +1406,13 @@ public class RemoteEnv extends AbstractEnv {
*/
public InputStream postBytes2ServerB(byte[] bytes, HashMap<String, String> para) throws Exception {
HttpClient client = createHttpMethod2(para);
/*
todo post 方法好象过去不了
但是get方法也会有一些url参数问题尤其是图表部分
比如:
op=fr_remote_design&cmd=design_get_plugin_service_data&serviceID=plugin.phantomjs&req=
*/
// client.asGet();
client.setContent(bytes);
return execute4InputStream(client);
}
@ -1900,8 +1947,6 @@ public class RemoteEnv extends AbstractEnv {
}
//TODO:
/**
* 预览存储过程
*

Loading…
Cancel
Save