Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #76

Merged
merged 25 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f84c7b2
add contact links.
wildone Jun 21, 2021
c1ebb77
add search criteria for all tags in known components.
wildone Jun 21, 2021
7cbcde4
add links to dialog.
wildone Jun 21, 2021
aca3025
Merge remote-tracking branch 'origin/develop' into develop
wildone Jun 21, 2021
64b4399
add field for links content output.
wildone Jun 21, 2021
bf5cefa
convert links tags to tag map.
wildone Jun 21, 2021
c2bb0b2
add dialog type hints.
wildone Jun 21, 2021
62a046f
update link field output.
wildone Jun 21, 2021
8384a88
add container badge so that it can be selected easier in authoring.
wildone Jun 22, 2021
103a9d6
add tab for allowing author to import paragraphs using dialog.
wildone Jun 22, 2021
8966f42
remove duplicate badge.
wildone Jun 22, 2021
3998d5a
add clientlibs for allowing author to import paragraphs using dialog.
wildone Jun 22, 2021
c4e7da7
update content after export.
wildone Jun 22, 2021
fab3b07
update dialog.
wildone Jun 23, 2021
046ddf3
add class fieldDescription to add padding to dialog fields.
wildone Jun 23, 2021
da55bb1
update dialog tab order.
wildone Jun 23, 2021
5d35e66
add segmentation logic.
wildone Jun 23, 2021
0f323dd
update class activate annotation.
wildone Jun 23, 2021
dab3907
update version.
wildone Jun 23, 2021
ab074c5
add field hint.
wildone Jun 24, 2021
a417c42
ensure list has a path set to current page or resource when its empty.
wildone Jun 24, 2021
1839dbc
update field names.
wildone Jun 24, 2021
82b3e04
update expression logic processing.
wildone Jun 24, 2021
6d3744d
update scripts.
wildone Jun 25, 2021
e8cf52e
update poms.
wildone Jun 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions aemdesign-aem-author/filevault-export.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
Param(
#equivalent of using localhost in docker container
[string]$AEM_HOST = "localhost",
# TCP port SOURCE_CQ listens on
[string]$AEM_PORT = "4502",
# AEM Admin user for AEM_HOST
[string]$AEM_USER = "admin",
# AEM Admin password for AEM_HOST
[string]$AEM_PASSWORD = "admin",
# Server WebDav Path
#$AEM_WEBDAV_PATH = "/crx/server/crx.default/jcr:root/"
[string]$AEM_WEBDAV_PATH = "/crx",
[string]$AEM_SCHEMA = "http",
#to set additional flags if required
[string]$VLT_FLAGS = "--insecure -Xmx2g",
[string]$VLT_CMD = "../tools/vault-cli/bin/vlt",
# Root folder name for placing content
[string]$CONTENT_DESTINATION = (Resolve-Path -Path ".\src\main\content" -Relative),
[string]$FILTER_FILE = "${CONTENT_DESTINATION}\META-INF\vault\filter.xml",
[string]$FILTER_FILE_LOCATION = "${CONTENT_DESTINATION}\META-INF",
[string[]]$ROOT_PATHS,
[switch]$Silent = $false,
[string]$LOG_PATH = "..\logs"
)

Function Format-XMLIndent
{
[Cmdletbinding()]
[Alias("IndentXML")]
param
(
[Parameter(ValueFromPipeline)]
[xml]$Content,
[int]$Indent
)

# String Writer and XML Writer objects to write XML to string
$StringWriter = New-Object System.IO.StringWriter
$XmlWriter = New-Object System.XMl.XmlTextWriter $StringWriter

# Default = None, change Formatting to Indented
$xmlWriter.Formatting = "indented"

# Gets or sets how many IndentChars to write for each level in
# the hierarchy when Formatting is set to Formatting.Indented
$xmlWriter.Indentation = $Indent

$Content.WriteContentTo($XmlWriter)
$XmlWriter.Flush();$StringWriter.Flush()
$StringWriter.ToString()
}


Function GetFilterList
{
[Cmdletbinding()]
[Alias("filterList")]
param
(
[Parameter(ValueFromPipeline)]
[string]$FILTER_FILE = ".\src\main\content\META-INF\vault\filter.xml"
)
$FILTER_PATHS = [System.Collections.ArrayList]::new()

$FILTER_XML = [xml](Get-Content $FILTER_FILE)
$FILTER_XML_CONTENT = $FILTER_XML.SelectNodes("//workspaceFilter")
$FILTER_XML_ITEMS = $FILTER_XML_CONTENT.SelectNodes('//filter')
$FILTER_XML_ITEMS | ForEach-Object {
[void]$FILTER_PATHS.Add($_.root)
}

return $FILTER_PATHS
}

