
com.liferay.search.experiences.internal.info.collection.provider.BlogsEntrySXPBlueprintInfoCollectionProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.search.experiences.service
Show all versions of com.liferay.search.experiences.service
Liferay Search Experiences Service
The newest version!
/**
* SPDX-FileCopyrightText: (c) 2025 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.search.experiences.internal.info.collection.provider;
import com.liferay.asset.util.AssetHelper;
import com.liferay.blogs.model.BlogsEntry;
import com.liferay.blogs.service.BlogsEntryLocalService;
import com.liferay.info.collection.provider.CollectionQuery;
import com.liferay.info.collection.provider.FilteredInfoCollectionProvider;
import com.liferay.info.collection.provider.SingleFormVariationInfoCollectionProvider;
import com.liferay.info.pagination.InfoPage;
import com.liferay.petra.function.transform.TransformUtil;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.search.Field;
import com.liferay.portal.search.document.Document;
import com.liferay.portal.search.hits.SearchHits;
import com.liferay.portal.search.searcher.SearchRequestBuilderFactory;
import com.liferay.portal.search.searcher.SearchResponse;
import com.liferay.portal.search.searcher.Searcher;
import com.liferay.search.experiences.model.SXPBlueprint;
import java.util.Collections;
import java.util.List;
/**
* @author Joshua Cords
*/
public class BlogsEntrySXPBlueprintInfoCollectionProvider
extends SXPBlueprintInfoCollectionProvider
implements FilteredInfoCollectionProvider,
SingleFormVariationInfoCollectionProvider {
public BlogsEntrySXPBlueprintInfoCollectionProvider(
AssetHelper assetHelper, BlogsEntryLocalService blogsEntryLocalService,
Searcher searcher,
SearchRequestBuilderFactory searchRequestBuilderFactory,
SXPBlueprint sxpBlueprint) {
super(assetHelper, searcher, searchRequestBuilderFactory, sxpBlueprint);
_blogsEntryLocalService = blogsEntryLocalService;
}
@Override
public InfoPage getCollectionInfoPage(
CollectionQuery collectionQuery) {
try {
SearchResponse searchResponse = getCollectionQuerySearchResponse(
collectionQuery);
return InfoPage.of(
_getBlogEntries(searchResponse.getSearchHits()),
collectionQuery.getPagination(), searchResponse.getTotalHits());
}
catch (Exception exception) {
_log.error("Unable to get blog entries", exception);
}
return InfoPage.of(
Collections.emptyList(), collectionQuery.getPagination(), 0);
}
private List _getBlogEntries(SearchHits searchHits) {
return TransformUtil.transform(
searchHits.getSearchHits(),
searchHit -> {
Document document = searchHit.getDocument();
return _blogsEntryLocalService.getBlogsEntry(
document.getLong(Field.ENTRY_CLASS_PK));
});
}
private static final Log _log = LogFactoryUtil.getLog(
BlogsEntrySXPBlueprintInfoCollectionProvider.class);
private final BlogsEntryLocalService _blogsEntryLocalService;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy