// xml config info variables.CCAPIConfig = structNew(); // CS Content Creation API settings variables.csUserId = ""; variables.csPassword = ""; variables.SSID = ""; variables.siteURL = ""; variables.webserviceURL = ""; variables.subsiteID = ""; // vars for elements and templates variables.elements = structNew(); variables.templates = structNew(); loadCCAPIConfig(); // load the elements and templates loadElements(); loadWSVars(); buildWS(); var CCAPIConfig = StructNew(); var configAppXMLPath = ExpandPath("#request.site.csAppsURL#config/ccapi.xml"); var configAppCFMPath = request.site.csAppsURL & "config/ccapi.cfm"; // config data should be loaded here // TODO: Need some error checking here // CCAPIConfig = server.ADF.environment[request.site.id].ccapi; // Pass a Logical path for the CFM file to the getConfigViaXML() since it will be read via CFINCLUDE if ( FileExists(ExpandPath(configAppCFMPath)) ) CCAPIConfig = server.ADF.objectFactory.getBean("CoreConfig").getConfigViaXML(configAppCFMPath); // Pass an Absolute path for the XML file to the getConfigViaXML() since it will be read via CFFILE else if ( FileExists(configAppXMLPath) ) CCAPIConfig = server.ADF.objectFactory.getBean("CoreConfig").getConfigViaXML(configAppXMLPath); setCCAPIConfig(CCAPIConfig); variables.utils.logAppend("CCAPI Configuration CFM (or XML) file is not setup for this site [#request.site.name# - #request.site.id#].", "CCAPI_Errors.log"); var wsURL = getWebServiceURL(); var wsPath = "commonspot.webservice.cs_service"; // Check to see if the WebService URL is using the 7.0.1+, 8.0.1+ and 9+ cs_remote.cfc if ( FindNoCase(wsURL,"cs_remote") ) wsPath = "commonspot.webservice.cs_remote"; // Set the WS value if ( arguments.forceRemote ) variables.ws = createObject("webService", wsURL); else variables.ws = createObject("component", wsPath); var CCAPIConfig = getCCAPIConfig(); var elementsList = ""; var itm = 0; var thisElement = ""; var elementName = ""; var elements = structNew(); if( isStruct(CCAPIConfig) and structKeyExists(CCAPIConfig, "elements") and isStruct(CCAPIConfig["elements"]) ) elementsList = structKeyList(CCAPIConfig["elements"]); for( itm=1; itm lte listLen(elementsList); itm=itm+1 ) { elementName = listGetAt(elementsList, itm); thisElement = CCAPIConfig["elements"][elementName]; // load this element into local variables first structInsert(elements, elementName, thisElement); } // load the elements into object space setElements(elements); var CCAPIConfig = getCCAPIConfig(); var wsVars = structNew(); if( isStruct(CCAPIConfig) and structKeyExists(CCAPIConfig, "wsVars") ) wsVars = CCAPIConfig["wsVars"]; if( structKeyExists(wsVars, "csuserid") ) setCSUserID(wsVars["csuserid"]); if( structKeyExists(wsVars, "cspassword") ) setCSPassword(wsVars["cspassword"]); if( structKeyExists(wsVars, "siteURL") ) setSiteURL(wsVars["siteURL"]); if( structKeyExists(wsVars, "webserviceURL") ) setWebServiceURL(wsVars["webserviceURL"]); if( structKeyExists(wsVars, "subsiteID") ) setSubsiteID(wsVars["subsiteID"]); var elementExists = 0; if( structKeyExists(getElements(), arguments.elementName) ) elementExists = 1; return elementExists; var error = ""; var loginResult = ""; if(loggedIn()){ logout(); } if( arguments.subsiteID gt 0 ){ setSubsiteID(arguments.subsiteID); } loginResult = variables.ws.csLogin( site = getSiteURL(), csUserID = getCSUserID(), csPassword = getCSPassword(), subSiteID = getSubsiteID(), subSiteURL = ''); // Verify that the login was successful and set the SSID if ( ListFirst(loginResult, ":") is "Success" ){ // Set the SSID setSSID(listRest(loginResult, ":")); // Log Success if( loggingEnabled() ) variables.utils.logAppend("#request.formattedTimestamp# - Success logging in to CCAPI: #loginResult#, [SubSiteID:#subSiteID#]", "CCAPI_ws_login.log"); } else { // Clear the SSID setSSID(""); error = listLast(loginResult, ":"); // Log Error if( loggingEnabled() ) variables.utils.logAppend("#request.formattedTimestamp# - Error logging in to CCAPI: #error#", "CCAPI_ws_login.log"); } //return loginResult; var logoutResult = variables.ws.csLogout(getSSID()); // Clear the SSID and SubsiteID for the session setSSID(""); setSubsiteID(0); if( loggingEnabled() ) variables.utils.logAppend("#request.formattedTimestamp# - Logout result: #logoutResult#", "CCAPI_ws_login.log"); var rtnVar = "false"; // if we did not get a message assume that length in the ssid will suffice if( not len(arguments.resultMsg) ) { // if the first character of the SSID is a number then we logged in if( isNumeric(left(getSSID(),1)) ) rtnVar = "true"; } else { // do we have the "no login" message if( not findNoCase("No login", arguments.resultMsg) ) rtnVar = "true"; } delete from locks where targetID = if( loggingEnabled() ) variables.utils.logAppend("#now()# - clearing locks - pageID: #arguments.pageID#", "CCAPI_status.log"); var config = getCCAPIConfig(); if(isStruct(config) and StructKeyExists(config,"logging") and StructKeyExists(config.logging,"enabled") and Len(config.logging.enabled)){ return true; } return false;