
prerna.aws.s3.S3ListFilesReactor Maven / Gradle / Ivy
The newest version!
package prerna.aws.s3;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.amazonaws.SdkClientException;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import prerna.reactor.AbstractReactor;
import prerna.sablecc2.om.PixelDataType;
import prerna.sablecc2.om.PixelOperationType;
import prerna.sablecc2.om.nounmeta.NounMetadata;
import prerna.util.Constants;
/**
* Deprecated on March 21st 2025. Please use StorageEngine Directly
*/
@Deprecated
public class S3ListFilesReactor extends AbstractReactor {
private static final Logger logger = LogManager.getLogger(S3ListFilesReactor.class);
private static final String BUCKET = "bucket";
private static final String PATH = "path";
private static final String RECURSIVE = "recursive";
private static final String LIMIT = "limit";
public S3ListFilesReactor() {
this.keysToGet = S3Utils.addCommonS3Keys(new String[] { BUCKET, PATH, RECURSIVE, LIMIT });
}
@Override
public String getDescriptionForKey(String key) {
if(key.equals(BUCKET)) {
return "S3 bucket name";
} else if(key.equals(PATH)) {
return "S3 path to list files from";
} else if(key.equals(RECURSIVE)) {
return "Boolean flag to indicate if objects should be listed recursively (default false)";
} else if(key.equals(LIMIT)) {
return "Max number of results to list (default 100). Use -1 for unlimited";
} else {
String commonDescription = S3Utils.getDescriptionForCommonS3Key(key);
if(commonDescription != null) {
return commonDescription;
}
}
return super.getDescriptionForKey(key);
}
@Override
public String getReactorDescription() {
return "List the files in an S3 bucket. Credentials can be optionally set via a profile path/name, or with an explicit access key and secret. Otherwise, credentials from environment variables or social properties are used.";
}
@Override
public NounMetadata execute() {
organizeKeys();
String bucketName = this.keyValue.get(BUCKET);
String path = this.keyValue.get(PATH);
if(bucketName == null || bucketName.isEmpty() || path == null){
throw new IllegalArgumentException("Bucket and Path cannot be empty");
}
int limit = 100;
String limitString = this.keyValue.get(LIMIT);
if(limitString != null && !limitString.isEmpty()) {
try {
limit = Integer.parseInt(limitString);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Limit must be an integer");
}
}
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy