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 Oct 16, 2019
2 parents e4dd2a0 + ebff38f commit c340a87
Show file tree
Hide file tree
Showing 47 changed files with 347 additions and 2,981 deletions.
10 changes: 10 additions & 0 deletions build-system/pom.xml
Expand Up @@ -133,6 +133,12 @@
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>${reflections.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- WICKET -->
Expand Down Expand Up @@ -1375,6 +1381,10 @@
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Expand Up @@ -2287,9 +2287,6 @@ public boolean isMenuActive(WebPage page) {

private void addCollectionsMenuItems(List<MenuItem> menu, QName type, Class<? extends PageAdminObjectList> redirectToPage) {
List<CompiledObjectCollectionView> objectViews = getCompiledUserProfile().findAllApplicableObjectCollectionViews(type);
if (objectViews == null) {
return;
}
List<MenuItem> collectionMenuItems = new ArrayList<>(objectViews.size());
objectViews.forEach(objectView -> {
CollectionRefSpecificationType collectionRefSpec = objectView.getCollection();
Expand Down
Expand Up @@ -466,6 +466,9 @@ public String debugDump(int indent) {
DebugUtil.indentDebugDump(sb, indent);
sb.append(getClass().getSimpleName());
sb.append(": ").append(name);
if (id != null && !id.equals(name)) {
sb.append(" (").append(id).append(")");
}
if (!auxiliaryObjectClassNames.isEmpty()) {
sb.append("\n");
DebugUtil.debugDumpWithLabelToString(sb, "Auxiliary object classes", auxiliaryObjectClassNames, indent + 1);
Expand Down
Expand Up @@ -437,7 +437,6 @@ public interface Item<V extends PrismValue, D extends ItemDefinition> extends It

<IV extends PrismValue,ID extends ItemDefinition> PartiallyResolvedItem<IV,ID> findPartial(ItemPath path);


/**
* Creates specific subclass of ItemDelta appropriate for type of item that this definition
* represents (e.g. PropertyDelta, ContainerDelta, ...)
Expand All @@ -448,7 +447,6 @@ public interface Item<V extends PrismValue, D extends ItemDefinition> extends It

/**
* Accepts a visitor that visits each item/value on the way to the structure root.
* @param visitor
*/
void acceptParentVisitor(@NotNull Visitor visitor);

Expand Down Expand Up @@ -479,7 +477,8 @@ public interface Item<V extends PrismValue, D extends ItemDefinition> extends It
static <T extends Item> Collection<T> cloneCollection(Collection<T> items) {
Collection<T> clones = new ArrayList<>(items.size());
for (T item: items) {
clones.add((T)item.clone());
//noinspection unchecked
clones.add((T)item.clone());
}
return clones;
}
Expand All @@ -488,9 +487,11 @@ static <T extends Item> Collection<T> cloneCollection(Collection<T> items) {
* Sets all parents to null. This is good if the items are to be "transplanted" into a
* different Containerable.
*/
@SuppressWarnings("unused")
static <T extends Item> Collection<T> resetParentCollection(Collection<T> items) {
for (T item: items) {
item.setParent(null);
//noinspection unchecked
item.setParent(null);
}
return items;
}
Expand Down Expand Up @@ -527,6 +528,7 @@ static <T extends Item> Collection<T> resetParentCollection(Collection<T> items)

boolean hasNoValues();

@SuppressWarnings("unused")
static boolean hasNoValues(Item<?, ?> item) {
return item == null || item.getValues().isEmpty();
}
Expand Down
Expand Up @@ -23,6 +23,7 @@
* Basically, REAL_VALUE is oriented towards the effective content of the item or value.
* Contrary to IGNORE_METADATA it ignores element names and reference filters (if OID is present).
*/
@SuppressWarnings("unused")
public class ParameterizedEquivalenceStrategy implements EquivalenceStrategy {

/**
Expand Down Expand Up @@ -183,17 +184,29 @@ private static void putIntoNiceNames(ParameterizedEquivalenceStrategy strategy,
private boolean consideringReferenceFilters; // F
private boolean compareElementNames; // E

/**
* Whether we hash runtime-schema items. Setting this to "true" is dangerous because these can hold unparsed (raw) values
* so hashing them can break equals-hashcode contract. (See MID-5851.) Note that although statically (compile-time)
* defined items can hold raw values as well the probability is much lesser.
*
* This excludes e.g. attributes, extension items and resource/connector configuration elements.
*
* On the other hand we must be a bit careful because if we exclude too much from hashing, we can run into
* performance issues (see MID-5852).
*/
private boolean hashRuntimeSchemaItems; // R

public String getDescription() {
return (literalDomComparison ? "L" : "-") +
(consideringOperationalData ? "O" : "-") +
(consideringContainerIds ? "I" : "-") +
(consideringDifferentContainerIds ? "i" : "-") +
(consideringValueOrigin ? "o" : "-") +
(consideringReferenceFilters ? "F" : "-") +
(compareElementNames ? "E" : "-");
(compareElementNames ? "E" : "-") +
(hashRuntimeSchemaItems ? "R" : "-");
}


@Override
public boolean equals(Item<?, ?> first, Item<?, ?> second) {
return first == second || first != null && second != null && first.equals(second, this);
Expand Down Expand Up @@ -258,6 +271,7 @@ public void setConsideringDifferentContainerIds(boolean consideringDifferentCont
this.consideringDifferentContainerIds = consideringDifferentContainerIds;
}

@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isConsideringOperationalData() {
return consideringOperationalData;
}
Expand All @@ -274,6 +288,14 @@ public void setConsideringReferenceFilters(boolean consideringReferenceFilters)
this.consideringReferenceFilters = consideringReferenceFilters;
}

public boolean isHashRuntimeSchemaItems() {
return hashRuntimeSchemaItems;
}

public void setHashRuntimeSchemaItems(boolean hashRuntimeSchemaItems) {
this.hashRuntimeSchemaItems = hashRuntimeSchemaItems;
}

@Override
public String toString() {
String desc = getDescription();
Expand Down
Expand Up @@ -815,10 +815,14 @@ public int hashCode(@NotNull EquivalenceStrategy equivalenceStrategy) {

@Override
public int hashCode(@NotNull ParameterizedEquivalenceStrategy equivalenceStrategy) {
if (definition != null && definition.isRuntimeSchema() && !equivalenceStrategy.isHashRuntimeSchemaItems()) {
//System.out.println("HashCode is 0 because of runtime: " + this);
return 0;
}
int valuesHash = MiscUtil.unorderedCollectionHashcode(values, null);
if (valuesHash == 0) {
// empty or non-significant container. We do not want this to destroy hashcode of
// parent item
// empty or non-significant container. We do not want this to destroy hashcode of parent item
//System.out.println("HashCode is 0 because values hashCode is 0: " + this);
return 0;
}
final int prime = 31;
Expand All @@ -828,6 +832,7 @@ public int hashCode(@NotNull ParameterizedEquivalenceStrategy equivalenceStrateg
result = prime * result + ((localElementName == null) ? 0 : localElementName.hashCode());
}
result = prime * result + valuesHash;
//System.out.println("HashCode is " + result + " for: " + this);
return result;
}

Expand Down
@@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2019 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
Expand Down Expand Up @@ -46,10 +46,10 @@
public class DummyContainerImpl<C extends Containerable> implements PrismContainer<C> {
private static final long serialVersionUID = 1L;

private final ItemPath path;
@NotNull private final ItemPath path;
private final PrismContainer<C> realContainer;

public DummyContainerImpl(PrismContainer<C> realContainer, ItemPath path) {
public DummyContainerImpl(PrismContainer<C> realContainer, @NotNull ItemPath path) {
this.realContainer = realContainer;
this.path = path;
}
Expand All @@ -70,7 +70,7 @@ public Class<C> getCompileTimeClass() {
return realContainer.getCompileTimeClass();
}

public boolean canRepresent(Class<?> compileTimeClass) {
public boolean canRepresent(@NotNull Class<?> compileTimeClass) {
return realContainer.canRepresent(compileTimeClass);
}

Expand All @@ -86,15 +86,17 @@ public String getDisplayName() {
return realContainer.getDisplayName();
}

@NotNull
public Collection<C> getRealValues() {
return realContainer.getRealValues();
}

@NotNull
public C getRealValue() {
return realContainer.getRealValue();
}

public void setValue(PrismContainerValue<C> value) throws SchemaException {
public void setValue(@NotNull PrismContainerValue<C> value) throws SchemaException {
realContainer.setValue(value);
}

Expand Down Expand Up @@ -199,6 +201,7 @@ public <IV extends PrismValue, ID extends ItemDefinition, I extends Item<IV, ID>
return realContainer.findCreateItem(itemQName, type, create);
}

@NotNull
public ItemPath getPath() {
return path;
}
Expand All @@ -212,6 +215,7 @@ public <IV extends PrismValue, ID extends ItemDefinition> Item<IV, ID> findItem(
return realContainer.findItem(path);
}

@NotNull
public Map<String, Object> getUserData() {
return realContainer.getUserData();
}
Expand Down Expand Up @@ -314,7 +318,7 @@ public boolean isSingleValue() {
return realContainer.isSingleValue();
}

public boolean add(PrismContainerValue<C> newValue, boolean checkUniqueness) throws SchemaException {
public boolean add(@NotNull PrismContainerValue<C> newValue, boolean checkUniqueness) throws SchemaException {
return realContainer.add(newValue, checkUniqueness);
}

Expand All @@ -335,7 +339,7 @@ public void assertDefinitions(boolean tolarateRaw, String sourceDescription) thr
realContainer.assertDefinitions(tolarateRaw, sourceDescription);
}

public boolean add(PrismContainerValue<C> newValue) throws SchemaException {
public boolean add(@NotNull PrismContainerValue<C> newValue) throws SchemaException {
return realContainer.add(newValue);
}

Expand All @@ -351,7 +355,7 @@ public List<? extends ItemDelta> diffModifications(PrismContainer<C> other) {
return realContainer.diffModifications(other);
}

public boolean add(PrismContainerValue<C> newValue, EquivalenceStrategy equivalenceStrategy)
public boolean add(@NotNull PrismContainerValue<C> newValue, @NotNull EquivalenceStrategy equivalenceStrategy)
throws SchemaException {
return realContainer.add(newValue, equivalenceStrategy);
}
Expand Down Expand Up @@ -403,7 +407,7 @@ public boolean remove(PrismContainerValue<C> value) {
return realContainer.remove(value);
}

public boolean remove(PrismContainerValue<C> value, EquivalenceStrategy strategy) {
public boolean remove(PrismContainerValue<C> value, @NotNull EquivalenceStrategy strategy) {
return realContainer.remove(value, strategy);
}

Expand Down Expand Up @@ -432,31 +436,31 @@ public boolean equals(Object obj) {
return realContainer.equals(obj);
}

public boolean equals(Object obj, EquivalenceStrategy equivalenceStrategy) {
public boolean equals(Object obj, @NotNull EquivalenceStrategy equivalenceStrategy) {
return realContainer.equals(obj, equivalenceStrategy);
}

public boolean equals(Object obj, ParameterizedEquivalenceStrategy equivalenceStrategy) {
public boolean equals(Object obj, @NotNull ParameterizedEquivalenceStrategy equivalenceStrategy) {
return realContainer.equals(obj, equivalenceStrategy);
}

public int hashCode() {
return realContainer.hashCode();
}

public int hashCode(EquivalenceStrategy equivalenceStrategy) {
public int hashCode(@NotNull EquivalenceStrategy equivalenceStrategy) {
return realContainer.hashCode(equivalenceStrategy);
}

public int hashCode(ParameterizedEquivalenceStrategy equivalenceStrategy) {
public int hashCode(@NotNull ParameterizedEquivalenceStrategy equivalenceStrategy) {
return realContainer.hashCode(equivalenceStrategy);
}

public boolean contains(PrismContainerValue<C> value) {
return realContainer.contains(value);
}

public boolean contains(PrismContainerValue<C> value, EquivalenceStrategy strategy) {
public boolean contains(PrismContainerValue<C> value, @NotNull EquivalenceStrategy strategy) {
return realContainer.contains(value, strategy);
}

Expand All @@ -474,7 +478,7 @@ public boolean containsEquivalentValue(PrismContainerValue<C> value,
return realContainer.containsEquivalentValue(value, comparator);
}

public PrismContainerValue<C> findValue(PrismContainerValue<C> value, EquivalenceStrategy strategy) {
public PrismContainerValue<C> findValue(PrismContainerValue<C> value, @NotNull EquivalenceStrategy strategy) {
return realContainer.findValue(value, strategy);
}

Expand All @@ -490,7 +494,7 @@ public ItemDelta<PrismContainerValue<C>, PrismContainerDefinition<C>> diff(

public ItemDelta<PrismContainerValue<C>, PrismContainerDefinition<C>> diff(
Item<PrismContainerValue<C>, PrismContainerDefinition<C>> other,
ParameterizedEquivalenceStrategy strategy) {
@NotNull ParameterizedEquivalenceStrategy strategy) {
return realContainer.diff(other, strategy);
}

Expand All @@ -507,7 +511,7 @@ public void merge(Item<PrismContainerValue<C>, PrismContainerDefinition<C>> othe
realContainer.merge(otherItem);
}

public void acceptParentVisitor(Visitor visitor) {
public void acceptParentVisitor(@NotNull Visitor visitor) {
realContainer.acceptParentVisitor(visitor);
}

Expand Down Expand Up @@ -594,6 +598,7 @@ public void modifyUnfrozen(
realContainer.modifyUnfrozen(mutator);
}

@NotNull
public Collection<PrismValue> getAllValues(ItemPath path) {
return realContainer.getAllValues(path);
}
Expand Down

0 comments on commit c340a87

Please sign in to comment.