mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
6398 Persona deletion functionality
This commit is contained in:
parent
4235e4f264
commit
827561fd7a
@ -293,6 +293,14 @@ public class Persona {
|
||||
public void removeAccount(PersonaAccount account) throws CentralRepoException {
|
||||
PersonaAccount.removePersonaAccount(account.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks this persona as deleted
|
||||
*/
|
||||
public void delete() throws CentralRepoException {
|
||||
String deleteSQL = "UPDATE personas SET status_id = " + PersonaStatus.DELETED.status_id + " WHERE id = " + this.id;
|
||||
CentralRepository.getInstance().executeUpdateSQL(deleteSQL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to process a Persona query from the persona table.
|
||||
@ -364,7 +372,8 @@ public class Persona {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rows from the Personas table with matching name.
|
||||
* Gets the rows from the Personas table with matching name.
|
||||
* Persona marked as DELETED are not returned.
|
||||
*
|
||||
* @param partialName Name substring to match.
|
||||
* @return Collection of personas matching the given name substring, may be
|
||||
@ -376,7 +385,8 @@ public class Persona {
|
||||
public static Collection<Persona> getPersonaByName(String partialName) throws CentralRepoException {
|
||||
|
||||
String queryClause = PERSONA_QUERY
|
||||
+ "WHERE LOWER(p.name) LIKE " + "LOWER('%" + partialName + "%')" ;
|
||||
+ "WHERE p.status_id != " + PersonaStatus.DELETED.status_id +
|
||||
" AND LOWER(p.name) LIKE " + "LOWER('%" + partialName + "%')" ;
|
||||
|
||||
PersonaQueryCallback queryCallback = new PersonaQueryCallback();
|
||||
CentralRepository.getInstance().executeSelectSQL(queryClause, queryCallback);
|
||||
|
@ -53,3 +53,4 @@ AddAccountDialog.confidenceLbl.text=Confidence:
|
||||
AddAccountDialog.typeLbl.text=Type:
|
||||
AddAccountDialog.identiferLbl.text=Identifier:
|
||||
AddAccountDialog.identifierTextField.text=
|
||||
PersonaManagerTopComponent.deleteBtn.text=Delete Persona
|
||||
|
@ -560,7 +560,7 @@ public final class PersonaDetailsPanel extends javax.swing.JPanel {
|
||||
|
||||
void clear() {
|
||||
currentPersona = null;
|
||||
nameField.setText(Persona.getDefaultName());
|
||||
nameField.setText(mode == PersonaDetailsMode.CREATE ? Persona.getDefaultName() : "");
|
||||
currentAccounts = new ArrayList<>();
|
||||
currentMetadata = new ArrayList<>();
|
||||
currentAliases = new ArrayList<>();
|
||||
@ -714,8 +714,8 @@ public final class PersonaDetailsPanel extends javax.swing.JPanel {
|
||||
}
|
||||
|
||||
@Messages({
|
||||
"PersonaDetailsPanel_NotEnoughAccounts_msg=A persona needs two or more accounts",
|
||||
"PersonaDetailsPanel_NotEnoughAccounts_Title=Not enough accounts",
|
||||
"PersonaDetailsPanel_NotEnoughAccounts_msg=A persona needs at least one account",
|
||||
"PersonaDetailsPanel_NotEnoughAccounts_Title=Missing account",
|
||||
"PersonaDetailsPanel_CentralRepoErr_msg=Failure to write to Central Repository",
|
||||
"PersonaDetailsPanel_CentralRepoErr_Title=Central Repository failure",
|
||||
"PersonaDetailsPanel_EmptyName_msg=Persona name cannot be empty",
|
||||
|
@ -77,7 +77,8 @@
|
||||
<Component id="createBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="editBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="deleteBtn" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="resultsPane" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="searchField" max="32767" attributes="0"/>
|
||||
@ -110,6 +111,7 @@
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="editBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="createBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="deleteBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -208,6 +210,14 @@
|
||||
<AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="deleteBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/persona/Bundle.properties" key="PersonaManagerTopComponent.deleteBtn.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="org.sleuthkit.autopsy.centralrepository.persona.PersonaDetailsPanel" name="detailsPanel">
|
||||
|
@ -30,6 +30,7 @@ import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.openide.windows.RetainLocation;
|
||||
import org.openide.windows.TopComponent;
|
||||
@ -54,7 +55,9 @@ public final class PersonaManagerTopComponent extends TopComponent {
|
||||
private Persona selectedPersona = null;
|
||||
|
||||
@Messages({
|
||||
"PMTopComponent_Name=Persona Manager"
|
||||
"PMTopComponent_Name=Persona Manager",
|
||||
"PMTopComponent_delete_exception_Title=Delete failure",
|
||||
"PMTopComponent_delete_exception_msg=Failed to delete persona",
|
||||
})
|
||||
public PersonaManagerTopComponent() {
|
||||
initComponents();
|
||||
@ -83,6 +86,25 @@ public final class PersonaManagerTopComponent extends TopComponent {
|
||||
PersonaDetailsMode.CREATE, selectedPersona, new CreateEditCallbackImpl());
|
||||
}
|
||||
});
|
||||
|
||||
deleteBtn.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
if (selectedPersona != null) {
|
||||
selectedPersona.delete();
|
||||
}
|
||||
} catch (CentralRepoException ex) {
|
||||
logger.log(Level.SEVERE, "Failed to delete persona: " + selectedPersona.getName(), ex);
|
||||
JOptionPane.showMessageDialog(PersonaManagerTopComponent.this,
|
||||
Bundle.PMTopComponent_delete_exception_msg(),
|
||||
Bundle.PMTopComponent_delete_exception_Title(),
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
executeSearch();
|
||||
}
|
||||
});
|
||||
|
||||
// Results table
|
||||
resultsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
@ -116,6 +138,7 @@ public final class PersonaManagerTopComponent extends TopComponent {
|
||||
Persona persona = currentResults.get(index);
|
||||
selectedPersona = persona;
|
||||
editBtn.setEnabled(true);
|
||||
deleteBtn.setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,6 +170,8 @@ public final class PersonaManagerTopComponent extends TopComponent {
|
||||
if (selectedRow != -1) {
|
||||
setPersona(resultsTable.getSelectedRow());
|
||||
detailsPanel.setMode(this, PersonaDetailsMode.VIEW, selectedPersona);
|
||||
} else {
|
||||
detailsPanel.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,6 +214,7 @@ public final class PersonaManagerTopComponent extends TopComponent {
|
||||
resultsTable.clearSelection();
|
||||
updateResultsTable(results);
|
||||
editBtn.setEnabled(false);
|
||||
deleteBtn.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -216,6 +242,7 @@ public final class PersonaManagerTopComponent extends TopComponent {
|
||||
searchBtn = new javax.swing.JButton();
|
||||
editBtn = new javax.swing.JButton();
|
||||
createBtn = new javax.swing.JButton();
|
||||
deleteBtn = new javax.swing.JButton();
|
||||
detailsPanel = new org.sleuthkit.autopsy.centralrepository.persona.PersonaDetailsPanel();
|
||||
|
||||
setMinimumSize(new java.awt.Dimension(400, 400));
|
||||
@ -246,6 +273,9 @@ public final class PersonaManagerTopComponent extends TopComponent {
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(createBtn, org.openide.util.NbBundle.getMessage(PersonaManagerTopComponent.class, "PersonaManagerTopComponent.createBtn.text")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(deleteBtn, org.openide.util.NbBundle.getMessage(PersonaManagerTopComponent.class, "PersonaManagerTopComponent.deleteBtn.text")); // NOI18N
|
||||
deleteBtn.setEnabled(false);
|
||||
|
||||
javax.swing.GroupLayout searchPanelLayout = new javax.swing.GroupLayout(searchPanel);
|
||||
searchPanel.setLayout(searchPanelLayout);
|
||||
searchPanelLayout.setHorizontalGroup(
|
||||
@ -257,7 +287,8 @@ public final class PersonaManagerTopComponent extends TopComponent {
|
||||
.addComponent(createBtn)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(editBtn)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(deleteBtn))
|
||||
.addComponent(resultsPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||
.addComponent(searchField)
|
||||
.addGroup(searchPanelLayout.createSequentialGroup()
|
||||
@ -283,7 +314,8 @@ public final class PersonaManagerTopComponent extends TopComponent {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(editBtn)
|
||||
.addComponent(createBtn))
|
||||
.addComponent(createBtn)
|
||||
.addComponent(deleteBtn))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@ -304,6 +336,7 @@ public final class PersonaManagerTopComponent extends TopComponent {
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton createBtn;
|
||||
private javax.swing.JButton deleteBtn;
|
||||
private org.sleuthkit.autopsy.centralrepository.persona.PersonaDetailsPanel detailsPanel;
|
||||
private javax.swing.JButton editBtn;
|
||||
private javax.swing.JSplitPane jSplitPane1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user