Hello,

I'm trying to activate users from my code and can't seem to get it right.
My problem is that I add a user, add some groups to it and then activate it, 
but upon activation the user on the public site does not retain the groups 
assigned to it.
I have to mention that the groups have been created and activated beforehand 
and, if I try the same operation from the interface, it works.

My code looks like this:

public void activate(Content content, String repoName, String 
activatorUserName) //repoName == "users", content == the node(user) to activate
{
          // get parent path
        String parentPath = 
StringUtils.substringBeforeLast(content.getHandle(), "/");
        if (StringUtils.isEmpty(parentPath))
        {
            parentPath = "/";
        }
          log.debug("Activate - parentPath: " + parentPath);
          String wkspaceName = ContentRepository.getDefaultWorkspace(repoName);
        log.debug("Activate - wkspaceName: " + wkspaceName);
        // instantiate the user with activation permissions
        UserManager usrMgr = Security.getUserManager();
        User activatorUser = usrMgr.getUser(activatorUserName); 
//activatorUserName == "superuser"
        // initialize syndicator and activate
        SimpleSyndicator ss = new SimpleSyndicator();
        ss.init(activatorUser, repoName, wkspaceName, new Rule());
          ss.activate(parentPath, content);
}

The result is something like this (from the users repo):

/system/u4
/system/u4/company=CompanyName
/system/u4/name=u4
/system/u4/jcr:uuid=3480fbc8-bc19-4f77-98a4-09b0bc60ce38
/system/u4/lastaccess=2010-01-08T13:05:08.493+02:00
/system/u4/jcr:mixinTypes=mix:lockable

/system/u4/[email protected]
/system/u4/jcr:created=2010-01-08T13:05:08.586+02:00
/system/u4/jcr:primaryType=mgnl:user
/system/u4/language=fr
/system/u4/firstName=Ovidiu
/system/u4/pswd=dTRwd2Q=
/system/u4/lastName=Chirita
/system/u4/country=c
/system/u4/MetaData
/system/u4/MetaData/jcr:uuid=4ba92e99-ab3e-4257-ab74-2b1c2c27d109
/system/u4/MetaData/jcr:created=2010-01-08T13:05:08.586+02:00
/system/u4/MetaData/jcr:primaryType=mgnl:metadata

Instead of:

/system/u3
/system/u3/company=CompanyName
/system/u3/name=u3
/system/u3/jcr:uuid=90cb2f27-3f27-49ca-a083-39c378dc0704
/system/u3/lastaccess=2010-01-08T13:01:35.204+02:00
/system/u3/jcr:mixinTypes=mix:lockable

/system/u3/[email protected]
/system/u3/jcr:created=2010-01-08T13:02:42.190+02:00
/system/u3/jcr:primaryType=mgnl:user
/system/u3/language=fr
/system/u3/firstName=Ovidiu
/system/u3/pswd=dTNwd2Q=
/system/u3/lastName=Chirita
/system/u3/country=C
/system/u3/MetaData

/system/u3/MetaData/jcr:uuid=d790f57e-ed1a-44b0-99ce-8b2bc1832574
/system/u3/MetaData/jcr:created=2010-01-08T13:02:42.190+02:00
/system/u3/MetaData/jcr:primaryType=mgnl:metaData


/system/u3/MetaData/mgnl:activatorid=superuser
/system/u3/MetaData/mgnl:authorid=superuser
/system/u3/MetaData/mgnl:title=
/system/u3/MetaData/mgnl:lastaction=2010-01-08T13:02:39.652+02:00
/system/u3/MetaData/mgnl:creationdate=2010-01-08T13:01:34.960+02:00

/system/u3/MetaData/mgnl:activated=false
/system/u3/MetaData/mgnl:lastmodified=2010-01-08T13:01:34.960+02:00

/system/u3/groups
/system/u3/groups/jcr:uuid=01800546-a9f2-4f0f-b26a-e9f73ab733fa
/system/u3/groups/jcr:mixinTypes=mix:lockable

/system/u3/groups/0=3045e661-eb7c-4633-a465-6d4ba7a3369d
/system/u3/groups/jcr:created=2010-01-08T13:02:42.194+02:00
/system/u3/groups/jcr:primaryType=mgnl:contentNode
/system/u3/groups/MetaData
/system/u3/groups/MetaData/mgnl:activatorid=superuser
/system/u3/groups/MetaData/mgnl:lastaction=2010-01-08T13:02:39.653+02:00
/system/u3/groups/MetaData/jcr:uuid=1c3f24a8-f1ca-4d73-b35e-afc92a20a3d4
/system/u3/groups/MetaData/mgnl:creationdate=2010-01-08T13:01:35.241+02:00
/system/u3/groups/MetaData/jcr:created=2010-01-08T13:02:42.194+02:00
/system/u3/groups/MetaData/mgnl:activated=false
/system/u3/groups/MetaData/jcr:primaryType=mgnl:metaData

Thanks in advance for any suggestions,
Ovidiu

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to