Browse Source

DEC-16411 S3插件维护

persist/10.0
Feng 4 years ago
parent
commit
ab60e1c61f
  1. 25
      src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java
  2. 2
      src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java
  3. 2
      src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java
  4. 20
      src/main/resources/com/fanruan/fs/s3/repository/web/js/bundle.js

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();

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

@ -43,7 +43,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();

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

@ -91,21 +91,18 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
}]
},
{
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",
@ -132,7 +129,7 @@ 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,
password: this.passwordRow.getCipher(),
bucket: this.model.bucket
};
},
@ -151,7 +148,7 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
endPoint: val.endPoint,
region: val.region,
accessKeyId: val.accessKeyId,
accessKeySecret: val.accessKeySecret,
password: val.password,
bucket: val.bucket
};
},
@ -179,9 +176,6 @@ 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;
}

Loading…
Cancel
Save