From 87c69e18da2685f45e6ab24bd9efefe4680191c0 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Mon, 17 Apr 2017 16:23:43 -0400 Subject: [PATCH] Removed Solr upgrade JARs and IndexUpgrader class --- .../SolrUpgradeTools/Solr4IndexUpgrade.jar | Bin 2746 -> 0 bytes .../SolrUpgradeTools/Solr4IndexUpgrade.java | 69 ----- .../SolrUpgradeTools/Solr5IndexUpgrade.jar | Bin 2990 -> 0 bytes .../SolrUpgradeTools/Solr5IndexUpgrade.java | 70 ----- .../autopsy/keywordsearch/IndexUpgrader.java | 252 ------------------ 5 files changed, 391 deletions(-) delete mode 100644 KeywordSearch/SolrUpgradeTools/Solr4IndexUpgrade.jar delete mode 100644 KeywordSearch/SolrUpgradeTools/Solr4IndexUpgrade.java delete mode 100644 KeywordSearch/SolrUpgradeTools/Solr5IndexUpgrade.jar delete mode 100644 KeywordSearch/SolrUpgradeTools/Solr5IndexUpgrade.java delete mode 100644 KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/IndexUpgrader.java diff --git a/KeywordSearch/SolrUpgradeTools/Solr4IndexUpgrade.jar b/KeywordSearch/SolrUpgradeTools/Solr4IndexUpgrade.jar deleted file mode 100644 index 764fc7df8d95604dd1574b796216ab2761417c05..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2746 zcmaJ@O>@&m7=AW(qD0tygb==35D64JiL5wH3OJNvLfnSfj*CMel$p-j7LKSac_bM~ zZ~TK!PrdcRy&s2!X=doH2mV9^|1lElLJQgAN^ZHlo+{)D+%g{PuBUG3 zj%(OfMoFh;<8s#OTgf(gbxT)hjb2_$&Bx^>N9UeiQ*Uhx{MFR#x9RkpT1hV`i8Y5; zOqXZhudT)vDcS*p|AGT1cf+Pq@>M zs_^P}&$v@le5=Fuv}cvCs z(`yQEd3J-GsB+WXRx0#s8D=dm_XIMEYn#rzVb%2Kt!CZfH9b`pD=T8nQViVrAFRYlO>y#3=f;pg#C#z`!U;4@qq##I^DkdZNt zMG4o3@wtp4+z|6GhH+CuR>mPQKZIK{mT+6bvWz2GkdTvc3|~t4O2%=lh}#_rs}k}I zL)Q(<@NO_f63GpQ=o00M;Yi-F^kS<~(VcZ(F==HqZ&N%sxMPTUXEEw+87{-6d@vFL z&lZWiK`CPxPkfVq!k==@=-96Kd z+lHf8X|zp#4OMOHu~BE34uShcrul_+-!VMhS@OXoHoV_SB7#9Z{#(~@wQQ&1ghzAGOvRAEX@-ejCRR*SuX8io0d~XBFxF4EPb5?lOA=EIS6U)38AXsO zs@O`x%yg8AN1^~8dG;gU)d_}}uivmW;a&`7tV_5T!v^j%%pVX`*W*@=_9v>p_FzBC z49TEaUts%_C|r0z**j2RKNAAHDg33VP5Q;`vvxA71srBL+KcU4>&CIgL@d-9F=x4{O43;E8LIdH+Wip6bm`1{&OTHKx zDNK>c6rq**T4n#$6*|jYg)I7&=0fBr;vS^u+#U{XQV?Q0h`++&{2q>M?&4^1563pu zU5pm?aC~!mCc2BUO!Rbg2Pb;bIzzqy*Xc8LlY*S3_}nJHmdTf#@6CK$gYN?fHA$Y& zkX;H!$@dgla?+2$EJbLBxYC#-=Xx$Od`kQSm@loefw9PkPh^Cm>nQ%sif8xG)jpr~ zM8i&KLO@(EUrf`zE82HnJ4m@WNVG4Z{4W-Mtms)F4kGU#EcO{*zW6UxKCrj6j~S)a RK@oilSQKL<_``^p{SRo1xSRk0 diff --git a/KeywordSearch/SolrUpgradeTools/Solr4IndexUpgrade.java b/KeywordSearch/SolrUpgradeTools/Solr4IndexUpgrade.java deleted file mode 100644 index 97f0dfbdb9..0000000000 --- a/KeywordSearch/SolrUpgradeTools/Solr4IndexUpgrade.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2011-2016 Basis Technology Corp. - * Contact: carrier sleuthkit 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 solr4indexupgrade; - -import java.io.File; -import java.io.IOException; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.index.IndexUpgrader; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.store.Directory; -import org.apache.lucene.store.FSDirectory; - -/** - * This class upgrades Solr 4 index to Solr 5 index. - */ -public class Solr4IndexUpgrade { - - /** - * Upgrades Solr 4 index to Solr 5 index. - * @param args the command line arguments - * @throws java.io.IOException - */ - public static void main(String[] args) throws IOException { - - if (args.length != 1) { - System.out.println("Must pass 1 input argument"); - showUsage(); - throw new IllegalArgumentException("Must pass 1 argument"); - } - String solr4path = args[0]; - upgrade(solr4path); - } - - /** - * Display usage information for JDiff. - */ - public static void showUsage() { - System.out.println("usage: java -jar Solr4IndexUpgrade.jar \"\\path\\to\\index\""); - } - - private static void upgrade(String solr4path) throws IOException { - - Directory dir = FSDirectory.open(new File(solr4path).toPath()); - - // upgrade from Solr 4 to Solr 5 - IndexWriterConfig config; - Analyzer analyzer = new StandardAnalyzer(); - config = new IndexWriterConfig(analyzer); - IndexUpgrader upgrader = new IndexUpgrader(dir, config, true); - upgrader.upgrade(); - } -} diff --git a/KeywordSearch/SolrUpgradeTools/Solr5IndexUpgrade.jar b/KeywordSearch/SolrUpgradeTools/Solr5IndexUpgrade.jar deleted file mode 100644 index 9a18d23a983b61889e98689b6cc6568700661a7d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2990 zcmb7GOLNm!6#f)DQKH%eLP%*-K!lg`kcHC#Apu$w5-_n7gF_%CEtTaPM^u(Pl1y-S z%=CYBro*CLwu>aw%+OsIbkl#)RkvL-Jy$Zei4~^R*wTG`=Y8(EC%+hpNcvoK#+N#+)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Yj2X>)^qUSLFPV;ZG(F}Uh7HL>l$_e=M^2Ip4o1|?$>idNA w<|%l%@ZW{-R;r}|Z@%_7Q*SxEeDO~xeMd13TC4nGcMm7!0Uad5@5nvCzlqfcVE_OC diff --git a/KeywordSearch/SolrUpgradeTools/Solr5IndexUpgrade.java b/KeywordSearch/SolrUpgradeTools/Solr5IndexUpgrade.java deleted file mode 100644 index f434d71d8d..0000000000 --- a/KeywordSearch/SolrUpgradeTools/Solr5IndexUpgrade.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2011-2016 Basis Technology Corp. - * Contact: carrier sleuthkit 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 solr5indexupgrade; - -import java.io.File; -import java.io.IOException; -import org.apache.lucene.analysis.core.KeywordAnalyzer; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.index.UpgradeIndexMergePolicy; -import org.apache.lucene.store.Directory; -import org.apache.lucene.store.FSDirectory; - -/** - * This class upgrades Solr 5 index to Solr 6 index. - */ -public class Solr5IndexUpgrade { - - /** - * Upgrades Solr 5 index to Solr 6 index. - * @param args the command line arguments - * @throws java.io.IOException - */ - public static void main(String[] args) throws IOException { - - if (args.length != 1) { - System.out.println("Must pass 1 argument"); - showUsage(); - throw new IllegalArgumentException("Must pass 1 argument"); - } - String solr5path = args[0]; - upgrade(solr5path); - } - - /** - * Display usage information for JDiff. - */ - public static void showUsage() { - System.out.println("usage: java -jar Solr5IndexUpgrade.jar \"\\path\\to\\index\""); - } - - private static void upgrade(String solr4path) throws IOException { - - Directory dir = FSDirectory.open(new File(solr4path).toPath()); - - - // upgrade from Solr 5 to Solr 6 - IndexWriterConfig iwc = new IndexWriterConfig(new KeywordAnalyzer()); - iwc.setMergePolicy(new UpgradeIndexMergePolicy(iwc.getMergePolicy())); - IndexWriter w = new IndexWriter(dir, iwc); - w.forceMerge(1); - w.close(); - } -} diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/IndexUpgrader.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/IndexUpgrader.java deleted file mode 100644 index d355db1296..0000000000 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/IndexUpgrader.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2011-2017 Basis Technology Corp. - * Contact: carrier sleuthkit 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.keywordsearch; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.math.NumberUtils; -import org.openide.modules.InstalledFileLocator; -import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.coreutils.ExecUtil; -import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.coreutils.PlatformUtil; -import org.sleuthkit.autopsy.framework.AutopsyService; -import org.sleuthkit.autopsy.framework.ProgressIndicator; - -/** - * This class handles the task of upgrading old indexes to the latest supported - * Solr version. - */ -class IndexUpgrader { - - private static final Logger logger = Logger.getLogger(IndexFinder.class.getName()); - private final String JAVA_PATH; - - IndexUpgrader() { - JAVA_PATH = PlatformUtil.getJavaPath(); - } - - /** - * Perform Solr text index upgrade to the latest supported version of Solr. - * - * @param newIndexDir Full path to directory of Solr index to be - * upgraded - * @param indexToUpgrade Index object of the existing Solr index - * @param context AutopsyService.CaseContext object - * @param numCompletedWorkUnits Number of completed progress units so far - * - * @return Index object of the upgraded index, null if cancelled. - * - * @throws - * org.sleuthkit.autopsy.framework.AutopsyService.AutopsyServiceException - */ - @NbBundle.Messages({ - "SolrSearch.upgrade4to5.msg=Upgrading existing text index from Solr 4 to Solr 5", - "SolrSearch.upgrade5to6.msg=Upgrading existing text index from Solr 5 to Solr 6", - "SolrSearch.upgradeFailed.msg=Upgrade of existing Solr text index failed, deleting temporary directories",}) - Index performIndexUpgrade(String newIndexDir, Index indexToUpgrade, AutopsyService.CaseContext context, int startingNumCompletedWorkUnits) throws AutopsyService.AutopsyServiceException { - - int numCompletedWorkUnits = startingNumCompletedWorkUnits; - ProgressIndicator progress = context.getProgressIndicator(); - - // Run the upgrade tools on the contents (core) in ModuleOutput/keywordsearch/data/solrX_schema_Y/index - String tempResultsDir = context.getCase().getTempDirectory(); - File tmpDir = Paths.get(tempResultsDir, "IndexUpgrade").toFile(); //NON-NLS - tmpDir.mkdirs(); - - Index upgradedIndex; - int currentSolrVersion = NumberUtils.toInt(indexToUpgrade.getSolrVersion()); - try { - - if (context.cancelRequested()) { - return null; - } - - // create process terminator that will monitor the cancellation flag - UserCancelledProcessTerminator terminatior = new UserCancelledProcessTerminator(context); - - // upgrade from Solr 4 to 5 - numCompletedWorkUnits++; - progress.progress(Bundle.SolrSearch_upgrade4to5_msg(), numCompletedWorkUnits); - currentSolrVersion = upgradeSolrIndexVersion4to5(currentSolrVersion, newIndexDir, tempResultsDir, terminatior); - if (Thread.currentThread().isInterrupted() || context.cancelRequested()) { - return null; - } - - // upgrade from Solr 5 to 6 - numCompletedWorkUnits++; - progress.progress(Bundle.SolrSearch_upgrade5to6_msg(), numCompletedWorkUnits); - currentSolrVersion = upgradeSolrIndexVersion5to6(currentSolrVersion, newIndexDir, tempResultsDir, terminatior); - if (Thread.currentThread().isInterrupted() || context.cancelRequested()) { - return null; - } - - // create upgraded index object - upgradedIndex = new Index(newIndexDir, Integer.toString(currentSolrVersion), indexToUpgrade.getSchemaVersion(), context.getCase().getTextIndexName(), context.getCase().getName()); - return upgradedIndex; - - } catch (Exception ex) { - // catch-all firewall for exceptions thrown by Solr upgrade tools - // upgrade did not complete, delete the new index directories - progress.progress(Bundle.SolrSearch_upgradeFailed_msg(), numCompletedWorkUnits); - File newIndexVersionDir = new File(newIndexDir).getParentFile(); - try { - FileUtils.deleteDirectory(newIndexVersionDir); - } catch (IOException exx) { - logger.log(Level.SEVERE, String.format("Failed to delete %s when upgrade failed", newIndexVersionDir), exx); - } - throw new AutopsyService.AutopsyServiceException("Exception while running Solr index upgrade in " + newIndexDir, ex); //NON-NLS - } - } - - /** - * Upgrades Solr index from version 4 to 5. - * - * @param currentIndexVersion Current Solr index version - * @param solr4IndexPath Full path to Solr v4 index directory - * @param tempResultsDir Path to directory where to store log output - * @param terminator Implementation of ExecUtil.ProcessTerminator - * to terminate upgrade process - * - * @return The new Solr index version. - */ - private int upgradeSolrIndexVersion4to5(int currentIndexVersion, String solr4IndexPath, String tempResultsDir, UserCancelledProcessTerminator terminator) throws AutopsyService.AutopsyServiceException { - - if (currentIndexVersion != 4) { - return currentIndexVersion; - } - String outputFileName = "output.txt"; - logger.log(Level.INFO, "Upgrading KWS index {0} from Solr 4 to Solr 5", solr4IndexPath); //NON-NLS - - // find the index upgrade tool - final File upgradeToolFolder = InstalledFileLocator.getDefault().locate("Solr4to5IndexUpgrade", IndexFinder.class.getPackage().getName(), false); //NON-NLS - if (upgradeToolFolder == null) { - throw new AutopsyService.AutopsyServiceException("Unable to locate Sorl 4 to Solr 5 upgrade tool"); - } - - // full path to index upgrade jar file - File upgradeJarPath = Paths.get(upgradeToolFolder.getAbsolutePath(), "Solr4IndexUpgrade.jar").toFile(); - if (!upgradeJarPath.exists() || !upgradeJarPath.isFile()) { - throw new AutopsyService.AutopsyServiceException("Unable to locate Solr 4 to Solr 5 upgrade tool's JAR file"); - } - - // create log output directory if it doesn't exist - new File(tempResultsDir).mkdirs(); - - final String outputFileFullPath = Paths.get(tempResultsDir, outputFileName).toString(); - final String errFileFullPath = Paths.get(tempResultsDir, outputFileName + ".err").toString(); //NON-NLS - List commandLine = new ArrayList<>(); - commandLine.add(JAVA_PATH); - commandLine.add("-jar"); - commandLine.add(upgradeJarPath.getAbsolutePath()); - commandLine.add(solr4IndexPath); - ProcessBuilder processBuilder = new ProcessBuilder(commandLine); - processBuilder.redirectOutput(new File(outputFileFullPath)); - processBuilder.redirectError(new File(errFileFullPath)); - try { - ExecUtil.execute(processBuilder, terminator); - } catch (SecurityException | IOException ex) { - throw new AutopsyService.AutopsyServiceException("Error executing Solr 4 to Solr 5 upgrade tool"); - } - - // alternatively can execute lucene upgrade command from the folder where lucene jars are located - // java -cp ".;lucene-core-5.5.1.jar;lucene-backward-codecs-5.5.1.jar;lucene-codecs-5.5.1.jar;lucene-analyzers-common-5.5.1.jar" org.apache.lucene.index.IndexUpgrader \path\to\index - return 5; - } - - /** - * Upgrades Solr index from version 5 to 6. - * - * @param currentIndexVersion Current Solr index version - * @param solr5IndexPath Full path to Solr v5 index directory - * @param tempResultsDir Path to directory where to store log output - * @param terminatior Implementation of ExecUtil.ProcessTerminator - * to terminate upgrade process - * - * @return The new Solr index version. - */ - private int upgradeSolrIndexVersion5to6(int currentIndexVersion, String solr5IndexPath, String tempResultsDir, UserCancelledProcessTerminator terminator) throws AutopsyService.AutopsyServiceException, SecurityException, IOException { - if (currentIndexVersion != 5) { - return currentIndexVersion; - } - String outputFileName = "output.txt"; - logger.log(Level.INFO, "Upgrading KWS index {0} from Sorl 5 to Solr 6", solr5IndexPath); //NON-NLS - - // find the index upgrade tool - final File upgradeToolFolder = InstalledFileLocator.getDefault().locate("Solr5to6IndexUpgrade", IndexFinder.class.getPackage().getName(), false); //NON-NLS - if (upgradeToolFolder == null) { - throw new AutopsyService.AutopsyServiceException("Unable to locate Sorl 5 to Solr 6 upgrade tool"); - } - - // full path to index upgrade jar file - File upgradeJarPath = Paths.get(upgradeToolFolder.getAbsolutePath(), "Solr5IndexUpgrade.jar").toFile(); - if (!upgradeJarPath.exists() || !upgradeJarPath.isFile()) { - throw new AutopsyService.AutopsyServiceException("Unable to locate Sorl 5 to Solr 6 upgrade tool's JAR file"); - } - - // create log output directory if it doesn't exist - new File(tempResultsDir).mkdirs(); - - final String outputFileFullPath = Paths.get(tempResultsDir, outputFileName).toString(); - final String errFileFullPath = Paths.get(tempResultsDir, outputFileName + ".err").toString(); //NON-NLS - List commandLine = new ArrayList<>(); - commandLine.add(JAVA_PATH); - commandLine.add("-jar"); - commandLine.add(upgradeJarPath.getAbsolutePath()); - commandLine.add(solr5IndexPath); - ProcessBuilder processBuilder = new ProcessBuilder(commandLine); - processBuilder.redirectOutput(new File(outputFileFullPath)); - processBuilder.redirectError(new File(errFileFullPath)); - try { - ExecUtil.execute(processBuilder, terminator); - } catch (SecurityException | IOException ex) { - throw new AutopsyService.AutopsyServiceException("Error executing Solr 4 to Solr 5 upgrade tool"); - } - - // alternatively can execute lucene upgrade command from the folder where lucene jars are located - // java -cp ".;lucene-core-6.2.1.jar;lucene-backward-codecs-6.2.1.jar;lucene-codecs-6.2.1.jar;lucene-analyzers-common-6.2.1.jar" org.apache.lucene.index.IndexUpgrader \path\to\index - return 6; - } - - /** - * Process terminator that can be used to kill Solr index upgrade processes - * if a user has requested to cancel the upgrade. - */ - private class UserCancelledProcessTerminator implements ExecUtil.ProcessTerminator { - - AutopsyService.CaseContext context = null; - - UserCancelledProcessTerminator(AutopsyService.CaseContext context) { - this.context = context; - } - - @Override - public boolean shouldTerminateProcess() { - if (context.cancelRequested()) { - return true; - } - return false; - } - } -}