AnsweredAssumed Answered

GEL Review

Question asked by tomeu on Oct 12, 2010
Latest reply on Jul 8, 2012 by riteshkumar
Hi all,

I'm build a gel code for set instance rights for a user. I can't get a session with GEL script. The error is "[XOG]Couldn't Log in to XOG. Check the username/password and Application has started.". Could you review the Gel code?

<gel:script xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:core="jelly:core"
            xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
            xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
            xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:sql="jelly:sql"
            xmlns:xog="http://www.niku.com/xog"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            
    <gel:parameter var="p_XOGURL" default="http://localhost"/>
    <gel:parameter var="p_XOGUsername" default="admin"/>
    <gel:parameter var="p_XOGPassword" default="CYII2010Adm" secure="true"/>
    
    <gel:parse var="v_xml_root">
        <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_user.xsd">
            <Header action="write" externalSource="NIKU" objectType="user" version="8.1.1.4445"/>
            <Users></Users>
        </NikuDataBus>
    </gel:parse>
    <gel:setDataSource dbId="niku"/>
    <sql:query var="vProjectFields" escapeText="false">
        select b.unique_name,a.id, c.code from odf_ca_project a, srm_resources b, inv_investments c where b.id=a.cyii_r_ue and a.id=${gel_objectInstanceId} and a.id=c.id
    </sql:query>
    <core:forEach items="${vProjectFields.rowsByIndex}" var="row">
        <core:set var="userName">${row[0]}</core:set>
        <core:set var="prId">${row[2]}</core:set>
        <!--<core:set var="v_ProjectID">${row[1]}</core:set><core:set var="v_lookupUserId">${row[2]}</core:set><core:set var="v_projectName">${row[3]}</core:set><core:set var="v_userName">${row[4]}</core:set><core:set var="v_lastName">${row[5]}</core:set><core:set var="v_firstName">${row[6]}</core:set><core:set var="v_extrenalId">${row[7]}</core:set><core:set var="v_extrenalSourceId">${row[8]}</core:set><core:set var="v_emailAddress">${row[9]}</core:set><core:set var="v_code">${row[10]}</core:set>-->
        <gel:log level="INFO">${row[0]}</gel:log>
        <gel:log level="INFO">${row[2]}</gel:log>
        <gel:parse var="usernode">
            <!--User externalId="${v_extrenalId}" userName="${v_userName}"-->
            <User userName="${userName}">
                <!--PersonalInformation emailAddress="${v_emailAddress}" firstName="${v_firstName}" lastName="${v_lastName}"/-->
                <InstanceRights>
                    <Right id="ProjectEditFull">
                        <InstanceObject id="${prId}" type="SRM_PROJECTS"/>
                    </Right>
                    <!--Right id="odf_cst_project_create_kmx_status_report_v2"><InstanceObject id="${prId}" type="SRM_PROJECTS"/></Right><Right id="odf_cst_project_create_kmx_vystup_projektu"><InstanceObject id="${v_code}" type="SRM_PROJECTS"/></Right><Right id="odf_cst_project_edit_all_kmx_vystup_projektu"><InstanceObject id="${v_code}" type="SRM_PROJECTS"/></Right><Right id="odf_cst_project_view_all_kmx_status_report_v2"><InstanceObject id="${v_code}" type="SRM_PROJECTS"/></Right><Right id="odf_cst_project_view_all_kmx_vystup_projektu"><InstanceObject id="${v_code}" type="SRM_PROJECTS"/></Right><Right id="ProjectEditManagement"><InstanceObject id="${v_code}" type="SRM_PROJECTS"/></Right><Right id="RiskIssueDelete"><InstanceObject id="${v_code}" type="SRM_PROJECTS"/></Right><Right id="RiskIssueEdit"><InstanceObject id="${v_code}" type="SRM_PROJECTS"/></Right><Right id="RiskIssueView"><InstanceObject id="${v_code}" type="SRM_PROJECTS"/></Right-->
                </InstanceRights>
            </User>
        </gel:parse>
        <gel:set select="$v_xml_root/NikuDataBus/Users" value="${usernode}" insert="true"/>
    </core:forEach>
    
    <gel:out>[XOG]Login en Clarity ${p_XOGURL}.</gel:out>
    <gel:log level="INFO" category="XOG">Se ha logueado Clarity en: ${p_XOGURL}.</gel:log>
    <core:catch var="v_xog_exception">
        <soap:invoke endpoint="${p_XOGURL}/niku/xog" var="auth">
            <soap:message>
                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
                    <soapenv:Header/>
                    <soapenv:Body>
                        <xog:Login>
                            <xog:Username>${XOGusername}</xog:Username>
                            <xog:Password>${XOGpassword}</xog:Password>
                        </xog:Login>
                    </soapenv:Body>
                </soapenv:Envelope>
            </soap:message>
        </soap:invoke>
        <gel:set asString="true" select="$auth/SOAP-ENV:Envelope/SOAPENV:Body/xog:SessionID/text()" var="sessionID"/>
        <core:choose>
            <core:when test="${sessionID == null}">
                <gel:out>[XOG]Couldn't Log in to XOG. Check the username/password and Application has started.</gel:out>
                <gel:log level="ERROR" category="XOG">Couldn't Log in to XOG. Check the username/password and Application has started.</gel:log>
            </core:when>
            <core:otherwise>
                <gel:out>[XOG]Gogin OK: ${sessionID}</gel:out>
                <gel:log level="INFO" category="XOG">[XOG]Log in successful ${sessionID}</gel:log>
                <core:catch var="v_xog_exception">
                    <soap:invoke endpoint="${p_XOGURL}/niku/xog" var="runresult">
                        <soap:message>
                            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
                                <soapenv:Header>
                                    <xog:Auth>
                                        <xog:SessionID>${sessionID}</xog:SessionID>
                                    </xog:Auth>
                                </soapenv:Header>
                                <soapenv:Body>
                                    <gel:include select="$v_xml_root/NikuDataBus"/>
                                </soapenv:Body>
                            </soapenv:Envelope>
                        </soap:message>
                    </soap:invoke>
                </core:catch>
                <core:choose>
                    <core:when test="${v_xog_exception != null}">
                        <gel:out>[XOG]XOG operation failed: ${v_xog_exception}</gel:out>
                        <gel:log level="ERROR" category="XOG">XOG operation failed: ${v_xog_exception}</gel:log>
                    </core:when>
                </core:choose>
                <soap:invoke endpoint="${p_XOGURL}/niku/xog" var="logoutresult">
                    <soap:message>
                        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
                            <soapenv:Header>
                                <xog:Auth>
                                    <xog:SessionID>${sessionID}</xog:SessionID>
                                </xog:Auth>
                            </soapenv:Header>
                            <soapenv:Body>
                                <xog:Logout/>
                            </soapenv:Body>
                        </soapenv:Envelope>
                    </soap:message>
                </soap:invoke>
                <gel:out>[XOG]Logged out </gel:out>
                <gel:log level="INFO" category="XOG">Logged out </gel:log>
            </core:otherwise>
        </core:choose>
    </core:catch>
    <core:if test="${v_xog_exception != null}">
        <gel:out>XOG failed: ${v_xog_exception}</gel:out>
        <gel:log level="ERROR" category="XOG">XOG failed: ${v_xog_exception}</gel:log>
    </core:if>
</gel:script>
Thanks in advance

Outcomes