7142 format file

This commit is contained in:
William Schaefer 2021-02-23 14:16:45 -05:00
parent 36671f2cef
commit b6bf611ce6

View File

@ -1,7 +1,20 @@
/* /*
* To change this license header, choose License Headers in Project Properties. * Central Repository
* To change this template file, choose Tools | Templates *
* and open the template in the editor. * Copyright 2017-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package org.sleuthkit.autopsy.centralrepository.contentviewer; package org.sleuthkit.autopsy.centralrepository.contentviewer;
@ -13,92 +26,92 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
/** /**
* Used as a key to ensure we eliminate duplicates from the result set by * Used as a key to ensure we eliminate duplicates from the result set by not
* not overwriting CR correlation instances. * overwriting CR correlation instances.
*/ */
final class UniquePathKey { final class UniquePathKey {
private static final Logger logger= Logger.getLogger(UniquePathKey.class.getName()); private static final Logger logger = Logger.getLogger(UniquePathKey.class.getName());
private final String dataSourceID; private final String dataSourceID;
private final String filePath; private final String filePath;
private final String type; private final String type;
private final String caseUUID; private final String caseUUID;
UniquePathKey(OtherOccurrenceNodeInstanceData nodeData) { UniquePathKey(OtherOccurrenceNodeInstanceData nodeData) {
super(); super();
dataSourceID = nodeData.getDeviceID(); dataSourceID = nodeData.getDeviceID();
if (nodeData.getFilePath() != null) { if (nodeData.getFilePath() != null) {
filePath = nodeData.getFilePath().toLowerCase(); filePath = nodeData.getFilePath().toLowerCase();
} else { } else {
filePath = null; filePath = null;
} }
type = nodeData.getType(); type = nodeData.getType();
String tempCaseUUID; String tempCaseUUID;
try {
tempCaseUUID = nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID();
} catch (CentralRepoException ignored) {
//non central repo nodeData won't have a correlation case
try { try {
tempCaseUUID = nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(); tempCaseUUID = Case.getCurrentCaseThrows().getName();
} catch (CentralRepoException ignored) { //place holder value will be used since correlation attribute was unavailble
//non central repo nodeData won't have a correlation case } catch (NoCurrentCaseException ex) {
try { logger.log(Level.WARNING, "Unable to get current case", ex);
tempCaseUUID = Case.getCurrentCaseThrows().getName(); tempCaseUUID = OtherOccurrencesPanel.getPlaceholderUUID();
//place holder value will be used since correlation attribute was unavailble
} catch (NoCurrentCaseException ex) {
logger.log(Level.WARNING, "Unable to get current case", ex);
tempCaseUUID = OtherOccurrencesPanel.getPlaceholderUUID();
}
} }
caseUUID = tempCaseUUID;
} }
caseUUID = tempCaseUUID;
}
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof UniquePathKey) { if (other instanceof UniquePathKey) {
UniquePathKey otherKey = (UniquePathKey) (other); UniquePathKey otherKey = (UniquePathKey) (other);
return (Objects.equals(otherKey.getDataSourceID(), this.getDataSourceID()) return (Objects.equals(otherKey.getDataSourceID(), this.getDataSourceID())
&& Objects.equals(otherKey.getFilePath(), this.getFilePath()) && Objects.equals(otherKey.getFilePath(), this.getFilePath())
&& Objects.equals(otherKey.getType(), this.getType()) && Objects.equals(otherKey.getType(), this.getType())
&& Objects.equals(otherKey.getCaseUUID(), this.getCaseUUID())); && Objects.equals(otherKey.getCaseUUID(), this.getCaseUUID()));
}
return false;
} }
return false;
}
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(getDataSourceID(), getFilePath(), getType(), getCaseUUID()); return Objects.hash(getDataSourceID(), getFilePath(), getType(), getCaseUUID());
} }
/** /**
* Get the type of this UniquePathKey. * Get the type of this UniquePathKey.
* *
* @return the type * @return the type
*/ */
String getType() { String getType() {
return type; return type;
} }
/** /**
* Get the file path for the UniquePathKey. * Get the file path for the UniquePathKey.
* *
* @return the filePath * @return the filePath
*/ */
String getFilePath() { String getFilePath() {
return filePath; return filePath;
} }
/** /**
* Get the data source id for the UniquePathKey. * Get the data source id for the UniquePathKey.
* *
* @return the dataSourceID * @return the dataSourceID
*/ */
String getDataSourceID() { String getDataSourceID() {
return dataSourceID; return dataSourceID;
} }
/** /**
* Get the case uuid for the UniquePathKey * Get the case uuid for the UniquePathKey
* *
* @return the case UUID * @return the case UUID
*/ */
String getCaseUUID() { String getCaseUUID() {
return caseUUID; return caseUUID;
} }
} }