-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MID-8842 ninja - upgrade command, work started + some minor cleanup
(cherry picked from commit bb8630c)
- Loading branch information
Showing
13 changed files
with
159 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tools/ninja/src/main/java/com/evolveum/midpoint/ninja/action/ComplexAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (C) 2010-2023 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.ninja.action; | ||
|
||
import com.evolveum.midpoint.ninja.util.ConsoleFormat; | ||
|
||
public abstract class ComplexAction<O, R> extends Action<O, R> { | ||
|
||
protected <O, T> T executeAction(Action<O, T> action, O options) throws Exception { | ||
action.init(context, options); | ||
|
||
log.info(""); | ||
log.info(ConsoleFormat.formatActionStartMessage(action)); | ||
log.info(""); | ||
|
||
return action.execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
.../ninja/src/main/java/com/evolveum/midpoint/ninja/action/upgrade/action/UpgradeAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (C) 2010-2023 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.ninja.action.upgrade.action; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import com.evolveum.midpoint.ninja.action.ActionResult; | ||
import com.evolveum.midpoint.ninja.action.ComplexAction; | ||
import com.evolveum.midpoint.ninja.action.VerifyAction; | ||
import com.evolveum.midpoint.ninja.action.VerifyOptions; | ||
import com.evolveum.midpoint.ninja.util.NinjaUtils; | ||
|
||
public class UpgradeAction extends ComplexAction<UpgradeOptions, ActionResult<Void>> { | ||
|
||
@Override | ||
public String getOperationName() { | ||
return "upgrade"; | ||
} | ||
|
||
@Override | ||
public ActionResult<Void> execute() throws Exception { | ||
log.info("Do you want to run objects verification before upgrade? yes/skip/cancel (y/s/C) [y] "); | ||
String response = NinjaUtils.readInput(log, input -> StringUtils.isEmpty(input) || input.matches("[ysC]")); | ||
|
||
if (StringUtils.isEmpty(response) || "y".equalsIgnoreCase(response)) { | ||
VerifyOptions verifyOptions = new VerifyOptions(); | ||
// todo options | ||
executeAction(new VerifyAction(), verifyOptions); | ||
} | ||
|
||
if ("s".equalsIgnoreCase(response)) { | ||
log.warn("Skipping objects verification"); | ||
} | ||
|
||
if ("C".equals(response)) { | ||
return new ActionResult<>(null, 0, "Upgrade cancelled by user"); | ||
} | ||
|
||
// UpgradeObjectsOptions upgradeObjectsOptions = new UpgradeObjectsOptions(); | ||
// // todo options | ||
// executeAction(new UpgradeObjectsAction(), upgradeObjectsOptions); | ||
// | ||
// PreUpgradeCheckOptions preUpgradeCheckOptions = new PreUpgradeCheckOptions(); | ||
// // todo options | ||
// executeAction(new PreUpgradeCheckAction(), preUpgradeCheckOptions); | ||
// | ||
// DownloadDistributionOptions downloadDistributionOptions = new DownloadDistributionOptions(); | ||
// // todo options | ||
// executeAction(new DownloadDistributionAction(), downloadDistributionOptions); | ||
// | ||
// // todo run sql 2x | ||
// | ||
// UpgradeInstallationOptions upgradeInstallationOptions = new UpgradeInstallationOptions(); | ||
// executeAction(new UpgradeInstallationAction(), upgradeInstallationOptions); | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...ninja/src/main/java/com/evolveum/midpoint/ninja/action/upgrade/action/UpgradeOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (C) 2010-2023 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.ninja.action.upgrade.action; | ||
|
||
import com.beust.jcommander.Parameters; | ||
|
||
@Parameters(resourceBundle = "messages", commandDescriptionKey = "upgrade") | ||
public class UpgradeOptions { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters