<page xmlns="http://xmlns.oracle.com/uix/controller"
      xmlns:baja="http://xmlns.oracle.com/uix/controller"
      xmlns:uix="http://xmlns.oracle.com/uix/ui" 
      xmlns:html="http://www.w3.org/TR/REC-html40">

    <baja:head  xmlns="http://xmlns.oracle.com/uix/ui">
        <dataScope>
            <contents>
                <head xmlns="http://xmlns.oracle.com/uix/ui"  uix:title="pageTitle@getPageTitle"/>
            </contents>
            <provider>
                <data name="getPageTitle">
                    <method class="oracle.sysman.eml.admin.rep.proxy.CacheData" method="getPageTitle"/>
                </data>
            </provider>
        </dataScope>
    </baja:head>
    
    <baja:content xmlns="http://xmlns.oracle.com/uix/ui">
        <dataScope>
            <contents>
            
            <script>
            <contents>
                
                function clearAruParams()
                {
                    with (document.aruFileUpload)
                    {
                        uploadDirectoryTest.value = ""
                        fileProducts.value = ""
                        fileReleases.value = ""
                        filePlatforms.value = ""
                        fileLanguages.value = ""
                        fileProductGroups.value = ""
                        fileProductReleases.value = ""
                        fileComponentReleases.value = ""
                        filePatchAdvisories.value = ""
                    }
                }
                
                function updateAruParams()
                {
                    var uploadDir = document.aruFileUpload.uploadDirectory.value
                    with (document.aruFileUpload)
                    {
                        fileProducts.value = uploadDir + "/aru_products.xml"
                        fileReleases.value = uploadDir + "/aru_releases.xml"
                        filePlatforms.value = uploadDir + "/aru_platforms.xml"
                        fileLanguages.value = uploadDir + "/aru_languages.xml"
                        fileProductGroups.value = uploadDir + "/aru_product_groups.xml"
                        fileProductReleases.value = uploadDir + "/aru_product_releases.xml"
                        fileComponentReleases.value = uploadDir + "/aru_component_releases.xml"
                        filePatchAdvisories.value = uploadDir + "/query_advisories.xml"
                    }
                }
            
                function clearParams()
                {
                    with (document.urlCacheUploadForm)
                    {
                        if (usingMode == "inspect")
                        {
                            stream.value = "";
                        }
                    }
                }
                
                function clickInspect()
                {
                    clearParams();
                    return true;
                }
                
                function clearFileName()
                {
                    with (document.urlCacheUploadForm)
                    {
                        if (usingMode == "upload")
                        {
                            fileU.value = "";
                        }
                    }
                }
                
                function getUrlValue()
                {
                    var url = document.urlCacheUploadForm.url.value;
                    return url;
                }
                
                function setURLValueFromCacheForm()
                {
                    document.urlFileUpload.url.value = document.urlCacheUploadForm.url.value;
                    return true;
                }
                
                function setCacheRedirValue()
                {
                    var contextpath = document.urlCacheUploadForm.contextPath.value;
                    var path = contextpath + "admin/rep/proxy/cacheListLov";
                    var imagepath = document.urlCacheUploadForm.imagePath.value;
                    var redir = imagepath + "cabo/jsps/frameRedirect.jsp?redirect="+path;
                    
                    // set hidden param to use in openWindow
                    document.urlCacheUploadForm.cacheRedir.value=redir;
                    //document.proxySetupForm.host.value=hostName;
                }
                
                function delimitSpaceToCaret(chkStr)
                {
                    var newStr = "";
                    var cmpStr = "";
                    var space = " ";
                    var caret = "^";
                    
                    strBegLoc = 0;
                    spcLoc = chkStr.indexOf(space);
                    while ( spcLoc > -1)
                    {
                        newStr = newStr+chkStr.substr(strBegLoc,spcLoc)+caret;
                        cmpStr = chkStr.substr(strBegLoc+spcLoc+1);
                        spcLoc = cmpStr.indexOf(space);
                        strBegLoc = newStr.length;
                    }
                    // add the last chunk
                    if (cmpStr.length > 0)
                        newStr = newStr+cmpStr;
                    
                    if (newStr.length > 0)
                     return newStr;
                    else
                     return chkStr;
                }
                
                function cacheListCallBack(lovwin, event)
                {
                    var h = lovwin.retCache;
                    if (h !=(void 0))
                    {
                        document.urlCacheUploadForm.url.value = h;
                    }
                }
            
            </contents>
            </script>
    
            <pageLayout>
                <mediumAdvertisement>
                    <include baja:node="/oemBanner" />
                </mediumAdvertisement>
                <globalButtons>
                    <include baja:node="/globalButtonBar" />
                </globalButtons>
                <tabs>
                    <include baja:node="/globalTabs" />
                </tabs>
                <pageHeader>
                    <include baja:node="../header"/>
                </pageHeader>
                <copyright>
                    <include baja:node="/copyright" />
                </copyright>
                <uix:start>
                    <include baja:node="../adminSideNav" />
                </uix:start>
                <location>
                    <include baja:node="/breadCrumbs" />
                </location>

                <contents>
                    
                <stackLayout>
                  <contents>
                    <messageBox automatic="true" />
                    <spacer height="10"/>
                    
                    <subTabLayout>

                      <subTabs>
                        <subTabBar selectedIndex="3">
                          <contents>
                            <link uix:text="PRP_SUB_TAB_PATCH@ResourceBundle" destination="/console/ecm/patch/patchConfigParams" />
                            <link uix:text="PRP_SUB_TAB_PROXY@ResourceBundle" destination="/console/admin/rep/proxy/server"/>
                            <link uix:text="PRP_SUB_TAB_CACHE@ResourceBundle" destination="/console/admin/rep/proxy/cache"/>
                            <link uix:text="PRP_SUB_TAB_DEBUG@ResourceBundle" destination="/console/admin/rep/proxy/debug"/>
                          </contents>
                        </subTabBar>
                      </subTabs>
                      
                      <contents>
                    
                    <spacer height="10"/>
                                        
                    <form name="urlCacheUploadForm" method="POST" usesUpload="true">
                        <contents>
                            <!-- 
                            I need to send the char buffer to the server only when the user wants to save it.
                            For all other cases we must explicitly set the document.urlCacheUploadForm.stream.value
                            to a empty string before submitting out request.
                            -->
                            <formValue name="usingMode" uix:text="displayMode@cacheData" />
                            
                            <formValue name="cacheRedir" />
                            <formValue name="contextPath" uix:value="contextPath@getContextPath"/>
                            <formValue name="imagePath" uix:value="imagePath@getImagePath"/>
                            
                                <stackLayout>
                                    <contents>
                        
                                        <tableLayout width="100%">
                                            <contents>
                                                <rowLayout>
                                                    <contents>
                                                        <cellFormat width="50%">
                                                            <contents>
                                                                <messageLovField name="url" 
                                                                                 uix:prompt="CACHE_URL@ResourceBundle"
                                                                                 uix:text="url@cacheData"
                                                                                 columns="50" 
                                                                                 uix:tip="CACHE_URL_TIP@ResourceBundle"
                                                                                 onClick=" setCacheRedirValue();
                                                                                           openWindow(top,
                                                                                           document.urlCacheUploadForm.cacheRedir.value,
                                                                                           'lovWindow',
                                                                                           {width:600, height:200},
                                                                                           true,
                                                                                           'dialog',
                                                                                           cacheListCallBack);"/>
                                                            </contents>
                                                        </cellFormat>
                                                        <cellFormat width="50%">
                                                            <contents>
                                                                <labeledFieldLayout labelWidth="10%"
                                                                                    fieldWidth="90%">
                                                                    <contents>
                                                                        <messageTextInput uix:prompt="CACHE_USERNAME@ResourceBundle"
                                                                                          uix:text="user@cacheData"
                                                                                          noAutoComplete="true"
                                                                                          name="resUser" />
                                                                        <messageTextInput uix:prompt="CACHE_PASSWORD@ResourceBundle"
                                                                                          uix:text="pass@cacheData"
                                                                                          name="resPass"
                                                                                          secret="true"
                                                                                          noAutoComplete="true" 
                                                                                          uix:tip="CACHE_AUTH_TIP@ResourceBundle" />
                                                                    </contents>
                                                                </labeledFieldLayout>
                                                            </contents>
                                                        </cellFormat>
                                                    </contents>
                                                </rowLayout>
                                            </contents>
                                        </tableLayout>
                                        
                                        <spacer heigth="10" />
                                        
                                        <flowLayout>
                                            <contents>
                                                <submitButton uix:text="CACHE_SEARCH@ResourceBundle"
                                                              name="event"
                                                              value="search" />
                                                <!-- the Inspect action should clear out the stream before submitting  the form. see clickInspect() -->
                                                <submitButton uix:text="CACHE_INSPECT@ResourceBundle" 
                                                              name="event"
                                                              value="inspect"
                                                              onClick="clickInspect();"/>
                                                <submitButton uix:text="CACHE_UPLOAD@ResourceBundle"
                                                              name="event"
                                                              value="switchUpload" />
                                                <submitButton text="Upload ARU Data"
                                                              name="event"
                                                              value="switchARUUpload" />
                                            </contents>
                                        </flowLayout>
                            
                            <spacer width="10" height="10"/>
                            
                            <switcher uix:childName="displayMode@cacheData">
                            
                                <case name="inspect">
                                    <include baja:node="cacheInspect" />
                                </case>
                                
                                <!-- The Search Mode. This displays all the entries in the resource cache that match the search string -->
                                <case name="search">
                                    <include baja:node="cacheSearch" />
                                </case>
                                <!-- End Search Mode -->
                                
                            </switcher>
                        
                        </contents>
                        </stackLayout>
                    
                </contents>
                </form>
                
                
                <spacer heigth="10" />
                <!--
                    The messageFileUpload does not work when used in the above urlCacheUploadForm.
                    So, as a workaound I have made a new form.
                    Care must be taken to copy the "url" value from the urlCacheUploadForm to urlFileUpload,
                    as this value is used for inserting the url resource file into the table.
                -->
                <switcher uix:childName="displayMode@cacheData">
                    <case name="upload">
                        <include baja:node="cacheUpload" />
                    </case>
                </switcher>
                
                <switcher uix:childName="displayMode@cacheData">
                    <case name="aru">
                        <include baja:node="cacheAruUpload" />
                    </case>
                </switcher>
                
                </contents>
                </subTabLayout>
                
              </contents>
              </stackLayout>				
                
            </contents>
        </pageLayout>
        
        </contents>
        
        <provider>
        
            <data name="ResourceBundle">	
                <bundle class = "oracle.sysman.eml.ecm.patch.util.PatchResourceBundle"/>
            </data>
            
            <data name="cacheData">
                <method class="oracle.sysman.eml.admin.rep.proxy.CacheData" method="getUrlData"/>
            </data>
            
            <data name="getContextPath">
                <method class="oracle.sysman.eml.ecm.ContextPathData" method="getContextPath"/>
            </data>
            
            <data name="getImagePath">
                <method class="oracle.sysman.eml.ecm.ContextPathData" method="getImagePath"/>
            </data>
            
        </provider>
            
    </dataScope>
</baja:content>

<handlers>

    <event name="inspect">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="doInspect" />
    </event>
    
    <event name="tableInspect">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="doTableInspect" />
    </event>
    
    <event name="tableDelete">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="doTableDelete" />
    </event>
    
    <event name="search">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="doSearch" />
    </event>
    
    <event name="save">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="doSave" />
    </event>
    
    <event name="saveFile">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="doSaveFile" />
    </event>
    
    <event name="uploadAruData">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="doSaveARUFiles" />
    </event>
    
    <event name="switchUpload">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="doSwitchUpload" />
    </event>
    
    <event name="switchARUUpload">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="doSwitchARUUpload" />
    </event>
    
    <event name="hide" source="hshResponseHeaders">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="hideResponseHeaders" />
    </event>
    
    <event name="hide" source="hshResponseStream">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="hideResponseStream" />
    </event>
    
    <event name="show" source="hshResponseHeaders">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="showResponseHeaders" />
    </event>
    
    <event name="show" source="hshResponseStream">
        <method class="oracle.sysman.eml.admin.rep.proxy.CacheHandler" method="showResponseStream" />
    </event>

</handlers>

</page>
