Fix WCI Publisher Search with a simple tweak

Ever seen this error in WebCenter Publisher when using Friendly URLs?

INFO | ERROR java.lang.StringIndexOutOfBoundsException: String index out of range: -1
INFO | ERROR at java.lang.String.substring(String.java:1768)
INFO | ERROR at org.apache.jsp.published_005ftools.search_jsp._jspService(search_jsp.java:101)
INFO | ERROR at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
INFO | ERROR at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
INFO | ERROR at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)

Yeah, it’s not the first time that Friendly URLs breaks existing functionality, and like that Excel issue, fortunately the fix is pretty easy. Basically, you’ll need to open up the ptcs.war file and edit the /published_tools/search.jsp file in there. Specifically, there’s a section that looks like this:

       String baseURL = (cspRequest.getReturnURI().toString());

       //SE-VV: 57027 - With the recent portal code changes in Merced, the string "gateway"
       //is not present in the baseURL anymore. As a workaround, we instead look for "?" so that index is a 
       //non-negative integer. Now, when we search for a CI from within a news portlet, it'll take us to
       //the correct search results page instead of throwing an error.
       int index = baseURL.indexOf("gateway");
       if(index < 0){
              index = baseURL.indexOf("?") + 1;
       }
              baseURL = baseURL.substring(0, index - 1);


The fix is to add one more conditional to the bottom:

       String baseURL = (cspRequest.getReturnURI().toString());

       //SE-VV: 57027 - With the recent portal code changes in Merced, the string "gateway"
       //is not present in the baseURL anymore. As a workaround, we instead look for "?" so that index is a 
       //non-negative integer. Now, when we search for a CI from within a news portlet, it'll take us to
       //the correct search results page instead of throwing an error.
       int index = baseURL.indexOf("gateway");
       if(index < 0){
              index = baseURL.indexOf("?") + 1;
       }
       if(index < 0){
              // with friendly URLs, "index" may be -1 because there may not be a ? in the URL (i.e., no query string)
              baseURL = baseURL.substring(0, index - 1);
       }

Apply the fix, restart Publisher, and Publisher search will be back:
wci-publisher-search

Tags: , ,

Comments are closed.