@@ -375,27 +375,18 @@ private Authorizable createNewAuthorizable(
375375
376376 Authorizable newAuthorizable = null ;
377377
378- if (StringUtils .isNotEmpty (principalConfigBean .getExternalId ())) {
379- // external group
380- if (!isGroup ) {
381- throw new IllegalStateException ("External IDs are only supported for groups (" + principalConfigBean .getPrincipalID ()
382- + " is using '" + principalConfigBean .getExternalId () + "')" );
383- }
384- if (externalGroupCreatorService == null ) {
385- throw new IllegalStateException ("External IDs are not availabe for your AEM version ("
386- + principalConfigBean .getPrincipalID () + " is using '" + principalConfigBean .getExternalId () + "')" );
387- }
388- newAuthorizable = externalGroupCreatorService .createGroupWithExternalId (userManager , principalConfigBean , status ,
389- authorizableInstallationHistory , vf , principalMapFromConfig , session );
390- LOG .info ("Successfully created new external group: {}" , principalId );
391- } else if (isGroup ) {
392- // internal group
378+ if (isGroup ) {
393379 newAuthorizable = createNewGroup (userManager , principalConfigBean ,
394380 status , authorizableInstallationHistory , vf ,
395381 principalMapFromConfig , session );
396382 LOG .info ("Successfully created new group: {}" , principalId );
397383 } else {
398- // internal user
384+ if (StringUtils .isNotEmpty (principalConfigBean .getExternalId ())) {
385+ throw new IllegalStateException ("External IDs are not supported for users (" + principalConfigBean .getPrincipalID ()
386+ + " is using '" + principalConfigBean .getExternalId ()
387+ + "') - use a ootb sync handler to have users automatically created." );
388+ }
389+
399390 newAuthorizable = createNewUser (userManager , principalConfigBean , status , authorizableInstallationHistory , vf ,
400391 principalMapFromConfig , session );
401392 LOG .info ("Successfully created new user: {}" , principalId );
@@ -524,13 +515,27 @@ private Authorizable createNewGroup(
524515 // create new Group
525516 Group newGroup = null ;
526517 try {
527- PrincipalImpl principalForNewGroup = new PrincipalImpl (groupID );
528- if (StringUtils .isNotBlank (intermediatePath )) {
529- newGroup = userManager .createGroup (principalForNewGroup , intermediatePath );
518+
519+ if (StringUtils .isNotEmpty (principalConfigBean .getExternalId ())) {
520+
521+ if (externalGroupCreatorService == null ) {
522+ throw new IllegalStateException ("External IDs are not availabe for your AEM version ("
523+ + principalConfigBean .getPrincipalID () + " is using '" + principalConfigBean .getExternalId () + "')" );
524+ }
525+ newGroup = (Group ) externalGroupCreatorService .createGroupWithExternalId (userManager , principalConfigBean , status ,
526+ authorizableInstallationHistory , vf , principalMapFromConfig , session );
527+ LOG .info ("Successfully created new external group: {}" , groupID );
530528 } else {
531- newGroup = userManager .createGroup (principalForNewGroup );
529+
530+ PrincipalImpl principalForNewGroup = new PrincipalImpl (groupID );
531+ if (StringUtils .isNotBlank (intermediatePath )) {
532+ newGroup = userManager .createGroup (principalForNewGroup , intermediatePath );
533+ } else {
534+ newGroup = userManager .createGroup (principalForNewGroup );
535+ }
532536 }
533537
538+
534539 } catch (AuthorizableExistsException e ) {
535540 LOG .warn ("Group {} already exists in system!" , groupID );
536541 newGroup = (Group ) userManager .getAuthorizable (groupID );
0 commit comments