cancel
Showing results for 
Search instead for 
Did you mean: 

Error while bootstrapping sites and groups programmatically

mpch
Champ in-the-making
Champ in-the-making
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 !
2 REPLIES 2

kaynezhang
World-Class Innovator
World-Class Innovator
1.Check if an group exists you should add "GROUP_" prefix
 this.authorityService.authorityExists("GROUP_"+shortGroupName) 

2.You log conatins " org.alfresco.repo.site.SiteDoesNotExistException" ,so make sure your site exists.

muralidharand
Star Contributor
Star Contributor
Hi,
Just for testing, don't add any users / groups and see the does system getting bootstrapped or not?