Skip to content

Commit

Permalink
Merge branch 'feature/manual-improvements' into post-3.7-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jan 9, 2018
2 parents 6c0fcab + e118c9e commit d972280
Show file tree
Hide file tree
Showing 67 changed files with 6,607 additions and 2,880 deletions.
Expand Up @@ -513,13 +513,15 @@ public String debugDump(int indent) {
if (values.isEmpty()) {
sb.append("[]");
} else {
String dump = null;
boolean multiline = false;
PrismPropertyValue<T> firstVal = values.iterator().next();
if (firstVal != null && !firstVal.isRaw() && firstVal.getValue() != null) {
if (DebugUtil.isDetailedDebugDump() && firstVal.getValue() instanceof DebugDumpable) {
multiline = true;
} else {
if (PrettyPrinter.prettyPrint(firstVal.getValue()).length() > MAX_SINGLELINE_LEN) {
dump = PrettyPrinter.debugDump(firstVal.getValue(), indent + 1);
if (dump.length() > MAX_SINGLELINE_LEN || dump.contains("\n")) {
multiline = true;
}
}
Expand All @@ -534,15 +536,18 @@ public String debugDump(int indent) {
} else if (value.getExpression() != null) {
sb.append(" (expression)");
} else {
T realValue = value.getValue();
if (realValue instanceof DebugDumpable) {
sb.append(((DebugDumpable)realValue).debugDump(indent + 1));
if (dump != null) {
sb.append(dump);
} else {
DebugUtil.indentDebugDump(sb, indent + 1);
if (DebugUtil.isDetailedDebugDump()) {
sb.append(PrettyPrinter.prettyPrint(value));
T realValue = value.getValue();
if (realValue instanceof DebugDumpable) {
sb.append(((DebugDumpable)realValue).debugDump(indent + 1));
} else {
PrismPrettyPrinter.debugDumpValue(sb, indent + 1, realValue, prismContext, getElementName(), null);
if (DebugUtil.isDetailedDebugDump()) {
PrismPrettyPrinter.debugDumpValue(sb, indent + 1, realValue, prismContext, getElementName(), null);
} else {
sb.append(PrettyPrinter.debugDump(value, indent + 1));
}
}
}
}
Expand Down
Expand Up @@ -26,6 +26,7 @@
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.ShortDumpable;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;

Expand All @@ -46,7 +47,7 @@
/**
* @author Radovan Semancik
*/
public class PrismReferenceValue extends PrismValue implements DebugDumpable, Serializable {
public class PrismReferenceValue extends PrismValue implements DebugDumpable, Serializable, ShortDumpable {
private static final long serialVersionUID = 1L;

private static final QName F_OID = new QName(PrismConstants.NS_TYPES, "oid");
Expand Down Expand Up @@ -646,23 +647,8 @@ public boolean match(PrismValue otherValue) {
@Override
public String toHumanReadableString() {
StringBuilder sb = new StringBuilder();
sb.append("oid=").append(oid);
if (getTargetType() != null) {
sb.append("(");
sb.append(DebugUtil.formatElementName(getTargetType()));
sb.append(")");
}
if (targetName != null) {
sb.append("('").append(targetName).append("')");
}
if (getRelation() != null) {
sb.append("[");
sb.append(getRelation().getLocalPart());
sb.append("]");
}
if (getObject() != null) {
sb.append('*');
}
sb.append("oid=");
shortDump(sb);
return sb.toString();
}

Expand Down Expand Up @@ -690,4 +676,25 @@ public void revive(PrismContext prismContext) throws SchemaException {
}
}

@Override
public void shortDump(StringBuilder sb) {
sb.append(oid);
if (getTargetType() != null) {
sb.append("(");
sb.append(DebugUtil.formatElementName(getTargetType()));
sb.append(")");
}
if (targetName != null) {
sb.append("('").append(targetName).append("')");
}
if (getRelation() != null) {
sb.append("[");
sb.append(getRelation().getLocalPart());
sb.append("]");
}
if (getObject() != null) {
sb.append('*');
}
}

}
Expand Up @@ -24,10 +24,16 @@
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.ModificationTypeType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.RawType;

import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;

import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -97,6 +103,95 @@ public static String prettyPrint(PrismReferenceValue prv, boolean showType) {
}
return sb.toString();
}

public static String prettyPrint(ObjectDeltaType deltaType) {
if (deltaType == null) {
return "null";
}
StringBuilder sb = new StringBuilder("ObjectDeltaType(");
sb.append(deltaType.getOid()).append(" ");
sb.append(deltaType.getChangeType());
sb.append(": ");
if (deltaType.getObjectToAdd() != null) {
sb.append(deltaType.getObjectToAdd());
} else {
sb.append("[");
Iterator<ItemDeltaType> iterator = deltaType.getItemDelta().iterator();
while (iterator.hasNext()) {
ItemDeltaType itemDelta = iterator.next();
shortPrettyPrint(sb, itemDelta);
if (iterator.hasNext()) {
sb.append(", ");
}
}
sb.append("]");
}
sb.append(")");
return sb.toString();
}

public static String prettyPrint(ItemDeltaType deltaType) {
if (deltaType == null) {
return "null";
}
StringBuilder sb = new StringBuilder("ItemDeltaType(");
shortPrettyPrint(sb, deltaType);
sb.append(")");
return sb.toString();
}

private static void shortPrettyPrint(StringBuilder sb, ItemDeltaType deltaType) {
ModificationTypeType modificationType = deltaType.getModificationType();
if (modificationType == ModificationTypeType.ADD) {
sb.append("(+)");
} else if (modificationType == ModificationTypeType.DELETE) {
sb.append("(-)");
} else if (modificationType == ModificationTypeType.REPLACE) {
sb.append("(=)");
}
sb.append(deltaType.getPath());
sb.append(": ");
List<RawType> values = deltaType.getValue();
if (values.isEmpty()) {
sb.append("[]");
} else if (values.size() == 1) {
values.get(0).shortDump(sb);
} else {
sb.append("[");
Iterator<RawType> iterator = values.iterator();
while (iterator.hasNext()) {
RawType value = iterator.next();
value.shortDump(sb);
if (iterator.hasNext()) {
sb.append(", ");
}
}
sb.append("]");
}
}

public static String debugDump(ObjectDeltaType deltaType, int indent) {
StringBuilder sb = DebugUtil.createTitleStringBuilder(ObjectDeltaType.class, indent);
if (deltaType == null) {
sb.append("null");
return sb.toString();
}
sb.append(deltaType.getOid()).append(" ");
sb.append(deltaType.getChangeType());
if (deltaType.getObjectToAdd() != null) {
sb.append("\n");
sb.append(deltaType.getObjectToAdd().asPrismObject().debugDump(indent + 1));
} else {
Iterator<ItemDeltaType> iterator = deltaType.getItemDelta().iterator();
while (iterator.hasNext()) {
sb.append("\n");
ItemDeltaType itemDelta = iterator.next();
DebugUtil.indentDebugDump(sb, indent + 1);
shortPrettyPrint(sb, itemDelta);
}
}
return sb.toString();
}

static {
PrettyPrinter.registerPrettyPrinter(PrismPrettyPrinter.class);
Expand All @@ -117,6 +212,10 @@ public static String debugDumpValue(int indent, Object value, PrismContext prism
// Note that expectedIndent applies only to lines after the first one. The caller is responsible for preparing
// indentation for the first line.
public static void debugDumpValue(StringBuilder sb, int expectedIndent, Object value, PrismContext prismContext, QName elementName, String defaultLanguage) {
if (value instanceof DebugDumpable) {
sb.append(((DebugDumpable)value).debugDump(expectedIndent));
return;
}
String formatted;
String language = DebugUtil.getPrettyPrintBeansAs() != null ? DebugUtil.getPrettyPrintBeansAs() : defaultLanguage;
if (elementName == null) {
Expand Down
Expand Up @@ -652,4 +652,9 @@ public static int compare(XMLGregorianCalendar o1, XMLGregorianCalendar o2) {
public static boolean isBeforeNow(XMLGregorianCalendar time) {
return toMillis(time) < System.currentTimeMillis();
}

public static boolean isAfterInterval(XMLGregorianCalendar reference, Duration interval, XMLGregorianCalendar now) {
XMLGregorianCalendar endOfInterval = addDuration(reference, interval);
return endOfInterval.compare(now) == DatatypeConstants.LESSER;
}
}
Expand Up @@ -5,8 +5,11 @@
import com.evolveum.midpoint.prism.xnode.PrimitiveXNode;
import com.evolveum.midpoint.prism.xnode.RootXNode;
import com.evolveum.midpoint.prism.xnode.XNode;
import com.evolveum.midpoint.util.ShortDumpable;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -21,7 +24,7 @@
/**
* A class used to hold raw XNodes until the definition for such an object is known.
*/
public class RawType implements Serializable, Cloneable, Equals, Revivable {
public class RawType implements Serializable, Cloneable, Equals, Revivable, ShortDumpable {
private static final long serialVersionUID = 4430291958902286779L;

/**
Expand Down Expand Up @@ -331,4 +334,25 @@ private void toStringExplicitType(StringBuilder sb) {
}
}
}

@Override
public void shortDump(StringBuilder sb) {
if (xnode != null) {
sb.append("(raw");
sb.append("):").append(xnode);
} else if (parsed != null) {
if (parsed instanceof ShortDumpable) {
((ShortDumpable)parsed).shortDump(sb);
} else {
Object realValue = parsed.getRealValue();
if (realValue == null) {
sb.append("null");
} else if (realValue instanceof ShortDumpable) {
((ShortDumpable)realValue).shortDump(sb);
} else {
sb.append(realValue.toString());
}
}
}
}
}
Expand Up @@ -249,6 +249,7 @@ public abstract class SchemaConstants {
public static final String NS_PROVISIONING = NS_MIDPOINT_PUBLIC + "/provisioning";
public static final String NS_PROVISIONING_LIVE_SYNC = NS_PROVISIONING + "/liveSync-3";
public static final QName SYNC_TOKEN = new QName(NS_PROVISIONING_LIVE_SYNC, "token");
public static final String NS_PROVISIONING_TASK = NS_PROVISIONING + "/task";

// Synchronization constants
public static final String NS_PROVISIONING_CHANNEL = NS_PROVISIONING + "/channels-3";
Expand Down
Expand Up @@ -37,6 +37,8 @@ public enum InternalCounters {
SCRIPT_EXECUTION_COUNT("scriptExecutionCount", "script execution count", null),

CONNECTOR_OPERATION_COUNT("connectorOperationCount", "connector operation count", InternalOperationClasses.CONNECTOR_OPERATIONS),

CONNECTOR_MODIFICATION_COUNT("connectorModificationCount", "connector modification count", InternalOperationClasses.CONNECTOR_OPERATIONS),

CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT("connectorSimulatedPagingSearchCount", "connector simulated paging search count", InternalOperationClasses.CONNECTOR_OPERATIONS),

Expand Down
Expand Up @@ -147,7 +147,14 @@ public static CachingStatistics getConnectorCacheStats() {
public static void recordConnectorOperation(String name) {
long count = recordCountInternal(InternalCounters.CONNECTOR_OPERATION_COUNT);
if (isTrace(InternalCounters.CONNECTOR_OPERATION_COUNT)) {
traceOperation("connector", () -> name, count, true);
traceOperation("connectorOperation", () -> name, count, true);
}
}

public static void recordConnectorModification(String name) {
long count = recordCountInternal(InternalCounters.CONNECTOR_MODIFICATION_COUNT);
if (isTrace(InternalCounters.CONNECTOR_MODIFICATION_COUNT)) {
traceOperation("connectorModification", () -> name, count, true);
}
}

Expand Down
Expand Up @@ -15,6 +15,8 @@
*/
package com.evolveum.midpoint.schema.result;

import com.evolveum.midpoint.util.ShortDumpable;

/**
* Primary goal of this class is to support asynchronous operations.
* The call to operation may return even if the resource operation
Expand All @@ -30,7 +32,7 @@
* @author semancik
*
*/
public class AsynchronousOperationResult {
public class AsynchronousOperationResult implements ShortDumpable {

private OperationResult operationResult;

Expand All @@ -51,4 +53,11 @@ public static AsynchronousOperationResult wrap(OperationResult result) {
public boolean isInProgress() {
return operationResult.isInProgress();
}

@Override
public void shortDump(StringBuilder sb) {
if (operationResult != null) {
sb.append(operationResult.getStatus());
}
}
}
Expand Up @@ -51,6 +51,8 @@ public class OperationConstants {
public static final String REINDEX = PREFIX + ".reindex";
public static final String AUDIT_REINDEX = PREFIX + ".auditReindex";
public static final String SHADOW_REFRESH = PREFIX + ".shadowRefresh";

public static final String PROVISIONING_PROPAGATION = "com.evolveum.midpoint.provisioning.propagation";

public static final String OPERATION_SEARCH_RESULT = "com.evolveum.midpoint.schema.result.searchResult";

Expand Down
Expand Up @@ -798,23 +798,6 @@ public static String prettyPrint(SynchronizationSituationDescriptionType syncDes
return sb.toString();
}

public static String prettyPrint(ObjectDeltaType deltaType) {
if (deltaType == null) {
return "null";
}
StringBuilder sb = new StringBuilder("ObjectDeltaType(");
sb.append(deltaType.getOid()).append(" ");
sb.append(deltaType.getChangeType());
sb.append(": ");
if (deltaType.getObjectToAdd() != null) {
sb.append(deltaType.getObjectToAdd());
} else {
sb.append(deltaType.getItemDelta());
}
sb.append(")");
return sb.toString();
}

public static String prettyPrint(ObjectDeltaOperationType deltaOpType) {
if (deltaOpType == null) {
return "null";
Expand Down

0 comments on commit d972280

Please sign in to comment.