@Nonnull
    public static String migrateLegacyPrimaryAllViewLocalizedName(@Nonnull List<View> views,
                                                                  @Nonnull String primaryView) {
        if (DEFAULT_VIEW_NAME.equals(primaryView)) {
            // modern name, we are safe
            return primaryView;
        }
        if (SystemProperties.getBoolean(AllView.class.getName()+".JENKINS-38606", true)) {
            AllView allView = null;
            for (View v : views) {
                if (DEFAULT_VIEW_NAME.equals(v.getViewName())) {
                    // name conflict, we cannot rename the all view anyway
                    return primaryView;
                }
                if (StringUtils.equals(v.getViewName(), primaryView)) {
                    if (v instanceof AllView) {
                        allView = (AllView) v;
                    } else {
                        // none of our business fixing as we can only safely fix the primary view
                        return primaryView;
                    }
                }
            }
            if (allView != null) {
                // the primary view is an AllView but using a non-default name
                for (Locale l : Locale.getAvailableLocales()) {
                    if (primaryView.equals(Messages._Hudson_ViewName().toString(l))) {
                        // bingo JENKINS-38606 detected
                        LOGGER.log(Level.INFO,
                                "JENKINS-38606 detected for AllView in {0}; renaming view from {1} to {2}",
                                new Object[] {allView.owner, primaryView, DEFAULT_VIEW_NAME});
                        allView.name = DEFAULT_VIEW_NAME;
                        return DEFAULT_VIEW_NAME;
                    }
                }
            }
        }
        return primaryView;
    }
@ Nonnull public static String migrateLegacyPrimaryAllViewLocalizedName ( @ Nonnull List < View > views , @ Nonnull String primaryView ) { if ( DEFAULT_VIEW_NAME . equals ( primaryView ) ) { return primaryView ; } if ( SystemProperties . getBoolean ( AllView . class . getName ( ) + ".JENKINS-38606" , true ) ) { AllView allView = null ; for ( View v : views ) { if ( DEFAULT_VIEW_NAME . equals ( v . getViewName ( ) ) ) { return primaryView ; } if ( StringUtils . equals ( v . getViewName ( ) , primaryView ) ) { if ( v instanceof AllView ) { allView = ( AllView ) v ; } else { return primaryView ; } } } if ( allView != null ) { for ( Locale l : Locale . getAvailableLocales ( ) ) { if ( primaryView . equals ( Messages . _Hudson_ViewName ( ) . toString ( l ) ) ) { LOGGER . log ( Level . INFO , "JENKINS-38606 detected for AllView in {0}; renaming view from {1} to {2}" , new Object [ ] { allView . owner , primaryView , DEFAULT_VIEW_NAME } ) ; allView . name = DEFAULT_VIEW_NAME ; return DEFAULT_VIEW_NAME ; } } } } return primaryView ; }
Corrects the name of the {@link AllView} if and only if the {@link AllView} is the primary view and
its name is one of the localized forms of {@link Messages#_Hudson_ViewName()} and the user has not opted out of
fixing the view name by setting the system property {@code hudson.mode.AllView.JENKINS-38606} to {@code false}.
Use this method to round-trip the primary view name, e.g.
{@code primaryView = migrateLegacyPrimaryAllViewLocalizedName(views, primaryView)}
<p>
NOTE: we can only fix the localized name of an {@link AllView} if it is the primary view as otherwise urls
would change, whereas the primary view is special and does not normally get accessed by the
{@code /view/_name_} url. (Also note that there are some cases where the primary view will get accessed by
its {@code /view/_name_} url which will then fall back to the primary view)

@param views the list of views.
@param primaryView the current primary view name.
@return the primary view name - this will be the same as the provided primary view name unless a JENKINS-38606
matching name is detected, in which case this will be the new name of the primary view.
@since 2.37