public Group createGroup(String name) throws GroupAlreadyExistsException, GroupNameInvalidException {
        final Lock lock = groupCache.getLock(name);
        lock.lock();
        try {
            Group newGroup;
            try {
                getGroup(name);
                // The group already exists since now exception, so:
                throw new GroupAlreadyExistsException();
            }
            catch (GroupNotFoundException unfe) {
                // The group doesn't already exist, so we can create a new group
                newGroup = provider.createGroup(name);

                createGroupPostProcess(newGroup);
            }
            return newGroup;
        } finally {
            lock.unlock();
        }
    }
Factory method for creating a new Group. A unique name is the only required field.

@param name the new and unique name for the group.
@return a new Group.
@throws GroupAlreadyExistsException if the group name already exists in the system.
xmppserver/src/main/java/org/jivesoftware/openfire/group/GroupManager.java