Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Sep 28, 2020
2 parents 347f8ee + f2fc743 commit 2297d64
Show file tree
Hide file tree
Showing 25 changed files with 423 additions and 276 deletions.
Expand Up @@ -48,48 +48,6 @@ public TaskSummaryPanel(String id, IModel<TaskType> model, Refreshable refreshab
this.refreshable = refreshable;
}

@Override
protected void onInitialize() {
super.onInitialize();


// AutoRefreshPanel refreshTag = new AutoRefreshPanel(ID_TAG_REFRESH, createRefreshModel()) {
//
// @Override
// protected void refreshPerformed(AjaxRequestTarget target) {
// refreshable.refresh(target);
// }
//
// };
// AbstractAjaxTimerBehavior refreshingBehavior = new AbstractAjaxTimerBehavior(Duration.milliseconds(refreshable.getRefreshInterval())) {
// @Override
// protected void onTimer(AjaxRequestTarget ajaxRequestTarget) {
// LOGGER.trace("onTimer called for {}; enabled = {}", this, refreshTag.getModelObject().isEnabled());
// refreshable.refresh(ajaxRequestTarget);
//
// }
//
// @Override
// protected boolean shouldTrigger() {
// return refreshTag.getModelObject().isEnabled();
// }
// };
//
// refreshTag.add(new AttributeModifier("class", "summary-tag"));
//
// refreshTag.add(refreshingBehavior);
// refreshTag.setOutputMarkupId(true);
//
// getSummaryBoxPanel().add(refreshTag);
}

private IModel<AutoRefreshDto> createRefreshModel() {
AutoRefreshDto dto = new AutoRefreshDto();
dto.setEnabled(true);
dto.setInterval(refreshable.getRefreshInterval());
return Model.of(dto);
}

