variables.componentName = "catalogPageDAO";
var contentData = StructNew();
var contentArray = ArrayNew(1);
var elementIDfield = "uniqueID";
// Return the data based on the Type of content that is requested
switch(arguments.contentType)
{
case "school":
contentArray = variables.schoolDAO.getSchools(idFieldName=elementIDfield,uniqueID=arguments.contentID);
break;
case "department":
contentArray = variables.departmentDAO.getDepartments(idFieldName=elementIDfield,uniqueID=arguments.contentID);
break;
case "program":
contentArray = variables.programDAO.getPrograms(idFieldName=elementIDfield,uniqueID=arguments.contentID);
break;
case "course":
contentArray = variables.courseDAO.getCourses(idFieldName=elementIDfield,uniqueID=arguments.contentID);
break;
case "term":
// Added for Term Bindings
contentArray = variables.termDAO.getTerms(idFieldName=elementIDfield,uniqueID=arguments.contentID);
break;
case "CatalogYear":
// Added for CatalogYear Bindings
contentArray = variables.catalogYearDAO.getCatalogYears(idFieldName=elementIDfield,uniqueID=arguments.contentID);
break;
default:
// WriteOutput("No Type was passed in.");
}
if ( ArrayLen(contentArray) AND StructKeyExists(contentArray[1],"values") ) {
contentData = contentArray[1].values;
contentData["datapageid"] = contentArray[1].pageID;
//contentData["dataformname"] = contentArray[1].formname;
}
return contentData;
var bindReturnValue = ""; // Set as no value to start
var bindReturnData = getBoundCatalogData(contentData=arguments.contentData,bindIDFieldName=arguments.bindIDFieldName,bindContentType=arguments.bindContentType);
// Check if we have a a value in the binding Value Field
if ( NOT StructIsEmpty(bindReturnData) AND StructKeyExists(bindReturnData,arguments.bindValueFieldName) AND LEN(TRIM(bindReturnData[arguments.bindValueFieldName])) )
bindReturnValue = bindReturnData[arguments.bindValueFieldName];
return bindReturnValue;
var bindContentID = ""; // Set as no value to start
var bindReturnData = StructNew(); // Set the stuct to be empty to start
// Check if we have a bind ID value stored in the content
if ( NOT StructIsEmpty(arguments.contentData) AND StructKeyExists(arguments.contentData,arguments.bindIDFieldName) AND LEN(TRIM(arguments.contentData[arguments.bindIDFieldName])) )
bindContentID = arguments.contentData[arguments.bindIDFieldName];
// If we have a bindContentID go get the bind record
if ( LEN(TRIM(bindContentID)) )
bindReturnData = getPageContentData(contentType=arguments.bindContentType,contentID=bindContentID);
return bindReturnData;
var result = structNew();
var pageData = StructNew();
var pageCreationResults = StructNew();
if( not structKeyExists(arguments, "custMetadata") or (structKeyExists(arguments, "custMetadata") and not listLen(structKeyList(arguments.custMetadata)) ) )
arguments.custMetadata = structNew();
// Setup the pageData struct
pageData = arguments.stdMetadata;
// Verify that we create a page with a unique page name and page title.
pageData['name'] = application.ptCourseCatalog.csData.createUniquePageName(csPageName=pageData.name,
csSubsiteID=pageData.subsiteID);
pageData['title'] = application.ptCourseCatalog.csData.createUniquePageTitle(csPageTitle=pageData.title,
csSubsiteID=pageData.subsiteID);
// Convert the metadata structure to an array of MetadataValue structures for the API
pageData['metadata'] = application.ptCourseCatalog.csData.metadataStructToArray(metadata=custMetadata);
// Create the page with the CCAPI - disabled... use CSAPI
pageCreationResults = application.ptCourseCatalog.csPage.createPage(stdMetadata=pageData,
custMetadata=custMetadata,
activatePage=true);
if ( StructKeyExists(pageCreationResults,"pageCreated") AND pageCreationResults.pageCreated EQ true )
{
result.newPageID = pageCreationResults.newPageID;
//application.ptCourseCatalog.utils.logAppend(pageCreationResults,"ptCourseCatalog_createCatalogPage.html");
//doErrorLogging(variables.componentName,"createCatalogPage",pageCreationResults,"CCAPI Catalog Page Create was a Success!");
}
else
{
result.newPageID = 0;
//application.ptCourseCatalog.utils.logAppend(pageCreationResults,"ptCourseCatalog_createCatalogPage.html");
doErrorLogging(variables.componentName,"createCatalogPage",pageCreationResults,"CCAPI Catalog Page Create Failed!");
}
/*
Issues with the CSAPI Page Create:
1) When auto-creating multiple level subsites (school/department)… the department page does not alwayscreated
// Create the page with the CSAPI
pageCreationResults = application.ptCourseCatalog.apiPage.create(pageData=pageData,
activatePage=true);
//application.ptCourseCatalog.utils.logAppend(pageCreationResults,"ptCourseCatalog_createCatalogPage.html");
if ( StructKeyExists(pageCreationResults, "CMDSTATUS") AND pageCreationResults.CMDSTATUS EQ true AND StructKeyExists(pageCreationResults, "CMDRESULTS") )
{
result.newPageID = pageCreationResults.CMDRESULTS;
//application.ptCourseCatalog.utils.logAppend(pageCreationResults,"ptCourseCatalog_createCatalogPage.html");
//doErrorLogging(variables.componentName,"createCatalogPage",pageCreationResults,"CSAPI Catalog Page Create was a Success!");
}
else
{
result.newPageID = 0;
//application.ptCourseCatalog.utils.logAppend(pageCreationResults,"ptCourseCatalog_createCatalogPage.html");
doErrorLogging(variables.componentName,"createCatalogPage",pageCreationResults,"CSAPI Catalog Page Create Failed!");
}
*/
return result;
var pageUpdateResults = StructNew();
var pageRenameResults = StructNew();
var pageInfoUpdateResults = StructNew();
var pageKeywordsUpdateResults = StructNew();
// Rename the page
pageRenameResults = handlePageRename(
csPageID=arguments.csPageID
,pageName=arguments.fileName
);
//application.ADF.utils.dodump(pageRenameResults,"pageRenameResults",0);
// Update the standard metadata for the page
pageInfoUpdateResults = handlePageInfoUpdate(
csPageID=arguments.csPageID
,pageName=arguments.pageName
,pageTitle=arguments.pageTitle
,pageDesc=arguments.pageDesc
,pubDatesc=arguments.pubDate
);
//application.ADF.utils.dodump(pageInfoUpdateResults,"pageInfoUpdateResults",0);
// Update the Keywords for the page
if ( LEN(TRIM(arguments.pageKeywords)) ) {
pageKeywordsUpdateResults = handleKeywordUpdate(
csPageID=arguments.csPageID
,keywordList=arguments.pageKeywords
);
//application.ADF.utils.dodump(pageKeywordsUpdateResults,"pageKeywordsUpdateResults",0); );
}
pageUpdateResults["rename"] = pageRenameResults;
pageUpdateResults["update"] = pageInfoUpdateResults;
pageUpdateResults["keywords"] = pageKeywordsUpdateResults;
// Invalidate the page cache for issue in CS 6.2.1 with the page cache
pageUpdateResults["invalidateCache"] = invalidatePageCache(arguments.csPageID);
return pageUpdateResults;
var newPageInfo = StructNew();
var pageInfo = StructNew();
var pageInfoUpdateResults = StructNew();
var updatePageResults = StructNew();
// Get Data from the current page
pageInfo = application.ptCourseCatalog.apiPage.getInfo(csPageID=arguments.csPageID);
//application.ADF.utils.dodump(pageInfo,"pageInfo",0);
// Make sure the page returns INFO before attempting to update it with new standard metadata
if ( pageInfo.CMDSTATUS ) {
// build page info update struct
newPageInfo.id = arguments.csPageID;
newPageInfo.title = arguments.pageTitle;
newPageInfo.caption = arguments.pageTitle;
newPageInfo.publicationDate = arguments.pubDate;
newPageInfo.description = arguments.pageDesc;
// Use the categoryID from the existing PageInfo
if ( StructKeyExists(pageInfo,"categoryid") )
newPageInfo.categoryID = pageInfo.categoryid;
else
newPageInfo.categoryID = 1;
// Update the standard metadata/properties for the page
pageInfoUpdateResults = application.ptCourseCatalog.apiPage.saveInfo(pageData=newPageInfo);
//application.ADF.utils.dodump(pageInfoUpdateResults,"pageInfoUpdateResults",0);
}
if ( StructKeyExists(pageInfoUpdateResults, "CMDSTATUS") AND pageInfoUpdateResults.CMDSTATUS ) {
updatePageResults["PAGEUPDATED"] = true;
updatePageResults["MSG"] = "Success: Page was succesfully updated!";
}
else {
updatePageResults["PAGEUPDATED"] = false;
updatePageResults["MSG"] = "Fail: Page was not updated!";
// Log Page Info Update Failure
doErrorLogging("cmdapi-page-setInfo","handlePageUpdate",pageInfoUpdateResults);
}
return updatePageResults;
var newPageNameData = StructNew();
var pageRenameResults = ArrayNew(1);
var updatePageResults = StructNew();
// build rename struct
newPageNameData.id = arguments.csPageID;
newPageNameData.name = arguments.pageName;
// Rename the page
pageRenameResults = application.ptCourseCatalog.apiPage.rename(pageData=newPageNameData);
//application.ADF.utils.dodump(pageRenameResults,"pageRenameResults",0);
// Create a Stucture with the Rename process results
if ( pageRenameResults.CMDSTATUS ) {
updatePageResults["PAGERENAMED"] = true;
updatePageResults["MSG"] = "Success: Page was succesfully renamed!";
}
else {
updatePageResults["PAGERENAMED"] = false;
updatePageResults["MSG"] = "Fail: Page was not renamed!";
// Log Page Rename Failure
doErrorLogging("cmdapi-page-rename","handlePageRename",pageRenameResults);
}
return updatePageResults;
var updatePageResults = application.ptCourseCatalog.apiKeywords.setForObject(csPageID=arguments.csPageID,keywordList=arguments.keywordList);
updatePageResults["KEYWORDSUPDATED"] = updatePageResults.CMDSTATUS;
updatePageResults["KEYWORDS"] = arguments.keywordList;
updatePageResults["PAGEID"] = arguments.csPageID;
// Set the status message based on the result
if ( updatePageResults.CMDSTATUS ) {
updatePageResults["MSG"] = "Success: Keywords were updated for the page.";
}
// Do error logging if update failed
else {
updatePageResults["MSG"] = "Fail: There was an error updating the keywords for the page.";
updatePageResults["KEYWORDS"] = updatePageResults;
// Log Page Keyword Update Failure
doErrorLogging("cmdapi-keyword-update","handleKeywordUpdate",updatePageResults);
}
return updatePageResults;
var pageResult = StructNew();
// Use the CS 6.x Command API to SET page keywords
var pageComponent = Server.CommonSpot.api.getObject('Page');
var pageCmdResults = "";
try {
pageComponent.invalidateCache(pageID=arguments.csPageID);
pageResult["CMDSTATUS"] = true;
pageResult["CMDRESULTS"] = true;
}
catch (any e) {
pageResult["CMDSTATUS"] = false;
pageResult["CMDRESULTS"] = false;
}
return pageResult;
var deletePageResult = StructNew();
var csPageURL = application.ptCourseCatalog.csData.getCSPageURL(arguments.csPageID);
if ( LEN(TRIM(csPageURL)) ) {
deletePageResult = application.ADF.apiPage.delete(csPageID=arguments.csPageID);
if ( StructKeyExists(deletePageResult,"CMDSTATUS") AND deletePageResult["CMDSTATUS"] EQ true ) {
deletePageResult["PAGEDELETED"] = true;
deletePageResult["MSG"] = "Success: The Page was successfully deleted.";
}
else {
deletePageResult["PAGEDELETED"] = false;
deletePageResult["MSG"] = "Fail: The page cound not be deleted.";
// Log Page Delete Failure
doErrorLogging("cmdapi-page-delete","handlePageDelete",deletePageResult);
}
}
else {
deletePageResult["PAGEDELETED"] = false;
deletePageResult["MSG"] = "Fail: The page id provided did not return a valid commonspot page.";
// Log Page Delete Failure
doErrorLogging("cmdapi-page-delete","handlePageDelete",deletePageResult);
}
return deletePageResult;
var retValue = "";
switch(arguments.contentType) {
case "department":
retValue = variables.departmentDAO.departmentCCAPI(dataValues=arguments.contentData);
//retValue = variables.departmentDAO.handleUpdateDepartmentRecord(contentData=arguments.contentData);
break;
case "program":
retValue = variables.programDAO.programCCAPI(dataValues=arguments.contentData);
// retValue = variables.programDAO.handleUpdateProgramRecord(contentData=arguments.contentData);
break;
case "course":
retValue = variables.courseDAO.courseCCAPI(dataValues=arguments.contentData);
//retValue = variables.courseDAO.handleUpdateCourseRecord(contentData=arguments.contentData);
break;
}
return retValue;