Search in sources :

Example 1 with S3ObjectInfo

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;
}
Also used : S3MetaData(com.axway.ats.rbv.s3.S3MetaData) MetaData(com.axway.ats.rbv.MetaData) S3ObjectInfo(com.axway.ats.action.s3.S3ObjectInfo) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 2 with S3ObjectInfo

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;
}
Also used : S3MetaData(com.axway.ats.rbv.s3.S3MetaData) MetaData(com.axway.ats.rbv.MetaData) S3ObjectInfo(com.axway.ats.action.s3.S3ObjectInfo) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 3 with S3ObjectInfo

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());
}
Also used : MatchableNotOpenException(com.axway.ats.rbv.model.MatchableNotOpenException) HashMap(java.util.HashMap) MetaData(com.axway.ats.rbv.MetaData) S3ObjectInfo(com.axway.ats.action.s3.S3ObjectInfo) RbvException(com.axway.ats.rbv.model.RbvException) ArrayList(java.util.ArrayList) MatchableAlreadyOpenException(com.axway.ats.rbv.model.MatchableAlreadyOpenException) MatchableNotOpenException(com.axway.ats.rbv.model.MatchableNotOpenException) RbvException(com.axway.ats.rbv.model.RbvException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException)

Aggregations

S3ObjectInfo (com.axway.ats.action.s3.S3ObjectInfo)3 MetaData (com.axway.ats.rbv.MetaData)3 PublicAtsApi (com.axway.ats.common.PublicAtsApi)2 S3MetaData (com.axway.ats.rbv.s3.S3MetaData)2 MatchableAlreadyOpenException (com.axway.ats.rbv.model.MatchableAlreadyOpenException)1 MatchableNotOpenException (com.axway.ats.rbv.model.MatchableNotOpenException)1 RbvException (com.axway.ats.rbv.model.RbvException)1 RbvStorageException (com.axway.ats.rbv.model.RbvStorageException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1