Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Unsatisfied Permission References in -ServiceImpl classes
I have the following permissions variable declarations in my -ServiceImpl classes
But why I try to use these variables in a permissions check method, like this
I get the "Unsatisfied References error" stating that the variables could be resolved because the target class
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-
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?
private static volatile ModelResourcePermission<credentialtype>
_credentialTypeModelResourcePermission =
ModelResourcePermissionFactory.getInstance(
CredentialTypeServiceImpl.class,
"_credentialTypeModelResourcePermission", CredentialType.class);
private static volatile PortletResourcePermission
_portletResourcePermission =
PortletResourcePermissionFactory.getInstance(
CredentialTypeServiceImpl.class, "_portletResourcePermission",
HrmCoreConstants.RESOURCE_NAME);
</credentialtype>But why I try to use these variables in a permissions check method, like this
_portletResourcePermission.check(getPermissionChecker(),
serviceContext.getScopeGroupId(), ActionKeys.ADD_CREDENTIAL_TYPE);
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-
@Reference(
target = "(model.class.name=com.tpl.pmedics.hrm_core.model.CredentialType)",
unbind = "-"
)
protected void setModelResourcePermission(
ModelResourcePermission<credentialtype> modelResourcePermission) {
_credentialTypeModelResourcePermission = modelResourcePermission;
}
private static ModelResourcePermission<credentialtype>
_credentialTypeModelResourcePermission;
</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?
David IlechukwuI have the following permissions variable declarations in my -ServiceImpl classesprivate static volatile ModelResourcePermission<credentialtype> _credentialTypeModelResourcePermission = ModelResourcePermissionFactory.getInstance( CredentialTypeServiceImpl.class, "_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.