java.lang.Object
com.irurueta.authserver.resourceserver.application.documents.DeleteDocumentUseCase

@Service public class DeleteDocumentUseCase extends Object
Use case that deletes a document on behalf of a caller. Only the owner of a document, or an administrator, may delete it. A document the caller may not delete is reported exactly like a missing one, so that the answer never reveals that a document with that identifier exists and belongs to someone else (the API answers 404 in both cases rather than 403).
  • Field Details

    • documentRepository

      private final DocumentRepository documentRepository
      Port that stores the documents.
  • Constructor Details

    • DeleteDocumentUseCase

      public DeleteDocumentUseCase()
  • Method Details

    • execute

      public boolean execute(String id, String caller, boolean administrator)
      Deletes a document when the caller owns it or is an administrator.
      Parameters:
      id - identifier of the document.
      caller - subject of the caller.
      administrator - whether the caller is an administrator, who may delete any document.
      Returns:
      true when the document was deleted, false when it does not exist or the caller may not delete it (the two are deliberately indistinguishable).