Search in sources :

Example 1 with HttpEndpoint

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;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) ParamsConfig(com.qlangtech.tis.config.ParamsConfig) LoggerFactory(org.slf4j.LoggerFactory) FormField(com.qlangtech.tis.plugin.annotation.FormField) Context(com.alibaba.citrus.turbine.Context) IFieldErrorHandler(com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler) Matcher(java.util.regex.Matcher) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DefaultContext(com.alibaba.citrus.turbine.impl.DefaultContext) IGroupChildTaskIterator(com.qlangtech.tis.datax.IGroupChildTaskIterator) HttpEndpoint(com.qlangtech.tis.plugin.aliyun.HttpEndpoint) IDataxReaderContext(com.qlangtech.tis.datax.IDataxReaderContext) FormFieldType(com.qlangtech.tis.plugin.annotation.FormFieldType) Validator(com.qlangtech.tis.plugin.annotation.Validator) TISExtension(com.qlangtech.tis.extension.TISExtension) Logger(org.slf4j.Logger) IHttpToken(com.qlangtech.tis.config.aliyun.IHttpToken) OSSClientBuilder(com.aliyun.oss.OSSClientBuilder) Descriptor(com.qlangtech.tis.extension.Descriptor) OSS(com.aliyun.oss.OSS) List(java.util.List) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) IOUtils(com.qlangtech.tis.extension.impl.IOUtils) Public(com.qlangtech.tis.annotation.Public) IControlMsgHandler(com.qlangtech.tis.runtime.module.misc.IControlMsgHandler) PluginFieldValidators(com.qlangtech.tis.plugin.datax.common.PluginFieldValidators) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Bucket(com.aliyun.oss.model.Bucket) Collections(java.util.Collections) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) Bucket(com.aliyun.oss.model.Bucket) HttpEndpoint(com.qlangtech.tis.plugin.aliyun.HttpEndpoint) OSS(com.aliyun.oss.OSS) OSSClientBuilder(com.aliyun.oss.OSSClientBuilder)

Aggregations

Context (com.alibaba.citrus.turbine.Context)1 DefaultContext (com.alibaba.citrus.turbine.impl.DefaultContext)1 OSS (com.aliyun.oss.OSS)1 OSSClientBuilder (com.aliyun.oss.OSSClientBuilder)1 Bucket (com.aliyun.oss.model.Bucket)1 Public (com.qlangtech.tis.annotation.Public)1 ParamsConfig (com.qlangtech.tis.config.ParamsConfig)1 IHttpToken (com.qlangtech.tis.config.aliyun.IHttpToken)1 IDataxReaderContext (com.qlangtech.tis.datax.IDataxReaderContext)1 IGroupChildTaskIterator (com.qlangtech.tis.datax.IGroupChildTaskIterator)1 DataxReader (com.qlangtech.tis.datax.impl.DataxReader)1 Descriptor (com.qlangtech.tis.extension.Descriptor)1 TISExtension (com.qlangtech.tis.extension.TISExtension)1 IOUtils (com.qlangtech.tis.extension.impl.IOUtils)1 HttpEndpoint (com.qlangtech.tis.plugin.aliyun.HttpEndpoint)1 FormField (com.qlangtech.tis.plugin.annotation.FormField)1 FormFieldType (com.qlangtech.tis.plugin.annotation.FormFieldType)1 Validator (com.qlangtech.tis.plugin.annotation.Validator)1 PluginFieldValidators (com.qlangtech.tis.plugin.datax.common.PluginFieldValidators)1 IControlMsgHandler (com.qlangtech.tis.runtime.module.misc.IControlMsgHandler)1