On Mon, 2010-03-08 at 11:19 +0100, Ovidiu Chirita wrote:
> 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);
> }
Looks alright ... almost ... Personally, I would not create new
syndicator but rather get one from the Factory/Components. Also I would
probably try to avoid having to do anything with the syndicator directly
at all, but use the ActivationCommand instead.
>
> The result is something like this (from the users repo):
Well, that's nice but not saying much. What is the difference between
such user on the author and on public? Is there any difference?
My best guess is that the user used to activate doesn't see all the
subnodes of the activated user node and therefore can't activate all of
them. Are you executing this piece of code in system context?
> /system/u3/groups/0=3045e661-eb7c-4633-a465-6d4ba7a3369d
As far as I can tell from the export there is only one group assigned,
but as to whether this is expected or not, it's up to you to know. Is
this the uuid of the group you have assigned? If so then that info was
not lost during activation and you need to look for the problem
elsewhere.
Jan
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------