*/
private void execute(ExecutionInstance instance, SubObject subObj, String[] vpParameters,
SourceBean response) {
logger.debug("IN");
EMFErrorHandler errorHandler = getErrorHandler();
BIObject obj = instance.getBIObject();
// GET ENGINE ASSOCIATED TO THE BIOBJECT
Engine engine = obj.getEngine();
// GET THE TYPE OF ENGINE (INTERNAL / EXTERNAL) AND THE SUITABLE
// BIOBJECT TYPES
Domain engineType = null;
Domain compatibleBiobjType = null;
try {
engineType = DAOFactory.getDomainDAO().loadDomainById(
engine.getEngineTypeId());
compatibleBiobjType = DAOFactory.getDomainDAO().loadDomainById(
engine.getBiobjTypeId());
} catch (EMFUserError error) {
logger.error("Error retrieving document's engine information",
error);
errorHandler.addError(error);
return;
}
String compatibleBiobjTypeCd = compatibleBiobjType.getValueCd();
String biobjTypeCd = obj.getBiObjectTypeCode();
// CHECK IF THE BIOBJECT IS COMPATIBLE WITH THE TYPES SUITABLE FOR THE
// ENGINE
if (!compatibleBiobjTypeCd.equalsIgnoreCase(biobjTypeCd)) {
// the engine document type and the biobject type are not compatible
logger.warn("Engine cannot execute input document type: "
+ "the engine " + engine.getName() + " can execute '"
+ compatibleBiobjTypeCd + "' type documents "
+ "while the input document is a '" + biobjTypeCd + "'.");
Vector params = new Vector();
params.add(engine.getName());
params.add(compatibleBiobjTypeCd);
params.add(biobjTypeCd);
errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR,
2002, params));
return;
}
// GET USER PROFILE
IEngUserProfile profile = getUserProfile();
// IF USER CAN'T EXECUTE THE OBJECT RETURN
if (!canExecute(profile, obj))
return;
// GET THE EXECUTION ROLE FROM SESSION
String executionRole = instance.getExecutionRole();
// IF THE ENGINE IS EXTERNAL
if ("EXT".equalsIgnoreCase(engineType.getValueCd())) {
try {
response.setAttribute(SpagoBIConstants.PUBLISHER_NAME, "ExecuteBIObjectPageExecution");
// instance the driver class
String driverClassName = obj.getEngine().getDriverName();
IEngineDriver aEngineDriver = (IEngineDriver) Class.forName(
driverClassName).newInstance();
// get the map of the parameters
Map mapPars = null;
if (subObj != null)
mapPars = aEngineDriver.getParameterMap(obj, subObj,
profile, executionRole);
else
mapPars = aEngineDriver.getParameterMap(obj, profile,
executionRole);
// adding or substituting parameters for viewpoint
if (vpParameters != null) {
for (int i = 0; i < vpParameters.length; i++) {
String param = (String) vpParameters[i];
String name = param.substring(0, param.indexOf("="));
String value = param.substring(param.indexOf("=") + 1);
if (mapPars.get(name) != null) {
mapPars.remove(name);
mapPars.put(name, value);
} else
mapPars.put(name, value);
}
}
//GET DOC CONFIG FOR DOCUMENT COMPOSITION
if (contextManager.get("docConfig") != null)
mapPars.put("docConfig", (DocumentCompositionConfiguration) contextManager.get("docConfig"));
// set into the reponse the parameters map
response.setAttribute(ObjectsTreeConstants.REPORT_CALL_URL,
mapPars);
if (subObj != null) {
response.setAttribute(SpagoBIConstants.SUBOBJECT, subObj);
}
} catch (Exception e) {
logger.error("Error During object execution", e);
errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR,
100));
}
// IF THE ENGINE IS INTERNAL
} else {
String className = engine.getClassName();
logger.debug("Try instantiating class " + className
+ " for internal engine " + engine.getName() + "...");
InternalEngineIFace internalEngine = null;
// tries to instantiate the class for the internal engine
try {
if (className == null && className.trim().equals(""))
throw new ClassNotFoundException();
internalEngine = (InternalEngineIFace) Class.forName(className)
.newInstance();
} catch (ClassNotFoundException cnfe) {
logger.error("The class ['" + className
+ "'] for internal engine " + engine.getName()
+ " was not found.", cnfe);
Vector params = new Vector();
params.add(className);
params.add(engine.getName());
errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR,
2001, params));
return;
} catch (Exception e) {
logger.error("Error while instantiating class " + className, e);
errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR,
100));
return;
}
logger
.debug("Class "
+ className
+ " instantiated successfully. Now engine's execution starts.");
// starts engine's execution
try {
if (subObj != null)
internalEngine.executeSubObject(this.getRequestContainer(),
obj, response, subObj);
else
internalEngine.execute(this.getRequestContainer(), obj,
response);
} catch (EMFUserError e) {
logger.error("Error while engine execution", e);
errorHandler.addError(e);
} catch (Exception e) {
logger.error("Error while engine execution", e);
errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR,
100));
}
}
logger.debug("OUT");