AnsweredAssumed Answered

Error while bootstrapping sites and groups programmatically

Question asked by mpch on Jun 12, 2014
Latest reply on Jun 13, 2014 by muralidharand
Hi,

I'm running into a problem trying to bootstrap various data on my Alfresco installation. I'm using the Alfresco All in One archetype with little to no modifications but the bootstrap and a bit of custom modeling.
The problem occurs if I try to set a site membership on a group. Here is what I'm doing :


AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

final SiteInfo site = this.siteService.createSite(shortSiteName, shortSiteName, shortSiteName,
        null, SiteVisibility.PRIVATE);

AuthenticationUtil.setRunAsUser(AuthenticationUtil.getSystemUserName());

final Set<String> zones = new HashSet<String>();
zones.add(AuthorityService.ZONE_APP_DEFAULT);

if (!this.authorityService.authorityExists(shortGroupName)) {
   final String groupAlf = this.authorityService.createAuthority(AuthorityType.GROUP, shortGroupName,
           groupName, zones);
   if (this.siteService.canAddMember(site.getShortName(), groupAlf, SiteModel.SITE_COLLABORATOR)) {
       this.siteService.setMembership(site.getShortName(), groupAlf, SiteModel.SITE_COLLABORATOR);
       this.logger.info("Was group added to site ? -> " + this.siteService.isMember(site.getShortName(), groupAlf));
   }
}

// Inserting contents.acp data …


Creating the site and the group do work if I do not set the membership (I can test it just fine through Share). The problem starts if I try to set a membership between the group and the site (as described above).

The canAddMember and isMember methods from siteService both return true, leading me to believe everything went OK, but looking further into the log, in the last messages before startup, I get these message :


2014-06-12 19:54:30,176  ERROR [activities.feed.FeedTaskProcessor] [DefaultScheduler_Worker-6] Skipping activity post 1 since failed to get recipients: java.lang.Exception: Failed to get site members: org.alfresco.repo.site.SiteDoesNotExistException: 05120021 Le site MySite n'existe pas. (MySite doesn't exist)
2014-06-12 19:54:30,185  ERROR [activities.feed.FeedTaskProcessor] [DefaultScheduler_Worker-6] Skipping activity post 2 since failed to get recipients: java.lang.Exception: Failed to get followers: java.lang.IllegalArgumentException: User does not exist!
2014-06-12 19:54:30,186  ERROR [activities.feed.FeedTaskProcessor] [DefaultScheduler_Worker-6] Skipping activity post 3 since failed to get recipients: java.lang.Exception: Failed to get followers: java.lang.IllegalArgumentException: User does not exist!


After startup, logging into share result in an internal server error and my site isn't available.

I'm kind of stuck on this one since I'm only using standard functionnality of Alfresco, the code seems valid and yet adding a simple membership seems to break everything.

Any help would be welcomed.

Thanks !

Outcomes