Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.intrallect.logfilter;
- import java.io.File;
- import java.io.IOException;
- import java.nio.charset.Charset;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.util.List;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Main {
- public static void main(final String[] args) throws IOException {
- // TODO Auto-generated method stub
- final Path filePath = new File("/home/bence/rndamat.catalina.out").toPath();
- final Charset charset = Charset.defaultCharset();
- final List<String> lines = Files.readAllLines(filePath, charset);
- for (int i = 0; i < lines.size(); i++) {
- final String currentLine = lines.get(i);
- // check if line is Mission Control related
- if (currentLine.contains("com.intrallect.amauthor.service.MissionControlService")) {
- if (currentLine.contains("Unpublishing")) {
- }
- // check for overwrite
- if (currentLine.contains("Overwriting")) {
- try {
- final Pattern pattern = Pattern.compile("'(.+)'.\\(id: (\\d+)\\) with (.+) in (.+)");
- final Matcher matcher = pattern.matcher(currentLine);
- matcher.find();
- final String originalName = matcher.group(1).trim();
- final String newName = matcher.group(3).trim();
- if (!newName.equals(originalName)) {
- System.out.println(originalName + " was replaced by " + newName + " in " + matcher.group(4) + " Resource Id: " + matcher.group(2));
- }
- } catch (final IllegalStateException ise) {
- System.out.println(currentLine);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement