Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
* 'master' of github.com:Evolveum/midpoint: (131 commits)
  MID-8932: fix NPE for mapping description
  MID-8842 ninja - improved progress reporting for older actions
  MID-8842 ninja - logging improvements
  MID-8761: adding resource name to translation of text and subText of resourc wizard panel for choice of next step
  MID-8842 ninja - logging improvements
  MID-8842 ninja - use AuditService#getRepositoryDiag method in ninja pre-upgrade check
  MID-8842 ninja - AuditService#getRepositoryDiag method added, code reused from existing repository service
  MID:8668 adding 'used' icon column for inbound mappings table
  removing enabled column from mapping tables
  MID-8842 ninja - download action log improvements
  adding stepId for wizard step panels
  MID-8842 ninja - more logging improvements
  MID-8842 ninja - improved ninja logging
  MID-8842 ninja - distribution manager improved message (not found)
  MID-8842 ninja - repository skip version check fix
  MID-8842 ninja - user dashboard processor + test
  MID-8842 ninja - user dashboard link processor + test
  fix for native repo sql upgrade script
  adding confirm popup about unsaved changes for exit from wizard
  fix for success login (schrodinger tests)
  ...
  • Loading branch information
katkav committed Aug 4, 2023
2 parents cd57675 + 55948ea commit 42c0b63
Show file tree
Hide file tree
Showing 611 changed files with 16,594 additions and 12,042 deletions.
44 changes: 44 additions & 0 deletions config/sql/native-new/postgres-new-upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,50 @@ call apply_change(15, $aa$
ALTER TABLE m_resource ADD abstract BOOLEAN;
$aa$);

-- Task Affected Indexing (Changes to types)
call apply_change(16, $aa$
ALTER TYPE ContainerType ADD VALUE IF NOT EXISTS 'AFFECTED_RESOURCE_OBJECTS' AFTER 'ACCESS_CERTIFICATION_WORK_ITEM';
ALTER TYPE ContainerType ADD VALUE IF NOT EXISTS 'AFFECTED_OBJECTS' AFTER 'AFFECTED_RESOURCE_OBJECTS';
$aa$);

-- Task Affected Indexing (tables)

call apply_change(17, $aa$
CREATE TABLE m_task_affected_resource_objects (
ownerOid UUID NOT NULL REFERENCES m_object_oid(oid) ON DELETE CASCADE,
containerType ContainerType GENERATED ALWAYS AS ('AFFECTED_RESOURCE_OBJECTS') STORED
CHECK (containerType = 'AFFECTED_RESOURCE_OBJECTS'),
objectClassId INTEGER REFERENCES m_uri(id),
resourceRefTargetOid UUID,
resourceRefTargetType ObjectType,
resourceRefRelationId INTEGER REFERENCES m_uri(id),
intent TEXT,
kind ShadowKindType,
PRIMARY KEY (ownerOid, cid)
) INHERITS(m_container);

CREATE TABLE m_task_affected_objects (
ownerOid UUID NOT NULL REFERENCES m_object_oid(oid) ON DELETE CASCADE,
containerType ContainerType GENERATED ALWAYS AS ('AFFECTED_OBJECTS') STORED
CHECK (containerType = 'AFFECTED_OBJECTS'),
type ObjectType,
archetypeRefTargetOid UUID,
archetypeRefTargetType ObjectType,
archetypeRefRelationId INTEGER REFERENCES m_uri(id),
PRIMARY KEY (ownerOid, cid)
) INHERITS(m_container);

$aa$);


-- Resource/super/resourceRef Indexing (tables)
call apply_change(18, $aa$
ALTER TABLE m_resource
ADD COLUMN superRefTargetOid UUID,
ADD COLUMN superRefTargetType ObjectType,
ADD COLUMN superRefRelationId INTEGER REFERENCES m_uri(id);
$aa$)
---
-- WRITE CHANGES ABOVE ^^
-- IMPORTANT: update apply_change number at the end of postgres-new.sql
-- to match the number used in the last change here!
Expand Down
32 changes: 30 additions & 2 deletions config/sql/native-new/postgres-new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,10 @@ CREATE TABLE m_resource (
connectorRefTargetType ObjectType,
connectorRefRelationId INTEGER REFERENCES m_uri(id),
template BOOLEAN,
abstract BOOLEAN
abstract BOOLEAN,
superRefTargetOid UUID,
superRefTargetType ObjectType,
superRefRelationId INTEGER REFERENCES m_uri(id)
)
INHERITS (m_assignment_holder);

Expand Down Expand Up @@ -1308,6 +1311,31 @@ CREATE INDEX m_task_ext_idx ON m_task USING gin(ext);
CREATE INDEX m_task_fullTextInfo_idx ON m_task USING gin(fullTextInfo gin_trgm_ops);
CREATE INDEX m_task_createTimestamp_idx ON m_task (createTimestamp);
CREATE INDEX m_task_modifyTimestamp_idx ON m_task (modifyTimestamp);

