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
katkav committed Oct 17, 2019
2 parents 9c91abf + dbc2f63 commit e94cd08
Show file tree
Hide file tree
Showing 68 changed files with 617 additions and 3,031 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 @@ -2286,9 +2286,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 @@ -327,7 +327,7 @@ public void onClick(AjaxRequestTarget target) {
}

private String getLocalizedPolyStringValue(){
return getPageBase().getLocalizationService().translate(getModelObject(), false);
return getPageBase().getLocalizationService().translate(getModelObject(), WebComponentUtil.getCurrentLocale(), false);
}

private IModel<List<String>> getLanguageChoicesModel(){
Expand Down
Expand Up @@ -296,11 +296,7 @@ private ObjectFilter createFilterForSearchValue(SearchItem item, DisplayableValu
}

public boolean isShowAdvanced() {
return showAdvanced;
}

public void setShowAdvanced(boolean showAdvanced) {
this.showAdvanced = showAdvanced;
return SearchBoxModeType.ADVANCED.equals(searchType);
}

public String getAdvancedQuery() {
Expand Down
Expand Up @@ -531,19 +531,6 @@ public String getObject() {
};
}

private VisibleEnableBehaviour createAdvancedVisibleBehaviour(final boolean showAdvanced) {
return new VisibleEnableBehaviour() {

private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() {
Search search = getModelObject();
return showAdvanced ? search.isShowAdvanced() : !search.isShowAdvanced();
}
};
}

private VisibleEnableBehaviour createVisibleBehaviour(SearchBoxModeType searchType) {
return new VisibleEnableBehaviour() {

Expand Down
Expand Up @@ -173,12 +173,7 @@ protected String getTableIdKeyValue(){

@Override
protected String getStorageKey() {
StringValue collectionName = getCollectionNameParameterValue();
String collectionNameValue = collectionName != null ? collectionName.toString() : "";
String key = isCollectionViewPage() ? WebComponentUtil.getObjectListPageStorageKey(collectionNameValue) :
super.getStorageKey();
//WebComponentUtil.getObjectListPageStorageKey(getType().getSimpleName()
return key;
return PageAdminObjectList.this.getStorageKey();
}

protected void setDefaultSorting(BaseSortableDataProvider<SelectableBean<O>> provider){
Expand All @@ -200,6 +195,14 @@ protected void setDefaultSorting(BaseSortableDataProvider<SelectableBean<O>> pro

protected void objectDetailsPerformed(AjaxRequestTarget target, O object){}

protected String getStorageKey(){
StringValue collectionName = getCollectionNameParameterValue();
String collectionNameValue = collectionName != null ? collectionName.toString() : "";
String key = isCollectionViewPage() ? WebComponentUtil.getObjectListPageStorageKey(collectionNameValue) :
WebComponentUtil.getObjectListPageStorageKey(getType().getSimpleName());
return key;
}

protected boolean isCreateNewObjectEnabled(){
return true;
}
Expand Down
Expand Up @@ -392,7 +392,6 @@ private void useInObjectListPerformed(AjaxRequestTarget target) {
}
Search search = SearchFactory.createSearch(request.getType(), this);
search.setAdvancedQuery(filterAsString);
search.setShowAdvanced(true);
search.setSearchType(SearchBoxModeType.ADVANCED);
if (!search.isAdvancedQueryValid(getPrismContext())) {
// shouldn't occur because the query was already parsed
Expand Down
Expand Up @@ -129,9 +129,10 @@ protected ExecuteChangeOptionsDto load() {
}

private void initSearch(String text){
PageStorage storage = getSessionStorage().getPageStorageMap().get(SessionStorage.KEY_USERS);
String storageKey = getStorageKey();
PageStorage storage = getSessionStorage().getPageStorageMap().get(storageKey);
if (storage == null) {
storage = getSessionStorage().initPageStorage(SessionStorage.KEY_USERS);
storage = getSessionStorage().initPageStorage(storageKey);
}
Search search = SearchFactory.createSearch(UserType.class, this);
if (SearchBoxModeType.FULLTEXT.equals(search.getSearchType())){
Expand All @@ -141,7 +142,7 @@ private void initSearch(String text){
searchItem.getValues().add(new SearchValue<>(text));
}
storage.setSearch(search);
getSessionStorage().getPageStorageMap().put(SessionStorage.KEY_USERS, storage);
getSessionStorage().getPageStorageMap().put(storageKey, storage);

}

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

0 comments on commit e94cd08

Please sign in to comment.