Compare commits

...

18 Commits

Author SHA1 Message Date
Dylan.Liu 06689bd208 Pull request #12: DEC-16834 feat: 集群组件出错优化 3 years ago
Dylan.Liu 0402aa3a9e Merge branch 'release/10.0' of https://code.fineres.com/scm/~dylan.liu/plugin-repository-s3 into release/10.0 3 years ago
Dylan.Liu ac8ee784fe DEC-16834 feat: 集群组件出错优化 3 years ago
Feng 0506f22a5d Pull request #11: DEC-16997 fix: 【S3插件】定时调度的结果文件预览失败 3 years ago
Feng b3beded0f2 Merge remote-tracking branch 'origin/release/10.0' into release/10.0 3 years ago
Feng f16a557bf0 DEC-16997 fix: 【S3插件】定时调度的结果文件预览失败 3 years ago
Feng 2c5773904b DEC-16997 fix: 【S3插件】定时调度的结果文件预览失败 3 years ago
Feng 19a499536b Pull request #10: DEC-17006 fix: 【S3插件】配置输入不存在的路径也可以连接成功 3 years ago
Feng 39e97de37f DEC-17006 fix: 【S3插件】配置输入不存在的路径也可以连接成功 3 years ago
Feng d797433f1a Pull request #9: DEC-16411 feat: S3插件变为官方插件 国际化 3 years ago
Feng 1c342df1e0 DEC-16411 feat: S3插件变为官方插件 国际化 3 years ago
Feng 5724103649 DEC-16411 feat: S3插件变为官方插件 3 years ago
Feng dee24ab76e Pull request #8: DEC-16411 feat: S3插件变为官方插件 3 years ago
Feng 4bf15d218c DEC-16411 feat: S3插件变为官方插件 3 years ago
Feng b0a6e35c7c DEC-16411 feat: S3插件变为官方插件 3 years ago
Feng bba598df12 Pull request #6: DEC-16411 feat: S3插件作为官方插件维护 3 years ago
Feng ad2da13ab2 DEC-16411 S3仓库打包脚本 3 years ago
Feng ab60e1c61f DEC-16411 S3插件维护 3 years ago
  1. 123
      build.xml
  2. 4
      plugin.xml
  3. 4
      src/main/java/com/fanruan/fs/s3/repository/S3FileServerResource.java
  4. 25
      src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java
  5. 2
      src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java
  6. 154
      src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java
  7. 3
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3.properties
  8. 3
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_en_US.properties
  9. 3
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_zh_CN.properties
  10. 99
      src/main/resources/com/fanruan/fs/s3/repository/web/js/bundle.js

