List of usage examples for com.liferay.portal.kernel.search IndexerRegistryUtil register
public static void register(Indexer<?> indexer)
From source file:com.liferay.alloy.mvc.BaseAlloyControllerImpl.java
License:Open Source License
protected void initIndexer() { indexer = buildIndexer();//from w w w .j a v a 2s. co m if (indexer == null) { return; } indexerClassName = indexer.getClassNames()[0]; Indexer existingIndexer = IndexerRegistryUtil.getIndexer(indexerClassName); if ((existingIndexer != null) && (existingIndexer == indexer)) { BaseAlloyIndexer baseAlloyIndexer = (BaseAlloyIndexer) indexer; alloyServiceInvoker = baseAlloyIndexer.getAlloyServiceInvoker(); return; } alloyServiceInvoker = new AlloyServiceInvoker(indexerClassName); BaseAlloyIndexer baseAlloyIndexer = (BaseAlloyIndexer) indexer; baseAlloyIndexer.setAlloyServiceInvoker(alloyServiceInvoker); baseAlloyIndexer.setPortletId(portlet.getRootPortletId()); PortletBag portletBag = PortletBagPool.get(portlet.getPortletId()); List<Indexer> indexerInstances = portletBag.getIndexerInstances(); if (existingIndexer != null) { IndexerRegistryUtil.unregister(existingIndexer); indexerInstances.remove(existingIndexer); } IndexerRegistryUtil.register(indexer); indexerInstances.add(indexer); }
From source file:com.liferay.asset.service.test.AssetCategoryLocalServiceTest.java
License:Open Source License
@After public void tearDown() throws Exception { if (_organizationIndexer != null) { IndexerRegistryUtil.register(_organizationIndexer); } }
From source file:com.liferay.asset.service.test.AssetCategoryLocalServiceTest.java
License:Open Source License
@Test public void testDeleteCategory() throws Exception { Map<Locale, String> titleMap = new HashMap<>(); titleMap.put(LocaleUtil.US, RandomTestUtil.randomString()); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId()); AssetVocabulary assetVocabulary = AssetVocabularyLocalServiceUtil.addVocabulary(TestPropsValues.getUserId(), _group.getGroupId(), RandomTestUtil.randomString(), titleMap, null, null, serviceContext); AssetCategory assetCategory = AssetCategoryLocalServiceUtil.addCategory(TestPropsValues.getUserId(), _group.getGroupId(), RandomTestUtil.randomString(), assetVocabulary.getVocabularyId(), serviceContext);//from w ww . ja v a2s . com serviceContext.setAssetCategoryIds(new long[] { assetCategory.getCategoryId() }); _organization = OrganizationLocalServiceUtil.addOrganization(TestPropsValues.getUserId(), OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, RandomTestUtil.randomString(), OrganizationConstants.TYPE_ORGANIZATION, 0, 0, ListTypeConstants.ORGANIZATION_STATUS_DEFAULT, RandomTestUtil.randomString(), true, serviceContext); TestAssetIndexer testAssetIndexer = new TestAssetIndexer(); testAssetIndexer.setExpectedValues(Organization.class.getName(), _organization.getOrganizationId()); if (_organizationIndexer == null) { _organizationIndexer = IndexerRegistryUtil.getIndexer(Organization.class); } IndexerRegistryUtil.register(testAssetIndexer); AssetCategoryLocalServiceUtil.deleteCategory(assetCategory, true); }
From source file:com.liferay.asset.service.test.AssetTagLocalServiceTest.java
License:Open Source License
@Test public void testDeleteTag() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId()); AssetTag assetTag = AssetTagLocalServiceUtil.addTag(TestPropsValues.getUserId(), _group.getGroupId(), "Tag", serviceContext);//from w w w .j a va2 s . c o m serviceContext.setAssetTagNames(new String[] { assetTag.getName() }); _organization = OrganizationLocalServiceUtil.addOrganization(TestPropsValues.getUserId(), OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, RandomTestUtil.randomString(), OrganizationConstants.TYPE_ORGANIZATION, 0, 0, ListTypeConstants.ORGANIZATION_STATUS_DEFAULT, RandomTestUtil.randomString(), true, serviceContext); TestAssetIndexer testAssetIndexer = new TestAssetIndexer(); testAssetIndexer.setExpectedValues(Organization.class.getName(), _organization.getOrganizationId()); if (_organizationIndexer == null) { _organizationIndexer = IndexerRegistryUtil.getIndexer(Organization.class); } IndexerRegistryUtil.register(testAssetIndexer); AssetTagLocalServiceUtil.deleteTag(assetTag); Assert.assertNull(AssetTagLocalServiceUtil.fetchAssetTag(assetTag.getTagId())); long classNameId = PortalUtil.getClassNameId(Organization.class); AssetTagStats assetTagStats = AssetTagStatsLocalServiceUtil.getTagStats(assetTag.getTagId(), classNameId); Assert.assertEquals(0, assetTagStats.getAssetCount()); }
From source file:com.liferay.portlet.PortletBagFactory.java
License:Open Source License
protected List<Indexer> newIndexers(Portlet portlet) throws Exception { List<Indexer> indexerInstances = new ArrayList<Indexer>(); List<String> indexerClasses = portlet.getIndexerClasses(); for (String indexerClass : indexerClasses) { Indexer indexerInstance = (Indexer) newInstance(Indexer.class, indexerClass); IndexerRegistryUtil.register(indexerInstance); indexerInstances.add(indexerInstance); }//from w ww. j a v a 2s . co m return indexerInstances; }
From source file:com.liferay.util.bridges.alloy.BaseAlloyControllerImpl.java
License:Open Source License
protected void initIndexer() { indexer = buildIndexer(); if (indexer != null) { IndexerRegistryUtil.register(indexer); } }