List of usage examples for com.liferay.portal.kernel.service GroupLocalServiceUtil getGroup
public static com.liferay.portal.kernel.model.Group getGroup(long groupId) throws com.liferay.portal.kernel.exception.PortalException
From source file:ch.inofix.contact.service.impl.ContactLocalServiceImpl.java
License:Open Source License
protected SearchContext buildSearchContext(long userId, long groupId, long ownerUserId, String company, String fullName, int status, LinkedHashMap<String, Object> params, boolean andSearch, int start, int end, Sort sort) throws PortalException { SearchContext searchContext = new SearchContext(); searchContext.setAttribute(Field.STATUS, status); if (Validator.isNotNull(company)) { searchContext.setAttribute("company", company); }// w w w.ja va2s . c o m if (Validator.isNotNull(fullName)) { searchContext.setAttribute("fullName", fullName); } searchContext.setAttribute("paginationType", "more"); Group group = GroupLocalServiceUtil.getGroup(groupId); searchContext.setCompanyId(group.getCompanyId()); if (ownerUserId > 0) { searchContext.setOwnerUserId(ownerUserId); } searchContext.setEnd(end); if (groupId > 0) { searchContext.setGroupIds(new long[] { groupId }); } searchContext.setSorts(sort); searchContext.setStart(start); searchContext.setUserId(userId); searchContext.setAndSearch(andSearch); if (params != null) { String keywords = (String) params.remove("keywords"); if (Validator.isNotNull(keywords)) { searchContext.setKeywords(keywords); } } QueryConfig queryConfig = new QueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); searchContext.setQueryConfig(queryConfig); if (sort != null) { searchContext.setSorts(sort); } searchContext.setStart(start); return searchContext; }
From source file:ch.inofix.referencemanager.service.impl.ReferenceLocalServiceImpl.java
License:Open Source License
protected SearchContext buildSearchContext(long userId, long groupId, long bibliographyId, String author, String title, String year, int status, LinkedHashMap<String, Object> params, boolean andSearch, int start, int end, Sort sort) throws PortalException { SearchContext searchContext = new SearchContext(); searchContext.setAttribute(Field.STATUS, status); if (Validator.isNotNull(author)) { searchContext.setAttribute("author", author); }/*from w ww . j a v a 2s .com*/ if (bibliographyId > 0) { searchContext.setAttribute("bibliographyId", bibliographyId); } if (Validator.isNotNull(title)) { searchContext.setAttribute("title", title); } if (Validator.isNotNull(year)) { searchContext.setAttribute("year", year); } searchContext.setAttribute("paginationType", "more"); Group group = GroupLocalServiceUtil.getGroup(groupId); searchContext.setCompanyId(group.getCompanyId()); searchContext.setEnd(end); if (groupId > 0) { searchContext.setGroupIds(new long[] { groupId }); } searchContext.setSorts(sort); searchContext.setStart(start); searchContext.setUserId(userId); searchContext.setAndSearch(andSearch); if (params != null) { String keywords = (String) params.remove("keywords"); if (Validator.isNotNull(keywords)) { searchContext.setKeywords(keywords); } } QueryConfig queryConfig = new QueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); searchContext.setQueryConfig(queryConfig); if (sort != null) { searchContext.setSorts(sort); } searchContext.setStart(start); return searchContext; }
From source file:ch.inofix.timetracker.service.impl.TaskRecordLocalServiceImpl.java
License:Open Source License
@Override public Hits search(long userId, long groupId, String keywords, int start, int end, Sort sort) throws PortalException { if (sort == null) { sort = new Sort(Field.MODIFIED_DATE, true); }/*from w w w . ja v a 2 s. c om*/ Indexer<TaskRecord> indexer = IndexerRegistryUtil.getIndexer(TaskRecord.class.getName()); SearchContext searchContext = new SearchContext(); searchContext.setAttribute(Field.STATUS, WorkflowConstants.STATUS_ANY); searchContext.setAttribute("paginationType", "more"); Group group = GroupLocalServiceUtil.getGroup(groupId); searchContext.setCompanyId(group.getCompanyId()); searchContext.setEnd(end); if (groupId > 0) { searchContext.setGroupIds(new long[] { groupId }); } searchContext.setSorts(sort); searchContext.setStart(start); searchContext.setUserId(userId); searchContext.setKeywords(keywords); return indexer.search(searchContext); }
From source file:com.liferay.akismet.moderation.util.ModerationUtil.java
License:Open Source License
protected static DynamicQuery buildMBMessageDynamicQuery(long scopeGroupId, boolean discussion) throws PortalException { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(MBMessage.class); Group group = GroupLocalServiceUtil.getGroup(scopeGroupId); if (!group.isCompany()) { Property groupIdProperty = PropertyFactoryUtil.forName("groupId"); Long[] scopeGroupIds = getChildScopeGroupIds(scopeGroupId); dynamicQuery.add(groupIdProperty.in(scopeGroupIds)); }/*from w w w .j a v a 2s .c o m*/ Property categoryIdProperty = PropertyFactoryUtil.forName("categoryId"); if (discussion) { dynamicQuery.add(categoryIdProperty.eq(MBCategoryConstants.DISCUSSION_CATEGORY_ID)); } else { dynamicQuery.add(categoryIdProperty.ne(MBCategoryConstants.DISCUSSION_CATEGORY_ID)); } Property statusProperty = PropertyFactoryUtil.forName("status"); dynamicQuery.add(statusProperty.eq(WorkflowConstants.STATUS_DENIED)); return dynamicQuery; }
From source file:com.liferay.akismet.moderation.util.ModerationUtil.java
License:Open Source License
protected static DynamicQuery buildWikiPageDynamicQuery(long scopeGroupId) throws PortalException { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(WikiPage.class); Group group = GroupLocalServiceUtil.getGroup(scopeGroupId); if (!group.isCompany()) { Property groupIdProperty = PropertyFactoryUtil.forName("groupId"); Long[] scopeGroupIds = getChildScopeGroupIds(scopeGroupId); dynamicQuery.add(groupIdProperty.in(scopeGroupIds)); }/*ww w. j av a 2 s. c o m*/ Property summaryProperty = PropertyFactoryUtil.forName("summary"); dynamicQuery.add(summaryProperty.eq(AkismetConstants.WIKI_PAGE_PENDING_APPROVAL)); return dynamicQuery; }
From source file:com.liferay.asset.publisher.web.display.context.SitesThatIAdministerItemSelectorViewDisplayContext.java
License:Open Source License
private LinkedHashMap<String, Object> _getGroupParams() throws PortalException { if (_groupParams != null) { return _groupParams; }/* w ww . j a va 2 s .co m*/ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); User user = themeDisplay.getUser(); boolean filterManageableGroups = true; if (permissionChecker.isCompanyAdmin()) { filterManageableGroups = false; } _groupParams = new LinkedHashMap<>(); _groupParams.put("active", Boolean.TRUE); if (filterManageableGroups) { _groupParams.put("usersGroups", user.getUserId()); } _groupParams.put("site", Boolean.TRUE); if (getGroupId() > 0) { List<Long> excludedGroupIds = new ArrayList<>(); Group group = GroupLocalServiceUtil.getGroup(getGroupId()); if (group.isStagingGroup()) { excludedGroupIds.add(group.getLiveGroupId()); } else { excludedGroupIds.add(getGroupId()); } _groupParams.put("excludedGroupIds", excludedGroupIds); } return _groupParams; }
From source file:com.liferay.asset.taglib.internal.display.context.InputAssetLinksDisplayContext.java
License:Open Source License
public String getGroupDescriptiveName(AssetEntry assetEntry) throws PortalException { Group group = GroupLocalServiceUtil.getGroup(assetEntry.getGroupId()); return group.getDescriptiveName(_themeDisplay.getLocale()); }
From source file:com.liferay.calendar.notification.impl.NotificationUtil.java
License:Open Source License
public static User getDefaultSenderUser(Calendar calendar) throws Exception { CalendarResource calendarResource = calendar.getCalendarResource(); User user = UserLocalServiceUtil.getUser(calendarResource.getUserId()); if (calendarResource.isGroup()) { Group group = GroupLocalServiceUtil.getGroup(calendarResource.getClassPK()); user = UserLocalServiceUtil.getUser(group.getCreatorUserId()); } else if (calendarResource.isUser()) { user = UserLocalServiceUtil.getUser(calendarResource.getClassPK()); }//from w w w . ja v a 2s. com return user; }
From source file:com.liferay.dynamic.data.mapping.model.impl.DDMStructureImpl.java
License:Open Source License
@Override public String getUnambiguousName(List<DDMStructure> structures, long groupId, final Locale locale) throws PortalException { if (getGroupId() == groupId) { return getName(locale); }/*from w w w. j a v a 2s .co m*/ boolean hasAmbiguousName = ListUtil.exists(structures, new PredicateFilter<DDMStructure>() { @Override public boolean filter(DDMStructure structure) { if (structure.getStructureId() == getStructureId()) { return false; } String name = structure.getName(locale); if (name.equals(getName(locale))) { return true; } return false; } }); if (hasAmbiguousName) { Group group = GroupLocalServiceUtil.getGroup(getGroupId()); return group.getUnambiguousName(getName(locale), locale); } return getName(locale); }
From source file:com.liferay.exportimport.content.processor.base.BaseTextExportImportContentProcessor.java
License:Open Source License
protected String replaceExportDLReferences(PortletDataContext portletDataContext, StagedModel stagedModel, String content, boolean exportReferencedContent) throws Exception { Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getGroupId()); if (group.isStagingGroup()) { group = group.getLiveGroup();//from w w w . j av a2s . c o m } if (group.isStaged() && !group.isStagedRemotely() && !group.isStagedPortlet(PortletKeys.DOCUMENT_LIBRARY)) { return content; } StringBuilder sb = new StringBuilder(content); String contextPath = PortalUtil.getPathContext(); String[] patterns = { contextPath.concat("/c/document_library/get_file?"), contextPath.concat("/documents/"), contextPath.concat("/image/image_gallery?") }; int beginPos = -1; int endPos = content.length(); while (true) { beginPos = StringUtil.lastIndexOfAny(content, patterns, endPos); if (beginPos == -1) { break; } Map<String, String[]> dlReferenceParameters = getDLReferenceParameters( portletDataContext.getScopeGroupId(), content, beginPos + contextPath.length(), endPos); FileEntry fileEntry = getFileEntry(dlReferenceParameters); if (fileEntry == null) { endPos = beginPos - 1; continue; } endPos = MapUtil.getInteger(dlReferenceParameters, "endPos"); try { if (exportReferencedContent && !fileEntry.isInTrash()) { StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, stagedModel, fileEntry, PortletDataContext.REFERENCE_TYPE_DEPENDENCY); } else { Element entityElement = portletDataContext.getExportDataElement(stagedModel); String referenceType = PortletDataContext.REFERENCE_TYPE_DEPENDENCY; if (fileEntry.isInTrash()) { referenceType = PortletDataContext.REFERENCE_TYPE_DEPENDENCY_DISPOSABLE; } portletDataContext.addReferenceElement(stagedModel, entityElement, fileEntry, referenceType, true); } String path = ExportImportPathUtil.getModelPath(fileEntry); StringBundler exportedReferenceSB = new StringBundler(6); exportedReferenceSB.append("[$dl-reference="); exportedReferenceSB.append(path); exportedReferenceSB.append("$]"); if (fileEntry.isInTrash()) { String originalReference = sb.substring(beginPos, endPos); exportedReferenceSB.append("[#dl-reference="); exportedReferenceSB.append(originalReference); exportedReferenceSB.append("#]"); } sb.replace(beginPos, endPos, exportedReferenceSB.toString()); int deleteTimestampParametersOffset = beginPos; if (fileEntry.isInTrash()) { deleteTimestampParametersOffset = sb.indexOf("[#dl-reference=", beginPos); } deleteTimestampParameters(sb, deleteTimestampParametersOffset); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } else if (_log.isWarnEnabled()) { StringBundler exceptionSB = new StringBundler(6); exceptionSB.append("Unable to process file entry "); exceptionSB.append(fileEntry.getFileEntryId()); exceptionSB.append(" for staged model "); exceptionSB.append(stagedModel.getModelClassName()); exceptionSB.append(" with primary key "); exceptionSB.append(stagedModel.getPrimaryKeyObj()); _log.warn(exceptionSB.toString()); } } endPos = beginPos - 1; } return sb.toString(); }