RE: Liferay Guestbook Web Application 7.2, ModelResourcePermissionFactory e

thumbnail
Ivano Carrara, modified 6 Years ago. Expert Posts: 350 Join Date: 7/3/05 Recent Posts
Dear all, following the Guestbook tutorial from 7.1 documentation but in the 7.2 environment I found an issue in the "Using Resources and Permissions" chapter.


In the <somepackage>guestbook.internal.security.permission.resource I created the GuestbookModelResourcePermissionRegistrar class.


But in the activate() method I get an error that cause that I can't deploy the guestbook-service and guestbook-web modules:


@Activate
    public void activate(BundleContext bundleContext) {
        
        Dictionary<String, Object> properties = new HashMapDictionary<>();

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

        _serviceRegistration = bundleContext.registerService(
            ModelResourcePermission.class,
            ModelResourcePermissionFactory.create(   // ERROR: The type com.liferay.petra.function.UnsafeFunction cannot be resolved. It is indirectly referenced from required .class files
                Guestbook.class, Guestbook::getGuestbookId,
                _guestbookLocalService::getGuestbook, _portletResourcePermission,
                (modelResourcePermission, consumer) -> {
                    consumer.accept(
                        new StagedModelPermissionLogic<>(
                            _stagingPermission, GuestbookPortletKeys.GUESTBOOK,
                            Guestbook::getGuestbookId));
                    consumer.accept(
                        new WorkflowedModelPermissionLogic<>(
                                _workflowPermission, modelResourcePermission,
                                _groupLocalService, Guestbook::getGuestbookId));
                }),
            properties);
    }


The same error happens for both Guestbook and Entity entities of the tutorial.


Please anyone is already aware of the above issues?


Thank you in advance,
Ivano C.
thumbnail
Ivano Carrara, modified 6 Years ago. Expert Posts: 350 Join Date: 7/3/05 Recent Posts
SOLVED


In build.grade I added:

compileOnly group: "com.liferay", name: "com.liferay.petra.function"