if (-not($ROOT_PATHS)) {
$ROOT_PATHS = GetFilterList
}

Write-Output "------- CONFIG ----------"
Write-Output "AEM_SCHEMA: $AEM_SCHEMA"
Write-Output "AEM_HOST: $AEM_HOST"
Write-Output "AEM_PORT: $AEM_PORT"
Write-Output "AEM_USER: $AEM_USER"
Write-Output "CONTENT_DESTINATION: $CONTENT_DESTINATION"
Write-Output "ROOT_PATHS: $ROOT_PATHS"
Write-Output "FILTER_FILE: $FILTER_FILE"
Write-Output "Silent: $Silent"
Write-Output "VLT_FLAGS: $VLT_FLAGS"
Write-Output "VLT_CMD:"

$ROOT_PATHS | ForEach-Object {
Write-Output "${VLT_CMD} ${VLT_FLAGS} --credentials ${AEM_USER}:****** export -v ${AEM_SCHEMA}://${AEM_HOST}:${AEM_PORT}${AEM_WEBDAV_PATH} $_ ${CONTENT_DESTINATION}"
}

if (-not($Silent))
{
$START = Read-Host -Prompt 'Do you want to start export with these settings? (y/n)'

if ($START -ne "y")
{
Write-Output "Quiting..."
Exit
}
}

Write-Output "------- START Exporting content ----------"
$ROOT_PATHS_LAST = $ROOT_PATHS | Select-Object -Last 1
$ROOT_PATHS | ForEach-Object {
Write-Output "START Export $_"
$LOG_FILENAME = "$_".Replace("/","-")

Write-Output "Remove Filer..."
Copy-Item ".\src\main\content\META-INF\vault\filter-blank.xml" -Destination "$FILTER_FILE"

Write-Output "Create filter for: $_"
$FILTER_XML = [xml](Get-Content $FILTER_FILE)
$FILTER_XML_CONTENT = $FILTER_XML.SelectNodes("//workspaceFilter")
$FILTER_XML_DELETE = $FILTER_XML_CONTENT.SelectNodes('//filter')
$FILTER_XML_DELETE | ForEach-Object{
$DELETE_STATUS = $FILTER_XML_CONTENT.RemoveChild($_)
}
$FILTER_XML_CONTENT_NEW = $FILTER_XML.CreateNode("element","filter","")
$FILTER_XML_CONTENT_NEW.SetAttribute("root",$_)
$FILTER_XML_CONTENT_NEW_ADD = $FILTER_XML_CONTENT.AppendChild($FILTER_XML_CONTENT_NEW)
Write-Output "Saving..."
$FILTER_XML.OuterXml | IndentXML -Indent 4 | Out-File $FILTER_FILE -encoding "UTF8"
Write-Output "Done..."

Write-Output "Running VLT..."
Invoke-Expression -Command "${VLT_CMD} ${VLT_FLAGS} --credentials ${AEM_USER}:${AEM_PASSWORD} export -v ${AEM_SCHEMA}://${AEM_HOST}:${AEM_PORT}${AEM_WEBDAV_PATH} $_ ${CONTENT_DESTINATION}" | Tee-Object -FilePath "${LOG_PATH}\filevailt-export-$LOG_FILENAME.log"

Write-Output "END Export $_"
}

Write-Output "------- END Exporting content ----------"

Write-Output "------- START Updating ${FILTER_FILE} ----------"

$FILTER_XML = [xml](Get-Content $FILTER_FILE)
Write-Output "Removing Existing Filters..."
$FILTER_XML_CONTENT = $FILTER_XML.SelectNodes("//workspaceFilter")
$FILTER_XML_DELETE = $FILTER_XML_CONTENT.SelectNodes('//filter')
$FILTER_XML_DELETE | ForEach-Object{
$DELETE_STATUS = $FILTER_XML_CONTENT.RemoveChild($_)
}
Write-Output "Adding Exported Filters..."
$ROOT_PATHS | ForEach-Object {
$FILTER_XML_CONTENT_NEW = $FILTER_XML.CreateNode("element","filter","")
$FILTER_XML_CONTENT_NEW.SetAttribute("root",$_)
$FILTER_XML_CONTENT_NEW_ADD = $FILTER_XML_CONTENT.AppendChild($FILTER_XML_CONTENT_NEW)
}
Write-Output "Saving..."
$FILTER_XML.OuterXml | IndentXML -Indent 4 | Out-File $FILTER_FILE -encoding "UTF8"
Write-Output "Done."
Write-Output "------- DONE Updating ${FILTER_FILE} ----------"