123
build.xml

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="jar" name="plugin-repository-s3">
<!-- JDK路径,根据自己机器上实际位置修改-->
<property name="jdk.home" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home"/>
<property name="libs" value="${basedir}/lib"/>
<property name="publicLibs" value=""/>
<property name="destLoc" value="."/>
<property name="classes" value="classes"/>
<xmlproperty file="${basedir}/plugin.xml"/>
<property name="current-version" value="${plugin.version}"/>
<!-- 插件版本-->
<property name="plugin-version" value="${current-version}"/>
<!-- 插件名字-->
<property name="plugin-name" value="s3-repository"/>
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/>
<target name="prepare">
<delete dir="${classes}"/>
<delete dir="fr-plugin-${plugin-name}-${plugin-version}"/>
<xmlproperty file="${basedir}/plugin.xml"/>
<delete dir="${destLoc}/${plugin.name}"/>
</target>
<path id="compile.classpath">
<fileset dir="${libs}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${publicLibs}">
<include name="**/*.jar"/>
</fileset>
</path>
<patternset id="resources4Jar">
<exclude name="**/.settings/**"/>
<exclude name=".classpath"/>
<exclude name=".project"/>
<exclude name="**/*.java"/>
<exclude name="**/*.db"/>
<exclude name="**/*.g"/>
<exclude name="**/package.html"/>
</patternset>
<target name="copy_resources">
<echo message="从${resources_from}拷贝图片,JS,CSS等资源文件"/>
<delete dir="tmp"/>
<copy todir="tmp">
<fileset dir="${resources_from}/src/main/resources">
<patternset refid="resources4Jar"/>
</fileset>
</copy>
<copy todir="${classes}">
<fileset dir="tmp"/>
</copy>
<delete dir="tmp"/>
</target>
<target name="compile_javas">
<echo message="编译${compile_files}下的Java文件"/>
<javac destdir="${classes}" debug="false" optimize="on" source="${source_jdk_version}"
target="${target_jdk_version}"
fork="true" memoryMaximumSize="512m" listfiles="false" srcdir="${basedir}"
executable="${compile_jdk_version}/bin/javac">
<src path="${basedir}/src/main/java"/>
<exclude name="**/.svn/**"/>
<compilerarg line="-encoding UTF8 "/>
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="jar_classes">
<echo message="打Jar包:${jar_name}"/>
<delete file="${basedir}/${jar_name}"/>
<jar jarfile="${basedir}/${jar_name}">
<fileset dir="${classes}">
</fileset>
</jar>
</target>
<target name="super_jar" depends="prepare">
<antcall target="copy_resources">
<param name="resources_from" value="${basedir}"/>
</antcall>
<antcall target="compile_javas">
<param name="source_jdk_version" value="1.8"/>
<param name="target_jdk_version" value="1.8"/>
<param name="compile_jdk_version" value="${jdk.home}"/>
<param name="compile_files" value="${basedir}/src"/>
</antcall>
<echo message="compile plugin success!"/>
<antcall target="jar_classes">
<param name="jar_name" value="${plugin-jar}"/>
</antcall>
<delete dir="${classes}"/>
</target>
<target name="jar" depends="super_jar">
<antcall target="zip"/>
</target>
<target name="zip">
<property name="plugin-folder" value="fr-plugin-${plugin-name}-${plugin-version}"/>
<echo message="----------zip files----------"/>
<mkdir dir="${plugin-folder}"/>
<copy todir="${plugin-folder}">
<fileset dir=".">
<include name="${plugin-jar}"/>
<include name="plugin.xml"/>
</fileset>
<fileset dir="${libs}">
<include name="*.jar"/>
<include name="*.dll"/>
</fileset>
</copy>
<zip destfile="${basedir}/${plugin-folder}.zip" basedir=".">
<include name="${plugin-folder}/*.jar"/>
<include name="${plugin-folder}/*.dll"/>
<include name="${plugin-folder}/plugin.xml"/>
</zip>
<xmlproperty file="${basedir}/plugin.xml"/>
<move file="${plugin-folder}.zip" todir="${destLoc}/${plugin.name}"/>
<delete dir="${plugin-folder}"/>
</target>
</project>

4
plugin.xml

