Implement basic detail endpoint

This commit is contained in:
2026-03-24 04:27:51 +05:00
parent 842de8071f
commit 4f3d955879
7 changed files with 296 additions and 9 deletions

View File

@@ -0,0 +1,34 @@
package com.backend.unifier.title.service;
import java.util.Optional;
import java.util.UUID;
import com.backend.unifier.title.model.ContentDetailEntry;
import com.backend.unifier.title.model.ContentIdentifier;
import com.backend.unifier.title.model.ContentProviderSource;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Instance;
@ApplicationScoped
public class GeneralDetailService {
private final IdentifierMaskService maskService;
private final Instance<DetailService> detailServices;
public GeneralDetailService(IdentifierMaskService maskService, Instance<DetailService> detailServices) {
this.maskService = maskService;
this.detailServices = detailServices;
}
public Optional<ContentDetailEntry> details(UUID id) {
ContentIdentifier realIdentifier = maskService.realIdentifier(id);
if (realIdentifier == null)
throw new IllegalStateException("content identifier not found for id '" + id + "'");
ContentProviderSource source = ContentProviderSource.valueOf(realIdentifier.source());
for (DetailService detailService : detailServices) {
if (detailService.source() == source)
return detailService.details(realIdentifier.id());
}
return Optional.empty();
}
}