Changeset 25351


Ignore:
Timestamp:
2012-04-12T13:59:19+12:00 (12 years ago)
Author:
sjm84
Message:

Some fixes for LibraryServlet

File:
1 edited

Legend:

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

    r25310 r25351  
    368368                if (q.equals(GSParams.EXTERNAL_LINK_TYPE))
    369369                {
    370                   el = queryMap.get(q)[0];
     370                    el = queryMap.get(q)[0];
    371371                }
    372372                else if (q.equals(GSParams.HREF))
     
    390390            {// This is an external link,
    391391
    392               if (el.equals("framed")) {
    393                 //TODO **** how best to change to a=p&sa=html&c=collection&url=href
    394                 // response.setContentType("text/xml");
    395                 //response.sendRedirect("http://localhost:8383/greenstone3/gs3library?a=p&sa=html&c=external&url="+href);
    396               } else {
    397                 // el = '' or direct
    398                 //the web page is re-directed to the external URL (&el=&rl=0&href="http://...")
    399                 response.setContentType("text/xml");
    400                 response.sendRedirect(href);
    401               }
     392                if (el.equals("framed"))
     393                {
     394                    //TODO **** how best to change to a=p&sa=html&c=collection&url=href
     395                    // response.setContentType("text/xml");
     396                    //response.sendRedirect("http://localhost:8383/greenstone3/gs3library?a=p&sa=html&c=external&url="+href);
     397                }
     398                else
     399                {
     400                    // el = '' or direct
     401                    //the web page is re-directed to the external URL (&el=&rl=0&href="http://...")
     402                    response.setContentType("text/xml");
     403                    response.sendRedirect(href);
     404                }
    402405            }
    403406        }
     
    701704
    702705        String requestedURL = request.getRequestURL().toString();
    703         String baseURL = requestedURL.substring(0, requestedURL.indexOf(this.getServletName()));
    704         xml_request.setAttribute("baseURL", baseURL);
     706        String baseURL = "";
     707        if (requestedURL.indexOf(this.getServletName()) != -1)
     708        {
     709            baseURL = requestedURL.substring(0, requestedURL.indexOf(this.getServletName()));
     710            xml_request.setAttribute("baseURL", baseURL);
     711        }
     712
     713        String fullURL;
     714        if (request.getQueryString() != null)
     715        {
     716            fullURL = requestedURL + "?" + request.getQueryString();
     717        }
     718        else
     719        {
     720            fullURL = requestedURL;
     721        }
     722
    705723        xml_request.setAttribute("remoteAddress", request.getRemoteAddr());
     724        xml_request.setAttribute("fullURL", fullURL.replace("&", "&"));
    706725
    707726        if (!runSecurityChecks(request, xml_request, userContext, out, baseURL, collection, document))
     
    870889                    Element urlParam = this.doc.createElement(GSXML.PARAM_ELEM);
    871890                    urlParam.setAttribute(GSXML.NAME_ATT, "redirectURL");
    872                     urlParam.setAttribute(GSXML.VALUE_ATT, this.getServletName() + "?" + request.getQueryString().replace("&", "&"));
     891                    if (request.getQueryString() != null && request.getQueryString().length() > 0)
     892                    {
     893                        urlParam.setAttribute(GSXML.VALUE_ATT, this.getServletName() + "?" + request.getQueryString().replace("&", "&"));
     894                    }
     895                    else
     896                    {
     897                        urlParam.setAttribute(GSXML.VALUE_ATT, this.getServletName());
     898                    }
    873899                    paramList.appendChild(urlParam);
    874900
Note: See TracChangeset for help on using the changeset viewer.