Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
SleuthkitErrorReporter.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2017 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.casemodule;
20 
21 import java.util.logging.Level;
22 import org.openide.util.NbBundle;
26 
34 class SleuthkitErrorReporter implements SleuthkitCase.ErrorObserver {
35 
36  private static final Logger LOGGER = Logger.getLogger(SleuthkitErrorReporter.class.getName());
37  private final int milliSecondsBetweenReports;
38  private final String message;
39  private long newProblems;
40  private long totalProblems;
41  private long lastReportedDate;
42 
52  SleuthkitErrorReporter(int secondsBetweenReports, String message) {
53  this.newProblems = 0;
54  this.totalProblems = 0;
55  this.lastReportedDate = 0; // arm the first warning by choosing zero
56  this.milliSecondsBetweenReports = secondsBetweenReports * 1000; // convert to milliseconds
57  this.message = message;
58  }
59 
68  @Override
69  public void receiveError(String context, String errorMessage) {
70  LOGGER.log(Level.SEVERE, String.format("%s error in the SleuthKit layer: %s", context, errorMessage));
71  this.newProblems += 1;
72  this.totalProblems += newProblems;
73  long currentTimeStamp = System.currentTimeMillis();
74  if ((currentTimeStamp - lastReportedDate) > milliSecondsBetweenReports) {
75  this.lastReportedDate = currentTimeStamp;
76  MessageNotifyUtil.Notify.error(message, context + ", " + errorMessage + " "
77  + this.newProblems + " "
78  + NbBundle.getMessage(SleuthkitErrorReporter.class, "IntervalErrorReport.NewIssues")
79  + " " + this.totalProblems + " "
80  + NbBundle.getMessage(SleuthkitErrorReporter.class, "IntervalErrorReport.TotalIssues")
81  + ".");
82  this.newProblems = 0;
83  }
84  }
85 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.