List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getCompanyId
public long getCompanyId()
From source file:com.liferay.salesforce.portlet.SalesforceContactsPortlet.java
License:Apache License
private String getUsername(ResourceRequest resourceRequest) throws PortletException { try {/*from w ww .j a v a2 s.c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletPreferences preferences = PrefsPortletPropsUtil .getPortletPreferences(themeDisplay.getCompanyId(), themeDisplay.getUserId()); // return preferences.getValue(PortletPropsKeys.SALESFORCE_USER_NAME, // null); //Hardcode username for now. Then build control panel access later to set username/password config return ("sales-engineering-na@liferay.com"); } catch (Exception e) { throw new PortletException(e); } }
From source file:com.liferay.server.admin.web.internal.portlet.action.EditDocumentLibraryExtraSettingsMVCActionCommand.java
License:Open Source License
protected void convert(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String[] keys = StringUtil.split(ParamUtil.getString(actionRequest, "keys")); String[] presets = new String[keys.length]; int[] types = new int[keys.length]; for (int i = 0; i < keys.length; i++) { presets[i] = ParamUtil.getString(actionRequest, "type_" + keys[i]); types[i] = addCustomField(themeDisplay.getCompanyId(), keys[i], presets[i]); }/*from w w w . j a v a 2 s .c o m*/ _dlFileEntryLocalService.convertExtraSettings(keys); }
From source file:com.liferay.site.admin.web.internal.display.context.SiteAdminDisplayContext.java
License:Open Source License
public int getChildSitesCount(Group group) { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); return GroupLocalServiceUtil.getGroupsCount(themeDisplay.getCompanyId(), group.getGroupId(), true); }
From source file:com.liferay.site.admin.web.internal.portlet.SiteAdminPortlet.java
License:Open Source License
public void deleteGroups(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long[] deleteGroupIds = null; long groupId = ParamUtil.getLong(actionRequest, "groupId"); if (groupId > 0) { deleteGroupIds = new long[] { groupId }; } else {/*ww w.ja v a 2 s .c o m*/ deleteGroupIds = ParamUtil.getLongValues(actionRequest, "rowIds"); } for (long deleteGroupId : deleteGroupIds) { groupService.deleteGroup(deleteGroupId); LiveUsers.deleteGroup(themeDisplay.getCompanyId(), deleteGroupId); } }
From source file:com.liferay.site.admin.web.internal.portlet.SiteAdminPortlet.java
License:Open Source License
public void editGroupAssignments(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(actionRequest, "groupId"); long[] removeUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "removeUserIds"), 0L); removeUserIds = filterRemoveUserIds(groupId, removeUserIds); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); userService.unsetGroupUsers(groupId, removeUserIds, serviceContext); LiveUsers.leaveGroup(themeDisplay.getCompanyId(), groupId, removeUserIds); }
From source file:com.liferay.site.admin.web.internal.portlet.SiteAdminPortlet.java
License:Open Source License
protected Group updateGroup(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long userId = portal.getUserId(actionRequest); long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId"); long parentGroupId = ParamUtil.getLong(actionRequest, "parentGroupSearchContainerPrimaryKeys", GroupConstants.DEFAULT_PARENT_GROUP_ID); Map<Locale, String> nameMap = null; Map<Locale, String> descriptionMap = null; int type = 0; String friendlyURL = null;//ww w .jav a 2 s . com boolean inheritContent = false; boolean active = false; boolean manualMembership = true; int membershipRestriction = GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION; boolean actionRequestMembershipRestriction = ParamUtil.getBoolean(actionRequest, "membershipRestriction"); if (actionRequestMembershipRestriction && (parentGroupId != GroupConstants.DEFAULT_PARENT_GROUP_ID)) { membershipRestriction = GroupConstants.MEMBERSHIP_RESTRICTION_TO_PARENT_SITE_MEMBERS; } ServiceContext serviceContext = ServiceContextFactory.getInstance(Group.class.getName(), actionRequest); ServiceContextThreadLocal.pushServiceContext(serviceContext); Group liveGroup = null; if (liveGroupId <= 0) { // Add group nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name"); descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description"); type = ParamUtil.getInteger(actionRequest, "type"); friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL"); manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership"); inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent"); active = ParamUtil.getBoolean(actionRequest, "active"); liveGroup = groupService.addGroup(parentGroupId, GroupConstants.DEFAULT_LIVE_GROUP_ID, nameMap, descriptionMap, type, manualMembership, membershipRestriction, friendlyURL, true, inheritContent, active, serviceContext); LiveUsers.joinGroup(themeDisplay.getCompanyId(), liveGroup.getGroupId(), userId); } else { // Update group liveGroup = groupLocalService.getGroup(liveGroupId); nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name", liveGroup.getNameMap()); descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description", liveGroup.getDescriptionMap()); type = ParamUtil.getInteger(actionRequest, "type", liveGroup.getType()); manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership", liveGroup.isManualMembership()); friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL", liveGroup.getFriendlyURL()); inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent", liveGroup.getInheritContent()); active = ParamUtil.getBoolean(actionRequest, "active", liveGroup.getActive()); liveGroup = groupService.updateGroup(liveGroupId, parentGroupId, nameMap, descriptionMap, type, manualMembership, membershipRestriction, friendlyURL, inheritContent, active, serviceContext); if (type == GroupConstants.TYPE_SITE_OPEN) { List<MembershipRequest> membershipRequests = membershipRequestLocalService.search(liveGroupId, MembershipRequestConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS); for (MembershipRequest membershipRequest : membershipRequests) { membershipRequestService.updateStatus(membershipRequest.getMembershipRequestId(), themeDisplay.translate("your-membership-has-been-approved"), MembershipRequestConstants.STATUS_APPROVED, serviceContext); LiveUsers.joinGroup(themeDisplay.getCompanyId(), membershipRequest.getGroupId(), new long[] { membershipRequest.getUserId() }); } } } // Settings UnicodeProperties typeSettingsProperties = liveGroup.getTypeSettingsProperties(); String customJspServletContextName = ParamUtil.getString(actionRequest, "customJspServletContextName", typeSettingsProperties.getProperty("customJspServletContextName")); typeSettingsProperties.setProperty("customJspServletContextName", customJspServletContextName); typeSettingsProperties.setProperty("defaultSiteRoleIds", ListUtil.toString(getRoles(actionRequest), Role.ROLE_ID_ACCESSOR, StringPool.COMMA)); typeSettingsProperties.setProperty("defaultTeamIds", ListUtil.toString(getTeams(actionRequest), Team.TEAM_ID_ACCESSOR, StringPool.COMMA)); String[] analyticsTypes = PrefsPropsUtil.getStringArray(themeDisplay.getCompanyId(), PropsKeys.ADMIN_ANALYTICS_TYPES, StringPool.NEW_LINE); for (String analyticsType : analyticsTypes) { if (StringUtil.equalsIgnoreCase(analyticsType, "google")) { String googleAnalyticsId = ParamUtil.getString(actionRequest, "googleAnalyticsId", typeSettingsProperties.getProperty("googleAnalyticsId")); typeSettingsProperties.setProperty("googleAnalyticsId", googleAnalyticsId); } else { String analyticsScript = ParamUtil.getString(actionRequest, Sites.ANALYTICS_PREFIX + analyticsType, typeSettingsProperties.getProperty(analyticsType)); typeSettingsProperties.setProperty(Sites.ANALYTICS_PREFIX + analyticsType, analyticsScript); } } boolean trashEnabled = ParamUtil.getBoolean(actionRequest, "trashEnabled", GetterUtil.getBoolean(typeSettingsProperties.getProperty("trashEnabled"), true)); typeSettingsProperties.setProperty("trashEnabled", String.valueOf(trashEnabled)); int trashEntriesMaxAgeCompany = PrefsPropsUtil.getInteger(themeDisplay.getCompanyId(), PropsKeys.TRASH_ENTRIES_MAX_AGE); int trashEntriesMaxAgeGroup = ParamUtil.getInteger(actionRequest, "trashEntriesMaxAge"); if (trashEntriesMaxAgeGroup <= 0) { trashEntriesMaxAgeGroup = GetterUtil.getInteger( typeSettingsProperties.getProperty("trashEntriesMaxAge"), trashEntriesMaxAgeCompany); } if (trashEntriesMaxAgeGroup != trashEntriesMaxAgeCompany) { typeSettingsProperties.setProperty("trashEntriesMaxAge", String.valueOf(GetterUtil.getInteger(trashEntriesMaxAgeGroup))); } else { typeSettingsProperties.remove("trashEntriesMaxAge"); } int contentSharingWithChildrenEnabled = ParamUtil.getInteger(actionRequest, "contentSharingWithChildrenEnabled", GetterUtil.getInteger(typeSettingsProperties.getProperty("contentSharingWithChildrenEnabled"), Sites.CONTENT_SHARING_WITH_CHILDREN_DEFAULT_VALUE)); typeSettingsProperties.setProperty("contentSharingWithChildrenEnabled", String.valueOf(contentSharingWithChildrenEnabled)); UnicodeProperties formTypeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); typeSettingsProperties.putAll(formTypeSettingsProperties); // Virtual hosts LayoutSet publicLayoutSet = liveGroup.getPublicLayoutSet(); String publicVirtualHost = ParamUtil.getString(actionRequest, "publicVirtualHost", publicLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(liveGroup.getGroupId(), false, publicVirtualHost); LayoutSet privateLayoutSet = liveGroup.getPrivateLayoutSet(); String privateVirtualHost = ParamUtil.getString(actionRequest, "privateVirtualHost", privateLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(liveGroup.getGroupId(), true, privateVirtualHost); // Staging if (liveGroup.hasStagingGroup()) { Group stagingGroup = liveGroup.getStagingGroup(); friendlyURL = ParamUtil.getString(actionRequest, "stagingFriendlyURL", stagingGroup.getFriendlyURL()); groupService.updateFriendlyURL(stagingGroup.getGroupId(), friendlyURL); LayoutSet stagingPublicLayoutSet = stagingGroup.getPublicLayoutSet(); publicVirtualHost = ParamUtil.getString(actionRequest, "stagingPublicVirtualHost", stagingPublicLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(stagingGroup.getGroupId(), false, publicVirtualHost); LayoutSet stagingPrivateLayoutSet = stagingGroup.getPrivateLayoutSet(); privateVirtualHost = ParamUtil.getString(actionRequest, "stagingPrivateVirtualHost", stagingPrivateLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(stagingGroup.getGroupId(), true, privateVirtualHost); UnicodeProperties stagedGroupTypeSettingsProperties = stagingGroup.getTypeSettingsProperties(); stagedGroupTypeSettingsProperties.putAll(formTypeSettingsProperties); groupService.updateGroup(stagingGroup.getGroupId(), stagedGroupTypeSettingsProperties.toString()); } liveGroup = groupService.updateGroup(liveGroup.getGroupId(), typeSettingsProperties.toString()); // Layout set prototypes long privateLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "privateLayoutSetPrototypeId"); long publicLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "publicLayoutSetPrototypeId"); boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest, "privateLayoutSetPrototypeLinkEnabled", privateLayoutSet.isLayoutSetPrototypeLinkEnabled()); boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest, "publicLayoutSetPrototypeLinkEnabled", publicLayoutSet.isLayoutSetPrototypeLinkEnabled()); if ((privateLayoutSetPrototypeId == 0) && (publicLayoutSetPrototypeId == 0) && !privateLayoutSetPrototypeLinkEnabled && !publicLayoutSetPrototypeLinkEnabled) { long layoutSetPrototypeId = ParamUtil.getLong(actionRequest, "layoutSetPrototypeId"); int layoutSetVisibility = ParamUtil.getInteger(actionRequest, "layoutSetVisibility"); boolean layoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest, "layoutSetPrototypeLinkEnabled", layoutSetPrototypeId > 0); if (layoutSetVisibility == _LAYOUT_SET_VISIBILITY_PRIVATE) { privateLayoutSetPrototypeId = layoutSetPrototypeId; privateLayoutSetPrototypeLinkEnabled = layoutSetPrototypeLinkEnabled; } else { publicLayoutSetPrototypeId = layoutSetPrototypeId; publicLayoutSetPrototypeLinkEnabled = layoutSetPrototypeLinkEnabled; } } if (!liveGroup.isStaged() || liveGroup.isStagedRemotely()) { SitesUtil.updateLayoutSetPrototypesLinks(liveGroup, publicLayoutSetPrototypeId, privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled, privateLayoutSetPrototypeLinkEnabled); } else { SitesUtil.updateLayoutSetPrototypesLinks(liveGroup.getStagingGroup(), publicLayoutSetPrototypeId, privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled, privateLayoutSetPrototypeLinkEnabled); } themeDisplay.setSiteGroupId(liveGroup.getGroupId()); return liveGroup; }
From source file:com.liferay.site.admin.web.internal.servlet.taglib.ui.SiteCustomFieldsFormNavigatorEntry.java
License:Open Source License
@Override public boolean isVisible(User user, Group group) { if ((group == null) || group.isCompany()) { return false; }/* w w w . j av a 2 s.c o m*/ boolean hasCustomAttributesAvailable = false; try { ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); hasCustomAttributesAvailable = CustomAttributesUtil.hasCustomAttributes(themeDisplay.getCompanyId(), Group.class.getName(), group.getGroupId(), null); } catch (Exception e) { } if (!hasCustomAttributesAvailable) { return false; } return true; }
From source file:com.liferay.site.admin.web.internal.servlet.taglib.ui.SiteMapsFormNavigatorEntry.java
License:Open Source License
@Override public void include(HttpServletRequest request, HttpServletResponse response) throws IOException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Group liveGroup = (Group) request.getAttribute("site.liveGroup"); request.setAttribute(MapProviderWebKeys.MAP_PROVIDER_KEY, _mapProviderHelper.getMapProviderKey(themeDisplay.getCompanyId(), liveGroup.getGroupId())); super.include(request, response); }
From source file:com.liferay.site.admin.web.internal.servlet.taglib.ui.SiteSiteTemplateFormNavigatorEntry.java
License:Open Source License
@Override public boolean isVisible(User user, Group group) { if ((group == null) || group.isCompany()) { return false; }//from w ww . j a v a 2s .c o m ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); LayoutSet privateLayoutSet = null; LayoutSet publicLayoutSet = null; try { privateLayoutSet = _layoutSetLocalService.getLayoutSet(group.getGroupId(), true); publicLayoutSet = _layoutSetLocalService.getLayoutSet(group.getGroupId(), false); } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return false; } if ((privateLayoutSet == null) && (publicLayoutSet == null)) { return false; } LayoutSetPrototype privateLayoutSetPrototype = null; LayoutSetPrototype publicLayoutSetPrototype = null; if (Validator.isNotNull(privateLayoutSet.getLayoutSetPrototypeUuid())) { privateLayoutSetPrototype = _layoutSetPrototypeLocalService.fetchLayoutSetPrototypeByUuidAndCompanyId( privateLayoutSet.getLayoutSetPrototypeUuid(), themeDisplay.getCompanyId()); } if (Validator.isNotNull(publicLayoutSet.getLayoutSetPrototypeUuid())) { publicLayoutSetPrototype = _layoutSetPrototypeLocalService.fetchLayoutSetPrototypeByUuidAndCompanyId( publicLayoutSet.getLayoutSetPrototypeUuid(), themeDisplay.getCompanyId()); } if ((publicLayoutSetPrototype == null) && (privateLayoutSetPrototype == null)) { return false; } return true; }
From source file:com.liferay.site.browser.web.internal.display.context.SiteBrowserDisplayContext.java
License:Open Source License
public GroupSearch getGroupSearch() throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); GroupSearch groupSearch = new GroupSearch(_liferayPortletRequest, getPortletURL()); GroupSearchTerms groupSearchTerms = (GroupSearchTerms) groupSearch.getSearchTerms(); List<Group> results = new ArrayList<>(); int additionalSites = 0; int total = 0; boolean includeCompany = ParamUtil.getBoolean(_request, "includeCompany"); boolean includeUserPersonalSite = ParamUtil.getBoolean(_request, "includeUserPersonalSite"); long[] classNameIds = _CLASS_NAME_IDS; if (includeCompany) { classNameIds = ArrayUtil.append(classNameIds, PortalUtil.getClassNameId(Company.class)); }/*from w w w . j av a 2 s . co m*/ if (includeUserPersonalSite) { if (groupSearch.getStart() == 0) { Group userPersonalSite = GroupLocalServiceUtil.getGroup(company.getCompanyId(), GroupConstants.USER_PERSONAL_SITE); results.add(userPersonalSite); } additionalSites++; } String type = getType(); if (type.equals("layoutScopes")) { total = GroupLocalServiceUtil.getGroupsCount(themeDisplay.getCompanyId(), Layout.class.getName(), getGroupId()); } else if (type.equals("parent-sites")) { } else { total = GroupLocalServiceUtil.searchCount(themeDisplay.getCompanyId(), classNameIds, groupSearchTerms.getKeywords(), getGroupParams()); } total += additionalSites; groupSearch.setTotal(total); int start = groupSearch.getStart(); if (groupSearch.getStart() > additionalSites) { start = groupSearch.getStart() - additionalSites; } List<Group> groups = null; if (type.equals("layoutScopes")) { groups = GroupLocalServiceUtil.getGroups(company.getCompanyId(), Layout.class.getName(), getGroupId(), start, groupSearch.getResultEnd() - additionalSites); groups = _filterLayoutGroups(groups, isPrivateLayout()); } else if (type.equals("parent-sites")) { Group group = GroupLocalServiceUtil.getGroup(getGroupId()); groups = group.getAncestors(); String filter = getFilter(); if (Validator.isNotNull(filter)) { groups = _filterGroups(groups, filter); } total = groups.size(); total += additionalSites; groupSearch.setTotal(total); } else { groups = GroupLocalServiceUtil.search(company.getCompanyId(), classNameIds, groupSearchTerms.getKeywords(), getGroupParams(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, groupSearch.getOrderByComparator()); groups = _filterGroups(groups, themeDisplay.getPermissionChecker()); total = groups.size(); total += additionalSites; groupSearch.setTotal(total); groups = groups.subList(start, groupSearch.getResultEnd() - additionalSites); } results.addAll(groups); groupSearch.setResults(results); return groupSearch; }