示例#1
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.manager.GroupManager#setGroupBackgroundImage(cc.kune
  * .domain.Group, java.lang.String, java.lang.String)
  */
 @Override
 public void setGroupBackgroundImage(
     final Group group, final String backgroundFileName, final String mime) {
   clearGroupBackImage(group);
   group.setBackgroundImage(backgroundFileName);
   group.setBackgroundMime(mime);
 }
示例#2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.manager.GroupManager#clearGroupBackImage(cc.kune.domain
  * .Group)
  */
 @Override
 public void clearGroupBackImage(final Group group) {
   final String file = group.getBackgroundImage();
   if (file != null) {
     fileManager.rm(FileUtils.groupToDir(group.getShortName()), file);
   }
   group.setBackgroundImage(null);
   group.setBackgroundMime(null);
 }
示例#3
0
 /*
  * (non-Javadoc)
  *
  * @see cc.kune.core.server.manager.GroupManager#update(java.lang.Long,
  * cc.kune.core.shared.dto.GroupDTO)
  */
 @Override
 public Group update(final Long groupId, final GroupDTO groupDTO) {
   final Group group = find(groupId);
   final String shortName = groupDTO.getShortName();
   final String longName = groupDTO.getLongName();
   if (!longName.equals(group.getLongName())) {
     checkIfLongNameAreInUse(longName);
     group.setLongName(longName);
   }
   if (!shortName.equals(group.getShortName())) {
     checkIfShortNameAreInUse(shortName);
     final String oldDir =
         kuneProperties.get(KuneProperties.UPLOAD_LOCATION)
             + FileUtils.groupToDir(group.getShortName());
     final String newDir =
         kuneProperties.get(KuneProperties.UPLOAD_LOCATION) + FileUtils.groupToDir(shortName);
     if (fileManager.exists(oldDir)) {
       if (fileManager.exists(newDir)) {
         throw new DefaultException("Destination group directory exists");
       }
       fileManager.mv(oldDir, newDir);
     }
     group.setShortName(shortName);
   }
   group.setGroupType(groupDTO.getGroupType());
   setAdmissionType(group);
   final boolean isClosed = group.getGroupType().equals(GroupType.CLOSED);
   setSocialNetwork(group, getDefGroupMode(isClosed), getDefSNVisibility(isClosed));
   persist(group);
   snCache.expire(group);
   return group;
 }
示例#4
0
 /** Test tool configuration. */
 @Test
 public void testToolConfiguration() {
   assertNotNull(defaultGroup);
   final ToolConfiguration docToolConfig = defaultGroup.getToolConfiguration(TOOL_NAME);
   assertNotNull(docToolConfig);
   assertTrue(docToolConfig.isEnabled());
   // final ToolConfiguration chatToolConfig =
   // defaultGroup.getToolConfiguration(ChatConstants.NAME);
   // assertNotNull(chatToolConfig);
   // assertTrue(chatToolConfig.isEnabled());
   final List<String> enabledTools = groupManager.findEnabledTools(defaultGroup.getId());
   assertNotNull(enabledTools);
   assertTrue(enabledTools.size() > 0);
   assertNotNull(containerManager.getTrashFolder(defaultGroup).getId());
 }
示例#5
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);
 }
示例#6
0
 /** Test default document content. */
 @Test
 public void testDefaultDocumentContent() {
   final Content content = defaultGroup.getDefaultContent();
   assertEquals(TYPE_DOCUMENT, content.getTypeId());
   final Container rootDocFolder = content.getContainer();
   assertEquals(true, rootDocFolder.isRoot());
 }
示例#7
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.manager.GroupManager#changeDefLicense(cc.kune.domain
  * .User, cc.kune.domain.Group, java.lang.String)
  */
 @Override
 public void changeDefLicense(final User user, final Group group, final String licName) {
   final License license = licenseFinder.findByShortName(licName);
   if (license == null) {
     throw new ServerManagerException("Unknown license");
   }
   group.setDefaultLicense(license);
 }
示例#8
0
 /**
  * Sets the social network.
  *
  * @param group the group
  * @param publicVisibility the public visibility
  * @param snVisibility the sn visibility
  * @return the social network
  */
 private SocialNetwork setSocialNetwork(
     final Group group,
     final GroupListMode publicVisibility,
     final SocialNetworkVisibility snVisibility) {
   final SocialNetwork network = group.getSocialNetwork();
   final AccessLists lists = network.getAccessLists();
   lists.getViewers().setMode(publicVisibility);
   network.setVisibility(snVisibility);
   return network;
 }
示例#9
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;
  }
示例#10
0
 /**
  * Inits the social network.
  *
  * @param group the group
  * @param userGroup the user group
  * @param publicVisibility the public visibility
  * @param snVisibility the sn visibility
  */
 private void initSocialNetwork(
     final Group group,
     final Group userGroup,
     final GroupListMode publicVisibility,
     final SocialNetworkVisibility snVisibility) {
   final SocialNetwork network = setSocialNetwork(group, publicVisibility, snVisibility);
   if (!group.getGroupType().equals(GroupType.ORPHANED_PROJECT)) {
     network.addAdmin(userGroup);
     network.getAccessLists().getEditors().setMode(GroupListMode.NOBODY);
   }
 }
示例#11
0
  /**
   * Correct member.
   *
   * @param user the user
   * @param group the group
   * @param memberType the member type
   * @return true, if successful
   */
  public static boolean correctMember(
      final User user, final Group group, final AccessRol memberType) {

    final AccessRights accessRights =
        rightsService.get(user, group.getSocialNetwork().getAccessLists());

    switch (memberType) {
      case Administrator:
        return accessRights.isAdministrable();
      case Editor:
        return accessRights.isEditable();
      default:
        return accessRights.isVisible();
    }
  }
示例#12
0
 /**
  * Sets the admission type.
  *
  * @param group the new admission type
  */
 private void setAdmissionType(final Group group) {
   final GroupType groupType = group.getGroupType();
   if (groupType.equals(GroupType.COMMUNITY)) {
     group.setAdmissionType(AdmissionType.Open);
   } else {
     if (groupType.equals(GroupType.CLOSED)) {
       group.setAdmissionType(AdmissionType.Closed);
     } else if (groupType.equals(GroupType.ORGANIZATION)) {
       group.setAdmissionType(AdmissionType.Moderated);
     } else if (groupType.equals(GroupType.PROJECT)) {
       group.setAdmissionType(AdmissionType.Moderated);
     } else if (groupType.equals(GroupType.ORPHANED_PROJECT)) {
       group.setAdmissionType(AdmissionType.Open);
     }
   }
 }
示例#13
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();
   }
 }
示例#14
0
 /** Test default content and licenses. */
 @Test
 public void testDefaultContentAndLicenses() {
   assertNotNull(defaultGroup.getDefaultContent());
   assertTrue(licenseManager.getAll().size() > 0);
   assertNotNull(defaultGroup.getDefaultLicense());
 }
示例#15
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);
 }
示例#16
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.server.manager.GroupManager#changeWsTheme(cc.kune.domain.User,
  * cc.kune.domain.Group, java.lang.String)
  */
 @Override
 public void changeWsTheme(final User user, final Group group, final String theme)
     throws AccessViolationException {
   // TODO: check theme
   group.setWorkspaceTheme(theme);
 }