// Add new community to communities (or change its read/write permissions)
if (addCommunity || changedReadWriteAccess)
{
if (addCommunity) {
ShareCommunityPojo cp = new ShareCommunityPojo();
cp.set_id(new ObjectId(communityIdStr));
cp.setName(getCommunity(new ObjectId(communityIdStr)).getName());
cp.setComment(comment);
communities.add(cp);
// Endorse if applicable...
if (null == share.getEndorsed()) { // legacy case
share.setEndorsed(new HashSet<ObjectId>());
share.getEndorsed().add(share.getOwner().get_id()); // user's personal community always endorsed
}//TESTED
boolean bAdmin = RESTTools.adminLookup(ownerIdStr, false); // (can be admin-on-request and not enabled, the bar for endorsing is pretty low)
if (bAdmin || SocialUtils.isOwnerOrModeratorOrContentPublisher(communityIdStr, ownerIdStr)) {
share.getEndorsed().add(cp.get_id());
}
//TESTED - adding as admin/community owner, not adding if not
}
share.setModified(new Date());