diff --git a/src/main/java/com/fr/plugin/file/download/oss/OssFile2Image.java b/src/main/java/com/fr/plugin/file/download/oss/OssFile2Image.java index a87da91..1dedd86 100644 --- a/src/main/java/com/fr/plugin/file/download/oss/OssFile2Image.java +++ b/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.model.OSSObject; -import com.fr.general.GeneralUtils; -import com.fr.general.IOUtils; -import com.fr.log.FineLoggerFactory; +import com.fanruan.api.util.GeneralKit; +import com.fanruan.api.util.IOKit; +import com.fanruan.api.log.LogKit; import com.fr.plugin.oss.universal.config.OssUniversalConfig; import com.fr.script.AbstractFunction; -import com.fr.stable.ArrayUtils; +import com.fanruan.api.util.ArrayKit; import com.fr.stable.Primitive; import javax.imageio.ImageIO; @@ -21,22 +21,22 @@ public class OssFile2Image extends AbstractFunction { @Override public Object run(Object[] args) { - int len = ArrayUtils.getLength(args); + int len = ArrayKit.getLength(args); if (len < 2) { return Primitive.ERROR_VALUE; } - String key = GeneralUtils.objectToString(args[0]); - String bucket = GeneralUtils.objectToString(args[1]); + String key = GeneralKit.objectToString(args[0]); + String bucket = GeneralKit.objectToString(args[1]); OSSClient ossClient = new OSSClient( OssUniversalConfig.getInstance().getEndPoint(), OssUniversalConfig.getInstance().getAccessKeyId(), OssUniversalConfig.getInstance().getRealAccessKeySecret()); OSSObject object = ossClient.getObject(bucket, key); - byte[] bytes = IOUtils.inputStream2Bytes(object.getObjectContent()); + byte[] bytes = IOKit.inputStream2Bytes(object.getObjectContent()); try { return ImageIO.read(new ByteArrayInputStream(bytes)); } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + LogKit.error(e.getMessage(), e); return Primitive.ERROR_VALUE; } } 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 index eb0aead..f032329 100644 --- a/src/main/java/com/fr/plugin/file/submit/oss/OssHyperlink4Download.java +++ b/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.gui.controlpane.NameObjectCreator; 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.ui.OssHyperlink4DownloadPane; -import com.fr.stable.AssistUtils; +import com.fanruan.api.util.AssistKit; public class OssHyperlink4Download extends AbstractHyperlinkProvider { @@ -14,7 +14,7 @@ public class OssHyperlink4Download extends AbstractHyperlinkProvider { public OssHyperlink4Download() { nameableCreator = new NameObjectCreator( - Toolkit.i18nText("Plugin-File_Download_Oss"), + DesignKit.i18nText("Plugin-File_Download_Oss"), OssDownloadHyperlink.class, OssHyperlink4DownloadPane.class); } @@ -27,7 +27,7 @@ public class OssHyperlink4Download extends AbstractHyperlinkProvider { @Override public boolean equals(Object o) { return o instanceof OssHyperlink4Download - && AssistUtils.equals(((OssHyperlink4Download) o).nameableCreator, nameableCreator); + && AssistKit.equals(((OssHyperlink4Download) o).nameableCreator, nameableCreator); } 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 index 52455e3..153120a 100644 --- a/src/main/java/com/fr/plugin/file/submit/oss/OssHyperlinkJavaScriptHandler.java +++ b/src/main/java/com/fr/plugin/file/submit/oss/OssHyperlinkJavaScriptHandler.java @@ -1,13 +1,15 @@ 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 java.util.Collections; + public class OssHyperlinkJavaScriptHandler extends AbstractJavaScriptFileHandler { @Override public String[] pathsForFiles() { try { - String text = TemplateUtils.render("${fineServletURL}"); + String text = RenderKit.renderParameter4Tpl("${fineServletURL}", Collections.EMPTY_MAP); System.out.println(text); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/fr/plugin/file/submit/oss/OssJavaScriptActionBridge.java b/src/main/java/com/fr/plugin/file/submit/oss/OssJavaScriptActionBridge.java index 6b13bf8..b74ac4d 100644 --- a/src/main/java/com/fr/plugin/file/submit/oss/OssJavaScriptActionBridge.java +++ b/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.fun.impl.AbstractJavaScriptActionProvider; -import com.fr.design.mainframe.DesignerContext; +import com.fanruan.api.design.DesignKit; import com.fr.js.JavaScript; import com.fr.plugin.file.submit.oss.ui.OssSubmitJavaScriptPane; @@ -12,8 +12,8 @@ public class OssJavaScriptActionBridge extends AbstractJavaScriptActionProvider public FurtherBasicBeanPane getJavaScriptActionPane() { return new OssSubmitJavaScriptPane(); } - + @Override public boolean isSupportType() { - return DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook(); + return DesignKit.getDesignerFrame().getSelectedJTemplate().isJWorkBook(); } } 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 index 9813d80..d8f418c 100644 --- a/src/main/java/com/fr/plugin/file/submit/oss/OssSubmitUIBridge.java +++ b/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.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.ui.OssPathConfigPane; @@ -14,7 +14,7 @@ public class OssSubmitUIBridge extends AbstractSubmitProvider { @Override public String dataForSubmit() { - return Toolkit.i18nText("Plugin-File_Submit_Oss"); + return DesignKit.i18nText("Plugin-File_Submit_Oss"); } @Override 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 index e4a4ba3..e867c6d 100644 --- a/src/main/java/com/fr/plugin/file/submit/oss/OssURLAliasProvider.java +++ b/src/main/java/com/fr/plugin/file/submit/oss/OssURLAliasProvider.java @@ -1,15 +1,15 @@ 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.fanruan.api.net.URLAliasKit; 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), - URLAliasFactory.createPluginAlias("/oss/upload", "/oss/upload", true) + URLAliasKit.createPluginAlias("/oss/download", "/oss/download", true), + URLAliasKit.createPluginAlias("/oss/upload", "/oss/upload", 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 index 43499c8..9962ce3 100644 --- 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 @@ -1,53 +1,47 @@ package com.fr.plugin.file.submit.oss.conf; -import com.fr.config.ConfigContext; -import com.fr.config.DefaultConfiguration; +import com.fanruan.api.conf.BaseConfiguration; import com.fr.config.Identifier; import com.fr.config.Status; import com.fr.config.Visualization; 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.fanruan.api.conf.HolderKit; +import com.fanruan.api.conf.impl.ColConf; import com.fr.intelli.record.Focus; import com.fr.record.analyzer.EnableMetrics; -import com.fr.stable.StringUtils; -import com.fr.third.org.apache.commons.collections4.CollectionUtils; +import com.fanruan.api.util.StringKit; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; /** * OSS文件上传下载所使用的OSS配置 */ @Visualization(category = "Plugin-Oss_Settings") @EnableMetrics -public class FileSubmitOssServerConfig extends DefaultConfiguration { +public class FileSubmitOssServerConfig extends BaseConfiguration { private static volatile FileSubmitOssServerConfig instance = null; public static FileSubmitOssServerConfig getInstance() { if (instance == null) { - instance = ConfigContext.getConfigInstance(FileSubmitOssServerConfig.class); + instance = BaseConfiguration.getConfigInstance(FileSubmitOssServerConfig.class); } return instance; } // 地域节点配置信息 @Identifier(value = "endPoint", name = "EndPoint", description = "Plugin-Oss_End_Point", status = Status.SHOW) - private Conf endPoint = Holders.simple(StringUtils.EMPTY); + private Conf endPoint = HolderKit.simple(StringKit.EMPTY); @Identifier(value = "accessKeyId", name = "AccessKeyId", description = "Plugin-Oss_AccessKeyId", status = Status.SHOW) - private Conf accessKeyId = Holders.simple(StringUtils.EMPTY); + private Conf accessKeyId = HolderKit.simple(StringKit.EMPTY); @Identifier(value = "accessKeySecret", name = "AccessKeySecret", description = "Plugin-Oss_AccessKeySecret", status = Status.SHOW) - private Conf accessKeySecret = Holders.simple(StringUtils.EMPTY); + private Conf accessKeySecret = HolderKit.simple(StringKit.EMPTY); @Identifier(value = "buckets", name = "Buckets", description = "Plugin-Oss_Buckets", status = Status.SHOW) - private ColConf> buckets = Holders.collection(new ArrayList(), String.class); + private ColConf> buckets = HolderKit.collection(new ArrayList(), String.class); public String getEndPoint() { return endPoint.get(); diff --git a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssDownloadHttpHandler.java b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssDownloadHttpHandler.java index d5cf285..e5b3e73 100644 --- a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssDownloadHttpHandler.java +++ b/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.OSSClient; 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.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.web.utils.WebUtils; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -18,6 +17,7 @@ import java.util.Calendar; import java.util.Date; public class OssDownloadHttpHandler extends BaseHttpHandler { + @Override public RequestMethod getMethod() { return RequestMethod.POST; @@ -35,10 +35,10 @@ public class OssDownloadHttpHandler extends BaseHttpHandler { @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); + String bucket = NetworkKit.getHTTPRequestParameter(req, "bucket"); + String directory = NetworkKit.getHTTPRequestParameter(req, "directory"); + String fileName = NetworkKit.getHTTPRequestParameter(req, "fileName"); + PrintWriter writer = NetworkKit.createPrintWriter(res); writer.write(createDownloadUrl(bucket, directory, fileName)); writer.flush(); writer.close(); @@ -54,7 +54,7 @@ public class OssDownloadHttpHandler extends BaseHttpHandler { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MINUTE, 1); Date expiration = calendar.getTime(); - String key = StableUtils.pathJoin(directory, fileName); + String key = GeneralKit.pathJoin(directory, fileName); GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, key, HttpMethod.GET); // 设置过期时间。 request.setExpiration(expiration); 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 index 166cd50..0158902 100644 --- 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 @@ -1,8 +1,8 @@ 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.fanruan.api.xml.XmlKit; +import com.fanruan.api.util.AssistKit; +import com.fanruan.api.util.StringKit; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLableReader; @@ -64,39 +64,40 @@ public class OssSubmitTarget implements XMLable { if ("Bucket".equals(tagName)) { this.bucket = reader.getElementValue(); } else if ("Directory".equals(tagName)) { - this.directory = (OssVariableValue) GeneralXMLTools.readXMLable(reader); + this.directory = (OssVariableValue) XmlKit.readXMLable(reader); } else if ("Name".equals(tagName)) { - this.name = (OssVariableValue) GeneralXMLTools.readXMLable(reader); + this.name = (OssVariableValue) XmlKit.readXMLable(reader); } else if ("File".equals(tagName)) { - this.file = (OssVariableValue) GeneralXMLTools.readXMLable(reader); + this.file = (OssVariableValue) XmlKit.readXMLable(reader); } } } public void writeXML(final XMLPrintWriter writer) { - if (StringUtils.isNotEmpty(bucket)) { + if (StringKit.isNotEmpty(bucket)) { writer.startTAG("Bucket").textNode(bucket).end(); } if (directory != null) { - GeneralXMLTools.writeXMLable(writer, directory, "Directory"); + XmlKit.writeXMLable(writer, directory, "Directory"); } if (name != null) { - GeneralXMLTools.writeXMLable(writer, name, "Name"); + XmlKit.writeXMLable(writer, name, "Name"); } if (file != null) { - GeneralXMLTools.writeXMLable(writer, file, "File"); + XmlKit.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); + && AssistKit.equals(((OssSubmitTarget) o).bucket, bucket) + && AssistKit.equals(((OssSubmitTarget) o).directory, directory) + && AssistKit.equals(((OssSubmitTarget) o).name, name) + && AssistKit.equals(((OssSubmitTarget) o).file, file); } + @Override public Object clone() throws CloneNotSupportedException { OssSubmitTarget cloned = (OssSubmitTarget) super.clone(); cloned.bucket = bucket; 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 index 2fd4cec..5991238 100644 --- 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 @@ -1,6 +1,6 @@ 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.XMLReadable; import com.fr.stable.xml.XMLable; @@ -40,7 +40,7 @@ public class OssSubmitTargetConfig implements XMLable { if (xmLableReader.isChildNode()) { String tagName = xmLableReader.getTagName(); if (OssSubmitTarget.XML_TAG.equals(tagName)) { - OssSubmitTarget target = (OssSubmitTarget)GeneralXMLTools.readXMLable(xmLableReader); + OssSubmitTarget target = (OssSubmitTarget)XmlKit.readXMLable(xmLableReader); targets.add(target); } } @@ -52,7 +52,7 @@ public class OssSubmitTargetConfig implements XMLable { @Override public void writeXML(XMLPrintWriter writer) { for (OssSubmitTarget target : targets) { - GeneralXMLTools.writeXMLable(writer, target, OssSubmitTarget.XML_TAG); + XmlKit.writeXMLable(writer, target, OssSubmitTarget.XML_TAG); } } diff --git a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssUpload.java b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssUpload.java index 8f48106..b702b05 100644 --- a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssUpload.java +++ b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssUpload.java @@ -3,36 +3,38 @@ package com.fr.plugin.file.submit.oss.fun; import com.aliyun.oss.OSSClient; import com.fr.cache.Attachment; import com.fr.general.FArray; -import com.fr.general.GeneralUtils; -import com.fr.locale.InterProviderFactory; +import com.fanruan.api.util.GeneralKit; +import com.fanruan.api.i18n.I18nKit; import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; -import com.fr.stable.StringUtils; +import com.fanruan.api.util.StringKit; import com.fr.stable.xml.FRFile; import java.io.ByteArrayInputStream; public class OssUpload { - public static void upload(Calculator calculator, OSSClient ossClient, OssSubmitTargetConfig submitTargetConfig) throws Exception { + public static void upload(Calculator calculator, OSSClient ossClient, OssSubmitTargetConfig submitTargetConfig) + throws Exception { OssSubmitTarget[] submitTargets = submitTargetConfig.getSubmitTargets(); for (OssSubmitTarget target : submitTargets) { OssVariableValue fileObject = target.getFile(); - String filePath = GeneralUtils.objectToString(fileObject); + String filePath = GeneralKit.objectToString(fileObject); Object file = calculator.evalValue(filePath); - uploadFile(ossClient, target.getBucket(), file, target.getDirectory() == null ? null : target.getDirectory().getResult(calculator), target.getName() == null ? null : target.getName().getResult(calculator)); } } - private static void uploadFile( OSSClient ossClient, String bucket, Object file, String directory, String newFileName) { + private static void uploadFile(OSSClient ossClient, String bucket, Object file, String directory, + String newFileName) { if (file instanceof FRFile) { - uploadSingleFile(ossClient, bucket, directory, combineName(((FRFile) file).getFileName(), newFileName), ((FRFile) file).getBytes()); + uploadSingleFile(ossClient, bucket, directory, combineName(((FRFile) file).getFileName(), newFileName), + ((FRFile) file).getBytes()); } else if (file instanceof FArray && ((FArray) file).length() != 0) { - FArray array = (FArray)file; + FArray array = (FArray) file; for (int i = 0; i < array.length(); i++) { Object element = array.elementAt(i); if (!(element instanceof Attachment)) { @@ -40,38 +42,38 @@ public class OssUpload { uploadFile(ossClient, bucket, element, directory, newFileName); } } else { - uploadSingleFile(ossClient, bucket, directory, combineName(((Attachment) element).getFilename(), newFileName), ((Attachment) element).getBytes()); + uploadSingleFile(ossClient, bucket, directory, + combineName(((Attachment) element).getFilename(), newFileName), + ((Attachment) element).getBytes()); } } } } - 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)) { - 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)); } - /* - * 这里的逻辑是: - * 1、如果没有设置文件名,就用上传的文件的名字; - * 2、如果设置了文件名,且带有文件后缀,就用设置的文件名; - * 3、其他情况都用原文件名。 + /** + * 这里的逻辑是: 1、如果没有设置文件名,就用上传的文件的名字; 2、如果设置了文件名,且带有文件后缀,就用设置的文件名; 3、其他情况都用原文件名。 */ private static String combineName(String fileName, String myFileName) { String realFileName; - if (StringUtils.isBlank(fileName)) { + if (StringKit.isBlank(fileName)) { fileName = "unnamed.png"; } if (StringUtils.isNotEmpty(myFileName)) { realFileName = myFileName; -// int index = myFileName.lastIndexOf("."); -// if (index == -1) { -// realFileName = fileName; -// } else { -// realFileName = myFileName; -// } + // int index = myFileName.lastIndexOf("."); + // if (index == -1) { + // realFileName = fileName; + // } else { + // realFileName = myFileName; + // } } else { realFileName = fileName; } diff --git a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssUploadHttpHandler.java b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssUploadHttpHandler.java index e00cc3f..71832f9 100644 --- a/src/main/java/com/fr/plugin/file/submit/oss/fun/OssUploadHttpHandler.java +++ b/src/main/java/com/fr/plugin/file/submit/oss/fun/OssUploadHttpHandler.java @@ -1,15 +1,15 @@ package com.fr.plugin.file.submit.oss.fun; import com.aliyun.oss.OSSClient; -import com.fr.base.ParameterMapNameSpace; -import com.fr.data.NetworkHelper; +import com.fr.stable.script.NameSpace; +import com.fanruan.api.cal.ParameterKit; +import com.fanruan.api.net.NetworkKit; import com.fr.decision.fun.impl.BaseHttpHandler; -import com.fr.general.xml.GeneralXMLTools; -import com.fr.json.JSON; +import com.fanruan.api.xml.XmlKit; import com.fr.json.JSONArray; -import com.fr.json.JSONFactory; 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.oss.universal.config.OssUniversalConfig; 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.SessionPoolManager; 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.HttpServletResponse; @@ -42,23 +42,23 @@ public class OssUploadHttpHandler extends BaseHttpHandler { @Override 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) { - String sessionID = NetworkHelper.getHTTPRequestParameter(req, "sessionID"); + String sessionID = NetworkKit.getHTTPRequestParameter(req, "sessionID"); final ReportSessionIDInfor reportSessionIDInfor = SessionPoolManager.getSessionIDInfor(sessionID, ReportSessionIDInfor.class); if (reportSessionIDInfor == null) { return; } - final OssSubmitJavaScript javaScript = (OssSubmitJavaScript) GeneralXMLTools.readStringAsXMLable(httpRequestEncodeParameter); + final OssSubmitJavaScript javaScript = (OssSubmitJavaScript) XmlKit.readStringAsXMLable(httpRequestEncodeParameter); if (javaScript == null) { return; } final Calculator calculator = Calculator.createCalculator(); - final ParameterMapNameSpace create = ParameterMapNameSpace.create(WebUtils.parameters4SessionIDInfor(req)); + final NameSpace create = ParameterKit.createParameterMapNameSpace(SessionKit.parameters4SessionIDInfor(req)); calculator.pushNameSpace(create); this.initCalAttrAndNS(calculator, reportSessionIDInfor, req); boolean b = true; - final JSONObject jsonObject = JSONObject.create(); + final JSONObject jsonObject = JSONKit.create(); OSSClient ossClient = new OSSClient( OssUniversalConfig.getInstance().getEndPoint(), OssUniversalConfig.getInstance().getAccessKeyId(), @@ -66,16 +66,16 @@ public class OssUploadHttpHandler extends BaseHttpHandler { try { this.process(ossClient, javaScript, calculator); } catch (Exception ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + LogKit.error(ex.getMessage(), ex); b = false; jsonObject.put("errorMsg", ex.getMessage()); } finally { ossClient.shutdown(); } calculator.removeNameSpace(create); - final PrintWriter printWriter = WebUtils.createPrintWriter(res); - final JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY); - final JSONObject jsonObject2 = JSONFactory.createJSON(JSON.OBJECT); + final PrintWriter printWriter = NetworkKit.createPrintWriter(res); + final JSONArray jsonArray = JSONKit.createJSONArray(); + final JSONObject jsonObject2 = JSONKit.create(); jsonObject.put("success", b); jsonObject2.put("oss_submit_info", jsonObject); jsonArray.put(jsonObject2); @@ -90,10 +90,10 @@ public class OssUploadHttpHandler extends BaseHttpHandler { } 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); - calculator.pushNameSpace(ParameterMapNameSpace.create(reportSessionIDInfor.getParameterMap4Execute())); - final ColumnRow value = ColumnRow.valueOf(WebUtils.getHTTPRequestParameter(httpServletRequest, "location")); + calculator.pushNameSpace(ParameterKit.createParameterMapNameSpace(reportSessionIDInfor.getParameterMap4Execute())); + final ColumnRow value = ColumnRow.valueOf(NetworkKit.getHTTPRequestParameter(httpServletRequest, "location")); if (value != ColumnRow.ERROR) { calculator.setAttribute(ColumnRow.CURRENT_CR_KEY, value); } 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 index 6679f05..f496867 100644 --- 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 @@ -1,10 +1,10 @@ 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.stable.CommonUtils; -import com.fr.stable.StringUtils; +import com.fanruan.api.util.GeneralKit; +import com.fanruan.api.log.LogKit; +import com.fanruan.api.cal.FormulaKit; +import com.fanruan.api.util.StringKit; import com.fr.stable.UtilEvalError; import com.fr.stable.script.CalculatorProvider; import com.fr.stable.xml.XMLPrintWriter; @@ -28,8 +28,8 @@ public class OssVariableValue implements XMLable { type = Type.FORMULA; this.value = value; } else { - String content = GeneralUtils.objectToString(value); - if (CommonUtils.canBeFormula(content)) { + String content = GeneralKit.objectToString(value); + if (FormulaKit.canBeFormula(content)) { type = Type.FORMULA; this.value = BaseFormula.createFormulaBuilder().build(content); } else { @@ -51,20 +51,20 @@ public class OssVariableValue implements XMLable { if (type == Type.FORMULA) { return ((BaseFormula)value).getPureContent(); } else { - return GeneralUtils.objectToString(value); + return GeneralKit.objectToString(value); } } - public String getResult(CalculatorProvider cal) { + 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); + LogKit.error(u.getMessage(), u); } } - return GeneralUtils.objectToString(result); + return GeneralKit.objectToString(result); } @Override @@ -74,9 +74,9 @@ public class OssVariableValue implements XMLable { if ("Attr".equals(tagName)) { type = Type.parse(reader.getAttrAsInt("type", 0)); if (type == Type.FORMULA) { - value = BaseFormula.createFormulaBuilder().build(reader.getAttrAsString("value", StringUtils.EMPTY)); + value = BaseFormula.createFormulaBuilder().build(reader.getAttrAsString("value", StringKit.EMPTY)); } 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) { writer.attr("type", Type.FORMULA.getIndex()).attr("value", ((BaseFormula) value).getPureContent()); } 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(); } @@ -99,7 +99,7 @@ public class OssVariableValue implements XMLable { } public String toString() { - return value == null ? StringUtils.EMPTY : GeneralUtils.objectToString(value); + return value == null ? StringKit.EMPTY : GeneralKit.objectToString(value); } 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 index 399fc8e..7966820 100644 --- 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 @@ -2,7 +2,7 @@ package com.fr.plugin.file.submit.oss.job; import com.aliyun.oss.OSSClient; 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.Original; import com.fr.plugin.file.submit.oss.fun.OssConstants; @@ -114,7 +114,7 @@ public class OssSubmitJob extends AbstractSubmitTask { @Override public void writeXML(XMLPrintWriter writer) { if (submitTargetConfig != null) { - GeneralXMLTools.writeXMLable(writer, submitTargetConfig, OssSubmitTargetConfig.XML_TAG); + XmlKit.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 index 3712c78..ffd4651 100644 --- 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 @@ -1,35 +1,29 @@ package com.fr.plugin.file.submit.oss.script; import com.fr.base.BaseFormula; -import com.fr.base.Parameter; -import com.fr.base.ParameterMapNameSpace; +import com.fr.stable.ParameterProvider; +import com.fanruan.api.cal.ParameterKit; import com.fr.base.ResultFormula; -import com.fr.general.GeneralUtils; -import com.fr.general.xml.GeneralXMLTools; +import com.fanruan.api.util.GeneralKit; +import com.fanruan.api.xml.XmlKit; import com.fr.js.Hyperlink; -import com.fr.json.JSONException; +import com.fanruan.api.err.JSONException; 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.script.Calculator; -import com.fr.stable.ArrayUtils; -import com.fr.stable.AssistUtils; -import com.fr.stable.ColumnRow; -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.fanruan.api.util.ArrayKit; +import com.fanruan.api.util.AssistKit; +import com.fanruan.api.util.StringKit; import com.fr.stable.web.Repository; import com.fr.stable.xml.XMLPrintWriter; 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.HashSet; import java.util.Map; -import java.util.Set; public class OssDownloadHyperlink extends Hyperlink { @@ -68,8 +62,8 @@ public class OssDownloadHyperlink extends Hyperlink { return; } ParameterProvider[] providers = getParameters(); - if (ArrayUtils.isEmpty(providers)) { - providers = ArrayUtils.add(providers, new Parameter(parameterName, variableValue.getValue())); + if (ArrayKit.isEmpty(providers)) { + providers = ArrayKit.add(providers, ParameterKit.newParameter(parameterName, variableValue.getValue())); } else { Map map = new HashMap(); for (ParameterProvider provider : providers) { @@ -78,7 +72,7 @@ public class OssDownloadHyperlink extends Hyperlink { if (map.containsKey(parameterName)) { map.get(parameterName).setValue(variableValue.getValue()); } else { - providers = ArrayUtils.add(providers, new Parameter(parameterName, variableValue.getValue())); + providers = ArrayKit.add(providers, ParameterKit.newParameter(parameterName, variableValue.getValue())); } } setParameters(providers); @@ -86,8 +80,8 @@ public class OssDownloadHyperlink extends Hyperlink { @Override - protected String actionJS(Repository repository) { - JSONObject data = JSONObject.create(); + protected String actionJS(Repository repository) throws JSONException{ + JSONObject data = JSONKit.create(); try { data.put("bucket", bucket); if (directory != null) { @@ -97,16 +91,17 @@ public class OssDownloadHyperlink extends Hyperlink { data.put("fileName", getResultValue(repository, "fileName", fileName)); } } catch (JSONException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + LogKit.error(e.getMessage(), e); } 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; ParameterProvider[] providers = getParameters(); for (ParameterProvider provider : providers) { - if (AssistUtils.equals(parameterName, provider.getName())) { + if (AssistKit.equals(parameterName, provider.getName())) { Object value = provider.getValue(); if (value instanceof BaseFormula) { result = ((BaseFormula) value).getResult(); @@ -123,22 +118,22 @@ public class OssDownloadHyperlink extends Hyperlink { Calculator calculator = newCalculator(repository); result = variableValue.getResult(calculator); } - return GeneralUtils.objectToString(result); + return GeneralKit.objectToString(result); } private Calculator newCalculator(Repository repository) { Calculator calculator = Calculator.createCalculator(); if (repository != null) { - calculator.pushNameSpace(ParameterMapNameSpace.create(repository.getReportParameterMap())); - calculator.pushNameSpace(SessionIDInfo.asNameSpace(repository.getSessionID())); + calculator.pushNameSpace(ParameterKit.createParameterMapNameSpace(repository.getReportParameterMap())); + calculator.pushNameSpace(SessionKit.asNameSpace(repository.getSessionID())); } if (!paraMap.isEmpty()) { - calculator.pushNameSpace(ParameterMapNameSpace.create(this.paraMap)); + calculator.pushNameSpace(ParameterKit.createParameterMapNameSpace(new HashMap(this.paraMap))); } return calculator; } - + @Override public void readXML(final XMLableReader reader) { super.readXML(reader); if (reader.isChildNode()) { @@ -146,24 +141,24 @@ public class OssDownloadHyperlink extends Hyperlink { if ("Bucket".equals(tagName)) { this.bucket = reader.getElementValue(); } else if ("Directory".equals(tagName)) { - this.setDirectory((OssVariableValue)GeneralXMLTools.readXMLable(reader)); + this.setDirectory((OssVariableValue)XmlKit.readXMLable(reader)); } else if ("FileName".equals(tagName)) { - this.setFileName((OssVariableValue) GeneralXMLTools.readXMLable(reader)); + this.setFileName((OssVariableValue) XmlKit.readXMLable(reader)); } } } - + @Override public void writeXML(final XMLPrintWriter writer) { writer.startTAG("JavaScript").attr("class", this.getClass().getName()); super.writeXML(writer); - if (StringUtils.isNotEmpty(bucket)) { + if (StringKit.isNotEmpty(bucket)) { writer.startTAG("Bucket").textNode(bucket).end(); } if (directory != null) { - GeneralXMLTools.writeXMLable(writer, directory, "Directory"); + XmlKit.writeXMLable(writer, directory, "Directory"); } if (fileName != null) { - GeneralXMLTools.writeXMLable(writer, fileName, "FileName"); + XmlKit.writeXMLable(writer, fileName, "FileName"); } writer.end(); } @@ -171,9 +166,9 @@ public class OssDownloadHyperlink extends Hyperlink { @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); + && AssistKit.equals(((OssDownloadHyperlink) o).bucket, bucket) + && AssistKit.equals(((OssDownloadHyperlink) o).directory, directory) + && AssistKit.equals(((OssDownloadHyperlink) o).fileName, fileName); } @Override 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 index 13bbaeb..b44e4e6 100644 --- 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 @@ -1,11 +1,10 @@ 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.json.JSONObject; import com.fr.plugin.file.submit.oss.fun.OssSubmitTargetConfig; -import com.fr.stable.AssistUtils; -import com.fr.stable.CommonCodeUtils; +import com.fanruan.api.util.AssistKit; +import com.fanruan.api.util.CodeKit; import com.fr.stable.web.Repository; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; @@ -24,11 +23,11 @@ public class OssSubmitJavaScript extends AbstractJavaScript { @Override 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) { - return "\"" + CommonCodeUtils.javascriptEncode(string) + "\"" ; + return "\"" + CodeKit.javascriptEncode(string) + "\"" ; } @Override @@ -48,7 +47,7 @@ public class OssSubmitJavaScript extends AbstractJavaScript { public void writeXML(XMLPrintWriter writer) { super.writeXML(writer); 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) { return o instanceof OssSubmitJavaScript && super.equals(o) - && AssistUtils.equals(((OssSubmitJavaScript) o).submitTargetConfig, submitTargetConfig); + && AssistKit.equals(((OssSubmitJavaScript) o).submitTargetConfig, submitTargetConfig); } @Override 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 index 59378bc..8ad6594 100644 --- 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 @@ -1,16 +1,16 @@ package com.fr.plugin.file.submit.oss.ui; -import com.fr.design.editor.ValueEditorPane; -import com.fr.design.editor.ValueEditorPaneFactory; +import com.fanruan.api.design.ui.editor.ValueEditorPane; +import com.fanruan.api.design.ui.editor.ValueEditors; import com.fr.design.editor.editor.Editor; 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; public class Editors { public static ValueEditorPane createValueEditorPane() { - return ValueEditorPaneFactory.createValueEditorPane(new Editor[]{ + return ValueEditors.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/OssHyperlink4DownloadPane.java b/src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlink4DownloadPane.java index 9215fc3..9fdfcc3 100644 --- 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 @@ -1,13 +1,12 @@ 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.fanruan.api.design.ui.editor.ValueEditorPane; +import com.fanruan.api.design.ui.component.UIComboBox; +import com.fanruan.api.design.ui.component.UILabel; +import com.fanruan.api.design.DesignKit; +import com.fanruan.api.design.ui.layout.TableLayoutKit; +import com.fanruan.api.util.GeneralKit; import com.fr.plugin.file.submit.oss.fun.OssVariableValue; import com.fr.plugin.file.submit.oss.script.OssDownloadHyperlink; import com.fr.plugin.oss.universal.config.OssUniversalConfig; @@ -30,15 +29,15 @@ public class OssHyperlink4DownloadPane extends BasicBeanPane