use of com.qlangtech.tis.plugin.aliyun.HttpEndpoint in project plugins by qlangtech.
the class DataXOssReader method verifyFormOSSRelative.
public static boolean verifyFormOSSRelative(IControlMsgHandler msgHandler, Context context, Descriptor.PostFormVals postFormVals) {
String endpoint = postFormVals.getField(FIELD_ENDPOINT);
String bucket = postFormVals.getField(FIELD_BUCKET);
HttpEndpoint end = ParamsConfig.getItem(endpoint, HttpEndpoint.KEY_DISPLAY_NAME);
try {
OSS ossClient = new OSSClientBuilder().build(end.getEndpoint(), end.getAccessKeyId(), end.getAccessKeySecret());
List<Bucket> buckets = ossClient.listBuckets();
if (buckets.size() < 1) {
msgHandler.addErrorMessage(context, "buckets不能为空");
return false;
}
Optional<Bucket> bucketFind = buckets.stream().filter((b) -> StringUtils.equals(bucket, b.getName())).findFirst();
if (!bucketFind.isPresent()) {
// msgHandler.addErrorMessage(context, );
msgHandler.addFieldError(context, FIELD_BUCKET, "还未创建bucket:" + bucket);
return false;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return true;
}
Aggregations