Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Jan 23, 2024
2 parents 949272e + e781acc commit 8bab532
Show file tree
Hide file tree
Showing 31 changed files with 951 additions and 429 deletions.
2 changes: 1 addition & 1 deletion docs/concepts/mark/event-marks.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Experimental.

== Use

In 4.7, the event marks are used exclusively in connection with xref:../simulation/[simulations].
In 4.7, the event marks are used exclusively in connection with xref:../../simulation/[simulations].
In the future we plan to extend their use to operations that are really executed, so they might be found in audit logs or on operational dashboards.

== Definition
Expand Down
2 changes: 1 addition & 1 deletion docs/simulation/results/metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ When searching for an object with given built-in metric set to 1, the query on t

== Event Mark-based Metrics

Each xref:../../mark/event-marks.adoc[event mark] present in the configuration is considered to be a simulation metric.
Each xref:../../concepts/mark/event-marks.adoc[event mark] present in the configuration is considered to be a simulation metric.
Values of such metric are either 1 (mark is present) or 0 (mark is not present).

There is a set of default event marks present among midPoint initial objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import com.evolveum.midpoint.repo.common.ObjectOperationPolicyHelper;

import com.evolveum.midpoint.repo.common.util.SubscriptionInformation;
import com.evolveum.midpoint.repo.common.subscription.SubscriptionState;
import com.evolveum.midpoint.schema.merger.AdminGuiConfigurationMergeManager;
import com.evolveum.midpoint.schema.result.OperationResultStatus;

Expand Down Expand Up @@ -330,14 +330,14 @@ public String getDescribe() {

@Override
public String getObject() {
SubscriptionInformation subscription = MidPointApplication.get().getSubscription();
if (!subscription.isCorrect()) {
SubscriptionState subscription = MidPointApplication.get().getSubscriptionState();
if (!subscription.isValid()) {
return " " + createStringResource("PageBase.nonActiveSubscriptionMessage").getString();
}
if (subscription.isDemo()) {
} else if (subscription.isDemo()) {
return " " + createStringResource("PageBase.demoSubscriptionMessage").getString();
} else {
return "";
}
return "";
}
});
subscriptionMessage.setOutputMarkupId(true);
Expand All @@ -357,7 +357,7 @@ public boolean isVisible() {
}

