Example usage for com.liferay.portal.kernel.service TeamLocalServiceUtil addTeam

List of usage examples for com.liferay.portal.kernel.service TeamLocalServiceUtil addTeam

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service TeamLocalServiceUtil addTeam.

Prototype

public static com.liferay.portal.kernel.model.Team addTeam(long userId, long groupId, String name,
        String description, ServiceContext serviceContext)
        throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

NOTE FOR DEVELOPERS: Never modify or reference this interface directly.

Usage

From source file:com.liferay.exportimport.lar.PermissionImporter.java

License:Open Source License

protected Role checkRole(LayoutCache layoutCache, long companyId, long groupId, long userId,
        Element roleElement) throws Exception {

    String name = roleElement.attributeValue("name");

    Role role = null;/*ww w  .  ja  va 2 s .  co m*/

    if (ExportImportPermissionUtil.isTeamRoleName(name)) {
        name = name.substring(ExportImportPermissionUtil.ROLE_TEAM_PREFIX.length());

        String description = roleElement.attributeValue("description");

        Team team = null;

        try {
            team = TeamLocalServiceUtil.getTeam(groupId, name);
        } catch (NoSuchTeamException nste) {

            // LPS-52675

            if (_log.isDebugEnabled()) {
                _log.debug(nste, nste);
            }

            team = TeamLocalServiceUtil.addTeam(userId, groupId, name, description, new ServiceContext());
        }

        role = RoleLocalServiceUtil.getTeamRole(companyId, team.getTeamId());

        return role;
    }

    String uuid = roleElement.attributeValue("uuid");

    role = layoutCache.getUuidRole(companyId, uuid);

    if (role == null) {
        role = layoutCache.getNameRole(companyId, name);
    }

    if ((role != null) || MergeLayoutPrototypesThreadLocal.isInProgress()) {
        return role;
    }

    String title = roleElement.attributeValue("title");

    Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(title);

    String description = roleElement.attributeValue("description");

    Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(description);

    int type = GetterUtil.getInteger(roleElement.attributeValue("type"));
    String subtype = roleElement.attributeValue("subtype");

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setUuid(uuid);

    role = RoleLocalServiceUtil.addRole(userId, null, 0, name, titleMap, descriptionMap, type, subtype,
            serviceContext);

    return role;
}

From source file:com.liferay.site.teams.exportimport.data.handler.test.TeamStagedModelDataHandlerTest.java

License:Open Source License

@Override
protected StagedModel addStagedModel(Group group, Map<String, List<StagedModel>> dependentStagedModelsMap)
        throws Exception {

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    Team team = TeamLocalServiceUtil.addTeam(TestPropsValues.getUserId(), group.getGroupId(),
            RandomTestUtil.randomString(), RandomTestUtil.randomString(), serviceContext);

    _user = UserTestUtil.addUser();//w  ww.j  a  v  a 2  s. com

    UserLocalServiceUtil.addTeamUser(team.getTeamId(), _user);

    _userGroup = UserGroupLocalServiceUtil.addUserGroup(TestPropsValues.getUserId(),
            TestPropsValues.getCompanyId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(),
            serviceContext);

    UserGroupLocalServiceUtil.addTeamUserGroup(team.getTeamId(), _userGroup);

    return team;
}

From source file:com.liferay.site.teams.service.test.TeamFinderTest.java

License:Open Source License

@Test
public void testGetUserOrUserGroupTeams() throws Exception {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(),
            _user.getUserId());// w  w w. ja v a  2s. c  o m

    Team userTeam = TeamLocalServiceUtil.addTeam(_user.getUserId(), _group.getGroupId(),
            RandomTestUtil.randomString(), "", serviceContext);

    TeamLocalServiceUtil.addUserTeam(_user.getUserId(), userTeam.getTeamId());

    List<Team> userOrUserGroupTeams1 = TeamLocalServiceUtil.getUserOrUserGroupTeams(_group.getGroupId(),
            _user.getUserId());

    Assert.assertEquals(userOrUserGroupTeams1.toString(), 1, userOrUserGroupTeams1.size());
    Assert.assertTrue(userOrUserGroupTeams1.toString(), userOrUserGroupTeams1.contains(userTeam));

    Team groupTeam = TeamLocalServiceUtil.addTeam(_user.getUserId(), _group.getGroupId(),
            RandomTestUtil.randomString(), "", serviceContext);

    TeamLocalServiceUtil.addUserGroupTeam(_userGroup.getUserGroupId(), groupTeam.getTeamId());

    List<Team> userOrUserGroupTeams2 = TeamLocalServiceUtil.getUserOrUserGroupTeams(_group.getGroupId(),
            _user.getUserId());

    Assert.assertEquals(userOrUserGroupTeams2.toString(), 2, userOrUserGroupTeams2.size());
    Assert.assertTrue(userOrUserGroupTeams2.toString(), userOrUserGroupTeams2.contains(userTeam));
    Assert.assertTrue(userOrUserGroupTeams2.toString(), userOrUserGroupTeams2.contains(groupTeam));
}

From source file:eu.gerhards.liferay.services.angular.service.impl.AngularTeamServiceImpl.java

License:Open Source License

@Override
public Team createTeam(long userId, long groupId, String name, String description) throws PortalException {

    _log.info("Creating team ... ");

    _log.debug("    ... security check ...");

    this.checkPersonalPermission(AngularActionKeys.ADD_TEAM);

    _log.debug("    ... processing ...");

    com.liferay.portal.kernel.model.Team team = TeamLocalServiceUtil.addTeam(userId, groupId, name, description,
            new ServiceContext());

    _log.debug("    returning team => " + team);

    return team;//from   w ww  .  java 2  s  . co  m
}