Browse Source

Pull request #73: JSY-21884 update:开放useGzip, keepalive, maxConnection为系统配置

Merge in PG/plugin-repository-s3 from ~SETH.TIAN/plugin-repository-s3:persist/jsy-11.0 to persist/jsy-11.0

* commit '5c27ef1ce00bca790f2a4571f7b72baaf8e62fa3':
  JSY-21884 update:开放useGzip, keepalive, maxConnection为系统配置
persist/jsy-11.0
Seth.Tian 3 years ago
parent
commit
8e2c9c319d
  1. 5
      build.gradle
  2. 2
      plugin.xml
  3. 55
      src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java
  4. 11
      src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java
  5. 2
      src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryProfile.java
  6. 198
      src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java
  7. 5
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3.properties
  8. 5
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_en_US.properties
  9. 5
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ja_JP.properties
  10. 5
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ko_KR.properties
  11. 4
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_zh_CN.properties
  12. 5
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_zh_TW.properties
  13. 72
      src/main/resources/com/fanruan/fs/s3/repository/web/js/bundle.js

5
build.gradle

@ -10,6 +10,8 @@ ext {
*/ */
libPath = "$projectDir/../webroot/WEB-INF/lib" libPath = "$projectDir/../webroot/WEB-INF/lib"
fineVersion = '11.0-jsy-20220713'
/** /**
* class进行加密保护 * class进行加密保护
*/ */
@ -118,5 +120,8 @@ dependencies {
//使jar //使jar
implementation fileTree(dir: 'lib', include: ['**/*.jar']) implementation fileTree(dir: 'lib', include: ['**/*.jar'])
implementation fileTree(dir: libPath, include: ['**/*.jar']) implementation fileTree(dir: libPath, include: ['**/*.jar'])
compileOnly('com.fanruan.hihidata:fine-core:' + fineVersion)
compileOnly('com.fanruan.hihidata:fine-cbb:' + fineVersion)
compileOnly('com.fanruan.hihidata:fine-decision:' + fineVersion)
} }

2
plugin.xml

@ -5,7 +5,7 @@
<main-package>com.fanruan.fs</main-package> <main-package>com.fanruan.fs</main-package>
<active>yes</active> <active>yes</active>
<hidden>no</hidden> <hidden>no</hidden>
<version>1.3.4</version> <version>1.3.5</version>
<env-version>11.0~11.0</env-version> <env-version>11.0~11.0</env-version>
<jartime>2021-08-30</jartime> <jartime>2021-08-30</jartime>
<vendor>richie</vendor> <vendor>richie</vendor>

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

