Example #1
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.content.CreationService#createFolder(cc.kune.domain
  * .Group, java.lang.Long, java.lang.String, cc.kune.domain.I18nLanguage,
  * java.lang.String)
  */
 @Override
 public Container createFolder(
     final Group group,
     final Long parentFolderId,
     final String name,
     final I18nLanguage language,
     final String typeId) {
   final Container parent = containerManager.find(parentFolderId);
   final String toolName = parent.getToolName();
   tools.get(toolName).checkTypesBeforeContainerCreation(parent.getTypeId(), typeId);
   final Container child = containerManager.createFolder(group, parent, name, language, typeId);
   tools.get(toolName).onCreateContainer(child, parent);
   return child;
 }
Example #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * cc.kune.core.server.content.CreationService#createContent(java.lang.String,
   * java.lang.String, cc.kune.domain.User, cc.kune.domain.Container,
   * java.lang.String)
   */
  @Override
  public Content createContent(
      final String title,
      final String body,
      final User user,
      final Container container,
      final String typeId,
      final WaveRef waveRef,
      final boolean publishExistingWave) {
    final ServerTool tool = tools.get(container.getToolName());
    tool.checkTypesBeforeContentCreation(container.getTypeId(), typeId);
    final URL gagdetUrl =
        tool instanceof ServerToolWithWaveGadget
            ? ((ServerToolWithWaveGadget) tool).getGadgetUrl()
            : KuneWaveService.WITHOUT_GADGET;
    final String[] otherParticipants =
        tool instanceof ServerToolWithWave
            ? ((ServerToolWithWave) tool).getNewContentAdditionalParts(container)
            : NO_MORE_PARTICIPANTS;

    final Content content =
        contentManager.createContent(
            title,
            body,
            publishExistingWave,
            waveRef,
            user,
            container,
            typeId,
            gagdetUrl,
            NO_PROPERTIES,
            otherParticipants);
    tool.onCreateContent(content, container);
    return content;
  }
Example #3
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.content.CreationService#copyContent(cc.kune.domain.
  * User, cc.kune.domain.Container, cc.kune.domain.Content)
  */
 @Override
 public Content copyContent(
     final User user, final Container container, final Content contentToCopy) {
   final ServerTool tool = tools.get(container.getToolName());
   final Content content = contentManager.copyContent(user, container, contentToCopy);
   tool.onCreateContent(content, container);
   return content;
 }
Example #4
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.manager.GroupManager#setToolEnabled(cc.kune.domain.
  * User, java.lang.String, java.lang.String, boolean)
  */
 @Override
 public void setToolEnabled(
     final User userLogged, final String groupShortName, final String tool, final boolean enabled)
     throws ToolIsDefaultException {
   final Group group = findByShortName(groupShortName);
   if (group.getDefaultContent().getStateToken().getTool().equals(tool) && !enabled) {
     throw new ToolIsDefaultException();
   }
   ToolConfiguration toolConfiguration = group.getToolConfiguration(tool);
   if (toolConfiguration == null) {
     toolConfiguration =
         serverToolRegistry.get(tool).initGroup(userLogged, group).getToolConfiguration(tool);
   }
   toolConfiguration.setEnabled(enabled);
 }
Example #5
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 #6
0
 /**
  * Inits the group.
  *
  * @param user the user
  * @param group the group
  * @param toolsToEnable the tools to enable
  * @param vars the vars
  * @throws GroupShortNameInUseException the group short name in use exception
  */
 private void initGroup(
     final User user, final Group group, final List<String> toolsToEnable, final Object... vars)
     throws GroupShortNameInUseException {
   try {
     persist(group);
   } catch (final IllegalStateException e) {
     e.printStackTrace();
   } catch (final PersistenceException e) {
     if (e.getCause() instanceof ConstraintViolationException) {
       throw new GroupShortNameInUseException();
     }
     throw e;
   }
   for (final ServerTool tool : serverToolRegistry.all()) {
     if (toolsToEnable.contains(tool.getName())) {
       tool.initGroup(user, group, vars);
     }
   }
   // Init always the trash
   initTrash(group);
 }
Example #7
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.manager.GroupManager#createGroup(cc.kune.domain.Group,
  * cc.kune.domain.User, java.lang.String)
  */
 @Override
 public Group createGroup(final Group group, final User user, final String publicDescrip)
     throws GroupShortNameInUseException, GroupLongNameInUseException, UserMustBeLoggedException {
   checkIfShortNameAreInUse(group.getShortName());
   checkIfLongNameAreInUse(group.getLongName());
   final String defaultSiteWorkspaceTheme = kuneProperties.get(KuneProperties.WS_THEMES_DEF);
   if (User.isKnownUser(user)) {
     setAdmissionType(group);
     final String licName = group.getDefaultLicense().getShortName();
     final License license = licenseFinder.findByShortName(licName);
     group.setDefaultLicense(license);
     group.setWorkspaceTheme(defaultSiteWorkspaceTheme);
     final boolean isClosed = group.getGroupType().equals(GroupType.CLOSED);
     initSocialNetwork(
         group, user.getUserGroup(), getDefGroupMode(isClosed), getDefSNVisibility(isClosed));
     final String title = i18n.t("About [%s]", group.getLongName());
     initGroup(
         user, group, serverToolRegistry.getToolsRegisEnabledForGroups(), title, publicDescrip);
     snCache.expire(user.getUserGroup());
     return group;
   } else {
     throw new UserMustBeLoggedException();
   }
 }