On Cloud Services Dev you have CRXDe (for now) to delete specific nodes not available on authoring UI. This post is for deleting such nodes on Stage and Prod where CRXDe is unavailable. Here we delete the old /oak:index/ntFolderDamLucene-6 node...
Old Index Config
Script Execution
1) Get the access token from Developer Console
2) In the following script saved in file delete-node.js, set the value of AEM_TOKEN to access token generated above and run it using node eg. node delete-node.js (used node -v = v19.0.1)
const https = require('https');
const QS = require('querystring');
let AEM_HOST = 'author-p9999-e99999.adobeaemcloud.com';
let AEM_TOKEN = "eyJhb.....";
let PATH = "/oak:index/ntFolderDamLucene-6";
doDeleteJob(PATH);
function doDeleteJob(nodePath){
const postData = {
":operation" : "delete"
};
let payload = QS.stringify(postData);
const options = {
hostname: AEM_HOST,
path: nodePath,
method: 'POST',
headers: {
Authorization: 'Bearer ' + AEM_TOKEN,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': payload.length
}
}
let req = https.request(options, (res) => {
res.setEncoding('utf8');
let body = "";
res.on("data", (chunk) => {
body += chunk;
});
res.on('end', () => {
console.log(res.statusCode + " : DELETED NODE : " + nodePath);
});
});
req.on('error', (e) => {
console.log("ERROR DELETE : " + nodePath + " , " + e);
});
req.write(payload);
req.end();
}
No comments:
Post a Comment