@ -32,11 +32,14 @@ public class S3Config extends CommonRepoConfig {
@Identifier("bucket") @Identifier("bucket")
private Conf<String> bucket = HolderKit.simple(StringUtils.EMPTY); private Conf<String> bucket = HolderKit.simple(StringUtils.EMPTY);
@Identifier("enablePathStyleAccess") @Identifier("keepAlive")
private Conf<Boolean> enablePathStyleAccess = HolderKit.simple(false); private Conf<Boolean> keepAlive = HolderKit.simple(false);
@Identifier("signerOverride") @Identifier("useGzip")
private Conf<String> signerOverride = HolderKit.simple(StringUtils.EMPTY); private Conf<Boolean> useGzip = HolderKit.simple(false);
@Identifier("maxConnection")
private Conf<Integer> maxConnection = HolderKit.simple(50);
@GetConfig("endPoint") @GetConfig("endPoint")
public String getEndPoint() { public String getEndPoint() {
@ -78,24 +81,34 @@ public class S3Config extends CommonRepoConfig {
this.bucket.set(bucket); this.bucket.set(bucket);
} }
@GetConfig("enablePathStyleAccess") @GetConfig("keepAlive")
public boolean isEnablePathStyleAccess() { public boolean getKeepAlive() {
return enablePathStyleAccess.get(); return this.keepAlive.get();
}
@SetConfig("keepAlive")
public void setKeepAlive(boolean keepAlive) {
this.keepAlive.set(keepAlive);
}
@GetConfig("useGzip")
public boolean getUseGzip() {
return useGzip.get();
} }
@SetConfig("enablePathStyleAccess") @SetConfig("useGzip")
public void setEnablePathStyleAccess(boolean enablePathStyleAccess) { public void setUseGzip(boolean useGzip) {
this.enablePathStyleAccess.set(enablePathStyleAccess); this.useGzip.set(useGzip);
} }
@GetConfig("signerOverride") @GetConfig("maxConnection")
public String getSignerOverride() { public int getMaxConnection() {
return signerOverride.get(); return maxConnection.get();
} }
@SetConfig("signerOverride") @SetConfig("maxConnection")
public void setSignerOverride(String signerOverride) { public void setMaxConnection(int maxConnection) {
this.signerOverride.set(signerOverride); this.maxConnection.set(maxConnection);
} }
@Override @Override
@ -107,8 +120,9 @@ public class S3Config extends CommonRepoConfig {
this.setRegion(newConfig.getRegion()); this.setRegion(newConfig.getRegion());
this.setAccessKeyId(newConfig.getAccessKeyId()); this.setAccessKeyId(newConfig.getAccessKeyId());
this.setBucket(newConfig.getBucket()); this.setBucket(newConfig.getBucket());
this.setEnablePathStyleAccess(newConfig.isEnablePathStyleAccess()); this.setKeepAlive(newConfig.getKeepAlive());
this.setSignerOverride(newConfig.getSignerOverride()); this.setUseGzip(newConfig.getUseGzip());
this.setMaxConnection(newConfig.getMaxConnection());
} }
} }
@ -119,8 +133,9 @@ public class S3Config extends CommonRepoConfig {
cloned.region = (Conf<String>) region.clone(); cloned.region = (Conf<String>) region.clone();
cloned.accessKeyId = (Conf<String>) accessKeyId.clone(); cloned.accessKeyId = (Conf<String>) accessKeyId.clone();
cloned.bucket = (Conf<String>) bucket.clone(); cloned.bucket = (Conf<String>) bucket.clone();
cloned.enablePathStyleAccess = (Conf<Boolean>) enablePathStyleAccess.clone(); cloned.useGzip = (Conf<Boolean>) useGzip.clone();
cloned.signerOverride = (Conf<String>) signerOverride.clone(); cloned.keepAlive = (Conf<Boolean>) keepAlive.clone();
cloned.maxConnection = (Conf<Integer>) maxConnection.clone();
return cloned; return cloned;
} }
} }

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

