pioneer
2 years ago
commit
a238b43e06
28 changed files with 2152 additions and 0 deletions
@ -0,0 +1,6 @@
|
||||
# open-JSD-10381 |
||||
|
||||
JSD-10381 调用泛微的邮件webservice接口,进行模板推送,定时任务等功能,实现从定时调度入口进入进行配置\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<plugin> |
||||
<id>com.fr.plugin.ajchk.v10</id> |
||||
<name><![CDATA[定时调度数据接口处理_EK]]></name> |
||||
<active>yes</active> |
||||
<version>1.0.5</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2018-07-31</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[定时调度数据接口处理,实现提交数据给HTTP接口功能。]]></description> |
||||
<change-notes><![CDATA[ |
||||
版本1.0主要功能:<br/> |
||||
[2022-06-20]JSD-10381插件初始化<br/> |
||||
定时调度数据接口处理,实现提交数据给HTTP接口功能。<br/> |
||||
]]></change-notes> |
||||
<main-package>com.fr.plugin.ajchk</main-package> |
||||
<prefer-packages> |
||||
<prefer-package>com.fanruan.api.*</prefer-package> |
||||
</prefer-packages> |
||||
<lifecycle-monitor class="com.fr.plugin.ajchk.interfaces.ActionLifeCycleMonitor"/> |
||||
<extra-core> |
||||
<LocaleFinder class="com.fr.plugin.ajchk.LocaleFinder"/> |
||||
</extra-core> |
||||
<extra-decision> |
||||
<WebResourceProvider class="com.fr.plugin.ajchk.interfaces.HttpWebResourceProvider"/> |
||||
<DecisionDBAccessProvider class="com.fr.plugin.ajchk.interfaces.HttpDecisionDBAccess"/> |
||||
<OutputFormulaProvider class="com.fr.plugin.ajchk.interfaces.HttpFormulaProvider"/> |
||||
</extra-decision> |
||||
<function-recorder class="com.fr.plugin.ajchk.interfaces.HttpWebResourceProvider"/> |
||||
</plugin> |
@ -0,0 +1,19 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: Constants |
||||
* Author: xx |
||||
* Date: 2021/2/21 16:11 |
||||
*/ |
||||
package com.fr.plugin.ajchk; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <Constants> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class Constants { |
||||
public static final String PLUGIN_ID = "com.fr.plugin.ajchk.v10"; |
||||
} |
@ -0,0 +1,24 @@
|
||||
|
||||
package com.fr.plugin.ajchk; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <LocaleFinder> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class LocaleFinder extends AbstractLocaleFinder { |
||||
|
||||
@Override |
||||
public String find() { |
||||
return "com/fr/plugin/ajchk/locale/lang"; |
||||
} |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
} |
@ -0,0 +1,64 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: AbstractDataOutput |
||||
* Author: xx |
||||
* Date: 2021/4/12 15:13 |
||||
*/ |
||||
package com.fr.plugin.ajchk.action; |
||||
|
||||
import com.fanruan.api.i18n.I18nKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.schedule.feature.output.OutputActionHandler; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <AbstractDataOutput> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public abstract class AbstractDataOutput extends OutputActionHandler<OutputHttp> { |
||||
@Override |
||||
public void doAction(OutputHttp outputHttp, Map<String, Object> taskParams) throws Exception { |
||||
this.checkOutputHttp(outputHttp); |
||||
Map<String, String> bodyParams = getHttpParams(outputHttp.getBodyParameters()); |
||||
if (bodyParams.isEmpty()) { |
||||
return; |
||||
} |
||||
Map<String, String> headers = getHttpParams(outputHttp.getHeaders()); |
||||
checkHeader(headers); |
||||
operation(outputHttp, taskParams, bodyParams, headers); |
||||
} |
||||
|
||||
/** |
||||
* 根据参数名在定时调度任务参数结果中,提取参数值信息 |
||||
* |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
private Map<String, String> getHttpParams(String paramsStr) { |
||||
String[] params = paramsStr.split(";"); |
||||
String[] keyAndValue; |
||||
Map<String, String> result = new HashMap<>(); |
||||
for (String content : params) { |
||||
keyAndValue = content.split("="); |
||||
result.put(keyAndValue[0], keyAndValue[1]); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public void checkOutputHttp(OutputHttp outputHttp) throws Exception { |
||||
if (outputHttp == null || StringKit.isBlank(outputHttp.getApiUrl())) { |
||||
throw new Exception(I18nKit.getLocText("Plugin-httpaction_Link_Valid")); |
||||
} |
||||
} |
||||
|
||||
public void checkHeader(Map<String, String> headers) throws Exception { |
||||
} |
||||
|
||||
public abstract void operation(OutputHttp outputHttp, Map<String, Object> taskParams, Map<String, String> bodyParams, Map<String, String> headers) throws Exception; |
||||
} |
@ -0,0 +1,30 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: GetOutput |
||||
* Author: xx |
||||
* Date: 2021/4/12 15:16 |
||||
*/ |
||||
package com.fr.plugin.ajchk.action; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fr.plugin.ajchk.kit.HttpKit; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <GetOutput> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class GetOutput extends AbstractDataOutput { |
||||
|
||||
@Override |
||||
public void operation(OutputHttp outputHttp, Map<String, Object> taskParams, Map<String, String> bodyParams, Map<String, String> headers) throws Exception { |
||||
LogKit.info("httpaction-GetOutput-operation-bodyParams:{}, headers:{}", bodyParams, headers); |
||||
String response = HttpKit.get(outputHttp.getApiUrl(), bodyParams, headers); |
||||
LogKit.info("httpaction-GetOutput-operation-response:{}", response); |
||||
} |
||||
} |
@ -0,0 +1,119 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: OutputHttp |
||||
* Author: xx |
||||
* Date: 2021/4/6 15:45 |
||||
*/ |
||||
package com.fr.plugin.ajchk.action; |
||||
|
||||
import com.fr.plugin.ajchk.entity.OutputHttpEntity; |
||||
import com.fr.schedule.base.bean.Format; |
||||
import com.fr.schedule.base.bean.output.BaseOutputAction; |
||||
import com.fr.schedule.base.constant.ScheduleConstants; |
||||
import com.fr.schedule.base.entity.AbstractScheduleEntity; |
||||
import com.fr.schedule.base.type.RunType; |
||||
import com.fr.third.fasterxml.jackson.annotation.JsonSubTypes; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <OutputHttp> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
@JsonSubTypes.Type(value = OutputHttp.class, name = "OutputHttp") |
||||
public class OutputHttp extends BaseOutputAction { |
||||
private static final long serialVersionUID = 2894577893249191611L; |
||||
|
||||
private String httpType = null; |
||||
private String apiUrl; |
||||
private String bodyContent; |
||||
private String headers; |
||||
private String bodyParameters; |
||||
private boolean previewAttach = false; |
||||
|
||||
public OutputHttp() { |
||||
} |
||||
|
||||
public boolean willExecuteByUser() { |
||||
return true; |
||||
} |
||||
|
||||
public RunType runType() { |
||||
return RunType.CUSTOM_CLASS; |
||||
} |
||||
|
||||
public Class<? extends AbstractScheduleEntity> outputActionEntityClass() { |
||||
return OutputHttpEntity.class; |
||||
} |
||||
|
||||
public AbstractScheduleEntity createOutputActionEntity() { |
||||
OutputHttpEntity httpEntity = new OutputHttpEntity(); |
||||
httpEntity.setId(this.getId()); |
||||
httpEntity.setHttpType(this.getHttpType()); |
||||
httpEntity.setApiUrl(this.getApiUrl()); |
||||
httpEntity.setBodyContent(this.getBodyContent()); |
||||
httpEntity.setHeaders(this.getHeaders()); |
||||
httpEntity.setBodyParameters(this.getBodyParameters()); |
||||
httpEntity.setPreviewAttach(this.isPreviewAttach()); |
||||
return httpEntity; |
||||
} |
||||
|
||||
@Override |
||||
public void modifyFormats(List<Format> formats) { |
||||
if (this.isPreviewAttach()) { |
||||
formats.add(new Format(ScheduleConstants.OUTPUTPNG_FORMAT_NUM)); |
||||
} |
||||
} |
||||
|
||||
public String getHttpType() { |
||||
return httpType; |
||||
} |
||||
|
||||
public void setHttpType(String httpType) { |
||||
this.httpType = httpType; |
||||
} |
||||
|
||||
public String getApiUrl() { |
||||
return apiUrl; |
||||
} |
||||
|
||||
public void setApiUrl(String apiUrl) { |
||||
this.apiUrl = apiUrl; |
||||
} |
||||
|
||||
public String getBodyContent() { |
||||
return bodyContent; |
||||
} |
||||
|
||||
public void setBodyContent(String bodyContent) { |
||||
this.bodyContent = bodyContent; |
||||
} |
||||
|
||||
public String getHeaders() { |
||||
return headers; |
||||
} |
||||
|
||||
public void setHeaders(String headers) { |
||||
this.headers = headers; |
||||
} |
||||
|
||||
public String getBodyParameters() { |
||||
return bodyParameters; |
||||
} |
||||
|
||||
public void setBodyParameters(String bodyParameters) { |
||||
this.bodyParameters = bodyParameters; |
||||
} |
||||
|
||||
public boolean isPreviewAttach() { |
||||
return previewAttach; |
||||
} |
||||
|
||||
public void setPreviewAttach(boolean previewAttach) { |
||||
this.previewAttach = previewAttach; |
||||
} |
||||
} |
@ -0,0 +1,53 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: PostJsonOutput |
||||
* Author: xx |
||||
* Date: 2021/4/15 10:45 |
||||
*/ |
||||
package com.fr.plugin.ajchk.action; |
||||
|
||||
import com.fanruan.api.i18n.I18nKit; |
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.ajchk.kit.HttpKit; |
||||
import com.fr.third.org.apache.http.entity.StringEntity; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <PostJsonOutput> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class PostJsonOutput extends AbstractDataOutput { |
||||
|
||||
@Override |
||||
public void checkHeader(Map<String, String> headers) throws Exception { |
||||
if (!headers.containsKey("Content-Type")) { |
||||
headers.put("Content-Type", "application/json"); |
||||
} |
||||
if (!ComparatorUtils.equalsIgnoreCase(headers.get("Content-Type"), "application/json")) { |
||||
throw new Exception(I18nKit.getLocText("Plugin-httpaction_Header_Content-Type_Valid")); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void operation(OutputHttp outputHttp, Map<String, Object> taskParams, Map<String, String> bodyParams, Map<String, String> headers) throws Exception { |
||||
LogKit.info("httpaction-PostJsonOutput-operation-bodyParams:{}, headers:{}", bodyParams, headers); |
||||
String bodyContent; |
||||
if (StringKit.isNotBlank(outputHttp.getBodyContent())) { |
||||
bodyContent = outputHttp.getBodyContent(); |
||||
} else { |
||||
bodyContent = JSONObject.mapFrom(bodyParams).encode(); |
||||
} |
||||
StringEntity stringEntity = new StringEntity(bodyContent, "UTF-8"); |
||||
String response = HttpKit.executeAndParse(com.fanruan.api.net.http.rs.HttpRequest.custom() |
||||
.url(outputHttp.getApiUrl()).post(stringEntity).headers(headers).build()); |
||||
LogKit.info("httpaction-PostJsonOutput-operation-response:{}", response); |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: PostOutput |
||||
* Author: xx |
||||
* Date: 2021/4/15 10:43 |
||||
*/ |
||||
package com.fr.plugin.ajchk.action; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fr.plugin.ajchk.kit.HttpKit; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <PostOutput> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class PostOutput extends AbstractDataOutput { |
||||
|
||||
@Override |
||||
public void operation(OutputHttp outputHttp, Map<String, Object> taskParams, Map<String, String> bodyParams, Map<String, String> headers) throws Exception { |
||||
LogKit.info("httpaction-PostOutput-operation-bodyParams:{}, headers:{}", bodyParams, headers); |
||||
String response = HttpKit.post(outputHttp.getApiUrl(), bodyParams, headers); |
||||
LogKit.info("httpaction-PostOutput-operation-response:{}", response); |
||||
} |
||||
} |
@ -0,0 +1,108 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: SoapOutput |
||||
* Author: xx |
||||
* Date: 2021/4/15 11:11 |
||||
*/ |
||||
package com.fr.plugin.ajchk.action; |
||||
|
||||
import com.fanruan.api.i18n.I18nKit; |
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.base.TemplateUtils; |
||||
import com.fr.decision.system.bean.message.MessageUrlType; |
||||
import com.fr.decision.webservice.v10.message.MessageService; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.plugin.ajchk.kit.HttpKit; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.org.apache.http.entity.StringEntity; |
||||
import com.fr.third.springframework.web.util.HtmlUtils; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <SoapOutput> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class SoapOutput extends AbstractDataOutput { |
||||
public static final String KEY = "SoapOutput"; |
||||
public static final String FROMID = "fromid"; |
||||
public static final String TOIDS = "toids"; |
||||
public static final String CCIDS = "ccids"; |
||||
public static final String BCCIDS = "bccids"; |
||||
public static final String SUBJECT = "subject"; |
||||
public static final String PATHS = "paths"; |
||||
public static final String REQUEST_XML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservice.email.weaver.com.cn\"><soapenv:Header/><soapenv:Body><web:sendInternalMail><web:in0>${fromid}</web:in0><web:in1>${toids}</web:in1><web:in2>${ccids}</web:in2><web:in3>${bccids}</web:in3><web:in4>${subject}</web:in4><web:in5>${content}</web:in5><web:in6>${paths}</web:in6></web:sendInternalMail></soapenv:Body></soapenv:Envelope>"; |
||||
|
||||
@Override |
||||
public void checkOutputHttp(OutputHttp outputHttp) throws Exception { |
||||
super.checkOutputHttp(outputHttp); |
||||
if (StringKit.isBlank(outputHttp.getBodyContent())) { |
||||
throw new Exception(I18nKit.getLocText("Plugin-httpaction_Body_Content_Valid")); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void checkHeader(Map<String, String> headers) throws Exception { |
||||
if (!headers.containsKey("Content-Type")) { |
||||
headers.put("Content-Type", "text/xml;charset=UTF-8"); |
||||
} |
||||
if (!ComparatorUtils.equalsIgnoreCase(headers.get("Content-Type"), "application/soap+xml") |
||||
&& !ComparatorUtils.equalsIgnoreCase(headers.get("Content-Type"), "text/xml")) { |
||||
throw new Exception(I18nKit.getLocText("Plugin-httpaction_Header_Content-Type_Valid")); |
||||
} |
||||
if (StringKit.isBlank(headers.get("SOAPAction"))) { |
||||
throw new Exception(I18nKit.getLocText("Plugin-httpaction_Header_SOAPAction_Valid")); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void operation(OutputHttp outputHttp, Map<String, Object> taskParams, Map<String, String> bodyParams, Map<String, String> headers) throws Exception { |
||||
LogKit.info("ajchk-SoapOutput-operation-bodyParams:{}, taskParams:{}, headers:{}", bodyParams, taskParams, headers); |
||||
Map<String, String> soapParams = new HashMap<>(); |
||||
soapParams.put(FROMID, bodyParams.get(FROMID)); |
||||
soapParams.put(TOIDS, bodyParams.get(TOIDS)); |
||||
soapParams.put(CCIDS, bodyParams.get(CCIDS)); |
||||
soapParams.put(BCCIDS, bodyParams.get(BCCIDS)); |
||||
soapParams.put(SUBJECT, bodyParams.get(SUBJECT)); |
||||
soapParams.put("content", outputHttp.getBodyContent()); |
||||
soapParams.put(PATHS, createFileInfo(bodyParams.get(PATHS))); |
||||
String soapXml = TemplateUtils.render(REQUEST_XML, soapParams, Calculator.createCalculator()); |
||||
LogKit.info("ajchk-SoapOutput-operation-soapXml:{}, headers:{}", soapXml, headers); |
||||
StringEntity stringEntity = new StringEntity(soapXml, "UTF-8"); |
||||
String response = HttpKit.executeAndParse(com.fanruan.api.net.http.rs.HttpRequest.custom().url(outputHttp.getApiUrl()).post(stringEntity).headers(headers).build()); |
||||
LogKit.info("ajchk-SoapOutput-operation-response:{}", response); |
||||
sendTemplateMessage(HtmlUtils.htmlUnescape(response), SoapOutput.KEY); |
||||
} |
||||
|
||||
private String createFileInfo(String paths) { |
||||
if (StringKit.isBlank(paths) || StringKit.equalsIgnoreCase(paths, "null")) { |
||||
return StringKit.EMPTY; |
||||
} |
||||
String[] files = paths.split(","); |
||||
StringBuilder fileInfo = new StringBuilder(); |
||||
for (String file : files) { |
||||
fileInfo.append("<web:string>").append(file).append("</web:string>"); |
||||
} |
||||
return fileInfo.toString(); |
||||
} |
||||
|
||||
/** |
||||
* 接口返回结果发送消息 |
||||
* |
||||
* @param response |
||||
*/ |
||||
public static void sendTemplateMessage(String response, String type) { |
||||
String content = I18nKit.getLocText("Plugin-httpaction") + "-" + |
||||
type + "-" + |
||||
I18nKit.getLocText("Plugin-httpaction_Result_Message") + |
||||
response; |
||||
MessageService.getInstance().sendMessage2SupperRole(content, StringUtils.EMPTY, MessageUrlType.NONE); |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: OutputHttpDAO |
||||
* Author: xx |
||||
* Date: 2021/4/14 15:38 |
||||
*/ |
||||
package com.fr.plugin.ajchk.dao; |
||||
|
||||
import com.fr.plugin.ajchk.entity.OutputHttpEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <OutputHttpDAO> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class OutputHttpDAO extends BaseDAO<OutputHttpEntity> { |
||||
public final static DAOProvider<OutputHttpEntity> DAO = new DAOProvider() { |
||||
@Override |
||||
public Class getEntityClass() { |
||||
return OutputHttpEntity.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BaseDAO> getDAOClass() { |
||||
return OutputHttpDAO.class; |
||||
} |
||||
}; |
||||
|
||||
public OutputHttpDAO(DAOSession daoSession) { |
||||
super(daoSession); |
||||
} |
||||
|
||||
protected Class<OutputHttpEntity> getEntityClass() { |
||||
return OutputHttpEntity.class; |
||||
} |
||||
} |
@ -0,0 +1,110 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: OutputHttpEntity |
||||
* Author: xx |
||||
* Date: 2021/4/6 15:55 |
||||
*/ |
||||
package com.fr.plugin.ajchk.entity; |
||||
|
||||
import com.fr.plugin.ajchk.action.OutputHttp; |
||||
import com.fr.schedule.base.entity.AbstractScheduleEntity; |
||||
import com.fr.stable.db.entity.TableAssociation; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <OutputHttpEntity> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
@Entity |
||||
@Table(name = "fine_output_httpaction") |
||||
@TableAssociation(associated = true) |
||||
public class OutputHttpEntity extends AbstractScheduleEntity { |
||||
public static final String COLUMN_HTTP_TYPE = "httpType"; |
||||
public static final String COLUMN_API_URL = "apiUrl"; |
||||
public static final String COLUMN_BODY_CONTENT = "bodyContent"; |
||||
public static final String COLUMN_HEADERS = "headers"; |
||||
public static final String COLUMN_BODY_PARAMETERS = "bodyParameters"; |
||||
public static final String COLUMN_PREVIEW_ATTACH = "previewAttach"; |
||||
private static final long serialVersionUID = -7540903658511807256L; |
||||
@Column(name = COLUMN_HTTP_TYPE, length = 65536) |
||||
private String httpType = null; |
||||
@Column(name = COLUMN_API_URL, length = 65536) |
||||
private String apiUrl = null; |
||||
@Column(name = COLUMN_BODY_CONTENT, length = 65536) |
||||
private String bodyContent = null; |
||||
@Column(name = COLUMN_HEADERS, length = 65536) |
||||
private String headers = null; |
||||
@Column(name = COLUMN_BODY_PARAMETERS, length = 65536) |
||||
private String bodyParameters = null; |
||||
@Column(name = COLUMN_PREVIEW_ATTACH) |
||||
private boolean previewAttach = false; |
||||
|
||||
public OutputHttpEntity() { |
||||
} |
||||
|
||||
public OutputHttp createBean() { |
||||
OutputHttp outputHttp = new OutputHttp(); |
||||
outputHttp.setId(this.getId()); |
||||
outputHttp.setHttpType(this.getHttpType()); |
||||
outputHttp.setApiUrl(this.getApiUrl()); |
||||
outputHttp.setBodyContent(this.getBodyContent()); |
||||
outputHttp.setHeaders(this.getHeaders()); |
||||
outputHttp.setBodyParameters(this.getBodyParameters()); |
||||
outputHttp.setPreviewAttach(this.isPreviewAttach()); |
||||
return outputHttp; |
||||
} |
||||
|
||||
public String getHttpType() { |
||||
return httpType; |
||||
} |
||||
|
||||
public void setHttpType(String httpType) { |
||||
this.httpType = httpType; |
||||
} |
||||
|
||||
public String getApiUrl() { |
||||
return apiUrl; |
||||
} |
||||
|
||||
public void setApiUrl(String apiUrl) { |
||||
this.apiUrl = apiUrl; |
||||
} |
||||
|
||||
public String getBodyContent() { |
||||
return bodyContent; |
||||
} |
||||
|
||||
public void setBodyContent(String bodyContent) { |
||||
this.bodyContent = bodyContent; |
||||
} |
||||
|
||||
public String getHeaders() { |
||||
return headers; |
||||
} |
||||
|
||||
public void setHeaders(String headers) { |
||||
this.headers = headers; |
||||
} |
||||
|
||||
public String getBodyParameters() { |
||||
return bodyParameters; |
||||
} |
||||
|
||||
public void setBodyParameters(String bodyParameters) { |
||||
this.bodyParameters = bodyParameters; |
||||
} |
||||
|
||||
public boolean isPreviewAttach() { |
||||
return previewAttach; |
||||
} |
||||
|
||||
public void setPreviewAttach(boolean previewAttach) { |
||||
this.previewAttach = previewAttach; |
||||
} |
||||
} |
@ -0,0 +1,48 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: ActionLifeCycleMonitor |
||||
* Author: xx |
||||
* Date: 2021/4/6 15:34 |
||||
*/ |
||||
package com.fr.plugin.ajchk.interfaces; |
||||
|
||||
import com.fr.plugin.ajchk.action.OutputHttp; |
||||
import com.fr.plugin.ajchk.entity.OutputHttpEntity; |
||||
import com.fr.plugin.ajchk.web.HttpOutputActionHandler; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||
import com.fr.schedule.feature.ScheduleOutputActionEntityRegister; |
||||
import com.fr.schedule.feature.output.OutputActionHandler; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <ActionLifeCycleMonitor> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class ActionLifeCycleMonitor extends AbstractPluginLifecycleMonitor { |
||||
|
||||
public ActionLifeCycleMonitor() { |
||||
} |
||||
|
||||
@Override |
||||
public void afterRun(PluginContext pluginContext) { |
||||
this.registerOutputHandler(); |
||||
} |
||||
|
||||
@Override |
||||
public void beforeStop(PluginContext pluginContext) { |
||||
ScheduleOutputActionEntityRegister.getInstance().removeClass(OutputHttpEntity.class); |
||||
} |
||||
|
||||
/** |
||||
* 注册handler |
||||
*/ |
||||
private void registerOutputHandler() { |
||||
OutputActionHandler.registerHandler(new HttpOutputActionHandler(), OutputHttp.class.getName()); |
||||
ScheduleOutputActionEntityRegister.getInstance().removeClass(OutputHttpEntity.class); |
||||
ScheduleOutputActionEntityRegister.getInstance().addClass(OutputHttpEntity.class); |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: HttpDecisionDBAccess |
||||
* Author: xx |
||||
* Date: 2021/4/14 15:33 |
||||
*/ |
||||
package com.fr.plugin.ajchk.interfaces; |
||||
|
||||
import com.fr.decision.plugin.db.AbstractDecisionDBAccessProvider; |
||||
import com.fr.plugin.ajchk.dao.OutputHttpDAO; |
||||
import com.fr.stable.db.accessor.DBAccessor; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <HttpDecisionDBAccess> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class HttpDecisionDBAccess extends AbstractDecisionDBAccessProvider { |
||||
private static DBAccessor accessor; |
||||
|
||||
public HttpDecisionDBAccess() { |
||||
} |
||||
|
||||
public static DBAccessor getAccessor() { |
||||
return accessor; |
||||
} |
||||
|
||||
public DAOProvider[] registerDAO() { |
||||
return new DAOProvider[]{ |
||||
OutputHttpDAO.DAO |
||||
}; |
||||
} |
||||
|
||||
public void onDBAvailable(DBAccessor dbAccessor) { |
||||
accessor = dbAccessor; |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: HttpFormulaProvider |
||||
* Author: xx |
||||
* Date: 2021/4/19 22:08 |
||||
*/ |
||||
package com.fr.plugin.ajchk.interfaces; |
||||
|
||||
import com.fr.main.workbook.ResultWorkBook; |
||||
import com.fr.plugin.ajchk.action.OutputHttp; |
||||
import com.fr.schedule.base.provider.impl.AbstractOutputFormulaProvider; |
||||
import com.fr.schedule.extension.report.util.ScheduleParameterUtils; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <HttpFormulaProvider> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class HttpFormulaProvider extends AbstractOutputFormulaProvider<OutputHttp, ResultWorkBook> { |
||||
public HttpFormulaProvider() { |
||||
} |
||||
|
||||
public void dealWithFormulaParam(OutputHttp outputHttp, ResultWorkBook resultWorkBook, List<Map<String, Object>> list) throws Exception { |
||||
outputHttp.setApiUrl(ScheduleParameterUtils.dealWithParameter(outputHttp.getApiUrl(), list.get(0), resultWorkBook)); |
||||
outputHttp.setBodyContent(ScheduleParameterUtils.dealWithParameter(outputHttp.getBodyContent(), list.get(0), resultWorkBook)); |
||||
outputHttp.setHeaders(ScheduleParameterUtils.dealWithParameter(outputHttp.getHeaders(), list.get(0), resultWorkBook)); |
||||
outputHttp.setBodyParameters(ScheduleParameterUtils.dealWithParameter(outputHttp.getBodyParameters(), list.get(0), resultWorkBook)); |
||||
} |
||||
|
||||
public String getActionClassName() { |
||||
return OutputHttp.class.getName(); |
||||
} |
||||
} |
@ -0,0 +1,58 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: HttpWebResourceProvider |
||||
* Author: xx |
||||
* Date: 2021/4/6 16:08 |
||||
*/ |
||||
package com.fr.plugin.ajchk.interfaces; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractWebResourceProvider; |
||||
import com.fr.decision.web.MainComponent; |
||||
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 com.fr.web.struct.Atom; |
||||
import com.fr.web.struct.Component; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ParserType; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
|
||||
import static com.fr.plugin.ajchk.Constants.PLUGIN_ID; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <HttpWebResourceProvider> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
@EnableMetrics |
||||
@Authorize(callSignKey = PLUGIN_ID) |
||||
public class HttpWebResourceProvider extends AbstractWebResourceProvider { |
||||
public HttpWebResourceProvider() { |
||||
} |
||||
|
||||
@Override |
||||
public Atom attach() { |
||||
return MainComponent.KEY; |
||||
} |
||||
|
||||
@Override |
||||
@Focus(id = PLUGIN_ID, text = "Plugin-httpaction", source = Original.PLUGIN) |
||||
public Atom[] clients() { |
||||
if (PluginContexts.currentContext().isAvailable()) { |
||||
return new Atom[]{ |
||||
new Component() { |
||||
@Override |
||||
public ScriptPath script(RequestClient client) { |
||||
return ScriptPath.build("com/fr/plugin/ajchk/web/dist/js/httpaction.min.js", ParserType.DYNAMIC); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
return super.clients(); |
||||
} |
||||
} |
@ -0,0 +1,722 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: HttpKit |
||||
* Author: xx |
||||
* Date: 2021/3/17 14:19 |
||||
*/ |
||||
package com.fr.plugin.ajchk.kit; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.macro.EncodeConstants; |
||||
import com.fanruan.api.net.http.rs.HttpRequest; |
||||
import com.fanruan.api.net.http.rs.*; |
||||
import com.fr.third.guava.collect.Maps; |
||||
import com.fr.third.org.apache.http.*; |
||||
import com.fr.third.org.apache.http.client.HttpRequestRetryHandler; |
||||
import com.fr.third.org.apache.http.client.config.RequestConfig; |
||||
import com.fr.third.org.apache.http.client.entity.UrlEncodedFormEntity; |
||||
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; |
||||
import com.fr.third.org.apache.http.client.methods.HttpEntityEnclosingRequestBase; |
||||
import com.fr.third.org.apache.http.client.methods.HttpRequestBase; |
||||
import com.fr.third.org.apache.http.client.protocol.HttpClientContext; |
||||
import com.fr.third.org.apache.http.client.utils.URIBuilder; |
||||
import com.fr.third.org.apache.http.config.Registry; |
||||
import com.fr.third.org.apache.http.config.RegistryBuilder; |
||||
import com.fr.third.org.apache.http.conn.routing.HttpRoute; |
||||
import com.fr.third.org.apache.http.conn.socket.ConnectionSocketFactory; |
||||
import com.fr.third.org.apache.http.conn.socket.LayeredConnectionSocketFactory; |
||||
import com.fr.third.org.apache.http.conn.socket.PlainConnectionSocketFactory; |
||||
import com.fr.third.org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
||||
import com.fr.third.org.apache.http.entity.FileEntity; |
||||
import com.fr.third.org.apache.http.entity.mime.HttpMultipartMode; |
||||
import com.fr.third.org.apache.http.entity.mime.MultipartEntityBuilder; |
||||
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; |
||||
import com.fr.third.org.apache.http.impl.client.HttpClients; |
||||
import com.fr.third.org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
||||
import com.fr.third.org.apache.http.message.BasicNameValuePair; |
||||
import com.fr.third.org.apache.http.protocol.HttpContext; |
||||
import org.jetbrains.annotations.NotNull; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
import javax.net.ssl.*; |
||||
import java.io.*; |
||||
import java.net.URI; |
||||
import java.net.URISyntaxException; |
||||
import java.net.URLEncoder; |
||||
import java.net.UnknownHostException; |
||||
import java.nio.charset.Charset; |
||||
import java.security.KeyManagementException; |
||||
import java.security.NoSuchAlgorithmException; |
||||
import java.security.cert.CertificateException; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import static com.fanruan.api.net.http.rs.HttpRequestType.POST; |
||||
|
||||
/** |
||||
* @author xx |
||||
* @version 10.0 |
||||
* Created by xx on 2019-08-29 |
||||
* <p> |
||||
* http请求工具类,封装了用于http请求的各种方法 |
||||
* 新增https忽略证书功能 Update By xx on 2021-03-17 |
||||
* </p> |
||||
*/ |
||||
public class HttpKit { |
||||
|
||||
private static final int RETRY_TIMES = 5; |
||||
private final static Object SYNC_LOCK = new Object(); |
||||
private static CloseableHttpClient httpClient = null; |
||||
|
||||
/** |
||||
* 根据请求地址创建HttpClient对象 |
||||
* |
||||
* @param url 请求地址 |
||||
* @return HttpClient对象 |
||||
*/ |
||||
public static CloseableHttpClient getHttpClient(String url) { |
||||
String hostname = url.split("/")[2]; |
||||
int port = 80; |
||||
if (hostname.contains(":")) { |
||||
String[] arr = hostname.split(":"); |
||||
hostname = arr[0]; |
||||
port = Integer.parseInt(arr[1]); |
||||
} |
||||
if (httpClient == null) { |
||||
synchronized (SYNC_LOCK) { |
||||
if (httpClient == null) { |
||||
// httpClient = createHttpClient(hostname, port, SSLContexts.createDefault());
|
||||
try { |
||||
httpClient = createHttpClient(hostname, port, createIgnoreVerifySSL()); |
||||
} catch (NoSuchAlgorithmException e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} catch (KeyManagementException e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return httpClient; |
||||
} |
||||
|
||||
/** |
||||
* 新增了https 请求绕过证书认证 |
||||
* |
||||
* @return |
||||
* @throws NoSuchAlgorithmException |
||||
* @throws KeyManagementException |
||||
*/ |
||||
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException { |
||||
SSLContext sc = SSLContext.getInstance("SSLv3"); |
||||
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
|
||||
X509TrustManager trustManager = new X509TrustManager() { |
||||
@Override |
||||
public void checkClientTrusted( |
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate, |
||||
String paramString) throws CertificateException { |
||||
} |
||||
|
||||
@Override |
||||
public void checkServerTrusted( |
||||
java.security.cert.X509Certificate[] paramArrayOfX509Certificate, |
||||
String paramString) throws CertificateException { |
||||
} |
||||
|
||||
@Override |
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() { |
||||
return null; |
||||
} |
||||
}; |
||||
sc.init(null, new TrustManager[]{trustManager}, null); |
||||
return sc; |
||||
} |
||||
|
||||
public static CloseableHttpClient createHttpClient(String hostname, int port, SSLContext sslContext) { |
||||
return createHttpClient(200, 40, 100, hostname, port, sslContext); |
||||
} |
||||
|
||||
private static CloseableHttpClient createHttpClient(int maxTotal, |
||||
int maxPerRoute, |
||||
int maxRoute, |
||||
String hostname, |
||||
int port, |
||||
SSLContext sslContext) { |
||||
ConnectionSocketFactory socketFactory = PlainConnectionSocketFactory.getSocketFactory(); |
||||
LayeredConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext); |
||||
Registry<ConnectionSocketFactory> registry = RegistryBuilder |
||||
.<ConnectionSocketFactory>create() |
||||
.register("http", socketFactory) |
||||
.register("https", sslConnectionSocketFactory) |
||||
.build(); |
||||
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry); |
||||
// 将最大连接数增加
|
||||
cm.setMaxTotal(maxTotal); |
||||
// 将每个路由基础的连接增加
|
||||
cm.setDefaultMaxPerRoute(maxPerRoute); |
||||
HttpHost httpHost = new HttpHost(hostname, port); |
||||
// 将目标主机的最大连接数增加
|
||||
cm.setMaxPerRoute(new HttpRoute(httpHost), maxRoute); |
||||
|
||||
// 请求重试处理
|
||||
HttpRequestRetryHandler httpRequestRetryHandler = new HttpRequestRetryHandler() { |
||||
@Override |
||||
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) { |
||||
if (executionCount >= RETRY_TIMES) {// 如果已经重试了5次,就放弃
|
||||
return false; |
||||
} |
||||
if (exception instanceof NoHttpResponseException) {// 如果服务器丢掉了连接,那么就重试
|
||||
return true; |
||||
} |
||||
if (exception instanceof SSLHandshakeException) {// 不要重试SSL握手异常
|
||||
return false; |
||||
} |
||||
if (exception instanceof InterruptedIOException) {// 超时
|
||||
return false; |
||||
} |
||||
if (exception instanceof UnknownHostException) {// 目标服务器不可达
|
||||
return false; |
||||
} |
||||
if (exception instanceof SSLException) {// SSL握手异常
|
||||
return false; |
||||
} |
||||
|
||||
HttpClientContext clientContext = HttpClientContext.adapt(context); |
||||
com.fr.third.org.apache.http.HttpRequest request = clientContext.getRequest(); |
||||
// 如果请求是幂等的,就再次尝试
|
||||
return !(request instanceof HttpEntityEnclosingRequest); |
||||
} |
||||
}; |
||||
|
||||
return HttpClients.custom() |
||||
.setConnectionManager(cm) |
||||
.setRetryHandler(httpRequestRetryHandler) |
||||
.build(); |
||||
} |
||||
|
||||
/** |
||||
* 设置 httpEntity |
||||
* |
||||
* @param requestBase 请求体 |
||||
* @param httpRequest 请求 |
||||
*/ |
||||
private static void setHttpEntity(@NotNull HttpEntityEnclosingRequestBase requestBase, @NotNull HttpRequest httpRequest) { |
||||
HttpEntity httpEntity = httpRequest.getHttpEntity(); |
||||
if (httpEntity != null) { |
||||
// 如果存在 httpEntity 直接设置
|
||||
requestBase.setEntity(httpEntity); |
||||
return; |
||||
} |
||||
Map<String, String> params = httpRequest.getParams(); |
||||
if (params == null || params.isEmpty()) { |
||||
return; |
||||
} |
||||
List<NameValuePair> pairs = new ArrayList<NameValuePair>(); |
||||
for (Map.Entry<String, String> entry : params.entrySet()) { |
||||
pairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); |
||||
} |
||||
try { |
||||
requestBase.setEntity(new UrlEncodedFormEntity(pairs, httpRequest.getEncoding())); |
||||
} catch (UnsupportedEncodingException e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
private static <V> Map<String, String> transformMap(Map<String, V> oldMap) { |
||||
if (oldMap == null) { |
||||
return null; |
||||
} |
||||
return Maps.transformEntries(oldMap, new Maps.EntryTransformer<String, V, String>() { |
||||
@Override |
||||
public String transformEntry(@Nullable String key, @Nullable V value) { |
||||
return value == null ? null : value.toString(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 发起POST请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params POST请求的参数 |
||||
* @return 服务器返回的文本内容 |
||||
*/ |
||||
public static <V> String post(String url, Map<String, V> params) throws IOException { |
||||
return executeAndParse(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.post(transformMap(params)) |
||||
.build()); |
||||
} |
||||
|
||||
/** |
||||
* 发起POST请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params POST请求的参数 |
||||
* @param responseType 返回类型 |
||||
* @return 服务器返回的文本内容 |
||||
* @see com.fanruan.api.net.http.HttpKit#execute(HttpRequest) |
||||
*/ |
||||
@Deprecated |
||||
public static <T, V> T post(String url, Map<String, V> params, HttpResponseType<T> responseType) throws IOException { |
||||
CloseableHttpResponse response = execute(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.post(transformMap(params)) |
||||
.build()); |
||||
return responseType.result(response, null); |
||||
} |
||||
|
||||
/** |
||||
* 发起POST请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params POST请求的参数 |
||||
* @param headers 请求头 |
||||
* @return 服务器返回的文本内容 |
||||
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest) |
||||
*/ |
||||
@Deprecated |
||||
public static <V> String post(String url, Map<String, V> params, Map<String, String> headers) throws IOException { |
||||
return executeAndParse(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.post(transformMap(params)) |
||||
.headers(headers) |
||||
.build()); |
||||
} |
||||
|
||||
/** |
||||
* 发起POST请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params POST请求的参数 |
||||
* @param headers 请求头 |
||||
* @param responseType 返回类型 |
||||
* @return 服务器返回的文本内容 |
||||
* @see com.fanruan.api.net.http.HttpKit#execute(HttpRequest) |
||||
*/ |
||||
@Deprecated |
||||
public static <T, V> T post(String url, Map<String, V> params, Map<String, String> headers, HttpResponseType<T> responseType) throws IOException { |
||||
CloseableHttpResponse response = execute(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.post(transformMap(params)) |
||||
.headers(headers) |
||||
.build()); |
||||
return responseType.result(response, null); |
||||
} |
||||
|
||||
/** |
||||
* 发起POST请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params POST请求的参数 |
||||
* @param responseEncoding 响应的文本的编码 |
||||
* @return 服务器返回的文本内容 |
||||
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle) |
||||
*/ |
||||
@Deprecated |
||||
public static <V> String post(String url, Map<String, V> params, String responseEncoding) throws IOException { |
||||
return executeAndParse(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.post(transformMap(params)) |
||||
.build(), |
||||
new TextResponseHandle(responseEncoding)); |
||||
} |
||||
|
||||
/** |
||||
* 发起POST请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params POST请求的参数 |
||||
* @param responseEncoding 响应的文本的编码 |
||||
* @param headers 请求头 |
||||
* @return 服务器返回的文本内容 |
||||
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle) |
||||
*/ |
||||
@Deprecated |
||||
public static <V> String post(String url, Map<String, V> params, String responseEncoding, Map<String, String> headers) throws IOException { |
||||
return executeAndParse(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.post(transformMap(params)) |
||||
.headers(headers) |
||||
.build(), |
||||
new TextResponseHandle(responseEncoding)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 发起POST请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params POST请求的参数 |
||||
* @param responseEncoding 响应的文本的编码 |
||||
* @param paramsEncoding 参数编码 |
||||
* @param headers 请求头 |
||||
* @return 服务器返回的文本内容 |
||||
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle) |
||||
*/ |
||||
public static <V> String post(String url, Map<String, V> params, String responseEncoding, String paramsEncoding, Map<String, String> headers) throws IOException { |
||||
return executeAndParse(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.post(transformMap(params)) |
||||
.encoding(paramsEncoding) |
||||
.headers(headers) |
||||
.build(), |
||||
new TextResponseHandle(responseEncoding)); |
||||
} |
||||
|
||||
/** |
||||
* 发起POST请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params POST请求的参数 |
||||
* @param responseEncoding 响应的文本的编码 |
||||
* @param paramsEncoding 参数编码 |
||||
* @param headers 请求头 |
||||
* @param responseType 返回值类型 |
||||
* @return 服务器返回的文本内容 |
||||
* @see com.fanruan.api.net.http.HttpKit#execute(HttpRequest) |
||||
*/ |
||||
public static <T, V> T post(String url, Map<String, V> params, String responseEncoding, String paramsEncoding, Map<String, String> headers, HttpResponseType<T> responseType) throws IOException { |
||||
CloseableHttpResponse response = execute(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.post(transformMap(params)) |
||||
.encoding(paramsEncoding) |
||||
.headers(headers) |
||||
.build()); |
||||
return responseType.result(response, responseEncoding); |
||||
} |
||||
|
||||
/** |
||||
* 发起GET请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @return 服务器返回的文本内容 |
||||
*/ |
||||
public static String get(String url) throws IOException { |
||||
return executeAndParse(HttpRequest.custom().url(url).build()); |
||||
} |
||||
|
||||
/** |
||||
* 发起GET请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params 参数 |
||||
* @return 服务器返回的文本内容 |
||||
*/ |
||||
public static String get(String url, Map<String, String> params) throws IOException { |
||||
return executeAndParse(HttpRequest.custom().url(url).params(params).build()); |
||||
} |
||||
|
||||
/** |
||||
* 发起GET请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params 参数 |
||||
* @param headers 请求头 |
||||
* @return 服务器返回的文本内容 |
||||
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle) |
||||
*/ |
||||
public static String get(String url, Map<String, String> params, Map<String, String> headers) throws IOException { |
||||
return executeAndParse(HttpRequest.custom().url(url).params(params).headers(headers).build()); |
||||
} |
||||
|
||||
/** |
||||
* 发起GET请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params 参数 |
||||
* @param responseEncoding 返回的文本的编码 |
||||
* @return 服务器返回的文本内容 |
||||
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle) |
||||
*/ |
||||
public static String get(String url, Map<String, String> params, String responseEncoding) throws IOException { |
||||
return executeAndParse(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.params(params) |
||||
.build(), |
||||
new TextResponseHandle(responseEncoding)); |
||||
} |
||||
|
||||
/** |
||||
* 发起GET请求并获取返回的文本 |
||||
* |
||||
* @param url 响应请求的的服务器地址 |
||||
* @param params 参数 |
||||
* @param responseEncoding 返回的文本的编码 |
||||
* @return 服务器返回的文本内容 |
||||
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle) |
||||
*/ |
||||
public static String get(String url, Map<String, String> params, String responseEncoding, Map<String, String> headers) throws IOException { |
||||
return executeAndParse(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.params(params) |
||||
.headers(headers) |
||||
.build(), |
||||
new TextResponseHandle(responseEncoding)); |
||||
} |
||||
|
||||
/** |
||||
* 从指定的地址下载文件 |
||||
* |
||||
* @param url 文件下载地址 |
||||
* @return 文件的字节流 |
||||
* @throws IOException 下载过程中出现错误则抛出此异常 |
||||
*/ |
||||
public static ByteArrayInputStream download(String url) throws IOException { |
||||
return executeAndParse(HttpRequest.custom().url(url).build(), StreamResponseHandle.DEFAULT); |
||||
} |
||||
|
||||
/** |
||||
* 从指定的地址下载文件 |
||||
* |
||||
* @param url 文件下载地址 |
||||
* @param params 参数对 |
||||
* @param responseEncoding 响应的文件编码 |
||||
* @param headers 请求头 |
||||
* @return 文件的字节流 |
||||
* @throws IOException 下载过程中出现错误则抛出此异常 |
||||
*/ |
||||
public static ByteArrayInputStream download(String url, Map<String, String> params, String responseEncoding, Map<String, String> headers) throws IOException { |
||||
return executeAndParse(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.params(params) |
||||
.headers(headers) |
||||
.build(), |
||||
new StreamResponseHandle(responseEncoding)); |
||||
} |
||||
|
||||
/** |
||||
* 上传文件到指定的服务器 |
||||
* |
||||
* @param url 接收文件的服务器地址 |
||||
* @param file 要上传的文件,默认的文件编码为utf-8 |
||||
* @throws IOException 上传中出现错误则抛出此异常 |
||||
*/ |
||||
public static void upload(String url, File file) throws IOException { |
||||
upload(url, file, Charset.forName("utf-8")); |
||||
} |
||||
|
||||
/** |
||||
* 上传文件到指定的服务器 |
||||
* |
||||
* @param url 接收文件的服务器地址 |
||||
* @param file 要上传的文件 |
||||
* @param charset 文件的编码 |
||||
* @throws IOException 上传中出现错误则抛出此异常 |
||||
*/ |
||||
public static void upload(String url, File file, Charset charset) throws IOException { |
||||
upload(url, new FileEntity(file), charset); |
||||
} |
||||
|
||||
/** |
||||
* 上传文件到指定的服务器 |
||||
* |
||||
* @param url 接收文件的服务器地址 |
||||
* @param builder 附件构造器 |
||||
* @param charset 文件的编码 |
||||
* @throws IOException 上传中出现错误则抛出此异常 |
||||
*/ |
||||
public static void upload(String url, MultipartEntityBuilder builder, Charset charset) throws IOException { |
||||
upload(url, builder, charset, Collections.<String, String>emptyMap(), POST); |
||||
} |
||||
|
||||
/** |
||||
* 上传文件到指定的服务器 |
||||
* |
||||
* @param url 接收文件的服务器地址 |
||||
* @param fileEntity 文件实体 |
||||
* @param charset 文件的编码 |
||||
* @throws IOException 上传中出现错误则抛出此异常 |
||||
*/ |
||||
public static void upload(String url, FileEntity fileEntity, Charset charset) throws IOException { |
||||
upload(url, fileEntity, charset, Collections.<String, String>emptyMap(), POST); |
||||
} |
||||
|
||||
/** |
||||
* 上传多文件到指定的服务器 |
||||
* |
||||
* @param url 接收文件的服务器地址 |
||||
* @param builder 附件构造器 |
||||
* @param charset 文件的编码 |
||||
* @param headers 请求头 |
||||
* @param httpRequestType 请求类型 |
||||
* @throws IOException 上传中出现错误则抛出此异常 |
||||
*/ |
||||
public static void upload(String url, MultipartEntityBuilder builder, Charset charset, Map<String, String> headers, HttpRequestType httpRequestType) throws IOException { |
||||
// richie:采用浏览器模式,防止出现乱码
|
||||
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); |
||||
HttpEntity reqEntity = builder.setCharset(charset).build(); |
||||
upload(url, reqEntity, charset, headers, httpRequestType); |
||||
} |
||||
|
||||
/** |
||||
* 上传文件到指定的服务器 |
||||
* |
||||
* @param url 接收文件的服务器地址 |
||||
* @param reqEntity 请求实体 |
||||
* @param charset 文件的编码 |
||||
* @param headers 请求头 |
||||
* @param httpRequestType 请求类型 |
||||
* @throws IOException 上传中出现错误则抛出此异常 |
||||
*/ |
||||
public static void upload(String url, HttpEntity reqEntity, Charset charset, Map<String, String> headers, HttpRequestType httpRequestType) throws IOException { |
||||
executeAndParse(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.headers(headers) |
||||
.method(httpRequestType) |
||||
.httpEntity(reqEntity) |
||||
.encoding(charset.toString()) |
||||
.build(), |
||||
UploadResponseHandle.DEFAULT); |
||||
} |
||||
|
||||
public static String uploadFile(String url, HttpEntity httpEntity, Charset charset, Map<String, String> map, HttpRequestType httpRequestType) throws IOException { |
||||
return executeAndParse(HttpRequest |
||||
.custom() |
||||
.url(url) |
||||
.headers(map) |
||||
.method(httpRequestType) |
||||
.httpEntity(httpEntity) |
||||
.encoding(charset.toString()) |
||||
.build(), |
||||
TextResponseHandle.DEFAULT); |
||||
} |
||||
|
||||
/** |
||||
* 请求资源或服务,使用默认文本http解析器,UTF-8编码 |
||||
* |
||||
* @param httpRequest httpRequest |
||||
* @return 返回处理结果 |
||||
*/ |
||||
public static String executeAndParse(HttpRequest httpRequest) throws IOException { |
||||
return executeAndParse(httpRequest, TextResponseHandle.DEFAULT); |
||||
} |
||||
|
||||
/** |
||||
* 请求资源或服务,自请求参数,并指定 http 响应处理器 |
||||
* 例: |
||||
* <pre> |
||||
* String res = HttpToolbox.executeAndParse(HttpRequest |
||||
* .custom() |
||||
* .url("") |
||||
* .build(), |
||||
* TextResponseHandle.DEFAULT); |
||||
* </pre> |
||||
* |
||||
* @param httpRequest httpRequest |
||||
* @param handle http 解析器 |
||||
* @return 返回处理结果 |
||||
*/ |
||||
public static <T> T executeAndParse(HttpRequest httpRequest, BaseHttpResponseHandle<T> handle) throws IOException { |
||||
return handle.parse(execute(httpRequest)); |
||||
} |
||||
|
||||
/** |
||||
* 请求资源或服务,传入请求参数 |
||||
* |
||||
* @param httpRequest httpRequest |
||||
* @return 返回处理结果 |
||||
*/ |
||||
public static CloseableHttpResponse execute(HttpRequest httpRequest) throws IOException { |
||||
return execute(getHttpClient(httpRequest.getUrl()), httpRequest); |
||||
} |
||||
|
||||
/** |
||||
* 请求资源或服务,自定义client对象,传入请求参数 |
||||
* |
||||
* @param httpClient http客户端 |
||||
* @param httpRequest httpRequest |
||||
* @return 返回处理结果 |
||||
*/ |
||||
public static CloseableHttpResponse execute(CloseableHttpClient httpClient, HttpRequest httpRequest) throws IOException { |
||||
String url = httpRequest.getUrl(); |
||||
|
||||
// 创建请求对象
|
||||
HttpRequestBase httpRequestBase = httpRequest.getMethod().createHttpRequest(url); |
||||
|
||||
// 设置header信息
|
||||
httpRequestBase.setHeader("User-Agent", "Mozilla/5.0"); |
||||
Map<String, String> headers = httpRequest.getHeaders(); |
||||
if (headers != null && !headers.isEmpty()) { |
||||
for (Map.Entry<String, String> entry : headers.entrySet()) { |
||||
httpRequestBase.setHeader(entry.getKey(), entry.getValue()); |
||||
} |
||||
} |
||||
|
||||
// 配置请求的设置
|
||||
RequestConfig requestConfig = httpRequest.getConfig(); |
||||
if (requestConfig != null) { |
||||
httpRequestBase.setConfig(requestConfig); |
||||
} |
||||
|
||||
// 判断是否支持设置entity(仅HttpPost、HttpPut、HttpPatch支持)
|
||||
if (HttpEntityEnclosingRequestBase.class.isAssignableFrom(httpRequestBase.getClass())) { |
||||
setHttpEntity((HttpEntityEnclosingRequestBase) httpRequestBase, httpRequest); |
||||
} else { |
||||
Map<String, String> params = httpRequest.getParams(); |
||||
if (params != null && !params.isEmpty()) { |
||||
// 注意get等不支持设置entity需要更新拼接之后的URL,但是url变量没有更新
|
||||
httpRequestBase.setURI(URI.create(buildUrl(url, params, httpRequest.getEncoding()))); |
||||
} |
||||
} |
||||
|
||||
return httpClient.execute(httpRequestBase); |
||||
} |
||||
|
||||
/** |
||||
* 构建 Url |
||||
* |
||||
* @param url 请求地址 |
||||
* @param params 参数 |
||||
* @return 拼接之后的地址 |
||||
*/ |
||||
public static String buildUrl(String url, Map<String, String> params) { |
||||
try { |
||||
return buildUrl(url, params, EncodeConstants.ENCODING_UTF_8); |
||||
} catch (UnsupportedEncodingException ignore) { |
||||
} |
||||
return url; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 构建 Url |
||||
* |
||||
* @param url 请求地址 |
||||
* @param params 参数 |
||||
* @return 拼接之后的地址 |
||||
* @throws UnsupportedEncodingException 不支持的编码 |
||||
*/ |
||||
private static String buildUrl(String url, Map<String, String> params, String paramsEncoding) throws UnsupportedEncodingException { |
||||
if (params == null || params.isEmpty()) { |
||||
return url; |
||||
} |
||||
URIBuilder builder; |
||||
try { |
||||
builder = new URIBuilder(url); |
||||
for (Map.Entry<String, String> entry : params.entrySet()) { |
||||
String key = URLEncoder.encode(entry.getKey(), paramsEncoding); |
||||
String value = URLEncoder.encode(entry.getValue(), paramsEncoding); |
||||
builder.setParameter(key, value); |
||||
} |
||||
return builder.build().toString(); |
||||
} catch (URISyntaxException e) { |
||||
LogKit.debug("Error to build url, please check the arguments."); |
||||
} |
||||
return url; |
||||
} |
||||
} |
@ -0,0 +1,51 @@
|
||||
/* |
||||
* Copyright (C), 2018-2021 |
||||
* Project: starter |
||||
* FileName: HttpOutputActionHandler |
||||
* Author: xx |
||||
* Date: 2021/4/6 15:43 |
||||
*/ |
||||
package com.fr.plugin.ajchk.web; |
||||
|
||||
import com.fanruan.api.i18n.I18nKit; |
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fr.plugin.ajchk.action.*; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.schedule.feature.output.OutputActionHandler; |
||||
|
||||
import java.util.LinkedHashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <HttpOutputActionHandler> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class HttpOutputActionHandler extends OutputActionHandler<OutputHttp> { |
||||
public static final Map<String, AbstractDataOutput> httpTypeMap = new LinkedHashMap<String, AbstractDataOutput>() { |
||||
private static final long serialVersionUID = -5593329532670407219L; |
||||
|
||||
{ |
||||
put(I18nKit.getLocText("Plugin-httpaction_ClassName_Get"), new GetOutput()); |
||||
put(I18nKit.getLocText("Plugin-httpaction_ClassName_Post"), new PostOutput()); |
||||
put(I18nKit.getLocText("Plugin-httpaction_ClassName_Post_Json"), new PostJsonOutput()); |
||||
put(I18nKit.getLocText("Plugin-httpaction_ClassName_Soap"), new SoapOutput()); |
||||
} |
||||
}; |
||||
|
||||
public HttpOutputActionHandler() { |
||||
} |
||||
|
||||
@Override |
||||
public void doAction(OutputHttp outputHttp, Map<String, Object> params) throws Exception { |
||||
if (!PluginContexts.currentContext().isAvailable()) { |
||||
return; |
||||
} |
||||
//todo 判断
|
||||
LogKit.info("ajchk-HttpOutputActionHandler-doAction-isPreviewAttach:{}", outputHttp.isPreviewAttach()); |
||||
AbstractDataOutput outputActionHandler = httpTypeMap.get(outputHttp.getHttpType()); |
||||
outputActionHandler.doAction(outputHttp, params); |
||||
} |
||||
} |
@ -0,0 +1,17 @@
|
||||
Plugin-httpaction=Schedule Http Action |
||||
Plugin-httpaction_ClassPath_Title=Submit Method |
||||
Plugin-httpaction_Url=API Url |
||||
Plugin-httpaction_Header_Property=Header Property |
||||
Plugin-httpaction_Body_Property=Body Property |
||||
Plugin-httpaction_Body_Content=Body Content |
||||
Plugin-httpaction_ClassName_Get_Submit=Get |
||||
Plugin-httpaction_ClassName_Post_Submit=Post |
||||
Plugin-httpaction_ClassName_Post_Json_Submit=PostJson |
||||
Plugin-httpaction_ClassName_Soap_Submit=Soap |
||||
Plugin-httpaction_Handing_Way=HTTP API |
||||
Plugin-httpaction_Link_Valid=URL is not empty |
||||
Plugin-httpaction_Body_Content_Valid=Body Template is not empty |
||||
Plugin-httpaction_Body_Content_Format_Valid=body Template Error |
||||
Plugin-httpaction_Header_Content-Type_Valid=Header Content-Type Error |
||||
Plugin-httpaction_Header_SOAPAction_Valid=Header SOAPAction Error |
||||
Plugin-httpaction_Result_Message=Result: |
@ -0,0 +1,17 @@
|
||||
Plugin-httpaction=\u5B9A\u65F6\u8C03\u5EA6\u6570\u636E\u63A5\u53E3\u5904\u7406 |
||||
Plugin-httpaction_ClassPath_Title=\u63D0\u4EA4\u65B9\u5F0F |
||||
Plugin-httpaction_Url=\u63A5\u53E3\u5730\u5740 |
||||
Plugin-httpaction_Header_Property=Header\u53C2\u6570 |
||||
Plugin-httpaction_Body_Property=Body\u53C2\u6570 |
||||
Plugin-httpaction_Body_Content=Body\u5185\u5BB9 |
||||
Plugin-httpaction_ClassName_Get=Get |
||||
Plugin-httpaction_ClassName_Post=Post |
||||
Plugin-httpaction_ClassName_Post_Json=PostJson |
||||
Plugin-httpaction_ClassName_Soap=Soap |
||||
Plugin-httpaction_Handing_Way=HTTP\u63A5\u53E3 |
||||
Plugin-httpaction_Link_Valid=\u94FE\u63A5\u4E0D\u80FD\u4E3A\u7A7A |
||||
Plugin-httpaction_Body_Content_Valid=body\u6A21\u677F\u4E0D\u80FD\u4E3A\u7A7A |
||||
Plugin-httpaction_Body_Content_Format_Valid=body\u6A21\u677F\u683C\u5F0F\u9519\u8BEF |
||||
Plugin-httpaction_Header_Content-Type_Valid=Header\u53C2\u6570Content-Type\u4E3A\u7A7A\u6216\u9519\u8BEF |
||||
Plugin-httpaction_Header_SOAPAction_Valid=Header\u53C2\u6570SOAPAction\u4E3A\u7A7A\u6216\u9519\u8BEF |
||||
Plugin-httpaction_Result_Message=\u7ED3\u679C: |
@ -0,0 +1,260 @@
|
||||
!(function () { |
||||
var HttpAction = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "" |
||||
}, |
||||
_store: function () { |
||||
return BI.Models.getModel("dec.model.schedule.task.file.handling.httpaction") |
||||
}, |
||||
watch: { |
||||
httpType: function (e) { |
||||
this.httpType.setValue(e); |
||||
}, |
||||
apiUrl: function (e) { |
||||
this.apiUrl.setValue(e) |
||||
}, |
||||
headers: function (e) { |
||||
this.headers.setValue(e) |
||||
}, |
||||
bodyParameters: function (e) { |
||||
this.bodyParameters.setValue(e) |
||||
}, |
||||
bodyContent: function (e) { |
||||
this.bodyContent.setValue(e) |
||||
}, |
||||
previewAttach: function (e) { |
||||
this.previewAttach.setSelected(e) |
||||
} |
||||
}, |
||||
mounted: function () { |
||||
var e = this.options.value; |
||||
BI.isEmpty(e) || this.setValue(e) |
||||
}, |
||||
render: function () { |
||||
var self = this; |
||||
return { |
||||
type: "bi.vertical", |
||||
tgap: 15, |
||||
items: [{//提交方式
|
||||
type: "bi.horizontal", |
||||
items: [{ |
||||
type: "bi.label", |
||||
cls: "dec-font-weight-bold", |
||||
width: 115, |
||||
height: 24, |
||||
textAlign: "left", |
||||
text: BI.i18nText("Plugin-httpaction_ClassPath_Title") |
||||
}, |
||||
{ |
||||
type: "bi.text_value_combo", |
||||
width: 300, |
||||
value: self.model.httpType, |
||||
ref: function (e) { |
||||
self.httpType = e |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.TextValueCombo.EVENT_CHANGE, |
||||
action: function () { |
||||
var e = this.getValue()[0]; |
||||
self.store.setHttpType(e) |
||||
} |
||||
}], |
||||
items: [ |
||||
{ |
||||
text: BI.i18nText("Plugin-httpaction_ClassName_Soap"), |
||||
value: BI.i18nText("Plugin-httpaction_ClassName_Soap") |
||||
}] |
||||
}] |
||||
}, |
||||
{//接口地址
|
||||
type: "dec.label.editor.item", |
||||
text: BI.i18nText("Plugin-httpaction_Url"), |
||||
textCls: "dec-font-weight-bold", |
||||
textWidth: 115, |
||||
editorWidth: 300, |
||||
watermark: BI.i18nText("Dec-Basic_Support_Formula_Input"), |
||||
ref: function (e) { |
||||
self.apiUrl = e |
||||
}, |
||||
allowBlank: false, |
||||
bubbleError: false, |
||||
errorText: BI.i18nText("Plugin-httpaction_Link_Valid"), |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setApiUrl(this.getValue()); |
||||
} |
||||
}] |
||||
}, |
||||
{//header参数
|
||||
type: "dec.label.editor.item", |
||||
text: BI.i18nText("Plugin-httpaction_Header_Property"), |
||||
textCls: "dec-font-weight-bold", |
||||
textWidth: 115, |
||||
editorWidth: 300, |
||||
watermark: BI.i18nText("Dec-Basic_Support_Formula_Input"), |
||||
ref: function (e) { |
||||
self.headers = e |
||||
}, |
||||
allowBlank: false, |
||||
bubbleError: false, |
||||
errorText: BI.i18nText("Dec-Error_Null"), |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setHeaders(this.getValue()); |
||||
} |
||||
}] |
||||
}, |
||||
{//body参数
|
||||
type: "dec.label.editor.item", |
||||
text: BI.i18nText("Plugin-httpaction_Body_Property"), |
||||
textCls: "dec-font-weight-bold", |
||||
textWidth: 115, |
||||
editorWidth: 300, |
||||
watermark: BI.i18nText("Dec-Basic_Support_Formula_Input"), |
||||
ref: function (e) { |
||||
self.bodyParameters = e |
||||
}, |
||||
allowBlank: false, |
||||
bubbleError: false, |
||||
errorText: BI.i18nText("Dec-Error_Null"), |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setBodyParameters(this.getValue()); |
||||
} |
||||
}] |
||||
}, |
||||
{//bodyContent
|
||||
type: "dec.label.textarea.item", |
||||
text: BI.i18nText("Plugin-httpaction_Body_Content"), |
||||
textCls: "dec-font-weight-bold", |
||||
watermark: BI.i18nText("Dec-Basic_Support_Formula_Input"), |
||||
textWidth: 100, |
||||
editorWidth: 390, |
||||
editorHeight: 100, |
||||
ref: function (e) { |
||||
self.bodyContent = e |
||||
}, |
||||
allowBlank: false, |
||||
bubbleError: false, |
||||
errorText: BI.i18nText("Plugin-httpaction_Body_Content_Valid"), |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setBodyContent(this.getValue()); |
||||
} |
||||
}] |
||||
}, |
||||
{//PreviewTemplate
|
||||
type: "bi.multi_select_item", |
||||
selected: self.model.previewAttach, |
||||
logic: { |
||||
dynamic: !0 |
||||
}, |
||||
text: BI.i18nText("Dec-Task_Preview_Template_Content"), |
||||
ref: function (e) { |
||||
self.previewAttach = e |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.MultiSelectItem.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setPreviewAttach(this.isSelected()); |
||||
} |
||||
}] |
||||
}] |
||||
}; |
||||
}, |
||||
/** |
||||
* 设定各项值 |
||||
*/ |
||||
setValue: function (e) { |
||||
var self = this; |
||||
BI.map(e, function (e, t) { |
||||
self.store.setHttpType(t.httpType); |
||||
self.store.setApiUrl(t.apiUrl); |
||||
self.store.setHeaders(t.headers); |
||||
self.store.setBodyParameters(t.bodyParameters); |
||||
self.store.setBodyContent(t.bodyContent); |
||||
self.store.setPreviewAttach(t.previewAttach); |
||||
}); |
||||
}, |
||||
/** |
||||
* 校验函数,可选 |
||||
* 返回值当前处理方式是否通过校验 |
||||
* @returns {boolean} |
||||
*/ |
||||
validation: function () { |
||||
return true; |
||||
}, |
||||
/** |
||||
* 取值函数,必选 |
||||
* 返回的值放到outputActionList中 |
||||
* @returns {{}} |
||||
*/ |
||||
getValue: function () { |
||||
var self = this; |
||||
return { |
||||
OutputHttp: BI.extend(self.value, { |
||||
"@class": "com.fr.plugin.ajchk.action.OutputHttp", |
||||
actionName: "com.fr.plugin.ajchk.action.OutputHttp", |
||||
httpType: self.model.httpType, |
||||
apiUrl: self.model.apiUrl, |
||||
headers: self.model.headers, |
||||
bodyParameters: self.model.bodyParameters, |
||||
bodyContent: self.model.bodyContent, |
||||
previewAttach: self.model.previewAttach |
||||
}) |
||||
}; |
||||
} |
||||
}); |
||||
BI.shortcut("dec.schedule.task.file.handling.httpaction", HttpAction); |
||||
})(); |
||||
!(function() { |
||||
var HttpActionModel = BI.inherit(Fix.Model, { |
||||
context: ["currTask"], |
||||
state: function() { |
||||
return { |
||||
httpType: BI.i18nText("Plugin-httpaction_ClassName_Get"), |
||||
apiUrl: '', |
||||
headers: '', |
||||
bodyParameters: '', |
||||
bodyContent: '', |
||||
previewAttach: false |
||||
} |
||||
}, |
||||
actions: { |
||||
setHttpType: function (e) { |
||||
this.model.httpType = e |
||||
}, |
||||
setApiUrl: function (e) { |
||||
this.model.apiUrl = e |
||||
}, |
||||
setHeaders: function (e) { |
||||
this.model.headers = e |
||||
}, |
||||
setBodyParameters: function (e) { |
||||
this.model.bodyParameters = e |
||||
}, |
||||
setBodyContent: function (e) { |
||||
this.model.bodyContent = e |
||||
}, |
||||
setPreviewAttach: function (e) { |
||||
e ? this.model.currTask.scheduleOutput.formats = BI.union(this.model.currTask.scheduleOutput.formats, [DecCst.Schedule.Template.Accessory.PREVIEW]) : BI.remove(this.model.currTask.scheduleOutput.formats, DecCst.Schedule.Template.Accessory.PREVIEW) |
||||
this.model.previewAttach = e; |
||||
} |
||||
} |
||||
}); |
||||
BI.model("dec.model.schedule.task.file.handling.httpaction", HttpActionModel); |
||||
}) (); |
||||
!(function () { |
||||
BI.config("dec.provider.schedule", function (provider) { |
||||
provider.registerHandingWay({ |
||||
text: BI.i18nText("Plugin-httpaction_Handing_Way"), |
||||
value: "com.fr.plugin.ajchk.action.OutputHttp", |
||||
cardType: "dec.schedule.task.file.handling.httpaction", |
||||
actions: [] |
||||
}, [DecCst.Schedule.TaskType.DEFAULT, DecCst.Schedule.TaskType.REPORT, DecCst.Schedule.TaskType.BI]); |
||||
}); |
||||
})(); |
@ -0,0 +1,2 @@
|
||||
/** com.fr.plugin.httpaction 22-06-28 11:10:23 */ |
||||
!function(){var t=BI.inherit(BI.Widget,{props:{baseCls:""},_store:function(){return BI.Models.getModel("dec.model.schedule.task.file.handling.httpaction")},watch:{httpType:function(t){this.httpType.setValue(t)},apiUrl:function(t){this.apiUrl.setValue(t)},headers:function(t){this.headers.setValue(t)},bodyParameters:function(t){this.bodyParameters.setValue(t)},bodyContent:function(t){this.bodyContent.setValue(t)},previewAttach:function(t){this.previewAttach.setSelected(t)}},mounted:function(){var t=this.options.value;BI.isEmpty(t)||this.setValue(t)},render:function(){var e=this;return{type:"bi.vertical",tgap:15,items:[{type:"bi.horizontal",items:[{type:"bi.label",cls:"dec-font-weight-bold",width:115,height:24,textAlign:"left",text:BI.i18nText("Plugin-httpaction_ClassPath_Title")},{type:"bi.text_value_combo",width:300,value:e.model.httpType,ref:function(t){e.httpType=t},listeners:[{eventName:BI.TextValueCombo.EVENT_CHANGE,action:function(){var t=this.getValue()[0];e.store.setHttpType(t)}}],items:[{text:BI.i18nText("Plugin-httpaction_ClassName_Soap"),value:BI.i18nText("Plugin-httpaction_ClassName_Soap")}]}]},{type:"dec.label.editor.item",text:BI.i18nText("Plugin-httpaction_Url"),textCls:"dec-font-weight-bold",textWidth:115,editorWidth:300,watermark:BI.i18nText("Dec-Basic_Support_Formula_Input"),ref:function(t){e.apiUrl=t},allowBlank:!1,bubbleError:!1,errorText:BI.i18nText("Plugin-httpaction_Link_Valid"),listeners:[{eventName:BI.Editor.EVENT_CHANGE,action:function(){e.store.setApiUrl(this.getValue())}}]},{type:"dec.label.editor.item",text:BI.i18nText("Plugin-httpaction_Header_Property"),textCls:"dec-font-weight-bold",textWidth:115,editorWidth:300,watermark:BI.i18nText("Dec-Basic_Support_Formula_Input"),ref:function(t){e.headers=t},allowBlank:!1,bubbleError:!1,errorText:BI.i18nText("Dec-Error_Null"),listeners:[{eventName:BI.Editor.EVENT_CHANGE,action:function(){e.store.setHeaders(this.getValue())}}]},{type:"dec.label.editor.item",text:BI.i18nText("Plugin-httpaction_Body_Property"),textCls:"dec-font-weight-bold",textWidth:115,editorWidth:300,watermark:BI.i18nText("Dec-Basic_Support_Formula_Input"),ref:function(t){e.bodyParameters=t},allowBlank:!1,bubbleError:!1,errorText:BI.i18nText("Dec-Error_Null"),listeners:[{eventName:BI.Editor.EVENT_CHANGE,action:function(){e.store.setBodyParameters(this.getValue())}}]},{type:"dec.label.textarea.item",text:BI.i18nText("Plugin-httpaction_Body_Content"),textCls:"dec-font-weight-bold",watermark:BI.i18nText("Dec-Basic_Support_Formula_Input"),textWidth:100,editorWidth:390,editorHeight:100,ref:function(t){e.bodyContent=t},allowBlank:!1,bubbleError:!1,errorText:BI.i18nText("Plugin-httpaction_Body_Content_Valid"),listeners:[{eventName:BI.Editor.EVENT_CHANGE,action:function(){e.store.setBodyContent(this.getValue())}}]},{type:"bi.multi_select_item",selected:e.model.previewAttach,logic:{dynamic:!0},text:BI.i18nText("Dec-Task_Preview_Template_Content"),ref:function(t){e.previewAttach=t},listeners:[{eventName:BI.MultiSelectItem.EVENT_CHANGE,action:function(){e.store.setPreviewAttach(this.isSelected())}}]}]}},setValue:function(t){var i=this;BI.map(t,function(t,e){i.store.setHttpType(e.httpType),i.store.setApiUrl(e.apiUrl),i.store.setHeaders(e.headers),i.store.setBodyParameters(e.bodyParameters),i.store.setBodyContent(e.bodyContent),i.store.setPreviewAttach(e.previewAttach)})},validation:function(){return!0},getValue:function(){var t=this;return{OutputHttp:BI.extend(t.value,{"@class":"com.fr.plugin.ajchk.action.OutputHttp",actionName:"com.fr.plugin.ajchk.action.OutputHttp",httpType:t.model.httpType,apiUrl:t.model.apiUrl,headers:t.model.headers,bodyParameters:t.model.bodyParameters,bodyContent:t.model.bodyContent,previewAttach:t.model.previewAttach})}}});BI.shortcut("dec.schedule.task.file.handling.httpaction",t)}(),function(){var t=BI.inherit(Fix.Model,{context:["currTask"],state:function(){return{httpType:BI.i18nText("Plugin-httpaction_ClassName_Get"),apiUrl:"",headers:"",bodyParameters:"",bodyContent:"",previewAttach:!1}},actions:{setHttpType:function(t){this.model.httpType=t},setApiUrl:function(t){this.model.apiUrl=t},setHeaders:function(t){this.model.headers=t},setBodyParameters:function(t){this.model.bodyParameters=t},setBodyContent:function(t){this.model.bodyContent=t},setPreviewAttach:function(t){t?this.model.currTask.scheduleOutput.formats=BI.union(this.model.currTask.scheduleOutput.formats,[DecCst.Schedule.Template.Accessory.PREVIEW]):BI.remove(this.model.currTask.scheduleOutput.formats,DecCst.Schedule.Template.Accessory.PREVIEW),this.model.previewAttach=t}}});BI.model("dec.model.schedule.task.file.handling.httpaction",t)}(),BI.config("dec.provider.schedule",function(t){t.registerHandingWay({text:BI.i18nText("Plugin-httpaction_Handing_Way"),value:"com.fr.plugin.ajchk.action.OutputHttp",cardType:"dec.schedule.task.file.handling.httpaction",actions:[]},[DecCst.Schedule.TaskType.DEFAULT,DecCst.Schedule.TaskType.REPORT,DecCst.Schedule.TaskType.BI])}); |
@ -0,0 +1,260 @@
|
||||
!(function () { |
||||
var HttpAction = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "" |
||||
}, |
||||
_store: function () { |
||||
return BI.Models.getModel("dec.model.schedule.task.file.handling.httpaction") |
||||
}, |
||||
watch: { |
||||
httpType: function (e) { |
||||
this.httpType.setValue(e); |
||||
}, |
||||
apiUrl: function (e) { |
||||
this.apiUrl.setValue(e) |
||||
}, |
||||
headers: function (e) { |
||||
this.headers.setValue(e) |
||||
}, |
||||
bodyParameters: function (e) { |
||||
this.bodyParameters.setValue(e) |
||||
}, |
||||
bodyContent: function (e) { |
||||
this.bodyContent.setValue(e) |
||||
}, |
||||
previewAttach: function (e) { |
||||
this.previewAttach.setSelected(e) |
||||
} |
||||
}, |
||||
mounted: function () { |
||||
var e = this.options.value; |
||||
BI.isEmpty(e) || this.setValue(e) |
||||
}, |
||||
render: function () { |
||||
var self = this; |
||||
return { |
||||
type: "bi.vertical", |
||||
tgap: 15, |
||||
items: [{//提交方式
|
||||
type: "bi.horizontal", |
||||
items: [{ |
||||
type: "bi.label", |
||||
cls: "dec-font-weight-bold", |
||||
width: 115, |
||||
height: 24, |
||||
textAlign: "left", |
||||
text: BI.i18nText("Plugin-httpaction_ClassPath_Title") |
||||
}, |
||||
{ |
||||
type: "bi.text_value_combo", |
||||
width: 300, |
||||
value: self.model.httpType, |
||||
ref: function (e) { |
||||
self.httpType = e |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.TextValueCombo.EVENT_CHANGE, |
||||
action: function () { |
||||
var e = this.getValue()[0]; |
||||
self.store.setHttpType(e) |
||||
} |
||||
}], |
||||
items: [ |
||||
{ |
||||
text: BI.i18nText("Plugin-httpaction_ClassName_Soap"), |
||||
value: BI.i18nText("Plugin-httpaction_ClassName_Soap") |
||||
}] |
||||
}] |
||||
}, |
||||
{//接口地址
|
||||
type: "dec.label.editor.item", |
||||
text: BI.i18nText("Plugin-httpaction_Url"), |
||||
textCls: "dec-font-weight-bold", |
||||
textWidth: 115, |
||||
editorWidth: 300, |
||||
watermark: BI.i18nText("Dec-Basic_Support_Formula_Input"), |
||||
ref: function (e) { |
||||
self.apiUrl = e |
||||
}, |
||||
allowBlank: false, |
||||
bubbleError: false, |
||||
errorText: BI.i18nText("Plugin-httpaction_Link_Valid"), |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setApiUrl(this.getValue()); |
||||
} |
||||
}] |
||||
}, |
||||
{//header参数
|
||||
type: "dec.label.editor.item", |
||||
text: BI.i18nText("Plugin-httpaction_Header_Property"), |
||||
textCls: "dec-font-weight-bold", |
||||
textWidth: 115, |
||||
editorWidth: 300, |
||||
watermark: BI.i18nText("Dec-Basic_Support_Formula_Input"), |
||||
ref: function (e) { |
||||
self.headers = e |
||||
}, |
||||
allowBlank: false, |
||||
bubbleError: false, |
||||
errorText: BI.i18nText("Dec-Error_Null"), |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setHeaders(this.getValue()); |
||||
} |
||||
}] |
||||
}, |
||||
{//body参数
|
||||
type: "dec.label.editor.item", |
||||
text: BI.i18nText("Plugin-httpaction_Body_Property"), |
||||
textCls: "dec-font-weight-bold", |
||||
textWidth: 115, |
||||
editorWidth: 300, |
||||
watermark: BI.i18nText("Dec-Basic_Support_Formula_Input"), |
||||
ref: function (e) { |
||||
self.bodyParameters = e |
||||
}, |
||||
allowBlank: false, |
||||
bubbleError: false, |
||||
errorText: BI.i18nText("Dec-Error_Null"), |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setBodyParameters(this.getValue()); |
||||
} |
||||
}] |
||||
}, |
||||
{//bodyContent
|
||||
type: "dec.label.textarea.item", |
||||
text: BI.i18nText("Plugin-httpaction_Body_Content"), |
||||
textCls: "dec-font-weight-bold", |
||||
watermark: BI.i18nText("Dec-Basic_Support_Formula_Input"), |
||||
textWidth: 100, |
||||
editorWidth: 390, |
||||
editorHeight: 100, |
||||
ref: function (e) { |
||||
self.bodyContent = e |
||||
}, |
||||
allowBlank: false, |
||||
bubbleError: false, |
||||
errorText: BI.i18nText("Plugin-httpaction_Body_Content_Valid"), |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setBodyContent(this.getValue()); |
||||
} |
||||
}] |
||||
}, |
||||
{//PreviewTemplate
|
||||
type: "bi.multi_select_item", |
||||
selected: self.model.previewAttach, |
||||
logic: { |
||||
dynamic: !0 |
||||
}, |
||||
text: BI.i18nText("Dec-Task_Preview_Template_Content"), |
||||
ref: function (e) { |
||||
self.previewAttach = e |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.MultiSelectItem.EVENT_CHANGE, |
||||
action: function () { |
||||
self.store.setPreviewAttach(this.isSelected()); |
||||
} |
||||
}] |
||||
}] |
||||
}; |
||||
}, |
||||
/** |
||||
* 设定各项值 |
||||
*/ |
||||
setValue: function (e) { |
||||
var self = this; |
||||
BI.map(e, function (e, t) { |
||||
self.store.setHttpType(t.httpType); |
||||
self.store.setApiUrl(t.apiUrl); |
||||
self.store.setHeaders(t.headers); |
||||
self.store.setBodyParameters(t.bodyParameters); |
||||
self.store.setBodyContent(t.bodyContent); |
||||
self.store.setPreviewAttach(t.previewAttach); |
||||
}); |
||||
}, |
||||
/** |
||||
* 校验函数,可选 |
||||
* 返回值当前处理方式是否通过校验 |
||||
* @returns {boolean} |
||||
*/ |
||||
validation: function () { |
||||
return true; |
||||
}, |
||||
/** |
||||
* 取值函数,必选 |
||||
* 返回的值放到outputActionList中 |
||||
* @returns {{}} |
||||
*/ |
||||
getValue: function () { |
||||
var self = this; |
||||
return { |
||||
OutputHttp: BI.extend(self.value, { |
||||
"@class": "com.fr.plugin.ajchk.action.OutputHttp", |
||||
actionName: "com.fr.plugin.ajchk.action.OutputHttp", |
||||
httpType: self.model.httpType, |
||||
apiUrl: self.model.apiUrl, |
||||
headers: self.model.headers, |
||||
bodyParameters: self.model.bodyParameters, |
||||
bodyContent: self.model.bodyContent, |
||||
previewAttach: self.model.previewAttach |
||||
}) |
||||
}; |
||||
} |
||||
}); |
||||
BI.shortcut("dec.schedule.task.file.handling.httpaction", HttpAction); |
||||
})(); |
||||
!(function() { |
||||
var HttpActionModel = BI.inherit(Fix.Model, { |
||||
context: ["currTask"], |
||||
state: function() { |
||||
return { |
||||
httpType: BI.i18nText("Plugin-httpaction_ClassName_Get"), |
||||
apiUrl: '', |
||||
headers: '', |
||||
bodyParameters: '', |
||||
bodyContent: '', |
||||
previewAttach: false |
||||
} |
||||
}, |
||||
actions: { |
||||
setHttpType: function (e) { |
||||
this.model.httpType = e |
||||
}, |
||||
setApiUrl: function (e) { |
||||
this.model.apiUrl = e |
||||
}, |
||||
setHeaders: function (e) { |
||||
this.model.headers = e |
||||
}, |
||||
setBodyParameters: function (e) { |
||||
this.model.bodyParameters = e |
||||
}, |
||||
setBodyContent: function (e) { |
||||
this.model.bodyContent = e |
||||
}, |
||||
setPreviewAttach: function (e) { |
||||
e ? this.model.currTask.scheduleOutput.formats = BI.union(this.model.currTask.scheduleOutput.formats, [DecCst.Schedule.Template.Accessory.PREVIEW]) : BI.remove(this.model.currTask.scheduleOutput.formats, DecCst.Schedule.Template.Accessory.PREVIEW) |
||||
this.model.previewAttach = e; |
||||
} |
||||
} |
||||
}); |
||||
BI.model("dec.model.schedule.task.file.handling.httpaction", HttpActionModel); |
||||
}) (); |
||||
!(function () { |
||||
BI.config("dec.provider.schedule", function (provider) { |
||||
provider.registerHandingWay({ |
||||
text: BI.i18nText("Plugin-httpaction_Handing_Way"), |
||||
value: "com.fr.plugin.ajchk.action.OutputHttp", |
||||
cardType: "dec.schedule.task.file.handling.httpaction", |
||||
actions: [] |
||||
}, [DecCst.Schedule.TaskType.DEFAULT, DecCst.Schedule.TaskType.REPORT, DecCst.Schedule.TaskType.BI]); |
||||
}); |
||||
})(); |
@ -0,0 +1,2 @@
|
||||
/** com.fr.plugin.httpaction 22-06-28 11:10:23 */ |
||||
!function(){var t=BI.inherit(BI.Widget,{props:{baseCls:""},_store:function(){return BI.Models.getModel("dec.model.schedule.task.file.handling.httpaction")},watch:{httpType:function(t){this.httpType.setValue(t)},apiUrl:function(t){this.apiUrl.setValue(t)},headers:function(t){this.headers.setValue(t)},bodyParameters:function(t){this.bodyParameters.setValue(t)},bodyContent:function(t){this.bodyContent.setValue(t)},previewAttach:function(t){this.previewAttach.setSelected(t)}},mounted:function(){var t=this.options.value;BI.isEmpty(t)||this.setValue(t)},render:function(){var e=this;return{type:"bi.vertical",tgap:15,items:[{type:"bi.horizontal",items:[{type:"bi.label",cls:"dec-font-weight-bold",width:115,height:24,textAlign:"left",text:BI.i18nText("Plugin-httpaction_ClassPath_Title")},{type:"bi.text_value_combo",width:300,value:e.model.httpType,ref:function(t){e.httpType=t},listeners:[{eventName:BI.TextValueCombo.EVENT_CHANGE,action:function(){var t=this.getValue()[0];e.store.setHttpType(t)}}],items:[{text:BI.i18nText("Plugin-httpaction_ClassName_Soap"),value:BI.i18nText("Plugin-httpaction_ClassName_Soap")}]}]},{type:"dec.label.editor.item",text:BI.i18nText("Plugin-httpaction_Url"),textCls:"dec-font-weight-bold",textWidth:115,editorWidth:300,watermark:BI.i18nText("Dec-Basic_Support_Formula_Input"),ref:function(t){e.apiUrl=t},allowBlank:!1,bubbleError:!1,errorText:BI.i18nText("Plugin-httpaction_Link_Valid"),listeners:[{eventName:BI.Editor.EVENT_CHANGE,action:function(){e.store.setApiUrl(this.getValue())}}]},{type:"dec.label.editor.item",text:BI.i18nText("Plugin-httpaction_Header_Property"),textCls:"dec-font-weight-bold",textWidth:115,editorWidth:300,watermark:BI.i18nText("Dec-Basic_Support_Formula_Input"),ref:function(t){e.headers=t},allowBlank:!1,bubbleError:!1,errorText:BI.i18nText("Dec-Error_Null"),listeners:[{eventName:BI.Editor.EVENT_CHANGE,action:function(){e.store.setHeaders(this.getValue())}}]},{type:"dec.label.editor.item",text:BI.i18nText("Plugin-httpaction_Body_Property"),textCls:"dec-font-weight-bold",textWidth:115,editorWidth:300,watermark:BI.i18nText("Dec-Basic_Support_Formula_Input"),ref:function(t){e.bodyParameters=t},allowBlank:!1,bubbleError:!1,errorText:BI.i18nText("Dec-Error_Null"),listeners:[{eventName:BI.Editor.EVENT_CHANGE,action:function(){e.store.setBodyParameters(this.getValue())}}]},{type:"dec.label.textarea.item",text:BI.i18nText("Plugin-httpaction_Body_Content"),textCls:"dec-font-weight-bold",watermark:BI.i18nText("Dec-Basic_Support_Formula_Input"),textWidth:100,editorWidth:390,editorHeight:100,ref:function(t){e.bodyContent=t},allowBlank:!1,bubbleError:!1,errorText:BI.i18nText("Plugin-httpaction_Body_Content_Valid"),listeners:[{eventName:BI.Editor.EVENT_CHANGE,action:function(){e.store.setBodyContent(this.getValue())}}]},{type:"bi.multi_select_item",selected:e.model.previewAttach,logic:{dynamic:!0},text:BI.i18nText("Dec-Task_Preview_Template_Content"),ref:function(t){e.previewAttach=t},listeners:[{eventName:BI.MultiSelectItem.EVENT_CHANGE,action:function(){e.store.setPreviewAttach(this.isSelected())}}]}]}},setValue:function(t){var i=this;BI.map(t,function(t,e){i.store.setHttpType(e.httpType),i.store.setApiUrl(e.apiUrl),i.store.setHeaders(e.headers),i.store.setBodyParameters(e.bodyParameters),i.store.setBodyContent(e.bodyContent),i.store.setPreviewAttach(e.previewAttach)})},validation:function(){return!0},getValue:function(){var t=this;return{OutputHttp:BI.extend(t.value,{"@class":"com.fr.plugin.ajchk.action.OutputHttp",actionName:"com.fr.plugin.ajchk.action.OutputHttp",httpType:t.model.httpType,apiUrl:t.model.apiUrl,headers:t.model.headers,bodyParameters:t.model.bodyParameters,bodyContent:t.model.bodyContent,previewAttach:t.model.previewAttach})}}});BI.shortcut("dec.schedule.task.file.handling.httpaction",t)}(),function(){var t=BI.inherit(Fix.Model,{context:["currTask"],state:function(){return{httpType:BI.i18nText("Plugin-httpaction_ClassName_Get"),apiUrl:"",headers:"",bodyParameters:"",bodyContent:"",previewAttach:!1}},actions:{setHttpType:function(t){this.model.httpType=t},setApiUrl:function(t){this.model.apiUrl=t},setHeaders:function(t){this.model.headers=t},setBodyParameters:function(t){this.model.bodyParameters=t},setBodyContent:function(t){this.model.bodyContent=t},setPreviewAttach:function(t){t?this.model.currTask.scheduleOutput.formats=BI.union(this.model.currTask.scheduleOutput.formats,[DecCst.Schedule.Template.Accessory.PREVIEW]):BI.remove(this.model.currTask.scheduleOutput.formats,DecCst.Schedule.Template.Accessory.PREVIEW),this.model.previewAttach=t}}});BI.model("dec.model.schedule.task.file.handling.httpaction",t)}(),BI.config("dec.provider.schedule",function(t){t.registerHandingWay({text:BI.i18nText("Plugin-httpaction_Handing_Way"),value:"com.fr.plugin.ajchk.action.OutputHttp",cardType:"dec.schedule.task.file.handling.httpaction",actions:[]},[DecCst.Schedule.TaskType.DEFAULT,DecCst.Schedule.TaskType.REPORT,DecCst.Schedule.TaskType.BI])}); |
Loading…
Reference in new issue