Program: 70883
Project: 70883
Buggy source:
/** 
 * Prepare parameters
 * @throws Exception
 * @throws RemoteException
 */
protected void prepareParameters() throws Exception, RemoteException {
  __bean=(ViewerAttributeBean)context.getBean();
  __docName=__getReportDocument();
  __checkDocumentExists();
  if (ParameterAccessor.isGetReportlet(context.getRequest())) {
    __totalPageNumber=1;
  }
 else {
    InputOptions getPageCountOptions=new InputOptions();
    getPageCountOptions.setOption(InputOptions.OPT_LOCALE,__bean.getLocale());
    getPageCountOptions.setOption(InputOptions.OPT_TIMEZONE,__bean.getTimeZone());
    getPageCountOptions.setOption(InputOptions.OPT_REQUEST,context.getRequest());
    OutputOptions outputOptions=new OutputOptions();
    __totalPageNumber=getReportService().getPageCount(__docName,getPageCountOptions,outputOptions);
    Boolean isCompleted=(Boolean)outputOptions.getOption(OutputOptions.OPT_REPORT_GENERATION_COMPLETED);
    if (isCompleted != null) {
      __isCompleted=isCompleted.booleanValue();
    }
  }
  __pageNumber=getPageNumber(context.getRequest(),operation.getOprand(),__docName);
  if (!isValidPageNumber(context.getRequest(),__pageNumber,__docName)) {
    __bookmark=getBookmark(operation.getOprand(),__bean);
    if (__bookmark != null && __bookmark.length() > 0) {
      InputOptions options=new InputOptions();
      options.setOption(InputOptions.OPT_REQUEST,context.getRequest());
      options.setOption(InputOptions.OPT_LOCALE,__bean.getLocale());
      if (isToc(operation.getOprand(),__bean)) {
        __bookmark=(getReportService()).findTocByName(__docName,__bookmark,options);
      }
      __pageNumber=getReportService().getPageNumberByBookmark(__docName,__bookmark,options);
      if (!isValidPageNumber(context.getRequest(),__pageNumber,__docName)) {
        AxisFault fault=new AxisFault();
        fault.setFaultReason(BirtResources.getMessage(ResourceConstants.ACTION_EXCEPTION_INVALID_BOOKMARK,new String[]{getBookmark(operation.getOprand(),__bean)}));
        throw fault;
      }
      __useBookmark=true;
    }
  }
  if (!isValidPageNumber(context.getRequest(),__pageNumber,__docName)) {
    AxisFault fault=new AxisFault();
    fault.setFaultReason(BirtResources.getMessage(ResourceConstants.ACTION_EXCEPTION_INVALID_PAGE_NUMBER,new Object[]{new Long(__pageNumber),new Long(__totalPageNumber)}));
    throw fault;
  }
  __svgFlag=getSVGFlag(operation.getOprand());
}

Fixed version (ground truth):
/** 
 * Prepare parameters
 * @throws Exception
 * @throws RemoteException
 */
protected void prepareParameters() throws Exception, RemoteException {
  __bean=(ViewerAttributeBean)context.getBean();
  __docName=__getReportDocument();
  __checkDocumentExists();
  if (ParameterAccessor.isGetReportlet(context.getRequest())) {
    __totalPageNumber=1;
  }
 else {
    InputOptions getPageCountOptions=new InputOptions();
    getPageCountOptions.setOption(InputOptions.OPT_LOCALE,__bean.getLocale());
    getPageCountOptions.setOption(InputOptions.OPT_TIMEZONE,__bean.getTimeZone());
    getPageCountOptions.setOption(InputOptions.OPT_REQUEST,context.getRequest());
    OutputOptions outputOptions=new OutputOptions();
    __totalPageNumber=getReportService().getPageCount(__docName,getPageCountOptions,outputOptions);
    Boolean isCompleted=(Boolean)outputOptions.getOption(OutputOptions.OPT_REPORT_GENERATION_COMPLETED);
    if (isCompleted != null) {
      __isCompleted=isCompleted.booleanValue();
    }
  }
  __pageNumber=getPageNumber(context.getRequest(),operation.getOprand(),__docName);
  if (!isValidPageNumber(context.getRequest(),__pageNumber,__docName)) {
    __bookmark=getBookmark(operation.getOprand(),__bean);
    if (__bookmark != null && __bookmark.length() > 0) {
      InputOptions options=new InputOptions();
      options.setOption(InputOptions.OPT_REQUEST,context.getRequest());
      options.setOption(InputOptions.OPT_LOCALE,__bean.getLocale());
      if (isToc(operation.getOprand(),__bean)) {
        __bookmark=(getReportService()).findTocByName(__docName,__bookmark,options);
      }
      __pageNumber=getReportService().getPageNumberByBookmark(__docName,__bookmark,options);
      if (!isValidPageNumber(context.getRequest(),__pageNumber,__docName)) {
        AxisFault fault=new AxisFault();
        fault.setFaultReason(BirtResources.getMessage(ResourceConstants.ACTION_EXCEPTION_INVALID_BOOKMARK,new String[]{getBookmark(operation.getOprand(),__bean)}));
        throw fault;
      }
      __useBookmark=true;
    }
  }
  if (!isValidPageNumber(context.getRequest(),__pageNumber,__docName)) {
    AxisFault fault=new AxisFault();
    fault.setFaultReason(BirtResources.getMessage(ResourceConstants.ACTION_EXCEPTION_INVALID_PAGE_NUMBER,new Object[]{Long.valueOf(__pageNumber),Long.valueOf(__totalPageNumber)}));
    throw fault;
  }
  __svgFlag=getSVGFlag(operation.getOprand());
}