diff --git a/build.xml b/build.xml
index b6b649f..76951f9 100644
--- a/build.xml
+++ b/build.xml
@@ -1,11 +1,11 @@
-
+
-
+
@@ -14,7 +14,7 @@
-
+
@@ -127,4 +127,4 @@
-
+
\ No newline at end of file
diff --git a/lib/aliyun-java-sdk-core-3.4.0.jar b/lib/aliyun-java-sdk-core-3.4.0.jar
new file mode 100644
index 0000000..5bcf59b
Binary files /dev/null and b/lib/aliyun-java-sdk-core-3.4.0.jar differ
diff --git a/lib/aliyun-java-sdk-ecs-4.2.0.jar b/lib/aliyun-java-sdk-ecs-4.2.0.jar
new file mode 100644
index 0000000..6a551cc
Binary files /dev/null and b/lib/aliyun-java-sdk-ecs-4.2.0.jar differ
diff --git a/lib/aliyun-java-sdk-ram-3.0.0.jar b/lib/aliyun-java-sdk-ram-3.0.0.jar
new file mode 100644
index 0000000..850878c
Binary files /dev/null and b/lib/aliyun-java-sdk-ram-3.0.0.jar differ
diff --git a/lib/aliyun-java-sdk-sts-3.0.0.jar b/lib/aliyun-java-sdk-sts-3.0.0.jar
new file mode 100644
index 0000000..879526f
Binary files /dev/null and b/lib/aliyun-java-sdk-sts-3.0.0.jar differ
diff --git a/lib/aliyun-sdk-oss-3.3.0.jar b/lib/aliyun-sdk-oss-3.3.0.jar
new file mode 100644
index 0000000..3ef0b6b
Binary files /dev/null and b/lib/aliyun-sdk-oss-3.3.0.jar differ
diff --git a/lib/commons-codec-1.9.jar b/lib/commons-codec-1.9.jar
new file mode 100644
index 0000000..ef35f1c
Binary files /dev/null and b/lib/commons-codec-1.9.jar differ
diff --git a/lib/commons-logging-1.2.jar b/lib/commons-logging-1.2.jar
new file mode 100644
index 0000000..93a3b9f
Binary files /dev/null and b/lib/commons-logging-1.2.jar differ
diff --git a/lib/httpclient-4.4.1.jar b/lib/httpclient-4.4.1.jar
new file mode 100644
index 0000000..b80d379
Binary files /dev/null and b/lib/httpclient-4.4.1.jar differ
diff --git a/lib/httpcore-4.4.1.jar b/lib/httpcore-4.4.1.jar
new file mode 100644
index 0000000..99715b6
Binary files /dev/null and b/lib/httpcore-4.4.1.jar differ
diff --git a/lib/jaxb-impl-2.2.3-1.jar b/lib/jaxb-impl-2.2.3-1.jar
new file mode 100644
index 0000000..eeaf660
Binary files /dev/null and b/lib/jaxb-impl-2.2.3-1.jar differ
diff --git a/lib/jdom-1.1.jar b/lib/jdom-1.1.jar
new file mode 100644
index 0000000..97c85f5
Binary files /dev/null and b/lib/jdom-1.1.jar differ
diff --git a/lib/jersey-core-1.9.jar b/lib/jersey-core-1.9.jar
new file mode 100644
index 0000000..548dd88
Binary files /dev/null and b/lib/jersey-core-1.9.jar differ
diff --git a/lib/jersey-json-1.9.jar b/lib/jersey-json-1.9.jar
new file mode 100644
index 0000000..b1a4ce5
Binary files /dev/null and b/lib/jersey-json-1.9.jar differ
diff --git a/lib/stax-api-1.0.1.jar b/lib/stax-api-1.0.1.jar
new file mode 100644
index 0000000..d9a1665
Binary files /dev/null and b/lib/stax-api-1.0.1.jar differ
diff --git a/plugin.xml b/plugin.xml
index fac7f84..27af839 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -4,7 +4,7 @@
yes
1.0
10.0
- 2018-10-31
+ 2018-11-02
author
-
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index e486d36..e4c8d3a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,12 @@
4.0.0
- com.fr.plugin
- starter
- 10.0
+ com.fr.maven
+ finereport-maven
+ 10.0
jar
- file.submit.oss
+ plugin-file-submit-oss
@@ -18,9 +18,19 @@
aliyun-sdk-oss
3.3.0
+
+ com.fr.report
+ fine-report-designer
+ 10.0
+
+
+ com.fr.report
+ designer-base
+ 10.0
+
- ${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.file.submit.oss-1.0/classes
+ ${web-inf-path}/plugins/plugin-com.fr.plugin.file.submit.oss-1.0/classes
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/OssHyperlink4Download.java b/src/main/java/com/fr/plugin/file/submit/oss/OssHyperlink4Download.java
new file mode 100644
index 0000000..eb0aead
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/OssHyperlink4Download.java
@@ -0,0 +1,39 @@
+package com.fr.plugin.file.submit.oss;
+
+import com.fr.design.fun.impl.AbstractHyperlinkProvider;
+import com.fr.design.gui.controlpane.NameObjectCreator;
+import com.fr.design.gui.controlpane.NameableCreator;
+import com.fr.design.i18n.Toolkit;
+import com.fr.plugin.file.submit.oss.script.OssDownloadHyperlink;
+import com.fr.plugin.file.submit.oss.ui.OssHyperlink4DownloadPane;
+import com.fr.stable.AssistUtils;
+
+public class OssHyperlink4Download extends AbstractHyperlinkProvider {
+
+ private NameableCreator nameableCreator;
+
+ public OssHyperlink4Download() {
+ nameableCreator = new NameObjectCreator(
+ Toolkit.i18nText("Plugin-File_Download_Oss"),
+ OssDownloadHyperlink.class,
+ OssHyperlink4DownloadPane.class);
+ }
+
+ @Override
+ public NameableCreator createHyperlinkCreator() {
+ return nameableCreator;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof OssHyperlink4Download
+ && AssistUtils.equals(((OssHyperlink4Download) o).nameableCreator, nameableCreator);
+ }
+
+
+ @Override
+ public int hashCode() {
+ return this.nameableCreator.menuName().hashCode();
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/OssHyperlinkJavaScriptHandler.java b/src/main/java/com/fr/plugin/file/submit/oss/OssHyperlinkJavaScriptHandler.java
new file mode 100644
index 0000000..52455e3
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/OssHyperlinkJavaScriptHandler.java
@@ -0,0 +1,19 @@
+package com.fr.plugin.file.submit.oss;
+
+import com.fr.base.TemplateUtils;
+import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler;
+
+public class OssHyperlinkJavaScriptHandler extends AbstractJavaScriptFileHandler {
+ @Override
+ public String[] pathsForFiles() {
+ try {
+ String text = TemplateUtils.render("${fineServletURL}");
+ System.out.println(text);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return new String[]{
+ "/com/fr/plugin/file/submit/oss/web/oss.js"
+ };
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/ui/OssJavaScriptActionImpl.java b/src/main/java/com/fr/plugin/file/submit/oss/OssJavaScriptActionBridge.java
similarity index 68%
rename from src/main/java/com/fr/plugin/file/submit/oss/ui/OssJavaScriptActionImpl.java
rename to src/main/java/com/fr/plugin/file/submit/oss/OssJavaScriptActionBridge.java
index 4f989fc..1fbb31b 100644
--- a/src/main/java/com/fr/plugin/file/submit/oss/ui/OssJavaScriptActionImpl.java
+++ b/src/main/java/com/fr/plugin/file/submit/oss/OssJavaScriptActionBridge.java
@@ -1,11 +1,11 @@
-package com.fr.plugin.file.submit.oss.ui;
+package com.fr.plugin.file.submit.oss;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.fun.impl.AbstractJavaScriptActionProvider;
import com.fr.js.JavaScript;
-public class OssJavaScriptActionImpl extends AbstractJavaScriptActionProvider {
+public class OssJavaScriptActionBridge extends AbstractJavaScriptActionProvider {
@Override
public FurtherBasicBeanPane extends JavaScript> getJavaScriptActionPane() {
return null;
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/OssRequestHandler.java b/src/main/java/com/fr/plugin/file/submit/oss/OssRequestHandler.java
new file mode 100644
index 0000000..574a7f9
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/OssRequestHandler.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.file.submit.oss;
+
+import com.fr.decision.webservice.plugin.handler.AbstractHttpHandlerProvider;
+import com.fr.decision.webservice.plugin.handler.HttpHandler;
+import com.fr.plugin.file.submit.oss.fun.OssHttpHandler;
+
+public class OssRequestHandler extends AbstractHttpHandlerProvider {
+ @Override
+ public HttpHandler[] registerHandlers() {
+ return new HttpHandler[] {
+ new OssHttpHandler()
+ };
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/OssSubmitUIBridge.java b/src/main/java/com/fr/plugin/file/submit/oss/OssSubmitUIBridge.java
new file mode 100644
index 0000000..9813d80
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/OssSubmitUIBridge.java
@@ -0,0 +1,24 @@
+package com.fr.plugin.file.submit.oss;
+
+import com.fr.design.beans.BasicBeanPane;
+import com.fr.design.fun.impl.AbstractSubmitProvider;
+import com.fr.design.i18n.Toolkit;
+import com.fr.plugin.file.submit.oss.fun.OssConstants;
+import com.fr.plugin.file.submit.oss.ui.OssPathConfigPane;
+
+public class OssSubmitUIBridge extends AbstractSubmitProvider {
+ @Override
+ public BasicBeanPane appearanceForSubmit() {
+ return new OssPathConfigPane();
+ }
+
+ @Override
+ public String dataForSubmit() {
+ return Toolkit.i18nText("Plugin-File_Submit_Oss");
+ }
+
+ @Override
+ public String keyForSubmit() {
+ return OssConstants.KEY;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/OssURLAliasProvider.java b/src/main/java/com/fr/plugin/file/submit/oss/OssURLAliasProvider.java
new file mode 100644
index 0000000..3f358b6
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/OssURLAliasProvider.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.file.submit.oss;
+
+import com.fr.decision.webservice.url.alias.URLAlias;
+import com.fr.decision.webservice.url.alias.URLAliasFactory;
+import com.fr.decision.webservice.url.provider.AbstractURLAliasProvider;
+
+public class OssURLAliasProvider extends AbstractURLAliasProvider {
+ @Override
+ public URLAlias[] registerAlias() {
+ return new URLAlias[]{
+ URLAliasFactory.createPluginAlias("/oss/download", "/oss/download", true)
+ };
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/conf/FileSubmitOssServerConfig.java b/src/main/java/com/fr/plugin/file/submit/oss/conf/FileSubmitOssServerConfig.java
new file mode 100644
index 0000000..cef8370
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/conf/FileSubmitOssServerConfig.java
@@ -0,0 +1,91 @@
+package com.fr.plugin.file.submit.oss.conf;
+
+import com.fr.config.ConfigContext;
+import com.fr.config.DefaultConfiguration;
+import com.fr.config.Identifier;
+import com.fr.config.holder.Conf;
+import com.fr.config.holder.factory.Holders;
+import com.fr.config.holder.impl.ColConf;
+import com.fr.config.holder.impl.ObjConf;
+import com.fr.stable.StringUtils;
+import com.fr.third.org.apache.commons.collections4.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * OSS文件上传下载所使用的OSS配置
+ */
+public class FileSubmitOssServerConfig extends DefaultConfiguration {
+
+ private static volatile FileSubmitOssServerConfig instance = null;
+
+ public static FileSubmitOssServerConfig getInstance() {
+ if (instance == null) {
+ instance = ConfigContext.getConfigInstance(FileSubmitOssServerConfig.class);
+ }
+ return instance;
+ }
+
+ // 地域节点配置信息
+ @Identifier("endPoint")
+ private Conf endPoint = Holders.simple(StringUtils.EMPTY);
+
+ @Identifier("accessKeyId")
+ private Conf accessKeyId = Holders.simple(StringUtils.EMPTY);
+
+ @Identifier("accessKeySecret")
+ private Conf accessKeySecret = Holders.simple(StringUtils.EMPTY);
+
+ @Identifier("buckets")
+ private ColConf> buckets = Holders.collection(new ArrayList(), String.class);
+
+ public String getEndPoint() {
+ return endPoint.get();
+ }
+
+ public void setEndPoint(String endPoint) {
+ this.endPoint.set(endPoint);
+ }
+
+ public String getAccessKeyId() {
+ return accessKeyId.get();
+ }
+
+ public void setAccessKeyId(String accessKeyId) {
+ this.accessKeyId.set(accessKeyId);
+ }
+
+ public String getAccessKeySecret() {
+ return accessKeySecret.get();
+ }
+
+ public void setAccessKeySecret(String accessKeySecret) {
+ this.accessKeySecret.set(accessKeySecret);
+ }
+
+ public String[] getBuckets() {
+ Collection collection = buckets.get();
+ return collection.toArray(new String[0]);
+ }
+
+ public void setBuckets(String[] buckets) {
+ if (buckets != null) {
+ for (String bucket : buckets) {
+ this.buckets.add(bucket);
+ }
+ }
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ FileSubmitOssServerConfig cloned = (FileSubmitOssServerConfig) super.clone();
+ cloned.endPoint = (Conf) endPoint.clone();
+ cloned.accessKeyId = (Conf) accessKeyId.clone();
+ cloned.accessKeySecret = (Conf) accessKeySecret.clone();
+ return cloned;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssConstants.java b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssConstants.java
new file mode 100644
index 0000000..ea39a7c
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssConstants.java
@@ -0,0 +1,6 @@
+package com.fr.plugin.file.submit.oss.fun;
+
+public class OssConstants {
+
+ public static final String KEY = "OssSubmit";
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssHttpHandler.java b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssHttpHandler.java
new file mode 100644
index 0000000..6c1e650
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssHttpHandler.java
@@ -0,0 +1,68 @@
+package com.fr.plugin.file.submit.oss.fun;
+
+import com.aliyun.oss.HttpMethod;
+import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.common.utils.DateUtil;
+import com.aliyun.oss.model.GeneratePresignedUrlRequest;
+import com.fr.data.NetworkHelper;
+import com.fr.decision.webservice.plugin.handler.HttpHandler;
+import com.fr.general.DateUtils;
+import com.fr.plugin.file.submit.oss.conf.FileSubmitOssServerConfig;
+import com.fr.stable.StableUtils;
+import com.fr.third.springframework.web.bind.annotation.RequestMethod;
+import com.fr.web.utils.WebUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+
+public class OssHttpHandler implements HttpHandler {
+ @Override
+ public RequestMethod getMethod() {
+ return RequestMethod.POST;
+ }
+
+ @Override
+ public String getPath() {
+ return "/oss/download";
+ }
+
+ @Override
+ public boolean isPublic() {
+ return true;
+ }
+
+ @Override
+ public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
+ String bucket = NetworkHelper.getHTTPRequestParameter(req, "bucket");
+ String directory = NetworkHelper.getHTTPRequestParameter(req, "directory");
+ String fileName = NetworkHelper.getHTTPRequestParameter(req, "fileName");
+ PrintWriter writer = WebUtils.createPrintWriter(res);
+ writer.write(createDownloadUrl(bucket, directory, fileName));
+ writer.flush();
+ writer.close();
+ }
+
+ private String createDownloadUrl(String bucket, String directory, String fileName) throws Exception {
+ // 创建OSSClient实例。
+ OSSClient ossClient = new OSSClient(
+ FileSubmitOssServerConfig.getInstance().getEndPoint(),
+ FileSubmitOssServerConfig.getInstance().getAccessKeyId(),
+ FileSubmitOssServerConfig.getInstance().getAccessKeySecret());
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.MINUTE, 1);
+ Date expiration = calendar.getTime();
+ GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, StableUtils.pathJoin(directory, fileName), HttpMethod.GET);
+ // 设置过期时间。
+ request.setExpiration(expiration);
+ // 生成签名URL(HTTP GET请求)。
+ URL signedUrl = ossClient .generatePresignedUrl(request);
+ ossClient.shutdown();
+ return signedUrl.toString();
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTarget.java b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTarget.java
new file mode 100644
index 0000000..ec80479
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTarget.java
@@ -0,0 +1,109 @@
+package com.fr.plugin.file.submit.oss.fun;
+
+import com.fr.general.xml.GeneralXMLTools;
+import com.fr.stable.AssistUtils;
+import com.fr.stable.StringUtils;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLable;
+import com.fr.stable.xml.XMLableReader;
+
+public class OssSubmitTarget implements XMLable {
+
+ public static final String XML_TAG = "OssSubmitTarget";
+
+ private String bucket;
+ private OssVariableValue directory;
+ private OssVariableValue file;
+ private OssVariableValue name;
+
+ public OssSubmitTarget() {
+ }
+
+ public OssSubmitTarget(final String bucket, final OssVariableValue directory, final OssVariableValue file, final OssVariableValue name) {
+ this.bucket = bucket;
+ this.directory = directory;
+ this.file = file;
+ this.name = name;
+ }
+
+ public String getBucket() {
+ return this.bucket;
+ }
+
+ public void setBucket(final String bucket) {
+ this.bucket = bucket;
+ }
+
+ public OssVariableValue getDirectory() {
+ return directory;
+ }
+
+ public void setDirectory(OssVariableValue directory) {
+ this.directory = directory;
+ }
+
+ public OssVariableValue getName() {
+ return this.name;
+ }
+
+ public void setName(final OssVariableValue name) {
+ this.name = name;
+ }
+
+ public OssVariableValue getFile() {
+ return this.file;
+ }
+
+ public void setFile(final OssVariableValue file) {
+ this.file = file;
+ }
+
+ public void readXML(final XMLableReader reader) {
+ if (reader.isChildNode()) {
+ String tagName = reader.getTagName();
+ if ("Bucket".equals(tagName)) {
+ this.bucket = reader.getElementValue();
+ } else if ("Directory".equals(tagName)) {
+ this.directory = (OssVariableValue) GeneralXMLTools.readXMLable(reader);
+ } else if ("Name".equals(tagName)) {
+ this.name = (OssVariableValue) GeneralXMLTools.readXMLable(reader);
+ } else if ("File".equals(tagName)) {
+ this.file = (OssVariableValue) GeneralXMLTools.readXMLable(reader);
+ }
+ }
+ }
+
+ public void writeXML(final XMLPrintWriter writer) {
+ if (StringUtils.isNotEmpty(bucket)) {
+ writer.startTAG("Bucket").textNode(bucket).end();
+ }
+ if (directory != null) {
+ GeneralXMLTools.writeXMLable(writer, directory, "Directory");
+ }
+ if (name != null) {
+ GeneralXMLTools.writeXMLable(writer, name, "Name");
+ }
+ if (file != null) {
+ GeneralXMLTools.writeXMLable(writer, file, "File");
+ }
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ return o instanceof OssSubmitTarget
+ && AssistUtils.equals(((OssSubmitTarget) o).bucket, bucket)
+ && AssistUtils.equals(((OssSubmitTarget) o).directory, directory)
+ && AssistUtils.equals(((OssSubmitTarget) o).name, name)
+ && AssistUtils.equals(((OssSubmitTarget) o).file, file);
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ OssSubmitTarget cloned = (OssSubmitTarget) super.clone();
+ cloned.bucket = bucket;
+ cloned.directory = (OssVariableValue) directory.clone();
+ cloned.name = (OssVariableValue) name.clone();
+ cloned.file = (OssVariableValue) file.clone();
+ return cloned;
+ }
+}
+
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTargetConfig.java b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTargetConfig.java
new file mode 100644
index 0000000..2fd4cec
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTargetConfig.java
@@ -0,0 +1,69 @@
+package com.fr.plugin.file.submit.oss.fun;
+
+import com.fr.general.xml.GeneralXMLTools;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLReadable;
+import com.fr.stable.xml.XMLable;
+import com.fr.stable.xml.XMLableReader;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class OssSubmitTargetConfig implements XMLable {
+
+ public static final String XML_TAG = "OssSubmitTargetConfig";
+
+ private List targets = new ArrayList();
+
+ public void addSubmitTarget(OssSubmitTarget target) {
+ targets.add(target);
+ }
+
+ public void clearSubmitTargets() {
+ targets.clear();
+ }
+
+ public void removeSubmitTarget(OssSubmitTarget target) {
+ targets.remove(target);
+ }
+
+ public OssSubmitTarget[] getSubmitTargets() {
+ return targets.toArray(new OssSubmitTarget[0]);
+ }
+
+ @Override
+ public void readXML(XMLableReader reader) {
+ if (reader.isChildNode()) {
+ reader.readXMLObject(new XMLReadable() {
+ @Override
+ public void readXML(XMLableReader xmLableReader) {
+ if (xmLableReader.isChildNode()) {
+ String tagName = xmLableReader.getTagName();
+ if (OssSubmitTarget.XML_TAG.equals(tagName)) {
+ OssSubmitTarget target = (OssSubmitTarget)GeneralXMLTools.readXMLable(xmLableReader);
+ targets.add(target);
+ }
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ public void writeXML(XMLPrintWriter writer) {
+ for (OssSubmitTarget target : targets) {
+ GeneralXMLTools.writeXMLable(writer, target, OssSubmitTarget.XML_TAG);
+ }
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ OssSubmitTargetConfig cloned = (OssSubmitTargetConfig) super.clone();
+ List list = new ArrayList();
+ for (OssSubmitTarget target : targets) {
+ list.add((OssSubmitTarget) target.clone());
+ }
+ cloned.targets = list;
+ return cloned;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssVariableValue.java b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssVariableValue.java
new file mode 100644
index 0000000..a20376e
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssVariableValue.java
@@ -0,0 +1,118 @@
+package com.fr.plugin.file.submit.oss.fun;
+
+import com.fr.base.BaseFormula;
+import com.fr.general.GeneralUtils;
+import com.fr.log.FineLoggerFactory;
+import com.fr.script.Calculator;
+import com.fr.stable.CommonUtils;
+import com.fr.stable.StringUtils;
+import com.fr.stable.UtilEvalError;
+import com.fr.stable.script.CalculatorProvider;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLable;
+import com.fr.stable.xml.XMLableReader;
+
+public class OssVariableValue implements XMLable {
+
+ public static final String XML_TAG = "OssVariableValue";
+
+ private Type type;
+
+ private Object value;
+
+ public OssVariableValue() {
+
+ }
+
+ public OssVariableValue(Object value) {
+ if (value instanceof BaseFormula) {
+ type = Type.FORMULA;
+ this.value = value;
+ } else {
+ String content = GeneralUtils.objectToString(value);
+ if (CommonUtils.canBeFormula(content)) {
+ type = Type.FORMULA;
+ this.value = BaseFormula.createFormulaBuilder().build(content);
+ } else {
+ type = Type.PLAIN;
+ this.value = content;
+ }
+ }
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public String getResult(CalculatorProvider cal) {
+ Object result = value;
+ if (type == Type.FORMULA) {
+ try {
+ result = ((BaseFormula)value).evalValue(cal);
+ } catch (UtilEvalError u) {
+ FineLoggerFactory.getLogger().error(u.getMessage(), u);
+ }
+ }
+ return GeneralUtils.objectToString(result);
+ }
+
+ @Override
+ public void readXML(XMLableReader reader) {
+ if (reader.isChildNode()) {
+ String tagName = reader.getTagName();
+ if ("Attr".equals(tagName)) {
+ type = Type.parse(reader.getAttrAsInt("type", 0));
+ if (type == Type.FORMULA) {
+ value = BaseFormula.createFormulaBuilder().build(reader.getAttrAsString("value", StringUtils.EMPTY));
+ } else {
+ value = reader.getAttrAsString("value", StringUtils.EMPTY);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void writeXML(XMLPrintWriter writer) {
+ writer.startTAG("Attr");
+ if (value instanceof BaseFormula) {
+ writer.attr("type", Type.FORMULA.getIndex()).attr("value", ((BaseFormula) value).getPureContent());
+ } else {
+ writer.attr("type", Type.PLAIN.getIndex()).attr("value", GeneralUtils.objectToString(value));
+ }
+ writer.end();
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public String toString() {
+ return value == null ? StringUtils.EMPTY : GeneralUtils.objectToString(value);
+ }
+
+
+ public enum Type {
+
+ PLAIN(0), FORMULA(1);
+
+ private int index;
+
+ Type(int index) {
+ this.index = index;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public static Type parse(int index) {
+ for (Type type : values()) {
+ if (type.index == index) {
+ return type;
+ }
+ }
+ return Type.PLAIN;
+ }
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/job/OssSubmitJob.java b/src/main/java/com/fr/plugin/file/submit/oss/job/OssSubmitJob.java
new file mode 100644
index 0000000..03dbc84
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/job/OssSubmitJob.java
@@ -0,0 +1,133 @@
+package com.fr.plugin.file.submit.oss.job;
+
+import com.aliyun.oss.OSSClient;
+import com.fr.cache.Attachment;
+import com.fr.data.AbstractSubmitTask;
+import com.fr.general.FArray;
+import com.fr.general.GeneralUtils;
+import com.fr.general.xml.GeneralXMLTools;
+import com.fr.intelli.record.Focus;
+import com.fr.intelli.record.Original;
+import com.fr.plugin.file.submit.oss.conf.FileSubmitOssServerConfig;
+import com.fr.plugin.file.submit.oss.fun.OssConstants;
+import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget;
+import com.fr.plugin.file.submit.oss.fun.OssSubmitTargetConfig;
+import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
+import com.fr.record.analyzer.EnableMetrics;
+import com.fr.script.Calculator;
+import com.fr.stable.StringUtils;
+import com.fr.stable.xml.FRFile;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLableReader;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+
+/**
+ * 提交到OSS的任务
+ */
+@EnableMetrics
+public class OssSubmitJob extends AbstractSubmitTask {
+
+ private OSSClient ossClient = null;
+
+ private OssSubmitTargetConfig submitTargetConfig;
+
+ public OssSubmitTargetConfig getSubmitTargetConfig() {
+ return submitTargetConfig;
+ }
+
+ public void setSubmitTargetConfig(OssSubmitTargetConfig submitTargetConfig) {
+ this.submitTargetConfig = submitTargetConfig;
+ }
+
+ @Override
+ public String getJobType() {
+ return OssConstants.KEY;
+ }
+
+ @Override
+ @Focus(id = "com.fr.plugin.file.submit.oss", text = "Plugin-File_Submit_OSS", source = Original.PLUGIN)
+ public void doJob(Calculator calculator) throws Exception {
+ ossClient = new OSSClient(
+ FileSubmitOssServerConfig.getInstance().getEndPoint(),
+ FileSubmitOssServerConfig.getInstance().getAccessKeyId(),
+ FileSubmitOssServerConfig.getInstance().getAccessKeySecret());
+ OssSubmitTarget[] submitTargets = submitTargetConfig.getSubmitTargets();
+ for (OssSubmitTarget target : submitTargets) {
+ OssVariableValue fileObject = target.getFile();
+ Object file = calculator.evalValue(GeneralUtils.objectToString(fileObject));
+
+
+ uploadFile(target.getBucket(), file,
+ target.getDirectory() == null ? null : target.getDirectory().getResult(calculator),
+ target.getName() == null ? null : target.getName().getResult(calculator));
+ }
+ }
+
+ @Override
+ public void doFinish(Calculator calculator) throws Exception {
+ ossClient.shutdown();
+ }
+
+ private void uploadFile(String bucket, Object file, String directory, String newFileName) {
+ if (file instanceof FRFile) {
+ ossClient.putObject(bucket, directory + "/" + combineName(((FRFile) file).getFileName(), newFileName), new ByteArrayInputStream(((FRFile) file).getBytes()));
+ } else if (file instanceof FArray && ((FArray) file).length() != 0) {
+ FArray array = (FArray)file;
+ for (int i = 0; i < array.length(); i++) {
+ Object element = array.elementAt(i);
+ if (!(element instanceof Attachment)) {
+ if (element instanceof FArray) {
+ uploadFile(bucket, element, directory, newFileName);
+ }
+ } else {
+ ossClient.putObject(bucket, directory + "/" + combineName(((Attachment) element).getFilename(), newFileName), new ByteArrayInputStream(((Attachment) element).getBytes()));
+ }
+ }
+ }
+ }
+
+ /*
+ * 这里的逻辑是:
+ * 1、如果没有设置文件名,就用上传的文件的名字;
+ * 2、如果设置了文件名,且带有文件后缀,就用设置的文件名;
+ * 3、其他情况都用原文件名。
+ */
+ private String combineName(String fileName, String myFileName) {
+ String realFileName;
+ if (StringUtils.isBlank(fileName)) {
+ fileName = "unnamed.png";
+ }
+ if (StringUtils.isNotEmpty(myFileName)) {
+ int index = myFileName.lastIndexOf(".");
+ if (index == -1) {
+ realFileName = fileName;
+ } else {
+ realFileName = myFileName;
+ }
+ } else {
+ realFileName = fileName;
+ }
+ return realFileName;
+ }
+
+ @Override
+ public void readXML(final XMLableReader reader) {
+ if (reader.isChildNode()) {
+ String tagName = reader.getTagName();
+ if (OssSubmitTargetConfig.XML_TAG.equals(tagName)) {
+ OssSubmitTargetConfig config = new OssSubmitTargetConfig();
+ config.readXML(reader);
+ submitTargetConfig = config;
+ }
+ }
+ }
+
+ @Override
+ public void writeXML(XMLPrintWriter writer) {
+ if (submitTargetConfig != null) {
+ GeneralXMLTools.writeXMLable(writer, submitTargetConfig, OssSubmitTargetConfig.XML_TAG);
+ }
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/script/OssDownloadHyperlink.java b/src/main/java/com/fr/plugin/file/submit/oss/script/OssDownloadHyperlink.java
new file mode 100644
index 0000000..897bd23
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/script/OssDownloadHyperlink.java
@@ -0,0 +1,110 @@
+package com.fr.plugin.file.submit.oss.script;
+
+import com.fr.general.xml.GeneralXMLTools;
+import com.fr.js.Hyperlink;
+import com.fr.json.JSONException;
+import com.fr.json.JSONObject;
+import com.fr.log.FineLoggerFactory;
+import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
+import com.fr.stable.AssistUtils;
+import com.fr.stable.StringUtils;
+import com.fr.stable.web.Repository;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLableReader;
+
+public class OssDownloadHyperlink extends Hyperlink {
+
+ private String bucket;
+ private OssVariableValue directory;
+ private OssVariableValue fileName;
+
+ public String getBucket() {
+ return bucket;
+ }
+
+ public void setBucket(String bucket) {
+ this.bucket = bucket;
+ }
+
+ public OssVariableValue getDirectory() {
+ return directory;
+ }
+
+ public void setDirectory(OssVariableValue directory) {
+ this.directory = directory;
+ }
+
+ public OssVariableValue getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(OssVariableValue fileName) {
+ this.fileName = fileName;
+ }
+
+ @Override
+ protected String actionJS(Repository repository) {
+ JSONObject data = JSONObject.create();
+ try {
+ data.put("bucket", bucket);
+ if (directory != null) {
+ data.put("directory", directory.getResult(repository.getCalculator()));
+ }
+ if (fileName != null) {
+ data.put("fileName", fileName.getResult(repository.getCalculator()));
+ }
+ } catch (JSONException e) {
+ FineLoggerFactory.getLogger().error(e.getMessage(), e);
+ }
+ return "FR.doHyperlinkByOssDownload(" + data.toString() + ");";
+ }
+
+ public void readXML(final XMLableReader reader) {
+ super.readXML(reader);
+ if (reader.isChildNode()) {
+ String tagName = reader.getTagName();
+ if ("Bucket".equals(tagName)) {
+ this.bucket = reader.getElementValue();
+ } else if ("Directory".equals(tagName)) {
+ this.directory = (OssVariableValue) GeneralXMLTools.readXMLable(reader);
+ } else if ("FileName".equals(tagName)) {
+ this.fileName = (OssVariableValue) GeneralXMLTools.readXMLable(reader);
+ }
+ }
+ }
+
+ public void writeXML(final XMLPrintWriter writer) {
+ writer.startTAG("JavaScript").attr("class", this.getClass().getName());
+ super.writeXML(writer);
+ if (StringUtils.isNotEmpty(bucket)) {
+ writer.startTAG("Bucket").textNode(bucket).end();
+ }
+ if (directory != null) {
+ GeneralXMLTools.writeXMLable(writer, directory, "Directory");
+ }
+ if (fileName != null) {
+ GeneralXMLTools.writeXMLable(writer, fileName, "FileName");
+ }
+ writer.end();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof OssDownloadHyperlink
+ && AssistUtils.equals(((OssDownloadHyperlink) o).bucket, bucket)
+ && AssistUtils.equals(((OssDownloadHyperlink) o).directory, directory)
+ && AssistUtils.equals(((OssDownloadHyperlink) o).fileName, fileName);
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ OssDownloadHyperlink cloned = (OssDownloadHyperlink) super.clone();
+ if (directory != null) {
+ cloned.directory = (OssVariableValue) directory.clone();
+ }
+ if (fileName != null) {
+ cloned.fileName = (OssVariableValue) fileName.clone();
+ }
+ return cloned;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/script/OssSubmitJavaScript.java b/src/main/java/com/fr/plugin/file/submit/oss/script/OssSubmitJavaScript.java
new file mode 100644
index 0000000..4cc5920
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/script/OssSubmitJavaScript.java
@@ -0,0 +1,34 @@
+package com.fr.plugin.file.submit.oss.script;
+
+import com.fr.js.AbstractJavaScript;
+import com.fr.stable.web.Repository;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLableReader;
+
+public class OssSubmitJavaScript extends AbstractJavaScript {
+
+ @Override
+ protected String actionJS(Repository repository) {
+ return null;
+ }
+
+ @Override
+ public void writeXML(XMLPrintWriter xmlPrintWriter) {
+ super.writeXML(xmlPrintWriter);
+ }
+
+ @Override
+ public void readXML(XMLableReader xmLableReader) {
+ super.readXML(xmLableReader);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return super.equals(o);
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/server/OssSubmitJob.java b/src/main/java/com/fr/plugin/file/submit/oss/server/OssSubmitJob.java
deleted file mode 100644
index 594738e..0000000
--- a/src/main/java/com/fr/plugin/file/submit/oss/server/OssSubmitJob.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.fr.plugin.file.submit.oss.server;
-
-import com.fr.data.AbstractSubmitTask;
-import com.fr.intelli.record.Focus;
-import com.fr.intelli.record.Original;
-import com.fr.record.analyzer.EnableMetrics;
-import com.fr.script.Calculator;
-import com.fr.stable.xml.XMLPrintWriter;
-import com.fr.stable.xml.XMLableReader;
-
-/**
- * 提交到OSS的任务
- */
-@EnableMetrics
-public class OssSubmitJob extends AbstractSubmitTask {
- @Override
- public String getJobType() {
- return null;
- }
-
- @Override
- @Focus(id="com.fr.plugin.file.submit.oss", text = "Plugin-File_Submit_OSS", source = Original.PLUGIN)
- public void doJob(Calculator calculator) throws Exception {
-
- }
-
- @Override
- public void doFinish(Calculator calculator) throws Exception {
-
- }
-
- @Override
- public void readXML(XMLableReader xmLableReader) {
-
- }
-
- @Override
- public void writeXML(XMLPrintWriter xmlPrintWriter) {
-
- }
-}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/ui/Editors.java b/src/main/java/com/fr/plugin/file/submit/oss/ui/Editors.java
new file mode 100644
index 0000000..59378bc
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/ui/Editors.java
@@ -0,0 +1,19 @@
+package com.fr.plugin.file.submit.oss.ui;
+
+import com.fr.design.editor.ValueEditorPane;
+import com.fr.design.editor.ValueEditorPaneFactory;
+import com.fr.design.editor.editor.Editor;
+import com.fr.design.editor.editor.FormulaEditor;
+import com.fr.design.editor.editor.TextEditor;
+import com.fr.design.i18n.Toolkit;
+
+public class Editors {
+
+ public static ValueEditorPane createValueEditorPane() {
+ return ValueEditorPaneFactory.createValueEditorPane(new Editor[]{
+ new TextEditor(),
+ new FormulaEditor(Toolkit.i18nText("Plugin-File_Submit_Oss_Editor_Formula")),
+ });
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlin4Dowload.java b/src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlin4Dowload.java
deleted file mode 100644
index 233ec5b..0000000
--- a/src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlin4Dowload.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.fr.plugin.file.submit.oss.ui;
-
-import com.fr.design.fun.impl.AbstractHyperlinkProvider;
-import com.fr.design.gui.controlpane.NameableCreator;
-
-public class OssHyperlin4Dowload extends AbstractHyperlinkProvider {
- @Override
- public NameableCreator createHyperlinkCreator() {
- return null;
- }
-}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlink4DownloadPane.java b/src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlink4DownloadPane.java
new file mode 100644
index 0000000..0864498
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlink4DownloadPane.java
@@ -0,0 +1,69 @@
+package com.fr.plugin.file.submit.oss.ui;
+
+import com.fr.design.beans.BasicBeanPane;
+import com.fr.design.editor.ValueEditorPane;
+import com.fr.design.gui.icombobox.UIComboBox;
+import com.fr.design.gui.ilable.UILabel;
+import com.fr.design.i18n.Toolkit;
+import com.fr.design.layout.TableLayout;
+import com.fr.design.layout.TableLayoutHelper;
+import com.fr.general.GeneralUtils;
+import com.fr.plugin.file.submit.oss.conf.FileSubmitOssServerConfig;
+import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
+import com.fr.plugin.file.submit.oss.script.OssDownloadHyperlink;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class OssHyperlink4DownloadPane extends BasicBeanPane {
+
+ private UIComboBox bucketComboBox;
+ private ValueEditorPane directoryValuePane;
+ private ValueEditorPane fileNameValuePane;
+
+ public OssHyperlink4DownloadPane() {
+ initComponents();
+ }
+
+ private void initComponents() {
+ this.setLayout(new BorderLayout());
+ this.bucketComboBox = new UIComboBox(FileSubmitOssServerConfig.getInstance().getBuckets());
+ this.directoryValuePane = Editors.createValueEditorPane();
+ this.fileNameValuePane = Editors.createValueEditorPane();
+ double p = TableLayout.PREFERRED;
+ double f = TableLayout.FILL;
+ double[] rowSize = {p, p, p};
+ double[] columnSize = {p, f};
+ JPanel centerPane = TableLayoutHelper.createTableLayoutPane(
+ new Component[][] {
+ {new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_Bucket_Name") + ":"), bucketComboBox},
+ {new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_Directory") + ":"), directoryValuePane},
+ {new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_File_Name") + ":"), fileNameValuePane}
+ }, rowSize, columnSize);
+ this.add(centerPane, BorderLayout.CENTER);
+ }
+
+ @Override
+ public void populateBean(OssDownloadHyperlink hyperlink) {
+ if (hyperlink == null) {
+ return;
+ }
+ bucketComboBox.setSelectedItem(hyperlink.getBucket());
+ directoryValuePane.populate(hyperlink.getDirectory() == null ? null : hyperlink.getDirectory().getValue());
+ fileNameValuePane.populate(hyperlink.getFileName() == null ? null : hyperlink.getFileName().getValue());
+ }
+
+ @Override
+ public OssDownloadHyperlink updateBean() {
+ OssDownloadHyperlink hyperlink = new OssDownloadHyperlink();
+ hyperlink.setBucket(GeneralUtils.objectToString(bucketComboBox.getSelectedItem()));
+ hyperlink.setDirectory(new OssVariableValue(directoryValuePane.update()));
+ hyperlink.setFileName(new OssVariableValue(fileNameValuePane.update()));
+ return hyperlink;
+ }
+
+ @Override
+ protected String title4PopupWindow() {
+ return Toolkit.i18nText("Plugin-File_Download_Hyperlink");
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/ui/OssPathConfigPane.java b/src/main/java/com/fr/plugin/file/submit/oss/ui/OssPathConfigPane.java
new file mode 100644
index 0000000..6c9a415
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/ui/OssPathConfigPane.java
@@ -0,0 +1,49 @@
+package com.fr.plugin.file.submit.oss.ui;
+
+import com.fr.design.beans.BasicBeanPane;
+import com.fr.design.gui.itableeditorpane.UITableEditorPane;
+import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget;
+import com.fr.plugin.file.submit.oss.fun.OssSubmitTargetConfig;
+import com.fr.plugin.file.submit.oss.job.OssSubmitJob;
+
+import java.awt.*;
+
+
+public class OssPathConfigPane extends BasicBeanPane {
+
+ private UITableEditorPane tableEditorPane;
+
+ public OssPathConfigPane() {
+ setLayout(new BorderLayout());
+ this.tableEditorPane = new UITableEditorPane(new OssSubmitPathTableModel());
+ this.add(tableEditorPane, BorderLayout.CENTER);
+ }
+
+ @Override
+ public void populateBean(OssSubmitJob job) {
+ if (job != null) {
+ OssSubmitTargetConfig submitTargetConfig = job.getSubmitTargetConfig();
+ if (submitTargetConfig != null) {
+ OssSubmitTarget[] targets = submitTargetConfig.getSubmitTargets();
+ this.tableEditorPane.populate(targets);
+ }
+ }
+ }
+
+ @Override
+ public OssSubmitJob updateBean() {
+ OssSubmitJob submitJob = new OssSubmitJob();
+ OssSubmitTargetConfig submitTargetConfig = new OssSubmitTargetConfig();
+ java.util.List targetList = tableEditorPane.update();
+ for (OssSubmitTarget target : targetList) {
+ submitTargetConfig.addSubmitTarget(target);
+ }
+ submitJob.setSubmitTargetConfig(submitTargetConfig);
+ return submitJob;
+ }
+
+ @Override
+ protected String title4PopupWindow() {
+ return "Path";
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitJavaScriptPane.java b/src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitJavaScriptPane.java
new file mode 100644
index 0000000..4937102
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitJavaScriptPane.java
@@ -0,0 +1,33 @@
+package com.fr.plugin.file.submit.oss.ui;
+
+import com.fr.design.beans.FurtherBasicBeanPane;
+import com.fr.design.i18n.Toolkit;
+import com.fr.plugin.file.submit.oss.script.OssSubmitJavaScript;
+
+public class OssSubmitJavaScriptPane extends FurtherBasicBeanPane {
+
+ @Override
+ public boolean accept(Object o) {
+ return o instanceof OssSubmitJavaScript;
+ }
+
+ @Override
+ public void reset() {
+ populateBean(null);
+ }
+
+ @Override
+ public void populateBean(OssSubmitJavaScript ossSubmitJavaScript) {
+
+ }
+
+ @Override
+ public OssSubmitJavaScript updateBean() {
+ return null;
+ }
+
+ @Override
+ public String title4PopupWindow() {
+ return Toolkit.i18nText("Plugin-File_Submit_OSS");
+ }
+}
diff --git a/src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitPathTableModel.java b/src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitPathTableModel.java
new file mode 100644
index 0000000..69bae88
--- /dev/null
+++ b/src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitPathTableModel.java
@@ -0,0 +1,275 @@
+package com.fr.plugin.file.submit.oss.ui;
+
+import com.fr.design.editor.ValueEditorPane;
+import com.fr.design.gui.icombobox.UIComboBox;
+import com.fr.design.gui.ilable.UILabel;
+import com.fr.design.gui.itableeditorpane.UITableEditAction;
+import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
+import com.fr.design.i18n.Toolkit;
+import com.fr.general.GeneralUtils;
+import com.fr.plugin.file.submit.oss.conf.FileSubmitOssServerConfig;
+import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget;
+import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
+import com.fr.stable.StringUtils;
+
+import javax.swing.*;
+import javax.swing.event.CellEditorListener;
+import javax.swing.event.ChangeEvent;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellEditor;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+
+public class OssSubmitPathTableModel extends UITableModelAdapter {
+
+ public OssSubmitPathTableModel() {
+ super(new String[]{
+ com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_Bucket_Name"),
+ com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_Directory"),
+ com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_File"),
+ com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_File_Name")});
+
+ this.setColumnClass(new Class[]{BucketEditor.class, DirectoryEditor.class, FileSelectEditor.class, FileNameEditor.class});
+
+ this.setDefaultEditor(BucketEditor.class, new BucketEditor());
+ this.setDefaultRenderer(BucketEditor.class, new SimpleRenderer());
+
+ this.setDefaultEditor(DirectoryEditor.class, new DirectoryEditor());
+ this.setDefaultRenderer(DirectoryEditor.class, new CurrentValueRenderer());
+
+ this.setDefaultEditor(FileSelectEditor.class, new FileSelectEditor());
+ this.setDefaultRenderer(FileSelectEditor.class, new CurrentValueRenderer());
+
+ this.setDefaultEditor(FileNameEditor.class, new FileNameEditor());
+ this.setDefaultRenderer(FileNameEditor.class, new CurrentValueRenderer());
+ }
+
+ public Object getValueAt(final int row, final int column) {
+ final OssSubmitTarget target = this.getList().get(row);
+ switch (column) {
+ case 0: {
+ return target.getBucket();
+ }
+ case 1: {
+ return target.getDirectory() == null ? null : target.getDirectory().getValue();
+ }
+ case 2: {
+ return target.getFile() == null ? null : target.getFile().getValue();
+ }
+ case 3: {
+ return target.getName() == null ? null : target.getName().getValue();
+ }
+ default: {
+ return null;
+ }
+ }
+ }
+
+ public boolean isCellEditable(final int row, final int column) {
+ return true;
+ }
+
+ public UITableEditAction[] createAction() {
+ return new UITableEditAction[]{
+ new AddPathAction(),
+ new UITableModelAdapter.DeleteAction(),
+ new UITableModelAdapter.MoveUpAction(),
+ new UITableModelAdapter.MoveDownAction()};
+ }
+
+ private void addPath() {
+ this.addRow(new OssSubmitTarget());
+ this.fireTableDataChanged();
+ this.table.getSelectionModel().setSelectionInterval(this.table.getRowCount() - 1, this.table.getRowCount() - 1);
+ }
+
+ private class BucketEditor extends AbstractCellEditor implements TableCellEditor {
+ private static final long serialVersionUID = 1L;
+ private UIComboBox bucketComboBox;
+
+ public BucketEditor() {
+ bucketComboBox = new UIComboBox(FileSubmitOssServerConfig.getInstance().getBuckets());
+ this.addCellEditorListener(new CellEditorListener() {
+ @Override
+ public void editingCanceled(final ChangeEvent changeEvent) {
+ }
+
+ @Override
+ public void editingStopped(final ChangeEvent changeEvent) {
+ if (table.getSelectedRow() == -1) {
+ return;
+ }
+ OssSubmitTarget submitTarget = getList().get(table.getSelectedRow());
+ submitTarget.setBucket(GeneralUtils.objectToString(getCellEditorValue()));
+ fireTableDataChanged();
+ }
+ });
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(final JTable table, final Object o, final boolean b, final int n, final int n2) {
+ bucketComboBox.setSelectedItem(o);
+ return this.bucketComboBox;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return this.bucketComboBox.getSelectedItem();
+ }
+ }
+
+ public class DirectoryEditor extends AbstractCellEditor implements TableCellEditor {
+ private ValueEditorPane textField;
+
+ public DirectoryEditor() {
+ this.textField = Editors.createValueEditorPane();
+ this.addCellEditorListener(new CellEditorListener() {
+ @Override
+ public void editingCanceled(final ChangeEvent changeEvent) {
+ }
+
+ @Override
+ public void editingStopped(final ChangeEvent changeEvent) {
+ if (table.getSelectedRow() == -1) {
+ return;
+ }
+ final OssSubmitTarget submitTarget = getList().get(table.getSelectedRow());
+ submitTarget.setDirectory(new OssVariableValue(getCellEditorValue()));
+ fireTableDataChanged();
+ }
+ });
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(final JTable table, final Object o, final boolean b, final int n, final int n2) {
+ this.textField.populate((o == null) ? StringUtils.EMPTY : o);
+ return this.textField;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return this.textField.update();
+ }
+ }
+
+ public class FileSelectEditor extends AbstractCellEditor implements TableCellEditor {
+ private ValueEditorPane textField;
+
+ public FileSelectEditor() {
+ this.textField = Editors.createValueEditorPane();
+ this.addCellEditorListener(new CellEditorListener() {
+ @Override
+ public void editingCanceled(final ChangeEvent changeEvent) {
+ }
+
+ @Override
+ public void editingStopped(final ChangeEvent changeEvent) {
+ if (table.getSelectedRow() == -1) {
+ return;
+ }
+ final OssSubmitTarget submitTarget = getList().get(table.getSelectedRow());
+ submitTarget.setFile(new OssVariableValue(getCellEditorValue()));
+ fireTableDataChanged();
+ }
+ });
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(final JTable table, final Object o, final boolean b, final int n, final int n2) {
+ this.textField.populate((o == null) ? StringUtils.EMPTY : o);
+ return this.textField;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return this.textField.update();
+ }
+ }
+
+ public class FileNameEditor extends AbstractCellEditor implements TableCellEditor {
+ private ValueEditorPane textField;
+
+ public FileNameEditor() {
+ this.textField = Editors.createValueEditorPane();
+ this.addCellEditorListener(new CellEditorListener() {
+ @Override
+ public void editingCanceled(final ChangeEvent changeEvent) {
+ }
+
+ @Override
+ public void editingStopped(final ChangeEvent changeEvent) {
+ if (table.getSelectedRow() == -1) {
+ return;
+ }
+ final OssSubmitTarget submitTarget = getList().get(table.getSelectedRow());
+ submitTarget.setName(new OssVariableValue(getCellEditorValue()));
+ fireTableDataChanged();
+ }
+ });
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(final JTable table, final Object o, final boolean b, final int n, final int n2) {
+ this.textField.populate((o == null) ? StringUtils.EMPTY : o);
+ return this.textField;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return this.textField.update();
+ }
+ }
+
+ private class SimpleRenderer extends DefaultTableCellRenderer {
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ this.setText(GeneralUtils.objectToString(value));
+ return this;
+ }
+ }
+
+ private class CurrentValueRenderer extends DefaultTableCellRenderer {
+ private static final long serialVersionUID = 1L;
+ private ValueEditorPane editor;
+ private UILabel disableLabel;
+
+ public CurrentValueRenderer() {
+ this(Editors.createValueEditorPane());
+ }
+
+ public CurrentValueRenderer(ValueEditorPane valueEditorPane) {
+ disableLabel = new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_Disable"));
+ disableLabel.setForeground(Color.pink);
+ disableLabel.setHorizontalAlignment(SwingConstants.CENTER);
+
+ editor = valueEditorPane;
+ }
+
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ if (table.isCellEditable(row, column)) {
+ if (value == null) {
+ editor.populate(StringUtils.EMPTY);
+ } else {
+ if (value instanceof OssVariableValue) {
+ editor.populate(((OssVariableValue) value).getValue());
+ } else {
+ editor.populate(value);
+ }
+ }
+ return editor;
+ } else {
+ return disableLabel;
+ }
+ }
+ }
+
+ private class AddPathAction extends UITableModelAdapter.AddTableRowAction {
+ public AddPathAction() {
+ super();
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ super.actionPerformed(actionEvent);
+ OssSubmitPathTableModel.this.addPath();
+ }
+ }
+}
diff --git a/src/main/resources/com/fr/plugin/file/submit/oss/submit.properties b/src/main/resources/com/fr/plugin/file/submit/oss/submit.properties
index e69de29..3b21f6d 100644
--- a/src/main/resources/com/fr/plugin/file/submit/oss/submit.properties
+++ b/src/main/resources/com/fr/plugin/file/submit/oss/submit.properties
@@ -0,0 +1,9 @@
+Plugin-File_Submit_Oss=Submit to OSS
+Plugin-File_Submit_Oss_Bucket_Name=Bucket name
+Plugin-File_Submit_Oss_Directory=Directory
+Plugin-File_Submit_Oss_File=File
+Plugin-File_Submit_Oss_File_Name=File name
+Plugin-File_Submit_Oss_Editor_Formula=Formula
+Plugin-File_Submit_Oss_Disable=Disabled
+Plugin-File_Download_Oss=Download(OSS)
+Plugin-File_Download_Hyperlink=Hyperlink(OSS)
\ No newline at end of file
diff --git a/src/main/resources/com/fr/plugin/file/submit/oss/submit_zh_CN.properties b/src/main/resources/com/fr/plugin/file/submit/oss/submit_zh_CN.properties
index e69de29..b5443d1 100644
--- a/src/main/resources/com/fr/plugin/file/submit/oss/submit_zh_CN.properties
+++ b/src/main/resources/com/fr/plugin/file/submit/oss/submit_zh_CN.properties
@@ -0,0 +1,9 @@
+Plugin-File_Submit_Oss=\u4E0A\u4F20\u81F3OSS
+Plugin-File_Submit_Oss_Bucket_Name=Bucket\u540D\u5B57
+Plugin-File_Submit_Oss_Directory=\u76EE\u5F55
+Plugin-File_Submit_Oss_File=\u6587\u4EF6
+Plugin-File_Submit_Oss_File_Name=\u6587\u4EF6\u540D
+Plugin-File_Submit_Oss_Editor_Formula=\u516C\u5F0F
+Plugin-File_Submit_Oss_Disable=\u4E0D\u53EF\u7F16\u8F91
+Plugin-File_Download_Oss=\u6587\u4EF6\u4E0B\u8F7D\uFF08OSS\uFF09
+Plugin-File_Download_Hyperlink=\u6587\u4EF6\u4E0B\u8F7D\uFF08OSS\uFF09
\ No newline at end of file
diff --git a/src/main/resources/com/fr/plugin/file/submit/oss/web/oss.js b/src/main/resources/com/fr/plugin/file/submit/oss/web/oss.js
new file mode 100644
index 0000000..68d6d89
--- /dev/null
+++ b/src/main/resources/com/fr/plugin/file/submit/oss/web/oss.js
@@ -0,0 +1,19 @@
+$.extend(FR, {
+
+ doHyperlinkByOssDownload: function (data) {
+ this.ajax({
+ url: FR.fineServletURL + "/url/oss/download",
+ async: true,
+ type: 'post',
+ data : {
+ sessionID: FR.SessionMgr.getSessionID(),
+ bucket : data.bucket,
+ directory : data.directory,
+ fileName : data.fileName
+ },
+ complete: function (res, status) {
+ window.open(res.responseText);
+ }.createDelegate(this)
+ });
+ }
+});
\ No newline at end of file
diff --git a/src/main/resources/com/fr/plugin/file/submit/oss/web/oss.tpl b/src/main/resources/com/fr/plugin/file/submit/oss/web/oss.tpl
new file mode 100644
index 0000000..1af33d5
--- /dev/null
+++ b/src/main/resources/com/fr/plugin/file/submit/oss/web/oss.tpl
@@ -0,0 +1 @@
+FR.doHyperlinkByDownload();
\ No newline at end of file