diff --git a/samples/default/data/manifest.json b/samples/default/data/manifest.json index e80ec9b..035e3bd 100755 --- a/samples/default/data/manifest.json +++ b/samples/default/data/manifest.json @@ -1,33 +1,53 @@ { - "Pages": [ - { - "Title": "Default Sample~", - "Ref": "pages/Default+Sample~.xml" - }, - { - "Title": "Cats", - "Ref": "pages/Cats.xml", - "AncestorTitle": "Default Sample~" - } - ], - "Attachments": [ - { - "Name": "pexels-just-a-couple-photos-3777622.jpg", - "ContainerPageTitle": "Cats", - "MimeType": "image/jpeg", - "Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg" - }, - { - "Name": "pexels-sami-aksu-14356302.jpg", - "ContainerPageTitle": "Cats", - "MimeType": "image/jpeg", - "Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg" - }, - { - "Name": "objects.inv", - "ContainerPageTitle": "Default Sample~", - "MimeType": "application/octet-stream", - "Ref": "attachments/Default+Sample~/objects.inv" - } - ] -} \ No newline at end of file + "Pages": [ + { + "Title": "Default Sample~", + "Hash": "4E4884BA3DEB5FE39C86E41507F3335C37A6D12895236D673BFA1C101ADAF6FF", + "Id": "789703362", + "Version": 1, + "_Ref": "pages/Default+Sample~.xml", + "Ref": "pages/Default+Sample~.xml" + }, + { + "Title": "Cats", + "AncestorTitle": "Default Sample~", + "Hash": "7AC678181A472E7F1B962566E9F9CACA1B5C35C055775692970A101B3C70985A", + "Id": "789703374", + "Version": 2, + "_Ref": "pages/Cats.xml", + "Ref": "pages/Cats.xml" + } + ], + "Attachments": [ + { + "Name": "pexels-just-a-couple-photos-3777622.jpg", + "ContainerPageTitle": "Cats", + "MimeType": "image/jpeg", + "_Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg", + "Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg", + "Id": null, + "Version": null, + "Hash": "FF90EF756F8C28433CF74AA039ABC0681FAE17D7A925498F00ACB9774AC8FF31" + }, + { + "Name": "pexels-sami-aksu-14356302.jpg", + "ContainerPageTitle": "Cats", + "MimeType": "image/jpeg", + "_Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg", + "Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg", + "Id": null, + "Version": null, + "Hash": "4A0DF56CAC53F413371CDB7FA1A8F66455B0060D0B5F9D41B2468DE08D11C7EF" + }, + { + "Name": "objects.inv", + "ContainerPageTitle": "Default Sample~", + "MimeType": "application/octet-stream", + "_Ref": "attachments/Default+Sample~/objects.inv", + "Ref": "attachments/Default+Sample~/objects.inv", + "Id": null, + "Version": null, + "Hash": "24FD5FA3627643C373552861775BF930B7AF5195376E481F9919FB08E06C0CA6" + } + ] +} diff --git a/samples/default/data/manifest.json.bck b/samples/default/data/manifest.json.bck new file mode 100755 index 0000000..035e3bd --- /dev/null +++ b/samples/default/data/manifest.json.bck @@ -0,0 +1,53 @@ +{ + "Pages": [ + { + "Title": "Default Sample~", + "Hash": "4E4884BA3DEB5FE39C86E41507F3335C37A6D12895236D673BFA1C101ADAF6FF", + "Id": "789703362", + "Version": 1, + "_Ref": "pages/Default+Sample~.xml", + "Ref": "pages/Default+Sample~.xml" + }, + { + "Title": "Cats", + "AncestorTitle": "Default Sample~", + "Hash": "7AC678181A472E7F1B962566E9F9CACA1B5C35C055775692970A101B3C70985A", + "Id": "789703374", + "Version": 2, + "_Ref": "pages/Cats.xml", + "Ref": "pages/Cats.xml" + } + ], + "Attachments": [ + { + "Name": "pexels-just-a-couple-photos-3777622.jpg", + "ContainerPageTitle": "Cats", + "MimeType": "image/jpeg", + "_Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg", + "Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg", + "Id": null, + "Version": null, + "Hash": "FF90EF756F8C28433CF74AA039ABC0681FAE17D7A925498F00ACB9774AC8FF31" + }, + { + "Name": "pexels-sami-aksu-14356302.jpg", + "ContainerPageTitle": "Cats", + "MimeType": "image/jpeg", + "_Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg", + "Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg", + "Id": null, + "Version": null, + "Hash": "4A0DF56CAC53F413371CDB7FA1A8F66455B0060D0B5F9D41B2468DE08D11C7EF" + }, + { + "Name": "objects.inv", + "ContainerPageTitle": "Default Sample~", + "MimeType": "application/octet-stream", + "_Ref": "attachments/Default+Sample~/objects.inv", + "Ref": "attachments/Default+Sample~/objects.inv", + "Id": null, + "Version": null, + "Hash": "24FD5FA3627643C373552861775BF930B7AF5195376E481F9919FB08E06C0CA6" + } + ] +} diff --git a/samples/default/data/pages/Cats.xml b/samples/default/data/pages/Cats.xml index 7203f34..f570692 100755 --- a/samples/default/data/pages/Cats.xml +++ b/samples/default/data/pages/Cats.xml @@ -1,5 +1,5 @@

