EN · DE · RU · FR · ES

#492: LdapGroupDao.java

projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java Java class, projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java 207 lines · 127 code · 62 comments · 18 blank
Purpose: Source file: projectforge/business/ldap/LdapGroupDao.java. LdapGroupDao.java is part of the ProjectForge open-source project management application.

Source (first 100 lines)

/////////////////////////////////////////////////////////////////////////////
//
// Project ProjectForge Community Edition
//         www.projectforge.org
//
// Copyright (C) 2001-2026 Micromata GmbH, Germany (www.micromata.com)
//
// ProjectForge is dual-licensed.
//
// This community edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation; version 3 of the License.
//
// This community edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
// Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, see http://www.gnu.org/licenses/.
//
/////////////////////////////////////////////////////////////////////////////

package org.projectforge.business.ldap;

import org.apache.commons.collections4.CollectionUtils;
import org.projectforge.framework.utils.NumberHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import java.util.List;

/**
 * @author Kai Reinhard (k.reinhard@micromata.de)
 */
@Service
public class LdapGroupDao extends LdapDao<String, LdapGroup>
{
  private static final String[] ADDITIONAL_OBJECT_CLASSES = { "top" };

  private static final String[] ADDITIONAL_OBJECT_CLASSES_WITH_POSIX_SUPPORT = { "top", "posixGroup" };

  private static final String NONE_UNIQUE_MEMBER_ID = "cn=none";

  @Autowired
  GroupDOConverter groupDOConverter;

  @Autowired
  LdapUserDao ldapUserDao;

  /**
   * Since member of groups can't be null, "cn=none" if the group has no real members.
   *
   * @param group
   * @return
   */
  public static boolean hasMembers(final LdapGroup group)
  {
    if (group.getMembers() == null || group.getMembers().size() == 0) {
      return false;
    }
    if (group.getMembers().size() > 1) {
      return true;
    }
    return !group.getMembers().iterator().next().startsWith(NONE_UNIQUE_MEMBER_ID);
  }

  /**
   * @see org.projectforge.business.ldap.LdapDao#getObjectClass()
   */
  @Override
  protected String getObjectClass()
  {
    return "groupOfUniqueNames";
  }

  /**
   * @see org.projectforge.business.ldap.LdapDao#getAdditionalObjectClasses()
   */
  @Override
  protected String[] getAdditionalObjectClasses()
  {
    throw new UnsupportedOperationException("Call getAdditionalObjectClasses(LdapGroup) instead.");
  }

  /**
   * @see org.projectforge.business.ldap.LdapDao#getAdditionalObjectClasses(org.projectforge.business.ldap.LdapObject)
   */
  @Override
  protected String[] getAdditionalObjectClasses(final LdapGroup obj)
  {
    final boolean posixAccount = ldapUserDao.isPosixAccountsConfigured()
        && !groupDOConverter.isPosixAccountValuesEmpty(obj);
    if (posixAccount) {
      return ADDITIONAL_OBJECT_CLASSES_WITH_POSIX_SUPPORT;
    }

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
5bafe7941 @Repository -> @Service. @Transactional-Annotations removed.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.

868d6abb7

2025 -> 2026
868d6abb75cd191a892911ac8e45058932cf9074
diff --git a/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java b/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
index ab520a81a..bdeccbf49 100644
--- a/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
+++ b/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
@@ -3,7 +3,7 @@
 // Project ProjectForge Community Edition
 //         www.projectforge.org
 //
-// Copyright (C) 2001-2025 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2026 Micromata GmbH, Germany (www.micromata.com)
 //
 // ProjectForge is dual-licensed.
 //

63081666f

Source file headers: 2024-> 2025.
63081666f620fb87315f01b817e560e0b2f6a33a
diff --git a/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java b/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
index 51a2f4e7d..ab520a81a 100644
--- a/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
+++ b/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
@@ -3,7 +3,7 @@
 // Project ProjectForge Community Edition
 //         www.projectforge.org
 //
-// Copyright (C) 2001-2024 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2025 Micromata GmbH, Germany (www.micromata.com)
 //
 // ProjectForge is dual-licensed.
 //

5bafe7941

@Repository -> @Service. @Transactional-Annotations removed.
5bafe7941698989d3f2bd6d3df8065708b1f8941
diff --git a/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java b/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
index f5aadf19f..51a2f4e7d 100644
--- a/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
+++ b/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
@@ -26,7 +26,7 @@ package org.projectforge.business.ldap;
 import org.apache.commons.collections4.CollectionUtils;
 import org.projectforge.framework.utils.NumberHelper;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Repository;
+import org.springframework.stereotype.Service;
 
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
@@ -37,7 +37,7 @@ import java.util.List;
 /**
  * @author Kai Reinhard (k.reinhard@micromata.de)
  */
-@Repository
+@Service
 public class LdapGroupDao extends LdapDao<String, LdapGroup>
 {
   private static final String[] ADDITIONAL_OBJECT_CLASSES = { "top" };

b6092df09

Copyright 2023 -> 2024
b6092df0927c4a3b161e888445f31dcab57493f2
diff --git a/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java b/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
index 649494d14..f5aadf19f 100644
--- a/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
+++ b/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
@@ -3,7 +3,7 @@
 // Project ProjectForge Community Edition
 //         www.projectforge.org
 //
-// Copyright (C) 2001-2023 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2024 Micromata GmbH, Germany (www.micromata.com)
 //
 // ProjectForge is dual-licensed.
 //

ab45d51fa

Copyright 2001-2022 -> 2001-2023.
ab45d51fa419ede6174b31d69987f96d4b841ff9
diff --git a/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java b/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
index 2c057c118..649494d14 100644
--- a/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
+++ b/projectforge-business/src/main/java/org/projectforge/business/ldap/LdapGroupDao.java
@@ -3,7 +3,7 @@
 // Project ProjectForge Community Edition
 //         www.projectforge.org
 //
-// Copyright (C) 2001-2022 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2023 Micromata GmbH, Germany (www.micromata.com)
 //
 // ProjectForge is dual-licensed.
 //