Clarity

  • 1.  Calling java method in GEL and use returned variables

    Posted Sep 28, 2016 12:24 PM

    <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"/>



  • 2.  Re: Calling java method in GEL and use returned variables

    Posted Sep 29, 2016 01:13 PM

    So if you want to see the underlying type:

     

        <gel:log>objLDAP type = ${context.getVariable('objLDAP').getClass().getName()}</gel:log>

     

    If FN is a property on objLDAP:

     

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

     

    V/r,

    Gene



  • 3.  Re: Calling java method in GEL and use returned variables

    Posted Sep 29, 2016 02:11 PM

    Thanks.

     

    I was able to use it as I mentioned in Edit.

     

    However, I was anticipating reply from you Gene as I saw your other posts on similar topics ☺



  • 4.  Re: Calling java method in GEL and use returned variables

    Posted Sep 29, 2016 02:24 PM

    I believe that JEXL for ${objLDAP} in this statement:

     

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

     

    will call the toString() method by default. 

     

    In complex objects or objects that haven't overridden the toString() method to provide a more readable string, you will most likely get the class name along with the object's hashcode.

     

    V/r,

    Gene



  • 5.  Re: Calling java method in GEL and use returned variables

    Posted Sep 29, 2016 02:41 PM

    You are right.

     

    Regards,

    Suhas Kamble