fix(samples/default): integrate attachments

This commit is contained in:
Rodweil, Theodor 2023-08-14 05:08:55 +02:00
parent 5fce02eb36
commit 48b8d6c646
5 changed files with 62 additions and 40 deletions

2
samples/default/data/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*.bck

View file

@ -2,18 +2,18 @@
"Pages": [
{
"Title": "Default Sample~",
"Id": "789703435",
"Version": 2,
"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",
"Id": "789703436",
"Version": 2,
"Hash": "7AC678181A472E7F1B962566E9F9CACA1B5C35C055775692970A101B3C70985A",
"_Ref": "pages/Cats.xml",
"Ref": "pages/Cats.xml"
}
@ -23,31 +23,31 @@
"Name": "pexels-just-a-couple-photos-3777622.jpg",
"ContainerPageTitle": "Cats",
"MimeType": "image/jpeg",
"Id": "789703437",
"Version": 2,
"Hash": "FF90EF756F8C28433CF74AA039ABC0681FAE17D7A925498F00ACB9774AC8FF31",
"_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"
"Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg"
},
{
"Name": "pexels-sami-aksu-14356302.jpg",
"ContainerPageTitle": "Cats",
"MimeType": "image/jpeg",
"Id": "789703438",
"Version": 2,
"Hash": "4A0DF56CAC53F413371CDB7FA1A8F66455B0060D0B5F9D41B2468DE08D11C7EF",
"_Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg",
"Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg",
"Id": null,
"Version": null,
"Hash": "4A0DF56CAC53F413371CDB7FA1A8F66455B0060D0B5F9D41B2468DE08D11C7EF"
"Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg"
},
{
"Name": "objects.inv",
"ContainerPageTitle": "Default Sample~",
"MimeType": "application/octet-stream",
"Id": "789703439",
"Version": 2,
"Hash": "859FE623C6E8E8D9F87EC680EACB24A3AB6C29622812ABA43DB8AFE43D58E749",
"_Ref": "attachments/Default+Sample~/objects.inv",
"Ref": "attachments/Default+Sample~/objects.inv",
"Id": null,
"Version": null,
"Hash": "24FD5FA3627643C373552861775BF930B7AF5195376E481F9919FB08E06C0CA6"
"Ref": "attachments/Default+Sample~/objects.inv"
}
]
}

View file

@ -2,20 +2,20 @@
"Pages": [
{
"Title": "Default Sample~",
"Hash": "4E4884BA3DEB5FE39C86E41507F3335C37A6D12895236D673BFA1C101ADAF6FF",
"Id": "789703362",
"Version": 1,
"_Ref": "pages/Default+Sample~.xml",
"Ref": "pages/Default+Sample~.xml"
"Ref": "pages/Default+Sample~.xml",
"Id": "789703435",
"Version": 2,
"Hash": "4E4884BA3DEB5FE39C86E41507F3335C37A6D12895236D673BFA1C101ADAF6FF"
},
{
"Title": "Cats",
"AncestorTitle": "Default Sample~",
"Hash": "7AC678181A472E7F1B962566E9F9CACA1B5C35C055775692970A101B3C70985A",
"Id": "789703374",
"Version": 2,
"_Ref": "pages/Cats.xml",
"Ref": "pages/Cats.xml"
"Ref": "pages/Cats.xml",
"Id": "789703436",
"Version": 2,
"Hash": "7AC678181A472E7F1B962566E9F9CACA1B5C35C055775692970A101B3C70985A"
}
],
"Attachments": [
@ -25,8 +25,8 @@
"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,
"Id": "789703437",
"Version": 2,
"Hash": "FF90EF756F8C28433CF74AA039ABC0681FAE17D7A925498F00ACB9774AC8FF31"
},
{
@ -35,8 +35,8 @@
"MimeType": "image/jpeg",
"_Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg",
"Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg",
"Id": null,
"Version": null,
"Id": "789703438",
"Version": 2,
"Hash": "4A0DF56CAC53F413371CDB7FA1A8F66455B0060D0B5F9D41B2468DE08D11C7EF"
},
{
@ -45,9 +45,9 @@
"MimeType": "application/octet-stream",
"_Ref": "attachments/Default+Sample~/objects.inv",
"Ref": "attachments/Default+Sample~/objects.inv",
"Id": null,
"Version": null,
"Hash": "24FD5FA3627643C373552861775BF930B7AF5195376E481F9919FB08E06C0CA6"
"Id": "789703439",
"Version": 2,
"Hash": "859FE623C6E8E8D9F87EC680EACB24A3AB6C29622812ABA43DB8AFE43D58E749"
}
]
}

View file

@ -9,10 +9,20 @@
integration test.
#>
Param(
# Confluence instance hostname
[Parameter(Mandatory)] [String]$Hostname,
# Confluence space id
[Parameter(Mandatory)] [String]$Space,
# Confluence personal access token
[Parameter(Mandatory)] [String]$PersonalAccessToken,
[Parameter()] [String] $ManifestFile = "$PSScriptRoot/data/manifest.json"
# Manifest file location
[Parameter()] [String]$ManifestFile = "$PSScriptRoot/data/manifest.json",
# flag for forcing update of pages and attachments, should they already
# exist
[Parameter()] [Switch]$Force,
# flag for exiting immediately upon any failure, the default behavior is to
# just skip the failure and continue
[Parameter()] [Switch]$Strict
)
$ErrorActionPreference = "Stop"
@ -37,23 +47,30 @@ $connection = Initialize-Connection `
Write-Host "fetching pages metadata..."
# unidirectionally synchronize all remote metadata to local (in-memory) manifest
# unidirectionally synchronize all remote metadata to local (in-memory)
# manifest. If locally cached metadata is sufficient, it will skip getting the
# data from the remote, unless the -Force switch is specified.
$manifest.Manifest.Pages = Get-PageMeta `
-Host $Hostname `
-Manifest $manifest.Manifest.Pages `
-Space $Space `
-Force:$Force `
-Strict:$Strict
Write-Host "publishing pages ($($manifest.Manifest.Pages.Count))..."
# publish all pages listed in manifest
Publish-Pages `
-Manifest $manifest `
-Connection $connection
-Connection $connection `
-Force:$Force `
-Strict:$Strict
Write-Host "fetching attachments metadata..."
# unidirectionally synchronize all remote attachment metadata to local
# (in-memory) manifest
# (in-memory) manifest. If locally cached metadata is sufficient, it will skip
# getting the data from the remote, unless the -Force switch is specified.
$manifest.Manifest.Attachments = Get-AttachmentMeta `
-Host $Hostname `
-Manifest $manifest.Manifest.Attachments `
@ -61,14 +78,17 @@ $manifest.Manifest.Attachments = Get-AttachmentMeta `
-PagesManifest $manifest.Manifest.Pages `
-PagesIndex $manifest.Index.Pages `
-Space $Space `
-Force
-Force:$Force `
-Strict:$Strict
Write-Host "publishing attachments ($($manifest.Manifest.Attachments.Count))..."
# publish all pages listed in manifest
Publish-Attachments `
-Manifest $manifest `
-Connection $connection
-Connection $connection `
-Force:$Force `
-Strict:$Strict
Write-Host "dumping manifest to filesystem..."