Example #1
0
  /*
   * (non-Javadoc)
   *
   * @see
   * cc.kune.core.server.manager.GroupManager#createUserGroup(cc.kune.domain
   * .User, boolean)
   */
  @Override
  public Group createUserGroup(final User user, final boolean wantPersonalHomepage)
      throws GroupShortNameInUseException, EmailAddressInUseException {
    final String defaultSiteWorkspaceTheme = kuneProperties.get(KuneProperties.WS_THEMES_DEF);
    final License licenseDef = licenseManager.getDefLicense();
    final Group userGroup =
        new Group(user.getShortName(), user.getName(), licenseDef, GroupType.PERSONAL);
    User userSameEmail = null;
    try {
      userSameEmail = userFinder.findByEmail(user.getEmail());
    } catch (final NoResultException e) {
      // Ok, no more with this email
    }
    if (userSameEmail != null) {
      throw new EmailAddressInUseException();
    }
    userGroup.setAdmissionType(AdmissionType.Closed);
    userGroup.setWorkspaceTheme(defaultSiteWorkspaceTheme);
    userGroup.setDefaultContent(null);
    user.setUserGroup(userGroup);
    initSocialNetwork(userGroup, userGroup, GroupListMode.EVERYONE, SocialNetworkVisibility.anyone);

    final String title = i18n.t("[%s] Bio", user.getName());
    final String body = i18n.t("This is [%s]'s bio, currently empty", user.getName());
    try {
      initGroup(
          user,
          userGroup,
          wantPersonalHomepage
              ? serverToolRegistry.getToolsRegisEnabledForUsers()
              : ServerToolRegistry.emptyToolList,
          title,
          body);
      super.persist(user, User.class);
    } catch (final PersistenceException e) {
      if (e.getCause() instanceof ConstraintViolationException) {
        throw new GroupShortNameInUseException();
      }
      throw e;
    }
    return userGroup;
  }
Example #2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.manager.GroupManager#setDefaultContent(java.lang.String
  * , cc.kune.domain.Content)
  */
 @Override
 public void setDefaultContent(final String groupShortName, final Content content) {
   final Group group = findByShortName(groupShortName);
   group.setDefaultContent(content);
 }