Package info.galleria.service.ejb

Source Code of info.galleria.service.ejb.GroupServiceImpl

package info.galleria.service.ejb;

import info.galleria.domain.Group;
import info.galleria.service.jpa.GroupRepository;

import javax.ejb.*;

/**
* Session Bean implementation class GroupServiceImpl
*/
@Stateless
@EJB(name = "java:global/galleria/galleria-ejb/GroupService", beanInterface = GroupService.class)
public class GroupServiceImpl implements GroupService
{

  private static final String REGISTERED_USERS_GROUP_NAME = "RegisteredUsers";

  @EJB
  private GroupRepository groupRepository;

  /**
   * @see GroupService#getOrCreateRegisteredUsersGroup()
   */
  public Group getOrCreateRegisteredUsersGroup()
  {
    Group defaultGroup = groupRepository.findById(REGISTERED_USERS_GROUP_NAME);
    if (defaultGroup == null)
    {
      defaultGroup = createRegisteredUsersGroup();
      return defaultGroup;
    }
    else
    {
      return defaultGroup;
    }
  }

  private Group createRegisteredUsersGroup()
  {
    Group group = new Group(REGISTERED_USERS_GROUP_NAME);
    groupRepository.create(group);
    return group;
  }

}
TOP

Related Classes of info.galleria.service.ejb.GroupServiceImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.