3131import lombok .RequiredArgsConstructor ;
3232import lombok .extern .slf4j .Slf4j ;
3333import org .apache .commons .collections4 .CollectionUtils ;
34+ import org .apache .commons .io .FileUtils ;
3435import org .apache .commons .lang3 .StringUtils ;
3536import org .springframework .stereotype .Service ;
3637import org .springframework .transaction .annotation .Transactional ;
@@ -76,9 +77,12 @@ public class CleaningTaskService {
7677
7778 private final String FLOW_PATH = "/flow" ;
7879
79- private final Pattern LEVEL_PATTERN = Pattern .compile (
80- "\\ b(TRACE|DEBUG|INFO|WARN|WARNING|ERROR|FATAL)\\ b" ,
81- Pattern .CASE_INSENSITIVE
80+ private static final Pattern STANDARD_LEVEL_PATTERN = Pattern .compile (
81+ "\\ b(DEBUG|Debug|INFO|Info|WARN|Warn|WARNING|Warning|ERROR|Error|FATAL|Fatal)\\ b"
82+ );
83+
84+ private static final Pattern EXCEPTION_SUFFIX_PATTERN = Pattern .compile (
85+ "\\ b\\ w+(Warning|Error|Exception)\\ b"
8286 );
8387
8488 private final ObjectMapper OBJECT_MAPPER = new ObjectMapper ();
@@ -168,9 +172,16 @@ private String getLogLevel(String logLine, String defaultLevel) {
168172 return defaultLevel ;
169173 }
170174
171- Matcher matcher = LEVEL_PATTERN .matcher (logLine );
172- if (matcher .find ()) {
173- return matcher .group (1 ).toUpperCase ();
175+ Matcher stdMatcher = STANDARD_LEVEL_PATTERN .matcher (logLine );
176+ if (stdMatcher .find ()) {
177+ return stdMatcher .group (1 ).toUpperCase ();
178+ }
179+
180+ Matcher exMatcher = EXCEPTION_SUFFIX_PATTERN .matcher (logLine );
181+ if (exMatcher .find ()) {
182+ String match = exMatcher .group (1 ).toUpperCase ();
183+ if ("WARNING" .equals (match )) return "WARN" ;
184+ if ("ERROR" .equals (match ) || "EXCEPTION" .equals (match )) return "ERROR" ;
174185 }
175186 return defaultLevel ;
176187 }
@@ -180,6 +191,11 @@ public void deleteTask(String taskId) {
180191 cleaningTaskRepo .deleteTaskById (taskId );
181192 operatorInstanceRepo .deleteByInstanceId (taskId );
182193 cleaningResultRepo .deleteByInstanceId (taskId );
194+ try {
195+ FileUtils .deleteDirectory (new File (FLOW_PATH + "/" + taskId ));
196+ } catch (IOException e ) {
197+ log .warn ("Can't delete flow path with task id: {}." , taskId , e );
198+ }
183199 }
184200
185201 public void executeTask (String taskId ) {
0 commit comments