in data-catalog-api/server/custos-sharing/src/main/java/org/apache/airavata/datacatalog/api/sharing/SharingManagerImpl.java [90:128]
public void initialize(String tenantId) throws SharingException {
logger.info("Initializing tenant {}", tenantId);
// Create DataProduct entity type
EntityType entityType = EntityType.newBuilder()
.setId(DATA_PRODUCT_ENTITY_TYPE_ID)
.setName("Data Product")
.build();
try {
Optional<EntityType> existingEntityType = custosSharingImpl.getEntityType(tenantId, entityType.getId());
if (!existingEntityType.isPresent()) {
custosSharingImpl.createEntityType(tenantId, entityType);
}
} catch (CustosSharingException e) {
throw new SharingException(e);
}
Set<Permission> allPermissions = new HashSet<>(Arrays.asList(Permission.values()));
allPermissions.remove(Permission.UNRECOGNIZED);
// Create permission types for all permissions
for (Permission permission : allPermissions) {
PermissionType permissionType = PermissionType.newBuilder()
.setId(permission.name())
.setName(permission.name())
.build();
try {
Optional<PermissionType> existingPermissionType = custosSharingImpl.getPermissionType(tenantId,
permissionType.getId());
if (!existingPermissionType.isPresent()) {
custosSharingImpl.createPermissionType(permissionType, tenantId);
}
} catch (CustosSharingException e) {
throw new SharingException(e);
}
}
}