Class SCMNavigator
- All Implemented Interfaces:
ExtensionPoint
,Describable<SCMNavigator>
- Direct Known Subclasses:
SingleSCMNavigator
SCMSource
s within an organization.
An implementation does not need to cache existing discoveries, but some form of caching is strongly recommended
where the backing provider of repositories has a rate limiter on API calls.- Since:
- 0.3-beta-1
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Modifier and TypeFieldDescriptionstatic final AlternativeUiTextProvider.Message<SCMNavigator>
Replaceable pronoun of that points to aSCMNavigator
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterSave
(SCMNavigatorOwner owner) Callback from theSCMNavigatorOwner
after theSCMNavigatorOwner
has been saved.protected final void
Checks theThread.interrupted()
and throws anInterruptedException
if it was set.protected final TaskListener
defaultListener
(TaskListener listener) Turns a possiblynull
TaskListener
reference into a guaranteed non-null reference.fetchActions
(SCMNavigatorOwner owner, SCMNavigatorEvent event, TaskListener listener) Fetches any actions that should be persisted for objects related to the specified owner.final Set<? extends SCMSourceCategory>
Returns the set ofSCMSourceCategory
that thisSCMNavigator
supports.final String
getId()
Returns the ID of the thing being navigated.Get the term used in the UI to represent this kind ofSCMNavigator
.Gets the traits for this navigator.protected abstract String
id()
Generates the ID of the thing being navigated from the configuration of thisSCMNavigator
.protected boolean
isCategoryEnabled
(SCMSourceCategory category) Sub-classes can override this method to filter the categories that are available from a specific source.protected final void
resetId()
retrieveActions
(SCMNavigatorOwner owner, SCMNavigatorEvent event, TaskListener listener) void
Sets the traits for this navigator.void
visitSource
(String sourceName, SCMSourceObserver observer) Looks for the named SCM source in a configured place.abstract void
visitSources
(SCMSourceObserver observer) Looks for SCM sources in a configured place.void
visitSources
(SCMSourceObserver observer, SCMHeadEvent<?> event) Looks for SCM sources in a configured place (scoped against a specific event).void
visitSources
(SCMSourceObserver observer, SCMSourceEvent<?> event) Looks for SCM sources in a configured place (scoped against a specific event).
-
Field Details
-
PRONOUN
Replaceable pronoun of that points to aSCMNavigator
. Defaults tonull
depending on the context.- Since:
- 2.0
-
-
Constructor Details
-
SCMNavigator
protected SCMNavigator()Constructor.
-
-
Method Details
-
getId
Returns the ID of the thing being navigated.The ID will typically be a composite of things like the server and the project/organization that the navigator is scoped to.
For example, a GitHub navigator that is navigating repositories in a GitHub organization could construct its ID as being the URL of the GitHub Server (to allow for GitHub Enterprise servers) and the name of the organization.
The key criteria is that if two navigators have the same ID and they are both in the same
SCMNavigatorOwner
then the results fromfetchActions(SCMNavigatorOwner, SCMNavigatorEvent, TaskListener)
should be not just equivalent butList.equals(Object)
.- Returns:
- the ID of the thing being navigated by this navigator.
- Since:
- 2.0.1
- See Also:
-
resetId
protected final void resetId()If implementations are usingDataBoundSetter
on fields that affect theid()
calculation then those fields must callresetId()
if they may have invalidated the cachedgetId()
.- Since:
- 2.0.1
-
id
Generates the ID of the thing being navigated from the configuration of thisSCMNavigator
.The ID will typically be a composite of things like the server and the project/organization that the navigator is scoped to.
For example, a GitHub navigator that is navigating repositories in a GitHub organization could construct its ID as being the URL of the GitHub Server (to allow for GitHub Enterprise servers) and the name of the organization.
The key criteria is that if two navigators have the same ID and they are both in the same
SCMNavigatorOwner
then the results fromfetchActions(SCMNavigatorOwner, SCMNavigatorEvent, TaskListener)
should be not just equivalent butList.equals(Object)
.If the results could be non-equal for navigators with the same ID then more detail needs to be encoded in the ID.
-
setTraits
Sets the traits for this navigator. No-op by default.- Parameters:
traits
- the list of traits
-
getTraits
Gets the traits for this navigator.- Returns:
- traits the list of traits, empty by default.
-
visitSources
public abstract void visitSources(@NonNull SCMSourceObserver observer) throws IOException, InterruptedException Looks for SCM sources in a configured place. After this method completes, no further calls may be made to theobserver
or its child callbacks. It is vitally important that implementations must periodically callcheckInterrupt()
otherwise it will be impossible for users to interrupt the operation.- Parameters:
observer
- a recipient of progress notifications and a source of contextual information- Throws:
IOException
- if scanning failsInterruptedException
- if scanning is interrupted
-
visitSources
public void visitSources(@NonNull SCMSourceObserver observer, @NonNull SCMSourceEvent<?> event) throws IOException, InterruptedException Looks for SCM sources in a configured place (scoped against a specific event). After this method completes, no further calls may be made to theobserver
or its child callbacks. It is vitally important that implementations must periodically callcheckInterrupt()
otherwise it will be impossible for users to interrupt the operation.- Parameters:
observer
- a recipient of progress notifications and a source of contextual informationevent
- the event from which the operation should be scoped.- Throws:
IOException
- if scanning failsInterruptedException
- if scanning is interrupted- Since:
- 2.0
-
visitSources
public void visitSources(@NonNull SCMSourceObserver observer, @NonNull SCMHeadEvent<?> event) throws IOException, InterruptedException Looks for SCM sources in a configured place (scoped against a specific event). After this method completes, no further calls may be made to theobserver
or its child callbacks. It is vitally important that implementations must periodically callcheckInterrupt()
otherwise it will be impossible for users to interrupt the operation.- Parameters:
observer
- a recipient of progress notifications and a source of contextual informationevent
- the event from which the operation should be scoped.- Throws:
IOException
- if scanning failsInterruptedException
- if scanning is interrupted- Since:
- 2.0
-
visitSource
public void visitSource(@NonNull String sourceName, @NonNull SCMSourceObserver observer) throws IOException, InterruptedException Looks for the named SCM source in a configured place. Implementers must ensure that after this method completes, no further calls may be made to theobserver
or its child callbacks. Implementations are strongly encouraged to override this method.- Parameters:
sourceName
- the source to visit.observer
- a recipient of progress notifications and a source of contextual information- Throws:
IOException
- if scanning failsInterruptedException
- if scanning is interrupted- Since:
- 2.0
-
getCategories
Returns the set ofSCMSourceCategory
that thisSCMNavigator
supports. There will always be exactly oneSCMCategory.isUncategorized()
instance in the returned set.- Returns:
- the set of
SCMSourceCategory
that thisSCMNavigator
supports. - Since:
- 2.0
-
isCategoryEnabled
Sub-classes can override this method to filter the categories that are available from a specific source. For example a source type might be capable of having mainline branches, user branches, merge requests and release tags while a specific instance of the source may be configured to only have mainline branches and release tags.- Parameters:
category
- the category.- Returns:
true
if the supplied category is enabled for thisSCMNavigator
instance.- Since:
- 2.0
-
getDescriptor
- Specified by:
getDescriptor
in interfaceDescribable<SCMNavigator>
- Overrides:
getDescriptor
in classAbstractDescribableImpl<SCMNavigator>
-
getPronoun
Get the term used in the UI to represent this kind ofSCMNavigator
. Must start with a capital letter.- Returns:
- the term or
null
to fall back to the calling context's default. - Since:
- 2.0
-
defaultListener
Turns a possiblynull
TaskListener
reference into a guaranteed non-null reference.- Parameters:
listener
- a possiblynull
TaskListener
reference.- Returns:
- guaranteed non-null
TaskListener
.
-
checkInterrupt
Checks theThread.interrupted()
and throws anInterruptedException
if it was set.- Throws:
InterruptedException
- if interrupted.- Since:
- 2.0
-