commit
940de2ff17
13 changed files with 413 additions and 0 deletions
@ -0,0 +1,7 @@ |
|||||||
|
|
||||||
|
# open-JSD-9831 |
||||||
|
|
||||||
|
JSD-9831 前端唤起设计器,并实现相关远程环境链接操作\ |
||||||
|
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||||
|
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||||
|
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,24 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<plugin> |
||||||
|
<id>com.fr.plugin.ihca.rpc</id> |
||||||
|
<name><![CDATA[设计器事件检测提交]]></name> |
||||||
|
<active>yes</active> |
||||||
|
<version>1.2</version> |
||||||
|
<env-version>10.0</env-version> |
||||||
|
<jartime>2018-07-31</jartime> |
||||||
|
<vendor>fr.open</vendor> |
||||||
|
<description><![CDATA[设计器事件检测提交]]></description> |
||||||
|
<change-notes><![CDATA[设计器远程连接服务器时,监测设计器中的报表文件和文件夹的新增、删除、重命名动作,推送消息至指定接口地址。]]></change-notes> |
||||||
|
<main-package>com.fr.plugin.ihca</main-package> |
||||||
|
<prefer-packages> |
||||||
|
<prefer-package>com.fanruan.api</prefer-package> |
||||||
|
</prefer-packages> |
||||||
|
<lifecycle-monitor class="com.fr.plugin.ihca.PluginMonitor"/> |
||||||
|
<extra-core> |
||||||
|
<LocaleFinder class="com.fr.plugin.ihca.LocaleFinder"/> |
||||||
|
</extra-core> |
||||||
|
<extra-decision> |
||||||
|
<GlobalRequestFilterProvider class="com.fr.plugin.ihca.request.RemoteFilter"/> |
||||||
|
</extra-decision> |
||||||
|
<function-recorder class="com.fr.plugin.ihca.request.RemoteFilter"/> |
||||||
|
</plugin> |
@ -0,0 +1,32 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2020 |
||||||
|
* Project: starter |
||||||
|
* FileName: LocaleFinder |
||||||
|
* Author: xxx |
||||||
|
* Date: 2020/8/31 22:19 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ihca; |
||||||
|
|
||||||
|
import com.fr.record.analyzer.EnableMetrics; |
||||||
|
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <LocaleFinder> |
||||||
|
* |
||||||
|
* @author xxx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@EnableMetrics |
||||||
|
public class LocaleFinder extends AbstractLocaleFinder { |
||||||
|
|
||||||
|
@Override |
||||||
|
public String find() { |
||||||
|
return "com/fr/plugin/ihca/locale/lang"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: PluginMonitor |
||||||
|
* Author: xxx |
||||||
|
* Date: 2021/3/30 15:10 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ihca; |
||||||
|
|
||||||
|
import com.fr.plugin.context.PluginContext; |
||||||
|
import com.fr.plugin.ihca.config.IhcaConfig; |
||||||
|
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <PluginMonitor> |
||||||
|
* |
||||||
|
* @author xxx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class PluginMonitor extends AbstractPluginLifecycleMonitor { |
||||||
|
public PluginMonitor() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterRun(PluginContext pluginContext) { |
||||||
|
IhcaConfig.getInstance(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void beforeStop(PluginContext pluginContext) { |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: IhcaConfig |
||||||
|
* Author: xxx |
||||||
|
* Date: 2021/3/30 9:38 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ihca.config; |
||||||
|
|
||||||
|
import com.fanruan.api.util.StringKit; |
||||||
|
import com.fr.config.*; |
||||||
|
import com.fr.config.holder.Conf; |
||||||
|
import com.fr.config.holder.factory.Holders; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <IhcaConfig> |
||||||
|
* |
||||||
|
* @author xxx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@Visualization(category = "Plugin-ihca_Group") |
||||||
|
public class IhcaConfig extends DefaultConfiguration { |
||||||
|
private static volatile IhcaConfig config = null; |
||||||
|
@Identifier(value = "uriBase", name = "Plugin-ihca_Config_UriBase", description = "Plugin-ihca_Config_UriBase_Description", status = Status.SHOW) |
||||||
|
private final Conf<String> uriBase = Holders.simple(StringKit.EMPTY); |
||||||
|
|
||||||
|
public static IhcaConfig getInstance() { |
||||||
|
if (config == null) { |
||||||
|
config = ConfigContext.getConfigInstance(IhcaConfig.class); |
||||||
|
} |
||||||
|
return config; |
||||||
|
} |
||||||
|
|
||||||
|
public String getUriBase() { |
||||||
|
return uriBase.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setUriBase(String uriBase) { |
||||||
|
this.uriBase.set(uriBase); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: DelegatingServletInputStream |
||||||
|
* Author: xxx |
||||||
|
* Date: 2021/8/27 18:21 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ihca.request; |
||||||
|
|
||||||
|
import javax.servlet.ReadListener; |
||||||
|
import javax.servlet.ServletInputStream; |
||||||
|
import java.io.IOException; |
||||||
|
import java.io.InputStream; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <DelegatingServletInputStream> |
||||||
|
* |
||||||
|
* @author xxx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class DelegatingServletInputStream extends ServletInputStream { |
||||||
|
private final InputStream sourceStream; |
||||||
|
|
||||||
|
public DelegatingServletInputStream(InputStream stream) { |
||||||
|
this.sourceStream = stream; |
||||||
|
} |
||||||
|
|
||||||
|
public final InputStream getSourceStream() { |
||||||
|
return this.sourceStream; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int read() throws IOException { |
||||||
|
return this.sourceStream.read(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void close() throws IOException { |
||||||
|
super.close(); |
||||||
|
this.sourceStream.close(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isFinished() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isReady() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setReadListener(ReadListener listener) { |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,120 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: ModifyBodyRequestWrapper |
||||||
|
* Author: xxx |
||||||
|
* Date: 2021/8/27 18:18 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ihca.request; |
||||||
|
|
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fanruan.api.net.http.HttpKit; |
||||||
|
import com.fanruan.api.util.StringKit; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.plugin.ihca.config.IhcaConfig; |
||||||
|
import com.fr.rpc.Invocation; |
||||||
|
import com.fr.rpc.serialization.InvocationSerializer; |
||||||
|
import com.fr.serialization.GZipSerializerWrapper; |
||||||
|
import com.fr.serialization.SerializerHelper; |
||||||
|
import com.fr.third.org.apache.http.entity.StringEntity; |
||||||
|
|
||||||
|
import javax.servlet.ServletInputStream; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletRequestWrapper; |
||||||
|
import java.io.BufferedReader; |
||||||
|
import java.io.ByteArrayInputStream; |
||||||
|
import java.io.InputStreamReader; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <ModifyBodyRequestWrapper> |
||||||
|
* |
||||||
|
* @author xxx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class ModifyBodyRequestWrapper extends HttpServletRequestWrapper { |
||||||
|
public static final String RENAME = "public abstract boolean com.fr.workspace.server.lock.TplOperator.rename(java.lang.String,java.lang.String)"; |
||||||
|
public static final String FILE_ADD = "public abstract com.fr.report.entity.VcsEntity com.fr.workspace.server.vcs.VcsOperator.saveVersion(java.lang.String,java.lang.String,java.lang.String,int)"; |
||||||
|
public static final String DELETE = "public abstract boolean com.fr.workspace.server.lock.TplOperator.delete(java.lang.String)"; |
||||||
|
public static final String DIR_ADD = "public abstract boolean com.fr.workspace.resource.WorkResource.createDirectory(java.lang.String)"; |
||||||
|
private final byte[] bodyContent; |
||||||
|
|
||||||
|
public ModifyBodyRequestWrapper(HttpServletRequest request) { |
||||||
|
super(request); |
||||||
|
this.bodyContent = modifyRequestBody(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
private byte[] modifyRequestBody() { |
||||||
|
try { |
||||||
|
byte[] orgContent = IOUtils.inputStream2Bytes(this.getRequest().getInputStream()); |
||||||
|
operation(orgContent); |
||||||
|
return orgContent; |
||||||
|
} catch (Exception e) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 数据处理操作 |
||||||
|
* |
||||||
|
* @param content |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
private void operation(byte[] content) { |
||||||
|
try { |
||||||
|
Invocation invocation = SerializerHelper.deserialize(content, GZipSerializerWrapper.wrap(InvocationSerializer.getDefault())); |
||||||
|
// LogKit.info("ihca-ModifyBodyRequestWrapper-operation-method:{} parameters:{}", invocation.getMethod(), invocation.getParams());
|
||||||
|
JSONObject opData = JSONObject.create(); |
||||||
|
if (StringKit.equalsIgnoreCase(invocation.getMethod().toString(), RENAME)) { |
||||||
|
opData.put("type", "rename"); |
||||||
|
opData.put("node", cutReportlets(invocation.getParams()[0])); |
||||||
|
opData.put("newName", cutReportlets(invocation.getParams()[1])); |
||||||
|
} else if (StringKit.equalsIgnoreCase(invocation.getMethod().toString(), FILE_ADD)) { |
||||||
|
opData.put("type", "add"); |
||||||
|
opData.put("user", invocation.getParams()[0]); |
||||||
|
opData.put("node", cutReportlets(invocation.getParams()[1])); |
||||||
|
} else if (StringKit.equalsIgnoreCase(invocation.getMethod().toString(), DELETE)) { |
||||||
|
opData.put("type", "delete"); |
||||||
|
opData.put("node", cutReportlets(invocation.getParams()[0])); |
||||||
|
} else if (StringKit.equalsIgnoreCase(invocation.getMethod().toString(), DIR_ADD)) { |
||||||
|
opData.put("type", "add"); |
||||||
|
opData.put("node", cutReportlets(invocation.getParams()[0])); |
||||||
|
} else { |
||||||
|
return; |
||||||
|
} |
||||||
|
Map<String, String> headers = new HashMap<>(); |
||||||
|
headers.put("Content-Type", "application/json"); |
||||||
|
// LogKit.info("ihca-ModifyBodyRequestWrapper-operation-opData:{}", opData.encode());
|
||||||
|
StringEntity stringEntity = new StringEntity(opData.encode(), "UTF-8"); |
||||||
|
String response = HttpKit.executeAndParse(com.fanruan.api.net.http.rs.HttpRequest.custom() |
||||||
|
.url(IhcaConfig.getInstance().getUriBase()).post(stringEntity).headers(headers).build()); |
||||||
|
// LogKit.info("ihca-ModifyBodyRequestWrapper-operation-response:{}", response);
|
||||||
|
} catch (Exception e) { |
||||||
|
LogKit.error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private String cutReportlets(Object filePath) { |
||||||
|
return StringKit.cutStringStartWith(String.valueOf(filePath), "reportlets/"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ServletInputStream getInputStream() { |
||||||
|
try { |
||||||
|
return new DelegatingServletInputStream(new ByteArrayInputStream(this.bodyContent)); |
||||||
|
} catch (Exception e) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public BufferedReader getReader() { |
||||||
|
return new BufferedReader(new InputStreamReader(new ByteArrayInputStream(this.bodyContent))); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,87 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: RemoteFilter |
||||||
|
* Author: xxx |
||||||
|
* Date: 2021/3/30 22:09 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ihca.request; |
||||||
|
|
||||||
|
import com.fanruan.api.i18n.I18nKit; |
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider; |
||||||
|
import com.fr.intelli.record.Focus; |
||||||
|
import com.fr.intelli.record.Original; |
||||||
|
import com.fr.plugin.context.PluginContexts; |
||||||
|
import com.fr.record.analyzer.EnableMetrics; |
||||||
|
import com.fr.stable.fun.Authorize; |
||||||
|
|
||||||
|
import javax.servlet.FilterChain; |
||||||
|
import javax.servlet.FilterConfig; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <RemoteFilter> |
||||||
|
* |
||||||
|
* @author xxx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@Authorize(callSignKey = RemoteFilter.PLUGIN_ID) |
||||||
|
@EnableMetrics |
||||||
|
public class RemoteFilter extends AbstractGlobalRequestFilterProvider { |
||||||
|
public static final String PLUGIN_ID = "com.fr.plugin.ihca.rpc"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 过滤器名称 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String filterName() { |
||||||
|
return "ihcaFilter"; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 过滤规则 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
@Focus(id = PLUGIN_ID, text = "Plugin-ihca", source = Original.PLUGIN) |
||||||
|
public String[] urlPatterns() { |
||||||
|
if (PluginContexts.currentContext() == null || !PluginContexts.currentContext().isAvailable()) { |
||||||
|
LogKit.error(I18nKit.getLocText("Plugin-ihca_Licence_Expired")); |
||||||
|
return new String[]{}; |
||||||
|
} |
||||||
|
return new String[]{"/decision/remote/design/channel"}; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 过滤器初始化 |
||||||
|
* |
||||||
|
* @param filterConfig |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void init(FilterConfig filterConfig) { |
||||||
|
super.init(filterConfig); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 过滤器处理 |
||||||
|
* |
||||||
|
* @param request |
||||||
|
* @param response |
||||||
|
* @param filterChain |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) { |
||||||
|
try { |
||||||
|
request = new ModifyBodyRequestWrapper(request); |
||||||
|
filterChain.doFilter(request, response); |
||||||
|
} catch (Exception e) { |
||||||
|
LogKit.error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
Plugin-ihca=RPC Plugin |
||||||
|
Plugin-ihca_Group=RPC Plugin |
||||||
|
Plugin-ihca_Config_UriBase=Uri Base |
||||||
|
Plugin-ihca_Config_UriBase_Description=Uri Base |
||||||
|
Plugin-ihca_Licence_Expired=RPC Plugin Licence Expired |
@ -0,0 +1,5 @@ |
|||||||
|
Plugin-ihca=\u8BBE\u8BA1\u5668\u4E8B\u4EF6\u68C0\u6D4B\u63D0\u4EA4\u63D2\u4EF6 |
||||||
|
Plugin-ihca_Group=\u8BBE\u8BA1\u5668\u4E8B\u4EF6\u68C0\u6D4B\u63D0\u4EA4\u63D2\u4EF6 |
||||||
|
Plugin-ihca_Config_UriBase=\u63A5\u53E3URL |
||||||
|
Plugin-ihca_Config_UriBase_Description=\u63A5\u53E3URL |
||||||
|
Plugin-ihca_Licence_Expired=\u8BBE\u8BA1\u5668\u4E8B\u4EF6\u68C0\u6D4B\u63D0\u4EA4\u63D2\u4EF6\u8BB8\u53EF\u8FC7\u671F |
Loading…
Reference in new issue