Ignore:
Timestamp:
2019-11-25T10:46:36+13:00 (4 years ago)
Author:
kjdon
Message:

fixed up processRedirectRequest method. for some reason parts had been commented out - just my testing?? - so put that back. And implemented el=framed portion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java

    r33713 r33719  
    3535
    3636import javax.servlet.ServletConfig;
     37import javax.servlet.ServletContext;
    3738import javax.servlet.ServletException;
    3839import javax.servlet.http.Cookie;
     
    425426    if (processRedirectRequest(request, response, queryMap)) {
    426427    // this method will do the redirect if needed and return true if it has
    427     // if el=direct/framed&rl=0&href=http://newurl.com
     428    // done so.
     429    // e.g. el=direct/framed&rl=0&href=http://newurl.com
    428430    return;
    429431    }
     
    859861    String rl = null;
    860862    String el = null;
     863    String collection = null;
    861864
    862865    while (queryIter.hasNext())
    863866    {
    864867        String q = queryIter.next();
    865         if (q.equals(GSParams.EXTERNAL_LINK_TYPE))
     868        if (q.equals(GSParams.COLLECTION))
     869        {
     870        collection = queryMap.get(q)[0];
     871        }
     872        else if (q.equals(GSParams.EXTERNAL_LINK_TYPE))
    866873        {
    867874        el = queryMap.get(q)[0];
     
    885892    //"rl=1" this is an internal link
    886893    if ((href != null) && (rl.equals("0")))
    887       {// This is an external link,
     894    {// This is an external link,
    888895
    889896        if (el.equals("framed"))
    890           {
    891         //TODO **** how best to change to a=p&sa=html&c=collection&url=href
    892         // response.setContentType("text/xml");
    893         //response.sendRedirect("http://localhost:8383/greenstone3/gs3library?a=p&sa=html&c=external&url="+href);
    894           }
     897        {
     898        // framed means we are linking to an external page inside our greenstone page
     899        HttpSession session = request.getSession();
     900        ServletContext context = session.getServletContext();
     901        String new_url = context.getContextPath()+"/"+ library_name+"?a=p&sa=html&url="+href;
     902        if (collection != null && !collection.equals("")) {
     903            new_url += "&c="+collection;
     904        }
     905        response.sendRedirect(new_url);
     906        }
    895907        else
    896           {
     908        {
    897909        // el = '' or direct
    898910        //the web page is re-directed to the external URL (&el=&rl=0&href="http://...")
    899         //response.setContentType("text/xml");
    900         //response.sendRedirect(href);
    901           }
     911        response.sendRedirect(href);
     912        }
    902913        return true;
    903914      }
Note: See TracChangeset for help on using the changeset viewer.