@ -43,15 +43,8 @@ public class S3RepositoryFactory extends ConfigRepositoryFactory<S3Config> {
AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard() AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion())) .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion()))
.withCredentials(new AWSStaticCredentialsProvider(credentials)); .withCredentials(new AWSStaticCredentialsProvider(credentials));
if (config.isEnablePathStyleAccess()) { ClientConfiguration clientConfiguration = new ClientConfiguration();
amazonS3ClientBuilder = amazonS3ClientBuilder.enablePathStyleAccess(); amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration);
}
if (StringUtils.isNotEmpty(config.getSignerOverride())) {
ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setSignerOverride(config.getSignerOverride());
clientConfiguration.setProtocol(Protocol.HTTP);
amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration);
}
AmazonS3 s3 = amazonS3ClientBuilder.build(); AmazonS3 s3 = amazonS3ClientBuilder.build();
s3.listObjects(config.getBucket()); s3.listObjects(config.getBucket());
} catch (Exception e) { } catch (Exception e) {

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

@ -30,8 +30,6 @@ public class S3RepositoryProfile extends RepositoryProfile<S3Config> {
this.s3Config.set(s3Config); this.s3Config.set(s3Config);
} }
@Override @Override
public RepositoryProfile<S3Config> clone() throws CloneNotSupportedException { public RepositoryProfile<S3Config> clone() throws CloneNotSupportedException {
S3RepositoryProfile cloned = (S3RepositoryProfile) super.clone(); S3RepositoryProfile cloned = (S3RepositoryProfile) super.clone();

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

@ -18,8 +18,8 @@ import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit; import com.fanruan.api.util.StringKit;
import com.fr.io.repository.FineFileEntry; import com.fr.io.repository.FineFileEntry;
import com.fr.io.repository.base.BaseResourceRepository; import com.fr.io.repository.base.BaseResourceRepository;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Filter; import com.fr.stable.Filter;
import com.fr.stable.StringUtils;
import com.fr.workspace.resource.ResourceIOException; import com.fr.workspace.resource.ResourceIOException;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -48,14 +48,10 @@ public class S3ResourceRepository extends BaseResourceRepository {
AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard() AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion())) .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion()))
.withCredentials(new AWSStaticCredentialsProvider(credentials)).disableChunkedEncoding(); .withCredentials(new AWSStaticCredentialsProvider(credentials)).disableChunkedEncoding();
if (config.isEnablePathStyleAccess()) {
amazonS3ClientBuilder = amazonS3ClientBuilder.enablePathStyleAccess();
}
ClientConfiguration clientConfiguration = new ClientConfiguration(); ClientConfiguration clientConfiguration = new ClientConfiguration();
if (StringUtils.isNotEmpty(config.getSignerOverride())) { clientConfiguration.setUseGzip(config.getUseGzip());
clientConfiguration.setSignerOverride(config.getSignerOverride()); clientConfiguration.setUseTcpKeepAlive(config.getKeepAlive());
} clientConfiguration.setMaxConnections(config.getMaxConnection());
clientConfiguration.setProtocol(Protocol.HTTP);
amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration); amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration);
this.s3 = amazonS3ClientBuilder.build(); this.s3 = amazonS3ClientBuilder.build();
this.bucket = config.getBucket(); this.bucket = config.getBucket();
@ -63,7 +59,7 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override @Override
public String getSeparator() { public String getSeparator() {
return "/"; return DELIMITER;
} }
@Override @Override
@ -72,10 +68,9 @@ public class S3ResourceRepository extends BaseResourceRepository {
ObjectMetadata metadata = s3.getObjectMetadata(bucket, path); ObjectMetadata metadata = s3.getObjectMetadata(bucket, path);
return s3Object2FileEntry(metadata, path); return s3Object2FileEntry(metadata, path);
} catch (Exception e) { } catch (Exception e) {
LogKit.info("{} not exist!", path); FineLoggerFactory.getLogger().error(e, "{} not exist!", path);
return null;
} }
return null;
} }
@Override @Override
@ -84,21 +79,26 @@ public class S3ResourceRepository extends BaseResourceRepository {
if (!dir.endsWith(DELIMITER)) { if (!dir.endsWith(DELIMITER)) {
dir += DELIMITER; dir += DELIMITER;
} }
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket) ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(this.bucket)
.withPrefix(dir).withDelimiter(DELIMITER); .withPrefix(dir).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest); String nextMarker = null;
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) { ObjectListing objectListing;
String key = summary.getKey(); do {
if (!key.endsWith(DELIMITER)) { objectListing = this.s3.listObjects(listObjectsRequest.withMarker(nextMarker));
result.add(s3Object2FileEntry(summary, key)); for (S3ObjectSummary summary : objectListing.getObjectSummaries()) {
String key = summary.getKey();
if (!key.endsWith(DELIMITER)) {
result.add(s3Object2FileEntry(summary, key));
}
}
for (String prefix : objectListing.getCommonPrefixes()) {
FineFileEntry entry = new FineFileEntry(prefix);
entry.setDirectory(true);
result.add(entry);
} }
}
for (String prefix : objectListing.getCommonPrefixes()) {
FineFileEntry entry = new FineFileEntry(prefix);
entry.setDirectory(true);
result.add(entry);
}
nextMarker = objectListing.getNextMarker();
} while (objectListing.isTruncated());
return result.toArray(new FineFileEntry[0]); return result.toArray(new FineFileEntry[0]);
} }
@ -113,27 +113,18 @@ public class S3ResourceRepository extends BaseResourceRepository {
try { try {
return s3.getObject(request).getObjectContent(); return s3.getObject(request).getObjectContent();
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[S3] read path {} is error!", filePath);
return new ByteArrayInputStream(new byte[0]); return new ByteArrayInputStream(new byte[0]);
} }
} }
@Override @Override
public void write(String path, byte[] data) { 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; ObjectMetadata metadata;
try { try {
metadata = s3.getObjectMetadata(bucket, path); metadata = this.s3.getObjectMetadata(this.bucket, path);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().warn("[S3] getObjectMetaData error ,path {}", path);
metadata = new ObjectMetadata(); metadata = new ObjectMetadata();
String mimeType = URLConnection.guessContentTypeFromName(path); String mimeType = URLConnection.guessContentTypeFromName(path);
if (mimeType != null) { if (mimeType != null) {
@ -146,18 +137,38 @@ public class S3ResourceRepository extends BaseResourceRepository {
s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata); s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata);
} }
@Override
public void write(String path, InputStream inputStream) throws ResourceIOException {
if (null == inputStream) {
this.s3.putObject(this.bucket, path, "");
} else {
ObjectMetadata metadata = new ObjectMetadata();
try {
metadata.setContentLength(inputStream.available());
this.s3.putObject(this.bucket, path, inputStream, metadata);
} catch (Exception e) {
FineLoggerFactory.getLogger().info("S3 inputStream.putObject error,path is {}, error message {}", path, e.getMessage());
} finally {
try {
inputStream.close();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[S3] error,path is {}, error message {}", path, e.getMessage());
}
}
}
}
@Override @Override
public boolean createFile(String path) { public boolean createFile(String path) {
List<String> paths = getAllNecessaryPath(path); List<String> paths = getAllNecessaryPath(path);
for (int i = paths.size() - 1; i >= 0; i--) { for (int i = paths.size() - 1; i >= 0; i--) {
String parent = paths.get(i); String parent = paths.get(i);
PutObjectRequest req = new PutObjectRequest(bucket, parent, new ByteArrayInputStream(new byte[0]), buildEmptyMetadata()); PutObjectRequest req = new PutObjectRequest(this.bucket, parent, new ByteArrayInputStream(new byte[0]), buildEmptyMetadata());
try { try {
s3.putObject(req); this.s3.putObject(req);
} catch (Exception e) { } catch (Exception e) {
LogKit.error("[S3] Failed to create parent path {}", parent); FineLoggerFactory.getLogger().error(e, "[S3] Failed to create parent path {}", parent);
return false; return false;
} }
} }
@ -166,7 +177,6 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override @Override
public boolean createDirectory(String path) { public boolean createDirectory(String path) {
if (!path.endsWith(DELIMITER)) { if (!path.endsWith(DELIMITER)) {
path += DELIMITER; path += DELIMITER;
} }
@ -177,7 +187,7 @@ public class S3ResourceRepository extends BaseResourceRepository {
try { try {
s3.putObject(req); s3.putObject(req);
} catch (Exception e) { } catch (Exception e) {
LogKit.error("[S3] Failed to create parent path {}", parent); FineLoggerFactory.getLogger().error(e, "[S3] Failed to create parent path {}", parent);
return false; return false;
} }
} }
@ -186,37 +196,42 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override @Override
public boolean delete(String path) { public boolean delete(String path) {
this.s3.deleteObject(this.bucket, path);
s3.deleteObject(bucket, path);
String prefix = path; String prefix = path;
if (!path.endsWith(DELIMITER)) { if (!path.endsWith(DELIMITER)) {
prefix = path + DELIMITER; prefix = path + DELIMITER;
} }
try { try {
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket) ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(this.bucket)
.withPrefix(prefix).withDelimiter(DELIMITER); .withPrefix(prefix).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest); ObjectListing objectListing;
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) { String nextMarker = null;
String key = summary.getKey(); do {
if (!key.endsWith(DELIMITER)) { objectListing = this.s3.listObjects(listObjectsRequest.withMarker(nextMarker));
s3.deleteObject(bucket, key); for (S3ObjectSummary summary : objectListing.getObjectSummaries()) {
String key = summary.getKey();
if (!key.endsWith(DELIMITER)) {
this.s3.deleteObject(this.bucket, key);
}
} }
} for (String pre : objectListing.getCommonPrefixes()) {
for (String pre : objectListing.getCommonPrefixes()) { delete(pre);
delete(pre); }
} nextMarker = objectListing.getNextMarker();
} while (objectListing.isTruncated());
} catch (Exception e) { } catch (Exception e) {
LogKit.error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e, "[S3] delete error path {}", path);
} }
s3.deleteObject(bucket, prefix); this.s3.deleteObject(this.bucket, prefix);
return true; return true;
} }
@Override @Override
public boolean exist(String path) { public boolean exist(String path) {
try { try {
return s3.doesObjectExist(bucket, path) || s3.doesObjectExist(bucket, path + DELIMITER); return this.s3.doesObjectExist(this.bucket, path) || this.s3.doesObjectExist(this.bucket, path + DELIMITER);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[S3] exist error path {}", path);
return false; return false;
} }
} }
@ -227,36 +242,40 @@ public class S3ResourceRepository extends BaseResourceRepository {
if (!dir.endsWith(DELIMITER)) { if (!dir.endsWith(DELIMITER)) {
dir += DELIMITER; dir += DELIMITER;
} }
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket) ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(this.bucket)
.withPrefix(dir).withDelimiter(DELIMITER); .withPrefix(dir).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest); String nextMarker = null;
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { ObjectListing objectListing;
do {
String key = objectSummary.getKey(); objectListing = this.s3.listObjects(listObjectsRequest.withMarker(nextMarker));
if (StringKit.equals(key, dir)) { for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
continue; String key = objectSummary.getKey();
} if (StringKit.equals(key, dir)) {
String[] arr = key.split(DELIMITER); continue;
String name = arr[arr.length - 1]; }
if (filter == null) { String[] arr = key.split(DELIMITER);
result.add(name); String name = arr[arr.length - 1];
} else { if (filter == null) {
if (filter.accept(name)) {
result.add(name); result.add(name);
} else {
if (filter.accept(name)) {
result.add(name);
}
} }
} }
} for (String prefix : objectListing.getCommonPrefixes()) {
for (String prefix : objectListing.getCommonPrefixes()) { String[] arr = prefix.split(DELIMITER);
String[] arr = prefix.split(DELIMITER); String name = arr[arr.length - 1] + DELIMITER;
String name = arr[arr.length - 1] + DELIMITER; if (filter == null) {
if (filter == null) {
result.add(name);
} else {
if (filter.accept(name)) {
result.add(name); result.add(name);
} else {
if (filter.accept(name)) {
result.add(name);
}
} }
} }
} nextMarker = objectListing.getNextMarker();
} while (objectListing.isTruncated());
return result.toArray(new String[0]); return result.toArray(new String[0]);
} }
@ -268,7 +287,7 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override @Override
public long lastModified(String path) { public long lastModified(String path) {
try { try {
S3Object s3Object = s3.getObject(bucket, path); S3Object s3Object = this.s3.getObject(this.bucket, path);
if (s3Object != null) { if (s3Object != null) {
try { try {
return s3Object.getObjectMetadata().getLastModified().getTime(); return s3Object.getObjectMetadata().getLastModified().getTime();
@ -277,19 +296,18 @@ public class S3ResourceRepository extends BaseResourceRepository {
} }
} }
} catch (Exception e) { } catch (Exception e) {
LogKit.info("{} not exist!", path); FineLoggerFactory.getLogger().error(e, "[S3] {} not exist!", path);
} }
return -1L; return -1L;
} }
@Override @Override
public long length(String path) { public long length(String path) {
try { try {
ObjectMetadata metadata = s3.getObjectMetadata(bucket, path); ObjectMetadata metadata = this.s3.getObjectMetadata(this.bucket, path);
return metadata.getContentLength(); return metadata.getContentLength();
} catch (Exception e) { } catch (Exception e) {
LogKit.info("{} not exist!", path); LogKit.info("[S3] {} not exist!", path);
} }
return -1L; return -1L;
@ -297,15 +315,15 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override @Override
public boolean rename(String path, String newPath) throws ResourceIOException { public boolean rename(String path, String newPath) throws ResourceIOException {
if (copy(path, newPath) && delete(path)) { if (copy(path, newPath) && delete(path)) {
if (LogKit.isDebugEnabled()) { if (FineLoggerFactory.getLogger().isDebugEnabled()) {
LogKit.debug("[S3] rename {} to {} success.", path, newPath); FineLoggerFactory.getLogger().debug("[S3] rename {} to {} success.", path, newPath);
} }
return true; return true;
} else {
FineLoggerFactory.getLogger().error("[S3] rename {} to {} failed.", path, newPath);
return false;
} }
LogKit.error("[S3] rename {} to {} failed.", path, newPath);
return false;
} }
@Override @Override

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

@ -4,4 +4,7 @@ Plugin-S3_Region=Region
Plugin-S3_Access_Key_Id=AccessKeyId Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret 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 "/" Dec-Error_Start_With_Slash_Or_End_Without_Slash=The path cannot start with "/", but must end with "/"
Plugin-S3_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -4,4 +4,7 @@ Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket Plugin-S3_Bucket=Bucket
Plugin-S3_End_Point=Endpoint Plugin-S3_End_Point=Endpoint
Plugin-S3_Input=Please input Plugin-S3_Input=Please input
Plugin-S3_Region=Region Plugin-S3_Region=Region
Plugin-S3_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -4,4 +4,7 @@ Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket Plugin-S3_Bucket=Bucket
Plugin-S3_End_Point=Endpoint Plugin-S3_End_Point=Endpoint
Plugin-S3_Input=\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002 Plugin-S3_Input=\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002
Plugin-S3_Region=Region Plugin-S3_Region=Region
Plugin-S3_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -4,4 +4,7 @@ Plugin-S3_Access_Key_Secret=
Plugin-S3_Bucket= Plugin-S3_Bucket=
Plugin-S3_End_Point= Plugin-S3_End_Point=
Plugin-S3_Input= Plugin-S3_Input=
Plugin-S3_Region= Plugin-S3_Region=
Plugin-S3_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -4,4 +4,6 @@ Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket Plugin-S3_Bucket=Bucket
Plugin-S3_End_Point=Endpoint Plugin-S3_End_Point=Endpoint
Plugin-S3_Input=\u8BF7\u8F93\u5165 Plugin-S3_Input=\u8BF7\u8F93\u5165
Plugin-S3_Region=Region Plugin-S3_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -4,4 +4,7 @@ Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket Plugin-S3_Bucket=Bucket
Plugin-S3_End_Point=Endpoint Plugin-S3_End_Point=Endpoint
Plugin-S3_Input=\u8ACB\u8F38\u5165 Plugin-S3_Input=\u8ACB\u8F38\u5165
Plugin-S3_Region=Region Plugin-S3_Region=Region
Plugin-S3_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -101,7 +101,7 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
text: BI.i18nText("Plugin-S3_Access_Key_Secret"), text: BI.i18nText("Plugin-S3_Access_Key_Secret"),
value: this.model.password, value: this.model.password,
el: { el: {
disabled: !o.editable, disabled: !o.editable
}, },
ref: function (_ref) { ref: function (_ref) {
self.passwordRow = _ref; self.passwordRow = _ref;
@ -115,7 +115,7 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
text: BI.i18nText("Plugin-S3_Bucket"), text: BI.i18nText("Plugin-S3_Bucket"),
value: this.model.bucket, value: this.model.bucket,
el: { el: {
disabled: !o.editable, disabled: !o.editable
}, },
listeners: [{ listeners: [{
eventName: BI.Editor.EVENT_CHANGE, eventName: BI.Editor.EVENT_CHANGE,
@ -137,6 +137,59 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
ref: function (_ref) { ref: function (_ref) {
self.filePathRow = _ref; self.filePathRow = _ref;
}, },
},{
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: "keepAlive",
value: this.model.keepAlive,
el: {
disabled: !o.editable,
type: "bi.switch",
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setKeepAlive(this.isSelected());
},
}],
},
},{
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: "useGzip",
value: this.model.useGzip,
el: {
disabled: !o.editable,
type: "bi.switch",
listeners: [
{
eventName: BI.Switcher.EVENT_CHANGE,
action: function () {
self.store.setUseGzip(this.isSelected());
},
},
],
},
},{
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: "maxConnection",
value: this.model.maxConnection,
el: {
disabled: !o.editable,
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setMaxConnection(this.getValue());
},
}],
},
}], }],
}; };
}, },
@ -148,6 +201,9 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
accessKeyId: this.model.accessKeyId, accessKeyId: this.model.accessKeyId,
password: this.passwordRow.getCipher(), password: this.passwordRow.getCipher(),
bucket: this.model.bucket, bucket: this.model.bucket,
keepAlive: this.model.keepAlive,
useGzip: this.model.useGzip,
maxConnection: this.model.maxConnection,
workRoot: this.filePathRow.getValue(), workRoot: this.filePathRow.getValue(),
}; };
}, },
@ -189,6 +245,9 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
password: val.password, password: val.password,
bucket: val.bucket, bucket: val.bucket,
workRoot: val.workRoot, workRoot: val.workRoot,
keepAlive: val.keepAlive,
useGzip: val.useGzip,
maxConnection: val.maxConnection,
}; };
}, },
@ -218,6 +277,15 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
setBucket: function (v) { setBucket: function (v) {
this.model.bucket = v; this.model.bucket = v;
}, },
setKeepAlive: function (v){
this.model.keepAlive = v;
},
setUseGzip: function (v){
this.model.useGzip = v;
},
setMaxConnection: function (v){
this.model.maxConnection = Number.parseInt(v);
}
}, },
}); });
BI.model("dec.model.intelligence.cluster.file.s3", Model); BI.model("dec.model.intelligence.cluster.file.s3", Model);

Loading…
Cancel
Save