Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
IntervalErrorReportData.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2015 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 org.openide.util.NbBundle;
23 
31 class IntervalErrorReportData {
32 
33  private final Case currentCase;
34  private long newProblems;
35  private long totalProblems;
36  private long lastReportedDate;
37  private final int milliSecondsBetweenReports;
38  private final String message;
39 
51  IntervalErrorReportData(Case currentCase, int secondsBetweenReports, String message) {
52  this.newProblems = 0;
53  this.totalProblems = 0;
54  this.lastReportedDate = 0; // arm the first warning by choosing zero
55  this.milliSecondsBetweenReports = secondsBetweenReports * 1000; // convert to milliseconds
56  this.message = message;
57  this.currentCase = currentCase;
58  this.currentCase.getSleuthkitCase().addErrorObserver(this.currentCase);
59  }
60 
64  void shutdown() {
65  this.currentCase.getSleuthkitCase().removeErrorObserver(this.currentCase);
66  }
67 
76  void addProblems(String context, String errorMessage) {
77  this.newProblems += 1;
78  this.totalProblems += newProblems;
79 
80  long currentTimeStamp = System.currentTimeMillis();
81  if ((currentTimeStamp - lastReportedDate) > milliSecondsBetweenReports) {
82  this.lastReportedDate = currentTimeStamp;
83  MessageNotifyUtil.Notify.error(message, context + ", " + errorMessage + " "
84  + this.newProblems + " "
85  + NbBundle.getMessage(IntervalErrorReportData.class, "IntervalErrorReport.NewIssues")
86  + " " + this.totalProblems + " "
87  + NbBundle.getMessage(IntervalErrorReportData.class, "IntervalErrorReport.TotalIssues")
88  + ".");
89  this.newProblems = 0;
90  }
91  }
92 }
static void error(String title, String message)

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.