var hasError = 0; var callingFileName = "lightboxProxy.cfm"; var bean = ""; var method = ""; var appName = ""; var params = StructNew(); var debug = 0; var result = StructNew(); var reDebugRaw = ""; var args = StructNew(); // list of parameters in request.params to exclude var argExcludeList = "bean,method,appName,forceScripts,addLBHeaderFooter,addMainTable,debug"; // Verify if the bean and method combo are allowed to be accessed through the ajax proxy var passedSecurity = false; var siteDevMode = application.ADF.siteDevMode; // Initalize the reHTML key of the local struct result.reHTML = ""; // Since we are relying on the request.params scope make sure the key params are available if ( StructKeyExists(request,"params") ) { params = request.params; if ( StructKeyExists(request.params,"bean") ) bean = request.params.bean; if ( StructKeyExists(request.params,"method") ) method = request.params.method; if ( StructKeyExists(request.params,"appName") ) appName = request.params.appName; if ( StructKeyExists(request.params,"debug") ) debug = request.params.debug; } if ( arguments.proxyFile NEQ callingFileName ) { // Verify if the bean and method combo are allowed to be accessed through the lightbox proxy passedSecurity = variables.csSecurity.validateProxy(bean, method); if ( passedSecurity ) { // convert the params that are passed in to the args struct before passing them to runCommand method args = variables.utils.buildRunCommandArgs(params,argExcludeList); try { // Run the Bean, Method and Args and get a return value result.reHTML = variables.utils.runCommand(trim(bean),trim(method),args,trim(appName)); } catch( Any e ) { hasError = 0; // if set to true, this will output the error html twice, so let debug handle it debug = 1; result.reHTML = e; variables.utils.logAppend( msg=e, label='Error in LightboxProxy calling utils.runCommand()', logfile='adf-lightbox-proxy.html' ); } // Build the DUMP for debugging the RAW value of reHTML if ( debug AND siteDevMode ) { // If the variable reHTML doesn't exist set the debug output to the string: void if ( !StructKeyExists(result,"reHTML") ){reDebugRaw="void";}else{reDebugRaw=result.reHTML;} reDebugRaw = variables.utils.doDump(reDebugRaw,"DEBUG OUTPUT",1,1); } // Check to see if reHTML was destroyed by a method that returns void before attempting to process the return if ( StructKeyExists(result,"reHTML") ) { // 2011-10-03 - MFC - Determine if the result has a CF Error Structure, return CFCATCH error message if ( isObject(result.reHTML) AND structKeyExists(result.reHTML,"message") AND structKeyExists(result.reHTML,"ErrNumber") AND structKeyExists(result.reHTML,"StackTrace") ) { hasError = 1; if ( siteDevMode ) result.reHTML = "Error: " & result.reHTML.message; else result.reHTML = "Error: A request processing error occurred."; } else if ( isStruct(result.reHTML) or isArray(result.reHTML) or isObject(result.reHTML) ) { hasError = 1; // 2012-03-10 - GAC - we need to check if we have a 'message' before we can output it if ( StructKeyExists(result.reHTML,"message") AND siteDevMode ) result.reHTML = "Error: Unable to convert the return value into string [" & result.reHTML.message & "]"; else result.reHTML = "Error: Unable to convert the return value into string."; } } else { // The method call returned void and destroyed the result.reHTML variable hasError = 1; result.reHTML = "Error: Return value came back as 'void'."; } } else { // Show error since the bean and/or method are not in the proxyWhiteList.xml file hasError = 1; if ( !siteDevMode ) { result.reHTML = "Error: The request is not accessible remotely via Lightbox Proxy."; } else { if ( len(trim(appName)) ) result.reHTML = "Error: The Bean: #bean# with method: #method# in the App: #appName# is not accessible remotely via Lightbox Proxy."; else result.reHTML = "Error: The Bean: #bean# with method: #method# is not accessible remotely via Lightbox Proxy."; } } // pass the debug dumps to the result.reHTML for output if ( debug AND siteDevMode ) { if ( hasError ) result.reHTML = result.reHTML & reDebugRaw; else result.reHTML = reDebugRaw; } } else { result.reHTML = "Error: This method can not be called directly."; if ( siteDevMode ) result.reHTML = " Use the lightboxProxy.cfm file."; } return result.reHTML;