Skip to content

Commit

Permalink
MID-8842 ninja - updated initial objects action options
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Sep 6, 2023
1 parent 6cc058b commit f951ee2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import java.util.*;

// todo action should write XML + maybe csv? for review
public class InitialObjects extends Action<InitialObjectsOptions, ActionResult<InitialObjectsResult>> {
public class InitialObjectsAction extends Action<InitialObjectsOptions, ActionResult<InitialObjectsResult>> {

private static final String INITIAL_OBJECTS_RESOURCE_PATTERN = "classpath*:/initial-objects/**/*.xml";

Expand Down Expand Up @@ -175,6 +175,11 @@ private <O extends ObjectType> void addTrigger(PrismObject<O> object) {
private <O extends ObjectType> void addObject(
PrismObject<O> object, OperationResult result, InitialObjectsResult actionResult) {

if (!options.isForceAdd()) {
log.debug("Skipping object add, force-add options is not set, object will be correctly added during midpoint startup.");
return;
}

addTrigger(object);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.evolveum.midpoint.ninja.action.upgrade.action;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.beust.jcommander.Parameter;
Expand All @@ -24,6 +23,10 @@ public class InitialObjectsOptions {
public static final String P_OUTPUT_LONG = "--output";
public static final String P_REPORT = "-r";
public static final String P_REPORT_LONG = "--report";
public static final String P_FORCE_ADD = "--force-add";

@Parameter(names = { P_FORCE_ADD }, descriptionKey = "initialObjects.forceAdd")
private boolean forceAdd;

@Parameter(names = { P_FILES, P_FILES_LONG }, descriptionKey = "initialObjects.files")
private List<File> files;
Expand Down Expand Up @@ -68,4 +71,12 @@ public List<File> getFiles() {
public void setFiles(List<File> files) {
this.files = files;
}

public boolean isForceAdd() {
return forceAdd;
}

public void setForceAdd(boolean forceAdd) {
this.forceAdd = forceAdd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public enum Command {

UPGRADE("upgrade", UpgradeOptions.class, UpgradeAction.class),

INITIAL_OBJECTS("initial-objects", InitialObjectsOptions.class, InitialObjects.class);
INITIAL_OBJECTS("initial-objects", InitialObjectsOptions.class, InitialObjectsAction.class);

private final String commandName;

Expand Down
4 changes: 3 additions & 1 deletion tools/ninja/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ help.command=[Command name]
upgrade=Upgrade midPoint
initialObjects=Initial objects
initialObjects.dryRun=Dry run. In this mode no changes will be made to the repository.
initialObjects.output=Output file path. If file is not defined data will be printed out to SYSOUT.
initialObjects.output=Output file path for the report. This option is used only when --report is used. \
If file is not defined data will be printed out to SYSOUT.
initialObjects.report=If true, create report XML file that will contain all deltas.
initialObjects.files=Files/Directories for initial objects. Directories will be recursively searched for XML files. \
If this option is not specified, default initial objects set bundled withing ninja will be used. Files will be sorted by name.
initialObjects.forceAdd=Force add non yet existing initial objects. By default, objects will be added during midpoint startup.

0 comments on commit f951ee2

Please sign in to comment.