本文整理汇总了Java中com.liferay.portal.kernel.model.Group类的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Group类属于com.liferay.portal.kernel.model包,在下文中一共展示了Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileEntryTypes
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
@Override
public Map<DLFileEntryType, List<DDMTemplate>> getFileEntryTypes(PermissionChecker permissionChecker, long groupId) throws PortalException {
List<DLFileEntryType> fileEntryTypes = this.dlFileEntryTypeService.getFileEntryTypes(this.portal.getCurrentAndAncestorSiteGroupIds(groupId));
HashMap<DLFileEntryType, List<DDMTemplate>> fileEntryTypeTemplateMapping = new HashMap<>(fileEntryTypes.size());
Map<Group, List<DDMTemplate>> templatesByGroup = this.getDLFileEntryTypeTemplates(permissionChecker, groupId);
List<DDMTemplate> templates = new ArrayList<>();
for(List<DDMTemplate> groupTemplates : templatesByGroup.values()) {
templates.addAll(groupTemplates);
}
// Put the default file entry type in there (because getFileEntryTypes won't do it)
fileEntryTypeTemplateMapping.put(this.dlFileEntryTypeService.getDLFileEntryType(DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT), templates);
for(DLFileEntryType fileEntryType : fileEntryTypes) {
fileEntryTypeTemplateMapping.put(fileEntryType, templates);
}
return fileEntryTypeTemplateMapping;
}
示例2: create
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
/**
* Create Dummy data
*
* @param request
* @throws Exception
*/
public void create(ActionRequest request) throws Exception {
T paramContext = getContext(request);
if(!validate(paramContext)) {
throw new Exception("Validation Error");
}
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
ServiceContext serviceContext = ServiceContextFactory.getInstance(Group.class.getName(), request);
paramContext.setThemeDisplay(themeDisplay);
paramContext.setServiceContext(serviceContext);
exec(request, paramContext);
}
示例3: getPageItems
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
@Override
public PageItems<WebSite> getPageItems(
Pagination pagination, long companyId) {
List<Group> groups = _groupLocalService.getGroups(companyId, 0, true);
List<Group> paginationGroups = ListUtil.subList(
groups, pagination.getStartPosition(), pagination.getEndPosition());
Stream<Group> stream = paginationGroups.stream();
List<WebSite> webSites = stream.map(
WebSiteImpl::new
).collect(
Collectors.toList()
);
int count = _groupLocalService.getGroupsCount(companyId, 0, true);
return new PageItems<>(webSites, count);
}
示例4: isStagingActive
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
public static boolean isStagingActive(
StagingCheckerModelFactory mf, Model model, long groupId)
throws SystemException {
Group group = GroupLocalServiceUtil.fetchGroup(groupId);
Set<Portlet> portlets = mf.getPortletSet(model.getClassName());
if (portlets.isEmpty()) {
return false;
}
Portlet portlet = portlets.toArray(new Portlet[1])[0];
if (!group.isStagedPortlet(portlet.getPortletId())) {
if (_log.isDebugEnabled()) {
_log.debug(
model.getName() + " is not staged for group " +
groupId);
}
return false;
}
return true;
}
示例5: getSiteGroupDescriptions
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
public List<String> getSiteGroupDescriptions(List<Long> siteGroupIds)
throws SystemException {
List<String> groupDescriptionList = new ArrayList<String>();
for (Long siteGroupId : siteGroupIds) {
Group group = GroupLocalServiceUtil.fetchGroup(siteGroupId);
String groupDescription = group.getName();
groupDescription = groupDescription.replace(
"LFR_ORGANIZATION", "(Org)");
if (group.isCompany()) {
if (!group.isStagingGroup()) {
groupDescription = "Global";
}
groupDescription += " - " + group.getCompanyId();
}
groupDescriptionList.add(groupDescription);
}
return groupDescriptionList;
}
示例6: addSiteMultiSelect
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
public void addSiteMultiSelect(String name) throws SystemException {
List<Group> groups =
GroupLocalServiceUtil.getGroups(
QueryUtil.ALL_POS, QueryUtil.ALL_POS);
List<KeyValuePair> values = new ArrayList<KeyValuePair>(groups.size());
for (Group group : groups) {
//if ((group.isCommunity() || group.isSite()) &&
// !group.isControlPanel() && !group.isStaged()) {
if (group.isRegularSite() && !group.isControlPanel() && !group.isStaged()) {
long siteId = group.getGroupId();
String siteName = group.getName();
if (Validator.isNull(siteId) || Validator.isNull(siteName)) {
continue;
}
values.add(new KeyValuePair(siteName, String.valueOf(siteId)));
}
}
addMultiSelectList(name, values);
}
示例7: SiteHandler
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
public SiteHandler() throws Exception {
super("Site", "site");
ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();
updateLayoutSetPrototypesLinksClass = portalClassLoader.loadClass(
"com.liferay.sites.kernel.util.SitesUtil");
updateLayoutSetPrototypesLinksMethod =
updateLayoutSetPrototypesLinksClass.getMethod(
"updateLayoutSetPrototypesLinks",
new Class<?>[] {
Group.class, Long.TYPE, Long.TYPE, Boolean.TYPE,
Boolean.TYPE
});
}
示例8: assignMemberUsers
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
private static void assignMemberUsers(List<UserAsMember> memberUsers, long companyId, long groupId) {
if (Objects.isNull(memberUsers) || memberUsers.isEmpty()) {
return;
}
for (UserAsMember memberUser : memberUsers) {
User user = UserLocalServiceUtil.fetchUserByScreenName(companyId, memberUser.getScreenName());
if (Objects.isNull(user)) {
LOG.error("User with screenName " + memberUser.getScreenName() + " does not exists. Won't be assigned as site member.");
continue;
}
try {
Group liferayGroup = GroupLocalServiceUtil.getGroup(groupId);
GroupLocalServiceUtil.addUserGroup(user.getUserId(), liferayGroup.getGroupId());
LOG.info("User " + user.getScreenName() + " was assigned as member of site " + liferayGroup.getDescriptiveName());
assignUserMemberRoles(memberUser.getRole(), companyId, liferayGroup, user);
} catch (PortalException e) {
e.printStackTrace();
}
}
}
示例9: assignUserMemberRoles
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
private static void assignUserMemberRoles(List<Role> membershipRoles, long companyId, Group liferayGroup, User liferayUser) {
if (Objects.isNull(membershipRoles) || membershipRoles.isEmpty()) {
return;
}
for (Role membershipRole : membershipRoles) {
try {
com.liferay.portal.kernel.model.Role liferayRole = RoleLocalServiceUtil.getRole(companyId, membershipRole.getName());
UserGroupRoleLocalServiceUtil.addUserGroupRoles(liferayUser.getUserId(), liferayGroup.getGroupId(), new long[] {liferayRole.getRoleId()});
StringBuilder sb = new StringBuilder("Role ")
.append(liferayRole.getDescriptiveName())
.append(" assigned to User ")
.append(liferayUser.getScreenName())
.append(" for site ")
.append(liferayGroup.getDescriptiveName());
LOG.info(sb.toString());
} catch (PortalException e) {
LOG.error("Can not add role with name" + membershipRole.getName() + " does not exists. Will not be assigned.");
}
}
}
示例10: assignMemberGroups
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
private static void assignMemberGroups(List<UsergroupAsMember> memberGroups, long companyId, long groupId) {
if (Objects.isNull(memberGroups) || memberGroups.isEmpty()) {
return;
}
for (UsergroupAsMember memberGroup : memberGroups) {
try {
UserGroup liferayUserGroup = UserGroupLocalServiceUtil.getUserGroup(companyId, memberGroup.getUsergroupName());
Group liferayGroup = GroupLocalServiceUtil.getGroup(groupId);
GroupLocalServiceUtil.addUserGroupGroup(liferayUserGroup.getUserGroupId(), liferayGroup);
LOG.info("UserGroup " + liferayUserGroup.getName() + " was assigned as site member to " + liferayGroup.getDescriptiveName());
assignGroupMemberRoles(memberGroup.getRole(), companyId, liferayGroup, liferayUserGroup);
} catch (PortalException e) {
LOG.error("Cannot find UserGroup with name: " + memberGroup.getUsergroupName() + ". Group won't be assigned to site.", e);
continue;
}
}
}
示例11: assignGroupMemberRoles
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
private static void assignGroupMemberRoles(List<Role> membershipRoles, long companyId, Group liferayGroup, UserGroup liferayUserGroup) {
if (Objects.isNull(membershipRoles) || membershipRoles.isEmpty()) {
return;
}
for (Role membershipRole : membershipRoles) {
try {
com.liferay.portal.kernel.model.Role liferayRole = RoleLocalServiceUtil.getRole(companyId, membershipRole.getName());
UserGroupGroupRoleLocalServiceUtil.addUserGroupGroupRoles(liferayUserGroup.getUserGroupId(), liferayGroup.getGroupId(), new long[] {liferayRole.getRoleId()});
StringBuilder sb = new StringBuilder("Role ")
.append(liferayRole.getDescriptiveName())
.append(" assigned to UserGroup ")
.append(liferayUserGroup.getName())
.append(" for site ")
.append(liferayGroup.getDescriptiveName());
LOG.info(sb.toString());
} catch (PortalException e) {
LOG.error("Can not add role with name" + membershipRole.getName() + " does not exists. Will not be assigned.");
}
}
}
示例12: setCustomFields
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
static void setCustomFields(final long runAsUserId, final long groupId,
final long company, final Site site) {
if (site.getCustomFieldSetting() == null || site.getCustomFieldSetting().isEmpty()) {
LOG.error("Site does has no Expando field settings.");
} else {
Class clazz = com.liferay.portal.kernel.model.Group.class;
String resolverHint = "Resolving customized value for page " + site.getName() + " "
+ "failed for key %%key%% " + "and value %%value%%";
for (CustomFieldSetting cfs : site.getCustomFieldSetting()) {
String key = cfs.getKey();
String value = cfs.getValue();
CustomFieldSettingUtil.setExpandoValue(
resolverHint.replace("%%key%%", key).replace("%%value%%", value),
runAsUserId, groupId, company, clazz, groupId, key, value);
}
}
}
示例13: getApplicationDisplayTemplates
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
/**
* Returns the DL File Entry types templates
*
* @param permissionChecker The current context's permission checker
* @param groupId The current site ID
* @param classNameId The template's classNameId
* @return A list of templates indexed by file entry types
*
* @throws PortalException If an error occurs while searching templates
*/
private Map<Group, List<DDMTemplate>> getApplicationDisplayTemplates(PermissionChecker permissionChecker, long groupId, long classNameId) throws PortalException {
HashMap<Group, List<DDMTemplate>> adts = new HashMap<>();
long[] currentGroupIds = this.portal.getCurrentAndAncestorSiteGroupIds(groupId);
long userId = permissionChecker.getUserId();
for(long currentGroupId : currentGroupIds) {
List<DDMTemplate> groupTemplates = this.ddmTemplateService.getTemplates(currentGroupId, classNameId)
.stream()
.filter(template -> {
// See DDMTemplatePermission.java in Liferay's source code for the inspirational stuff
String modelResourceName = DDMTemplate.class.getName();
long companyId = template.getCompanyId();
long templateId = template.getTemplateId();
String actionKey = ActionKeys.VIEW;
return (
permissionChecker.hasOwnerPermission(companyId, modelResourceName, templateId, userId, actionKey) ||
permissionChecker.hasPermission(companyId, modelResourceName, templateId, actionKey)
);
})
.collect(Collectors.toList());
// If we have templates to show, put it in the map
if(!groupTemplates.isEmpty()) {
Group group = this.groupService.getGroup(currentGroupId);
adts.put(group, groupTemplates);
}
}
return adts;
}
示例14: displayTerm
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
@Override
public String displayTerm(HttpServletRequest request, FacetConfiguration facetConfiguration, String queryTerm) {
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
Locale locale = themeDisplay.getLocale();
try {
Group group = groupLocalService.getGroup(Long.parseLong(queryTerm));
return group.getDescriptiveName(locale);
} catch (PortalException e) {
LOG.warn("Could not retrieve Scope/Group label from id [" + queryTerm + "]", e);
return queryTerm;
}
}
示例15: getWebSite
import com.liferay.portal.kernel.model.Group; //导入依赖的package包/类
@Override
public Optional<WebSite> getWebSite(long groupId) {
try {
Group group = _groupLocalService.getGroup(groupId);
return Optional.ofNullable(new WebSiteImpl(group));
}
catch (NoSuchGroupException nsge) {
return Optional.empty();
}
catch (PortalException pe) {
throw new ServerErrorException(500, pe);
}
}