Example usage for com.liferay.portal.kernel.service GroupLocalServiceUtil getOrganizationGroup

List of usage examples for com.liferay.portal.kernel.service GroupLocalServiceUtil getOrganizationGroup

Introduction

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

Prototype

public static com.liferay.portal.kernel.model.Group getOrganizationGroup(long companyId, long organizationId)
        throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

Returns the specified organization group.

Usage

From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java

License:Open Source License

@Test
public void testDeleteOrganizationSiteOnlyRemovesSiteRoles() throws Exception {

    Organization organization = OrganizationLocalServiceUtil.addOrganization(TestPropsValues.getUserId(),
            OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, RandomTestUtil.randomString(), true);

    Group organizationSite = GroupLocalServiceUtil.getOrganizationGroup(TestPropsValues.getCompanyId(),
            organization.getOrganizationId());

    organizationSite.setManualMembership(true);

    User user = UserTestUtil.addOrganizationOwnerUser(organization);

    UserLocalServiceUtil.addGroupUser(organizationSite.getGroupId(), user.getUserId());
    UserLocalServiceUtil.addOrganizationUsers(organization.getOrganizationId(),
            new long[] { user.getUserId() });

    Role siteRole = RoleTestUtil.addRole(RoleConstants.TYPE_SITE);

    UserGroupRoleLocalServiceUtil.addUserGroupRoles(user.getUserId(), organizationSite.getGroupId(),
            new long[] { siteRole.getRoleId() });

    GroupLocalServiceUtil.deleteGroup(organizationSite);

    Assert.assertEquals(1, UserGroupRoleLocalServiceUtil.getUserGroupRolesCount(user.getUserId(),
            organizationSite.getGroupId()));

    UserLocalServiceUtil.deleteUser(user);

    OrganizationLocalServiceUtil.deleteOrganization(organization);
}

From source file:com.liferaystack.activator.LiferaystackActivatorLoginPreAction.java

License:Apache License

@Override
public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
    HttpServletRequest request = lifecycleEvent.getRequest();
    System.out.println("http request is " + request);
    try {//www .j  a va2  s.c o  m
        long userId = PortalUtil.getUser(request).getUserId();
        System.out.println("userId is >>>>>>>>>>>>>>>>>>>" + userId);
        List<Organization> organizations = OrganizationLocalServiceUtil.getUserOrganizations(userId);

        for (Organization organization : organizations) {
            System.out.println("users organisation is " + organization);
            Group organizationGroup = GroupLocalServiceUtil.getOrganizationGroup(organization.getCompanyId(),
                    organization.getOrganizationId());
            List<Layout> privateLayouts = LayoutLocalServiceUtil.getLayouts(organizationGroup.getGroupId(),
                    true);
            List<Layout> publicLayouts = LayoutLocalServiceUtil.getLayouts(organizationGroup.getGroupId(),
                    false);
            String rightURL = null;
            for (Layout layout : publicLayouts) {
                //if(layout.getP){
                rightURL = PortalUtil.getLayoutActualURL(layout);
                System.out.println("rightURL : " + rightURL);

                //}

            }
        }

    } catch (PortalException e) {
        e.printStackTrace();
    }
    System.out.println("login.event.post=" + lifecycleEvent + ", session s: ");
}