Browse Source

feat: 用finekit方法更新插件。

pull/1/head
zjz1993 5 years ago
parent
commit
9efc7b0773
  1. 18
      src/main/java/com/fr/plugin/file/download/oss/OssFile2Image.java
  2. 8
      src/main/java/com/fr/plugin/file/submit/oss/OssHyperlink4Download.java
  3. 6
      src/main/java/com/fr/plugin/file/submit/oss/OssHyperlinkJavaScriptHandler.java
  4. 6
      src/main/java/com/fr/plugin/file/submit/oss/OssJavaScriptActionBridge.java
  5. 4
      src/main/java/com/fr/plugin/file/submit/oss/OssSubmitUIBridge.java
  6. 6
      src/main/java/com/fr/plugin/file/submit/oss/OssURLAliasProvider.java
  7. 26
      src/main/java/com/fr/plugin/file/submit/oss/conf/FileSubmitOssServerConfig.java
  8. 23
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssDownloadHttpHandler.java
  9. 29
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTarget.java
  10. 6
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTargetConfig.java
  11. 16
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssUpload.java
  12. 38
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssUploadHttpHandler.java
  13. 28
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssVariableValue.java
  14. 4
      src/main/java/com/fr/plugin/file/submit/oss/job/OssSubmitJob.java
  15. 75
      src/main/java/com/fr/plugin/file/submit/oss/script/OssDownloadHyperlink.java
  16. 15
      src/main/java/com/fr/plugin/file/submit/oss/script/OssSubmitJavaScript.java
  17. 8
      src/main/java/com/fr/plugin/file/submit/oss/ui/Editors.java
  18. 29
      src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlink4DownloadPane.java
  19. 3
      src/main/java/com/fr/plugin/file/submit/oss/ui/OssPathConfigPane.java
  20. 6
      src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitJavaScriptPane.java
  21. 47
      src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitPathTableModel.java
  22. 4
      src/main/java/com/fr/plugin/file/submit/oss/ui/tools/RewriteAction.java

18
src/main/java/com/fr/plugin/file/download/oss/OssFile2Image.java

@ -2,12 +2,12 @@ package com.fr.plugin.file.download.oss;
import com.aliyun.oss.OSSClient; import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.OSSObject; import com.aliyun.oss.model.OSSObject;
import com.fr.general.GeneralUtils; import com.fanruan.api.util.GeneralKit;
import com.fr.general.IOUtils; import com.fanruan.api.util.IOKit;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
import com.fr.plugin.oss.universal.config.OssUniversalConfig; import com.fr.plugin.oss.universal.config.OssUniversalConfig;
import com.fr.script.AbstractFunction; import com.fr.script.AbstractFunction;
import com.fr.stable.ArrayUtils; import com.fanruan.api.util.ArrayKit;
import com.fr.stable.Primitive; import com.fr.stable.Primitive;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@ -21,22 +21,22 @@ public class OssFile2Image extends AbstractFunction {
@Override @Override
public Object run(Object[] args) { public Object run(Object[] args) {
int len = ArrayUtils.getLength(args); int len = ArrayKit.getLength(args);
if (len < 2) { if (len < 2) {
return Primitive.ERROR_VALUE; return Primitive.ERROR_VALUE;
} }
String key = GeneralUtils.objectToString(args[0]); String key = GeneralKit.objectToString(args[0]);
String bucket = GeneralUtils.objectToString(args[1]); String bucket = GeneralKit.objectToString(args[1]);
OSSClient ossClient = new OSSClient( OSSClient ossClient = new OSSClient(
OssUniversalConfig.getInstance().getEndPoint(), OssUniversalConfig.getInstance().getEndPoint(),
OssUniversalConfig.getInstance().getAccessKeyId(), OssUniversalConfig.getInstance().getAccessKeyId(),
OssUniversalConfig.getInstance().getRealAccessKeySecret()); OssUniversalConfig.getInstance().getRealAccessKeySecret());
OSSObject object = ossClient.getObject(bucket, key); OSSObject object = ossClient.getObject(bucket, key);
byte[] bytes = IOUtils.inputStream2Bytes(object.getObjectContent()); byte[] bytes = IOKit.inputStream2Bytes(object.getObjectContent());
try { try {
return ImageIO.read(new ByteArrayInputStream(bytes)); return ImageIO.read(new ByteArrayInputStream(bytes));
} catch (IOException e) { } catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); LogKit.error(e.getMessage(), e);
return Primitive.ERROR_VALUE; return Primitive.ERROR_VALUE;
} }
} }

8
src/main/java/com/fr/plugin/file/submit/oss/OssHyperlink4Download.java

