Program: 71691
Project: 71691
Buggy source:
/** 
 * Create web viewer url to run the report.
 * @param servletName servlet name to viewer report
 * @param report report file name
 * @param format report format
 * @param resourceFolder the resource folder
 * @param maxrows max rows limited
 * @param maxlevels max level member limited
 * @return valid web viewer url
 */
private static String createURL(String webappName,String servletName,String report,String format,String resourceFolder,String maxrows,String maxrowlevels,String maxcolumnlevels){
  String encodedReportName=null;
  try {
    encodedReportName=URLEncoder.encode(report,UTF_8);
  }
 catch (  UnsupportedEncodingException e) {
    LogUtil.logWarning(e.getLocalizedMessage(),e);
  }
  String locale=ViewerPlugin.getDefault().getPluginPreferences().getString(USER_LOCALE);
  if (LocaleTable.containsKey(locale)) {
    locale=(String)LocaleTable.get(locale);
  }
 else {
    if ("String_Node_Str".equals(locale)) {
      locale=null;
    }
 else {
      try {
        locale=URLEncoder.encode(locale,UTF_8);
      }
 catch (      UnsupportedEncodingException e) {
        locale=null;
        LogUtil.logWarning(e.getLocalizedMessage(),e);
      }
    }
  }
  String svgFlag=ViewerPlugin.getDefault().getPluginPreferences().getString(SVG_FLAG);
  boolean bSVGFlag=false;
  String cubeMemorySize=ViewerPlugin.getDefault().getPluginPreferences().getString(PREVIEW_MAXINMEMORYCUBESIZE);
  boolean rtl=false;
  String bidiOrientation=ViewerPlugin.getDefault().getPluginPreferences().getString(BIDI_ORIENTATION);
  if (bidiOrientation == null) {
    bidiOrientation=BIDI_ORIENTATION_AUTO;
  }
  if (BIDI_ORIENTATION_LTR.equals(bidiOrientation)) {
    rtl=false;
  }
 else   if (BIDI_ORIENTATION_RTL.equals(bidiOrientation)) {
    rtl=true;
  }
 else {
    rtl=(Window.getDefaultOrientation() == SWT.RIGHT_TO_LEFT);
  }
  if ("String_Node_Str".equalsIgnoreCase(svgFlag)) {
    bSVGFlag=true;
  }
  String masterPageContent=ViewerPlugin.getDefault().getPluginPreferences().getString(MASTER_PAGE_CONTENT);
  boolean bMasterPageContent=true;
  if ("String_Node_Str".equalsIgnoreCase(masterPageContent)) {
    bMasterPageContent=false;
  }
  String encodedResourceFolder=null;
  try {
    if (resourceFolder != null)     encodedResourceFolder=URLEncoder.encode(resourceFolder,UTF_8);
  }
 catch (  UnsupportedEncodingException e) {
    LogUtil.logWarning(e.getLocalizedMessage(),e);
  }
  if (encodedResourceFolder == null)   encodedResourceFolder="String_Node_Str";
  String reportParam="String_Node_Str";
  if (isReportDocument(encodedReportName))   reportParam="String_Node_Str";
  reportParam+="String_Node_Str" + encodedReportName;
  String asattachment=null;
  if (POSTSCRIPT.equalsIgnoreCase(format))   asattachment="String_Node_Str";
  int dpi=Toolkit.getDefaultToolkit().getScreenResolution();
  return getBaseURL(webappName) + servletName + "String_Node_Str"+ reportParam+ "String_Node_Str"+ format+ "String_Node_Str"+ String.valueOf(bSVGFlag)+ (locale != null ? "String_Node_Str" + locale : "String_Node_Str")+ "String_Node_Str"+ String.valueOf(bMasterPageContent)+ "String_Node_Str"+ String.valueOf(rtl)+ (maxrows != null && maxrows.trim().length() > 0 ? "String_Node_Str" + maxrows : "String_Node_Str")+ (maxrowlevels != null && maxrowlevels.trim().length() > 0 ? "String_Node_Str" + maxrowlevels : "String_Node_Str")+ (maxcolumnlevels != null && maxcolumnlevels.trim().length() > 0 ? "String_Node_Str" + maxcolumnlevels : "String_Node_Str")+ (cubeMemorySize != null && cubeMemorySize.trim().length() > 0 ? "String_Node_Str" + cubeMemorySize : "String_Node_Str")+ "String_Node_Str"+ encodedResourceFolder+ (asattachment != null ? asattachment : "String_Node_Str")+ "String_Node_Str"+ dpi;
}

Fixed version (ground truth):
private static String createURL(String webappName,String servletName,String report,Map<String,String> urlParams){
  String encodedReportName=null;
  try {
    encodedReportName=URLEncoder.encode(report,UTF_8);
  }
 catch (  UnsupportedEncodingException e) {
    LogUtil.logWarning(e.getLocalizedMessage(),e);
  }
  String reportParam=ParameterAccessor.PARAM_REPORT;
  if (isReportDocument(encodedReportName)) {
    reportParam=ParameterAccessor.PARAM_REPORT_DOCUMENT;
  }
  reportParam+="String_Node_Str" + encodedReportName;
  return getBaseURL(webappName) + servletName + "String_Node_Str"+ reportParam+ convertParams(urlParams);
}