var result = StructNew(); var bean = ""; var errorMsg = ""; var errorSafeMsg = ""; var errorLogLabel = ""; var hasError = false; var siteDevMode = application.ADF.siteDevMode; arguments.appName = TRIM(arguments.appName); arguments.beanName = TRIM(arguments.beanName); arguments.methodName = TRIM(arguments.methodName); // if there has been an app name passed through go directly to that if( LEN(TRIM(arguments.appName)) AND !arguments.softFail ) { if ( StructKeyExists(application,arguments.appName) ) { if( LEN(TRIM(arguments.beanName)) ) { if ( StructKeyExists(application[arguments.appName],arguments.beanName) ) { try { bean = application[arguments.appName][arguments.beanName]; } catch ( any excpt ) { hasError = true; errorSafeMsg = "Error: The provided appName/beanName combination could not be used to reference an existing component! Check the Error logs for more details."; errorLogMsg = "Error: The provided appName/beanName '#arguments.appName#.#arguments.beanName#' combination could not be used to reference an existing component! Attempting to call the Method: '#arguments.methodName#'"; errorLogMsg = excpt; } } else { hasError = true; errorSafeMsg = "Error: The provided appName/beanName combination were not found and could not be used to reference a component!"; errorLogMsg = "Error: The provided appName/beanName '#arguments.appName#.#arguments.beanName#' was not found and could not be used to reference a component! Attempting to call the Method: '#arguments.methodName#'"; } } else { hasError = true; errorSafeMsg = "Error: A beanName was not provided!"; errorLogMsg = "Error: The provided beanName '#arguments.beanName#' was not provided! Attempting to call the Method: '#arguments.methodName#'"; } } else { hasError = true; errorSafeMsg = "Error: The provided appName was not found and could not be used to reference a component!"; errorLogMsg = "Error: The provided appName '#arguments.appName#' was not found and could not be used to reference a component! Attempting to call the Bean:'#arguments.beanName#' and Method: '#arguments.methodName#'"; } } else { if( LEN(TRIM(arguments.beanName)) ) { // if the softFail argument is true and an appName is passed in try to use appName.beanName first // - after that it will try to find a matching component object based on just the beanName // - first in the application.ADF object and then looking through the server.ADF if( LEN(arguments.appName) AND StructKeyExists(application, arguments.appName) AND StructKeyExists(application[arguments.appName],arguments.beanName) ) { bean = application[arguments.appName][arguments.beanName]; } else if ( application.ADF.objectFactory.containsBean(arguments.beanName) ) { bean = application.ADF.objectFactory.getBean(arguments.beanName); } else if ( server.ADF.objectFactory.containsBean(arguments.beanName) ) { bean = server.ADF.objectFactory.getBean(arguments.beanName); } else if ( StructKeyExists(application.ADF,arguments.beanName) ) { bean = application.ADF[arguments.beanName]; } } else { hasError = true; errorSafeMsg = "Error: A beanName was not provided!"; errorLogMsg = "Error: The provided beanName '#arguments.beanName#' was not provided! Attempting to call the Method: '#arguments.methodName#'"; } } hasError = true; errorSafeMsg = "Error: Calling the RunCommand() method failed. Check the Error logs for more details."; if ( LEN(arguments.appName) ) errorLogLabel = "Error: Calling the utils.RunCommand() method failed. #arguments.appName#.#arguments.beanName#.#arguments.methodName#"; else errorLogLabel = "Error: Calling the utils.RunCommand() method failed. #arguments.beanName#.#arguments.methodName#"; errorLogMsg = cfcatch; hasError = true; errorSafeMsg = "Error: The Bean is not an Object and could not be used as a component! Check the Error logs for more details."; if ( LEN(arguments.appName) ) errorLogMsg = "Error: The Bean '#arguments.appName#.#arguments.beanName#' is not an Object and could not be used as a component! Attempting to call the Method: '#arguments.methodName#'"; else errorLogMsg = "Error: The Bean '#arguments.beanName#' is not an Object and could not be used as a component! Attempting to call the Method: '#arguments.methodName#'"; if ( hasError ) { if ( siteDevMode ) result.reData = errorLogMsg; else result.reData = errorSafeMsg; logAppend(msg=errorLogMsg,label=errorLogLabel,logfile='adf-run-command.html'); } // Check to make sure the result.returnData was not destroyed by a method that returns void if ( StructKeyExists(result,"reData") ) return result.reData; else return; var rtn = StructNew(); var listStart = ''; var listEnd = ''; var pg = ''; var maxPage = Ceiling(arguments.itemCount / arguments.pageSize); var itemStart = 0; var itemEnd = 0; // Make sure we don't have any extra spaces arguments.pageParamName = trim(arguments.pageParamName); // Make sure the value passed in for listLimit is at least 4 if (arguments.listLimit LT 4 ) arguments.listLimit = 4; if ( arguments.page LT 1 ) arguments.page = 1; else if ( arguments.page GT maxPage ) arguments.page = maxPage; if ( arguments.page EQ 1 ) { itemStart = 1; itemEnd = arguments.pageSize; } else { itemStart = ((arguments.page - 1) * arguments.pageSize) + 1; itemEnd = arguments.page * arguments.pageSize; } if ( itemEnd GT arguments.itemCount ) itemEnd = arguments.itemCount; rtn.itemStart = itemStart; rtn.itemEnd = itemEnd; // Validate that the URL Params arg starts with a leading "&" if ( LEN(arguments.URLparams) AND (LEFT(arguments.URLparams,1) NEQ "&") ) arguments.URLparams = "&" & arguments.URLparams; var fileInfo = CreateObject("java","java.io.File").init(arguments.filePath); var thisModuleLastModified = fileInfo.lastModified(); var thisModuleDateTime = createObject("java","java.util.Date").init(thisModuleLastModified); return thisModuleDateTime; var retResult = StructNew(); var schedURL = arguments.url; var defaultDateFormat = "mm/dd/yyyy"; var defaultTimeFormat = "HH:mm"; var defaultMinStartDelay = 5; var defaultMinIntervalDelay = 15; var defaultRequestTimeOut = "3600"; // 3600 second (1 hour) is the default before the request times out var defaultInterval = "once"; var intervalOptionsList = "once,daily,weekly,monthly"; var defaultStartDateTime = DateAdd("n",defaultMinStartDelay,Now()); var defaultEndDateTime = DateAdd("n",1,defaultStartDateTime); var logFileDir = arguments.schedLogDir; var fullLogFilePath = ""; var uniqueFullLogFilePath = ""; var uniqueLogFileName = ""; var logExt = ""; var logFileName = ""; var schedStartDate = arguments.startDate; var schedStartTime = arguments.startTime; var schedEndDate = ""; var schedEndTime = ""; var schedStartDateTime = ""; var schedEndDateTime = ""; // Set the schedInterval to the default value var schedInterval = defaultInterval; var schedRequestTimeOut = defaultRequestTimeOut; // TODO: FUTURE FEATURE: Use for recurring tasks that need authentication to run unattended var validAuthToken = false; // ACF 10+ only allows .log and .txt extension for the generated log files. // Additional extensions can be added to the \cfusion\lib\neo-cron.xml config file. // https://wikidocs.adobe.com/wiki/display/coldfusionen/cfschedule logExt = ListLast(arguments.schedLogFileName,'.'); logFileName = Mid(arguments.schedLogFileName, 1, Len(arguments.schedLogFileName)-Len(logExt)-1); if ( ListFindNoCase(arguments.allowedLogExts,logExt) EQ 0 ) arguments.schedLogFileName = logFileName & ".log"; fullLogFilePath = logFileDir & arguments.schedLogFileName; uniqueFullLogFilePath = createUniqueFileName(fullLogFilePath); uniqueLogFileName = ListLast(uniqueFullLogFilePath,"/"); // Verify that the interval passed is valid, if not set the interval to once // - if a numeric value they run the task every X number of seconds if ( IsNumeric(arguments.interval) OR ListFindNoCase(intervalOptionsList,arguments.interval) ) schedInterval = arguments.interval; // Build Start Date if ( LEN(TRIM(schedStartDate)) AND application.ADF.date.IsRealDate(schedStartDate) ) schedStartDate = DateFormat(schedStartDate,defaultDateFormat); else schedStartDate = DateFormat(defaultStartDateTime,defaultDateFormat); // Build Start Time if ( LEN(TRIM(schedStartTime)) AND application.ADF.date.IsRealDate(schedStartTime) ) schedStartTime = TimeFormat(schedStartTime, defaultTimeFormat); else schedStartTime = TimeFormat(defaultStartDateTime, defaultTimeFormat); // Build Start Date/Time String schedStartDateTime = DateFormat(schedStartDate,"mm-dd-yyyy") & " " & TimeFormat(schedStartTime,"HH:mm:ss"); // Make sure the Start Date/Time is really in the future if ( defaultStartDateTime GT schedStartDateTime ) { schedStartDate = DateFormat(defaultStartDateTime,defaultDateFormat); schedStartTime = TimeFormat(defaultStartDateTime, defaultTimeFormat); schedStartDateTime = DateFormat(schedStartDate,"mm-dd-yyyy") & " " & TimeFormat(schedStartTime,"HH:mm:ss"); } // Build End Date if ( LEN(TRIM(arguments.endDate)) AND application.ADF.date.IsRealDate(arguments.endDate) ) { schedEndDate = DateFormat(schedStartDate,defaultDateFormat); if ( LEN(TRIM(arguments.endTime)) AND application.ADF.date.IsRealDate(arguments.endTime) ) schedEndTime = TimeFormat(arguments.endTime, defaultTimeFormat); else schedEndTime = "23:59:59"; schedEndDateTime = DateFormat(schedEndDate,"mm-dd-yyyy") & " " & TimeFormat(schedEndTime,"HH:mm:ss"); // Make sure the End Date/Time is after the Start Date/Time if ( schedEndDateTime GT schedStartDateTime ) { schedEndDate = ""; schedEndTime = ""; schedEndDateTime = ""; } } // Make sure the passed timeout value is a valid integer if ( IsNumeric(arguments.timeout) ) schedRequestTimeOut = int(arguments.timeout); // Validate authtoken (Future authentication feature) //validAuthToken = application.ADF.csSecurity.isValidAuthToken(arguments.authtoken); validAuthToken = true; if ( LEN(TRIM(arguments.AuthToken)) AND validAuthToken ) schedURL = schedURL & "&authtoken=" & arguments.authtoken; // Set up the return result struct variables retResult.status = ""; retResult.authenicated = validAuthToken; //Future authentication feature var retParams = arguments.csParams; var paramsOverride = StructNew(); var key = ""; // Build the App Params Struct that will override the XPARAMS/ATTRIBUTES keys and values If ( LEN(TRIM(arguments.appName)) AND LEN(TRIM(arguments.appParamsVarName)) ) { if ( StructKeyExists(application,TRIM(arguments.appName)) AND StructKeyExists(application[TRIM(arguments.appName)],TRIM(arguments.appParamsVarName)) ) paramsOverride = application[TRIM(arguments.appName)][TRIM(arguments.appParamsVarName)]; // Replace the the XPARAMS PROPS values with the APP CONFIG override values if ( IsStruct(paramsOverride) ) { for ( key in paramsOverride ) { // Check to make sure the param from the App can override the CS param if ( ListFindNoCase(arguments.paramsExceptionList,key) EQ 0 ) retParams[key] = paramsOverride[key]; } } } return retParams; var retData = StructNew(); var dataTemp = StructNew(); var retError = true; if ( !IsValid('variableName',arguments.dumpVarStr) ) { retError = true; retData.dumpVar = arguments.dumpVarStr; retData.dumpMsg = "The ADFDumpVar utility was not passed a valid variable name."; } try { dataTemp = Evaluate(arguments.dumpVarStr); // Evaluate the passed in variable // TODO: We need to find a better way to do this! retError = false; } catch ( any e ) { retError = true; retData.dumpVar = arguments.dumpVarStr; retData.dumpMsg = "The ADFDumpVar utility failed to parse the passed in variable name."; } if ( !retError ) { // Clean the secure data from the dump data if ( arguments.sanitize ) { // Use if ( arguments.dumpVarStr EQ "server" ) { retData.dumpMsg = "The ADFDumpVar utility cannot be used to dump the entire SERVER scope"; } else { retData = sanitizeADFDumpVarData(dumpVarStr=arguments.dumpVarStr,dumpVarData=dataTemp); } } else retData = dataTemp; } return retData; var retData = ""; var configPWscope = "server"; var configPWkey = "cspassword"; var configPWReplaceValue = "**************"; var pwFindArray = ArrayNew(1); var i = 1; var k = 1; var n = 1; var configPWpath = ""; var configPWpathKey = ""; var configPWpathKeyList = ""; var configPWpathArray = ArrayNew(1); var varPath = ""; retData = arguments.dumpVarData; if ( ListFirst(arguments.dumpVarStr,".") EQ configPWscope ) { if ( ListFindNoCase(arguments.dumpVarStr,configPWkey,".") AND IsSimpleValue(arguments.dumpVarData) ) { retData = configPWReplaceValue; } else if ( IsStruct(arguments.dumpVarData) AND arguments.dumpVarStr NEQ "server") { if ( arguments.dumpVarStr EQ "server" ) { // We can not allow using the ADFdumpVar command to dump the enitre SERVER scope retData.dumpMsg = "The ADFDumpVar utility cannot be used to dump the entire SERVER scope"; } else { retData = application.ADF.data.duplicateStruct(arguments.dumpVarData); // Find the instances of the CSPASSWORD struct key pwFindArray = StructFindKey(retData,configPWkey,"all"); // Loop over the Find Array and REPLACE each value with a TEMP string for ( i=1; i LTE ArrayLen(pwFindArray); i=i+1 ) { varPath = "retData"; configPWpath = pwFindArray[i].path; configPWpathArray = ListToArray(configPWpath,"."); for ( n=1; n LTE ArrayLen(configPWpathArray); n=n+1 ) { if ( IsNumeric(configPWpathArray[n]) ) varPath = varPath & "[" & configPWpathArray[n] & "]"; else if ( configPWpathArray[n] NEQ configPWkey ) varPath = varPath & "." & configPWpathArray[n]; } // Evaluate the concatenated variable path // TODO: We need to find a better way to do this! // and Update the retData[varPath] with the new replacement values StructUpdate(Evaluate(varPath), configPWkey, configPWReplaceValue); } } } } return retData;