/*
 * Autopsy Forensic Browser
 *
 * Copyright 2019 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.actions;

import java.awt.event.ActionEvent;
import java.text.MessageFormat;
import java.util.logging.Level;
import javax.swing.AbstractAction;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException;
import org.sleuthkit.datamodel.TskCoreException;

public final class DeleteDataSourceAction extends AbstractAction {
    private static final Logger logger = Logger.getLogger(DeleteDataSourceAction.class.getName());
    private final Long selectDataSource;
    
    @NbBundle.Messages({"DeleteDataSourceAction.name.text=Delete Data Source"})
    public DeleteDataSourceAction(Long selectedDataSource) {
        super(Bundle.DeleteDataSourceAction_name_text());
        selectDataSource = selectedDataSource;

    }
    @NbBundle.Messages({"ErrorDeletingDataSource.name.text=Error Deleting Data Source"})
    @Override
    public void actionPerformed(ActionEvent event) {
        try {
            //VersionNumber checkVersionNumber = Case.getCurrentCaseThrows().getSleuthkitCase().getDBSchemaVersion();
            Case.getCurrentCaseThrows().getSleuthkitCase().deleteDataSource(selectDataSource);
            deleteDataSource(selectDataSource);
        } catch (NoCurrentCaseException | TskCoreException | KeywordSearchServiceException e) {
	    String msg = MessageFormat.format(Bundle.ErrorDeletingDataSource_name_text(), selectDataSource);
            logger.log(Level.WARNING, msg, e);
            //throw new TskCoreException(msg, e);
        }
    }
    private static void deleteDataSource(Long dataSourceId) throws KeywordSearchServiceException {
        try {
            KeywordSearchService kwsService = Lookup.getDefault().lookup(KeywordSearchService.class);
            kwsService.deleteDataSource(dataSourceId);
        } catch (KeywordSearchServiceException e) {
            logger.log(Level.WARNING, "KWS Error", e);
        }
        
    }
}

@@ -754,40 +754,8 @@
 nt;%0A
-import java.text.MessageFormat;%0A
 impo
@@ -1434,24 +1434,26 @@
  Long select
+ed
 DataSource;%0A
@@ -1664,22 +1664,29 @@
         
+this.
 select
+ed
 DataSour
@@ -1726,290 +1726,83 @@
    @
-NbBundle.Messages(%7B%22ErrorDeletingDataSource.name.text=Error Deleting Data Source%22%7D)%0A    @Override%0A    public void actionPerformed(ActionEvent event) %7B%0A        try %7B%0A            //VersionNumber checkVersionNumber = Case.getCurrentCaseThrows().getSleuthkitCase().getDBSchemaVersion();
+Override%0A    public void actionPerformed(ActionEvent event) %7B%0A        try %7B
 %0A   
@@ -1872,32 +1872,34 @@
 ataSource(select
+ed
 DataSource);%0A   
@@ -1926,24 +1926,26 @@
 ource(select
+ed
 DataSource);
@@ -2045,67 +2045,61 @@
 ) %7B%0A
-%09
+   
     
-String msg = MessageFormat.format(Bundle.
+     logger.log(Level.WARNING, %22
 Error
+ 
 Deleting
 Data
@@ -2098,38 +2098,33 @@
 ting
+ 
 Data
-S
+ s
 ource
-_name_text(),
+ %22 +
  select
+ed
 Data
@@ -2133,102 +2133,8 @@
 urce
-);%0A            logger.log(Level.WARNING, msg, e);%0A            //throw new TskCoreException(msg
 , e)

Update DeleteDataSourceAction.java