1515import java .util .Collection ;
1616import java .util .HashSet ;
1717import java .util .LinkedHashSet ;
18- import java .util .List ;
1918import java .util .Map ;
2019import java .util .Set ;
2120
4847import biz .netcentric .cq .tools .actool .authorizableutils .AuthorizableCreatorException ;
4948import biz .netcentric .cq .tools .actool .authorizableutils .AuthorizableCreatorService ;
5049import biz .netcentric .cq .tools .actool .authorizableutils .AuthorizableInstallationHistory ;
50+ import biz .netcentric .cq .tools .actool .configmodel .AcConfiguration ;
5151import biz .netcentric .cq .tools .actool .configreader .ConfigFilesRetriever ;
5252import biz .netcentric .cq .tools .actool .configreader .ConfigReader ;
5353import biz .netcentric .cq .tools .actool .configreader .ConfigurationMerger ;
@@ -97,30 +97,26 @@ public class AceServiceImpl implements AceService {
9797 private String configurationPath ;
9898
9999 @ Activate
100- public void activate (@ SuppressWarnings ( "rawtypes" ) final Map properties )
100+ public void activate (final Map <?,?> properties )
101101 throws Exception {
102102 LOG .debug ("Activated AceService!" );
103103 modified (properties );
104104 }
105105
106106 @ Modified
107- public void modified (@ SuppressWarnings ( "rawtypes" ) final Map properties ) {
107+ public void modified (final Map <?,?> properties ) {
108108 LOG .debug ("Modified AceService!" );
109109 configurationPath = PropertiesUtil .toString (properties .get (PROPERTY_CONFIGURATION_PATH ), "" );
110110 }
111111
112- // FIXME: Why is this called installConfigurationFromYamlList if it doesn't use YAML?
113- private void installConfigurationFromYamlList (
114- final List mergedConfigurations , AcInstallationHistoryPojo history ,
112+ private void installAcConfiguration (
113+ AcConfiguration acConfiguration , AcInstallationHistoryPojo history ,
115114 final Session session ,
116115 Set <AuthorizableInstallationHistory > authorizableHistorySet ,
117116 Map <String , Set <AceBean >> repositoryDumpAceMap ) throws Exception {
118117
119- // FIXME: putting different types of configuration objects in a heterogeneous list is pretty bad
120- Map <String , LinkedHashSet <AuthorizableConfigBean >> authorizablesMapfromConfig = (Map <String , LinkedHashSet <AuthorizableConfigBean >>) mergedConfigurations
121- .get (0 );
122- Map <String , Set <AceBean >> aceMapFromConfig = (Map <String , Set <AceBean >>) mergedConfigurations
123- .get (1 );
118+ Map <String , Set <AuthorizableConfigBean >> authorizablesMapfromConfig = acConfiguration .getAuthorizablesConfig ();
119+ Map <String , Set <AceBean >> aceMapFromConfig = acConfiguration .getAceConfig ();
124120
125121 if (aceMapFromConfig == null ) {
126122 String message = "ace config not found in YAML file! installation aborted!" ;
@@ -135,7 +131,7 @@ private void installConfigurationFromYamlList(
135131 installAces (history , session , aceMapFromConfig );
136132 }
137133
138- private Set <String > getAuthorizablesToRemoveAcesFor (Map <String , LinkedHashSet <AuthorizableConfigBean >> authorizablesMapfromConfig ) {
134+ private Set <String > getAuthorizablesToRemoveAcesFor (Map <String , Set <AuthorizableConfigBean >> authorizablesMapfromConfig ) {
139135 Set <String > authorizablesToRemoveAcesFor = new HashSet <String >(authorizablesMapfromConfig .keySet ());
140136 Set <String > authorizablesToBeMigrated = collectAuthorizablesToBeMigrated (authorizablesMapfromConfig );
141137 Collection <?> invalidAuthorizablesInConfig = CollectionUtils .intersection (authorizablesToRemoveAcesFor , authorizablesToBeMigrated );
@@ -149,10 +145,10 @@ private Set<String> getAuthorizablesToRemoveAcesFor(Map<String, LinkedHashSet<Au
149145 return authorizablesToRemoveAcesFor ;
150146 }
151147
152- private Set <String > collectAuthorizablesToBeMigrated (Map <String , LinkedHashSet <AuthorizableConfigBean >> authorizablesMapfromConfig ) {
148+ private Set <String > collectAuthorizablesToBeMigrated (Map <String , Set <AuthorizableConfigBean >> authorizablesMapfromConfig ) {
153149 Set <String > authorizablesToBeMigrated = new HashSet <String >();
154150 for (String principalStr : authorizablesMapfromConfig .keySet ()) {
155- LinkedHashSet <AuthorizableConfigBean > authorizableConfigBeans = authorizablesMapfromConfig .get (principalStr );
151+ Set <AuthorizableConfigBean > authorizableConfigBeans = authorizablesMapfromConfig .get (principalStr );
156152 for (AuthorizableConfigBean authorizableConfigBean : authorizableConfigBeans ) {
157153 String migrateFrom = authorizableConfigBean .getMigrateFrom ();
158154 if (StringUtils .isNotBlank (migrateFrom )) {
@@ -203,7 +199,7 @@ private void installAces(
203199 private void installAuthorizables (
204200 AcInstallationHistoryPojo history ,
205201 Set <AuthorizableInstallationHistory > authorizableHistorySet ,
206- Map <String , LinkedHashSet <AuthorizableConfigBean >> authorizablesMapfromConfig )
202+ Map <String , Set <AuthorizableConfigBean >> authorizablesMapfromConfig )
207203 throws RepositoryException , Exception {
208204 // --- installation of Authorizables from configuration ---
209205
@@ -265,7 +261,7 @@ public AcInstallationHistoryPojo execute() {
265261 String rootPath = getConfigurationRootPath ();
266262 Node rootNode = session .getNode (rootPath );
267263 Map <String , String > newestConfigurations = configFilesRetriever .getConfigFileContentFromNode (rootNode );
268- installNewConfigurations (session , history , newestConfigurations , authorizableInstallationHistorySet );
264+ installConfigurationFiles (session , history , newestConfigurations , authorizableInstallationHistorySet );
269265 } catch (AuthorizableCreatorException e ) {
270266 history .addError (e .toString ());
271267 // here no rollback of authorizables necessary since session wasn't
@@ -299,7 +295,7 @@ public AcInstallationHistoryPojo execute() {
299295
300296 /** Common entry point for JMX and install hook. */
301297 @ Override
302- public void installNewConfigurations (Session session , AcInstallationHistoryPojo history , Map <String , String > currentConfiguration ,
298+ public void installConfigurationFiles (Session session , AcInstallationHistoryPojo history , Map <String , String > configurationFileContentsByFilename ,
303299 Set <AuthorizableInstallationHistory > authorizableInstallationHistorySet )
304300 throws Exception {
305301
@@ -313,13 +309,14 @@ public void installNewConfigurations(Session session, AcInstallationHistoryPojo
313309 LOG .info (message );
314310 history .addMessage (message );
315311
316- if (currentConfiguration != null ) {
312+ if (configurationFileContentsByFilename != null ) {
317313
318- history .setConfigFileContentsByName (currentConfiguration );
314+ AcConfiguration acConfiguration = configurationMerger .getMergedConfigurations (configurationFileContentsByFilename , history ,
315+ configReader );
316+ history .setAcConfiguration (acConfiguration );
317+ history .setConfigFileContentsByName (configurationFileContentsByFilename );
319318
320- List mergedConfigurations = configurationMerger .getMergedConfigurations (currentConfiguration , history , configReader );
321-
322- installMergedConfigurations (history , session , authorizableInstallationHistorySet , mergedConfigurations );
319+ installMergedConfigurations (history , session , authorizableInstallationHistorySet , acConfiguration );
323320
324321 // if everything went fine (no exceptions), save the session
325322 // thus persisting the changed ACLs
@@ -352,7 +349,7 @@ private void installMergedConfigurations(
352349 AcInstallationHistoryPojo history ,
353350 Session session ,
354351 Set <AuthorizableInstallationHistory > authorizableInstallationHistorySet ,
355- List mergedConfigurations ) throws ValueFormatException ,
352+ AcConfiguration acConfiguration ) throws ValueFormatException ,
356353 RepositoryException , Exception {
357354
358355 String message = "Starting installation of merged configurations..." ;
@@ -366,9 +363,7 @@ private void installMergedConfigurations(
366363 AcHelper .ACE_ORDER_NONE ,
367364 dumpservice .getQueryExcludePaths ()).getAceDump ();
368365
369- installConfigurationFromYamlList (mergedConfigurations , history ,
370- session , authorizableInstallationHistorySet ,
371- repositoryDumpAceMap );
366+ installAcConfiguration (acConfiguration , history , session , authorizableInstallationHistorySet , repositoryDumpAceMap );
372367
373368 }
374369
@@ -603,9 +598,9 @@ public Set<String> getAllAuthorizablesFromConfig(Session session)
603598 AcInstallationHistoryPojo history = new AcInstallationHistoryPojo ();
604599 Node rootNode = session .getNode (configurationPath );
605600 Map <String , String > newestConfigurations = configFilesRetriever .getConfigFileContentFromNode (rootNode );
606- List mergedConfigurations = configurationMerger .getMergedConfigurations (
607- newestConfigurations , history , configReader );
608- return (( Map < String , Set < AceBean >>) mergedConfigurations . get ( 0 )). keySet () ;
601+ AcConfiguration acConfiguration = configurationMerger .getMergedConfigurations (newestConfigurations , history , configReader );
602+ Set < String > allAuthorizablesFromConfig = acConfiguration . getAceConfig (). keySet ( );
603+ return allAuthorizablesFromConfig ;
609604 }
610605
611606}
0 commit comments