use of com.epam.pipeline.entity.datastorage.StoragePolicy in project cloud-pipeline by epam.
the class DataStorageDaoTest method setUp.
@Before
public void setUp() {
testFolder = buildFolder(null);
awsRegion = new AwsRegion();
awsRegion.setName("Default");
awsRegion.setDefault(true);
awsRegion.setAwsRegionName("us-east-1");
awsRegionDao.create(awsRegion);
s3Bucket = new S3bucketDataStorage(null, TEST_STORAGE_NAME, TEST_STORAGE_PATH);
s3Bucket.setDescription("testDescription");
s3Bucket.setParentFolderId(testFolder.getId());
s3Bucket.setRegionId(awsRegion.getId());
s3Bucket.setOwner(TEST_OWNER);
s3Bucket.setMountPoint("testMountPoint");
s3Bucket.setMountOptions("testMountOptions");
s3Bucket.setShared(true);
s3Bucket.setAllowedCidrs(Arrays.asList("test1", "test2"));
policy = new StoragePolicy();
policy.setBackupDuration(BACKUP_DURATION);
policy.setLongTermStorageDuration(LTS_DURATION);
policy.setShortTermStorageDuration(STS_DURATION);
policy.setVersioningEnabled(true);
s3Bucket.setStoragePolicy(policy);
nfsStorage = new NFSDataStorage(null, "NFS_STORAGE", "nfs_path");
nfsStorage.setOwner(TEST_OWNER);
nfsStorage.setDescription("NFS");
nfsStorage.setParentFolderId(testFolder.getId());
nfsStorage.setMountOptions("-s");
nfsStorage.setMountPoint("nfs");
}
use of com.epam.pipeline.entity.datastorage.StoragePolicy in project cloud-pipeline by epam.
the class ObjectCreatorUtils method constructDataStorageVO.
public static DataStorageVO constructDataStorageVO(String name, String description, DataStorageType storageType, String path, Integer stsDuration, Integer ltsDuration, Long parentFolderId, String mountPoint, String mountOptions) {
DataStorageVO storageVO = constructDataStorageVO(name, description, storageType, path, parentFolderId, mountPoint, mountOptions);
StoragePolicy policy = new StoragePolicy();
if (stsDuration != null) {
policy.setShortTermStorageDuration(stsDuration);
}
if (ltsDuration != null) {
policy.setLongTermStorageDuration(ltsDuration);
}
storageVO.setStoragePolicy(policy);
return storageVO;
}
use of com.epam.pipeline.entity.datastorage.StoragePolicy in project cloud-pipeline by epam.
the class DataStorageManagerTest method compareDataStorage.
private void compareDataStorage(AbstractDataStorage saved, AbstractDataStorage loaded) {
Assert.assertNotNull(loaded);
Assert.assertEquals(saved.getName(), loaded.getName());
Assert.assertEquals(saved.getDescription(), loaded.getDescription());
StoragePolicy savedStoragePolicy = saved.getStoragePolicy();
StoragePolicy loadedStoragePolicy = loaded.getStoragePolicy();
Assert.assertEquals(savedStoragePolicy.getShortTermStorageDuration(), loadedStoragePolicy.getShortTermStorageDuration());
Assert.assertEquals(savedStoragePolicy.getLongTermStorageDuration(), loadedStoragePolicy.getLongTermStorageDuration());
Assert.assertEquals(saved.getType(), loaded.getType());
}
use of com.epam.pipeline.entity.datastorage.StoragePolicy in project cloud-pipeline by epam.
the class FolderManagerTest method shouldCloneFolderWithDataStorages.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneFolderWithDataStorages() {
Folder sourceFolder = new Folder();
sourceFolder.setName(FOLDER_TO_CLONE);
folderManager.create(sourceFolder);
DataStorageVO dataStorageVO = constructDataStorageVO(TEST_NAME, TEST_DESCRIPTION, DataStorageType.S3, TEST_PATH, STS_DURATION, LTS_DURATION, sourceFolder.getId(), TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
StoragePolicy storagePolicy = dataStorageVO.getStoragePolicy();
storagePolicy.setBackupDuration(BACKUP_DURATION);
dataStorageVO.setStoragePolicy(storagePolicy);
AbstractDataStorage expectedDataStorage = dataStorageManager.create(dataStorageVO, true, true, false);
Folder childSourceFolder = new Folder();
childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
childSourceFolder.setParentId(sourceFolder.getId());
folderManager.create(childSourceFolder);
dataStorageVO.setParentFolderId(childSourceFolder.getId());
dataStorageVO.setName(TEST_NAME_1);
dataStorageVO.setPath(TEST_NAME_1);
dataStorageManager.create(dataStorageVO, true, true, false);
Folder destinationFolder = new Folder();
destinationFolder.setName(TEST_NAME);
folderManager.create(destinationFolder);
folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
destinationFolder = folderManager.loadByNameOrId(TEST_NAME);
destinationFolder = folderManager.load(destinationFolder.getId());
Folder clonedFolder = destinationFolder.getChildFolders().get(0);
AbstractDataStorage clonedDataStorage = clonedFolder.getStorages().get(0);
clonedDataStorage = dataStorageManager.load(clonedDataStorage.getId());
assertTrue(clonedDataStorage.getName().startsWith(TEST_CLONE_PREFIX + storageSuffix));
assertTrue(clonedDataStorage.getPath().startsWith((TEST_CLONE_PREFIX + storageSuffix).toLowerCase()));
assertDataStorages(expectedDataStorage, clonedDataStorage);
Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
clonedDataStorage = clonedChildFolder.getStorages().get(0);
clonedDataStorage = dataStorageManager.load(clonedDataStorage.getId());
assertTrue(clonedDataStorage.getName().startsWith(TEST_CLONE_PREFIX + storageSuffix));
assertTrue(clonedDataStorage.getPath().startsWith((TEST_CLONE_PREFIX + storageSuffix).toLowerCase()));
assertDataStorages(expectedDataStorage, clonedDataStorage);
}
use of com.epam.pipeline.entity.datastorage.StoragePolicy in project cloud-pipeline by epam.
the class DataStorageMapper method map.
@Override
public XContentBuilder map(final EntityContainer<DataStorageDoc> doc) {
try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
AbstractDataStorage storage = doc.getEntity().getStorage();
jsonBuilder.startObject().field(DOC_TYPE_FIELD, documentType.name()).field("id", storage.getId()).field("parentId", storage.getParentFolderId()).field("name", storage.getName()).field("path", storage.getPath()).field("createdDate", parseDataToString(storage.getCreatedDate())).field("description", storage.getDescription()).field("storageType", storage.getType()).field("awsRegion", doc.getEntity().getRegionName());
StoragePolicy storagePolicy = storage.getStoragePolicy();
if (storagePolicy != null) {
jsonBuilder.field("storagePolicyBackupDuration", storagePolicy.getBackupDuration()).field("storagePolicyLongTermStorageDuration", storagePolicy.getLongTermStorageDuration()).field("storagePolicyShortTermStorageDuration", storagePolicy.getShortTermStorageDuration()).field("storagePolicyVersioningEnabled", storagePolicy.getVersioningEnabled());
}
buildUserContent(doc.getOwner(), jsonBuilder);
buildMetadata(doc.getMetadata(), jsonBuilder);
buildPermissions(doc.getPermissions(), jsonBuilder);
jsonBuilder.endObject();
return jsonBuilder;
} catch (IOException e) {
throw new IllegalArgumentException("An error occurred while creating document: ", e);
}
}
Aggregations