123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: ps
- (C) Copyright IBM Corp. 2005, 2011
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- -->
- <xts:morphlet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/">
- <!--
- * params for this morphlet :== r [caller-mode]
- * r :== getCapabilities | getObject | getContainer | search
- * getCapabilities :== <none>
- * getObject :== id
- * getContainer :== id | path paginations
- * paginations :== maxobjs skipobjs sort
- * maxobjs :== #
- * skipobjs :== #
- * sort :== n | n_d | d | d_d
- * id :== CM-id | NAV-id
- * path :== CM-searchpath
- * search :== text sscope sfield smethod smodified stype path paginations
- * text :== text to search
- * sscope :== fo | fb | p | m
- * sfield :== n | d | nd
- * smethod :== 1 | 2 | 3
- * smodified :== t | l3d | lw | lm | l3m | l6m | ly | l3y
- * stype :== object type
- * path :== starting path to search
- * paginations :== (see getContainer)
- * caller-mode :== custom
- -->
-
- <xts:block id="handleRequest" type="exec"
- dependency=""
- condition=".[true()]"
- mode="interpret" processor="XSLT" mandatory="false">
- <xts:logicsheet path="logicsheets/buslogic.xslt"/>
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
- xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
- xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
- xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
- xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
- exclude-result-prefixes="xts xos bus nav SOAP-ENV">
-
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
-
- <xsl:variable name="params" select="/root/env/param"/>
- <xsl:variable name="preferences" select="/root/bus:biBusHeader/bus:userPreferenceVars"/>
- <xsl:variable name="userPrefsDefault" select="/root/system/param[@name='defaultPortalPreferences']"/>
- <xsl:variable name="browser" select="'ie'"/>
- <xsl:variable name="request" select="$params[@name='r']"/>
-
- <xsl:template match="/">
- <xsl:choose>
- <xsl:when test="$request = 'getCapabilities'">
- <xsl:call-template name="do-getCapabilities"/>
- </xsl:when>
- <xsl:when test="$request = 'getContainer' or $request = 'getObject' or $request = 'search'">
- <xsl:call-template name="do-NAVRequest"/>
- </xsl:when>
- <xsl:otherwise>
- <xts:sequence>
- <xts:append select="/root">
- <request-result>
- <error><code>unsupported-request</code></error>
- </request-result>
- </xts:append>
- </xts:sequence>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="do-getCapabilities">
- <xts:sequence>
- <xts:append>
- <send:request provider="cm">
- <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
- <cm:query>
- <cm:search>~</cm:search>
- <cm:properties>
- <cm:property name="defaultName"/>
- </cm:properties>
- </cm:query>
- </xts:transform>
- </send:request>
- </xts:append>
-
- <xts:append select="/root">
- <request-result>
- <xsl:element name="getCapabilitiesResponse">
- <session-capabilities>
- <xsl:copy-of select="/root/session/param[@name='capabilities']/*"/>
- </session-capabilities>
- <xsl:copy-of select="$params[@name='capabilities']/*"/>
- <browser-info>
- <xsl:copy-of select="/root/system/param[@name='capabilities']/*"/>
- </browser-info>
- </xsl:element>
- </request-result>
- </xts:append>
- </xts:sequence>
- </xsl:template>
-
- <xsl:template name="do-NAVRequest">
- <xsl:variable name="obj-path">
- <xsl:choose>
- <xsl:when test="string($params[@name='id']) != ''">
- <xsl:choose>
- <xsl:when test="starts-with($params[@name='id'], '_')">
- <xsl:value-of select="$params[@name='id']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text/>path:storeID("<xsl:value-of select="$params[@name='id']"/>")<xsl:text/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="string($params[@name='path']) != ''">
- <xsl:text/>path:<xsl:value-of select="$params[@name='path']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text/>systemDefault<xsl:text/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="navRequest">
- <xsl:choose>
- <xsl:when test="$request = 'getContainer'">
- <xsl:value-of select="'getContainer'"/>
- </xsl:when>
- <xsl:when test="$request = 'getObject'">
- <xsl:value-of select="'getItem'"/>
- </xsl:when>
- <xsl:when test="$request = 'search'">
- <xsl:value-of select="'search'"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
-
- <xts:sequence>
- <xts:append select="/root">
- <request-result>
- <xsl:if test="$navRequest != ''">
- <xts:request name="NAV" faultBlock="navRequestFault">
- <SOAP-ENV:Envelope>
- <SOAP-ENV:Header>
- <xsl:copy-of select="/root/header/bus:biBusHeader"/>
- </SOAP-ENV:Header>
- <SOAP-ENV:Body>
- <xsl:element name="{$navRequest}" namespace="http://developer.cognos.com/schemas/cps/navigation/1/">
- <nav:validateTag/>
-
- <xsl:choose>
- <xsl:when test="$navRequest = 'getItem'">
- <nav:id><xsl:value-of select="$obj-path"/></nav:id>
- </xsl:when>
- <xsl:when test="$navRequest = 'getContainer'">
- <nav:id><xsl:value-of select="$obj-path"/></nav:id>
- <nav:childObjects>all</nav:childObjects>
- <xsl:call-template name="build-pagination-params"/>
- </xsl:when>
- <xsl:when test="$navRequest = 'search'">
- <xsl:call-template name="build-search-params"/>
- <xsl:call-template name="build-pagination-params"/>
- </xsl:when>
- </xsl:choose>
- <nav:param name="postUrl"/>
- <nav:param name="backUrl">rewrite</nav:param>
- <nav:param name="browserAgent"><xsl:value-of select="$browser"/></nav:param>
-
- <!-- properties -->
- <nav:property name="screenTip"/>
- <nav:property name="description"/>
- <nav:property name="parentId"/>
- <nav:property name="fullPath"/>
- <nav:property name="lastModifiedDate"/>
- <nav:property name="status"/>
- <nav:property name="newState"/>
- <nav:property name="readState"/>
- <nav:property name="action"/>
- <nav:property name="actionsURL"/>
- <nav:property name="hidden"/>
- <nav:property name="icons"/>
- </xsl:element>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>
- </xts:request>
- </xsl:if>
- </request-result>
- </xts:append>
- </xts:sequence>
- </xsl:template>
-
- <xsl:template name="build-pagination-params">
- <xsl:variable name="skipobjs">
- <xsl:choose>
- <xsl:when test="string($params[@name='skipobjs']) != ''">
- <xsl:value-of select="$params[@name='skipobjs']"/>
- </xsl:when>
- <xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="maxObjects">
- <xsl:choose>
- <xsl:when test="$params[@name='maxobjs'] != ''">
- <xsl:value-of select="$params[@name='maxobjs']"/>
- </xsl:when>
- <xsl:when test="$preferences/item[name = 'linesPerPage']/value">
- <xsl:value-of select="$preferences/item[name = 'linesPerPage']/value"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$userPrefsDefault/pref[@name='lines']"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="sort">
- <xsl:if test="$params[@name='sort'] != ''">
- <xsl:value-of select="$params[@name='sort']"/>
- </xsl:if>
- </xsl:variable>
-
- <nav:skipObjects>
- <xsl:choose>
- <xsl:when test="$skipobjs != '' ">
- <xsl:value-of select="$skipobjs"/>
- </xsl:when>
- <xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>
- </nav:skipObjects>
- <nav:maxObjects><xsl:value-of select="$maxObjects"/></nav:maxObjects>
- <xsl:choose>
- <xsl:when test="starts-with(string($sort),'n')">
- <xsl:variable name="order">
- <xsl:choose>
- <xsl:when test="$sort = 'n_d'">
- <xsl:text>descending</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>ascending</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <nav:sort order="{$order}">name</nav:sort>
- </xsl:when>
- <xsl:when test="starts-with(string($sort),'d')">
- <xsl:variable name="order">
- <xsl:choose>
- <xsl:when test="$sort = 'd_d'">
- <xsl:text>descending</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>ascending</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <nav:sort order="{$order}">lastModifiedDate</nav:sort>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="build-search-params">
- <xsl:if test="string($params[@name='stext']) != ''">
- <nav:string><xsl:value-of select="$params[@name='stext']"/></nav:string>
- </xsl:if>
- <nav:searchType>normal</nav:searchType>
- <!-- scope -->
- <xsl:variable name="sscope" select="$params[@name='sscope']"/>
- <nav:scope>
- <xsl:variable name="path" select="$params[@name='path']"/>
- <xsl:choose>
- <xsl:when test="$sscope = 'p'">
- <xsl:value-of select="'systemDefault'"/>
- </xsl:when>
- <xsl:when test="$sscope = 'm'">
- <xsl:value-of select="'userDefault'"/>
- </xsl:when>
- <xsl:when test="$sscope = 'fo'">
- <xsl:value-of select="$path"/>
- </xsl:when>
- <xsl:when test="$sscope = 'fb'">
- <xsl:value-of select="$path"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="'systemDefault'"/>
- </xsl:otherwise>
- </xsl:choose>
- </nav:scope>
-
- <!-- recursive scope: whether to search subfolders -->
- <nav:recursive>
- <xsl:choose>
- <xsl:when test="string($params[@name='sscope']) = 'fo'">
- <xsl:value-of select="'false'"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="'true'"/>
- </xsl:otherwise>
- </xsl:choose>
- </nav:recursive>
- <!-- field -->
- <nav:fields>
- <xsl:choose>
- <xsl:when test="$params[@name = 'sfield'] = 'n'">
- <xsl:value-of select="'nf'"/>
- </xsl:when>
- <xsl:when test="$params[@name = 'sfield'] = 'd'">
- <xsl:value-of select="'df'"/>
- </xsl:when>
- <xsl:when test="$params[@name = 'sfield'] = 'nd'">
- <xsl:value-of select="'ndf'"/>
- </xsl:when>
- </xsl:choose>
- </nav:fields>
- <!-- match criteria -->
- <xsl:variable name="smethod" select="$params[@name='smethod']"/>
- <nav:match>
- <xsl:choose>
- <xsl:when test="$smethod = '1'">
- <xsl:value-of select="'contains'"/>
- </xsl:when>
- <xsl:when test="$smethod = '2'">
- <xsl:value-of select="'starts'"/>
- </xsl:when>
- <xsl:when test="$smethod = '3'">
- <xsl:value-of select="'exact'"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="'contains'"/>
- </xsl:otherwise>
- </xsl:choose>
- </nav:match>
- <!-- modified since -->
- <xsl:variable name="smodified" select="$params[@name='smodified']"/>
- <xsl:if test="$smodified != 'any'">
- <nav:itemModified>
- <xsl:choose>
- <xsl:when test="$smodified = 't'">0</xsl:when>
- <xsl:when test="$smodified = 'l3d'">259200</xsl:when>
- <xsl:when test="$smodified = 'lw'">604800</xsl:when>
- <xsl:when test="$smodified = 'lm'">2629743</xsl:when>
- <xsl:when test="$smodified = 'l3m'">7889231</xsl:when>
- <xsl:when test="$smodified = 'l6m'">15778463</xsl:when>
- <xsl:when test="$smodified = 'ly'">31556926</xsl:when>
- <xsl:when test="$smodified = 'l3y'">94670777</xsl:when>
- </xsl:choose>
- </nav:itemModified>
- </xsl:if>
- <!-- item type(s) to restrict search to -->
- <xsl:variable name="stype" select="string($params[@name='stype'])"/>
- <xsl:if test="$stype != ''">
- <nav:itemType><xsl:value-of select="$stype"/></nav:itemType>
- </xsl:if>
- </xsl:template>
-
- </xsl:stylesheet>
- </xts:block>
-
- <xts:block id="output" type="exec"
- dependency="handleRequest"
- mode="interpret" processor="XSLT">
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
- xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
- xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
- exclude-result-prefixes="xts xos bus nav SOAP-ENV">
-
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
-
- <xsl:variable name="params" select="/root/env/param"/>
-
- <xsl:template match="/">
- <xts:sequence>
- <xts:append select="/root/output">
- <xos:part>
- <xos:entityHeader>
- <xos:param name="Content-Type">text/xml; charset=UTF-8</xos:param>
- </xos:entityHeader>
- <xos:entityBody>
- <response>
- <xsl:for-each select="/root/request-result">
- <xsl:copy-of select="./*"/>
- </xsl:for-each>
- </response>
- </xos:entityBody>
- </xos:part>
- </xts:append>
- </xts:sequence>
- </xsl:template>
- </xsl:stylesheet>
- </xts:block>
- <xts:block id="navRequestFault" type="fault" processor="XSLT">
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- exclude-result-prefixes="xts">
-
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
-
- <xsl:variable name="params" select="/root/env/param"/>
-
- <xsl:template match="/">
- <xsl:variable name="xts-fault" select="/root/fault/xts:exception[last()]"/>
- <xsl:variable name="code" select="$xts-fault/xts:exceptionCode"/>
- <xsl:variable name="prefix" select="substring-before( string( $code ), ':' )"/>
- <xsl:variable name="local-code" select="substring-after( string( $code ), ':' )"/>
- <error>
- <xsl:choose>
- <xsl:when test="($prefix = 'nav') and ($local-code = 'InvalidCredentials')">
- <code>invalidCredentials</code>
- </xsl:when>
- <xsl:otherwise>
- <code xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/">
- <xsl:value-of select="$code"/>
- </code>
- </xsl:otherwise>
- </xsl:choose>
- <message>
- <xsl:value-of select="$xts-fault/xts:exceptionMsg"/>
- </message>
- <details>
- <xsl:value-of select="$xts-fault/xts:exceptionDetails"/>
- </details>
- </error>
- </xsl:template>
- </xsl:stylesheet>
- </xts:block>
- </xts:morphlet>
|