private void addUserComponentScope(List<PreferenceScope> order, final PreferenceScopeFactory scopeFactory, final String componentKey) { if (componentKey != null) { final PreferenceScope userScope = scopeFactory.createScope(DefaultScopes.USER.type()); final PreferenceScope componentScope = scopeFactory.createScope(DefaultScopes.COMPONENT.type(), componentKey); order.add(scopeFactory.createScope(userScope, componentScope)); } }
private List<PreferenceScope> getScopeOrder( final PreferenceScopeFactory scopeFactory, final PreferenceScope... scopes ) { final List<PreferenceScope> order = new ArrayList<>(); if ( scopes != null ) { final List<PreferenceScope> nonNullScopes = Arrays.asList( scopes ).stream().filter( s -> s != null ).collect( Collectors.toList() ); order.addAll( nonNullScopes ); } order.add( scopeFactory.createScope( WorkbenchPreferenceScopes.USER ) ); order.add( scopeFactory.createScope( WorkbenchPreferenceScopes.GLOBAL ) ); return order; } }
private void addAllUsersEntireApplicationScope(List<PreferenceScope> order, final PreferenceScopeFactory scopeFactory) { final PreferenceScope allUsersScope = scopeFactory.createScope(DefaultScopes.ALL_USERS.type()); final PreferenceScope entireApplicationScope = scopeFactory.createScope(DefaultScopes.ENTIRE_APPLICATION.type()); order.add(scopeFactory.createScope(allUsersScope, entireApplicationScope)); } }
private void addAllUsersEntireApplicationScope(List<PreferenceScope> order, final PreferenceScopeFactory scopeFactory) { final PreferenceScope allUsersScope = scopeFactory.createScope(DefaultScopes.ALL_USERS.type()); final PreferenceScope entireApplicationScope = scopeFactory.createScope(DefaultScopes.ENTIRE_APPLICATION.type()); order.add(scopeFactory.createScope(allUsersScope, entireApplicationScope)); } }
private void addUserEntireApplicationScope(List<PreferenceScope> order, final PreferenceScopeFactory scopeFactory) { final PreferenceScope userScope = scopeFactory.createScope(DefaultScopes.USER.type()); final PreferenceScope entireApplicationScope = scopeFactory.createScope(DefaultScopes.ENTIRE_APPLICATION.type()); order.add(scopeFactory.createScope(userScope, entireApplicationScope)); }
private void addAllUsersComponentScope(List<PreferenceScope> order, final PreferenceScopeFactory scopeFactory, final String componentKey) { if (componentKey != null) { final PreferenceScope allUsersScope = scopeFactory.createScope(DefaultScopes.ALL_USERS.type()); final PreferenceScope componentScope = scopeFactory.createScope(DefaultScopes.COMPONENT.type(), componentKey); order.add(scopeFactory.createScope(allUsersScope, componentScope)); } }
private void addAllUsersComponentScope(List<PreferenceScope> order, final PreferenceScopeFactory scopeFactory, final String componentKey) { if (componentKey != null) { final PreferenceScope allUsersScope = scopeFactory.createScope(DefaultScopes.ALL_USERS.type()); final PreferenceScope componentScope = scopeFactory.createScope(DefaultScopes.COMPONENT.type(), componentKey); order.add(scopeFactory.createScope(allUsersScope, componentScope)); } }
private void addUserComponentScope(List<PreferenceScope> order, final PreferenceScopeFactory scopeFactory, final String componentKey) { if (componentKey != null) { final PreferenceScope userScope = scopeFactory.createScope(DefaultScopes.USER.type()); final PreferenceScope componentScope = scopeFactory.createScope(DefaultScopes.COMPONENT.type(), componentKey); order.add(scopeFactory.createScope(userScope, componentScope)); } }
private void addUserEntireApplicationScope(List<PreferenceScope> order, final PreferenceScopeFactory scopeFactory) { final PreferenceScope userScope = scopeFactory.createScope(DefaultScopes.USER.type()); final PreferenceScope entireApplicationScope = scopeFactory.createScope(DefaultScopes.ENTIRE_APPLICATION.type()); order.add(scopeFactory.createScope(userScope, entireApplicationScope)); }
@Override public PreferenceScopeResolutionStrategyInfo getUserInfoFor( final String scopeType, final String scopeKey ) { PreferenceScopeResolutionStrategy scopeResolutionStrategy; if ( scopeType != null ) { PreferenceScope userScope = scopeFactory.createScope( WorkbenchPreferenceScopes.USER ); PreferenceScope userScopedScope; if ( scopeKey != null ) { userScopedScope = scopeFactory.createScope( scopeType, scopeKey ); } else { userScopedScope = scopeFactory.createScope( scopeType ); } PreferenceScope projectUserScope = scopeFactory.createScope( userScope, userScopedScope ); scopeResolutionStrategy = new WorkbenchPreferenceScopeResolutionStrategy( scopeFactory, projectUserScope ); } else { scopeResolutionStrategy = new WorkbenchPreferenceScopeResolutionStrategy( scopeFactory ); } return scopeResolutionStrategy.getInfo(); } }
private void saveProviderTypeEnablements(final Map<ProviderType, Boolean> providerTypeEnablements) { provisioningPreferences.load(); provisioningPreferences.setProviderTypeEnablements(providerTypeEnablements); provisioningPreferences.save(scopeFactory.createScope(GuvnorPreferenceScopes.GLOBAL)); } }
private void addStunnerPreferences(boolean stunnerEnabled) { if (stunnerEnabled) { adminPage.addPreference("root", "StunnerPreferences", constants.StunnerDesignerPreferences(), new Sets.Builder().add("fa").add("fa-object-group").build(), "general", scopeFactory.createScope(GuvnorPreferenceScopes.GLOBAL), AdminPageOptions.WITH_BREADCRUMBS); } }
@Test public void preferencesShouldBeSavedOnGlobalScopeWhenUserHasPermissionTest() { doReturn(globalScope).when(scopeFactory).createScope(GuvnorPreferenceScopes.GLOBAL); doReturn(true).when(authorizationManager).authorize(eq(WorkbenchFeatures.EDIT_GLOBAL_PREFERENCES), any()); defaultAdminPageHelper.setup(); verifyLibraryPreferencesWasAddedInGlobalScope(); verifyArtifactRepositoryPreferencesWasAddedInGlobalScope(); verifyManagePreferencesWasAddedInGlobalScope(); verifyServiceTasksAdminWasAdded(); }
@Test public void preferencesShouldNotBeAddedWhenUserHasPermissionAndDisabledTest() { doReturn(globalScope).when(scopeFactory).createScope(GuvnorPreferenceScopes.GLOBAL); doReturn(true).when(authorizationManager).authorize(eq(WorkbenchFeatures.EDIT_GLOBAL_PREFERENCES), any()); defaultAdminPageHelper.setup(false, false, false); verifyLibraryPreferencesWasNotAdded(); verifyArtifactRepositoryPreferencesWasNotAdded(); verifyManagePreferencesWasAddedInGlobalScope(); verifyServiceTasksAdminWasAdded(); }
@Test public void preferencesShouldBeSavedOnGlobalScopeWhenUserHasPermissionAndEnabledTest() { doReturn(globalScope).when(scopeFactory).createScope(GuvnorPreferenceScopes.GLOBAL); doReturn(true).when(authorizationManager).authorize(eq(WorkbenchFeatures.EDIT_GLOBAL_PREFERENCES), any()); defaultAdminPageHelper.setup(true, true, true); verifyLibraryPreferencesWasAddedInGlobalScope(); verifyArtifactRepositoryPreferencesWasAddedInGlobalScope(); verifyManagePreferencesWasAddedInGlobalScope(); verifyServiceTasksAdminWasAdded(); }
@Before public void setUp() { providerTypesSpi = mockProviderTypeListSPI(PROVIDER_TYPES_COUNT); when(scopeFactory.createScope(GuvnorPreferenceScopes.GLOBAL)).thenReturn(preferenceScope); provisioningPreferences = spy(new ProvisioningPreferences() { { setProviderTypeEnablements(new HashMap<>()); } @Override public void load() { } @Override public void save(PreferenceScope customScope) { } }); when(runtimeProvisioningService.getProviderTypes(anyInt(), anyInt(), anyString(), anyBoolean())).thenReturn(providerTypesSpi); service = new ProviderTypeServiceImpl(runtimeProvisioningService, provisioningPreferences, scopeFactory); }
private void addProfilePreferences() { final boolean canEditProfilePreferences = authorizationManager.authorize(WorkbenchFeatures.EDIT_PROFILE_PREFERENCES, sessionInfo.getIdentity()); profileService.call((Boolean force) -> { if (canEditProfilePreferences && !force) { adminPage.addPreference("root", "ProfilePreferences", translationService.format(PreferencesConstants.ProfilePreferences_Title), new Sets.Builder().add("fa").add("fa-list").build(), "advanced", scopeFactory.createScope(GuvnorPreferenceScopes.GLOBAL), AdminPageOptions.WITH_BREADCRUMBS); } }).isForce(); }
preferenceScopeResolutionStrategy)); userEntireApplicationScope = scopeFactory.createScope(userScope, entireApplicationScope); allUsersEntireApplication = scopeFactory.createScope(allUsersScope, entireApplicationScope);
preferenceScopeResolutionStrategy)); userEntireApplicationScope = scopeFactory.createScope(userScope, entireApplicationScope); allUsersEntireApplication = scopeFactory.createScope(allUsersScope, entireApplicationScope);
@Test public void orderWithProjectScopeTest() { PreferenceScope userScope = scopesFactory.createScope( WorkbenchPreferenceScopes.USER ); PreferenceScope projectScope = scopesFactory.createScope( WorkbenchPreferenceScopes.PROJECT, "my-project" ); PreferenceScope userProjectScope = scopesFactory.createScope( userScope, projectScope );