Example usage for com.liferay.portal.kernel.service ResourceLocalServiceUtil getResource

List of usage examples for com.liferay.portal.kernel.service ResourceLocalServiceUtil getResource

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service ResourceLocalServiceUtil getResource.

Prototype

public static com.liferay.portal.kernel.model.Resource getResource(long companyId, String name, int scope,
        String primKey) 

Source Link

Document

Returns a new resource with the name and primary key at the scope.

Usage

From source file:com.liferay.exportimport.test.PermissionExportImportTest.java

License:Open Source License

protected void validateImportedPortletPermissions(Group importGroup, Role role, String importResourcePrimKey)
        throws Exception {

    List<String> actions = ResourceActionsUtil.getResourceActions(_PORTLET_ID, null);

    Resource resource = ResourceLocalServiceUtil.getResource(TestPropsValues.getCompanyId(), _PORTLET_ID,
            ResourceConstants.SCOPE_INDIVIDUAL, importResourcePrimKey);

    List<String> currentIndividualActions = new ArrayList<>();

    ResourcePermissionUtil.populateResourcePermissionActionIds(importGroup.getGroupId(), role, resource,
            actions, currentIndividualActions, new ArrayList<String>(), new ArrayList<String>(),
            new ArrayList<String>());

    Assert.assertEquals(currentIndividualActions.toString(), _ACTION_IDS.length,
            currentIndividualActions.size());

    for (String action : currentIndividualActions) {
        boolean foundActionId = false;

        for (String actionId : _ACTION_IDS) {
            if (action.equals(actionId)) {
                foundActionId = true;/*w  w  w.  ja  v  a2  s . co m*/

                break;
            }
        }

        Assert.assertTrue("Unable to import permissions", foundActionId);
    }
}