Search in sources :

Example 31 with AbstractDataStorage

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()));
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageDoc(com.epam.pipeline.elasticsearchagent.model.DataStorageDoc) EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.S3bucketDataStorage) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) Test(org.junit.jupiter.api.Test)

Example 32 with AbstractDataStorage

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;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage)

Example 33 with AbstractDataStorage

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);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage)

Example 34 with AbstractDataStorage

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);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage)

Example 35 with AbstractDataStorage

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;
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) ArrayList(java.util.ArrayList) DataStorageDownloadFileUrl(com.epam.pipeline.entity.datastorage.DataStorageDownloadFileUrl)

Aggregations

AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)62 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)22 Test (org.junit.Test)22 Transactional (org.springframework.transaction.annotation.Transactional)18 Folder (com.epam.pipeline.entity.pipeline.Folder)13 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)11 ArrayList (java.util.ArrayList)7 List (java.util.List)6 EntityVO (com.epam.pipeline.controller.vo.EntityVO)5 StoragePolicy (com.epam.pipeline.entity.datastorage.StoragePolicy)5 Service (org.springframework.stereotype.Service)5 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)4 UpdateDataStorageItemVO (com.epam.pipeline.controller.vo.data.storage.UpdateDataStorageItemVO)3 DataStorageDownloadFileUrl (com.epam.pipeline.entity.datastorage.DataStorageDownloadFileUrl)3 DataStorageException (com.epam.pipeline.entity.datastorage.DataStorageException)3 DataStorageFile (com.epam.pipeline.entity.datastorage.DataStorageFile)3 DataStorageLink (com.epam.pipeline.entity.pipeline.run.parameter.DataStorageLink)3 ObjectCreatorUtils.constructDataStorageVO (com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO)3 IOException (java.io.IOException)3 MessageConstants (com.epam.pipeline.common.MessageConstants)2