AnsweredAssumed Answered

Calling java method in GEL and use returned variables

Question asked by Suhas Kamble on Sep 28, 2016
Latest reply on Sep 29, 2016 by Suhas Kamble

<gel:script xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary">

<core:invokeStatic className="java.lang.System" method="getenv" var="NIKU_HOME">
<core:arg value="NIKU_HOME"/>
</core:invokeStatic>

<gel:parse file="${NIKU_HOME}/config/properties.xml" var="properties"/>
<gel:set asString="true" select="$properties/properties/directoryServer[@className='com.niku.security.directory.LDAPDirectoryService']/@url" var="ldapAdServer"/>
<gel:set asString="true" select="$properties/properties/directoryServer[@className='com.niku.security.directory.LDAPDirectoryService']/@adminUser" var="ldapUsername"/>
<gel:set asString="true" select="$properties/properties/directoryServer[@className='com.niku.security.directory.LDAPDirectoryService']/@adminCredential" var="ldapPassword"/>
<core:set value="" var="ldapSearchBase"/>

<gel:log level="info" message="LDAP dtls ${ldapAdServer}"/>
<core:invokeStatic var="objLDAP" className="LDAP_Service" method="get_details_by_LanID">
<core:arg type="java.lang.String" value="RESIDHERE"/>
<core:arg type="java.lang.String" value="${ldapAdServer}"/>
<core:arg type="java.lang.String" value="${ldapSearchBase}"/>
<core:arg type="java.lang.String" value="${ldapUsername}"/>
<core:arg type="java.lang.String" value="${ldapPassword}"/>
</core:invokeStatic>
<gel:log level="info" message="User dtls ${objLDAP}.FN"/>

</gel:script>

 

I am setting various string variables in the java method get_details_by_LanID()

In the second last statement highlighted above I am trying to get the value of variable FN from the object instance objLDAP of class LDAP_Service

 

I am not sure how do I utilize the object variables in GEL, could not find any documentation. I can modify the java code to return string array but first I need to understand how to consume a java method response.

 

 

EDIT:

 

I changed this statement

<gel:log level="info" message="User dtls ${objLDAP}.FN"/>

 

to 

<gel:log level="info" message="User dtls ${objLDAP}"/>

and the method is now returning just one string so I am able to see FN in this variable directly.

 

Now I am trying to find out a way to consume the array of strings and will post updates.

 

After settting the return type as Hashtable in Java code I am able to retrieve the columns as 

 


<gel:log level="info" message="User dtls ${objLDAP}.FN"/>

Outcomes