@ -5,12 +5,14 @@
<main-package>com.fanruan.fs</main-package>
<active>yes</active>
<hidden>no</hidden>
<version>1.2.2</version>
<version>1.2.4</version>
<env-version>10.0</env-version>
<jartime>2020-01-27</jartime>
<vendor>richie</vendor>
<description><![CDATA[使用支持S3协议的云存储文件系统作为文件服务器。]]></description>
<change-notes><![CDATA[
[2021-01-24]修复定时调度结果文件预览失败。<br/>
[2021-01-20]正式作为官方插件维护。<br/>
[2020-12-16]修复远程设计新增、修改模板问题。<br/>
[2020-10-29]修复连接不释放问题。<br/>
[2020-08-17]修复key不存在时报错的问题。<br/>

4
src/main/java/com/fanruan/fs/s3/repository/S3FileServerResource.java

@ -1,7 +1,7 @@
package com.fanruan.fs.s3.repository;
import com.fr.decision.fun.impl.AbstractWebResourceProvider;
import com.fr.decision.web.MainComponent;
import com.fr.decision.web.CommonComponent;
import com.fanruan.fs.s3.repository.web.S3FileServerComponent;
import com.fr.web.struct.Atom;
@ -14,7 +14,7 @@ public class S3FileServerResource extends AbstractWebResourceProvider {
@Override
public Atom attach() {
return MainComponent.KEY;
return CommonComponent.KEY;
}
@Override

25
src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java

@ -1,8 +1,8 @@
package com.fanruan.fs.s3.repository.core;
import com.fanruan.api.conf.HolderKit;
import com.fr.config.Identifier;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.io.config.CommonRepoConfig;
import com.fr.io.context.ResourceModuleContext;
import com.fr.io.context.info.GetConfig;
@ -21,19 +21,16 @@ public class S3Config extends CommonRepoConfig {
}
@Identifier("endPoint")
private Conf<String> endPoint = Holders.simple(StringUtils.EMPTY);
private Conf<String> endPoint = HolderKit.simple(StringUtils.EMPTY);
@Identifier("region")
private Conf<String> region = Holders.simple(StringUtils.EMPTY);
private Conf<String> region = HolderKit.simple(StringUtils.EMPTY);
@Identifier("accessKeyId")
private Conf<String> accessKeyId = Holders.simple(StringUtils.EMPTY);
@Identifier("accessKeySecret")
private Conf<String> accessKeySecret = Holders.simple(StringUtils.EMPTY);
private Conf<String> accessKeyId = HolderKit.simple(StringUtils.EMPTY);
@Identifier("bucket")
private Conf<String> bucket = Holders.simple(StringUtils.EMPTY);
private Conf<String> bucket = HolderKit.simple(StringUtils.EMPTY);
@GetConfig("endPoint")
public String getEndPoint() {
@ -65,16 +62,6 @@ public class S3Config extends CommonRepoConfig {
this.accessKeyId.set(accessKeyId);
}
@GetConfig("accessKeySecret")
public String getAccessKeySecret() {
return accessKeySecret.get();
}
@SetConfig("accessKeySecret")
public void setAccessKeySecret(String accessKeySecret) {
this.accessKeySecret.set(accessKeySecret);
}
@GetConfig("bucket")
public String getBucket() {
return bucket.get();
@ -93,7 +80,6 @@ public class S3Config extends CommonRepoConfig {
this.setEndPoint(newConfig.getEndPoint());
this.setRegion(newConfig.getRegion());
this.setAccessKeyId(newConfig.getAccessKeyId());
this.setAccessKeySecret(newConfig.getAccessKeySecret());
this.setBucket(newConfig.getBucket());
}
}
@ -104,7 +90,6 @@ public class S3Config extends CommonRepoConfig {
cloned.endPoint = (Conf<String>) endPoint.clone();
cloned.region = (Conf<String>) region.clone();
cloned.accessKeyId = (Conf<String>) accessKeyId.clone();
cloned.accessKeySecret = (Conf<String>) accessKeySecret.clone();
cloned.bucket = (Conf<String>) bucket.clone();
return cloned;
}

2
src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java

@ -36,7 +36,7 @@ public class S3RepositoryFactory extends ConfigRepositoryFactory<S3Config> {
@Override
public boolean verifyConfig(S3Config config) {
try {
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getAccessKeySecret());
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getPassword());
AmazonS3 s3 = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion()))
.withCredentials(new AWSStaticCredentialsProvider(credentials)).build();

154
src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java

@ -19,6 +19,7 @@ import com.fanruan.api.util.StringKit;
import com.fr.io.repository.FineFileEntry;
import com.fr.io.repository.base.BaseResourceRepository;
import com.fr.stable.Filter;
import com.fr.stable.StringUtils;
import com.fr.workspace.resource.ResourceIOException;
import java.io.ByteArrayInputStream;
@ -43,7 +44,7 @@ public class S3ResourceRepository extends BaseResourceRepository {
public S3ResourceRepository(String repoName, String workRoot, S3Config config) {
super(repoName, workRoot);
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getAccessKeySecret());
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getPassword());
this.s3 = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion()))
.withCredentials(new AWSStaticCredentialsProvider(credentials)).build();
@ -59,11 +60,8 @@ public class S3ResourceRepository extends BaseResourceRepository {
public FineFileEntry getEntry(String path) {
GetObjectRequest request = new GetObjectRequest(bucket, path);
try {
S3Object s3Object = s3.getObject(request);
try {
try (S3Object s3Object = s3.getObject(request)) {
return s3Object2FileEntry(s3Object, path);
} finally {
s3Object.close();
}
} catch (Exception e) {
LogKit.info("{} not exist!", path);
@ -96,22 +94,6 @@ public class S3ResourceRepository extends BaseResourceRepository {
return result.toArray(new FineFileEntry[0]);
}
private FineFileEntry s3Object2FileEntry(S3ObjectSummary s3Object, String path) {
FineFileEntry entry = new FineFileEntry(path);
entry.setDirectory(s3Object.getKey().endsWith("/"));
entry.setSize(s3Object.getSize());
entry.setTimestamp(s3Object.getLastModified().getTime());
return entry;
}
private FineFileEntry s3Object2FileEntry(S3Object s3Object, String path) {
FineFileEntry entry = new FineFileEntry(path);
entry.setDirectory(s3Object.getKey().endsWith("/"));
entry.setSize(s3Object.getObjectMetadata().getContentLength());
entry.setTimestamp(s3Object.getObjectMetadata().getLastModified().getTime());
return entry;
}
@Override
public URL getResource(String path) {
throw new RuntimeException("Not support method.");
@ -129,6 +111,17 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public void write(String path, byte[] data) {
List<String> paths = getAllNecessaryPath(path);
for (int i = paths.size() - 1; i > 0; i--) {
String parent = paths.get(i);
PutObjectRequest req = new PutObjectRequest(bucket, parent, new ByteArrayInputStream(new byte[0]), buildEmptyMetadata());
try {
s3.putObject(req);
} catch (Exception e) {
LogKit.error("[S3] Failed to create parent path {}", parent);
}
}
ObjectMetadata metadata;
try {
metadata = s3.getObjectMetadata(bucket, path);
@ -138,6 +131,8 @@ public class S3ResourceRepository extends BaseResourceRepository {
if (mimeType != null) {
metadata.setContentType(mimeType);
}
}
if (metadata != null) {
metadata.setContentLength(data.length);
}
s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata);
@ -146,41 +141,73 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public boolean createFile(String path) {
PutObjectRequest request = new PutObjectRequest(bucket, path, new ByteArrayInputStream(new byte[0]), new ObjectMetadata());
try {
s3.putObject(request);
} catch (Exception e) {
return false;
List<String> paths = getAllNecessaryPath(path);
for (int i = paths.size() - 1; i >= 0; i--) {
String parent = paths.get(i);
PutObjectRequest req = new PutObjectRequest(bucket, parent, new ByteArrayInputStream(new byte[0]), buildEmptyMetadata());
try {
s3.putObject(req);
} catch (Exception e) {
LogKit.error("[S3] Failed to create parent path {}", parent);
return false;
}
}
return true;
}
@Override
public boolean createDirectory(String path) {
PutObjectRequest request = new PutObjectRequest(bucket, path + "/", new ByteArrayInputStream(new byte[0]), new ObjectMetadata());
try {
s3.putObject(request);
} catch (Exception e) {
return false;
if (!path.endsWith(DELIMITER)) {
path += DELIMITER;
}
List<String> paths = getAllNecessaryPath(path);
for (int i = paths.size() - 1; i >= 0; i--) {
String parent = paths.get(i);
PutObjectRequest req = new PutObjectRequest(bucket, parent, new ByteArrayInputStream(new byte[0]), buildEmptyMetadata());
try {
s3.putObject(req);
} catch (Exception e) {
LogKit.error("[S3] Failed to create parent path {}", parent);
return false;
}
}
return true;
}
@Override
public boolean delete(String path) {
s3.deleteObject(bucket, path);
String prefix = path;
if (!path.endsWith(DELIMITER)) {
prefix = path + DELIMITER;
}
try {
s3.deleteObject(bucket, path);
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket)
.withPrefix(prefix).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest);
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) {
String key = summary.getKey();
if (!key.endsWith(DELIMITER)) {
s3.deleteObject(bucket, key);
}
}
for (String pre : objectListing.getCommonPrefixes()) {
delete(pre);
}
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
return false;
}
s3.deleteObject(bucket, prefix);
return true;
}
@Override
public boolean exist(String path) {
try {
return s3.doesObjectExist(bucket, path);
return s3.doesObjectExist(bucket, path) || s3.doesObjectExist(bucket, path + DELIMITER);
} catch (Exception e) {
return false;
}
@ -196,7 +223,12 @@ public class S3ResourceRepository extends BaseResourceRepository {
.withPrefix(dir).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest);
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
String[] arr = objectSummary.getKey().split(DELIMITER);
String key = objectSummary.getKey();
if (StringUtils.equals(key, dir)) {
continue;
}
String[] arr = key.split(DELIMITER);
String name = arr[arr.length - 1];
if (filter == null) {
result.add(name);
@ -222,7 +254,8 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public boolean isDirectory(String path) {
if (path.endsWith(DELIMITER)) {
if (path.endsWith(DELIMITER) && exist(path)) {
return true;
}
ObjectListing listing = s3.listObjects(bucket, path);
@ -297,4 +330,53 @@ public class S3ResourceRepository extends BaseResourceRepository {
return S3RepositoryFactory.IDENTITY;
}
/*--------------------------------------私有方法-----------------------------------------**/
private ObjectMetadata buildEmptyMetadata() {
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(0);
return metadata;
}
private FineFileEntry s3Object2FileEntry(S3ObjectSummary s3Object, String path) {
FineFileEntry entry = new FineFileEntry(path);
entry.setDirectory(s3Object.getKey().endsWith("/"));
entry.setSize(s3Object.getSize());
entry.setTimestamp(s3Object.getLastModified().getTime());
return entry;
}
private FineFileEntry s3Object2FileEntry(S3Object s3Object, String path) {
FineFileEntry entry = new FineFileEntry(path);
entry.setDirectory(s3Object.getKey().endsWith("/"));
entry.setSize(s3Object.getObjectMetadata().getContentLength());
entry.setTimestamp(s3Object.getObjectMetadata().getLastModified().getTime());
return entry;
}
/**
* 递归创建父目录的metadata. 比如path是 {@code WEB-INF/reportlets/test/1.cpt}
* 则返回 {@code [WEB-INF/reportlets/test/1.cpt, WEB-INF/reportlets/test/, WEB-INF/reportlets/, WEB-INF/]}
*/
private List<String> getAllNecessaryPath(String path) {
// 获取所有path路径及其所有父路径
List<String> allPath = new ArrayList<>();
allPath.add(path);
int lastIdxOfDelimiter = path.lastIndexOf(DELIMITER);
// 以/结尾的先把末尾的/去掉
if (lastIdxOfDelimiter == path.length() - 1) {
path = path.substring(0, lastIdxOfDelimiter);
lastIdxOfDelimiter = path.lastIndexOf(DELIMITER);
}
while (lastIdxOfDelimiter > 0) {
allPath.add(path.substring(0, lastIdxOfDelimiter + 1));
path = path.substring(0, lastIdxOfDelimiter);
lastIdxOfDelimiter = path.lastIndexOf(DELIMITER);
}
return allPath;
}
}

3
src/main/resources/com/fanruan/fs/s3/repository/locale/s3.properties

@ -3,4 +3,5 @@ Plugin-S3_End_Point=Endpoint
Plugin-S3_Region=Region
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket
Plugin-S3_Bucket=Bucket
Dec-Error_Start_With_Slash_Or_End_Without_Slash=The path cannot start with "/", but must end with "/"

3
src/main/resources/com/fanruan/fs/s3/repository/locale/s3_en_US.properties

@ -3,4 +3,5 @@ Plugin-S3_End_Point=Endpoint
Plugin-S3_Region=Region
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket
Plugin-S3_Bucket=Bucket
Dec-Error_Start_With_Slash_Or_End_Without_Slash=The path cannot start with "/", but must end with "/"

3
src/main/resources/com/fanruan/fs/s3/repository/locale/s3_zh_CN.properties

@ -3,4 +3,5 @@ Plugin-S3_End_Point=Endpoint
Plugin-S3_Region=Region
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket
Plugin-S3_Bucket=Bucket
Dec-Error_Start_With_Slash_Or_End_Without_Slash=\u8DEF\u5F84\u5F00\u5934\u4E0D\u80FD\u52A0\u659C\u6760\uFF0C\u5FC5\u987B\u4EE5\u659C\u6760\u7ED3\u5C3E

99
src/main/resources/com/fanruan/fs/s3/repository/web/js/bundle.js

@ -3,8 +3,10 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
value: "S3", // 地址栏显示的hash值
id: "decision-intelligence-cluster-file-s3", // id
text: "S3", // 文字
cardType: "dec.intelligence.cluster.file.s3"
cardType: "dec.intelligence.cluster.file.s3",
workRoot: false,
});
return items;
});
@ -15,12 +17,12 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
props: {
baseCls: "dec-cluster-ftp",
value: {}
value: {},
},
_store: function () {
return BI.Models.getModel("dec.model.intelligence.cluster.file.s3", {
value: this.options.value
value: this.options.value,
});
},
@ -28,6 +30,7 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
tgap: 15,
@ -49,8 +52,8 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setEndPoint(this.getValue());
}
}]
},
}],
}, {
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
@ -68,8 +71,8 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setRegion(this.getValue());
}
}]
},
}],
}, {
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
@ -87,25 +90,22 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setAccessKeyId(this.getValue());
}
}]
},
}],
},
{
type: "dec.label.editor.item",
type: "dec.common.cipher.editor",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Access_Key_Secret"),
text: BI.i18nText("Plugin-S3_Access_Key_Secret"),
value: "******",
value: this.model.password,
el: {
disabled: !o.editable,
},
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setAccessKeySecret(this.getValue());
}
}]
ref: function (_ref) {
self.passwordRow = _ref;
},
},
{
type: "dec.label.editor.item",
@ -121,9 +121,23 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setBucket(this.getValue());
}
}]
}]
},
}],
},
{
type: "dec.label.editor.item",
el: {
disabled: !o.editable,
},
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Dec-Please_Input"),
text: BI.i18nText("Dec-Basic_Path"),
value: this.model.workRoot,
ref: function (_ref) {
self.filePathRow = _ref;
},
}],
};
},
@ -132,14 +146,34 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
endPoint: this.model.endPoint,
region: this.model.region,
accessKeyId: this.model.accessKeyId,
accessKeySecret: this.model.accessKeySecret,
bucket: this.model.bucket
password: this.passwordRow.getCipher(),
bucket: this.model.bucket,
workRoot: this.filePathRow.getValue(),
};
},
validation: function () {
var valid = true;
var path = this.filePathRow.getValue();
if (Dec.Utils.strLength(path) > DecCst.STRING_SHORT_TEXT_LENGTH) {
this.filePathRow.showError(BI.i18nText("Dec-Error_Length_Greater_Than_Short_Text"));
valid = false;
}
if (BI.startWith(path, "/") || !BI.endWith(path, "/")) {
this.filePathRow.showError(BI.i18nText("Dec-Error_Start_With_Slash_Or_End_Without_Slash"));
valid = false;
}
if (!BI.isKey(path)) {
this.filePathRow.showError(BI.i18nText("Dec-Error_Null"));
valid = false;
}
return valid;
},
});
BI.shortcut("dec.intelligence.cluster.file.s3", S3);
})();
}());
!(function () {
@ -147,12 +181,14 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
state: function () {
var val = this.options.value;
return {
endPoint: val.endPoint,
region: val.region,
accessKeyId: val.accessKeyId,
accessKeySecret: val.accessKeySecret,
bucket: val.bucket
password: val.password,
bucket: val.bucket,
workRoot: val.workRoot,
};
},
@ -160,10 +196,10 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
encodingArray: function () {
return BI.map(DecCst.EncodeConstants.ENCODING_ARRAY, function (i, v) {
return {
value: v
value: v,
};
});
}
},
},
actions: {
@ -179,13 +215,10 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
this.model.accessKeyId = v;
},
setAccessKeySecret: function (v) {
this.model.accessKeySecret = v;
},
setBucket: function (v) {
this.model.bucket = v;
}
}
},
},
});
BI.model("dec.model.intelligence.cluster.file.s3", Model);
})();
}());

Loading…
Cancel
Save