
com.alogic.s3.S3Bucket Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alogic-vfs Show documentation
Show all versions of alogic-vfs Show documentation
虚拟文件系统(Virutal File System)框架
package com.alogic.s3;
import com.alogic.xscript.ExecuteWatcher;
import com.alogic.xscript.Logiclet;
import com.alogic.xscript.LogicletContext;
import com.alogic.xscript.doc.XsObject;
import com.amazonaws.services.s3.AmazonS3;
import com.anysoft.util.BaseException;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
/**
* 定位到指定的bucket
*
* @since 1.6.16.6
*/
public class S3Bucket extends S3Client.Operation{
protected String $name;
protected boolean create = true;
public S3Bucket(String tag, Logiclet p) {
super(tag, p);
}
@Override
public void configure(Properties props){
super.configure(props);
$name = PropertiesConstants.getRaw(props,"name",NULL);
create = PropertiesConstants.getBoolean(props,"create",create,true);
}
@Override
protected void onExecute(AmazonS3 client, XsObject root, XsObject current, LogicletContext ctx, ExecuteWatcher watcher) {
boolean result = false;
try {
String name = PropertiesConstants.transform(ctx, $name, NULL);
if (StringUtils.isEmpty(name)) {
log("Bucket name is empty", "error");
return;
}
try {
boolean exist = client.doesBucketExistV2(name);
if (exist) {
onSuperExecute(root, current, ctx, watcher);
}else{
if (create){
client.createBucket(name);
onSuperExecute(root,current,ctx,watcher);
}
}
} catch (Exception ex) {
log(ExceptionUtils.getStackTrace(ex), "error");
throw new BaseException("core.e1003", ex.getMessage());
}
}finally {
PropertiesConstants.setBoolean(ctx,id,result);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy