echo $page->getCreatedDate(), BR;
        //u\DebugUtility::dump( $page->getDynamicField( "exclude-from-menu" ) );
        //u\DebugUtility::dump( $page->getDynamicFields() );
        echo u\StringUtility::getCoalescedString( $page->getExpirationFolderId() ), BR;
        echo u\StringUtility::getCoalescedString( $page->getExpirationFolderPath() ), BR;
        echo u\StringUtility::boolToString( $page->getExpirationFolderRecycled() ), BR;
        echo $page->getLastModifiedBy(), BR;
        echo $page->getLastModifiedDate(), BR;
    */
    //u\DebugUtility::dump( $page->getMetadata() );
    //$page->getMetadataSet()->dump();
    //echo u\StringUtility::getCoalescedString( $page->getMetadataSetId() ), BR;
    //echo u\StringUtility::getCoalescedString( $page->getMetadataSetPath() ), BR;
    //u\DebugUtility::dump( $page->getMetadataStdClass() );
    //echo u\StringUtility::boolToString( $page->hasDynamicField( "exclude-from-menu" ) ), BR;
    /*
    $page->setExpirationFolder(
        $cascade->getAsset(
            a\Folder::TYPE, "39d53a118b7ffe834c5fe91e7e2e0cd9" )
    )->edit();
    */
    //$page->setMetadata( $page->getMetadata() );
    //$page->setMetadataSet( $cascade->getAsset(
    //a\MetadataSet::TYPE, "35963bf48b7ffe83164c931407216994" ) );
    //echo a\Linkable::getLinkableType( $service, "06a23e5b8b7ffe830820c9fac501387b" ), BR;
    a\Linkable::getLinkable($service, "06a23e5b8b7ffe830820c9fac501387b")->dump();
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
} catch (\Error $er) {
    echo S_PRE . $er . E_PRE;
}
function assetTreeSwitchDataDefinitionForBlock(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    global $common_assets_site_name;
    $type = $child->getType();
    if ($type != a\DataBlock::TYPE) {
        return;
    }
    if (!isset($params["cascade"])) {
        throw new \Exception("The Cascade object is not supplied");
    } else {
        $cascade = $params["cascade"];
    }
    $block = $child->getAsset($service);
    $b_name = $block->getName();
    if ($b_name == "_footer-contact") {
        $dd_name = "Footer Contact";
    } elseif ($b_name == "_left-column") {
        $dd_name = "Left Column";
    } elseif ($b_name == "_right-column") {
        $dd_name = "Right Column";
    } elseif ($b_name == "_site-info") {
        $dd_name = "Site Info";
    } else {
        return;
    }
    $dd = $cascade->getAsset(a\DataDefinition::TYPE, $dd_name, $common_assets_site_name);
    $st = new p\StructuredData($dd->getStructuredData(), $service, $dd->getId());
    $identifiers = $block->getIdentifiers();
    foreach ($identifiers as $identifier) {
        // create the correct number of instances for multiple field
        if (u\StringUtility::endsWith($identifier, ";0") && $st->hasIdentifier($identifier)) {
            $st->createNInstancesForMultipleField($block->getNumberOfSiblings($identifier), $identifier);
        }
        // map the data
        if ($st->hasNode($identifier) && $block->isTextNode($identifier)) {
            $st->setText($identifier, $block->getText($identifier));
        } elseif ($st->hasNode($identifier) && $block->isAssetNode($identifier)) {
            $asset_node_type = $block->getAssetNodeType($identifier);
            if ($asset_node_type == "page" && $block->getPageId($identifier) != null) {
                $st->setPage($identifier, $cascade->getPage($block->getPageId($identifier)));
            } elseif ($asset_node_type == "file" && $block->getFileId($identifier) != null) {
                $st->setFile($identifier, $cascade->getFile($block->getFileId($identifier)));
            } elseif ($asset_node_type == "block" && $block->getBlockId($identifier) != null) {
                $st->setBlock($identifier, a\Block::getBlock($service, $block->getBlockId($identifier)));
            } elseif ($asset_node_type == "page,file,symlink" && $block->getLinkableId($identifier) != null) {
                $st->setLinkable($identifier, a\Linkable::getLinkable($service, $block->getLinkableId($identifier)));
            }
        }
    }
    $block->setStructuredData($st);
}
 private static function copyData($source, StructuredData $target, $id)
 {
     if (!$source instanceof StructuredData && !$source instanceof StructuredDataPhantom) {
         throw new \Exception("Wrong source type");
     }
     if ($source->isTextNode($id) || $source->isWYSIWYG($id)) {
         $target->setText($id, $source->getText($id));
         if ($target->getText($id) == NULL) {
             $target->setText($id, "");
         }
     } elseif ($source->isAssetNode($id)) {
         $asset_type = $source->getAssetNodeType($id);
         try {
             switch ($asset_type) {
                 case c\T::PAGE:
                     $page_id = $source->getPageId($id);
                     if (isset($page_id)) {
                         $target->setPage($id, $source->getService()->getAsset($source->getService()->createId(a\Page, $page_id)));
                     }
                     break;
                 case c\T::FILE:
                     $file_id = $source->getFileId($id);
                     if (isset($file_id)) {
                         $target->setFile($id, $source->getService()->getAsset($source->getService()->createId(a\File, $file_id)));
                     }
                     break;
                 case c\T::BLOCK:
                     $block_id = $source->getBlockId($id);
                     if (isset($block_id)) {
                         $target->setBlock($id, a\Block::getBlock($target->getService(), $block_id));
                     }
                     break;
                 case c\T::SYMLINK:
                     $symlink_id = $source->getSymlinkId($id);
                     if (isset($symlink_id)) {
                         $target->setSymlink($id, $source->getService()->getAsset($source->getService()->createId(a\Symlink, $symlink_id)));
                     }
                     break;
                 case c\T::PFS:
                     $linkable_id = $source->getLinkableId($id);
                     if (isset($linkable_id)) {
                         $target->setLinkable($id, a\Linkable::getLinkable($source->getService(), $linkable_id));
                     }
                     break;
             }
         } catch (e\NoSuchTypeException $e) {
             // do nothing to skip deleted blocks
         }
     }
 }