public void Check(GenerateConfirmationLinkParameter generateConfirmationLinkParameter) { if (generateConfirmationLinkParameter == null) { throw new ArgumentNullException(nameof(generateConfirmationLinkParameter)); } if (string.IsNullOrWhiteSpace(generateConfirmationLinkParameter.Subject)) { throw new BaseDocumentManagementApiException(ErrorCodes.InvalidRequest, ErrorDescriptions.SubjectIsMissing); } }
public async Task <string> Execute(string documentId, GenerateConfirmationLinkParameter generateConfirmationCodeParameter) { if (string.IsNullOrWhiteSpace(documentId)) { throw new ArgumentNullException(nameof(documentId)); } _generateConfirmationLinkParameterValidator.Check(generateConfirmationCodeParameter); var officeDocument = await _officeDocumentRepository.Get(documentId); if (officeDocument == null) { throw new DocumentNotFoundException(); } if (string.IsNullOrWhiteSpace(officeDocument.UmaResourceId)) { throw new BaseDocumentManagementApiException(ErrorCodes.InternalError, ErrorDescriptions.NoUmaResource); } if (string.IsNullOrWhiteSpace(officeDocument.UmaPolicyId)) { throw new BaseDocumentManagementApiException(ErrorCodes.InternalError, ErrorDescriptions.NoUmaPolicy); } if (officeDocument.Subject != generateConfirmationCodeParameter.Subject) { throw new NotAuthorizedException(); } var confirmationLink = new OfficeDocumentConfirmationLink { ConfirmationCode = Guid.NewGuid().ToString(), DocumentId = documentId, ExpiresIn = generateConfirmationCodeParameter.ExpiresIn, NumberOfConfirmations = generateConfirmationCodeParameter.NumberOfConfirmations }; await _officeDocumentConfirmationLinkStore.Add(confirmationLink); return(confirmationLink.ConfirmationCode); }
public Task <string> GenerateConfirmationLink(string documentId, GenerateConfirmationLinkParameter generateConfirmationCodeParameter) { return(_generateConfirmationLinkAction.Execute(documentId, generateConfirmationCodeParameter)); }