Write-Output "------- Revert Filter.xml ----------"
git checkout HEAD src/main/content/META-INF/
git clean -fx src/main/content/META-INF
Write-Output "------- Revert Filter.xml ----------"
225 changes: 225 additions & 0 deletions aemdesign-aem-author/filevault-import.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
Param(
#equivalent of using localhost in docker container
[string]$AEM_HOST = "localhost",
# TCP port SOURCE_CQ listens on
[string]$AEM_PORT = "4502",
# AEM Admin user for AEM_HOST
[string]$AEM_USER = "admin",
# AEM Admin password for AEM_HOST
[string]$AEM_PASSWORD = "admin",
# Root folder name for placing content
[string]$SOURCE_CONTENT_FOLDER = "localhost-author-export",
# Server WebDav Path
#$AEM_WEBDAV_PATH = "/crx/server/crx.default/jcr:root/"
[string]$AEM_WEBDAV_PATH = "/crx",
[string]$AEM_SCHEMA = "http",
#to set additional flags if required
[string]$VLT_FLAGS = "--insecure -Xmx2g",
[string]$VLT_CMD = "../tools/vault-cli/bin/vlt",
# Root folder name for placing content
[string]$CONTENT_DESTINATION = ".\src\main\content",
[string]$FILTER_FILE = "${CONTENT_DESTINATION}\META-INF\vault\filter.xml",
[string]$FILTER_FILE_LOCATION = "${CONTENT_DESTINATION}\META-INF",
#which filter paths to import
[string[]]$ROOT_PATHS,
[string]$ROOT_PATH = "/",
[string]$CONTENT_SOURCE = (Resolve-Path -Path "src\main\content\jcr_root" -Relative),
# connection timeout
[string]$TIMEOUT = "5",
# host address
[string]$ADDRESS = "${AEM_SCHEMA}://${AEM_HOST}:${AEM_PORT}",
# Disable services before import
[string[]]$SERVICES_TO_DISABLE = @(
"/system/console/bundles/com.day.cq.cq-mailer",
"/system/console/bundles/com.adobe.granite.workflow.core"
),

[HashTable]$BODY_SERVICE_TO_DISABLE = @{
"action"="stop"
},
[HashTable]$BODY_SERVICE_TO_DISABLE_ENABLE = @{
"action"="start"
},
[switch]$Silent = $false,
[string]$LOG_PATH = "..\logs"
)


Function Format-XMLIndent
{
[Cmdletbinding()]
[Alias("IndentXML")]
param
(
[Parameter(ValueFromPipeline)]
[xml]$Content,
[int]$Indent
)

# String Writer and XML Writer objects to write XML to string
$StringWriter = New-Object System.IO.StringWriter
$XmlWriter = New-Object System.XMl.XmlTextWriter $StringWriter

# Default = None, change Formatting to Indented
$xmlWriter.Formatting = "indented"

# Gets or sets how many IndentChars to write for each level in
# the hierarchy when Formatting is set to Formatting.Indented
$xmlWriter.Indentation = $Indent

$Content.WriteContentTo($XmlWriter)
$XmlWriter.Flush();$StringWriter.Flush()
$StringWriter.ToString()
}


function doSlingPost {
[CmdletBinding()]
Param (

[Parameter(Mandatory=$true)]
[string]$Url="http://localhost:4502",

[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[ValidateSet('Post','Delete')]
[string]$Method,

[Parameter(Mandatory=$false)]
[HashTable]$Body,

[Parameter(Mandatory=$false,
HelpMessage="Provide Basic Auth Credentials in following format: <user>:<pass>")]
[string]$BasicAuthCreds="",

[Parameter(Mandatory=$false)]
[string]$UserAgent="",

[Parameter(Mandatory=$false)]
[string]$Referer="",

[Parameter(Mandatory=$false)]
[string]$Timeout="5"

)



$HEADERS = @{
}

if (-not([string]::IsNullOrEmpty($UserAgent))) {
$HEADERS.add("User-Agent",$UserAgent)
}

if (-not([string]::IsNullOrEmpty($Referer))) {
$HEADERS.add("Referer",$Referer)
}


if (-not([string]::IsNullOrEmpty($BasicAuthCreds))) {
$BASICAUTH = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($BasicAuthCreds))
$HEADERS.add("Authorization","Basic $BASICAUTH")
}


Write-Output "Performing action $Method on $Url."

$Response = Invoke-WebRequest -Method Post -Headers $HEADERS -TimeoutSec $Timeout -Uri "$Url" -Form $Body -ContentType "application/x-www-form-urlencoded"

}

