variables.cacheVarName = "ptSocialMediaCache"; variables.tempCacheVarName = "ptSocialMediaCacheTemp"; var varName = variables.cacheVarName; // Reset the ptCalendarCache application Struct variables.socialMediaCacheDAO.createNewCacheSpace(cacheVarName=varName); // Begin the build process buildSocialMediaCache(); return true; var varName = variables.cacheVarName; var tempVarName = variables.tempCacheVarName; // If Cache Exists use TEMP space to do the rebuild if ( StructKeyExists(application,varName) ) { // 1) Copy the current LIVE cache data to the TEMP cache space // - LIVE (ptSocialMediaCache) is the source and TEMP (ptSocialMediaCacheTemp) is the destination variables.socialMediaCacheDAO.copyFeedDataCache(sourceVarName=varName,destVarName=tempVarName); // Once the current data is copied to the Temp... begin the TEMP rebuild process buildSocialMediaCache(cacheVarName=tempVarName); // 2) After RE-Build is complete // - Copy the TEMP Cache over the LIVE Cache // - TEMP (ptSocialMediaCacheTemp) is the source and LIVE (ptSocialMediaCache) is the destination variables.socialMediaCacheDAO.copyFeedDataCache(sourceVarName=tempVarName,destVarName=varName); // 3) Delete the TEMP Cache data from memory variables.socialMediaCacheDAO.deleteFeedCache(cacheVarName=tempVarName); } else { initBuildSocialMediaCache(); } return true; var dateTimeStamp = Now(); var cacheTypeList = getServiceTypeList(); var serviceType = ''; // 1) Make sure the Application cache struct is in place if ( NOT StructKeyExists(application,arguments.cacheVarName) ) variables.socialMediaCacheDAO.createNewCacheSpace(cacheVarName=arguments.cacheVarName); // 2) Build the Feed Cache for each configured service type for (var i = 1; i <= ListLen(cacheTypeList); i++ ) { serviceType = ListGetAt(cacheTypeList,i); buildServiceTypeFeedCache(serviceType=serviceType,cacheVarName=arguments.cacheVarName); } // 3) Set the date/time stamps for the ptCalendarCache build variables.socialMediaCacheDAO.writeCacheTimeStamp(cacheVarName=arguments.cacheVarName); ; // 4) Update the server cache status variables for the cfthread processing. server.ADF.ptSocialMedia.cacheThreadStatus = "completed"; server.ADF.ptSocialMedia.cacheThreadEnd = now(); return true; try { if ( arguments.serviceType EQ "facebook" ) buildFacebookFeedCache(cacheVarName=arguments.cacheVarName); else if ( arguments.serviceType EQ "instagram" ) buildInstagramFeedCache(cacheVarName=arguments.cacheVarName); else if ( arguments.serviceType EQ "twitter" ) buildTwitterFeedCache(cacheVarName=arguments.cacheVarName); else if ( arguments.serviceType EQ "youtube" ) buildYouTubeFeedCache(cacheVarName=arguments.cacheVarName); else if ( arguments.serviceType EQ "wordpress" ) buildWordPressFeedCache(cacheVarName=arguments.cacheVarName); } catch (any e) { application.adf.utils.logappend(msg=e, logfile='debugSM.html', label='cfcatch'); return false; } return true; var retStruct = StructNew(); var smFeedData = StructNew(); var feedArray = ArrayNew(1); var smServiceType = "facebook"; var smItm=1; var smFeedID = ""; var smPostExcludeList = ""; var smRenderLimit = getMaxCachedPostsPerService(); var smcComponent = Server.CommonSpot.api.getObject('socialMediaChannel'); var smAppConfig = getAppConfig(); // Get the active Facebook pages from the CommonSpot social media configuration var smcList = smcComponent.getList(serviceID=1); var fbChannelArray = application.adf.cedata.queryToCEDataArrayOfStructures(smcList); var smPostFilterList = ""; var smFilterType = ""; var filterField = ""; var filteredPostData = {}; // Get the PostIDs of filtered posts var filteredPostData = application.ptsocialmedia.socialMediaCacheDAO.getFilteredPostData(); //application.ptSocialMedia.utils.doDump(smcList,"smcList",0); //application.adf.utils.logappend(msg=smcList, logfile='debugSM.html', label='smcList'); //application.ptSocialMedia.utils.doDump(fbChannelArray,"fbChannelArray",0); //application.adf.utils.logappend(msg=fbChannelArray, logfile='debugSM.html', label='fbChannelArray'); //application.adf.utils.logappend(msg=smAppConfig, logfile='debugSM.html', label='smAppConfig'); // Loop over the Active Facebook pages and build a feed array for each for ( smItm=1; smItm LTE ArrayLen(fbChannelArray); smItm=smItm+1 ) { smFeedID = fbChannelArray[smItm].values.ID; smPostExcludeList = ""; smFilterType = smAppConfig.filterType; if (smFilterType EQ "excluded") filterField = "facebookIncludedList"; else filterField = "facebookExcludedList"; //writeoutput("StructKeyExists(filteredPostData.values,#filterField#) - " & StructKeyExists(filteredPostData.values,filterField)); if ( StructKeyExists(filteredPostData,"values") AND StructKeyExists(filteredPostData.values,filterField) ) { smPostFilterList = filteredPostData.values[filterField]; } /*application.ptSocialMedia.utils.doDump(smPostFilterList, "smPostFilterList - buildFacebookFeedCache", 0);*/ // Build Facebook Feed Data feedArray = variables.facebookFeedsService.buildFacebookFeedData(smFeedID,smRenderLimit,smPostFilterList,arguments.showFeedDump,smFilterType); //application.ptSocialMedia.utils.doDump(feedArray,"feedArray",0); // Add the Feed Array to the final smFeedData struct with the smFeedID as the struct Key if ( ArrayLen(feedArray) ) smFeedData[smFeedID] = feedArray; else { // If a Feed Array is NOT built check the CACHE to see if an Array exists for this smFeedID // - the application.ptSocialMediaCache struct exists checks are done in the Cache DAO functions feedArray = variables.socialMediaCacheDAO.getFacebookFeedData(feedID=smFeedID); // Still only the feed struct if a data array has a length if ( ArrayLen(feedArray) ) smFeedData[smFeedID] = feedArray; } } //application.ptSocialMedia.utils.doDump(smFeedData,"buildFacebookFeedCache - smFeedData",0); // set cache for the service feeds retStruct.status = variables.socialMediaCacheDAO.updateServiceFeedDataCache(serviceType=smServiceType,serviceFeedData=smFeedData,cacheVarName=arguments.cacheVarName); return retStruct; var retStruct = StructNew(); var smFeedData = StructNew(); var feedArray = ArrayNew(1); var smServiceType = "instagram"; var smItm=1; var smFeedID = ""; var smPostExcludeList = ""; var smRenderLimit = getMaxCachedPostsPerService(); var smcComponent = Server.CommonSpot.api.getObject('socialMediaChannel'); var smAppConfig = getAppConfig(); // Get the active Facebook pages from the CommonSpot social media configuration var smcList = smcComponent.getList(serviceID=1); var igChannelArray = application.adf.cedata.queryToCEDataArrayOfStructures(smcList); var smPostFilterList = ""; var smFilterType = ""; var filterField = ""; var filteredPostData = {}; //application.ptSocialMedia.utils.doDump(smcList,"smcList",0); //application.ptSocialMedia.utils.doDump(igChannelArray,"igChannelArray",0); // Loop over the active Instagram pages and build a feed array for each for ( smItm=1; smItm LTE ArrayLen(igChannelArray); smItm=smItm+1 ) { smFeedID = igChannelArray[smItm].values.ID; smPostExcludeList = ""; // Get the PostIDs of filtered posts filteredPostData = application.ptsocialmedia.socialMediaCacheDAO.getFilteredPostData(); //application.ptSocialMedia.utils.doDump(filteredPostData,"filteredPostData - buildFacebookFeedCache",0); smFilterType = smAppConfig.filterType; if (smFilterType EQ "excluded") filterField = "instagramIncludedList"; else filterField = "instagramExcludedList"; if ( StructKeyExists(filteredPostData,"values") AND StructKeyExists(filteredPostData.values,filterField) ) { smPostFilterList = filteredPostData.values[filterField]; //application.ptSocialMedia.utils.doDump(smPostFilterList, "smPostFilterList - buildInstagramFeedCache", 0); } // Build Facebook Feed Data feedArray = variables.instagramFeedsService.buildInstagramFeedData(smFeedID,smRenderLimit,smPostFilterList,arguments.showFeedDump,smFilterType); application.ptSocialMedia.utils.doDump(feedArray,"feedArray",0); // Add the Feed Array to the final smFeedData struct with the smFeedID as the struct Key if ( ArrayLen(feedArray) ) smFeedData[smFeedID] = feedArray; else { // If a Feed Array is NOT built check the CACHE to see if an Array exists for this smFeedID // - the application.ptSocialMediaCache struct exists checks are done in the Cache DAO functions feedArray = variables.socialMediaCacheDAO.getInstagramFeedData(feedID=smFeedID); // Still only the feed struct if a data array has a length if ( ArrayLen(feedArray) ) smFeedData[smFeedID] = feedArray; } } //application.ptSocialMedia.utils.doDump(smFeedData,"smFeedData",0); // set cache for the service feeds retStruct.status = variables.socialMediaCacheDAO.updateServiceFeedDataCache(serviceType=smServiceType,serviceFeedData=smFeedData,cacheVarName=arguments.cacheVarName); return retStruct; var retStruct = StructNew(); var smFeedData = StructNew(); var feedArray = ArrayNew(1); var smServiceType = "twitter"; var smItm=1; var smFeedID = ""; var smfeedCriteria = ""; var smFeedType = ""; var smPostExcludeList = ""; var smAppConfig = getAppConfig(); var smRenderLimit = getMaxCachedPostsPerService(); // Get the Active Twitter accounts and keywords from the element var smSelectedItems = variables.twitterAccountsKeywordsDAO.getTwitterAccountsKeywordsActive(); //application.ptSocialMedia.utils.doDump(smSelectedItems,"smSelectedItems",0); var smPostFilterList = ""; var smFilterType = ""; var filterField = ""; var filteredPostData = {}; // Loop over the items and build a feed array for each for ( smItm=1; smItm LTE ArrayLen(smSelectedItems); smItm=smItm+1 ) { smFeedID = smSelectedItems[smItm].values.uniqueID; // Social media Page or Account to get smfeedCriteria = smSelectedItems[smItm].values.twitterAccountKeyword; smFeedType = smSelectedItems[smItm].values.type; smPostExcludeList = ""; // Get the PostIDs of filtered posts filteredPostData = application.ptsocialmedia.socialMediaCacheDAO.getFilteredPostData(); //application.ptSocialMedia.utils.doDump(filteredPostData,"filteredPostData - buildTwitterFeedCache",0); smFilterType = smAppConfig.filterType; if (smFilterType EQ "excluded") filterField = "twitterIncludedList"; else filterField = "twitterExcludedList"; //writeoutput("StructKeyExists(filteredPostData.values,#filterField#) - " & StructKeyExists(filteredPostData.values,filterField)); if ( StructKeyExists(filteredPostData,"values") AND StructKeyExists(filteredPostData.values,filterField) ) { smPostFilterList = filteredPostData.values[filterField]; //application.ptSocialMedia.utils.doDump(smPostFilterList, "smPostFilterList - buildTwitterFeedCache", 0); } // Build Twitter Feed Data feedArray = variables.twitterFeedsService.buildTwitterFeedData(smFeedID,smfeedCriteria,smFeedType,smRenderLimit,smPostFilterList,arguments.showFeedDump,smFilterType); //application.ptSocialMedia.utils.doDump(feedArray,"feedArray",0); // Add the Feed Array to the final smFeedData struct with the smFeedID as the struct Key if ( ArrayLen(feedArray) ) smFeedData[smFeedID] = feedArray; else { // If a Feed Array is NOT built check the CACHE to see if an Array exists for this smFeedID // - application.ptSocialMediaCache check are done in the Cache DAO functions feedArray = variables.socialMediaCacheDAO.getTwitterFeedData(feedID=smFeedID); // Still only the feed struct if a data array has a length if ( ArrayLen(feedArray) ) smFeedData[smFeedID] = feedArray; } } //application.ptSocialMedia.utils.doDump(smFeedData,"smFeedData",0); // set cache for the service feeds retStruct.status = variables.socialMediaCacheDAO.updateServiceFeedDataCache(serviceType=smServiceType,serviceFeedData=smFeedData,cacheVarName=arguments.cacheVarName); return retStruct; var retStruct = StructNew(); var smFeedData = StructNew(); var feedArray = ArrayNew(1); var smServiceType = "wordpress"; var smItm=1; var smFeedID = ""; var smfeedCriteria = ""; var smPostExcludeList = ""; var smfeedImage = ""; var smfeedImageData = Structnew(); var smMaxWords = 50; // TODO: Blog Post max words... add this to the config element or the wordpress blog element var smRenderLimit = getMaxCachedPostsPerService(); // Get the Active WordPress Blogs from the element var smSelectedItems = variables.wordPressBlogsDAO.getWordPressBlogsActive(); //application.ptSocialMedia.utils.doDump(smSelectedItems,"smSelectedItems",0); // Loop over the items and build a feed array for each for ( smItm=1; smItm LTE ArrayLen(smSelectedItems); smItm=smItm+1 ) { smFeedID = smSelectedItems[smItm].values.uniqueID; // Social media Page or Account to get smfeedCriteria = smSelectedItems[smItm].values.blogLink; smfeedImage = ""; smPostExcludeList = ""; // Get the PostIDs of excluded posts if ( StructKeyExists(smSelectedItems[smItm].values,"postExcludeList") ) smPostExcludeList = smSelectedItems[smItm].values.postExcludeList; // CP Image Data Exists Get Image URL if ( StructKeyExists(smSelectedItems[smItm].values,"blogImage") AND ListFirst(smSelectedItems[smItm].values.blogImage,":") EQ "CPIMAGE" ) { smfeedImageData = Application.ptSocialMedia.csData.decipherCPIMAGE(smSelectedItems[smItm].values.blogImage); if ( StructKeyExists(smfeedImageData,"ResolvedURL") AND StructKeyExists(smfeedImageData.ResolvedURL,"ServerRelative") AND LEN(TRIM(smfeedImageData.ResolvedURL.ServerRelative)) ) smfeedImage = smfeedImageData.ResolvedURL.ServerRelative; } // Build WordPress Feed Data feedArray = variables.wordPressFeedsService.buildWordPressFeedData(smFeedID,smfeedCriteria,smRenderLimit,smMaxWords,smfeedImage,smPostExcludeList,arguments.showFeedDump); //application.ptSocialMedia.utils.doDump(feedArray,"feedArray",0); // Add the Feed Array to the final smFeedData struct with the smFeedID as the struct Key if ( ArrayLen(feedArray) ) smFeedData[smFeedID] = feedArray; else { // If a Feed Array is NOT built check the CACHE to see if an Array exists for this smFeedID // - application.ptSocialMediaCache check are done in the Cache DAO functions feedArray = variables.socialMediaCacheDAO.getFacebookFeedData(feedID=smFeedID); // Still only the feed struct if a data array has a length if ( ArrayLen(feedArray) ) smFeedData[smFeedID] = feedArray; } } //application.ptSocialMedia.utils.doDump(smFeedData,"smFeedData",0); // set cache for the service feeds retStruct.status = variables.socialMediaCacheDAO.updateServiceFeedDataCache(serviceType=smServiceType,serviceFeedData=smFeedData,cacheVarName=arguments.cacheVarName); return retStruct; var retStruct = StructNew(); var smFeedData = StructNew(); var feedArray = ArrayNew(1); var smServiceType = "youtube"; var smItm=1; var smFeedID = ""; var smfeedCriteria = ""; var smPostExcludeList = ""; var smAppConfig = getAppConfig(); var smRenderLimit = getMaxCachedPostsPerService(); // Get the Active YouTube Channels from the element var smSelectedItems = variables.youTubeChannelsDAO.getYouTubeChannelsActive(); //application.ptSocialMedia.utils.doDump(smSelectedItems,"smSelectedItems",0); var smPostFilterList = ""; var smFilterType = ""; var filterField = ""; var filteredPostData = {}; // Loop over the items and build a feed array for each for ( smItm=1; smItm LTE ArrayLen(smSelectedItems); smItm=smItm+1 ) { smFeedID = smSelectedItems[smItm].values.uniqueID; // Social media Page or Account to get smfeedCriteria = smSelectedItems[smItm].values.channelUsername; smPostExcludeList = ""; // Get the PostIDs of excluded posts if ( StructKeyExists(smSelectedItems[smItm].values,"postExcludeList") ) smPostExcludeList = smSelectedItems[smItm].values.postExcludeList; // Build YouTube Feed Data feedArray = variables.youTubeFeedsService.buildYouTubeFeedData(smFeedID,smfeedCriteria,smRenderLimit,smPostExcludeList,arguments.showFeedDump); //application.ptSocialMedia.utils.doDump(feedArray,"feedArray",0); // Get the PostIDs of filtered posts filteredPostData = application.ptsocialmedia.socialMediaCacheDAO.getFilteredPostData(); //application.ptSocialMedia.utils.doDump(filteredPostData,"filteredPostData - buildTwitterFeedCache",0); smFilterType = smAppConfig.filterType; if ( smFilterType EQ "excluded" ) filterField = "youtubeIncludedList"; else filterField = "youtubeExcludedList"; if ( StructKeyExists(filteredPostData,"values") AND StructKeyExists(filteredPostData.values,filterField) ) { smPostFilterList = filteredPostData.values[filterField]; //application.ptSocialMedia.utils.doDump(smPostFilterList, "smPostFilterList - buildTwitterFeedCache", 0); } // Add the Feed Array to the final smFeedData struct with the smFeedID as the struct Key if ( ArrayLen(feedArray) ) smFeedData[smFeedID] = feedArray; else { // If a Feed Array is NOT built check the CACHE to see if an Array exists for this smFeedID // - application.ptSocialMediaCache check are done in the Cache DAO functions feedArray = variables.socialMediaCacheDAO.getFacebookFeedData(feedID=smFeedID); // Still only the feed struct if a data array has a length if ( ArrayLen(feedArray) ) smFeedData[smFeedID] = feedArray; } } //application.ptSocialMedia.utils.doDump(smFeedData,"smFeedData",0); // set cache for the service feeds retStruct.status = variables.socialMediaCacheDAO.updateServiceFeedDataCache(serviceType=smServiceType,serviceFeedData=smFeedData,cacheVarName=arguments.cacheVarName); return retStruct; var varName = variables.cacheVarName; var tempVarName = variables.tempCacheVarName; // Delete FEED Cache Data variables.socialMediaCacheDAO.deleteFeedCache(cacheVarName=varName); // delete the TEMP FEED Cache Data variables.socialMediaCacheDAO.deleteFeedCache(cacheVarName=tempVarName); // Delete rebuild Cache Data Scheduled Task variables.socialMediaScheduledTasksDAO.deleteCacheRebuildScheduledTask(); return true; // Initialize the variables var retHTML = ""; var feedCacheState = getFeedCacheState(); var CSRF_Token = application.ADF.csSecurity.getCSRF_Token(); application.ptSocialMedia.scripts.loadJQuery(noconflict=1); application.ptSocialMedia.scripts.loadADFLightbox(); application.ADF.scripts.addFooterJS(createCacheRebuildScheduledTaskFooterJS,"TERTIARY");
Creating Scheduled Task... Service Feed Cache is NOT enabled!
Scheduled Task can NOT be created.
// Initialize the variables var retHTML = ""; var feedCacheState = getFeedCacheState(); var CSRF_Token = application.ADF.csSecurity.getCSRF_Token(); application.ptSocialMedia.scripts.loadJQuery(noconflict=1); application.ptSocialMedia.scripts.loadADFLightbox(); application.ADF.scripts.addFooterJS(reBuildSocialMediaCacheFooterJS,"TERTIARY");
Rebuilding Feed Cache...
Please Wait! The cache rebuild may take a few minutes.
Service Feed Cache is NOT enabled!
Feed Cache can not be built.
// Initialize the variables var retHTML = ""; var feedCacheState = getFeedCacheState(); var varName = variables.cacheVarName; application.ptSocialMedia.scripts.loadJQuery(noconflict=1); application.ptSocialMedia.scripts.loadADFLightbox(); //ptSocialMediaCache Variable Dump if ( feedCacheState AND StructKeyExists(application,varName) ) application.ptSocialMedia.utils.doDump(application[varName],"Social Media Feed Cache",0); else WriteOutput("
Social Media Feed Cache is not Available
");