CREATE TABLE m_task_affected_resource_objects (
ownerOid UUID NOT NULL REFERENCES m_object_oid(oid) ON DELETE CASCADE,
containerType ContainerType GENERATED ALWAYS AS ('AFFECTED_RESOURCE_OBJECTS') STORED
CHECK (containerType = 'AFFECTED_RESOURCE_OBJECTS'),
objectClassId INTEGER REFERENCES m_uri(id),
resourceRefTargetOid UUID,
resourceRefTargetType ObjectType,
resourceRefRelationId INTEGER REFERENCES m_uri(id),
intent TEXT,
kind ShadowKindType,
PRIMARY KEY (ownerOid, cid)
) INHERITS(m_container);

CREATE TABLE m_task_affected_objects (
ownerOid UUID NOT NULL REFERENCES m_object_oid(oid) ON DELETE CASCADE,
containerType ContainerType GENERATED ALWAYS AS ('AFFECTED_OBJECTS') STORED
CHECK (containerType = 'AFFECTED_OBJECTS'),
type ObjectType,
archetypeRefTargetOid UUID,
archetypeRefTargetType ObjectType,
archetypeRefRelationId INTEGER REFERENCES m_uri(id),
PRIMARY KEY (ownerOid, cid)
) INHERITS(m_container);

-- endregion

-- region cases
Expand Down Expand Up @@ -2087,4 +2115,4 @@ END $$;
-- This is important to avoid applying any change more than once.
-- Also update SqaleUtils.CURRENT_SCHEMA_CHANGE_NUMBER
-- repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleUtils.java
call apply_change(15, $$ SELECT 1 $$, true);
call apply_change(18, $$ SELECT 1 $$, true);
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ <h5 class="text-center text-secondary mb-5" wicket:id="subText"/>
<i class="fas fa-right-from-bracket mr-2"></i>
<wicket:message key="WizardPanel.exit"/>
</a>
<a class="btn btn-primary" wicket:id="customButtons" />
<a class="btn btn-success" wicket:id="submit">
<i class="fas fa-check mr-2"/>
<span wicket:id="submitLabel"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

