Mario González
Mario González

Reputation: 31

Liferay 7.3.7 error "Denied access to model object as it does not belong to current company"

I'm preparing to migrate from Liferay 7.3.5GA6 to 7.3.7GA8 version. I'm facing an error on a ftl template that states: Denied access to model object as it does not belong to current company 20116 The code in which this happens is the following:

<#list AssetEntryAssetCategoryRelLocalService.getAssetEntryAssetCategoryRelsByAssetCategoryId(category.getCategoryId()) as curEntry>

This is working properly on 7.3.5GA6. I've found 2 similar bugs on Liferay Bug tracking, https://issues.liferay.com/browse/LPS-133074 and https://issues.liferay.com/browse/LPS-125553 but they're not exactly the same. I presume it's something related to new security capabilities from one of the bugs, but I'm not sure if in my case it's a bug or really it's working as expected

Upvotes: 1

Views: 341

Answers (1)

Mario Gonz&#225;lez
Mario Gonz&#225;lez

Reputation: 31

I've found the problem. It appears to be related to an earlier migration, from 7.1.3 to 7.3.5. In that migration, the model for relation between categories and assets changed, and the migration process left some "garbage" behind. In my case, some of the entries in the ASSETENTRYASSETCATEGORYREL table had the COMPANYID column with NULL value. They were not being used, but in my code, as I was taking all the relations for a particular categoryId, they had the NULL value instead of 20116 (my companyId value), and thus the error. I've deleted all the entries with NULL value and everything works again.

Upvotes: 1

Related Questions