var syncMapData = ArrayNew(1);
// Make the CEData calls based on the arguments passed in
if ( arguments.sourceCEFormID GT 0 ) {
syncMapData = application.ptSync.ceData.getCEData(
customElementName="Sync Mapping",
searchFields="sourceCE,isActive",
searchValues="#arguments.sourceCEFormID#,1",
queryType="multi");
}
else if ( arguments.destCEFormID GT 0 ) {
syncMapData = application.ptSync.ceData.getCEData(
customElementName="Sync Mapping",
searchFields="destCE,isActive",
searchValues="#arguments.destCEFormID#,1",
queryType="multi");
}
else if ( LEN(arguments.mappingID) ){
syncMapData = application.ptSync.ceData.getCEData(
customElementName="Sync Mapping",
searchFields="ID,isActive",
searchValues="#arguments.mappingID#,1",
queryType="multi");
}
else {
syncMapData = application.ptSync.ceData.getCEData(customElementName="Sync Mapping",
searchFields="isActive",
searchValues="1",
queryType="search");
}
return syncMapData;
var retCEData = ArrayNew(1);
var ceName = "";
// Get the sync mapping data for the source form ID
//var syncMapDataArray = application.ptSync.syncDAO.getSyncMapping(sourceCEFormID=arguments.formID);
// Check if the data is valid and active
ceName = application.ptSync.ceData.getCENameByFormID(arguments.formID);
retCEData = application.ptSync.ceData.getCEData(
customElementName=ceName,
customElementFieldName=uuidFieldName,
item=uuidValue);
return retCEData;
// Get the Custom Element Name
var ceName = application.ptSync.ceData.getCENameByFormID(arguments.formID);
// Replace any spaces with underscores
ceName = Replace(ceName, " ", "_", "all");
// Replace any special characters
ceName = REReplaceNoCase(ceName,"[^a-z,0-9,_]","","ALL");
// Set the CCAPI site URL
application.ptSync.ccapi.setSiteURL(application.ptSync.cache.siteData.dest.rooturl);
//application.ADF.utils.dodump(application.ptSync.ccapi.getSiteURL(),"application.ptSync.ccapi.getSiteURL()", false);
// Update the element record on the destination site
return populateContent(elementName=ceName, data=arguments.dataStruct, siteType="destination");
var elements = "";
var thisElement = structNew();
var result = structNew();
var contentStruct = structNew();
var contentUpdateResponse = "";
var msg = "";
var logFile = "";
var error = "";
var ws = "";
var logStruct = structNew();
var logArray = arrayNew(1);
// construct the CCAPI object
application.ptSync.ccapi.initCCAPI(arguments.siteType);
elements = application.ptSync.ccapi.getElements();
ws = application.ptSync.ccapi.getWS();
result.contentUpdated = false;
// get the settings for this element
if ( isStruct(elements) and structKeyExists(elements, arguments.elementName) )
{
// set up local variable for the element
thisElement = elements[arguments.elementName];
// if there is no subsite default to 1
if( not structKeyExists(thisElement, "subsiteID") )
thisElement["subsiteID"] = 1;
//2010-12-09 - RAK - If they forced the pageID set it
if(arguments.forceSubsiteID neq -1){
thisElement["subsiteID"] = arguments.forceSubsiteID;
}else if( structKeyExists(arguments.data, "subsiteID")){
//Otherwise check to see if subsiteID has been passed into data (signifying a local custom element)
thisElement["subsiteID"] = arguments.data.subsiteID;
}
// assume global custom element and use default subsiteID
// login for the first time or to the subsite where the new page was created
if( application.ptSync.ccapi.loggedIn() eq 'false' or ( thisElement["subsiteID"] neq application.ptSync.ccapi.getSubsiteID() ) )
application.ptSync.ccapi.login(thisElement["subsiteID"]);
//2010-12-09 - RAK - If they forced the pageID set it
if(arguments.forcePageID neq -1){
thisElement["pageID"] = arguments.forcePageID;
}else if( structKeyExists(arguments.data, "pageID") ){
//Otherwise check to see if the data passed in for this element contains "pageID"
thisElement["pageID"] = arguments.data.pageID;
}
// clear locks before starting
application.ptSync.ccapi.clearLock(thisElement["pageID"]);
// construct specific data for the content creation API
contentStruct.pageID = thisElement["pageID"];
if( structKeyExists(thisElement, "controlID") )
contentStruct.controlID = thisElement["controlID"];
else
contentStruct.controlName = thisElement["controlName"];
// if we find the option to submit change in the data
if( structKeyExists(arguments.data, "submitChange") )
contentStruct.submitChange = arguments.data.submitChange;
else
contentStruct.submitChange = "1";
// if we find the comment for the submission in the data struct
if( structKeyExists(arguments.data, "submitChangeComment") )
contentStruct.submitChange_comment = arguments.data.submitChangeComment;
else
contentStruct.submitChange_comment = "Submit data for Custom element through API";
// Following structure contains the data. The structure keys are the 'field names'
contentStruct.data = arguments.data;
// Call CCAPI to add/update textblock
if( thisElement["elementType"] eq "textblock")
{
// update textblock
contentUpdateResponse = ws.populateTextblock(ssid=application.ptSync.ccapi.getSSID(), sParams=contentStruct);
}
if( thisElement["elementType"] eq "custom" )
{
// update custom element
contentUpdateResponse = ws.populateCustomElement(ssid=application.ptSync.ccapi.getSSID(), sParams=contentStruct);
// check to see if update wasn't successful
if( listFirst(contentUpdateResponse, ":") neq "Success" )
{
// clear locks after completing update
application.ptSync.ccapi.clearLock(thisElement["pageID"]);
// If update wasn't successful then login again to the default subsite specified in the config xml file
if( thisElement["subsiteID"] neq application.ptSync.ccapi.getSubsiteID() )
{
application.ptSync.ccapi.login(thisElement["subsiteID"]);
// TODO: do we need this logging?
//logStruct.msg = "#request.formattedTimestamp# - Relogging into #thisElement['subsiteID']#";
//logStruct.logFile = 'populate_content.log';
//arrayAppend(logArray, logStruct);
}
else
application.ptSync.ccapi.login();
// Now try it again after logging in
contentUpdateResponse = ws.populateCustomElement(ssid=application.ptSync.ccapi.getSSID(), sParams=contentStruct);
// TODO: do we need this logging?
//logStruct.msg = "#request.formattedTimestamp# - 2ND ATTEMPT: contentUpdateResponse: #contentUpdateResponse#";
//logStruct.logFile = 'populate_content.log';
//arrayAppend(logArray, logStruct);
}
}
// TODO handle debugging for texblock update call
if( listFirst(contentUpdateResponse, ":") eq "Success" )
{
result.contentUpdated = true;
result.msg = contentUpdateResponse;
logStruct.msg = "#request.formattedTimestamp# - Elemented Updated/Created: #thisElement['elementType']# [#arguments.elementName#]. ContentUpdateResponse: #contentUpdateResponse#";
logStruct.logFile = 'CCAPI_populate_content.log';
arrayAppend(logArray, logStruct);
}
else
{
result.msg = contentUpdateResponse;
// comma separated for parsing
// 'date','pageID','contentID','subsiteID','title','error'
error = listRest(contentUpdateResponse, ":");
logStruct.msg = "#request.formattedTimestamp# - Error updating element: #thisElement['elementType']# [#arguments.elementName#]. Error recorded: #error#";
logStruct.logFile = 'CCAPI_populate_content_error.log';
arrayAppend(logArray, logStruct);
}
// clear locks after completing update
application.ptSync.ccapi.clearLock(thisElement["pageID"]);
}
else // logging for the element name not existing
{
result.msg = "Element name does not exist in configuration: #arguments.elementName#";
logStruct.msg = "#request.formattedTimestamp# - Element name does not exist in configuration: #arguments.elementName#";
logStruct.logFile = "CCAPI_populate_content_error.log";
arrayAppend(logArray, logStruct);
}
if( application.ptSync.ccapi.loggingEnabled() and arrayLen(logArray) )
application.ptSync.utils.bulkLogAppend(logArray);
application.ptSync.ccapi.logout();
// construct the CCAPI object
application.ptSync.ccapi.initCCAPI("destination");
application.ptSync.ccapi.login();
application.ptSync.ccapi.logout();
var dataValueQry = "";
SELECT PageID
FROM Data_FieldValue
WHERE VersionState <= 2
AND Action = 2
AND formID =
AND pageID =
AND controlID =
if ( dataValueQry.RecordCount )
return true;
else
return false;
// construct the CCAPI object
application.ptSync.ccapi.initCCAPI(arguments.siteType);
elements = application.ptSync.ccapi.getElements();
ws = application.ptSync.ccapi.getWS();
result.uploadCompleted = false;
if( application.ptSync.ccapi.loggedIn() EQ 'false' or arguments.doLogin gt 0 ) // login to the subsite where the new subsite will be created
{
if( arguments.subsiteid neq 0 )
application.ptSync.ccapi.login(arguments.subsiteid);
else
application.ptSync.ccapi.login();
}
// create the subsite
uploadResponse = ws.uploadImage(ssid=application.ptSync.ccapi.getSSID(), sparams=arguments.data, image=toBase64(arguments.imgBinaryData));
// check to see if update wasn't successful
if( listFirst(uploadResponse, ":") neq "Success" )
{
// check to see if there was an error logging in
if( findNoCase(listRest(uploadResponse, ":"), "login") and not arguments.doLogin )
{
// resend this through the login
uploadImage(arguments.subsiteid, arguments.data,arguments.imgBinaryData, 1);
}
logStruct.msg = "#request.formattedTimestamp# - Error upload image: #arguments.data.localfilename# - #listRest(uploadResponse, ':')#";
logStruct.logFile = 'CCAPI_upload_image.log';
arrayAppend(logArray, logStruct);
}
else {
result.uploadCompleted = "true";
logStruct.msg = "#request.formattedTimestamp# - Upload Image Success: #arguments.data.localfilename# - #uploadResponse#";
logStruct.logFile = 'CCAPI_upload_image.log';
arrayAppend(logArray, logStruct);
}
result.uploadResponse = uploadResponse;
// Logout
application.ptSync.ccapi.logoutResult = application.ptSync.ccapi.logout();
// handle logging
// TODO: plug the logging option into the CCAPI config settings
if( application.ptSync.ccapi.loggingEnabled() and arrayLen(logArray) )
application.ptSync.utils.bulkLogAppend(logArray);
--->