Expand All @@ -30,6 +31,8 @@ public class BasicWizardStepPanel<T> extends WizardStepPanel<T> {
private static final String ID_BACK = "back";
private static final String ID_EXIT = "exit";

private static final String ID_CUSTOM_BUTTONS = "customButtons";

private static final String ID_SUBMIT = "submit";
private static final String ID_SUBMIT_LABEL = "submitLabel";
private static final String ID_NEXT = "next";
Expand Down Expand Up @@ -84,6 +87,10 @@ public void onClick(AjaxRequestTarget target) {
WebComponentUtil.addDisabledClassBehavior(exit);
add(exit);

RepeatingView customButtons = new RepeatingView(ID_CUSTOM_BUTTONS);
add(customButtons);
initCustomButtons(customButtons);

AjaxSubmitButton submit = new AjaxSubmitButton(ID_SUBMIT) {

@Override
Expand Down Expand Up @@ -129,6 +136,9 @@ protected void onError(AjaxRequestTarget target) {
next.add(nextLabel);
}

protected void initCustomButtons(RepeatingView customButtons) {
}

protected boolean isSubmitEnable() {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.evolveum.midpoint.schema.result.OperationResultStatus;

import com.evolveum.midpoint.security.api.SecurityContextManager.ResultAwareCheckedProducer;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.wicket.Component;
Expand Down Expand Up @@ -749,8 +750,11 @@ public <T> T runPrivileged(Producer<T> producer) {
return securityContextManager.runPrivileged(producer);
}

public <T> T runAsChecked(CheckedProducer<T> producer, PrismObject<UserType> user) throws CommonException {
return securityContextManager.runAsChecked(producer, user);
public <T> T runAsChecked(
ResultAwareCheckedProducer<T> producer,
PrismObject<UserType> user,
OperationResult result) throws CommonException {
return securityContextManager.runAsChecked(producer, user, result);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@ public interface PrismContainerValueWrapper<C extends Containerable> extends Pri
int size();

PrismContainerValue<C> getContainerValueApplyDelta() throws SchemaException;

Collection<ItemDelta> getDeltas() throws SchemaException;
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.gui.impl.page.admin.org.PageOrgHistory;
import com.evolveum.midpoint.gui.impl.page.admin.role.PageRoleHistory;
import com.evolveum.midpoint.gui.impl.page.admin.service.PageServiceHistory;

import com.evolveum.midpoint.gui.impl.page.admin.user.PageUserHistory;

import com.evolveum.midpoint.gui.impl.page.login.PageLogin;
import com.evolveum.midpoint.prism.delta.*;
import com.evolveum.midpoint.web.security.MidPointAuthWebSession;
import com.evolveum.midpoint.web.component.dialog.Popupable;

Expand Down Expand Up @@ -143,10 +145,6 @@
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.crypto.EncryptionException;
import com.evolveum.midpoint.prism.crypto.Protector;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.DeltaFactory;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.PropertyDelta;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.path.ItemPathCollectionsUtil;
Expand Down Expand Up @@ -299,6 +297,50 @@ public static RestartResponseException restartOnLoginPageException() {
return new RestartResponseException(PageLogin.class);
}

public static void setTaskStateBeforeSave(
PrismObjectWrapper<TaskType> taskWrapper, boolean runEnabled, PageBase pageBase, AjaxRequestTarget target) {
try {
PrismPropertyWrapper<TaskExecutionStateType> executionState = taskWrapper.findProperty(ItemPath.create(TaskType.F_EXECUTION_STATE));
PrismPropertyWrapper<TaskSchedulingStateType> schedulingState = taskWrapper.findProperty(ItemPath.create(TaskType.F_SCHEDULING_STATE));
if (executionState == null || schedulingState == null) {
throw new SchemaException("Task cannot be set as running, no execution status or scheduling status present");
}

if (runEnabled) {
executionState.getValue().setRealValue(TaskExecutionStateType.RUNNABLE);
schedulingState.getValue().setRealValue(TaskSchedulingStateType.READY);
} else {
if (!ItemStatus.ADDED.equals(taskWrapper.getStatus())) {
return;
}
executionState.getValue().setRealValue(TaskExecutionStateType.SUSPENDED);
schedulingState.getValue().setRealValue(TaskSchedulingStateType.SUSPENDED);
}

PrismReferenceWrapper<Referencable> taskOwner = taskWrapper.findReference(ItemPath.create(TaskType.F_OWNER_REF));
if (taskOwner == null) {
return;
}
PrismReferenceValueWrapperImpl<Referencable> taskOwnerValue = taskOwner.getValue();
if (taskOwnerValue == null) {
return;
}

if (taskOwnerValue.getNewValue() == null || taskOwnerValue.getNewValue().isEmpty()) {
GuiProfiledPrincipal guiPrincipal = AuthUtil.getPrincipalUser();
if (guiPrincipal == null) {
//BTW something very strange must happened
return;
}
FocusType focus = guiPrincipal.getFocus();
taskOwnerValue.setRealValue(ObjectTypeUtil.createObjectRef(focus, SchemaConstants.ORG_DEFAULT));
}
} catch (SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Error while finishing task settings.", e);
target.add(pageBase.getFeedbackPanel());
}
}

public enum AssignmentOrder {

ASSIGNMENT(0),
Expand Down Expand Up @@ -2376,9 +2418,11 @@ private static String createSimulationResultIcon() {

public static ObjectFilter evaluateExpressionsInFilter(ObjectFilter objectFilter, VariablesMap variables, OperationResult result, PageBase pageBase) {
try {
return ExpressionUtil.evaluateFilterExpressions(objectFilter, variables, MiscSchemaUtil.getExpressionProfile(),
pageBase.getExpressionFactory(), pageBase.getPrismContext(), "collection filter",
pageBase.createSimpleTask(result.getOperation()), result);
return ExpressionUtil.evaluateFilterExpressions(
objectFilter, variables,
MiscSchemaUtil.getExpressionProfile(),
pageBase.getExpressionFactory(),
"collection filter", pageBase.createSimpleTask(result.getOperation()), result);
} catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException |
ConfigurationException | SecurityViolationException ex) {
result.recordPartialError("Unable to evaluate filter exception, ", ex);
Expand Down Expand Up @@ -5533,7 +5577,7 @@ public static IModel<String> createMappingDescription(IModel<PrismContainerValue

String target = "";
VariableBindingDefinitionType targetv = mappingType.getTarget();
if (targetv != null) {
if (targetv != null && targetv.getPath() != null) {
target += targetv.getPath().toString();
}

Expand Down Expand Up @@ -5732,6 +5776,26 @@ public static <O extends ObjectType> String getLabelForType(Class<O> type, boole
return translateMessage(ObjectTypeUtil.createTypeDisplayInformation(type.getSimpleName(), startsWithUppercase));
}

public static void showToastForRecordedButUnsavedChanges(AjaxRequestTarget target, PrismContainerValueWrapper value) {
Collection<ItemDelta> deltas = List.of();
try {
deltas = value.getDeltas();
} catch (SchemaException e) {
//couldn't get deltas of items
}

if (!deltas.isEmpty()) {
new Toast()
.warning()
.title(PageBase.createStringResourceStatic("WebComponentUtil.recordedButUnsavedChanges.title").getString())
.icon("fa fa-exclamation")
.autohide(true)
.delay(5_000)
.body(PageBase.createStringResourceStatic("WebComponentUtil.recordedButUnsavedChanges.body").getString())
.show(target);
}
}

/**
* @deprecated See {@link com.evolveum.midpoint.gui.api.util.LocalizationUtil}
*/
Expand Down

0 comments on commit 42c0b63

Please sign in to comment.