def path = "/content/we-retail"
def pageCount = 0;
def summarybarDisabledProperty = "summarybarDisabled";
def slideOutEnabledProperty = "slideOutEnabled";
getPage(path).recurse { page ->
def content = page.node
def pagePath = page.path;
content?.recurse { node ->
def componentNode = node.get("sling:resourceType")
if(componentNode == "we-retail/components/content/image"){
def newNodePathtemp = node.path;
if(node.get(summarybarDisabledProperty)){
def summaryBarStr = getPropertyValueAsStr(node, summarybarDisabledProperty);
if (summaryBarStr == "true") {
nodePath = node.path;
if (nodePath.contains("slideouthero/findhotel")) {
//Inside Slide Out Hero Component
println page.path;
//Remove and set the property, uncomment this block to save the changes
/*
node.getProperty(summarybarDisabledProperty).remove();
node.set(slideOutEnabledProperty, "{Boolean}true");
session.save();
*/
pageCount++;
} else {
//Do not do anything
}
} else {
//println summaryBarStr +" " +page.path;
}
}
}
}
}
println "Total number pages : "+pageCount
def getPropertyValueAsStr(def content, def propertyName){
def propertyValStr = "";
if(content.get(propertyName)){
def propertyVal = content.getProperty(propertyName);
if(propertyVal){
if(!propertyVal.isMultiple()){
propertyValStr = propertyVal.getString();
}else{
values = propertyVal.getValues();
values.each {
if(propertyValStr.length() > 0){
propertyValStr = propertyValStr + " ; " + "$it";
}else{
propertyValStr = "$it";
}
}
}
}
}
return propertyValStr;
}
def pageCount = 0;
def summarybarDisabledProperty = "summarybarDisabled";
def slideOutEnabledProperty = "slideOutEnabled";
getPage(path).recurse { page ->
def content = page.node
def pagePath = page.path;
content?.recurse { node ->
def componentNode = node.get("sling:resourceType")
if(componentNode == "we-retail/components/content/image"){
def newNodePathtemp = node.path;
if(node.get(summarybarDisabledProperty)){
def summaryBarStr = getPropertyValueAsStr(node, summarybarDisabledProperty);
if (summaryBarStr == "true") {
nodePath = node.path;
if (nodePath.contains("slideouthero/findhotel")) {
//Inside Slide Out Hero Component
println page.path;
//Remove and set the property, uncomment this block to save the changes
/*
node.getProperty(summarybarDisabledProperty).remove();
node.set(slideOutEnabledProperty, "{Boolean}true");
session.save();
*/
pageCount++;
} else {
//Do not do anything
}
} else {
//println summaryBarStr +" " +page.path;
}
}
}
}
}
println "Total number pages : "+pageCount
def getPropertyValueAsStr(def content, def propertyName){
def propertyValStr = "";
if(content.get(propertyName)){
def propertyVal = content.getProperty(propertyName);
if(propertyVal){
if(!propertyVal.isMultiple()){
propertyValStr = propertyVal.getString();
}else{
values = propertyVal.getValues();
values.each {
if(propertyValStr.length() > 0){
propertyValStr = propertyValStr + " ; " + "$it";
}else{
propertyValStr = "$it";
}
}
}
}
}
return propertyValStr;
}
No comments:
Post a Comment
If you have any doubts or questions, please let us know.