public function setContentType(ContentType $c, $exception = true)
 {
     // nothing to do if already set
     if ($c->getId() == $this->getContentType()->getId()) {
         echo "Nothing to do" . BR;
         return $this;
     }
     // part 1: get the page level blocks and formats
     $block_format_array = $this->getPageLevelRegionBlockFormat();
     // just the default config, other config can be added
     $default_configuration = $this->getContentType()->getConfigurationSet()->getDefaultConfiguration();
     $default_configuration_name = $default_configuration->getName();
     $default_config_page_regions = $default_configuration->getPageRegions();
     $default_region_names = $default_configuration->getPageRegionNames();
     $page_level_config = $this->page_configuration_map[$default_configuration_name];
     $page_level_regions = $page_level_config->getPageRegions();
     $page_region_names = $page_level_config->getPageRegionNames();
     if (self::DEBUG && self::DUMP) {
         u\DebugUtility::dump($block_format_array);
     }
     // part 2: switch content type
     if ($c == NULL) {
         throw new e\NullAssetException(S_SPAN . c\M::NULL_ASSET . E_SPAN);
     }
     $page = $this->getProperty();
     $page->contentTypeId = $c->getId();
     $page->contentTypePath = $c->getPath();
     $configuration_array = array();
     $new_configurations = $c->getPageConfigurationSet()->getPageConfigurations();
     foreach ($new_configurations as $new_configuration) {
         $configuration_array[] = $new_configuration->toStdClass();
     }
     $page->pageConfigurations->pageConfiguration = $configuration_array;
     if (self::DEBUG && self::DUMP) {
         u\DebugUtility::dump($page->pageConfigurations);
     }
     $asset = new \stdClass();
     $asset->{$p = $this->getPropertyName()} = $page;
     // edit asset
     $service = $this->getService();
     $service->edit($asset);
     if (!$service->isSuccessful()) {
         throw new e\EditingFailureException(S_SPAN . c\M::EDIT_ASSET_FAILURE . E_SPAN . $service->getMessage());
     }
     if (self::DEBUG && self::DUMP) {
         u\DebugUtility::dump($this->getProperty()->pageConfigurations);
     }
     $this->reloadProperty();
     $this->processPageConfigurations($this->getProperty()->pageConfigurations->pageConfiguration);
     $this->content_type = $c;
     parent::setPageContentType($this->content_type);
     if (isset($this->getProperty()->structuredData)) {
         $this->data_definition_id = $this->content_type->getDataDefinitionId();
         // structuredDataNode could be empty for xml pages
         if (isset($this->getProperty()->structuredData) && isset($this->getProperty()->structuredData->structuredDataNodes) && isset($this->getProperty()->structuredData->structuredDataNodes->structuredDataNode)) {
             if ($exception) {
                 // defaulted to true
                 $this->processStructuredData($this->data_definition_id);
             }
         }
     } else {
         $this->xhtml = $this->getProperty()->xhtml;
     }
     // part 3: plug the blocks and formats back in
     $count = count(array_keys($block_format_array));
     if ($count > 0) {
         $service = $this->getService();
         $page_level_config = $this->page_configuration_map[$default_configuration_name];
         $page_region_names = $page_level_config->getPageRegionNames();
         if (self::DEBUG && self::DUMP) {
             u\DebugUtility::dump($page_region_names);
         }
         foreach ($block_format_array as $region => $block_format) {
             // only if the region exists in the current config
             if (in_array($region, $page_region_names)) {
                 if (isset($block_format['block'])) {
                     $block_id = $block_format['block'];
                 }
                 if (isset($block_format['format'])) {
                     $format_id = $block_format['format'];
                 }
                 if (isset($block_id)) {
                     $block = $this->getAsset($service, $service->getType($block_id), $block_id);
                     $this->setRegionBlock($default_configuration_name, $region, $block);
                 } else {
                     if (isset($block_format['no-block'])) {
                         $this->setRegionNoBlock($default_configuration_name, $region, true);
                     }
                 }
                 if (isset($format_id)) {
                     $format = $this->getAsset($service, $service->getType($format_id), $format_id);
                     $this->setRegionFormat($default_configuration_name, $region, $format);
                 } else {
                     if (isset($block_format['no-format'])) {
                         $this->setRegionNoFormat($default_configuration_name, $region, true);
                     }
                 }
             }
         }
         if ($exception) {
             $this->edit();
         } else {
             $this->editWithoutException();
         }
     }
     $page = $this->getProperty();
     if (self::DEBUG && self::DUMP) {
         u\DebugUtility::dump($page->pageConfigurations);
     }
     return $this;
 }