RE: Searching and indexing custom Entity in Liferay 7.4 Using Elastic Search

Amresh kumar, modified 3 Years ago. New Member Posts: 20 Join Date: 5/17/12 Recent Posts
@Component(immediate = true)

public class EmployeeEntryModelResourcePermissionRegistrar {

@Activate

public void activate(BundleContext bundleContext) {

Dictionary<String, Object> properties = new HashMapDictionary<>();

properties.put("model.class.name", Employee.class.getName());

_serviceRegistration = bundleContext.registerService(

ModelResourcePermission.class,

ModelResourcePermissionFactory.create(

Employee.class, Employee::getEmployeeId,

_empoloyeeLocalService::getEmployee, _portletResourcePermission,

(modelResourcePermission, consumer) -> {

consumer.accept(

new StagedModelPermissionLogic<>(

_stagingPermission, "com_test_TestDemoPortlet",

Employee::getEmployeeId));

  consumer.accept( new WorkflowedModelPermissionLogic<>( _workflowPermission,

  modelResourcePermission, _groupLocalService, Employee::getEmployeeId));

}),properties);

}

@Deactivate

public void deactivate() {

_serviceRegistration.unregister();

}@Reference

private EmployeeLocalService _empoloyeeLocalService;

@Reference(target = "(resource.name=" + "com.emp.service.employee" + ")")

private PortletResourcePermission _portletResourcePermission;

private ServiceRegistration<ModelResourcePermission> _serviceRegistration;

@Reference

private StagingPermission _stagingPermission;

@Reference

private WorkflowPermission _workflowPermission;

@Reference

private GroupLocalService _groupLocalService;

Hi,

I have developed the Indexer by extending BaseIndexer and there is an option to disabled the permission check 

setPermissionAware(false); is working absolutly fine.

Try to use the newer approach as below for indexing , setPermissionAware(true/false) is not longer necessary.

How to disabled permission in newer approach any idea ?

thumbnail
Russell Bohl, modified 3 Years ago. Expert Posts: 308 Join Date: 2/13/13 Recent Posts

Hi Amresh, with the new composite indexing framework it is no longer possible (as far as I know) to set permissions aware to false.

Indexing Introduction in Liferay Help Center

However, you can probably get the behavior you want (I am guessing you want unauthenticated users to be able to search for your entity) by allowing guests to view the asset.

Amresh kumar, modified 3 Years ago. New Member Posts: 20 Join Date: 5/17/12 Recent Posts

Thanks a lot Russell for your prompt response.

Finally I have implemented the permission and now working fine.