Changeset 4155


Ignore:
Timestamp:
2003-04-15T12:37:09+12:00 (21 years ago)
Author:
kjdon
Message:

added unknown page method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/PageAction.java

    r4144 r4155  
    4040    } else if (page_name.equals(ABOUT_PAGE)) {
    4141        return aboutPage(page, request);
    42     } else {
    43         System.err.println("PageAction Error: unimplemented page specified!");
    44         return null;
    45     }
     42    }
     43   
     44    System.err.println("PageAction Error: unknown page specified!");
     45    return unknownPage(page, request);
     46   
    4647    }
    4748
     
    141142   
    142143    }
     144
     145    /** if we dont know the page type, use this method */
     146    protected Element unknownPage(Element page, Element request) {
     147
     148    String page_name = request.getAttribute(GSXML.SUBACTION_ATT);
     149
     150    String stylesheet = GSFile.stylesheetFile(config_, page_name+".xsl");
     151    if (stylesheet==null) {
     152        // return the home page instead
     153        return homePage(page, request);
     154    }
     155
     156    // extract the params from the cgi-request,
     157    Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     158    HashMap params = GSXML.extractParams(cgi_paramList, false);
     159   
     160    String coll_name = (String)params.get(GSCGI.COLLECTION_ARG);
     161    if (coll_name == null || coll_name.equals("")) {
     162        // just process an empty page using the stylesheet
     163        Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);
     164        page.appendChild(page_response);
     165   
     166        Document style_doc = converter_.getDOM(new File(stylesheet));
     167        GSXSLT.absoluteIncludePaths(style_doc, config_);
     168        return (Element)transformer_.transform(style_doc, page);   
     169       
     170    }
     171    // else get the coll description - actually this is the same as for the about page - should we merge these two methods??
     172   
     173    // if there is a service specified should we get the service description instead??
     174    // get the collection or cluster description
     175    Element coll_about_message = doc_.createElement(GSXML.MESSAGE_ELEM);
     176   
     177    Element coll_about_request = GSXML.createBasicRequest(doc_, GSXML.REQUEST_TYPE_DESCRIBE,  coll_name, page.getAttribute(GSXML.LANG_ATT));
     178    coll_about_message.appendChild(coll_about_request);
     179   
     180    Element coll_about_response = (Element)mr_.process(coll_about_message);
     181
     182    // add the response to the page
     183    Element response = (Element) GSXML.getChildByTagName(coll_about_response, GSXML.RESPONSE_ELEM);
     184    Element page_response = GSXML.duplicateWithNewName(doc_, response, "pageResponse", false);
     185    page.appendChild(page_response);
     186
     187
     188    Document style_doc = converter_.getDOM(new File(stylesheet));
     189    GSXSLT.absoluteIncludePaths(style_doc, config_);
     190    return (Element)transformer_.transform(style_doc, page);   
     191   
     192    }
    143193}
Note: See TracChangeset for help on using the changeset viewer.