@ -3,10 +3,10 @@ package com.fr.plugin.file.submit.oss;
import com.fr.design.fun.impl.AbstractHyperlinkProvider; import com.fr.design.fun.impl.AbstractHyperlinkProvider;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.DesignKit;
import com.fr.plugin.file.submit.oss.script.OssDownloadHyperlink; import com.fr.plugin.file.submit.oss.script.OssDownloadHyperlink;
import com.fr.plugin.file.submit.oss.ui.OssHyperlink4DownloadPane; import com.fr.plugin.file.submit.oss.ui.OssHyperlink4DownloadPane;
import com.fr.stable.AssistUtils; import com.fanruan.api.util.AssistKit;
public class OssHyperlink4Download extends AbstractHyperlinkProvider { public class OssHyperlink4Download extends AbstractHyperlinkProvider {
@ -14,7 +14,7 @@ public class OssHyperlink4Download extends AbstractHyperlinkProvider {
public OssHyperlink4Download() { public OssHyperlink4Download() {
nameableCreator = new NameObjectCreator( nameableCreator = new NameObjectCreator(
Toolkit.i18nText("Plugin-File_Download_Oss"), DesignKit.i18nText("Plugin-File_Download_Oss"),
OssDownloadHyperlink.class, OssDownloadHyperlink.class,
OssHyperlink4DownloadPane.class); OssHyperlink4DownloadPane.class);
} }
@ -27,7 +27,7 @@ public class OssHyperlink4Download extends AbstractHyperlinkProvider {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
return o instanceof OssHyperlink4Download return o instanceof OssHyperlink4Download
&& AssistUtils.equals(((OssHyperlink4Download) o).nameableCreator, nameableCreator); && AssistKit.equals(((OssHyperlink4Download) o).nameableCreator, nameableCreator);
} }

6
src/main/java/com/fr/plugin/file/submit/oss/OssHyperlinkJavaScriptHandler.java

@ -1,13 +1,15 @@
package com.fr.plugin.file.submit.oss; package com.fr.plugin.file.submit.oss;
import com.fr.base.TemplateUtils; import com.fanruan.api.util.RenderKit;
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler;
import java.util.Collections;
public class OssHyperlinkJavaScriptHandler extends AbstractJavaScriptFileHandler { public class OssHyperlinkJavaScriptHandler extends AbstractJavaScriptFileHandler {
@Override @Override
public String[] pathsForFiles() { public String[] pathsForFiles() {
try { try {
String text = TemplateUtils.render("${fineServletURL}"); String text = RenderKit.renderParameter4Tpl("${fineServletURL}", Collections.EMPTY_MAP);
System.out.println(text); System.out.println(text);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

6
src/main/java/com/fr/plugin/file/submit/oss/OssJavaScriptActionBridge.java

@ -2,7 +2,7 @@ package com.fr.plugin.file.submit.oss;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.fun.impl.AbstractJavaScriptActionProvider; import com.fr.design.fun.impl.AbstractJavaScriptActionProvider;
import com.fr.design.mainframe.DesignerContext; import com.fanruan.api.design.DesignKit;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.plugin.file.submit.oss.ui.OssSubmitJavaScriptPane; import com.fr.plugin.file.submit.oss.ui.OssSubmitJavaScriptPane;
@ -12,8 +12,8 @@ public class OssJavaScriptActionBridge extends AbstractJavaScriptActionProvider
public FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane() { public FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane() {
return new OssSubmitJavaScriptPane(); return new OssSubmitJavaScriptPane();
} }
@Override
public boolean isSupportType() { public boolean isSupportType() {
return DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook(); return DesignKit.getDesignerFrame().getSelectedJTemplate().isJWorkBook();
} }
} }

4
src/main/java/com/fr/plugin/file/submit/oss/OssSubmitUIBridge.java

@ -2,7 +2,7 @@ package com.fr.plugin.file.submit.oss;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.impl.AbstractSubmitProvider; import com.fr.design.fun.impl.AbstractSubmitProvider;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.DesignKit;
import com.fr.plugin.file.submit.oss.fun.OssConstants; import com.fr.plugin.file.submit.oss.fun.OssConstants;
import com.fr.plugin.file.submit.oss.ui.OssPathConfigPane; import com.fr.plugin.file.submit.oss.ui.OssPathConfigPane;
@ -14,7 +14,7 @@ public class OssSubmitUIBridge extends AbstractSubmitProvider {
@Override @Override
public String dataForSubmit() { public String dataForSubmit() {
return Toolkit.i18nText("Plugin-File_Submit_Oss"); return DesignKit.i18nText("Plugin-File_Submit_Oss");
} }
@Override @Override

6
src/main/java/com/fr/plugin/file/submit/oss/OssURLAliasProvider.java

@ -1,15 +1,15 @@
package com.fr.plugin.file.submit.oss; package com.fr.plugin.file.submit.oss;
import com.fr.decision.webservice.url.alias.URLAlias; import com.fr.decision.webservice.url.alias.URLAlias;
import com.fr.decision.webservice.url.alias.URLAliasFactory; import com.fanruan.api.net.URLAliasKit;
import com.fr.decision.webservice.url.provider.AbstractURLAliasProvider; import com.fr.decision.webservice.url.provider.AbstractURLAliasProvider;
public class OssURLAliasProvider extends AbstractURLAliasProvider { public class OssURLAliasProvider extends AbstractURLAliasProvider {
@Override @Override
public URLAlias[] registerAlias() { public URLAlias[] registerAlias() {
return new URLAlias[]{ return new URLAlias[]{
URLAliasFactory.createPluginAlias("/oss/download", "/oss/download", true), URLAliasKit.createPluginAlias("/oss/download", "/oss/download", true),
URLAliasFactory.createPluginAlias("/oss/upload", "/oss/upload", true) URLAliasKit.createPluginAlias("/oss/upload", "/oss/upload", true)
}; };
} }
} }

26
src/main/java/com/fr/plugin/file/submit/oss/conf/FileSubmitOssServerConfig.java

@ -1,53 +1,47 @@
package com.fr.plugin.file.submit.oss.conf; package com.fr.plugin.file.submit.oss.conf;
import com.fr.config.ConfigContext; import com.fanruan.api.conf.BaseConfiguration;
import com.fr.config.DefaultConfiguration;
import com.fr.config.Identifier; import com.fr.config.Identifier;
import com.fr.config.Status; import com.fr.config.Status;
import com.fr.config.Visualization; import com.fr.config.Visualization;
import com.fr.config.holder.Conf; import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders; import com.fanruan.api.conf.HolderKit;
import com.fr.config.holder.impl.ColConf; import com.fanruan.api.conf.impl.ColConf;
import com.fr.config.holder.impl.ObjConf;
import com.fr.intelli.record.Focus; import com.fr.intelli.record.Focus;
import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.third.org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/** /**
* OSS文件上传下载所使用的OSS配置 * OSS文件上传下载所使用的OSS配置
*/ */
@Visualization(category = "Plugin-Oss_Settings") @Visualization(category = "Plugin-Oss_Settings")
@EnableMetrics @EnableMetrics
public class FileSubmitOssServerConfig extends DefaultConfiguration { public class FileSubmitOssServerConfig extends BaseConfiguration {
private static volatile FileSubmitOssServerConfig instance = null; private static volatile FileSubmitOssServerConfig instance = null;
public static FileSubmitOssServerConfig getInstance() { public static FileSubmitOssServerConfig getInstance() {
if (instance == null) { if (instance == null) {
instance = ConfigContext.getConfigInstance(FileSubmitOssServerConfig.class); instance = BaseConfiguration.getConfigInstance(FileSubmitOssServerConfig.class);
} }
return instance; return instance;
} }
// 地域节点配置信息 // 地域节点配置信息
@Identifier(value = "endPoint", name = "EndPoint", description = "Plugin-Oss_End_Point", status = Status.SHOW) @Identifier(value = "endPoint", name = "EndPoint", description = "Plugin-Oss_End_Point", status = Status.SHOW)
private Conf<String> endPoint = Holders.simple(StringUtils.EMPTY); private Conf<String> endPoint = HolderKit.simple(StringKit.EMPTY);
@Identifier(value = "accessKeyId", name = "AccessKeyId", description = "Plugin-Oss_AccessKeyId", status = Status.SHOW) @Identifier(value = "accessKeyId", name = "AccessKeyId", description = "Plugin-Oss_AccessKeyId", status = Status.SHOW)
private Conf<String> accessKeyId = Holders.simple(StringUtils.EMPTY); private Conf<String> accessKeyId = HolderKit.simple(StringKit.EMPTY);
@Identifier(value = "accessKeySecret", name = "AccessKeySecret", description = "Plugin-Oss_AccessKeySecret", status = Status.SHOW) @Identifier(value = "accessKeySecret", name = "AccessKeySecret", description = "Plugin-Oss_AccessKeySecret", status = Status.SHOW)
private Conf<String> accessKeySecret = Holders.simple(StringUtils.EMPTY); private Conf<String> accessKeySecret = HolderKit.simple(StringKit.EMPTY);
@Identifier(value = "buckets", name = "Buckets", description = "Plugin-Oss_Buckets", status = Status.SHOW) @Identifier(value = "buckets", name = "Buckets", description = "Plugin-Oss_Buckets", status = Status.SHOW)
private ColConf<Collection<String>> buckets = Holders.collection(new ArrayList<String>(), String.class); private ColConf<Collection<String>> buckets = HolderKit.collection(new ArrayList<String>(), String.class);
public String getEndPoint() { public String getEndPoint() {
return endPoint.get(); return endPoint.get();

23
src/main/java/com/fr/plugin/file/submit/oss/fun/OssDownloadHttpHandler.java

@ -3,12 +3,11 @@ package com.fr.plugin.file.submit.oss.fun;
import com.aliyun.oss.HttpMethod; import com.aliyun.oss.HttpMethod;
import com.aliyun.oss.OSSClient; import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.GeneratePresignedUrlRequest; import com.aliyun.oss.model.GeneratePresignedUrlRequest;
import com.fr.data.NetworkHelper; import com.fanruan.api.net.NetworkKit;
import com.fr.decision.fun.impl.BaseHttpHandler; import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.plugin.oss.universal.config.OssUniversalConfig; import com.fr.plugin.oss.universal.config.OssUniversalConfig;
import com.fr.stable.StableUtils; import com.fanruan.api.util.GeneralKit;
import com.fr.third.springframework.web.bind.annotation.RequestMethod; import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -18,27 +17,27 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
public class OssDownloadHttpHandler extends BaseHttpHandler { public class OssDownloadHttpHandler extends BaseHttpHandler {
@Override
public RequestMethod getMethod() { public RequestMethod getMethod() {
return RequestMethod.POST; return RequestMethod.POST;
} }
@Override
public String getPath() { public String getPath() {
return "/oss/download"; return "/oss/download";
} }
@Override
public boolean isPublic() { public boolean isPublic() {
return true; return true;
} }
@Override
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
String bucket = NetworkHelper.getHTTPRequestParameter(req, "bucket"); String bucket = NetworkKit.getHTTPRequestParameter(req, "bucket");
String directory = NetworkHelper.getHTTPRequestParameter(req, "directory"); String directory = NetworkKit.getHTTPRequestParameter(req, "directory");
String fileName = NetworkHelper.getHTTPRequestParameter(req, "fileName"); String fileName = NetworkKit.getHTTPRequestParameter(req, "fileName");
PrintWriter writer = WebUtils.createPrintWriter(res); PrintWriter writer = NetworkKit.createPrintWriter(res);
writer.write(createDownloadUrl(bucket, directory, fileName)); writer.write(createDownloadUrl(bucket, directory, fileName));
writer.flush(); writer.flush();
writer.close(); writer.close();
@ -54,7 +53,7 @@ public class OssDownloadHttpHandler extends BaseHttpHandler {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 1); calendar.add(Calendar.MINUTE, 1);
Date expiration = calendar.getTime(); Date expiration = calendar.getTime();
String key = StableUtils.pathJoin(directory, fileName); String key = GeneralKit.pathJoin(directory, fileName);
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, key, HttpMethod.GET); GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, key, HttpMethod.GET);
// 设置过期时间。 // 设置过期时间。
request.setExpiration(expiration); request.setExpiration(expiration);

29
src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTarget.java

@ -1,8 +1,8 @@
package com.fr.plugin.file.submit.oss.fun; package com.fr.plugin.file.submit.oss.fun;
import com.fr.general.xml.GeneralXMLTools; import com.fanruan.api.xml.XmlKit;
import com.fr.stable.AssistUtils; import com.fanruan.api.util.AssistKit;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -64,39 +64,40 @@ public class OssSubmitTarget implements XMLable {
if ("Bucket".equals(tagName)) { if ("Bucket".equals(tagName)) {
this.bucket = reader.getElementValue(); this.bucket = reader.getElementValue();
} else if ("Directory".equals(tagName)) { } else if ("Directory".equals(tagName)) {
this.directory = (OssVariableValue) GeneralXMLTools.readXMLable(reader); this.directory = (OssVariableValue) XmlKit.readXMLable(reader);
} else if ("Name".equals(tagName)) { } else if ("Name".equals(tagName)) {
this.name = (OssVariableValue) GeneralXMLTools.readXMLable(reader); this.name = (OssVariableValue) XmlKit.readXMLable(reader);
} else if ("File".equals(tagName)) { } else if ("File".equals(tagName)) {
this.file = (OssVariableValue) GeneralXMLTools.readXMLable(reader); this.file = (OssVariableValue) XmlKit.readXMLable(reader);
} }
} }
} }
public void writeXML(final XMLPrintWriter writer) { public void writeXML(final XMLPrintWriter writer) {
if (StringUtils.isNotEmpty(bucket)) { if (StringKit.isNotEmpty(bucket)) {
writer.startTAG("Bucket").textNode(bucket).end(); writer.startTAG("Bucket").textNode(bucket).end();
} }
if (directory != null) { if (directory != null) {
GeneralXMLTools.writeXMLable(writer, directory, "Directory"); XmlKit.writeXMLable(writer, directory, "Directory");
} }
if (name != null) { if (name != null) {
GeneralXMLTools.writeXMLable(writer, name, "Name"); XmlKit.writeXMLable(writer, name, "Name");
} }
if (file != null) { if (file != null) {
GeneralXMLTools.writeXMLable(writer, file, "File"); XmlKit.writeXMLable(writer, file, "File");
} }
} }
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
return o instanceof OssSubmitTarget return o instanceof OssSubmitTarget
&& AssistUtils.equals(((OssSubmitTarget) o).bucket, bucket) && AssistKit.equals(((OssSubmitTarget) o).bucket, bucket)
&& AssistUtils.equals(((OssSubmitTarget) o).directory, directory) && AssistKit.equals(((OssSubmitTarget) o).directory, directory)
&& AssistUtils.equals(((OssSubmitTarget) o).name, name) && AssistKit.equals(((OssSubmitTarget) o).name, name)
&& AssistUtils.equals(((OssSubmitTarget) o).file, file); && AssistKit.equals(((OssSubmitTarget) o).file, file);
} }
@Override
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
OssSubmitTarget cloned = (OssSubmitTarget) super.clone(); OssSubmitTarget cloned = (OssSubmitTarget) super.clone();
cloned.bucket = bucket; cloned.bucket = bucket;

6
src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTargetConfig.java

@ -1,6 +1,6 @@
package com.fr.plugin.file.submit.oss.fun; package com.fr.plugin.file.submit.oss.fun;
import com.fr.general.xml.GeneralXMLTools; import com.fanruan.api.xml.XmlKit;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLable;
@ -40,7 +40,7 @@ public class OssSubmitTargetConfig implements XMLable {
if (xmLableReader.isChildNode()) { if (xmLableReader.isChildNode()) {
String tagName = xmLableReader.getTagName(); String tagName = xmLableReader.getTagName();
if (OssSubmitTarget.XML_TAG.equals(tagName)) { if (OssSubmitTarget.XML_TAG.equals(tagName)) {
OssSubmitTarget target = (OssSubmitTarget)GeneralXMLTools.readXMLable(xmLableReader); OssSubmitTarget target = (OssSubmitTarget)XmlKit.readXMLable(xmLableReader);
targets.add(target); targets.add(target);
} }
} }
@ -52,7 +52,7 @@ public class OssSubmitTargetConfig implements XMLable {
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
for (OssSubmitTarget target : targets) { for (OssSubmitTarget target : targets) {
GeneralXMLTools.writeXMLable(writer, target, OssSubmitTarget.XML_TAG); XmlKit.writeXMLable(writer, target, OssSubmitTarget.XML_TAG);
} }
} }

16
src/main/java/com/fr/plugin/file/submit/oss/fun/OssUpload.java

@ -3,11 +3,11 @@ package com.fr.plugin.file.submit.oss.fun;
import com.aliyun.oss.OSSClient; import com.aliyun.oss.OSSClient;
import com.fr.cache.Attachment; import com.fr.cache.Attachment;
import com.fr.general.FArray; import com.fr.general.FArray;
import com.fr.general.GeneralUtils; import com.fanruan.api.util.GeneralKit;
import com.fr.locale.InterProviderFactory; import com.fanruan.api.i18n.I18nKit;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.stable.xml.FRFile; import com.fr.stable.xml.FRFile;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -18,7 +18,7 @@ public class OssUpload {
OssSubmitTarget[] submitTargets = submitTargetConfig.getSubmitTargets(); OssSubmitTarget[] submitTargets = submitTargetConfig.getSubmitTargets();
for (OssSubmitTarget target : submitTargets) { for (OssSubmitTarget target : submitTargets) {
OssVariableValue fileObject = target.getFile(); OssVariableValue fileObject = target.getFile();
String filePath = GeneralUtils.objectToString(fileObject); String filePath = GeneralKit.objectToString(fileObject);
Object file = calculator.evalValue(filePath); Object file = calculator.evalValue(filePath);
@ -48,12 +48,12 @@ public class OssUpload {
private static void uploadSingleFile(OSSClient ossClient, String bucket, String directory, String newFileName, byte[] bytes) { private static void uploadSingleFile(OSSClient ossClient, String bucket, String directory, String newFileName, byte[] bytes) {
if (ArrayUtils.isEmpty(bytes)) { if (ArrayUtils.isEmpty(bytes)) {
throw new RuntimeException(InterProviderFactory.getProvider().getLocText("Plugin-File_Submit_Oss_Failed", newFileName)); throw new RuntimeException(I18nKit.getLocText("Plugin-File_Submit_Oss_Failed", newFileName));
} }
ossClient.putObject(bucket, directory + "/" + newFileName, new ByteArrayInputStream(bytes)); ossClient.putObject(bucket, directory + "/" + newFileName, new ByteArrayInputStream(bytes));
} }
/* /**
* 这里的逻辑是 * 这里的逻辑是
* 1如果没有设置文件名就用上传的文件的名字 * 1如果没有设置文件名就用上传的文件的名字
* 2如果设置了文件名且带有文件后缀就用设置的文件名 * 2如果设置了文件名且带有文件后缀就用设置的文件名
@ -61,10 +61,10 @@ public class OssUpload {
*/ */
private static String combineName(String fileName, String myFileName) { private static String combineName(String fileName, String myFileName) {
String realFileName; String realFileName;
if (StringUtils.isBlank(fileName)) { if (StringKit.isBlank(fileName)) {
fileName = "unnamed.png"; fileName = "unnamed.png";
} }
if (StringUtils.isNotEmpty(myFileName)) { if (StringKit.isNotEmpty(myFileName)) {
int index = myFileName.lastIndexOf("."); int index = myFileName.lastIndexOf(".");
if (index == -1) { if (index == -1) {
realFileName = fileName; realFileName = fileName;

38
src/main/java/com/fr/plugin/file/submit/oss/fun/OssUploadHttpHandler.java

@ -1,15 +1,15 @@
package com.fr.plugin.file.submit.oss.fun; package com.fr.plugin.file.submit.oss.fun;
import com.aliyun.oss.OSSClient; import com.aliyun.oss.OSSClient;
import com.fr.base.ParameterMapNameSpace; import com.fr.stable.script.NameSpace;
import com.fr.data.NetworkHelper; import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.net.NetworkKit;
import com.fr.decision.fun.impl.BaseHttpHandler; import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.general.xml.GeneralXMLTools; import com.fanruan.api.xml.XmlKit;
import com.fr.json.JSON;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.json.JSONKit;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.file.submit.oss.script.OssSubmitJavaScript; import com.fr.plugin.file.submit.oss.script.OssSubmitJavaScript;
import com.fr.plugin.oss.universal.config.OssUniversalConfig; import com.fr.plugin.oss.universal.config.OssUniversalConfig;
import com.fr.script.Calculator; import com.fr.script.Calculator;
@ -18,7 +18,7 @@ import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.web.core.ReportSessionIDInfor; import com.fr.web.core.ReportSessionIDInfor;
import com.fr.web.core.SessionPoolManager; import com.fr.web.core.SessionPoolManager;
import com.fr.web.session.SessionIDInfo; import com.fr.web.session.SessionIDInfo;
import com.fr.web.utils.WebUtils; import com.fanruan.api.session.SessionKit;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -42,23 +42,23 @@ public class OssUploadHttpHandler extends BaseHttpHandler {
@Override @Override
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
final String httpRequestEncodeParameter = NetworkHelper.getHTTPRequestEncodeParameter(req, "xmlconf", true); final String httpRequestEncodeParameter = NetworkKit.getHTTPRequestEncodeParameter(req, "xmlconf", true);
if (httpRequestEncodeParameter != null) { if (httpRequestEncodeParameter != null) {
String sessionID = NetworkHelper.getHTTPRequestParameter(req, "sessionID"); String sessionID = NetworkKit.getHTTPRequestParameter(req, "sessionID");
final ReportSessionIDInfor reportSessionIDInfor = SessionPoolManager.getSessionIDInfor(sessionID, ReportSessionIDInfor.class); final ReportSessionIDInfor reportSessionIDInfor = SessionPoolManager.getSessionIDInfor(sessionID, ReportSessionIDInfor.class);
if (reportSessionIDInfor == null) { if (reportSessionIDInfor == null) {
return; return;
} }
final OssSubmitJavaScript javaScript = (OssSubmitJavaScript) GeneralXMLTools.readStringAsXMLable(httpRequestEncodeParameter); final OssSubmitJavaScript javaScript = (OssSubmitJavaScript) XmlKit.readStringAsXMLable(httpRequestEncodeParameter);
if (javaScript == null) { if (javaScript == null) {
return; return;
} }
final Calculator calculator = Calculator.createCalculator(); final Calculator calculator = Calculator.createCalculator();
final ParameterMapNameSpace create = ParameterMapNameSpace.create(WebUtils.parameters4SessionIDInfor(req)); final NameSpace create = ParameterKit.createParameterMapNameSpace(SessionKit.parameters4SessionIDInfor(req));
calculator.pushNameSpace(create); calculator.pushNameSpace(create);
this.initCalAttrAndNS(calculator, reportSessionIDInfor, req); this.initCalAttrAndNS(calculator, reportSessionIDInfor, req);
boolean b = true; boolean b = true;
final JSONObject jsonObject = JSONObject.create(); final JSONObject jsonObject = JSONKit.create();
OSSClient ossClient = new OSSClient( OSSClient ossClient = new OSSClient(
OssUniversalConfig.getInstance().getEndPoint(), OssUniversalConfig.getInstance().getEndPoint(),
OssUniversalConfig.getInstance().getAccessKeyId(), OssUniversalConfig.getInstance().getAccessKeyId(),
@ -66,16 +66,16 @@ public class OssUploadHttpHandler extends BaseHttpHandler {
try { try {
this.process(ossClient, javaScript, calculator); this.process(ossClient, javaScript, calculator);
} catch (Exception ex) { } catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex); LogKit.error(ex.getMessage(), ex);
b = false; b = false;
jsonObject.put("errorMsg", ex.getMessage()); jsonObject.put("errorMsg", ex.getMessage());
} finally { } finally {
ossClient.shutdown(); ossClient.shutdown();
} }
calculator.removeNameSpace(create); calculator.removeNameSpace(create);
final PrintWriter printWriter = WebUtils.createPrintWriter(res); final PrintWriter printWriter = NetworkKit.createPrintWriter(res);
final JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY); final JSONArray jsonArray = JSONKit.createJSONArray();
final JSONObject jsonObject2 = JSONFactory.createJSON(JSON.OBJECT); final JSONObject jsonObject2 = JSONKit.create();
jsonObject.put("success", b); jsonObject.put("success", b);
jsonObject2.put("oss_submit_info", jsonObject); jsonObject2.put("oss_submit_info", jsonObject);
jsonArray.put(jsonObject2); jsonArray.put(jsonObject2);
@ -90,10 +90,10 @@ public class OssUploadHttpHandler extends BaseHttpHandler {
} }
private void initCalAttrAndNS(final Calculator calculator, final ReportSessionIDInfor reportSessionIDInfor, final HttpServletRequest httpServletRequest) { private void initCalAttrAndNS(final Calculator calculator, final ReportSessionIDInfor reportSessionIDInfor, final HttpServletRequest httpServletRequest) {
calculator.setAttribute(Calculator.SHEET_NUMBER_KEY, WebUtils.getHTTPRequestParameter(httpServletRequest, "sheetNum")); calculator.setAttribute(Calculator.SHEET_NUMBER_KEY, NetworkKit.getHTTPRequestParameter(httpServletRequest, "sheetNum"));
reportSessionIDInfor.setUpAttribute4dbCommit(calculator); reportSessionIDInfor.setUpAttribute4dbCommit(calculator);
calculator.pushNameSpace(ParameterMapNameSpace.create(reportSessionIDInfor.getParameterMap4Execute())); calculator.pushNameSpace(ParameterKit.createParameterMapNameSpace(reportSessionIDInfor.getParameterMap4Execute()));
final ColumnRow value = ColumnRow.valueOf(WebUtils.getHTTPRequestParameter(httpServletRequest, "location")); final ColumnRow value = ColumnRow.valueOf(NetworkKit.getHTTPRequestParameter(httpServletRequest, "location"));
if (value != ColumnRow.ERROR) { if (value != ColumnRow.ERROR) {
calculator.setAttribute(ColumnRow.CURRENT_CR_KEY, value); calculator.setAttribute(ColumnRow.CURRENT_CR_KEY, value);
} }

28
src/main/java/com/fr/plugin/file/submit/oss/fun/OssVariableValue.java

@ -1,10 +1,10 @@
package com.fr.plugin.file.submit.oss.fun; package com.fr.plugin.file.submit.oss.fun;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.general.GeneralUtils; import com.fanruan.api.util.GeneralKit;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.log.LogKit;
import com.fr.stable.CommonUtils; import com.fanruan.api.cal.FormulaKit;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import com.fr.stable.UtilEvalError; import com.fr.stable.UtilEvalError;
import com.fr.stable.script.CalculatorProvider; import com.fr.stable.script.CalculatorProvider;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
@ -28,8 +28,8 @@ public class OssVariableValue implements XMLable {
type = Type.FORMULA; type = Type.FORMULA;
this.value = value; this.value = value;
} else { } else {
String content = GeneralUtils.objectToString(value); String content = GeneralKit.objectToString(value);
if (CommonUtils.canBeFormula(content)) { if (FormulaKit.canBeFormula(content)) {
type = Type.FORMULA; type = Type.FORMULA;
this.value = BaseFormula.createFormulaBuilder().build(content); this.value = BaseFormula.createFormulaBuilder().build(content);
} else { } else {
@ -51,20 +51,20 @@ public class OssVariableValue implements XMLable {
if (type == Type.FORMULA) { if (type == Type.FORMULA) {
return ((BaseFormula)value).getPureContent(); return ((BaseFormula)value).getPureContent();
} else { } else {
return GeneralUtils.objectToString(value); return GeneralKit.objectToString(value);
} }
} }
public String getResult(CalculatorProvider cal) { public String getResult(CalculatorProvider cal){
Object result = value; Object result = value;
if (type == Type.FORMULA) { if (type == Type.FORMULA) {
try { try {
result = ((BaseFormula) value).evalValue(cal); result = ((BaseFormula) value).evalValue(cal);
} catch (UtilEvalError u) { } catch (UtilEvalError u) {
FineLoggerFactory.getLogger().error(u.getMessage(), u); LogKit.error(u.getMessage(), u);
} }
} }
return GeneralUtils.objectToString(result); return GeneralKit.objectToString(result);
} }
@Override @Override
@ -74,9 +74,9 @@ public class OssVariableValue implements XMLable {
if ("Attr".equals(tagName)) { if ("Attr".equals(tagName)) {
type = Type.parse(reader.getAttrAsInt("type", 0)); type = Type.parse(reader.getAttrAsInt("type", 0));
if (type == Type.FORMULA) { if (type == Type.FORMULA) {
value = BaseFormula.createFormulaBuilder().build(reader.getAttrAsString("value", StringUtils.EMPTY)); value = BaseFormula.createFormulaBuilder().build(reader.getAttrAsString("value", StringKit.EMPTY));
} else { } else {
value = reader.getAttrAsString("value", StringUtils.EMPTY); value = reader.getAttrAsString("value", StringKit.EMPTY);
} }
} }
} }
@ -88,7 +88,7 @@ public class OssVariableValue implements XMLable {
if (value instanceof BaseFormula) { if (value instanceof BaseFormula) {
writer.attr("type", Type.FORMULA.getIndex()).attr("value", ((BaseFormula) value).getPureContent()); writer.attr("type", Type.FORMULA.getIndex()).attr("value", ((BaseFormula) value).getPureContent());
} else { } else {
writer.attr("type", Type.PLAIN.getIndex()).attr("value", GeneralUtils.objectToString(value)); writer.attr("type", Type.PLAIN.getIndex()).attr("value", GeneralKit.objectToString(value));
} }
writer.end(); writer.end();
} }
@ -99,7 +99,7 @@ public class OssVariableValue implements XMLable {
} }
public String toString() { public String toString() {
return value == null ? StringUtils.EMPTY : GeneralUtils.objectToString(value); return value == null ? StringKit.EMPTY : GeneralKit.objectToString(value);
} }

4
src/main/java/com/fr/plugin/file/submit/oss/job/OssSubmitJob.java

@ -2,7 +2,7 @@ package com.fr.plugin.file.submit.oss.job;
import com.aliyun.oss.OSSClient; import com.aliyun.oss.OSSClient;
import com.fr.data.AbstractSubmitTask; import com.fr.data.AbstractSubmitTask;
import com.fr.general.xml.GeneralXMLTools; import com.fanruan.api.xml.XmlKit;
import com.fr.intelli.record.Focus; import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original; import com.fr.intelli.record.Original;
import com.fr.plugin.file.submit.oss.fun.OssConstants; import com.fr.plugin.file.submit.oss.fun.OssConstants;
@ -114,7 +114,7 @@ public class OssSubmitJob extends AbstractSubmitTask {
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
if (submitTargetConfig != null) { if (submitTargetConfig != null) {
GeneralXMLTools.writeXMLable(writer, submitTargetConfig, OssSubmitTargetConfig.XML_TAG); XmlKit.writeXMLable(writer, submitTargetConfig, OssSubmitTargetConfig.XML_TAG);
} }
} }
} }

75
src/main/java/com/fr/plugin/file/submit/oss/script/OssDownloadHyperlink.java

@ -1,35 +1,29 @@
package com.fr.plugin.file.submit.oss.script; package com.fr.plugin.file.submit.oss.script;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.Parameter; import com.fr.stable.ParameterProvider;
import com.fr.base.ParameterMapNameSpace; import com.fanruan.api.cal.ParameterKit;
import com.fr.base.ResultFormula; import com.fr.base.ResultFormula;
import com.fr.general.GeneralUtils; import com.fanruan.api.util.GeneralKit;
import com.fr.general.xml.GeneralXMLTools; import com.fanruan.api.xml.XmlKit;
import com.fr.js.Hyperlink; import com.fr.js.Hyperlink;
import com.fr.json.JSONException; import com.fanruan.api.err.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fanruan.api.json.JSONKit;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.file.submit.oss.fun.OssVariableValue; import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils; import com.fanruan.api.util.ArrayKit;
import com.fr.stable.AssistUtils; import com.fanruan.api.util.AssistKit;
import com.fr.stable.ColumnRow; import com.fanruan.api.util.StringKit;
import com.fr.stable.FormulaProvider;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.script.CalculatorProvider;
import com.fr.stable.script.ExTool;
import com.fr.stable.script.NameSpace;
import com.fr.stable.web.Repository; import com.fr.stable.web.Repository;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.web.session.SessionIDInfo; import com.fanruan.api.session.SessionKit;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class OssDownloadHyperlink extends Hyperlink { public class OssDownloadHyperlink extends Hyperlink {
@ -68,8 +62,8 @@ public class OssDownloadHyperlink extends Hyperlink {
return; return;
} }
ParameterProvider[] providers = getParameters(); ParameterProvider[] providers = getParameters();
if (ArrayUtils.isEmpty(providers)) { if (ArrayKit.isEmpty(providers)) {
providers = ArrayUtils.add(providers, new Parameter(parameterName, variableValue.getValue())); providers = ArrayKit.add(providers, ParameterKit.newParameter(parameterName, variableValue.getValue()));
} else { } else {
Map<String, ParameterProvider> map = new HashMap<String, ParameterProvider>(); Map<String, ParameterProvider> map = new HashMap<String, ParameterProvider>();
for (ParameterProvider provider : providers) { for (ParameterProvider provider : providers) {
@ -78,7 +72,7 @@ public class OssDownloadHyperlink extends Hyperlink {
if (map.containsKey(parameterName)) { if (map.containsKey(parameterName)) {
map.get(parameterName).setValue(variableValue.getValue()); map.get(parameterName).setValue(variableValue.getValue());
} else { } else {
providers = ArrayUtils.add(providers, new Parameter(parameterName, variableValue.getValue())); providers = ArrayKit.add(providers, ParameterKit.newParameter(parameterName, variableValue.getValue()));
} }
} }
setParameters(providers); setParameters(providers);
@ -86,8 +80,8 @@ public class OssDownloadHyperlink extends Hyperlink {
@Override @Override
protected String actionJS(Repository repository) { protected String actionJS(Repository repository) throws JSONException{
JSONObject data = JSONObject.create(); JSONObject data = JSONKit.create();
try { try {
data.put("bucket", bucket); data.put("bucket", bucket);
if (directory != null) { if (directory != null) {
@ -97,16 +91,17 @@ public class OssDownloadHyperlink extends Hyperlink {
data.put("fileName", getResultValue(repository, "fileName", fileName)); data.put("fileName", getResultValue(repository, "fileName", fileName));
} }
} catch (JSONException e) { } catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); LogKit.error(e.getMessage(), e);
} }
return "FR.doHyperlinkByOssDownload(" + data.toString() + ");"; return "FR.doHyperlinkByOssDownload(" + data.toString() + ");";
} }
private String getResultValue(Repository repository, String parameterName, OssVariableValue variableValue) { @NotNull
private String getResultValue(Repository repository, String parameterName, OssVariableValue variableValue){
Object result = null; Object result = null;
ParameterProvider[] providers = getParameters(); ParameterProvider[] providers = getParameters();
for (ParameterProvider provider : providers) { for (ParameterProvider provider : providers) {
if (AssistUtils.equals(parameterName, provider.getName())) { if (AssistKit.equals(parameterName, provider.getName())) {
Object value = provider.getValue(); Object value = provider.getValue();
if (value instanceof BaseFormula) { if (value instanceof BaseFormula) {
result = ((BaseFormula) value).getResult(); result = ((BaseFormula) value).getResult();
@ -123,22 +118,22 @@ public class OssDownloadHyperlink extends Hyperlink {
Calculator calculator = newCalculator(repository); Calculator calculator = newCalculator(repository);
result = variableValue.getResult(calculator); result = variableValue.getResult(calculator);
} }
return GeneralUtils.objectToString(result); return GeneralKit.objectToString(result);
} }
private Calculator newCalculator(Repository repository) { private Calculator newCalculator(Repository repository) {
Calculator calculator = Calculator.createCalculator(); Calculator calculator = Calculator.createCalculator();
if (repository != null) { if (repository != null) {
calculator.pushNameSpace(ParameterMapNameSpace.create(repository.getReportParameterMap())); calculator.pushNameSpace(ParameterKit.createParameterMapNameSpace(repository.getReportParameterMap()));
calculator.pushNameSpace(SessionIDInfo.asNameSpace(repository.getSessionID())); calculator.pushNameSpace(SessionKit.asNameSpace(repository.getSessionID()));
} }
if (!paraMap.isEmpty()) { if (!paraMap.isEmpty()) {
calculator.pushNameSpace(ParameterMapNameSpace.create(this.paraMap)); calculator.pushNameSpace(ParameterKit.createParameterMapNameSpace(new HashMap(this.paraMap)));
} }
return calculator; return calculator;
} }
@Override
public void readXML(final XMLableReader reader) { public void readXML(final XMLableReader reader) {
super.readXML(reader); super.readXML(reader);
if (reader.isChildNode()) { if (reader.isChildNode()) {
@ -146,24 +141,24 @@ public class OssDownloadHyperlink extends Hyperlink {
if ("Bucket".equals(tagName)) { if ("Bucket".equals(tagName)) {
this.bucket = reader.getElementValue(); this.bucket = reader.getElementValue();
} else if ("Directory".equals(tagName)) { } else if ("Directory".equals(tagName)) {
this.setDirectory((OssVariableValue)GeneralXMLTools.readXMLable(reader)); this.setDirectory((OssVariableValue)XmlKit.readXMLable(reader));
} else if ("FileName".equals(tagName)) { } else if ("FileName".equals(tagName)) {
this.setFileName((OssVariableValue) GeneralXMLTools.readXMLable(reader)); this.setFileName((OssVariableValue) XmlKit.readXMLable(reader));
} }
} }
} }
@Override
public void writeXML(final XMLPrintWriter writer) { public void writeXML(final XMLPrintWriter writer) {
writer.startTAG("JavaScript").attr("class", this.getClass().getName()); writer.startTAG("JavaScript").attr("class", this.getClass().getName());
super.writeXML(writer); super.writeXML(writer);
if (StringUtils.isNotEmpty(bucket)) { if (StringKit.isNotEmpty(bucket)) {
writer.startTAG("Bucket").textNode(bucket).end(); writer.startTAG("Bucket").textNode(bucket).end();
} }
if (directory != null) { if (directory != null) {
GeneralXMLTools.writeXMLable(writer, directory, "Directory"); XmlKit.writeXMLable(writer, directory, "Directory");
} }
if (fileName != null) { if (fileName != null) {
GeneralXMLTools.writeXMLable(writer, fileName, "FileName"); XmlKit.writeXMLable(writer, fileName, "FileName");
} }
writer.end(); writer.end();
} }
@ -171,9 +166,9 @@ public class OssDownloadHyperlink extends Hyperlink {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
return o instanceof OssDownloadHyperlink return o instanceof OssDownloadHyperlink
&& AssistUtils.equals(((OssDownloadHyperlink) o).bucket, bucket) && AssistKit.equals(((OssDownloadHyperlink) o).bucket, bucket)
&& AssistUtils.equals(((OssDownloadHyperlink) o).directory, directory) && AssistKit.equals(((OssDownloadHyperlink) o).directory, directory)
&& AssistUtils.equals(((OssDownloadHyperlink) o).fileName, fileName); && AssistKit.equals(((OssDownloadHyperlink) o).fileName, fileName);
} }
@Override @Override

15
src/main/java/com/fr/plugin/file/submit/oss/script/OssSubmitJavaScript.java

@ -1,11 +1,10 @@
package com.fr.plugin.file.submit.oss.script; package com.fr.plugin.file.submit.oss.script;
import com.fr.general.xml.GeneralXMLTools; import com.fanruan.api.xml.XmlKit;
import com.fr.js.AbstractJavaScript; import com.fr.js.AbstractJavaScript;
import com.fr.json.JSONObject;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTargetConfig; import com.fr.plugin.file.submit.oss.fun.OssSubmitTargetConfig;
import com.fr.stable.AssistUtils; import com.fanruan.api.util.AssistKit;
import com.fr.stable.CommonCodeUtils; import com.fanruan.api.util.CodeKit;
import com.fr.stable.web.Repository; import com.fr.stable.web.Repository;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -24,11 +23,11 @@ public class OssSubmitJavaScript extends AbstractJavaScript {
@Override @Override
protected String actionJS(Repository repository) { protected String actionJS(Repository repository) {
return "var fm = new FR.OssForm();fm.ossCommit({xmlconf:" + quote(GeneralXMLTools.writeXMLableAsString(this)) + "},this)"; return "var fm = new FR.OssForm();fm.ossCommit({xmlconf:" + quote(XmlKit.writeXMLableAsString(this)) + "},this)";
} }
private String quote(String string) { private String quote(String string) {
return "\"" + CommonCodeUtils.javascriptEncode(string) + "\"" ; return "\"" + CodeKit.javascriptEncode(string) + "\"" ;
} }
@Override @Override
@ -48,7 +47,7 @@ public class OssSubmitJavaScript extends AbstractJavaScript {
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer); super.writeXML(writer);
if (submitTargetConfig != null) { if (submitTargetConfig != null) {
GeneralXMLTools.writeXMLable(writer, submitTargetConfig, OssSubmitTargetConfig.XML_TAG); XmlKit.writeXMLable(writer, submitTargetConfig, OssSubmitTargetConfig.XML_TAG);
} }
} }
@ -56,7 +55,7 @@ public class OssSubmitJavaScript extends AbstractJavaScript {
public boolean equals(Object o) { public boolean equals(Object o) {
return o instanceof OssSubmitJavaScript return o instanceof OssSubmitJavaScript
&& super.equals(o) && super.equals(o)
&& AssistUtils.equals(((OssSubmitJavaScript) o).submitTargetConfig, submitTargetConfig); && AssistKit.equals(((OssSubmitJavaScript) o).submitTargetConfig, submitTargetConfig);
} }
@Override @Override

8
src/main/java/com/fr/plugin/file/submit/oss/ui/Editors.java

@ -1,16 +1,16 @@
package com.fr.plugin.file.submit.oss.ui; package com.fr.plugin.file.submit.oss.ui;
import com.fr.design.editor.ValueEditorPane; import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory; import com.fanruan.api.design.ui.editor.ValueEditors;
import com.fr.design.editor.editor.Editor; import com.fr.design.editor.editor.Editor;
import com.fr.design.editor.editor.FormulaEditor; import com.fr.design.editor.editor.FormulaEditor;
import com.fr.design.editor.editor.TextEditor; import com.fanruan.api.design.ui.editor.TextEditor;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
public class Editors { public class Editors {
public static ValueEditorPane createValueEditorPane() { public static ValueEditorPane createValueEditorPane() {
return ValueEditorPaneFactory.createValueEditorPane(new Editor[]{ return ValueEditors.createValueEditorPane(new Editor[]{
new TextEditor(), new TextEditor(),
new FormulaEditor(Toolkit.i18nText("Plugin-File_Submit_Oss_Editor_Formula")), new FormulaEditor(Toolkit.i18nText("Plugin-File_Submit_Oss_Editor_Formula")),
}); });

29
src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlink4DownloadPane.java

@ -1,13 +1,12 @@
package com.fr.plugin.file.submit.oss.ui; package com.fr.plugin.file.submit.oss.ui;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.editor.ValueEditorPane; import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fanruan.api.design.ui.component.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fanruan.api.design.ui.component.UILabel;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.DesignKit;
import com.fr.design.layout.TableLayout; import com.fanruan.api.design.ui.layout.TableLayoutKit;
import com.fr.design.layout.TableLayoutHelper; import com.fanruan.api.util.GeneralKit;
import com.fr.general.GeneralUtils;
import com.fr.plugin.file.submit.oss.fun.OssVariableValue; import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
import com.fr.plugin.file.submit.oss.script.OssDownloadHyperlink; import com.fr.plugin.file.submit.oss.script.OssDownloadHyperlink;
import com.fr.plugin.oss.universal.config.OssUniversalConfig; import com.fr.plugin.oss.universal.config.OssUniversalConfig;
@ -30,15 +29,15 @@ public class OssHyperlink4DownloadPane extends BasicBeanPane<OssDownloadHyperlin
this.bucketComboBox = new UIComboBox(OssUniversalConfig.getInstance().getArrayBuckets()); this.bucketComboBox = new UIComboBox(OssUniversalConfig.getInstance().getArrayBuckets());
this.directoryValuePane = Editors.createValueEditorPane(); this.directoryValuePane = Editors.createValueEditorPane();
this.fileNameValuePane = Editors.createValueEditorPane(); this.fileNameValuePane = Editors.createValueEditorPane();
double p = TableLayout.PREFERRED; double p = TableLayoutKit.PREFERRED;
double f = TableLayout.FILL; double f = TableLayoutKit.FILL;
double[] rowSize = {p, p, p}; double[] rowSize = {p, p, p};
double[] columnSize = {p, f}; double[] columnSize = {p, f};
JPanel centerPane = TableLayoutHelper.createTableLayoutPane( JPanel centerPane = TableLayoutKit.createTableLayoutPane(
new Component[][] { new Component[][] {
{new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_Bucket_Name") + ":"), bucketComboBox}, {new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_Bucket_Name") + ":"), bucketComboBox},
{new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_Directory") + ":"), directoryValuePane}, {new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_Directory") + ":"), directoryValuePane},
{new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_File_Name") + ":"), fileNameValuePane} {new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_File_Name") + ":"), fileNameValuePane}
}, rowSize, columnSize); }, rowSize, columnSize);
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
} }
@ -56,7 +55,7 @@ public class OssHyperlink4DownloadPane extends BasicBeanPane<OssDownloadHyperlin
@Override @Override
public OssDownloadHyperlink updateBean() { public OssDownloadHyperlink updateBean() {
OssDownloadHyperlink hyperlink = new OssDownloadHyperlink(); OssDownloadHyperlink hyperlink = new OssDownloadHyperlink();
hyperlink.setBucket(GeneralUtils.objectToString(bucketComboBox.getSelectedItem())); hyperlink.setBucket(GeneralKit.objectToString(bucketComboBox.getSelectedItem()));
hyperlink.setDirectory(new OssVariableValue(directoryValuePane.update())); hyperlink.setDirectory(new OssVariableValue(directoryValuePane.update()));
hyperlink.setFileName(new OssVariableValue(fileNameValuePane.update())); hyperlink.setFileName(new OssVariableValue(fileNameValuePane.update()));
return hyperlink; return hyperlink;
@ -64,6 +63,6 @@ public class OssHyperlink4DownloadPane extends BasicBeanPane<OssDownloadHyperlin
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-File_Download_Hyperlink"); return DesignKit.i18nText("Plugin-File_Download_Hyperlink");
} }
} }

3
src/main/java/com/fr/plugin/file/submit/oss/ui/OssPathConfigPane.java

@ -1,11 +1,12 @@
package com.fr.plugin.file.submit.oss.ui; package com.fr.plugin.file.submit.oss.ui;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fanruan.api.design.ui.component.table.UITableEditorPane;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget; 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.OssSubmitTargetConfig;
import com.fr.plugin.file.submit.oss.job.OssSubmitJob; import com.fr.plugin.file.submit.oss.job.OssSubmitJob;
import javax.swing.*;
import java.awt.*; import java.awt.*;

6
src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitJavaScriptPane.java

@ -1,8 +1,8 @@
package com.fr.plugin.file.submit.oss.ui; package com.fr.plugin.file.submit.oss.ui;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fanruan.api.design.ui.component.table.UITableEditorPane;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.DesignKit;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget; 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.OssSubmitTargetConfig;
import com.fr.plugin.file.submit.oss.script.OssSubmitJavaScript; import com.fr.plugin.file.submit.oss.script.OssSubmitJavaScript;
@ -59,6 +59,6 @@ public class OssSubmitJavaScriptPane extends FurtherBasicBeanPane<OssSubmitJavaS
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return Toolkit.i18nText("Plugin-File_Submit_Oss"); return DesignKit.i18nText("Plugin-File_Submit_Oss");
} }
} }

47
src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitPathTableModel.java

@ -1,16 +1,16 @@
package com.fr.plugin.file.submit.oss.ui; package com.fr.plugin.file.submit.oss.ui;
import com.fr.design.editor.ValueEditorPane; import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fanruan.api.util.StringKit;
import com.fr.design.gui.ilable.UILabel; import com.fanruan.api.design.ui.component.UIComboBox;
import com.fr.design.gui.itableeditorpane.UITableEditAction; import com.fanruan.api.design.ui.component.UILabel;
import com.fr.design.gui.itableeditorpane.UITableModelAdapter; import com.fanruan.api.design.ui.component.table.action.UITableEditAction;
import com.fr.design.i18n.Toolkit; import com.fanruan.api.design.ui.component.table.model.UITableModelAdapter;
import com.fr.general.GeneralUtils; import com.fanruan.api.design.DesignKit;
import com.fanruan.api.util.GeneralKit;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget; import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget;
import com.fr.plugin.file.submit.oss.fun.OssVariableValue; import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
import com.fr.plugin.oss.universal.config.OssUniversalConfig; import com.fr.plugin.oss.universal.config.OssUniversalConfig;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.CellEditorListener; import javax.swing.event.CellEditorListener;
@ -24,10 +24,10 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
public OssSubmitPathTableModel() { public OssSubmitPathTableModel() {
super(new String[]{ super(new String[]{
com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_Bucket_Name"), DesignKit.i18nText("Plugin-File_Submit_Oss_Bucket_Name"),
com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_Directory"), DesignKit.i18nText("Plugin-File_Submit_Oss_Directory"),
com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_File"), DesignKit.i18nText("Plugin-File_Submit_Oss_File"),
com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_File_Name")}); DesignKit.i18nText("Plugin-File_Submit_Oss_File_Name")});
this.setColumnClass(new Class[]{BucketEditor.class, DirectoryEditor.class, FileSelectEditor.class, FileNameEditor.class}); this.setColumnClass(new Class[]{BucketEditor.class, DirectoryEditor.class, FileSelectEditor.class, FileNameEditor.class});
@ -43,7 +43,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
this.setDefaultEditor(FileNameEditor.class, new FileNameEditor()); this.setDefaultEditor(FileNameEditor.class, new FileNameEditor());
this.setDefaultRenderer(FileNameEditor.class, new CurrentValueRenderer()); this.setDefaultRenderer(FileNameEditor.class, new CurrentValueRenderer());
} }
@Override
public Object getValueAt(final int row, final int column) { public Object getValueAt(final int row, final int column) {
final OssSubmitTarget target = this.getList().get(row); final OssSubmitTarget target = this.getList().get(row);
switch (column) { switch (column) {
@ -64,17 +64,16 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
} }
} }
} }
@Override
public boolean isCellEditable(final int row, final int column) { public boolean isCellEditable(final int row, final int column) {
return true; return true;
} }
@Override
public UITableEditAction[] createAction() { public UITableEditAction[] createAction() {
return new UITableEditAction[]{ return new UITableEditAction[]{
new AddPathAction(), new AddPathAction(),
new UITableModelAdapter.DeleteAction(), };
new UITableModelAdapter.MoveUpAction(),
new UITableModelAdapter.MoveDownAction()};
} }
private void addPath() { private void addPath() {
@ -100,7 +99,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
return; return;
} }
OssSubmitTarget submitTarget = getList().get(table.getSelectedRow()); OssSubmitTarget submitTarget = getList().get(table.getSelectedRow());
submitTarget.setBucket(GeneralUtils.objectToString(getCellEditorValue())); submitTarget.setBucket(GeneralKit.objectToString(getCellEditorValue()));
fireTableDataChanged(); fireTableDataChanged();
} }
}); });
@ -142,7 +141,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
@Override @Override
public Component getTableCellEditorComponent(final JTable table, final Object o, final boolean b, final int n, final int n2) { 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); this.textField.populate((o == null) ? StringKit.EMPTY : o);
return this.textField; return this.textField;
} }
@ -176,7 +175,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
@Override @Override
public Component getTableCellEditorComponent(final JTable table, final Object o, final boolean b, final int n, final int n2) { 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); this.textField.populate((o == null) ? StringKit.EMPTY : o);
return this.textField; return this.textField;
} }
@ -210,7 +209,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
@Override @Override
public Component getTableCellEditorComponent(final JTable table, final Object o, final boolean b, final int n, final int n2) { 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); this.textField.populate((o == null) ? StringKit.EMPTY : o);
return this.textField; return this.textField;
} }
@ -222,7 +221,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
private class SimpleRenderer extends DefaultTableCellRenderer { private class SimpleRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
this.setText(GeneralUtils.objectToString(value)); this.setText(GeneralKit.objectToString(value));
return this; return this;
} }
} }
@ -237,7 +236,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
} }
public CurrentValueRenderer(ValueEditorPane valueEditorPane) { public CurrentValueRenderer(ValueEditorPane valueEditorPane) {
disableLabel = new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_Disable")); disableLabel = new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_Disable"));
disableLabel.setForeground(Color.pink); disableLabel.setForeground(Color.pink);
disableLabel.setHorizontalAlignment(SwingConstants.CENTER); disableLabel.setHorizontalAlignment(SwingConstants.CENTER);
@ -247,7 +246,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (table.isCellEditable(row, column)) { if (table.isCellEditable(row, column)) {
if (value == null) { if (value == null) {
editor.populate(StringUtils.EMPTY); editor.populate(StringKit.EMPTY);
} else { } else {
if (value instanceof OssVariableValue) { if (value instanceof OssVariableValue) {
editor.populate(((OssVariableValue) value).getValue()); editor.populate(((OssVariableValue) value).getValue());

4
src/main/java/com/fr/plugin/file/submit/oss/ui/tools/RewriteAction.java

@ -1,8 +1,6 @@
package com.fr.plugin.file.submit.oss.ui.tools; package com.fr.plugin.file.submit.oss.ui.tools;
import com.fr.design.actions.UpdateAction; import com.fanruan.api.design.ui.action.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.mainframe.DesignerContext;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;

Loading…
Cancel
Save