protected void copyResourcePermissions(String sourcePortletId, String targetPortletId) { Layout layout = getLayout(); Portlet portlet = PortletLocalServiceUtil.getPortletById(getCompanyId(), sourcePortletId); String sourcePortletPrimaryKey = PortletPermissionUtil.getPrimaryKey(layout.getPlid(), sourcePortletId); List<ResourcePermission> resourcePermissions = ResourcePermissionLocalServiceUtil.getResourcePermissions( portlet.getCompanyId(), portlet.getPortletName(), PortletKeys.PREFS_OWNER_TYPE_USER, sourcePortletPrimaryKey); for (ResourcePermission resourcePermission : resourcePermissions) { String targetPortletPrimaryKey = PortletPermissionUtil.getPrimaryKey(layout.getPlid(), targetPortletId); resourcePermission.setResourcePermissionId(CounterLocalServiceUtil.increment()); resourcePermission.setPrimKey(targetPortletPrimaryKey); ResourcePermissionLocalServiceUtil.addResourcePermission(resourcePermission); } }
protected Image addImage() throws Exception { return ImageLocalServiceUtil.updateImage( CounterLocalServiceUtil.increment(), FileUtil.getBytes(getClass(), "dependencies/liferay.jpg")); }