Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Christopher Olbertz
How to get PermissionChecker?
May 22, 2012 9:43 AM
Answer

Christopher Olbertz

Rank: Regular Member

Posts: 102

Join Date: November 21, 2007

Recent Posts

Hi everybody,

I am working on a portlet with permissions and I used ServiceBuilder for the service layer. I found the information, that every implementation class has the method getPermissionChecker. But my implementation class does not have this method.

This is my implementation class with an add() method:

 1public class PRProductLocalServiceImpl extends PRProductLocalServiceBaseImpl {
 2    /**
 3     * Adds a new product to the database.
 4     *
 5     * @param productName
 6     * @param productSerial
 7     * @return
 8     * @throws com.liferay.portal.kernel.exception.SystemException
 9     */
10    public PRProduct addProduct(PRProduct newProduct, long userId)
11        throws SystemException, PortalException {
12
13       
14        PRProduct product =
15            prProductPersistence.create(
16                counterLocalService.increment(PRProduct.class.getName()));
17
18        product.setProductName(newProduct.getProductName());
19        product.setSerialNumber(newProduct.getSerialNumber());
20        product.setCompanyId(newProduct.getCompanyId());
21        product.setGroupId(newProduct.getGroupId());
22       
23        resourceLocalService.addResources(
24            newProduct.getCompanyId(), newProduct.getGroupId(), userId,
25            PRProduct.class.getName(), product.getPrimaryKey(), false,
26            true, true);
27
28        return prProductPersistence.update(product, false);
29    }
30}


If I understand it correctly, I am able to call getPermissionChecker() in my add() method. Or do I do somethong wrong?

Thank you,

Christopher
Juan Gonzalez
RE: How to get PermissionChecker?
May 22, 2012 9:59 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2137

Join Date: October 28, 2008

Recent Posts

Did you test in your external service (XXXServiceImpl) instead?
Shinn Lok
RE: How to get PermissionChecker?
May 22, 2012 10:15 AM
Answer

Shinn Lok

LIFERAY STAFF

Rank: Junior Member

Posts: 69

Join Date: January 14, 2011

Recent Posts

As Juan said, *LocalServiceImpls don't have permission checks. You would need to put it in PRProductServiceImpl which extends PRProductServiceBaseImpl, BaseServiceImpl. There you will find the getPermissionChecker().