use of com.epam.pipeline.vo.EntityPermissionVO in project cloud-pipeline by epam.
the class S3Synchronizer method createIndexAndDocuments.
@SuppressWarnings("PMD.AvoidCatchingGenericException")
void createIndexAndDocuments(final AbstractDataStorage dataStorage) {
EntityPermissionVO entityPermission = cloudPipelineAPIClient.loadPermissionsForEntity(dataStorage.getId(), dataStorage.getAclClass());
PermissionsContainer permissionsContainer = new PermissionsContainer();
if (entityPermission != null) {
permissionsContainer.add(entityPermission.getPermissions(), dataStorage.getOwner());
}
String alias = indexPrefix + indexName + String.format("-%d", dataStorage.getId());
String indexName = generateRandomString(5).toLowerCase() + "-" + alias;
try {
String currentIndexName = elasticsearchServiceClient.getIndexNameByAlias(alias);
elasticIndexService.createIndexIfNotExist(indexName, indexSettingsPath);
DataStorageAction action = new DataStorageAction();
action.setBucketName(dataStorage.getPath());
action.setId(dataStorage.getId());
action.setWrite(false);
action.setRead(true);
AbstractTemporaryCredentials credentials = cloudPipelineAPIClient.generateTemporaryCredentials(Collections.singletonList(action));
BulkRequestCreator bulkRequestCreator = requests -> elasticsearchServiceClient.sendRequests(indexName, requests);
S3Helper s3Helper = new S3Helper(enableTags, credentials, bulkRequestCreator, dataStorage, indexName, bulkInsertSize, permissionsContainer);
s3Helper.addItems();
elasticsearchServiceClient.createIndexAlias(indexName, alias);
if (StringUtils.hasText(currentIndexName)) {
elasticsearchServiceClient.deleteIndex(currentIndexName);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
if (elasticsearchServiceClient.isIndexExists(indexName)) {
elasticsearchServiceClient.deleteIndex(indexName);
}
}
}
use of com.epam.pipeline.vo.EntityPermissionVO in project cloud-pipeline by epam.
the class ObjectCreationUtils method buildEntityPermissionVO.
public static EntityPermissionVO buildEntityPermissionVO(final String owner, final Set<String> allowedUsers, final Set<String> deniedUsers, final Set<String> allowedGroups, final Set<String> deniedGroups) {
Set<AclPermissionEntry> permissions = new HashSet<>();
allowedUsers.forEach(user -> permissions.add(getPermissionEntry(user, true, 1)));
deniedUsers.forEach(user -> permissions.add(getPermissionEntry(user, true, 2)));
allowedGroups.forEach(group -> permissions.add(getPermissionEntry(group, false, 1)));
deniedGroups.forEach(group -> permissions.add(getPermissionEntry(group, false, 2)));
EntityPermissionVO entityPermissionVO = new EntityPermissionVO();
entityPermissionVO.setOwner(owner);
entityPermissionVO.setPermissions(permissions);
return entityPermissionVO;
}
use of com.epam.pipeline.vo.EntityPermissionVO in project cloud-pipeline by epam.
the class FolderLoaderTest method setup.
@BeforeEach
void setup() {
EntityPermissionVO entityPermissionVO = buildEntityPermissionVO(USER_NAME, ALLOWED_USERS, DENIED_USERS, ALLOWED_GROUPS, DENIED_GROUPS);
MetadataEntry metadataEntry = buildMetadataEntry(AclClass.FOLDER, 1L, TEST_KEY + " " + TEST_VALUE);
when(apiClient.loadUserByName(anyString())).thenReturn(USER);
when(apiClient.loadPermissionsForEntity(anyLong(), any())).thenReturn(entityPermissionVO);
when(apiClient.loadMetadataEntry(any())).thenReturn(Collections.singletonList(metadataEntry));
}
use of com.epam.pipeline.vo.EntityPermissionVO in project cloud-pipeline by epam.
the class IssueLoaderTest method setup.
@BeforeEach
void setup() {
EntityPermissionVO entityPermissionVO = buildEntityPermissionVO(USER_NAME, ALLOWED_USERS, DENIED_USERS, ALLOWED_GROUPS, DENIED_GROUPS);
MetadataEntry metadataEntry = buildMetadataEntry(AclClass.TOOL, 1L, TEST_KEY + " " + TEST_VALUE);
when(apiClient.loadUserByName(anyString())).thenReturn(USER);
when(apiClient.loadPermissionsForEntity(anyLong(), any())).thenReturn(entityPermissionVO);
when(apiClient.loadMetadataEntry(any())).thenReturn(Collections.singletonList(metadataEntry));
}
use of com.epam.pipeline.vo.EntityPermissionVO in project cloud-pipeline by epam.
the class MetadataEntityLoaderTest method setup.
@BeforeEach
void setup() {
EntityPermissionVO entityPermissionVO = buildEntityPermissionVO(USER_NAME, ALLOWED_USERS, DENIED_USERS, ALLOWED_GROUPS, DENIED_GROUPS);
MetadataEntry metadataEntry = buildMetadataEntry(AclClass.METADATA_ENTITY, 1L, TEST_KEY + " " + TEST_VALUE);
when(apiClient.loadPermissionsForEntity(anyLong(), any())).thenReturn(entityPermissionVO);
when(apiClient.loadMetadataEntry(any())).thenReturn(Collections.singletonList(metadataEntry));
}
Aggregations