private boolean isFooterVisible() {
return MidPointApplication.get().getSubscription().isDemoOrIncorrect();
return MidPointApplication.get().getSubscriptionState().isInvalidOrDemo();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction;
import com.evolveum.midpoint.web.component.prism.DynamicFormPanel;
import com.evolveum.midpoint.web.component.prism.InputPanel;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.component.prism.show.VisualizationDto;
import com.evolveum.midpoint.web.component.prism.show.VisualizationUtil;
import com.evolveum.midpoint.web.component.util.Selectable;
Expand Down Expand Up @@ -3246,7 +3245,7 @@ private static VisualizationDto createTaskChangesDto(String titleKey, String box
}

public static String getMidpointCustomSystemName(PageAdminLTE pageBase, String defaultSystemNameKey) {
if (MidPointApplication.get().getSubscription().isDemoOrIncorrect()) {
if (MidPointApplication.get().getSubscriptionState().isInvalidOrDemo()) {
return pageBase.createStringResource(defaultSystemNameKey).getString();
}

Expand Down Expand Up @@ -4051,16 +4050,4 @@ protected PrismContainerDefinition<C> load() {
}
};
}

public static boolean isAssignmentAddedOrRemoved(PrismContainerWrapper<AssignmentType> assignmentsWrapper) {
if (assignmentsWrapper != null) {
for (PrismContainerValueWrapper<AssignmentType> assignmentWrapper : assignmentsWrapper.getValues()) {
if (ValueStatus.DELETED.equals(assignmentWrapper.getStatus()) ||
ValueStatus.ADDED.equals(assignmentWrapper.getStatus())) {
return true;
}
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.model.IModel;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -172,16 +171,4 @@ private <AH extends AssignmentHolderType> List<AssignmentObjectRelation> loadAss
}
return assignmentTargetRelations;
}

@Override
public void refreshTable(AjaxRequestTarget ajaxRequestTarget) {
super.refreshTable(ajaxRequestTarget);
var containerModelObject = getContainerModel() == null ? null : getContainerModel().getObject();
boolean isAssignmentAddedOrDeleted = WebComponentUtil.isAssignmentAddedOrRemoved(containerModelObject);
//MID-9380 we need enabled previously disabled Save/Preview changes buttons in case
// when the user has #assign or #unassign authorization
if (isAssignmentAddedOrDeleted) {
ajaxRequestTarget.add(getPageBase());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,25 +301,9 @@ protected void showMainPopup(Popupable popupable, AjaxRequestTarget target) {
getPageBase().showMainPopup(popupable, target);
}

@Override
protected boolean isSavePreviewButtonEnabled() {
//in case user isn't allowed to modify focus data but has
// e.g. #assign authorization, Save button is disabled on page load.
// Save button becomes enabled just if some changes are made
// on the Assignments tab (in the use case with #assign authorization)
// PrismContainerDefinition def = getObjectWrapper().getDefinition();
return !ItemStatus.NOT_CHANGED.equals(getModelObject().getStatus()) || getModelObject().canModify() ||
isAssignmentAddedOrRemoved();
}

//if the user has just #assign authorization (no #edit), we need to enable Save/Preview buttons
// when the assignments model is changed
public boolean isAssignmentAddedOrRemoved() {
try {
PrismContainerWrapper<AssignmentType> assignmentsWrapper = getModelObject().findContainer(AssignmentHolderType.F_ASSIGNMENT);
return WebComponentUtil.isAssignmentAddedOrRemoved(assignmentsWrapper);
} catch (SchemaException e) {
LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage());
return false;
}
!getModelObject().isReadOnly(); //this check was added due to MID-9380
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,34 @@
*/
package com.evolveum.midpoint.gui.impl.page.admin.component;

import java.util.List;

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper;
import com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto;
import com.evolveum.midpoint.model.api.ModelAuthorizationAction;
import com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto;
import com.evolveum.midpoint.web.page.admin.users.dto.UserDtoStatus;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationPhaseType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

public class UserOperationalButtonsPanel extends FocusOperationalButtonsPanel<UserType> {
private static final long serialVersionUID = 1L;

private LoadableModel<List<AssignmentEditorDto>> delegationsModel;

public UserOperationalButtonsPanel(String id, LoadableModel<PrismObjectWrapper<UserType>> model, LoadableModel<List<AssignmentEditorDto>> delegationsModel, LoadableModel<ExecuteChangeOptionsDto> executeOptionsModel, boolean isSelfProfile) {
public UserOperationalButtonsPanel(String id, LoadableModel<PrismObjectWrapper<UserType>> model, LoadableModel<ExecuteChangeOptionsDto> executeOptionsModel, boolean isSelfProfile) {
super(id, model, executeOptionsModel, isSelfProfile);
this.delegationsModel = delegationsModel;
}

@Override
protected boolean isSavePreviewButtonEnabled() {
//in case user isn't allowed to modify focus data but has
// e.g. #assign authorization, Save button is disabled on page load.
// Save button becomes enabled if some changes are made
// on the Delegations panel
return isDelegationAddedOrRemoved() || super.isSavePreviewButtonEnabled();
return isAuthorizedToModifyUsers() || super.isSavePreviewButtonEnabled();
}


//when the user has just #assign authorization (no #edit), we need to enable Save/Preview buttons
// when the delegations model is changed
public boolean isDelegationAddedOrRemoved() {
for (AssignmentEditorDto dto : delegationsModel.getObject()) {
if (UserDtoStatus.ADD.equals(dto.getStatus()) || UserDtoStatus.DELETE.equals(dto.getStatus())) {
return true;
}
private boolean isAuthorizedToModifyUsers() {
try {
return getPageBase().isAuthorized(ModelAuthorizationAction.MODIFY.getUrl(),
AuthorizationPhaseType.EXECUTION, new UserType().asPrismObject(), null, null);
} catch (Exception e) {
return false;
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected void collectObjectsForPreview(Map<PrismObject<UserType>, ModelContext<

@Override
protected UserOperationalButtonsPanel createButtonsPanel(String id, LoadableModel<PrismObjectWrapper<UserType>> wrapperModel) {
return new UserOperationalButtonsPanel(id, wrapperModel, getObjectDetailsModels().getDelegationsModel(), getObjectDetailsModels().getExecuteOptionsModel(), getObjectDetailsModels().isSelfProfile()) {
return new UserOperationalButtonsPanel(id, wrapperModel, getObjectDetailsModels().getExecuteOptionsModel(), getObjectDetailsModels().isSelfProfile()) {

private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import java.util.*;
import javax.xml.datatype.Duration;

import com.evolveum.midpoint.repo.common.subscription.Subscription;

import com.evolveum.midpoint.repo.common.subscription.SubscriptionStateCache;

import jakarta.servlet.ServletContext;
import org.apache.commons.configuration2.Configuration;
import org.apache.wicket.*;
Expand Down Expand Up @@ -91,8 +95,7 @@
import com.evolveum.midpoint.repo.api.*;
import com.evolveum.midpoint.repo.common.SystemObjectCache;
import com.evolveum.midpoint.repo.common.expression.ExpressionFactory;
import com.evolveum.midpoint.repo.common.util.SubscriptionInformation;
import com.evolveum.midpoint.repo.common.util.SubscriptionUtil;
import com.evolveum.midpoint.repo.common.subscription.SubscriptionState;
import com.evolveum.midpoint.schema.RelationRegistry;
import com.evolveum.midpoint.schema.SchemaService;
import com.evolveum.midpoint.schema.result.OperationResult;
Expand Down Expand Up @@ -162,6 +165,7 @@ public class MidPointApplication extends AuthenticatedWebApplication implements
@Autowired private Clock clock;
@Autowired private AccessCertificationService certificationService;
@Autowired private ActivationComputer activationComputer;
@Autowired private SubscriptionStateCache subscriptionStateCache;
@Autowired(required = false) private List<WicketConfigurator> wicketConfigurators = new ArrayList<>();
@Autowired @Qualifier("descriptorLoader") private DescriptorLoader descriptorLoader;
@Value("${midpoint.additionalPackagesToScan:}") private String additionalPackagesToScan;
Expand All @@ -170,7 +174,7 @@ public class MidPointApplication extends AuthenticatedWebApplication implements
private WebApplicationConfiguration webApplicationConfiguration;

private DeploymentInformationType deploymentInfo;
private SubscriptionInformation subscriptionInformation;
private Subscription subscription;

public static final String MOUNT_INTERNAL_SERVER_ERROR = "/error";
public static final String MOUNT_UNAUTHORIZED_ERROR = "/error/401";
Expand Down Expand Up @@ -328,10 +332,15 @@ public DeploymentInformationType getDeploymentInfo() {
return deploymentInfo;
}

@NotNull
public SubscriptionInformation getSubscription() {
// should not be null, unless called before initialization, in which case we provide default NONE
return Objects.requireNonNullElse(subscriptionInformation, SubscriptionUtil.createNoneSubscription());
public @NotNull SubscriptionState getSubscriptionState() {
var subscription = this.subscription;
if (subscription != null) {
// Should be always the case, maybe except the initialization.
return subscriptionStateCache.getSubscriptionState(subscription);
} else {
// This will try to get it from the current system configuration.
return subscriptionStateCache.getSubscriptionState();
}
}

private void initializeSchrodinger() {
Expand Down Expand Up @@ -571,7 +580,7 @@ public void update(@Nullable SystemConfigurationType value) {

private void updateDeploymentInfo(@Nullable SystemConfigurationType value) {
deploymentInfo = value != null ? value.getDeploymentInformation() : null;
subscriptionInformation = SubscriptionUtil.getSubscriptionInformation(value);
subscription = SubscriptionStateCache.getSubscription(value);
}

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,19 @@ private static String prepareConfiguration(LoggingConfigurationType config, Midp
return sb.toString();
}

/** "Extra" currently means "not file-based". */
public static boolean isExtraAppenderPresent(LoggingConfigurationType configBean) {
if (configBean == null) {
return false;
}
for (AppenderConfigurationType appenderBean : configBean.getAppender()) {
if (!(appenderBean instanceof FileAppenderConfigurationType)) {
return true;
}
}
return false;
}

private static void prepareAppenderConfiguration(StringBuilder sb, AppenderConfigurationType appender,
LoggingConfigurationType config, boolean isRoot, boolean createAltForThisAppender,
MidpointConfiguration midpointConfiguration) throws SchemaException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class RepositoryDiag implements Serializable {
*/
private String implementationDescription;

/** True if the repository is H2-based (always `false` for the native repository). */
private boolean isH2;

private boolean isEmbedded;

/**
Expand Down Expand Up @@ -75,6 +78,14 @@ public void setImplementationDescription(String implementationDescription) {
this.implementationDescription = implementationDescription;
}

public boolean isH2() {
return isH2;
}

public void setH2(boolean h2) {
isH2 = h2;
}

public boolean isEmbedded() {
return isEmbedded;
}
Expand Down

0 comments on commit 8bab532

Please sign in to comment.