Class OwnershipTransferHandlerWithBLValidationErrors

java.lang.Object
com.atlassian.jira.dev.functest.user.anonymize.OwnershipTransferHandlerWithBLValidationErrors
All Implemented Interfaces:
AnonymizationHandler<OwnershipTransferParameter>, OwnershipTransferHandler

@ReturnValuesAreNonnullByDefault public class OwnershipTransferHandlerWithBLValidationErrors extends Object implements OwnershipTransferHandler
  • Constructor Details

    • OwnershipTransferHandlerWithBLValidationErrors

      public OwnershipTransferHandlerWithBLValidationErrors()
  • Method Details

    • getAffectedEntities

      @Nonnull public Collection<AffectedEntity> getAffectedEntities(@Nonnull OwnershipTransferParameter ownershipTransferParameter)
      Description copied from interface: OwnershipTransferHandler
      Used to display in the UI a list of entities that require an ownership transfer, without actually performing the operation yet. Its goal is to inform the end-user about the scope of the changes. Implementation should not use OwnershipTransferParameter.getTransferToUserKey() during computing affected entities.

      This method should return results as fast as possible, as it is affecting the UI.

      Specified by:
      getAffectedEntities in interface AnonymizationHandler<OwnershipTransferParameter>
      Specified by:
      getAffectedEntities in interface OwnershipTransferHandler
      Parameters:
      ownershipTransferParameter - stores original and target user keys
      Returns:
      a collection of entities that will be affected by the ownership transfer
    • update

      public ServiceResult update(OwnershipTransferParameter parameter)
      Description copied from interface: AnonymizationHandler
      Performs the updates required by the user anonymization.

      Implementations must be idempotent - multiple invocations of this method should lead to the same result. In particular, when the method fails we can call it again to finish the operation.

      During the execution, implementations can update their the progress by calling Context.start(object); on the context passed in parameter, and subsequently call Context.Task.complete(); on the task object to indicate task has finished.

      Implementations can also call Context.setName("Name of current step") to describe the task that is currently processed.

      Specified by:
      update in interface AnonymizationHandler<OwnershipTransferParameter>
      Parameters:
      parameter - Data relevant to the handled anonymization step, e.g. previous and new (anonymized) username
      Returns:
      a service outcome of the update operation, containing any errors
    • validateBusinessLogic

      @Nullable public ErrorCollection validateBusinessLogic(AnonymizationParameters anonymizationParametes)
      Description copied from interface: AnonymizationHandler
      Allows handlers to prevent the anonymization if it would break business logic constraints.

      As an example, ownership transfer handler can ensure that an entity can only be transferred to a user with a particular role, e.g. only to another admin.

      The calculations done here should be as quick as possible not to degrade the user experience! Only business logic constraints should be checked here. You can assume that the passed in parameters are otherwise valid, e.g. the user to transfer the entity to exists and is not disabled.

      Specified by:
      validateBusinessLogic in interface AnonymizationHandler<OwnershipTransferParameter>
      Returns:
      an ErrorCollection, containing translated business logic validation errors if there were any, null otherwise