|
12 | 12 | * information: "Portions Copyright [year] [name of copyright owner]". |
13 | 13 | * |
14 | 14 | * Portions Copyright 2013-2016 ForgeRock AS. |
15 | | - * Portions Copyright 2022 Wren Security |
| 15 | + * Portions Copyright 2022-2026 Wren Security |
16 | 16 | */ |
17 | 17 | package org.opends.server.tools.upgrade; |
18 | 18 |
|
19 | | -import static org.opends.server.util.SchemaUtils.addSchemaFileToElementDefinitionIfAbsent; |
20 | | - |
21 | | -import static java.nio.charset.StandardCharsets.*; |
22 | | -import static java.nio.file.StandardOpenOption.*; |
| 19 | +import static java.nio.charset.StandardCharsets.UTF_8; |
| 20 | +import static java.nio.file.StandardOpenOption.APPEND; |
23 | 21 | import static javax.security.auth.callback.ConfirmationCallback.NO; |
24 | 22 | import static javax.security.auth.callback.ConfirmationCallback.YES; |
25 | | -import static javax.security.auth.callback.TextOutputCallback.*; |
| 23 | +import static javax.security.auth.callback.TextOutputCallback.INFORMATION; |
26 | 24 | import static org.forgerock.util.Utils.joinAsString; |
27 | | -import static org.opends.messages.ToolMessages.*; |
| 25 | +import static org.opends.messages.ToolMessages.ERR_UPGRADE_ADDATTRIBUTE_FAILS; |
| 26 | +import static org.opends.messages.ToolMessages.ERR_UPGRADE_ADDOBJECTCLASS_FAILS; |
| 27 | +import static org.opends.messages.ToolMessages.ERR_UPGRADE_ADD_CONFIG_FILE_FAILS; |
| 28 | +import static org.opends.messages.ToolMessages.ERR_UPGRADE_CONFIG_ERROR_UPGRADE_FOLDER; |
| 29 | +import static org.opends.messages.ToolMessages.ERR_UPGRADE_COPYSCHEMA_FAILS; |
| 30 | +import static org.opends.messages.ToolMessages.ERR_UPGRADE_CORRUPTED_TEMPLATE; |
| 31 | +import static org.opends.messages.ToolMessages.ERR_UPGRADE_PERFORMING_POST_TASKS_FAIL; |
| 32 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_ALL_REBUILD_INDEX_DECLINED; |
| 33 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_CHANGE_DONE_IN_SPECIFIC_FILE; |
| 34 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_NO_CHANGE_DONE_IN_SPECIFIC_FILE; |
| 35 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_NO_INDEX_TO_REBUILD_FOR_BACKEND; |
| 36 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_REBUILD_ALL; |
| 37 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_REBUILD_INDEXES_DECLINED; |
| 38 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_REBUILD_INDEX_ARGUMENTS; |
| 39 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_REBUILD_INDEX_ENDS; |
| 40 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_REBUILD_INDEX_STARTS; |
| 41 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_ADD_CONFIG_FILE; |
| 42 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_ADD_SUBORDINATE_BASE_DN_TO_GLOBAL_CONFIG; |
| 43 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_CANNOT_READ_SCHEMA_FILE; |
| 44 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_CANNOT_WRITE_TO_CONCATENATED_SCHEMA_FILE; |
| 45 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_DELETE_CHANGELOG_SUMMARY; |
| 46 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_DELETE_FILE; |
| 47 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_DELETE_SUBORDINATE_BASE_DN_FROM_ROOT_DSE; |
| 48 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_MIGRATE_CHANGELOG_DESCRIPTION; |
| 49 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_MIGRATE_CONFIG_READ_FAIL; |
| 50 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_MIGRATE_JE_CANCELLED; |
| 51 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_MIGRATE_JE_DESCRIPTION; |
| 52 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_MIGRATE_JE_ENV_UNREADABLE; |
| 53 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_MIGRATE_JE_NO_JE_LIB; |
| 54 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_MIGRATE_JE_SUMMARY_1; |
| 55 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_MIGRATE_JE_SUMMARY_5; |
| 56 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_MIGRATE_JE_UGLY_DN; |
| 57 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_NEEDS_USER_CONFIRM; |
| 58 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_REFRESH_UPGRADE_DIRECTORY; |
| 59 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_REMOVE_OLD_JARS; |
| 60 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_REPLACE_SCHEMA_FILE; |
| 61 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_SUMMARY_RESTORE_CSV_DELIMITER_CHAR; |
| 62 | +import static org.opends.messages.ToolMessages.INFO_UPGRADE_TASK_UNABLE_TO_REMOVE_OLD_JARS; |
28 | 63 | import static org.opends.server.tools.upgrade.FileManager.copyRecursively; |
29 | | -import static org.opends.server.tools.upgrade.UpgradeUtils.*; |
30 | | -import static org.opends.server.util.StaticUtils.*; |
| 64 | +import static org.opends.server.tools.upgrade.UpgradeUtils.batDirectory; |
| 65 | +import static org.opends.server.tools.upgrade.UpgradeUtils.binDirectory; |
| 66 | +import static org.opends.server.tools.upgrade.UpgradeUtils.concatenatedSchemaFile; |
| 67 | +import static org.opends.server.tools.upgrade.UpgradeUtils.configDirectory; |
| 68 | +import static org.opends.server.tools.upgrade.UpgradeUtils.configFile; |
| 69 | +import static org.opends.server.tools.upgrade.UpgradeUtils.configSchemaDirectory; |
| 70 | +import static org.opends.server.tools.upgrade.UpgradeUtils.deleteFileIfExists; |
| 71 | +import static org.opends.server.tools.upgrade.UpgradeUtils.getInstancePath; |
| 72 | +import static org.opends.server.tools.upgrade.UpgradeUtils.libDirectory; |
| 73 | +import static org.opends.server.tools.upgrade.UpgradeUtils.searchConfigFile; |
| 74 | +import static org.opends.server.tools.upgrade.UpgradeUtils.templateConfigDirectory; |
| 75 | +import static org.opends.server.tools.upgrade.UpgradeUtils.templateConfigSchemaDirectory; |
| 76 | +import static org.opends.server.tools.upgrade.UpgradeUtils.updateConfigFile; |
| 77 | +import static org.opends.server.tools.upgrade.UpgradeUtils.updateConfigUpgradeSchemaFile; |
| 78 | +import static org.opends.server.tools.upgrade.UpgradeUtils.updateSchemaFile; |
| 79 | +import static org.opends.server.tools.upgrade.UpgradeUtils.deleteMatchingFiles; |
| 80 | +import static org.opends.server.util.SchemaUtils.addSchemaFileToElementDefinitionIfAbsent; |
| 81 | +import static org.opends.server.util.StaticUtils.isClassAvailable; |
| 82 | +import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
31 | 83 |
|
| 84 | +import com.forgerock.opendj.cli.ClientException; |
| 85 | +import com.forgerock.opendj.cli.ReturnCode; |
| 86 | +import com.sleepycat.je.DatabaseException; |
| 87 | +import com.sleepycat.je.Environment; |
| 88 | +import com.sleepycat.je.EnvironmentConfig; |
| 89 | +import com.sleepycat.je.Transaction; |
| 90 | +import com.sleepycat.je.TransactionConfig; |
32 | 91 | import java.io.BufferedWriter; |
33 | 92 | import java.io.File; |
34 | 93 | import java.io.FileReader; |
|
45 | 104 | import java.util.Set; |
46 | 105 | import java.util.TreeMap; |
47 | 106 | import java.util.TreeSet; |
48 | | - |
49 | 107 | import javax.security.auth.callback.TextOutputCallback; |
50 | | - |
51 | 108 | import org.forgerock.i18n.LocalizableMessage; |
52 | 109 | import org.forgerock.i18n.slf4j.LocalizedLogger; |
53 | 110 | import org.forgerock.opendj.ldap.Attribute; |
|
72 | 129 | import org.opends.server.util.ChangeOperationType; |
73 | 130 | import org.opends.server.util.StaticUtils; |
74 | 131 |
|
75 | | -import com.forgerock.opendj.cli.ClientException; |
76 | | -import com.forgerock.opendj.cli.ReturnCode; |
77 | | -import com.sleepycat.je.DatabaseException; |
78 | | -import com.sleepycat.je.Environment; |
79 | | -import com.sleepycat.je.EnvironmentConfig; |
80 | | -import com.sleepycat.je.Transaction; |
81 | | -import com.sleepycat.je.TransactionConfig; |
82 | | - |
83 | 132 | /** Factory methods for create new upgrade tasks. */ |
84 | 133 | final class UpgradeTasks |
85 | 134 | { |
@@ -1416,6 +1465,22 @@ public void perform(final UpgradeContext context) throws ClientException { |
1416 | 1465 | }; |
1417 | 1466 | } |
1418 | 1467 |
|
| 1468 | + static UpgradeTask removeMatchingJarFiles(final String... patterns) |
| 1469 | + { |
| 1470 | + return new AbstractUpgradeTask() { |
| 1471 | + @Override |
| 1472 | + public void perform(UpgradeContext context) throws ClientException { |
| 1473 | + try { |
| 1474 | + for (String pattern : patterns) { |
| 1475 | + deleteMatchingFiles(libDirectory.toPath(), pattern); |
| 1476 | + } |
| 1477 | + } catch (IOException e) { |
| 1478 | + throw new ClientException(ReturnCode.ERROR_UNEXPECTED, LocalizableMessage.raw(e.getMessage())); |
| 1479 | + } |
| 1480 | + } |
| 1481 | + }; |
| 1482 | + } |
| 1483 | + |
1419 | 1484 | /** Prevent instantiation. */ |
1420 | 1485 | private UpgradeTasks() |
1421 | 1486 | { |
|
0 commit comments