I use the below java snippet to fetch the Report Specification XML using Cognos 10.2 SDKs
At random times it fails, not fetching the report xml, which is the base for my application
Please help :(
Errors I face:
while debugging I see a NullPointerException, when qResult.getStatus() = "working"; qResult.getPrimaryRequest() = null; with that Exception is thrown.
=================================================================================
// get the Report Spec
//reportPath = "/content/package[@name='CustomerDetails']/report[@name='Customer Details']"
public String getReportSpec(Object connect, String reportPath) {
String reportSpec = "";
if ((connect.getReportService() != null) && (report != null)) {
// sn_dg_prm_smpl_modifyreport_P1_start_0
try {
String reportPath = report.getBaseClassObject().getSearchPath()
.getValue();
Option[] qOpts = new Option[2];
ReportServiceQueryOptionBoolean upgradeSpecFlag = new ReportServiceQueryOptionBoolean();
upgradeSpecFlag.setName(ReportServiceQueryOptionEnum.upgrade);
upgradeSpecFlag.setValue(true);
ReportServiceQueryOptionSpecificationFormat specFormat = new ReportServiceQueryOptionSpecificationFormat();
specFormat
.setName(ReportServiceQueryOptionEnum.specificationFormat);
specFormat.setValue(SpecificationFormatEnum.report);
qOpts[0] = upgradeSpecFlag;
qOpts[1] = specFormat;
// sn_dg_sdk_method_reportService_query_start_1
AsynchReply qResult = connect.getReportService().query(
new SearchPathSingleObject(reportPath),
new ParameterValue[] {}, qOpts);
// sn_dg_sdk_method_reportService_query_end_1
if ((qResult.getStatus() == AsynchReplyStatusEnum.working)
|| (qResult.getStatus() == AsynchReplyStatusEnum.stillWorking)) {
while ((qResult.getStatus() == AsynchReplyStatusEnum.working)
|| (qResult.getStatus() == AsynchReplyStatusEnum.stillWorking)) {
qResult = connect.getReportService().wait(
qResult.getPrimaryRequest(),
new ParameterValue[] {}, new Option[] {});
}
}
// sn_dg_sdk_method_reportService_query_start_2
// extract the report spec
if (qResult.getDetails() != null) {
for (int i = 0; i < qResult.getDetails().length; i++) {
if (qResult.getDetails() instanceof AsynchDetailReportObject) {
reportSpec = ((AsynchDetailReportObject) qResult
.getDetails()).getReport()
.getSpecification().getValue();
}
}
}
// sn_dg_sdk_method_reportService_query_end_2
}
// sn_dg_prm_smpl_modifyreport_P1_end_0
catch (java.rmi.RemoteException remoteEx) {
System.out.println(remoteEx.getMessage());
remoteEx.printStackTrace();
}
}
return reportSpec;
}