Search the FirstSpirit Knowledge Base
Hello Team,
I would like to skip the complete Action Tasks below Generate Action, when the users Action Generate has result of " No start nodes defined.Nothing will be generated.!!!
Is there any script available?
Generate Action LOG:
INFO 10.04.2018 08:50:49.912 (de.espirit.firstspirit.server.sessionmanagement.SessionManagerImpl): new session (ID=2860102498864889649, user=SYSTEM, userID=0, type=DUMMY) created
INFO 10.04.2018 08:50:49.912 (de.espirit.firstspirit.server.scheduler.ScheduleManagerImpl): starting task 'Generate' - schedule entry 'Hotdeployment wcms_bgn_qa 7972' (id=71170703)
INFO 10.04.2018 08:50:49.913 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): setting user service to nearest revision Tue Apr 10 08:50:49 CEST 2018
INFO 10.04.2018 08:50:49.914 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): start generation of project 'wcms_bgn_qa' (project id=60475111), date 'Mon Apr 09 10:47:16 CEST 2018', revision 398244, schedule Hotdeployment wcms_bgn_qa 7972 (id=71170703)
INFO 10.04.2018 08:50:49.914 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): deleting directory '/opt/wcms/fs/web/fs5staging/6475111/7110703'
INFO 10.04.2018 08:50:49.915 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): start partial generation
INFO 10.04.2018 08:50:49.915 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): No start nodes defined. Nothing will be generated!!!
INFO 10.04.2018 08:50:49.915 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): finished generation of project 'wcms_bgn_qa' (id=60475111) - 0 fatal error(s), 0 error(s), 0 warning(s), duration 0:00:00.002
INFO 10.04.2018 08:50:49.915 (de.espirit.firstspirit.server.scheduler.ScheduleManagerImpl): finished task 'Generate' - schedule entry 'Hotdeployment wcms_bgn_qa 7972' (id=71170703)
Thank you.
Regards,
Siva
Dear Siva,
here's an example for a script, which checks the generation logfile (searches errors and warnings and the appropriate page):
**********************************
import java.io.InputStreamReader;
import java.io.BufferedReader;
logfile = "";
knoten = "";
truncate = true;
task = context.getTask();
inputStream = task.getScheduleEntry().getRunningEntries().get(0).getState().getTaskResults().get(1).getLogfile();
context.logInfo("Size of the logfile = " + inputStream.available());
br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
for(i=0;i<200;) {
zeile = br.readLine();
if(zeile==null) {
i = 200;
truncate = false;
} else if((zeile.length()>5) && (zeile.substring(0,5).equals("ERROR") || (zeile.substring(0,5).equals("WARN ")))) {
i = i+1;
logfile = logfile + zeile + "\n" + Knoten + "\n\n";
} else if((zeile.length()>5) && (zeile.substring(0,5).equals("INFO ") && (zeile.contains("generating page reference")))) {
Knoten = "Pageref: " + zeile.substring(zeile.indexOf("generating page reference")+26,zeile.length()) + "\n";
}
}
if(truncate) {
logfile = logfile + "\nLogfile was truncated after 200 lines";
}
context.setProperty("logfile", logfile);
*******************************************************************
Just change it, so that it checks for "No start nodes defined. Nothing will be generated!!!"
If you find it, deactivate the following tasks:
*******************************************************************
//--- temporarily deactivate all following tasks ---//
idx = context.taskIndex;
tasks = context.tasks;
for (int i = idx + 1; i < tasks.size(); i++) {
tasks.get(i).setActive(false);
}
*******************************************************************
I hope, that you can solve the issue with this example.
Best regards,
Holger
Hi Siva,
have you considered to uncheck the "Execute even in case of error" checkbox for the tasks below the generation? The very first task after the generation would still execute, but the following tasks would be skipped.
Best regards,
Donato
Hello Marro,
Thank you for your reply and kind time.
Generate Action is Successful and color is GREEN.There is no error.
If no node is selected in the Generate Action means don't execute all the below Action tasks as shown in the previous comment Image.
Skip executing all the actions after Generate.
How to achieve this via script?
LOG: Generate:
INFO 18.04.2018 11:19:54.914 (de.espirit.firstspirit.server.sessionmanagement.SessionManagerImpl): new session (ID=7005683005691293533, user=SYSTEM, userID=0, type=DUMMY) created
INFO 18.04.2018 11:19:54.914 (de.espirit.firstspirit.server.scheduler.ScheduleManagerImpl): starting task 'Generate' - schedule entry 'Hotdeployment wcms_c_Siva' (id=6912998)
INFO 18.04.2018 11:19:54.915 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): setting user service to nearest revision Wed Apr 18 11:19:54 CEST 2018
INFO 18.04.2018 11:19:54.915 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): start generation of project 'wcms_c' (project id=6333735), date 'Wed Apr 11 08:48:59 CEST 2018', revision 2963587, schedule Hotdeployment wcms_c_Siva (id=6912998)
INFO 18.04.2018 11:19:54.934 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): deleting directory '/opt/wcms/fs/web/fs5staging/6333735/6912998'
INFO 18.04.2018 11:19:54.935 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): start partial generation
INFO 18.04.2018 11:19:54.935 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): No start nodes defined. Nothing will be generated!!!
INFO 18.04.2018 11:19:54.935 (de.espirit.firstspirit.server.scheduler.GenerateTaskExecutor): finished generation of project 'wcms_c' (id=6333735) - 0 fatal error(s), 0 error(s), 0 warning(s), duration 0:00:00.020
INFO 18.04.2018 11:19:54.935 (de.espirit.firstspirit.server.scheduler.ScheduleManagerImpl): finished task 'Generate' - schedule entry 'Hotdeployment wcms_c_Siva' (id=6912998)
Thank you.
Regards,
Siva
Dear Siva,
here's an example for a script, which checks the generation logfile (searches errors and warnings and the appropriate page):
**********************************
import java.io.InputStreamReader;
import java.io.BufferedReader;
logfile = "";
knoten = "";
truncate = true;
task = context.getTask();
inputStream = task.getScheduleEntry().getRunningEntries().get(0).getState().getTaskResults().get(1).getLogfile();
context.logInfo("Size of the logfile = " + inputStream.available());
br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
for(i=0;i<200;) {
zeile = br.readLine();
if(zeile==null) {
i = 200;
truncate = false;
} else if((zeile.length()>5) && (zeile.substring(0,5).equals("ERROR") || (zeile.substring(0,5).equals("WARN ")))) {
i = i+1;
logfile = logfile + zeile + "\n" + Knoten + "\n\n";
} else if((zeile.length()>5) && (zeile.substring(0,5).equals("INFO ") && (zeile.contains("generating page reference")))) {
Knoten = "Pageref: " + zeile.substring(zeile.indexOf("generating page reference")+26,zeile.length()) + "\n";
}
}
if(truncate) {
logfile = logfile + "\nLogfile was truncated after 200 lines";
}
context.setProperty("logfile", logfile);
*******************************************************************
Just change it, so that it checks for "No start nodes defined. Nothing will be generated!!!"
If you find it, deactivate the following tasks:
*******************************************************************
//--- temporarily deactivate all following tasks ---//
idx = context.taskIndex;
tasks = context.tasks;
for (int i = idx + 1; i < tasks.size(); i++) {
tasks.get(i).setActive(false);
}
*******************************************************************
I hope, that you can solve the issue with this example.
Best regards,
Holger
Hello Holger,
Thank you for your reply and kind time.you solution should work perfectly.
I have resolved the problem by below code:
public void execute() {
for (ScheduleTask task : _context.getTasks()) {
if (task.isActive() && task instanceof GenerateTask) {
GenerateTask cur_task = (GenerateTask) task;
generationTask = cur_task;
if (generationTask.getStartNodes() == null || generationTask.getStartNodes().isEmpty()) {
List<ScheduleEntryControl> controls = _context.getTask().getScheduleEntry().getRunningEntries();
for (ScheduleEntryControl control : controls) {
control.stopExecution();
}
}
}
}
}
Regards,
Siva