public function __construct(Cascade $cascade) { $this->cascade = $cascade; $this->clearResults(); $this->cache = u\Cache::getInstance($cascade->getService()); $this->cache->clearCache(); }
public static function setMetadataSet(Cascade $target_cascade, Site $source_site, Site $target_site, Asset $source_asset, Asset $target_asset, $exception_thrown = true) { // get metadata set $source_ms = $source_asset->getMetadataSet(); $source_ms_path = u\StringUtility::removeSiteNameFromPath($source_ms->getPath()); $source_ms_site = $source_ms->getSiteName(); $target_ms_site = $source_ms_site; if ($exception_thrown) { try { $ms = $target_cascade->getAsset(MetadataSet::TYPE, $source_ms_path, $target_ms_site); $target_asset->setMetadataSet($ms); } catch (\Exception $e) { $msg = "The metadata set {$source_ms_path} does not exist in {$target_ms_site}. "; throw new e\CascadeInstancesErrorException(S_SPAN . $msg . E_SPAN . $e); } } else { $ms = $target_cascade->getMetadataSet($source_ms_path, $target_ms_site); if (isset($ms)) { $target_asset->setMetadataSet($ms); } } // set metadata if (isset($ms)) { try { $m = $source_asset->getMetadata(); $target_asset->setMetadata($m); $source_metadata = $source_asset->getMetadata(); $target_metadata = $target_asset->getMetadata(); $target_metadata->setAuthor($source_metadata->getAuthor())->setDisplayName($source_metadata->getDisplayName())->setEndDate($source_metadata->getEndDate())->setKeywords($source_metadata->getKeywords())->setMetaDescription($source_metadata->getMetaDescription())->setReviewDate($source_metadata->getReviewDate())->setStartDate($source_metadata->getStartDate())->setSummary($source_metadata->getSummary())->setTeaser($source_metadata->getTeaser())->setTitle($source_metadata->getTitle()); $fields = $source_metadata->getDynamicFieldNames(); $count = count($fields); if ($count > 0) { foreach ($fields as $field) { $target_metadata->setDynamicField($field, $source_metadata->getDynamicFieldValues($field)); } } $target_asset->edit(); } catch (\Exception $e) { throw new e\CascadeInstancesErrorException($e . BR . S_SPAN . "Path: " . $source_asset->getPath() . E_SPAN); } } }
public function republishFailedJobs(Cascade $cascade, Destination $destination) { echo $this->type . BR; echo $this->num_jobs_with_errors . BR; if ($this->type == self::TYPE_PUBLISH && $this->num_jobs_with_errors > 0) { foreach ($this->msg_errors as $error) { try { list($destination, $site, $path) = u\StringUtility::getExplodedStringArray("\t", $error); //$destination = trim( $destination, "[]" ); $site = trim($site, ":"); // ignore destinations if ($site != "" && $path != "") { $cascade->getAsset(Page::TYPE, $path, $site)->publish($destination); } } catch (\Exception $e) { echo "Failed to republish failed job" . BR; echo S_PRE . $e . E_PRE; continue; } } } return $this; }
function createDestinationForSites(a\Cascade $cascade, $site_name, $group_name = '') { // normally site and group are assigned the same name if ($group_name == '') { $group_name = $site_name; } $web_transport = $cascade->getAsset(a\FtpTransport::TYPE, '57abc6cd8b7f0856006702a06dafeb80'); $www_transport = $cascade->getAsset(a\FtpTransport::TYPE, '6e0d1f298b7f0856015997e48a8179fc'); $destination_parent = $cascade->getAsset(a\SiteDestinationContainer::TYPE, '/', $site_name); $group = $cascade->getAsset(a\Group::TYPE, $group_name); $cwt = $cascade->getAsset(a\Group::TYPE, "CWT-Designers"); $web_destination = $cascade->getDestination(a\Destination::TYPE, $site_name . '-web', $site_name); if ($web_destination == NULL) { // create destination $destination = $cascade->createDestination($destination_parent, $site_name . '-web', $web_transport)->setDirectory($site_name)->setWebUrl("http://web.upstate.edu/" . $site_name)->setCheckedByDefault(true)->enable()->addGroup($group)->addGroup($cwt)->edit(); } $www_destination = $cascade->getDestination(a\Destination::TYPE, $site_name . '-www', $site_name); if ($www_destination == NULL) { // create destination $destination = $cascade->createDestination($destination_parent, $site_name . '-www', $www_transport)->setDirectory($site_name)->setWebUrl("http://www.upstate.edu/" . $site_name)->disable()->addGroup($group)->addGroup($cwt)->edit(); } }