[FORWARD PORT] LPS-50649 fix condition and add classNameId

This is a forward port of https://github.com/sergiogonzalez/liferay-plugins-ee/pull/117