@Override
protected List<SummaryTag<TaskType>> getSummaryTagComponentList(){
List<SummaryTag<TaskType>> summaryTagList = new ArrayList<>();
Expand Down
Expand Up @@ -22,6 +22,12 @@
<level>ERROR</level>
<package>ro.isdc.wro.extensions.processor.css.Less4jProcessor</package>
</classLogger>
<classLogger>
<!-- disabled because INFO log during of creating
new authentication filter chain -->
<level>OFF</level>
<package>org.springframework.security.web.DefaultSecurityFilterChain</package>
</classLogger>
<classLogger>
<!-- disabled because of MID-744, helper insert messages on ERROR
level which should not be there (probably should be on TRACE) -->
Expand All @@ -43,7 +49,7 @@
<level>WARN</level>
<package>org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl</package>
</classLogger>
<!-- Diesabled because of MID-4636 -->
<!-- Disabled because of MID-4636 -->
<classLogger>
<level>OFF</level>
<package>org.hibernate.internal.ExceptionMapperStandardImpl</package>
Expand Down
1 change: 1 addition & 0 deletions gui/admin-gui/src/main/resources/logback.xml
Expand Up @@ -55,6 +55,7 @@
<logger name="org.springframework.boot.SpringApplication" level="INFO"/>

<logger name="ro.isdc.wro.extensions.processor.css.Less4jProcessor" level="ERROR"/>
<logger name="org.springframework.security.web.DefaultSecurityFilterChain" level="OFF"/>
<logger name="org.hibernate.engine.jdbc.spi.SqlExceptionHelper" level="OFF"/>
<logger name="org.hibernate.engine.jdbc.batch.internal.BatchingBatch" level="OFF"/>
<logger name="org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl" level="WARN"/>
Expand Down
17 changes: 17 additions & 0 deletions infra/prism-api/pom.xml
Expand Up @@ -66,6 +66,23 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<!-- TEST -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.tools</groupId>
<artifactId>test-ng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Expand Up @@ -16,6 +16,7 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import org.apache.commons.codec.binary.Base64;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.TestOnly;
import org.w3c.dom.Element;

import javax.xml.bind.annotation.XmlEnumValue;
Expand Down Expand Up @@ -136,7 +137,9 @@ public static XMLGregorianCalendar createXMLGregorianCalendar(Date date) {
}

public static XMLGregorianCalendar createXMLGregorianCalendar(String string) {
return getDatatypeFactory().newXMLGregorianCalendar(string);
// FIXME: We need to make gregorian calendar roundtrip to make sure time zone is included

return createXMLGregorianCalendar(getDatatypeFactory().newXMLGregorianCalendar(string));
}

public static XMLGregorianCalendar createXMLGregorianCalendarFromIso8601(String iso8601string) {
Expand All @@ -161,14 +164,16 @@ public static XMLGregorianCalendar createXMLGregorianCalendar(XMLGregorianCalend
if (cal == null) {
return null;
}
return getDatatypeFactory().newXMLGregorianCalendar(cal.toGregorianCalendar()); // TODO find a better way
return createXMLGregorianCalendar(cal.toGregorianCalendar()); // TODO find a better way
}

@TestOnly
public static XMLGregorianCalendar createXMLGregorianCalendar(int year, int month, int day, int hour, int minute,
int second, int millisecond, int timezone) {
return getDatatypeFactory().newXMLGregorianCalendar(year, month, day, hour, minute, second, millisecond, timezone);
}

@TestOnly
public static XMLGregorianCalendar createXMLGregorianCalendar(int year, int month, int day, int hour, int minute,
int second) {
return getDatatypeFactory().newXMLGregorianCalendar(year, month, day, hour, minute, second, 0, 0);
Expand Down Expand Up @@ -477,7 +482,8 @@ public static <T> T toJavaValue(String stringContent, Class<T> type, boolean exc
} else if (type.equals(GregorianCalendar.class)) {
return (T) getDatatypeFactory().newXMLGregorianCalendar(stringContent).toGregorianCalendar();
} else if (XMLGregorianCalendar.class.isAssignableFrom(type)) {
return (T) getDatatypeFactory().newXMLGregorianCalendar(stringContent);
// MID-6361: We need to make XmlGregorian - Gregorian - XmlGregorian roundtrip to make sure time zone is includded
return (T) createXMLGregorianCalendar(stringContent);
} else if (type.equals(ZonedDateTime.class)) {
return (T) ZonedDateTime.parse(stringContent);
} else if (Duration.class.isAssignableFrom(type)) {
Expand Down
Expand Up @@ -8,6 +8,7 @@
package com.evolveum.midpoint.schema.util;

import com.evolveum.midpoint.prism.util.CloneUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType;

public class OperationResultUtil {
Expand Down Expand Up @@ -47,4 +48,10 @@ public static OperationResultType shallowClone(OperationResultType result, boole
}
return clone;
}

public static boolean isSuccessful(OperationResultStatusType result) {
return OperationResultStatusType.SUCCESS.equals(result) ||
OperationResultStatusType.HANDLED_ERROR.equals(result) ||
OperationResultStatusType.WARNING.equals(result);
}
}
Expand Up @@ -109,7 +109,7 @@ public static OperationStatsType getAggregatedOperationStats(TaskType task, Pris
subTasks.forEach(subTask -> {
OperationStatsType operationStatsType = subTask.getOperationStats();
if (operationStatsType != null) {
IterativeTaskInformation.addTo(iterativeTaskInformation, operationStatsType.getIterativeTaskInformation(), true);
IterativeTaskInformation.addTo(iterativeTaskInformation, operationStatsType.getIterativeTaskInformation(), false);
SynchronizationInformation.addTo(synchronizationInformation, operationStatsType.getSynchronizationInformation());
ActionsExecutedInformation.addTo(actionsExecutedInformation, operationStatsType.getActionsExecutedInformation());
}
Expand Down
Expand Up @@ -14,7 +14,6 @@
import java.io.File;
import java.io.IOException;
import javax.xml.bind.JAXBElement;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

Expand All @@ -27,6 +26,7 @@
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.prism.util.PrismAsserts;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.util.SchemaTestConstants;
import com.evolveum.midpoint.util.exception.SchemaException;
Expand Down Expand Up @@ -162,7 +162,7 @@ public void testParseGenericObjectFromJaxb() throws Exception {
PrismAsserts.assertPropertyValue(extension, SchemaTestConstants.EXTENSION_INT_TYPE_ELEMENT, 1234);
PrismAsserts.assertPropertyValue(extension, SchemaTestConstants.EXTENSION_DOUBLE_TYPE_ELEMENT, 456.789D);
PrismAsserts.assertPropertyValue(extension, SchemaTestConstants.EXTENSION_LONG_TYPE_ELEMENT, 567890L);
XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar("2002-05-30T09:10:11");
XMLGregorianCalendar calendar = XmlTypeConverter.createXMLGregorianCalendar("2002-05-30T09:10:11");
PrismAsserts.assertPropertyValue(extension, SchemaTestConstants.EXTENSION_DATE_TYPE_ELEMENT, calendar);

//todo locations ????? how to test DOM ??????
Expand Down
Expand Up @@ -11,7 +11,6 @@
import java.io.File;
import java.util.Collection;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

Expand All @@ -24,6 +23,7 @@
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.util.PrismAsserts;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.schema.util.SchemaTestConstants;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.QNameUtil;
Expand Down Expand Up @@ -138,7 +138,7 @@ private void assertGenericObject(PrismObject<GenericObjectType> generic) throws
PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_INT_TYPE_ELEMENT, 1234);
PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_DOUBLE_TYPE_ELEMENT, 456.789D);
PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_LONG_TYPE_ELEMENT, 567890L);
XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar("2002-05-30T09:10:11");
XMLGregorianCalendar calendar = XmlTypeConverter.createXMLGregorianCalendar("2002-05-30T09:10:11");
PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_DATE_TYPE_ELEMENT, calendar);

}
Expand Down
Expand Up @@ -280,13 +280,7 @@ public static boolean equals(Object a, Object b) {
* this method will simply return null.
*/
public static @Nullable XMLGregorianCalendar asXMLGregorianCalendar(@Nullable Date date) {
if (date == null) {
return null;
} else {
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(date.getTime());
return DATATYPE_FACTORY.newXMLGregorianCalendar(gc);
}
return date == null ? null : asXMLGregorianCalendar(date.getTime());
}

public static @Nullable XMLGregorianCalendar asXMLGregorianCalendar(
Expand Down
Expand Up @@ -21,6 +21,8 @@
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.ObjectTreeDeltas;
import com.evolveum.midpoint.schema.ResourceShadowDiscriminator;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -109,4 +111,6 @@ default String dumpFocusPolicyRules(int indent) {
Long getSequenceCounter(String sequenceOid);

void setSequenceCounter(String sequenceOid, long counter);

String getTaskTreeOid(Task task, OperationResult result) throws SchemaException;
}
Expand Up @@ -1244,6 +1244,11 @@ public void setSequenceCounter(String sequenceOid, long counter) {
public String debugDump(int indent) {
return null;
}

@Override
public String getTaskTreeOid(Task task, OperationResult result) throws SchemaException {
return null;
}
};
}

Expand Down
Expand Up @@ -219,6 +219,8 @@ public enum ExportType {
@NotNull private transient final List<ObjectReferenceType> operationApprovedBy = new ArrayList<>();
@NotNull private transient final List<String> operationApproverComments = new ArrayList<>();

private String taskTreeOid;

public LensContext(Class<F> focusClass, PrismContext prismContext,
ProvisioningService provisioningService) {
Validate.notNull(prismContext, "No prismContext");
Expand Down Expand Up @@ -1730,6 +1732,13 @@ public boolean isExperimentalCodeEnabled() {
Boolean.TRUE.equals(systemConfiguration.asObjectable().getInternals().isEnableExperimentalCode());
}

public String getTaskTreeOid(Task task, OperationResult result) throws SchemaException {
if (taskTreeOid == null) {
taskTreeOid = task.getTaskTreeId(result);
}
return taskTreeOid;
}

public ObjectDeltaObject<F> getFocusOdoAbsolute() {
return focusContext != null ? focusContext.getObjectDeltaObjectAbsolute() : null;
}
Expand Down
Expand Up @@ -108,8 +108,7 @@ private <F extends ObjectType> boolean recordFocusOperationExecution(LensContext
List<LensObjectDeltaOperation<F>> executedDeltas = getExecutedDeltas(focusContext,
(Class<F>) objectNew.asObjectable().getClass(), clockworkException, result);
LOGGER.trace("recordFocusOperationExecution: executedDeltas: {}", executedDeltas.size());
return recordOperationExecution(objectNew, false, executedDeltas, now, context.getChannel(),
getSkipWhenSuccess(context), task, result);
return recordOperationExecution(context, objectNew, false, executedDeltas, now, task, result);
}

@NotNull
Expand Down Expand Up @@ -149,16 +148,14 @@ private <F extends ObjectType> void recordProjectionOperationExecution(LensConte
}
List<LensObjectDeltaOperation<ShadowType>> executedDeltas = getExecutedDeltas(projectionContext, ShadowType.class,
clockworkException, result);
recordOperationExecution(object, true, executedDeltas, now,
context.getChannel(), getSkipWhenSuccess(context), task, result);
recordOperationExecution(context, object, true, executedDeltas, now, task, result);
}

/**
* @return true if the operation execution was recorded (or would be recorded, but skipped because of the configuration)
*/
private <F extends ObjectType> boolean recordOperationExecution(PrismObject<F> object, boolean deletedOk,
List<LensObjectDeltaOperation<F>> executedDeltas, XMLGregorianCalendar now,
String channel, boolean skipWhenSuccess, Task task, OperationResult result)
private <O extends ObjectType, F extends ObjectType> boolean recordOperationExecution(LensContext<O> context, PrismObject<F> object, boolean deletedOk,
List<LensObjectDeltaOperation<F>> executedDeltas, XMLGregorianCalendar now, Task task, OperationResult result)
throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
OperationExecutionType operation = new OperationExecutionType(prismContext);
OperationResult summaryResult = new OperationResult("recordOperationExecution");
Expand All @@ -176,10 +173,11 @@ private <F extends ObjectType> boolean recordOperationExecution(PrismObject<F> o
LOGGER.trace("recordOperationExecution: skipping because oid is null for object = {}", object);
return false;
}
createTaskRef(context, operation, task, result);
summaryResult.computeStatus();
OperationResultStatusType overallStatus = summaryResult.getStatus().createStatusType();
setOperationContext(operation, overallStatus, now, channel, task, result);
storeOperationExecution(object, oid, operation, deletedOk, skipWhenSuccess, result);
setOperationContext(operation, overallStatus, now, context.getChannel(), task);
storeOperationExecution(object, oid, operation, deletedOk, getSkipWhenSuccess(context), result);
return true;
}

Expand Down Expand Up @@ -283,17 +281,31 @@ private <F extends ObjectType> void storeOperationExecution(@NotNull PrismObject
}

private void setOperationContext(OperationExecutionType operation,
OperationResultStatusType overallStatus, XMLGregorianCalendar now, String channel, Task task, OperationResult result) throws SchemaException {
OperationResultStatusType overallStatus, XMLGregorianCalendar now, String channel, Task task) {

operation.setStatus(overallStatus);
operation.setInitiatorRef(ObjectTypeUtil.createObjectRef(task.getOwner(), prismContext)); // TODO what if the real initiator is different? (e.g. when executing approved changes)
operation.setChannel(channel);
operation.setTimestamp(now);
}

private <O extends ObjectType> void createTaskRef(LensContext<O> context, OperationExecutionType operation, Task task, OperationResult result) {
if (task instanceof RunningTask && ((RunningTask) task).getParentForLightweightAsynchronousTask() != null) {
task = ((RunningTask) task).getParentForLightweightAsynchronousTask();
}
if (task.isPersistent()) {
operation.setTaskRef(ObjectTypeUtil.createObjectRef(task.getTaskTreeId(result), ObjectTypes.TASK));
String taskOid;
try {
taskOid = context.getTaskTreeOid(task, result);
} catch (SchemaException e) {
//if something unexpeced happened, let's try current task oid
LOGGER.warn("Cannot get task tree oid, current task oid will be used, task: {}, \nreason: {}", task, e.getMessage(), e);
result.recordWarning("Cannot get task tree oid, current task oid will be used, task: " + task + "\nreason: " + e.getMessage(), e);
taskOid = task.getOid();
}

operation.setTaskRef(ObjectTypeUtil.createObjectRef(taskOid, ObjectTypes.TASK));
}
operation.setStatus(overallStatus);
operation.setInitiatorRef(ObjectTypeUtil.createObjectRef(task.getOwner(), prismContext)); // TODO what if the real initiator is different? (e.g. when executing approved changes)
operation.setChannel(channel);
operation.setTimestamp(now);
}

private <F extends ObjectType> ObjectDeltaOperationType createObjectDeltaOperation(LensObjectDeltaOperation<F> deltaOperation) {
Expand Down
Expand Up @@ -43,7 +43,7 @@ public <O extends ObjectType> void execute(@NotNull ModelContext<O> context, Tas
return;
}

String id = task.getTaskTreeId(result);
String id = context.getTaskTreeOid(task, result);
if (id == null) {
LOGGER.trace("No persistent task context, no counting!");
return;
Expand Down

0 comments on commit 2297d64

Please sign in to comment.