Class RepositoryCreationRequestedEvent

All Implemented Interfaces:
CancelableEvent, CancelState, Serializable
Direct Known Subclasses:
RepositoryForkRequestedEvent

public class RepositoryCreationRequestedEvent extends RepositoryEvent implements CancelableEvent
Raised just before a repository is created. This event is synchronous, allowing listeners to perform operations in the same database transaction where the repository will be created.

This event is cancelable. A listener may prevent the repository from being created by canceling this event. Throwing an exception will not prevent the repository from being created; the exception will be logged and ignored.

Note: The repository attached to the event will not have an ID, as it has not been created yet. Any listener which would like to create associations based on that ID must listen for the RepositoryCreatedEvent instead, which will include it (but will not run in the same transaction).

This event is internally audited with CoverageLevel.BASE level.

See Also:
  • Constructor Details

    • RepositoryCreationRequestedEvent

      public RepositoryCreationRequestedEvent(@Nonnull Object source, @Nonnull Repository repository, @Nullable String defaultBranch, @Nonnull CancelState cancelState)
      Parameters:
      source - the source of the event
      repository - the repository to be created
      defaultBranch - the default branch for the repository, or null if the SCM's default will be used
      cancelState - tracks vetoes for the event
      Since:
      7.5
  • Method Details

    • cancel

      public void cancel(@Nonnull KeyedMessage message)
      Cancels repository creation, providing a message explaining why.
      Specified by:
      cancel in interface CancelState
      Parameters:
      message - a descriptive message explaining why the operation has been canceled
    • getDefaultBranch

      @Nullable public String getDefaultBranch()
      Retrieves the default branch the repository will use, if one was specified. If no default was specified, the SCM's default branch will be used.
      Returns:
      the default branch, or null if the SCM's default branch will be used
      Since:
      7.5
    • isCanceled

      public boolean isCanceled()
      Retrieves a flag indicating whether repository creation has already been canceled by another listener.
      Specified by:
      isCanceled in interface CancelState
      Returns:
      true if another listener has already canceled repository creation; otherwise, false