Write-Output "------- CONFIG ----------"
Write-Output "AEM_SCHEMA: $AEM_SCHEMA"
Write-Output "AEM_HOST: $AEM_HOST"
Write-Output "AEM_PORT: $AEM_PORT"
Write-Output "AEM_USER: $AEM_USER"
Write-Output "CONTENT_SOURCE: $CONTENT_SOURCE"
Write-Output "ROOT_PATH: $ROOT_PATH"
Write-Output "FILTER_FILE: $FILTER_FILE"
Write-Output "Silent: $Silent"
Write-Output "VLT_FLAGS: $VLT_FLAGS"
Write-Output "VLT_CMD: $VLT_CMD"
Write-Output "ROOT_PATHS:"
$ROOT_PATHS | ForEach-Object {
Write-Output " - $_"
}
Write-Output "SERVICES_TO_DISABLE:"
$SERVICES_TO_DISABLE | ForEach-Object {
Write-Output " - $_"
}

if (-not($Silent))
{
$START = Read-Host -Prompt 'Do you want to start import with these settings? (y/n)'

if ($START -ne "y")
{
Write-Output "Quiting..."
Exit
}
}

Write-Output "------- Revert META-INF ----------"
git checkout HEAD src/main/content/META-INF/
git clean -fx src/main/content/META-INF
Write-Output "------- Revert META-INF ----------"

if ($ROOT_PATHS)
{
Write-Output "------- START Update filter ----------"
$ROOT_PATHS_LAST = $ROOT_PATHS | Select-Object -Last 1
$ROOT_PATHS | ForEach-Object {
$LOG_FILENAME = "$_".Replace("/","-")

Write-Output "Remove exiting Filer..."
Copy-Item ".\src\main\content\META-INF\vault\filter-blank.xml" -Destination "$FILTER_FILE"

Write-Output "Create filter for: $_"
$FILTER_XML = [xml](Get-Content $FILTER_FILE)
$FILTER_XML_CONTENT = $FILTER_XML.SelectNodes("//workspaceFilter")
$FILTER_XML_DELETE = $FILTER_XML_CONTENT.SelectNodes('//filter')
$FILTER_XML_DELETE | ForEach-Object{
$DELETE_STATUS = $FILTER_XML_CONTENT.RemoveChild($_)
}
$FILTER_XML_CONTENT_NEW = $FILTER_XML.CreateNode("element","filter","")
$FILTER_XML_CONTENT_NEW.SetAttribute("root",$_)
$FILTER_XML_CONTENT_NEW_ADD = $FILTER_XML_CONTENT.AppendChild($FILTER_XML_CONTENT_NEW)
Write-Output "Saving..."
$FILTER_XML.OuterXml | IndentXML -Indent 4 | Out-File $FILTER_FILE -encoding "UTF8"
Write-Output "Done..."
}

Write-Output "------- END Update filter ----------"
}

if ($SERVICES_TO_DISABLE)
{
Write-Output "------- Disable Services ----------"
$SERVICES_TO_DISABLE | ForEach-Object {
Write-Output "Stopping service: $_"
doSlingPost -Method Post -Referer $ADDRESS -UserAgent "curl" -Body $BODY_SERVICE_TO_DISABLE -Url "${ADDRESS}$_" -BasicAuthCreds ${AEM_USER}:${AEM_PASSWORD} -Timeout $TIMEOUT
}
}

Write-Output "------- START Importing content ----------"
Write-Output "${VLT_CMD} ${VLT_FLAGS} --credentials ${AEM_USER}:****** import -v ${ADDRESS}${AEM_WEBDAV_PATH} ${CONTENT_SOURCE} ${ROOT_PATH}"

Invoke-Expression -Command "${VLT_CMD} ${VLT_FLAGS} --credentials ${AEM_USER}:${AEM_PASSWORD} import -v ${ADDRESS}${AEM_WEBDAV_PATH} ${CONTENT_SOURCE} ${ROOT_PATH} " | Tee-Object -FilePath "${LOG_PATH}\filevailt-import.log"

Write-Output "------- END Importing content ----------"


if ($SERVICES_TO_DISABLE)
{
Write-Output "------- Enable Services ----------"
$SERVICES_TO_DISABLE | ForEach-Object {
Write-Output "Stopping service: $_"
doSlingPost -Method Post -Referer $ADDRESS -UserAgent "curl" -Body $BODY_SERVICE_TO_DISABLE_ENABLE -Url "${ADDRESS}$_" -BasicAuthCreds ${AEM_USER}:${AEM_PASSWORD} -Timeout $TIMEOUT
}
}

Write-Output "------- Revert META-INF ----------"
git checkout HEAD src/main/content/META-INF/
git clean -fx src/main/content/META-INF
Write-Output "------- Revert META-INF ----------"
Loading