Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 20, 2023
2 parents 0a384b3 + 5d9348d commit 1357480
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper;
import com.evolveum.midpoint.gui.api.util.WebPrismUtil;
import com.evolveum.midpoint.gui.impl.component.menu.LeftMenuAuthzUtil;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -362,13 +364,28 @@ protected void postProcessResult(OperationResult result,

protected void navigateAction() {
Class<? extends PageBase> objectListPage = DetailsPageUtil.getObjectListPage(getType());
if (!canRedirectBack() && DetailsPageUtil.getObjectListPage(getType()) != null) {
var pageClass = DetailsPageUtil.getObjectListPage(getType());
if (!canRedirectBack() && pageClass != null && isAuthorized(pageClass)) {
navigateToNext(objectListPage);
} else {
redirectBack();
}
}

private boolean isAuthorized(Class<? extends PageBase> pageClass) {
try {
List<String> pageAuths = LeftMenuAuthzUtil.getAuthorizationsForPage(pageClass);
for (String auth : pageAuths) {
if (!isAuthorized(auth)) {
return false;
}
}
} catch (Exception e) {
//nothing to do here
}
return true;
}

protected Collection<ObjectDeltaOperation<? extends ObjectType>> executeChanges(Collection<ObjectDelta<? extends ObjectType>> deltas, boolean previewOnly, ExecuteChangeOptionsDto options, Task task, OperationResult result, AjaxRequestTarget target) {
if (noChangesToExecute(deltas, options)) {
if (!isShowedByWizard()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,21 @@ protected boolean showIcon() {

private InlineMenuItem createTaskViewMenuItem(StringResourceModel label, String archetypeOid, boolean isSimulationTasks) {
return new ButtonInlineMenuItemWithCount(label) {
@Override
protected boolean isBadgeVisible() {
if (!getPageBase().isNativeRepo()) {
return false;
}

return super.isBadgeVisible();
}

@Override
public int getCount() {
if (!getPageBase().isNativeRepo()) {
return 0;
}

ObjectQuery query = createQueryFroTasks(isSimulationTasks);
if (archetypeOid != null) {
query.addFilter(PrismContext.get()
Expand Down Expand Up @@ -527,10 +540,17 @@ public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
@Override
public void onClick(AjaxRequestTarget target) {

if (warnIfNonNative(target)) {
return;
}

redirectToTasksListPage(archetypeOid, isSimulationTasks);
}

};
}

};
}

Expand Down Expand Up @@ -605,7 +625,6 @@ private ObjectQuery createQueryFroTasks(boolean isSimulationTasks) {

}


return filter.build();
}

Expand Down Expand Up @@ -634,6 +653,19 @@ protected void createNewTaskPerformed(SynchronizationTaskFlavor flavor, boolean

}

private boolean warnIfNonNative(AjaxRequestTarget target) {
if (!getPageBase().isNativeRepo()) {
String warnMessage = getString("PageAdmin.operation.nonNativeRepositoryWarning");
String localeWarnMessage = getLocalizationService()
.translate(PolyString.fromOrig(warnMessage),
WebComponentUtil.getCurrentLocale(), true);
warn(localeWarnMessage);
target.add(getPageBase().getFeedbackPanel());
return true;
}
return false;
}

private void createNewTaskPerformed(SynchronizationTaskFlavor flavor, boolean isSimulation, AjaxRequestTarget target) {
var newTask = getPageBase().taskAwareExecutor(target, OP_CREATE_TASK)
.hideSuccessfulStatus()
Expand Down Expand Up @@ -666,6 +698,7 @@ private void createNewTaskPerformed(SynchronizationTaskFlavor flavor, boolean is
}

protected abstract UserProfileStorage.TableId getRepositorySearchTableId();

protected abstract StringResourceModel getLabelModel();

protected final RepositoryShadowBeanObjectDataProvider createProvider(IModel<Search<ShadowType>> searchModel, CompiledShadowCollectionView collection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ protected CompositedIconBuilder getDefaultCompositedIconBuilder(String basicIcon
return builder;
}

protected boolean isBadgeVisible() {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@

public abstract class ButtonInlineMenuItemWithCount extends ButtonInlineMenuItem {

public ButtonInlineMenuItemWithCount(IModel<String> labelModel){
public ButtonInlineMenuItemWithCount(IModel<String> labelModel) {
super(labelModel);
}

public ButtonInlineMenuItemWithCount(IModel<String> labelModel, boolean isSubmit){
public ButtonInlineMenuItemWithCount(IModel<String> labelModel, boolean isSubmit) {
super(labelModel, isSubmit);
}

protected abstract int getCount();

@Override
protected boolean isBadgeVisible() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ private void initLayout() {

Label badge = new Label(ID_MENU_ITEM_BADGE, () -> {
if (dto instanceof ButtonInlineMenuItemWithCount) {
return ((ButtonInlineMenuItemWithCount)dto).getCount();
return ((ButtonInlineMenuItemWithCount) dto).getCount();
}
return "";
});
badge.add(new VisibleBehaviour(() -> dto instanceof ButtonInlineMenuItemWithCount));
badge.add(new VisibleBehaviour(dto::isBadgeVisible));
getLinkContainer().add(badge);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
</td>
<td class="text-break" wicket:id="newValueContainer">
<div class="d-flex align-items-center gap-1">
<div class="d-flex align-items-center gap-1" wicket:id="newValueSubContainer">
<i wicket:id="newValueImage"/>
<div wicket:id="newValue"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class VisualizationItemLinePanel extends BasePanel<VisualizationItemLineD
private static final String ID_OLD_VALUE_IMAGE = "oldValueImage";
private static final String ID_OLD_VALUE = "oldValue";
private static final String ID_NEW_VALUE_CONTAINER = "newValueContainer";
private static final String ID_NEW_VALUE_SUB_CONTAINER = "newValueSubContainer";
private static final String ID_NEW_VALUE_IMAGE = "newValueImage";
private static final String ID_NEW_VALUE = "newValue";
private static final String ID_OLD_METADATA = "oldMetadata";
Expand Down Expand Up @@ -114,25 +115,34 @@ private void initLayout() {
}

WebMarkupContainer newValueCell = new WebMarkupContainer(ID_NEW_VALUE_CONTAINER);
sivp = new VisualizationItemValuePanel(ID_NEW_VALUE, () -> getModel().getObject().getNewValue());
sivp.setRenderBodyOnly(true);
newValueCell.add(sivp);
newValueCell.add(AttributeModifier.replace("colspan",
() -> !getModelObject().isDelta() && !getModelObject().isNullEstimatedOldValues() && getModelObject().isDeltaVisualization() ? 2 : 1));
newValueCell.add(AttributeModifier.replace("align",
() -> !getModelObject().isDelta() && !getModelObject().isNullEstimatedOldValues() && getModelObject().isDeltaVisualization() ? "center" : null));

WebMarkupContainer newValueSubContainer = new WebMarkupContainer(ID_NEW_VALUE_SUB_CONTAINER);
newValueSubContainer.add(AttributeModifier.append("class",
() -> !getModelObject().isDelta()
&& !getModelObject().isNullEstimatedOldValues()
&& getModelObject().isDeltaVisualization()
? "justify-content-center" : null));
newValueCell.add(newValueSubContainer);

sivp = new VisualizationItemValuePanel(ID_NEW_VALUE, () -> getModel().getObject().getNewValue());
sivp.setRenderBodyOnly(true);
newValueSubContainer.add(sivp);

IconComponent newValueImagePanel = new IconComponent(ID_NEW_VALUE_IMAGE, newValueIconModel, newValueTitleModel);
newValueImagePanel.add(new VisibleBehaviour(() -> {
VisualizationItemValue val = getModelObject().getNewValue();
return newValueIconModel.getObject() != null && val != null && val.getSourceValue() != null;
}));
newValueCell.add(newValueImagePanel);
newValueSubContainer.add(newValueImagePanel);

add(newValueCell);

initMetadataButton(oldValueCell, ID_OLD_METADATA, () -> getModelObject().getOldValue());
initMetadataButton(newValueCell, ID_NEW_METADATA, () -> getModelObject().getNewValue());
initMetadataButton(newValueSubContainer, ID_NEW_METADATA, () -> getModelObject().getNewValue());
}

private void initMetadataButton(WebMarkupContainer parent, String id, IModel<VisualizationItemValue> model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class VisualizationPanel extends BasePanel<VisualizationDto> {
private boolean operationalItemsVisible = false;

private IModel<String> overviewModel;
private final IModel<Boolean> minimalized;

public VisualizationPanel(String id, @NotNull IModel<VisualizationDto> model) {
this(id, model, false, true);
Expand All @@ -84,6 +85,7 @@ public VisualizationPanel(String id, @NotNull IModel<VisualizationDto> model, bo

this.advanced = advanced;
this.showOperationalItems = showOperationalItems;
minimalized = Model.of(model.getObject().isMinimized());
}

@Override
Expand All @@ -94,7 +96,7 @@ protected void onInitialize() {
initLayout();

if (!advanced && overviewModel.getObject() != null) {
getModelObject().setMinimized(true);
minimalized.setObject(true);
}
}

Expand Down Expand Up @@ -145,7 +147,7 @@ private void initLayout() {
headerPanel.add(new AjaxEventBehavior("click") {
@Override
protected void onEvent(AjaxRequestTarget target) {
headerOnClickPerformed(target, model);
headerOnClickPerformed(target);
}
});
add(headerPanel);
Expand Down Expand Up @@ -246,8 +248,8 @@ public void onClick(AjaxRequestTarget target) {
headerPanel.add(warning);

final AjaxIconButton minimize = new AjaxIconButton(ID_MINIMIZE,
() -> getModelObject().isMinimized() ? GuiStyleConstants.CLASS_ICON_EXPAND : GuiStyleConstants.CLASS_ICON_COLLAPSE,
() -> getModelObject().isMinimized() ? getString("prismOptionButtonPanel.maximize") : getString("prismOptionButtonPanel.minimize")) {
() -> minimalized.getObject() ? GuiStyleConstants.CLASS_ICON_EXPAND : GuiStyleConstants.CLASS_ICON_COLLAPSE,
() -> minimalized.getObject() ? getString("prismOptionButtonPanel.maximize") : getString("prismOptionButtonPanel.minimize")) {

@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
Expand All @@ -258,16 +260,15 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {

@Override
public void onClick(AjaxRequestTarget target) {
headerOnClickPerformed(target, VisualizationPanel.this.getModel());
headerOnClickPerformed(target);
}
};
minimize.add(new VisibleBehaviour(this::hasBodyContent));
headerPanel.add(minimize);

final WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
body.add(new VisibleBehaviour(() -> {
VisualizationDto dto = getModelObject();
if (dto.isMinimized()) {
if (minimalized.getObject()) {
return false;
}

Expand Down Expand Up @@ -319,9 +320,8 @@ protected boolean isExistingViewableObject() {
obj.getOid() != null && (visualization.getSourceDelta() == null || !visualization.getSourceDelta().isAdd());
}

public void headerOnClickPerformed(AjaxRequestTarget target, IModel<VisualizationDto> model) {
VisualizationDto dto = model.getObject();
dto.setMinimized(!dto.isMinimized());
public void headerOnClickPerformed(AjaxRequestTarget target) {
minimalized.setObject(!minimalized.getObject());
target.add(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void init() {
instance = this;
}

/** BEWARE! Do not use in constructors of Spring beans! */
public static ModelCommonBeans get() {
return instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ public ScriptExpressionFactory(
@NotNull PrismContext prismContext,
@NotNull Collection<FunctionLibraryBinding> builtInLibraryBindings,
@NotNull Collection<ScriptEvaluator> evaluators,
@NotNull ObjectResolver objectResolver) {
@NotNull ObjectResolver objectResolver,
@NotNull FunctionLibraryManager functionLibraryManager) {
this.prismContext = prismContext;
this.builtInLibraryBindings = Collections.unmodifiableCollection(builtInLibraryBindings);
registerEvaluators(evaluators);
this.objectResolver = objectResolver;
this.functionLibraryManager = ModelCommonBeans.get().functionLibraryManager; // TODO initialize via spring?
this.functionLibraryManager = functionLibraryManager;
}

@VisibleForTesting
Expand Down
1 change: 1 addition & 0 deletions model/model-impl/src/main/resources/ctx-model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
</list>
</constructor-arg>
<constructor-arg name="objectResolver" ref="modelObjectResolver"/>
<constructor-arg name="functionLibraryManager" ref="functionLibraryManager"/>
</bean>

<bean id="functionExpressionEvaluatorFactory"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
public class ExportMiningOptions extends BaseMiningOptions implements BasicExportOptions {

private static final String DELIMITER = ",";
public static final String P_OUTPUT = "-O";
public static final String P_OUTPUT = "-o";
public static final String P_OUTPUT_LONG = "--output";
public static final String P_OVERWRITE = "-ow";
public static final String P_OVERWRITE = "-O";
public static final String P_OVERWRITE_LONG = "--overwrite";
public static final String P_PREFIX_APPLICATION = "-arp";
public static final String P_PREFIX_APPLICATION_LONG = "--application-role-prefix";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;

import com.evolveum.midpoint.ninja.util.ConsoleFormat;

import org.apache.commons.io.FileUtils;

import com.evolveum.midpoint.ninja.action.Action;
import com.evolveum.midpoint.ninja.impl.NinjaException;
import com.evolveum.midpoint.ninja.util.ConsoleFormat;
import com.evolveum.midpoint.ninja.util.InputParameterException;
import com.evolveum.midpoint.ninja.util.NinjaUtils;

public class UpgradeInstallationAction extends Action<UpgradeInstallationOptions, Void> {
Expand All @@ -29,7 +29,7 @@ public String getOperationName() {
public Void execute() throws Exception {
final File distributionDirectory = options.getDistributionDirectory();
if (distributionDirectory == null) {
throw new NinjaException("Undefined distribution directory");
throw new InputParameterException("Undefined distribution directory option " + UpgradeInstallationOptions.P_DISTRIBUTION_DIRECTORY);
}

final boolean backupFiles = options.isBackup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class UpgradeInstallationOptions {

public static final String P_INSTALLATION_DIRECTORY = "--installation-directory";

@Parameter(names = { P_DISTRIBUTION_DIRECTORY }, descriptionKey = "upgradeInstallation.distributionDirectory", required = true)
@Parameter(names = { P_DISTRIBUTION_DIRECTORY }, descriptionKey = "upgradeInstallation.distributionDirectory")
private File distributionDirectory;

@Parameter(names = { P_BACKUP_INSTALLATION_DIRECTORY }, descriptionKey = "upgradeInstallation.backupInstallationDirectory")
Expand Down

0 comments on commit 1357480

Please sign in to comment.