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
Groovy console script can't resolve SOME arguments
Hi,
I have a problem using Groovy in Liferay admin script console to call certain Liferay APIs with Java primitive types (long, integer) arguments. Strange is that some APIs with similar signatures are called without problems.
For example:
This works fine
method signature: public static int
getCompanyArticlesCount(long companyId, int status)
number = com.liferay.journal.service.JournalArticleLocalServiceUtil.getCompanyArticlesCount(20116L, 0);
And this not (with int)
(method signature: public static long
getPortletPreferencesCount( int ownerType, String portletId)
number = com.liferay.portal.kernel.service.PortletPreferencesLocalServiceUtil.getPortletPreferencesesCount(0, "id");
throws
No signature of method: static com.liferay.portal.kernel.service.PortletPreferencesLocalServiceUtil.getPortletPreferencesesCount() is applicable for argument types: (java.lang.Integer, java.lang.String) values: [0, id] Possible solutions: getPortletPreferencesesCount(), getPortletPreferencesCount(int, java.lang.String), getPortletPreferencesCount(int, long, java.lang.String), getPortletPreferencesCount(long, int, java.lang.String, boolean)
Similar not working example with long:
method signature: public static java.util.List
<com.liferay.portal.kernel.model.PortletPreferences>
getPortletPreferencesByPlid(long plid)
prefs = com.liferay.portal.kernel.service.PortletPreferencesLocalServiceUtil.getPortletPreferenceses(0L);
Throwing
No signature of method: static com.liferay.portal.kernel.service.PortletPreferencesLocalServiceUtil.getPortletPreferenceses() is applicable for argument types: (java.lang.Long) values: [0] Possible solutions: getPortletPreferences(long), getPortletPreferenceses(int, int), getPortletPreferences(), getPortletPreferences(long, java.lang.String), getPortletPreferences(int, long, java.lang.String), getPortletPreferences(long, int, long) Line 1: prefs = com.liferay.portal.kernel.service.PortletPreferencesLocalServiceUtil.getPortletPreferenceses(0L);
It's Liferay DXP 7.1, patch dxp-19-7110. I've tried also different variants how to set argument like using "long"/"short" variable passed into the method, but nothing works.
Does anyone have explanation or trick how to call these APIs like from PortletPreferencesLocalServiceUtil?
Thanks in advance!
All the best,
Gustav Novotny