Merge pull request #3184 from raman-bt/accounts_relationships

Updated the CommunicationsManager API usage for getCommunicationsCoun…
This commit is contained in:
Richard Cordovano 2017-11-08 09:39:31 -05:00 committed by GitHub
commit a0b27ae39d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 29 deletions

View File

@ -28,6 +28,7 @@ import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.Account;
import org.sleuthkit.datamodel.AccountDeviceInstance;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.CommunicationsFilter;
import org.sleuthkit.datamodel.CommunicationsManager;
@ -38,8 +39,8 @@ class AccountDetailsNode extends AbstractNode {
private final static Logger logger = Logger.getLogger(AccountDetailsNode.class.getName());
private final CommunicationsFilter filter; //TODO: Use this
AccountDetailsNode(Set<Account> accounts,CommunicationsFilter filter, CommunicationsManager commsManager) {
super(new AccountRelationshipChildren(accounts, commsManager, filter));
AccountDetailsNode(Set<AccountDeviceInstance> accountDeviceInstances, CommunicationsFilter filter, CommunicationsManager commsManager) {
super(new AccountRelationshipChildren(accountDeviceInstances, commsManager, filter));
this.filter = filter;
}
@ -48,12 +49,12 @@ class AccountDetailsNode extends AbstractNode {
*/
private static class AccountRelationshipChildren extends Children.Keys<BlackboardArtifact> {
private final Set<Account> accounts;
private final Set<AccountDeviceInstance> accountDeviceInstances;
private final CommunicationsManager commsManager;
private final CommunicationsFilter filter;//TODO: Use this
private final CommunicationsFilter filter;
private AccountRelationshipChildren(Set<Account> accounts, CommunicationsManager commsManager, CommunicationsFilter filter) {
this.accounts = accounts;
private AccountRelationshipChildren(Set<AccountDeviceInstance> accountDeviceInstances, CommunicationsManager commsManager, CommunicationsFilter filter) {
this.accountDeviceInstances = accountDeviceInstances;
this.commsManager = commsManager;
this.filter = filter;
}
@ -66,22 +67,15 @@ class AccountDetailsNode extends AbstractNode {
@Override
protected void addNotify() {
Set<BlackboardArtifact> keys = new HashSet<>();
for (Account account : accounts) {
List<Account> accountsWithRelationship = new ArrayList<>();
try {
accountsWithRelationship.addAll(commsManager.getAccountsWithRelationship(account)); //TODO: Use filter here
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Error loading with relationships to " + account, ex);
}
accountsWithRelationship.forEach(otherAcount -> {
try {
keys.addAll(commsManager.getRelationships(account, otherAcount)); //TODO:Use filter here
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Error loading relationships between " + account + " and " + otherAcount, ex);
}
});
try {
Set<BlackboardArtifact> communications = commsManager.getCommunications(accountDeviceInstances, filter);
keys = new HashSet<>(communications);
}
catch (TskCoreException ex) {
logger.log(Level.WARNING, "Error loading communications for accounts. ", ex);
}
setKeys(keys);
}
}

View File

@ -115,7 +115,7 @@ class AccountsRootChildren extends Children.Keys<AccountDeviceInstanceKey> {
}
long msgCount = 0;
try {
msgCount = commsManager.getRelationshipsCount(accountDeviceInstance.getAccount(), filter );
msgCount = commsManager.getCommunicationsCount(accountDeviceInstance, filter );
} catch (TskCoreException ex) {
LOGGER.log(Level.WARNING, "Failed to get message count for account", ex); //NON-NLS
}

View File

@ -306,7 +306,7 @@ final public class FiltersPanel extends javax.swing.JPanel {
final CommunicationsManager commsManager = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager();
List<AccountDeviceInstanceKey> accountDeviceInstanceKeys =
commsManager.getAccountDeviceInstancesWithRelationships(commsFilter)
commsManager.getAccountDeviceInstancesWithCommunications(commsFilter)
.stream()
.map(adi -> new AccountDeviceInstanceKey(adi, commsFilter))
.collect(Collectors.toList());

View File

@ -31,6 +31,7 @@ import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.directorytree.DataResultFilterNode;
import org.sleuthkit.datamodel.Account;
import org.sleuthkit.datamodel.AccountDeviceInstance;
import org.sleuthkit.datamodel.CommunicationsFilter;
import org.sleuthkit.datamodel.CommunicationsManager;
@ -71,13 +72,13 @@ final class MessageBrowser extends javax.swing.JPanel implements ExplorerManager
messagesResultPanel.setNode(null);
messagesResultPanel.setPath("");
} else {
Set<Account> accounts = new HashSet<>();
Set<AccountDeviceInstance> accountDeviceInstances = new HashSet<>();
CommunicationsFilter filter = null;
CommunicationsManager commsManager = null;
for (Node n : selectedNodes) {
if (n instanceof AccountDeviceInstanceNode) {
final AccountDeviceInstanceNode adiNode = (AccountDeviceInstanceNode) n;
accounts.add(adiNode.getAccountDeviceInstance().getAccount());
accountDeviceInstances.add(adiNode.getAccountDeviceInstance());
if (commsManager == null) {
commsManager = adiNode.getCommsManager();
}
@ -92,11 +93,11 @@ final class MessageBrowser extends javax.swing.JPanel implements ExplorerManager
logger.log(Level.WARNING, "Unexpected Node encountered: " + n.toString());
}
}
messagesResultPanel.setNode(new TableFilterNode(new DataResultFilterNode(new AccountDetailsNode(accounts, filter, commsManager),internalExplorerManager), true));
if (accounts.size() == 1) {
messagesResultPanel.setPath(Iterables.getOnlyElement(accounts).getAccountUniqueID());
messagesResultPanel.setNode(new TableFilterNode(new AccountDetailsNode(accountDeviceInstances, filter, commsManager), true));
if (accountDeviceInstances.size() == 1) {
messagesResultPanel.setPath(Iterables.getOnlyElement(accountDeviceInstances).getAccount().getAccountUniqueID());
} else {
messagesResultPanel.setPath(accounts.size() + " accounts");
messagesResultPanel.setPath(accountDeviceInstances.size() + " accounts");
}
}
}