feat: add ICANN accreditation status on domain result page

This commit is contained in:
Maël Gangloff 2025-09-15 23:04:28 +02:00
parent b1566bbeac
commit c4f79bece8
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
12 changed files with 338 additions and 153 deletions

View File

@ -1,11 +1,16 @@
import {Flex, List, Tag, Tooltip, Typography} from 'antd'
import {Flex, List, Tag, Tooltip} from 'antd'
import React from 'react'
import type {Domain} from '../../utils/api'
import {rdapRoleDetailTranslation, rdapRoleTranslation} from '../../utils/functions/rdapTranslation'
import {
icannAccreditationTranslation,
rdapRoleDetailTranslation,
rdapRoleTranslation
} from '../../utils/functions/rdapTranslation'
import {roleToAvatar} from '../../utils/functions/roleToAvatar'
import {rolesToColor} from '../../utils/functions/rolesToColor'
import {sortDomainEntities} from '../../utils/functions/sortDomainEntities'
import {extractDetailsFromJCard} from '../../utils/functions/extractDetailsFromJCard'
import {CheckCircleOutlined, CloseCircleOutlined, SettingOutlined} from "@ant-design/icons"
export function EntitiesList({domain}: { domain: Domain }) {
const rdapRoleTranslated = rdapRoleTranslation()
@ -27,11 +32,28 @@ export function EntitiesList({domain}: { domain: Domain }) {
dataSource={sortDomainEntities(domain)}
renderItem={(e) => {
const details = extractDetailsFromJCard(e)
const icannAccreditationTranslated = icannAccreditationTranslation()
const status = e.entity.icannAccreditation?.status as ('Terminated' | 'Accredited' | 'Reserved' | undefined)
return <List.Item>
<List.Item.Meta
avatar={roleToAvatar(e)}
title={<Typography.Text code>{e.entity.handle}</Typography.Text>}
title={<Flex gap='small'>
<Tag>{e.entity.handle}</Tag>
{
e.entity.icannAccreditation && status && <Tooltip
title={e.entity.icannAccreditation.registrarName + " (" + icannAccreditationTranslated[status] + ")"}>
<Tag icon={
status === 'Terminated' ? <CloseCircleOutlined /> :
status === 'Accredited' ? <CheckCircleOutlined/> : <SettingOutlined/>
} color={
status === 'Terminated' ? 'red' :
status === 'Accredited' ? 'green' : 'yellow'
}>{e.entity.icannAccreditation.id}</Tag>
</Tooltip>
}
</Flex>}
description={<>
{details.fn && <div>👤 {details.fn}</div>}
{details.organization && <div>🏢 {details.organization}</div>}

View File

@ -9,12 +9,12 @@ import {getIcannAccreditations} from "../../utils/api/icann-accreditations"
const {Text, Paragraph} = Typography
interface FiltersType {
'icannAccreditation.status': 'Accredited' | 'Reserved' | 'Terminated',
status: 'Accredited' | 'Reserved' | 'Terminated',
}
function RegistrarListTable(filters: FiltersType) {
interface TableRow {
key: string
key: number
handle: number
name: string
}
@ -26,9 +26,9 @@ function RegistrarListTable(filters: FiltersType) {
getIcannAccreditations(params).then((data) => {
setTotal(data['hydra:totalItems'])
setDataTable(data['hydra:member'].map((accreditation: IcannAccreditation) => ({
key: accreditation.handle,
handle: parseInt(accreditation.handle),
name: accreditation.icannAccreditation.registrarName
key: accreditation.id,
handle: accreditation.id,
name: accreditation.registrarName
})
).sort((a, b) => a.handle - b.handle))
})
@ -76,17 +76,17 @@ export default function IcannRegistrarPage() {
Accredited: <>
<Text>{t`An accredited number means that ICANN's contract with the registrar is ongoing.`}</Text>
<Divider/>
<RegistrarListTable {...{'icannAccreditation.status': 'Accredited'}} />
<RegistrarListTable status='Accredited' />
</>,
Reserved: <>
<Text>{t`A reserved number can be used by TLD registries for specific operations.`}</Text>
<Divider/>
<RegistrarListTable {...{'icannAccreditation.status': 'Reserved'}} />
<RegistrarListTable status='Reserved' />
</>,
Terminated: <>
<Text>{t`A terminated number means that ICANN's contract with the registrar has been terminated.`}</Text>
<Divider/>
<RegistrarListTable {...{'icannAccreditation.status': 'Terminated'}} />
<RegistrarListTable status='Terminated' />
</>
}

View File

@ -8,7 +8,7 @@ interface IcannAccreditationList {
export async function getIcannAccreditations(params: object): Promise<IcannAccreditationList> {
return (await request<IcannAccreditationList>({
url: 'entities/icann-accreditations',
url: 'icann-accreditations',
params
})).data
}

View File

@ -32,6 +32,11 @@ export interface Entity {
string,
string | string[],
]>] | []
remarks?: {
type: string
description: string
}[]
icannAccreditation?: IcannAccreditation
}
export interface Nameserver {
@ -125,13 +130,11 @@ export interface TrackedDomains {
}
export interface IcannAccreditation {
handle: string
icannAccreditation: {
registrarName: string
status: string
date?: string
updated?: string
}
id: number
registrarName: string
status: string
date?: string
updated?: string
}
export async function request<T = object, R = AxiosResponse<T>, D = object>(config: AxiosRequestConfig): Promise<R> {

View File

@ -113,3 +113,10 @@ export const rdapStatusCodeDetailTranslation = () => ({
administrative: t`The object instance has been allocated administratively (i.e., not for use by the recipient in their own right in operational networks).`,
reserved: t`The object instance has been allocated to an IANA special-purpose address registry.`
})
export const icannAccreditationTranslation = () => ({
Terminated: t`Terminated`,
Accredited: t`Accredited`,
Reserved: t`Reserved`
})

View File

@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250915192826 extends AbstractMigration
{
public function getDescription(): string
{
return 'Move ICANN accreditation to table';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE icann_accreditation_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE icann_accreditation (id INT NOT NULL, registrar_name VARCHAR(255) DEFAULT NULL, rdap_base_url VARCHAR(255) DEFAULT NULL, status VARCHAR(255) DEFAULT NULL, updated DATE DEFAULT NULL, date DATE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN icann_accreditation.updated IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN icann_accreditation.date IS \'(DC2Type:date_immutable)\'');
$this->addSql('ALTER TABLE entity ADD icann_accreditation_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE entity DROP icann_registrar_name');
$this->addSql('ALTER TABLE entity DROP icann_rdap_base_url');
$this->addSql('ALTER TABLE entity DROP icann_status');
$this->addSql('ALTER TABLE entity DROP icann_updated');
$this->addSql('ALTER TABLE entity DROP icann_date');
$this->addSql('DELETE FROM domain_entity de USING entity e WHERE de.entity_uid = e.id AND e.tld_id IS NULL');
$this->addSql('DELETE FROM entity_event ee USING entity e WHERE ee.entity_uid = e.id AND e.tld_id IS NULL');
$this->addSql('DELETE FROM nameserver_entity ne USING entity e WHERE ne.entity_uid = e.id AND e.tld_id IS NULL');
$this->addSql('DELETE FROM entity e WHERE e.tld_id IS NULL;');
$this->addSql('ALTER TABLE entity ALTER tld_id SET NOT NULL');
$this->addSql('ALTER TABLE entity ADD CONSTRAINT FK_E284468D77C9FEB FOREIGN KEY (icann_accreditation_id) REFERENCES icann_accreditation (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_E284468D77C9FEB ON entity (icann_accreditation_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE entity DROP CONSTRAINT FK_E284468D77C9FEB');
$this->addSql('DROP SEQUENCE icann_accreditation_id_seq CASCADE');
$this->addSql('DROP TABLE icann_accreditation');
$this->addSql('DROP INDEX IDX_E284468D77C9FEB');
$this->addSql('ALTER TABLE entity ADD icann_registrar_name VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE entity ADD icann_rdap_base_url VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE entity ADD icann_status VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE entity ADD icann_updated DATE DEFAULT NULL');
$this->addSql('ALTER TABLE entity ADD icann_date DATE DEFAULT NULL');
$this->addSql('ALTER TABLE entity DROP icann_accreditation_id');
$this->addSql('ALTER TABLE entity ALTER tld_id DROP NOT NULL');
$this->addSql('COMMENT ON COLUMN entity.icann_updated IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN entity.icann_date IS \'(DC2Type:date_immutable)\'');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250915200844 extends AbstractMigration
{
public function getDescription(): string
{
return 'Remove auto increment on id';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP SEQUENCE icann_accreditation_id_seq CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE icann_accreditation_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace App\Api\Extension;
use ApiPlatform\Doctrine\Orm\Extension\QueryCollectionExtensionInterface;
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Metadata\Operation;
use App\Entity\Entity;
use Doctrine\ORM\QueryBuilder;
class NotNullAccreditationIcannExtension implements QueryCollectionExtensionInterface
{
public function applyToCollection(
QueryBuilder $queryBuilder,
QueryNameGeneratorInterface $queryNameGenerator,
string $resourceClass,
?Operation $operation = null,
array $context = [],
): void {
if (Entity::class !== $resourceClass) {
return;
}
if ($operation && 'icann_accreditations_collection' === $operation->getName()) {
$rootAlias = $queryBuilder->getRootAliases()[0];
$queryBuilder->andWhere(sprintf('%s.icannAccreditation.status IS NOT NULL', $rootAlias));
}
}
}

View File

@ -2,15 +2,11 @@
namespace App\Entity;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\EntityRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Embedded;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Attribute\SerializedName;
@ -20,31 +16,6 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
)]
#[ApiResource(
operations: [
new GetCollection(
uriTemplate: '/entities/icann-accreditations',
openapiContext: [
'parameters' => [
[
'name' => 'icannAccreditation.status',
'in' => 'query',
'required' => true,
'schema' => [
'type' => 'array',
'items' => [
'type' => 'string',
'enum' => ['Accredited', 'Terminated', 'Reserved'],
],
],
'style' => 'form',
'explode' => true,
'description' => 'Filter by ICANN accreditation status',
],
],
],
description: 'ICANN Registrar IDs list',
normalizationContext: ['groups' => ['entity:list']],
name: 'icann_accreditations_collection'
),
/*
new GetCollection(
uriTemplate: '/entities',
@ -67,12 +38,6 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
*/
]
)]
#[ApiFilter(
SearchFilter::class,
properties: [
'icannAccreditation.status' => 'exact',
]
)]
class Entity
{
#[ORM\Id]
@ -81,7 +46,7 @@ class Entity
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: Tld::class, inversedBy: 'entities')]
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: true)]
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: false)]
#[Groups(['entity:list', 'entity:item', 'domain:item'])]
private ?Tld $tld = null;
@ -120,7 +85,7 @@ class Entity
#[Groups(['entity:item', 'domain:item'])]
private ?array $remarks = null;
#[Embedded(class: IcannAccreditation::class, columnPrefix: 'icann_')]
#[ORM\ManyToOne(inversedBy: 'entities')]
#[Groups(['entity:list', 'entity:item', 'domain:item'])]
private ?IcannAccreditation $icannAccreditation = null;
@ -129,7 +94,6 @@ class Entity
$this->domainEntities = new ArrayCollection();
$this->nameserverEntities = new ArrayCollection();
$this->events = new ArrayCollection();
$this->icannAccreditation = new IcannAccreditation();
}
public function getHandle(): ?string
@ -284,11 +248,13 @@ class Entity
public function getIcannAccreditation(): ?IcannAccreditation
{
return null === $this->icannAccreditation->getStatus() ? null : $this->icannAccreditation;
return $this->icannAccreditation;
}
public function setIcannAccreditation(?IcannAccreditation $icannAccreditation): void
public function setIcannAccreditation(?IcannAccreditation $icannAccreditation): static
{
$this->icannAccreditation = $icannAccreditation;
return $this;
}
}

