use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.
the class DataStorageLoaderTest method shouldLoadDataStorageTest.
@Test
void shouldLoadDataStorageTest() throws EntityNotFoundException {
StoragePolicy policy = new StoragePolicy();
policy.setBackupDuration(DURATION);
policy.setLongTermStorageDuration(DURATION);
policy.setShortTermStorageDuration(DURATION);
S3bucketDataStorage expectedDataStorage = new S3bucketDataStorage();
expectedDataStorage.setId(1L);
expectedDataStorage.setParentFolderId(1L);
expectedDataStorage.setName(TEST_NAME);
expectedDataStorage.setPath(TEST_PATH);
expectedDataStorage.setOwner(TEST_NAME);
expectedDataStorage.setStoragePolicy(policy);
DataStorageLoader dataStorageLoader = new DataStorageLoader(apiClient);
when(apiClient.loadDataStorage(anyLong())).thenReturn(expectedDataStorage);
Optional<EntityContainer<DataStorageDoc>> container = dataStorageLoader.loadEntity(1L);
EntityContainer<DataStorageDoc> storageDocEntityContainer = container.orElseThrow(AssertionError::new);
DataStorageDoc actualDataStorageDoc = storageDocEntityContainer.getEntity();
assertNotNull(actualDataStorageDoc);
AbstractDataStorage actualDataStorage = actualDataStorageDoc.getStorage();
verifyDataStorage(expectedDataStorage, actualDataStorage);
verifyPipelineUser(storageDocEntityContainer.getOwner());
verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, storageDocEntityContainer.getPermissions());
verifyMetadata(EXPECTED_METADATA, new ArrayList<>(storageDocEntityContainer.getMetadata().values()));
}
use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.
the class DataStorageDao method loadDataStorageByNameOrPath.
public AbstractDataStorage loadDataStorageByNameOrPath(String name, String path) {
String usePath = path == null ? name : path;
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue(DataStorageParameters.DATASTORAGE_NAME.name(), name);
params.addValue(DataStorageParameters.PATH.name(), usePath);
List<AbstractDataStorage> items = getNamedParameterJdbcTemplate().query(loadDataStorageByNameQuery, params, DataStorageParameters.getRowMapper());
return !items.isEmpty() ? items.get(0) : null;
}
use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.
the class DataStorageManager method loadDataStorageObjectTags.
public Map<String, String> loadDataStorageObjectTags(Long id, String path, String version) {
AbstractDataStorage dataStorage = load(id);
checkDataStorageVersioning(dataStorage, version);
return storageProviderManager.listObjectTags(dataStorage, path, version);
}
use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.
the class DataStorageManager method deleteDataStorageObjectTags.
public Map<String, String> deleteDataStorageObjectTags(Long id, String path, Set<String> tags, String version) {
AbstractDataStorage dataStorage = load(id);
checkDataStorageVersioning(dataStorage, version);
return storageProviderManager.deleteObjectTags(dataStorage, path, tags, version);
}
use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.
the class DataStorageManager method generateDataStorageItemUrl.
public List<DataStorageDownloadFileUrl> generateDataStorageItemUrl(final Long dataStorageId, final List<String> paths) {
AbstractDataStorage dataStorage = load(dataStorageId);
List<DataStorageDownloadFileUrl> urls = new ArrayList<>();
if (paths == null) {
return urls;
}
paths.forEach(path -> urls.add(storageProviderManager.generateDownloadURL(dataStorage, path, null)));
return urls;
}
Aggregations