Unsatisfied Permission References in -ServiceImpl classes

David Ilechukwu, modified 7 Years ago. Regular Member Posts: 154 Join Date: 6/7/10 Recent Posts
I have the following permissions variable declarations  in my -ServiceImpl classes

&nbsp; &nbsp; private static volatile ModelResourcePermission<credentialtype>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _credentialTypeModelResourcePermission =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ModelResourcePermissionFactory.getInstance(
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CredentialTypeServiceImpl.class,
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "_credentialTypeModelResourcePermission", CredentialType.class);
&nbsp; &nbsp;&nbsp;
&nbsp; &nbsp; private static volatile PortletResourcePermission
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _portletResourcePermission =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PortletResourcePermissionFactory.getInstance(
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CredentialTypeServiceImpl.class, "_portletResourcePermission",
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HrmCoreConstants.RESOURCE_NAME);&nbsp;
</credentialtype>

But why I try to use these variables in a permissions check method, like this
&nbsp; &nbsp; &nbsp; &nbsp; _portletResourcePermission.check(getPermissionChecker(),&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; serviceContext.getScopeGroupId(), ActionKeys.ADD_CREDENTIAL_TYPE);&nbsp;

I get the "Unsatisfied References error" stating that the variables could be resolved because the target class 
​​​​​​​model.class.name=com.tpl.pmedics.hrm_core.model.CredentialType
 was unavilable. I get the same errors for my _portletResourcePermission variable, when I try to use it in a permisions check.

And then this error seems to propagate into  my portlet web module as well, since my OSGI references (in my helper permission classes) fail as well-
&nbsp; &nbsp; @Reference(
&nbsp; &nbsp; &nbsp; &nbsp; target = "(model.class.name=com.tpl.pmedics.hrm_core.model.CredentialType)",
&nbsp; &nbsp; &nbsp; &nbsp; unbind = "-"
&nbsp; &nbsp; )
&nbsp; &nbsp; protected void setModelResourcePermission(
&nbsp; &nbsp; &nbsp; &nbsp; ModelResourcePermission<credentialtype> modelResourcePermission) {

&nbsp; &nbsp; &nbsp; &nbsp; _credentialTypeModelResourcePermission = modelResourcePermission;
&nbsp; &nbsp; }

&nbsp; &nbsp; private static ModelResourcePermission<credentialtype>
&nbsp; &nbsp; &nbsp; &nbsp; _credentialTypeModelResourcePermission; &nbsp;
</credentialtype></credentialtype>

giving the same "Unsatisfied References" error. I am using Liferay 7.1 service builder. My -api and -service modules both deploy successfully to the server (using the blade deploy command) without any errors in the log.

Any help please why this is happening, please?
thumbnail
Minhchau Dang, modified 7 Years ago. Liferay Master Posts: 598 Join Date: 10/22/07 Recent Posts
David IlechukwuI have the following permissions variable declarations  in my -ServiceImpl classes

private static volatile ModelResourcePermission<credentialtype>
&nbsp; &nbsp; _credentialTypeModelResourcePermission =
&nbsp; &nbsp; &nbsp; &nbsp; ModelResourcePermissionFactory.getInstance(
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CredentialTypeServiceImpl.class,
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "_credentialTypeModelResourcePermission", CredentialType.class);
</credentialtype>

Technically, the only thing that code does is allow you to inject the OSGi component, which you declare as providing the ModelResourcePermission service with the corresponding model.class.name property, into a Spring bean's static field.

In other words, you still need to have a ModelResourcePermission component. You can either declare the component normally, like in DDMTemplate, or you can ask Liferay to generate one using Java 8's function objects and register it directly against the bundle context, like in DDMFormInstance.