View File

@ -2,35 +2,92 @@
namespace App\Entity;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use App\Config\RegistrarStatus;
use App\Repository\IcannAccreditationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Embeddable;
use Symfony\Component\Serializer\Attribute\Groups;
#[Embeddable]
#[ApiResource(
operations: [
new GetCollection(
uriTemplate: '/icann-accreditations',
openapiContext: [
'parameters' => [
[
'name' => 'status',
'in' => 'query',
'required' => true,
'schema' => [
'type' => 'array',
'items' => [
'type' => 'string',
'enum' => ['Accredited', 'Terminated', 'Reserved'],
],
],
'style' => 'form',
'explode' => true,
'description' => 'Filter by ICANN accreditation status',
],
],
],
shortName: 'ICANN Accreditation',
description: 'ICANN Registrar IDs list',
normalizationContext: ['groups' => ['icann:list']]
),
]
)]
#[ApiFilter(
SearchFilter::class,
properties: [
'status' => 'exact',
]
)]
#[ORM\Entity(repositoryClass: IcannAccreditationRepository::class)]
class IcannAccreditation
{
#[ORM\Id]
#[ORM\Column]
#[Groups(['icann:item', 'icann:list', 'domain:item'])]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['entity:item', 'entity:list', 'domain:item'])]
#[Groups(['icann:item', 'icann:list', 'domain:item'])]
private ?string $registrarName = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['entity:item', 'domain:item'])]
#[Groups(['icann:item'])]
private ?string $rdapBaseUrl = null;
#[ORM\Column(nullable: true, enumType: RegistrarStatus::class)]
#[Groups(['entity:item', 'entity:list', 'domain:item'])]
#[Groups(['icann:item', 'icann:list', 'domain:item'])]
private ?RegistrarStatus $status = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
#[Groups(['entity:item', 'entity:list', 'domain:item'])]
#[Groups(['icann:item', 'icann:list', 'domain:item'])]
private ?\DateTimeImmutable $updated = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
#[Groups(['entity:item', 'entity:list', 'domain:item'])]
#[Groups(['icann:item', 'icann:list', 'domain:item'])]
private ?\DateTimeImmutable $date = null;
/**
* @var Collection<int, Entity>
*/
#[ORM\OneToMany(targetEntity: Entity::class, mappedBy: 'icannAccreditation')]
private Collection $entities;
public function __construct()
{
$this->entities = new ArrayCollection();
}
public function getRegistrarName(): ?string
{
return $this->registrarName;
@ -90,4 +147,46 @@ class IcannAccreditation
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function setId(?int $id): static
{
$this->id = $id;
return $this;
}
/**
* @return Collection<int, Entity>
*/
public function getEntities(): Collection
{
return $this->entities;
}
public function addEntity(Entity $entity): static
{
if (!$this->entities->contains($entity)) {
$this->entities->add($entity);
$entity->setIcannAccreditation($this);
}
return $this;
}
public function removeEntity(Entity $entity): static
{
if ($this->entities->removeElement($entity)) {
// set the owning side to null (unless already changed)
if ($entity->getIcannAccreditation() === $this) {
$entity->setIcannAccreditation(null);
}
}
return $this;
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\IcannAccreditation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<IcannAccreditation>
*/
class IcannAccreditationRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, IcannAccreditation::class);
}
// /**
// * @return Connector[] Returns an array of Connector objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('c.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Connector
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -14,6 +14,7 @@ use App\Entity\DomainEvent;
use App\Entity\DomainStatus;
use App\Entity\Entity;
use App\Entity\EntityEvent;
use App\Entity\IcannAccreditation;
use App\Entity\Nameserver;
use App\Entity\NameserverEntity;
use App\Entity\RdapServer;
@ -23,6 +24,7 @@ use App\Repository\DomainEventRepository;
use App\Repository\DomainRepository;
use App\Repository\EntityEventRepository;
use App\Repository\EntityRepository;
use App\Repository\IcannAccreditationRepository;
use App\Repository\NameserverEntityRepository;
use App\Repository\NameserverRepository;
use App\Repository\RdapServerRepository;
@ -105,6 +107,7 @@ class RDAPService
private DomainEntityRepository $domainEntityRepository,
private RdapServerRepository $rdapServerRepository,
private TldRepository $tldRepository,
private IcannAccreditationRepository $icannAccreditationRepository,
private EntityManagerInterface $em,
private LoggerInterface $logger,
private StatService $statService,
@ -344,7 +347,6 @@ class RDAPService
}
/**
* @throws \DateMalformedStringException
* @throws \Exception
*/
private function updateDomainEvents(Domain $domain, array $rdapData): void
@ -380,7 +382,6 @@ class RDAPService
}
/**
* @throws \DateMalformedStringException
* @throws \Exception
*/
private function updateDomainEntities(Domain $domain, array $rdapData): void
@ -418,7 +419,7 @@ class RDAPService
}
/**
* @throws \DateMalformedStringException
* @throws \Exception
*/
private function updateDomainNameservers(Domain $domain, array $rdapData): void
{
@ -461,7 +462,7 @@ class RDAPService
}
/**
* @throws \DateMalformedStringException
* @throws \Exception
*/
private function updateNameserverEntities(Nameserver $nameserver, array $rdapNameserver, Tld $tld): void
{
@ -517,36 +518,10 @@ class RDAPService
}
/**
* @throws \DateMalformedStringException
* @throws \Exception
*/
private function registerEntity(array $rdapEntity, array $roles, string $domain, Tld $tld): Entity
{
$entity = null;
/**
* If the RDAP server transmits the entity's IANA number, it is used as a priority to identify the entity.
*
* @see https://datatracker.ietf.org/doc/html/rfc7483#section-4.8
*/
$isIANAid = false;
if (isset($rdapEntity['publicIds'])) {
foreach ($rdapEntity['publicIds'] as $publicId) {
if ('IANA Registrar ID' === $publicId['type'] && isset($publicId['identifier']) && '' !== $publicId['identifier']) {
$entity = $this->entityRepository->findOneBy([
'handle' => $publicId['identifier'],
'tld' => null,
]);
if (null !== $entity) {
$rdapEntity['handle'] = $publicId['identifier'];
$isIANAid = true;
break;
}
}
}
}
/*
* If there is no number to identify the entity, one is generated from the domain name and the roles associated with this entity
*/
@ -559,16 +534,10 @@ class RDAPService
]);
}
if (null === $entity) {
$entity = $this->entityRepository->findOneBy([
'handle' => $rdapEntity['handle'],
'tld' => $tld,
]);
}
if ($isIANAid && null !== $entity) {
return $entity;
}
$entity = $this->entityRepository->findOneBy([
'handle' => $rdapEntity['handle'],
'tld' => $tld,
]);
if (null === $entity) {
$entity = (new Entity())->setTld($tld);
@ -578,7 +547,23 @@ class RDAPService
]);
}
$entity->setHandle($rdapEntity['handle']);
/**
* If the RDAP server transmits the entity's IANA number, it is used as a priority to identify the entity.
*
* @see https://datatracker.ietf.org/doc/html/rfc7483#section-4.8
*/
$icannAccreditation = null;
if (isset($rdapEntity['publicIds'])) {
foreach ($rdapEntity['publicIds'] as $publicId) {
if ('IANA Registrar ID' === $publicId['type'] && isset($publicId['identifier']) && '' !== $publicId['identifier']) {
$icannAccreditation = $this->icannAccreditationRepository->findOneBy([
'id' => (int) $publicId['identifier'],
]);
}
}
}
$entity->setHandle($rdapEntity['handle'])->setIcannAccreditation($icannAccreditation);
if (isset($rdapEntity['remarks']) && is_array($rdapEntity['remarks'])) {
$entity->setRemarks($rdapEntity['remarks']);
@ -719,7 +704,7 @@ class RDAPService
* @throws RedirectionExceptionInterface
* @throws DecodingExceptionInterface
* @throws ClientExceptionInterface
* @throws ORMException
* @throws \Exception
*/
public function updateRDAPServersFromIANA(): void
{
@ -733,7 +718,6 @@ class RDAPService
}
/**
* @throws ORMException
* @throws \Exception
*/
private function updateRDAPServers(array $dnsRoot): void
@ -772,6 +756,7 @@ class RDAPService
/**
* @throws ORMException
* @throws \Exception
*/
public function updateRDAPServersFromFile(string $fileName): void
{
@ -836,7 +821,6 @@ class RDAPService
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws DecodingExceptionInterface
* @throws ClientExceptionInterface
* @throws \Exception
*/
@ -850,23 +834,20 @@ class RDAPService
$data = new \SimpleXMLElement($registrarList->getContent());
foreach ($data->registry->record as $registrar) {
$entity = $this->entityRepository->findOneBy(['handle' => $registrar->value, 'tld' => null]);
if (null === $entity) {
$entity = new Entity();
$icannAcreditation = $this->icannAccreditationRepository->findOneBy(['id' => (int) $registrar->value]);
if (null === $icannAcreditation) {
$icannAcreditation = new IcannAccreditation();
}
$entity
->setHandle($registrar->value)
->setTld(null)
->setJCard(['vcard', [['version', [], 'text', '4.0'], ['fn', [], 'text', (string) $registrar->name]]])
->setRemarks(null)
->getIcannAccreditation()
->setRegistrarName($registrar->name)
->setStatus(RegistrarStatus::from($registrar->status))
->setRdapBaseUrl($registrar->rdapurl->count() ? ($registrar->rdapurl->server) : null)
->setUpdated(null !== $registrar->attributes()->updated ? new \DateTimeImmutable($registrar->attributes()->updated) : null)
->setDate(null !== $registrar->attributes()->date ? new \DateTimeImmutable($registrar->attributes()->date) : null);
$this->em->persist($entity);
$icannAcreditation
->setId((int) $registrar->value)
->setRegistrarName($registrar->name)
->setStatus(RegistrarStatus::from($registrar->status))
->setRdapBaseUrl($registrar->rdapurl->count() ? ($registrar->rdapurl->server) : null)
->setUpdated(null !== $registrar->attributes()->updated ? new \DateTimeImmutable($registrar->attributes()->updated) : null)
->setDate(null !== $registrar->attributes()->date ? new \DateTimeImmutable($registrar->attributes()->date) : null);
$this->em->persist($icannAcreditation);
}
$this->em->flush();
}