Complete Step 1.1: ValidatePDF Application Layer
Updated PHASENPLAN and ROADMAP to reflect progress on Feature 1 - ValidatePDF (75% complete). Marked Step 1.1 as completed, including MediatR setup, pipeline behaviors (`ValidationBehavior`, `LoggingBehavior`), ValidatePDF feature (Query, Handler, Validator), and DTOs. Added `DependencyInjection.cs` for Application Layer DI configuration. Introduced `LoggingBehavior` and `ValidationBehavior` for MediatR pipelines. Implemented `ValidatePdfHandler`, `ValidatePdfQuery`, and `ValidatePdfValidator`. Created DTOs (`ValidatePdfRequest`, `ValidatePdfResponse`) for the ValidatePDF feature. Added unit tests for `ValidatePdfHandler` to verify metadata handling and exception propagation. Removed unused folder references in `DocumentOperator.Application.csproj`.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using DocumentOperator.Application.Common.Interfaces;
|
||||
using DocumentOperator.Domain.Models.ValueObjects;
|
||||
using MediatR;
|
||||
|
||||
namespace DocumentOperator.Application.Features.Documents.ValidatePdf;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for ValidatePdfQuery
|
||||
/// Orchestrates PDF validation using IPdfProcessor
|
||||
/// </summary>
|
||||
public class ValidatePdfHandler : IRequestHandler<ValidatePdfQuery, PdfMetadata>
|
||||
{
|
||||
private readonly IPdfProcessor _pdfProcessor;
|
||||
|
||||
public ValidatePdfHandler(IPdfProcessor pdfProcessor)
|
||||
{
|
||||
_pdfProcessor = pdfProcessor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates PDF and returns metadata
|
||||
/// </summary>
|
||||
public async Task<PdfMetadata> Handle(ValidatePdfQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
// Value Object ? Byte Array
|
||||
byte[] pdfBytes = request.PdfContent.ToByteArray();
|
||||
|
||||
// DevExpress Service aufrufen (kann PdfProcessingException werfen)
|
||||
var metadata = await _pdfProcessor.ValidateAsync(pdfBytes);
|
||||
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using DocumentOperator.Domain.Models.ValueObjects;
|
||||
using MediatR;
|
||||
|
||||
namespace DocumentOperator.Application.Features.Documents.ValidatePdf;
|
||||
|
||||
/// <summary>
|
||||
/// Query to validate a PDF document and return metadata
|
||||
/// </summary>
|
||||
/// <param name="PdfContent">PDF content as Base64 string (validated by Value Object)</param>
|
||||
public record ValidatePdfQuery(Base64String PdfContent) : IRequest<PdfMetadata>;
|
||||
@@ -0,0 +1,17 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace DocumentOperator.Application.Features.Documents.ValidatePdf;
|
||||
|
||||
/// <summary>
|
||||
/// Validator for ValidatePdfQuery
|
||||
/// Validates that PdfContent is not null (Base64String already validates format in its constructor)
|
||||
/// </summary>
|
||||
public class ValidatePdfValidator : AbstractValidator<ValidatePdfQuery>
|
||||
{
|
||||
public ValidatePdfValidator()
|
||||
{
|
||||
RuleFor(x => x.PdfContent)
|
||||
.NotNull()
|
||||
.WithMessage("PDF content is required");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user