try{
profile= getUserProfile();
}
catch (Exception e) {
logger.error("could not retrieve profile",e);
throw new NonExecutableDocumentException();
}
ExecutionInstance instance =null;
try{
instance = new ExecutionInstance(profile, "111", "111", idDocument, roleName, SpagoBIConstants.SDK_EXECUTION_SERVICE, false, false);
}
catch (Exception e) {
logger.error("error while creating instance",e);
throw new NonExecutableDocumentException();
}
// put the parameters value in SDKPArameters into BiObject
instance.refreshBIObjectWithSDKParameters(parameters);
// check if there were errors referring to parameters
List errors=null;
try{
errors=instance.getParametersErrors();
}
catch (Exception e) {
logger.error("error while retrieving parameters errors",e);
throw new NonExecutableDocumentException();
}
if(errors!=null && errors.size()>0){
for (Iterator iterator = errors.iterator(); iterator.hasNext();) {
Object error = (Object) iterator.next();
if(error instanceof EMFUserError){
EMFUserError emfUser=(EMFUserError)error;
String message="Error on parameter values ";
if(emfUser.getMessage()!=null) message+=" "+emfUser.getMessage();
if(emfUser.getAdditionalInfo()!=null) message+=" "+emfUser.getAdditionalInfo();
logger.error(message);
throw new MissingParameterValue();
}
else if(error instanceof EMFValidationError){
EMFValidationError emfValidation=(EMFValidationError)error;
String message="Error while checking parameters: ";
if(emfValidation.getMessage()!=null) message+=" "+emfValidation.getMessage();
if(emfValidation.getAdditionalInfo()!=null) message+=" "+emfValidation.getAdditionalInfo();
logger.error(message);
throw new InvalidParameterValue();
}
}
}
logger.debug("Check the document type and call the exporter (if present)");
try {
if ( document.getType().equalsIgnoreCase("KPI")) { // CASE KPI
toReturn = executeKpi(document, instance.getBIObject(), (String)profile.getUserUniqueIdentifier(), output);
} else if (document.getType().equalsIgnoreCase("REPORT") || document.getType().equalsIgnoreCase("ACCESSIBLE_HTML")){ // CASE REPORT OR ACCESSIBLE_HTML
toReturn = executeReport(document, instance.getBIObject(), profile, output);
} else {
logger.error("NO EXPORTER AVAILABLE");
}
} catch(Exception e) {
logger.error("Error while executing document");
throw new NonExecutableDocumentException();
}
if(toReturn==null){
logger.error("No result returned by the document");
throw new NonExecutableDocumentException();
}
logger.debug("OUT");
return toReturn;
}