List of usage examples for com.liferay.portal.kernel.model Organization getGroup
public Group getGroup();
From source file:com.bemis.portal.migration.customer.service.impl.CustomerMigrationLocalServiceImpl.java
License:Open Source License
protected Organization addOrganizationFromCustomer(long userId, CustomerOrg aCustomerOrgParent, long setPrototypeId, long parentOrganizationId) { String organizationType = OrganizationConstants.TYPE_ORGANIZATION; long statusId = ListTypeConstants.ORGANIZATION_STATUS_DEFAULT; long countryId = CountryServiceUtil.fetchCountryByA2(aCustomerOrgParent.getCountry()).getCountryId(); long regionId = RegionServiceUtil.fetchRegion(countryId, aCustomerOrgParent.getState()).getRegionId(); String bemisCustomerId = aCustomerOrgParent.getBemisCustomerId(); String bemisParentOrg = aCustomerOrgParent.getBemisParentId(); Organization anOrganization = null; String name = ""; // @TODO Custom fields need to be finalized from the customer profile // Only parent organizations get the default and the short name if (parentOrganizationId == OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID) { name = aCustomerOrgParent.getCustomerName(); organizationType = PARENT_LOCATION_TYPE; } else {//from ww w . ja v a 2s. c om name = aCustomerOrgParent.getCustomerName() + " - " + aCustomerOrgParent.getCity(); organizationType = CUSTOMER_LOCATION_TYPE; } try { anOrganization = _organizationLocalService.getOrganization(_bemisPortalService.getDefaultCompanyId(), name); if (_log.isDebugEnabled()) { _log.debug(">>> Organization with id [" + anOrganization.getOrganizationId() + "] already exists"); } } catch (NoSuchOrganizationException nsoe) { // If we are a new organization, let us add it. try { // Create an organization with a site anOrganization = addOrganization(userId, parentOrganizationId, name, organizationType, regionId, countryId, statusId, null, true, null, bemisCustomerId, bemisParentOrg); // Now we map the site to the customer template Group organizationGroup = anOrganization.getGroup(); SitesUtil.updateLayoutSetPrototypesLinks(organizationGroup, 0, setPrototypeId, true, true); _log.debug(">>> Created an Organization with id [" + anOrganization.getOrganizationId() + "]"); } catch (Exception pe) { _log.error(pe); } } catch (PortalException pe) { _log.error(">>> Error creating Organization for Customer [" + name + "]", pe); } return anOrganization; }
From source file:com.liferay.site.service.persistence.test.GroupServiceUserSitesGroupsTest.java
License:Open Source License
@Test public void testInactiveOrganizationGroup() throws Exception { _user = UserTestUtil.addUser();//from w ww . j av a 2 s .c om Organization organization = OrganizationTestUtil.addOrganization(true); _organizations.addFirst(organization); UserLocalServiceUtil.addOrganizationUsers(organization.getOrganizationId(), new long[] { _user.getUserId() }); Group group = organization.getGroup(); LayoutTestUtil.addLayout(group); group = GroupLocalServiceUtil.getGroup(group.getGroupId()); group.setActive(false); GroupLocalServiceUtil.updateGroup(group); List<Group> groups = GroupServiceUtil.getUserSitesGroups(_user.getUserId(), null, QueryUtil.ALL_POS); Assert.assertFalse(groups + " contains " + group, groups.contains(group)); }
From source file:com.liferay.site.service.persistence.test.GroupServiceUserSitesGroupsTest.java
License:Open Source License
@Test public void testOrganizationAncestorsGroups() throws Exception { _user = UserTestUtil.addUser();/* w w w . j av a2 s . co m*/ Organization parentOrganization = OrganizationTestUtil.addOrganization(true); Group parentOrganizationGroup = parentOrganization.getGroup(); _organizations.addFirst(parentOrganization); Organization organization = OrganizationTestUtil.addOrganization(parentOrganization.getOrganizationId(), RandomTestUtil.randomString(), false); _organizations.addFirst(organization); UserLocalServiceUtil.addOrganizationUsers(organization.getOrganizationId(), new long[] { _user.getUserId() }); try { List<Group> groups = GroupServiceUtil.getUserSitesGroups(_user.getUserId(), null, QueryUtil.ALL_POS); Group organizationGroup = organization.getGroup(); Assert.assertTrue(groups + " does not contain " + parentOrganizationGroup, groups.contains(parentOrganizationGroup)); Assert.assertFalse(groups + " contains " + organizationGroup, groups.contains(organizationGroup)); } finally { UserLocalServiceUtil.unsetOrganizationUsers(organization.getOrganizationId(), new long[] { _user.getUserId() }); } }
From source file:com.liferay.site.service.persistence.test.GroupServiceUserSitesGroupsTest.java
License:Open Source License
@Test public void testOrganizationGroups() throws Exception { _user = UserTestUtil.addUser();/*from w w w .j a v a 2 s . c om*/ Organization organization = OrganizationTestUtil.addOrganization(true); _organizations.addFirst(organization); UserLocalServiceUtil.addGroupUser(organization.getGroupId(), _user); Group organizationGroup = organization.getGroup(); LayoutTestUtil.addLayout(organizationGroup); List<Group> groups = GroupServiceUtil.getUserSitesGroups(_user.getUserId(), null, QueryUtil.ALL_POS); Assert.assertTrue(groups + " does not contain " + organizationGroup, groups.contains(organizationGroup)); }
From source file:com.liferay.site.service.persistence.test.GroupServiceUserSitesGroupsTest.java
License:Open Source License
@Test public void testOrganizationUser() throws Exception { _user = UserTestUtil.addUser();/*from ww w . ja v a 2 s . c o m*/ Organization organization = OrganizationTestUtil.addOrganization(true); _organizations.addFirst(organization); UserLocalServiceUtil.addOrganizationUser(organization.getOrganizationId(), _user); Group organizationGroup = organization.getGroup(); LayoutTestUtil.addLayout(organizationGroup); List<Group> groups = GroupServiceUtil.getUserSitesGroups(_user.getUserId(), null, QueryUtil.ALL_POS); Assert.assertTrue(groups + " does not contain " + organizationGroup, groups.contains(organizationGroup)); }
From source file:com.liferay.site.service.persistence.test.GroupServiceUserSitesGroupsTest.java
License:Open Source License
@Test public void testOrganizationWithoutLayouts() throws Exception { _user = UserTestUtil.addUser();/*from w ww .j av a2s. c o m*/ Organization organization = OrganizationTestUtil.addOrganization(true); _organizations.addFirst(organization); UserLocalServiceUtil.addGroupUser(organization.getGroupId(), _user); List<Group> groups = GroupServiceUtil.getUserSitesGroups(_user.getUserId(), null, QueryUtil.ALL_POS); Group organizationGroup = organization.getGroup(); Assert.assertTrue(groups + " does not contain " + organizationGroup, groups.contains(organizationGroup)); }
From source file:com.liferay.site.service.persistence.test.GroupServiceUserSitesGroupsTest.java
License:Open Source License
@Test public void testOrganizationWithoutSite() throws Exception { _user = UserTestUtil.addUser();// ww w. j a va2s . c om Organization organization = OrganizationTestUtil.addOrganization(false); _organizations.addFirst(organization); UserLocalServiceUtil.addGroupUser(organization.getGroupId(), _user); List<Group> groups = GroupServiceUtil.getUserSitesGroups(_user.getUserId(), null, QueryUtil.ALL_POS); Group organizationGroup = organization.getGroup(); Assert.assertFalse(groups + " contains " + organizationGroup, groups.contains(organizationGroup)); }
From source file:com.liferay.users.admin.web.internal.portlet.action.EditOrganizationMVCActionCommand.java
License:Open Source License
protected Organization updateOrganization(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long organizationId = ParamUtil.getLong(actionRequest, "organizationId"); long parentOrganizationId = ParamUtil.getLong(actionRequest, "parentOrganizationSearchContainerPrimaryKeys", OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID); String name = ParamUtil.getString(actionRequest, "name"); long statusId = ParamUtil.getLong(actionRequest, "statusId"); String type = ParamUtil.getString(actionRequest, "type"); long regionId = ParamUtil.getLong(actionRequest, "regionId"); long countryId = ParamUtil.getLong(actionRequest, "countryId"); String comments = ParamUtil.getString(actionRequest, "comments"); boolean deleteLogo = ParamUtil.getBoolean(actionRequest, "deleteLogo"); byte[] logoBytes = null; long fileEntryId = ParamUtil.getLong(actionRequest, "fileEntryId"); if (fileEntryId > 0) { FileEntry fileEntry = _dlAppLocalService.getFileEntry(fileEntryId); logoBytes = FileUtil.getBytes(fileEntry.getContentStream()); }/* w ww . ja v a 2 s. com*/ boolean site = ParamUtil.getBoolean(actionRequest, "site"); List<Address> addresses = UsersAdminUtil.getAddresses(actionRequest); List<EmailAddress> emailAddresses = UsersAdminUtil.getEmailAddresses(actionRequest); List<OrgLabor> orgLabors = UsersAdminUtil.getOrgLabors(actionRequest); List<Phone> phones = UsersAdminUtil.getPhones(actionRequest); List<Website> websites = UsersAdminUtil.getWebsites(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(Organization.class.getName(), actionRequest); Organization organization = null; if (organizationId <= 0) { // Add organization organization = _organizationService.addOrganization(parentOrganizationId, name, type, regionId, countryId, statusId, comments, site, addresses, emailAddresses, orgLabors, phones, websites, serviceContext); } else { // Update organization organization = _organizationService.updateOrganization(organizationId, parentOrganizationId, name, type, regionId, countryId, statusId, comments, !deleteLogo, logoBytes, site, addresses, emailAddresses, orgLabors, phones, websites, serviceContext); } // Layout set prototypes long publicLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "publicLayoutSetPrototypeId"); long privateLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "privateLayoutSetPrototypeId"); boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest, "publicLayoutSetPrototypeLinkEnabled", publicLayoutSetPrototypeId > 0); boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest, "privateLayoutSetPrototypeLinkEnabled", privateLayoutSetPrototypeId > 0); Group organizationGroup = organization.getGroup(); if (GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), organizationGroup, ActionKeys.UPDATE)) { SitesUtil.updateLayoutSetPrototypesLinks(organizationGroup, publicLayoutSetPrototypeId, privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled, privateLayoutSetPrototypeLinkEnabled); } // Reminder queries String reminderQueries = actionRequest.getParameter("reminderQueries"); PortletPreferences portletPreferences = organization.getPreferences(); LocalizationUtil.setLocalizedPreferencesValues(actionRequest, portletPreferences, "reminderQueries"); portletPreferences.setValue("reminderQueries", reminderQueries); portletPreferences.store(); return organization; }
From source file:com.liferay.users.admin.web.internal.portlet.configuration.icon.ManageSitePortletConfigurationIcon.java
License:Open Source License
@Override public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) { try {/* w ww . j av a2s . c om*/ Organization organization = ActionUtil.getOrganization(portletRequest); Group organizationGroup = organization.getGroup(); PortletURL portletURL = PortletProviderUtil.getPortletURL(portletRequest, organizationGroup, Group.class.getName(), PortletProvider.Action.EDIT); portletURL.setParameter("viewOrganizationsRedirect", _portal.getCurrentURL(portletRequest)); return portletURL.toString(); } catch (Exception e) { } return StringPool.BLANK; }
From source file:com.liferay.users.admin.web.internal.portlet.configuration.icon.ManageSitePortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); try {// ww w .j a v a 2 s . co m PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); Organization organization = ActionUtil.getOrganization(portletRequest); Group organizationGroup = organization.getGroup(); if (organizationGroup.isSite() && (GroupPermissionUtil.contains(permissionChecker, organizationGroup, ActionKeys.MANAGE_STAGING) || OrganizationPermissionUtil.contains(permissionChecker, organization, ActionKeys.UPDATE))) { return true; } } catch (Exception e) { } return false; }