Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HAL-1708/JBEAP-20551: correctly resolve metadata after server or host… #431

Merged
merged 1 commit into from
Jan 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions core/src/main/java/org/jboss/hal/core/finder/ColumnRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.inject.Inject;
import javax.inject.Provider;
Expand Down Expand Up @@ -66,29 +67,21 @@ public void registerColumn(String id, AsyncProvider column) {
}

void lookup(String id, LookupCallback callback) {
Set<String> resources = requiredResources.getResources(id);
if (resolvedColumns.containsKey(id)) {
if (resources.stream().anyMatch(r -> r.contains("{selected."))) {
// resources dependent on selected.host/server are processed for the current selection only
// if the column is already resolved resources need to be processed for the new selection
logger.debug("Column '{}' has the following required resources attached to it: {}", id, resources);
metadataProcessor.process(id, progress.get(), createAsyncCallback(id, callback, false));
}
callback.found(resolvedColumns.get(id));

} else {
logger.debug("Try to lookup column '{}'", id);
if (!requiredResources.getResources(id).isEmpty()) {
if (!resources.isEmpty()) {
// first of all process the required resources attached to this column
logger.debug("Column '{}' has the following required resources attached to it: {}", id,
requiredResources.getResources(id));
metadataProcessor.process(id, progress.get(), new AsyncCallback<Void>() {
@Override
public void onFailure(final Throwable throwable) {
//noinspection HardCodedStringLiteral
callback.error("Unable to load required resources for column '" + id +
((throwable != null) ? "': " + throwable.getMessage() : "'"));
}

@Override
public void onSuccess(final Void aVoid) {
lookupInternal(id, callback);
}
});

logger.debug("Column '{}' has the following required resources attached to it: {}", id, resources);
metadataProcessor.process(id, progress.get(), createAsyncCallback(id, callback, true));
} else {
logger.debug("No required resources attached to column '{}'", id);
lookupInternal(id, callback);
Expand Down Expand Up @@ -134,6 +127,23 @@ private void resolve(String id, FinderColumn column) {
resolvedColumns.put(id, column);
}

private AsyncCallback<Void> createAsyncCallback(String id, LookupCallback callback, boolean lookUpOnSuccess) {
return new AsyncCallback<Void>() {
@Override
public void onFailure(final Throwable throwable) {
//noinspection HardCodedStringLiteral
callback.error("Unable to load required resources for column '" + id +
((throwable != null) ? "': " + throwable.getMessage() : "'"));
}

@Override
public void onSuccess(final Void aVoid) {
if (lookUpOnSuccess) {
lookupInternal(id, callback);
}
}
};
}

interface LookupCallback {

Expand Down