use of com.axway.ats.action.s3.S3ObjectInfo in project ats-framework by Axway.
the class S3Verification method verifyObjectExists.
@PublicAtsApi
public S3ObjectInfo[] verifyObjectExists() throws RbvException {
addFileCheckRule();
List<MetaData> matchedMetaData = verifyExists();
S3ObjectInfo[] matchedS3Objects = new S3ObjectInfo[matchedMetaData.size()];
for (int i = 0; i < matchedMetaData.size(); i++) {
S3ObjectInfo newMatchedObject = new S3ObjectInfo();
matchedS3Objects[i] = newMatchedObject;
MetaData currentMetaData = matchedMetaData.get(i);
newMatchedObject.setBucketName((String) currentMetaData.getProperty(S3MetaData.BUCKET_NAME));
newMatchedObject.setName((String) currentMetaData.getProperty(S3MetaData.FILE_NAME));
newMatchedObject.setSize((Long) currentMetaData.getProperty(S3MetaData.SIZE));
newMatchedObject.setMd5((String) currentMetaData.getProperty(S3MetaData.MD5));
newMatchedObject.setLastModified((Date) currentMetaData.getProperty(S3MetaData.LAST_MODIFIED));
}
return matchedS3Objects;
}
use of com.axway.ats.action.s3.S3ObjectInfo in project ats-framework by Axway.
the class S3Verification method verifyObjectAlwaysExists.
@PublicAtsApi
public S3ObjectInfo[] verifyObjectAlwaysExists() throws RbvException {
addFileCheckRule();
List<MetaData> matchedMetaData = verifyAlwaysExists();
S3ObjectInfo[] matchedS3Objects = new S3ObjectInfo[matchedMetaData.size()];
for (int i = 0; i < matchedMetaData.size(); i++) {
S3ObjectInfo newMatchedObject = new S3ObjectInfo();
matchedS3Objects[i] = newMatchedObject;
MetaData currentMetaData = matchedMetaData.get(i);
newMatchedObject.setBucketName((String) currentMetaData.getProperty(S3MetaData.BUCKET_NAME));
newMatchedObject.setName((String) currentMetaData.getProperty(S3MetaData.FILE_NAME));
newMatchedObject.setSize((Long) currentMetaData.getProperty(S3MetaData.SIZE));
newMatchedObject.setMd5((String) currentMetaData.getProperty(S3MetaData.MD5));
newMatchedObject.setLastModified((Date) currentMetaData.getProperty(S3MetaData.LAST_MODIFIED));
}
return matchedS3Objects;
}
use of com.axway.ats.action.s3.S3ObjectInfo in project ats-framework by Axway.
the class S3Folder method getAllMetaData.
public List<MetaData> getAllMetaData() throws RbvException {
// first check if the folder is already open
if (!isOpen) {
throw new MatchableNotOpenException("S3 folder is not open");
}
newMetaData.clear();
if (fileName == null) {
fileName = ".*";
}
HashMap<String, MetaData> tempMetaData = new HashMap<String, MetaData>();
// fetch dir contents recursively
List<S3ObjectInfo> s3ObjectsList;
try {
s3ObjectsList = this.s3Operations.list(path, fileName, searchRecursively);
} catch (Exception e) {
final String notExistMessageSuffix = "does not exist";
String exMessage = e.getMessage();
Throwable cause = e.getCause();
if ((exMessage != null && exMessage.endsWith(notExistMessageSuffix)) || (cause != null && cause.getMessage() != null && cause.getMessage().endsWith(notExistMessageSuffix))) {
log.warn(getDescription() + " does not exist, skipping to next poll attempt");
return new ArrayList<MetaData>();
}
throw new RbvException("Unable to list the contents of " + path, e);
}
if (s3ObjectsList != null) {
for (S3ObjectInfo s3Object : s3ObjectsList) {
// The way files are compared is by combining their
// name+path and modification time in a hash string
String hashKey = getUniqueIdentifier(s3Object);
MetaData metaData = new MetaData();
metaData.putProperty(S3MetaData.BUCKET_NAME, s3Object.getBucketName());
metaData.putProperty(S3MetaData.FILE_NAME, s3Object.getName());
metaData.putProperty(S3MetaData.MD5, s3Object.getMd5());
metaData.putProperty(S3MetaData.LAST_MODIFIED, s3Object.getLastModified());
metaData.putProperty(S3MetaData.SIZE, s3Object.getSize());
if (!allMetaData.containsKey(hashKey)) {
newMetaData.add(metaData);
}
tempMetaData.put(hashKey, metaData);
}
}
allMetaData.clear();
allMetaData.putAll(tempMetaData);
return new ArrayList<MetaData>(allMetaData.values());
}
Aggregations