variables.componentName = "catalogPageController";
var processPageStatus = StructNew();
var processingAction = arguments.action;
var contentData = StructNew();
var buildNewPage = false;
var actionStatus = StructNew();
var allowPageDelete = true; // TODO: Allow Page Delete Option could be added to the config element (with an alternate doPageArchive option)
var csPageID = 0;
var rebuildPageStatus = StructNew();
//application.ADF.utils.dodump(arguments, "handleProcessCatalogPage - ARGS");
// 1) Check the Content Type to determine the task
// A) Department (a type:Department record has been Created or Updated)
// - Use the contentID to get the Department Data record.
// -- Check if there is a csPageID
// --- No csPageID or it is 0
// ----- Create a department page
// --------- From the the templateID stored in the record
// --------- In the the subsiteID stored in the record
// --------- Use the config option to determine the page name convention
// --------- Populate Custom Metadata with the Content ID
// ----- Update the Department Element with the new CS PAGE ID
// --- Yes we have a valid csPageID
// ---- Update the page
// ------- If the standard metadata or the config option has changed
// --------- Update the Dept Metadata: title, page name, etc. with the CSAPI
// B) Program (a type:Program record has been Created or Updated)
// - Use the contentID to get the Program Data record.
// -- Check if there is a csPageID
// --- No csPageID or it is 0
// ----- Create a Program page
// --------- From the the templateID stored in the record
// --------- In the the subsiteID stored in the department record
//** // ---------- Check if we are using the TERM Subsite (check config element)
// --------- Use the config option to determine the page name convention
// --------- Populate Custom Metadata with the Content ID
// ----- Update the Program Element with the new CS PAGE ID
// --- Yes we have a valid csPageID
// ---- Update the Program page
// ----- !!Not accounting for Department Subsite Change!!
// ------- If the standard metadata or the config option has changed
// --------- Update the Program Metadata: title, page name, etc. with the CSAPI
// C) Course (a type:Course record has been Created or Updated)
// - Use the contentID to get the Course Data record.
// -- Check if there is a csPageID
// --- No csPageID or it is 0
// ----- Create a course page
// --------- From the the templateID stored in the record
// --------- In the the subsiteID stored in the department record
//** // ---------- Check if we are using the TERM Subsite (check config element)
// --------- Use the config option to determine the page name convention
// --------- Populate Custom Metadata with the Content ID
// ----- Update the Course Element with the new CS PAGE ID
// --- Yes we have a valid csPageID
// ---- Update the course page
// ----- !!Not accounting for Department Subsite Change!!
// ------- If the standard metadata or the config option has changed
// --------- Update the Course Metadata: title, page name, etc. with the CSAPI
// Note: the processing action will need to be set after New or update is determined.
// -- a 'delete' would override that determination
contentData = variables.catalogPageDAO.getPageContentData(contentType=arguments.contentType,contentID=arguments.contentID);
// If this is not a "Delete" get the Action based on the csPageID in the record and the page existance
if ( processingAction NEQ "delete" )
{
processingAction = variables.catalogPageService.getPageActionFromContent(contentData=contentData);
//doErrorLogging(variables.componentName,"handleProcessCatalogPage",processingAction,"Log Processing Action!");
// If this is not a "Create" get csPageID in the record
if ( processingAction NEQ "create" )
csPageID = variables.catalogPageService.getCSPageIDFromContent(contentData=contentData);
if ( processingAction EQ "rebuild" )
{
// 1) Remove the current page
if ( IsNumeric(csPageID) AND csPageID GT 0 AND allowPageDelete )
{
// For rebuild delete the current page
rebuildPageStatus["delete-status"] = variables.catalogPageService.handleDeleteCatalogPage(contentType=arguments.contentType,csPageID=csPageID);
if ( StructKeyExists(rebuildPageStatus["delete-status"], "PAGEDELETED")
AND (rebuildPageStatus["delete-status"]["PAGEDELETED"] ) )
rebuildPageStatus["status"] = true;
else
rebuildPageStatus["status"] = false;
}
// 2) Reset the Rebuild Flag
if ( rebuildPageStatus.status )
{
// Reset the record values
contentData.catalogPageID = 0;
contentData.catalogPageRebuild = 0;
}
// 3) Set the processing action to "create" so a new page will be created
processingAction = "create";
}
else if ( processingAction EQ "update" )
{
//csPageID = variables.catalogPageService.getCSPageIDFromContent(contentData=contentData);
// Make the page ID is GREATER than 0
if ( IsNumeric(csPageID) AND csPageID GT 0 )
{
// Make sure the page is valid and exists
if ( NOT variables.catalogPageService.isCSPageIDaValidCSPage(csPageID=csPageID) )
processingAction = "create";
}
else
{
processingAction = "create";
}
}
}
else
{
// Get the CS Page ID to delete
csPageID = variables.catalogPageService.getCSPageIDFromContent(contentData=contentData);
}
switch(processingAction)
{
case "create":
//WriteOutput("Create!");
processPageStatus["create-status"] = variables.catalogPageService.handleCreateCatalogPage(contentType=arguments.contentType,contentID=arguments.contentID,contentData=contentData);
if ( StructKeyExists(processPageStatus["create-status"], "catalogPageID")
AND (processPageStatus["create-status"]["catalogPageID"] GT 0) )
processPageStatus["status"] = true;
else
processPageStatus["status"] = false;
break;
case "update":
//WriteOutput("Update!");
processPageStatus["create-status"] = variables.catalogPageService.handleUpdateCatalogPage(contentType=arguments.contentType,contentID=arguments.contentID,contentData=contentData,csPageID=csPageID);
if ( StructKeyExists(processPageStatus["create-status"], "catalogPageID")
AND (processPageStatus["create-status"]["catalogPageID"] GT 0) )
processPageStatus["status"] = true;
else
processPageStatus["status"] = false;
break;
case "delete":
//WriteOutput("Delete!");
if ( IsNumeric(csPageID) AND allowPageDelete )
processPageStatus["create-status"] = variables.catalogPageService.handleDeleteCatalogPage(contentType=arguments.contentType,csPageID=csPageID);
if ( StructKeyExists(processPageStatus["create-status"], "PAGEDELETED")
AND (processPageStatus["create-status"]["PAGEDELETED"] ) )
processPageStatus["status"] = true;
else
processPageStatus["status"] = false;
break;
}
// Append original request params to the return data
processPageStatus["type"] = arguments.contentType;
processPageStatus["data"] = contentData;
processPageStatus["uniqueID"] = arguments.contentID;
processPageStatus["csPageID"] = csPageID;
processPageStatus["action"] = processingAction;
return processPageStatus;
var contentType = "";
var processData = "";
// Get the content type from the Form ID
if ( arguments.formID EQ application.ptCourseCatalog.getDepartmentFormID() )
contentType = "department";
else if ( arguments.formID EQ application.ptCourseCatalog.getProgramFormID() )
contentType = "program";
else if ( arguments.formID EQ application.ptCourseCatalog.getCourseFormID() )
contentType = "course";
//application.ADF.utils.dodump(contentType, "contentType");
if ( LEN(contentType) )
{
// Call the main processing function
processData = handleProcessCatalogPage(contentType=contentType,
contentID=arguments.contentID);
// Check the return
if ( isStruct(processData) AND StructKeyExists(processData, "status")
AND isBoolean(processData.status) AND processData.status )
return processData.status;
}
// Error with the processing
return false;