WikiSecurityEvent se = (WikiSecurityEvent)event;
if ( se.getType() == WikiSecurityEvent.PROFILE_NAME_CHANGED )
{
UserProfile[] profiles = (UserProfile[])se.getTarget();
Principal[] oldPrincipals = new Principal[]
{ new WikiPrincipal( profiles[0].getLoginName() ),
new WikiPrincipal( profiles[0].getFullname() ),
new WikiPrincipal( profiles[0].getWikiName() ) };
Principal newPrincipal = new WikiPrincipal( profiles[1].getFullname() );
// Examine each page ACL
try
{
int pagesChanged = 0;
Collection pages = getAllPages();
for ( Iterator it = pages.iterator(); it.hasNext(); )
{
WikiPage page = (WikiPage)it.next();
boolean aclChanged = changeAcl( page, oldPrincipals, newPrincipal );
if ( aclChanged )
{
// If the Acl needed changing, change it now
try
{
m_engine.getAclManager().setPermissions( page, page.getAcl() );
}
catch ( WikiSecurityException e )
{
log.error( "Could not change page ACL for page " + page.getName() + ": " + e.getMessage(), e );
}
pagesChanged++;
}
}
log.info( "Profile name change for '" + newPrincipal.toString() +
"' caused " + pagesChanged + " page ACLs to change also." );
}
catch ( ProviderException e )
{
// Oooo! This is really bad...