What can we say… They secretly rule the world.

-

photo by: https://www.pexels.com/@jacp/

+

photo by: https://www.pexels.com/@jacp/

-

photo by: https://www.pexels.com/@sami-aksu-48867324/

\ No newline at end of file +

photo by: https://www.pexels.com/@sami-aksu-48867324/

diff --git a/samples/default/run.ps1 b/samples/default/run.ps1 index 50c14a4..c4e7714 100755 --- a/samples/default/run.ps1 +++ b/samples/default/run.ps1 @@ -12,29 +12,69 @@ Param( [Parameter(Mandatory)] [String] $Hostname, [Parameter(Mandatory)] [String] $Space, [Parameter(Mandatory)] [String] $PersonalAccessToken, - [Parameter()] [String] $ManifestFile = 'data/manifest.json' + [Parameter()] [String] $ManifestFile = "$PSScriptRoot/data/manifest.json" ) +$ErrorActionPreference = "Stop" +$DebugPreference = 'Continue' + Import-Module "$PSScriptRoot/../../src/PSConfluencePublisher.psd1" -# create a high-level manifest pseudo-object +Write-Host "initializing manifest..." + +# create a high-level manifest pseudo-object. As mentioned, this is just a +# pseduo-object to organize things a little better. $manifest = Initialize-Manifest -Path $ManifestFile -# create a high-level connection pseudo-object +Write-Host "initializing and testing connectivity..." + +# create a high-level connection pseudo-object. As mentioned, this is just a +# pseduo-object to organize things a little better. $connection = Initialize-Connection ` -Host $Hostname ` -Space $Space ` -PersonalAccessToken $PersonalAccessToken +Write-Host "fetching pages metadata..." + # unidirectionally synchronize all remote metadata to local (in-memory) manifest $manifest.Manifest.Pages = Get-PageMeta ` -Host $Hostname ` -Manifest $manifest.Manifest.Pages ` -Space $Space ` - -Force + +Write-Host "publishing pages ($($manifest.Manifest.Pages.Count))..." + +# publish all pages listed in manifest +Publish-Pages ` + -Manifest $manifest ` + -Connection $connection + +Write-Host "fetching attachments metadata..." + +# unidirectionally synchronize all remote attachment metadata to local +# (in-memory) manifest +$manifest.Manifest.Attachments = Get-AttachmentMeta ` + -Host $Hostname ` + -Manifest $manifest.Manifest.Attachments ` + -Index $manifest.Index.Attachments ` + -PagesManifest $manifest.Manifest.Pages ` + -PagesIndex $manifest.Index.Pages ` + -Space $Space ` + -Force + +Write-Host "publishing attachments ($($manifest.Manifest.Attachments.Count))..." + +# publish all pages listed in manifest +Publish-Attachments ` + -Manifest $manifest ` + -Connection $connection + +Write-Host "dumping manifest to filesystem..." # write back to disk Set-Manifest ` -Manifest $manifest.Manifest ` -File $manifest.Path ` - -Backup $true + -Backup $true | Out-Null +