This repository has been archived by the owner on Mar 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
[HAL-1287] - add capability to display warnings that come from WFCORE… #383
Open
baranowb
wants to merge
2
commits into
hal:master
Choose a base branch
from
baranowb:HAL-1287
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
dmr/src/main/java/org/jboss/as/console/client/shared/state/WarningNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.jboss.as.console.client.shared.state; | ||
|
||
import java.util.logging.Level; | ||
|
||
import com.google.gwt.event.shared.EventHandler; | ||
import com.google.gwt.event.shared.GwtEvent; | ||
|
||
public class WarningNotification extends GwtEvent<WarningNotification.Handler> { | ||
|
||
public static final Type<WarningNotification.Handler> TYPE = new Type<WarningNotification.Handler>(); | ||
private final String warning; | ||
private final Level severity; | ||
public WarningNotification(final String warning, final Level serverity) { | ||
this.warning = warning; | ||
this.severity = serverity; | ||
} | ||
|
||
@Override | ||
public Type<Handler> getAssociatedType() { | ||
return TYPE; | ||
} | ||
|
||
@Override | ||
protected void dispatch(Handler listener) { | ||
listener.onWarning(this.warning, this.severity); | ||
} | ||
|
||
public interface Handler extends EventHandler { | ||
public void onWarning(String warning, Level level); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
dmr/src/main/java/org/jboss/as/console/client/shared/state/WarningProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.jboss.as.console.client.shared.state; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.logging.Level; | ||
|
||
import org.jboss.dmr.client.ModelNode; | ||
import org.jboss.dmr.client.Property; | ||
import org.jboss.dmr.client.notify.Notifications; | ||
|
||
public class WarningProcessor implements ResponseProcessor { | ||
|
||
protected static final String LEVEL = "level"; | ||
protected static final String RESPONSE_HEADERS = "response-headers"; | ||
protected static final String RESULT = "result"; | ||
protected static final String STEP_1 = "step-1"; | ||
protected static final String WARNING = "warning"; | ||
protected static final String WARNINGS = "warnings"; | ||
|
||
@Override | ||
public boolean accepts(ModelNode response) { | ||
// result->step-x->response-headers->warnings | ||
if (response.hasDefined(RESULT)) { | ||
final ModelNode result = response.get(RESULT); | ||
if (result.hasDefined(STEP_1)) { | ||
final List<Property> steps = result.asPropertyList(); | ||
for (Property step : steps) { | ||
final ModelNode stepContent = step.getValue(); | ||
if (stepContent.hasDefined(RESPONSE_HEADERS) && stepContent.get(RESPONSE_HEADERS).hasDefined(WARNINGS)) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void process(ModelNode response, Map<String, ServerState> serverStates) { | ||
final List<ModelNode> warnings = fetchWarnings(response); | ||
for (ModelNode warning : warnings) { | ||
final WarningNotification warningNotification = new WarningNotification(warning.get(WARNING).asString(), | ||
Level.parse(warning.get(LEVEL).asString())); | ||
Notifications.fireWarningNotification(warningNotification); | ||
} | ||
} | ||
|
||
protected List<ModelNode> fetchWarnings(final ModelNode response) { | ||
List<ModelNode> warnings = new ArrayList<ModelNode>(); | ||
for (Property step : response.get(RESULT).asPropertyList()) { | ||
final ModelNode value = step.getValue(); | ||
if (value.hasDefined(RESPONSE_HEADERS) && value.get(RESPONSE_HEADERS).hasDefined(WARNINGS)) { | ||
warnings.addAll(value.get(RESPONSE_HEADERS).get(WARNINGS).asList()); | ||
} | ||
} | ||
return warnings; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the model node structure the same for both standalone and domain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc yeah, Im going to update this PR since there has been change in core WRT this.
Also, I assume that every op is a "stepped" operation. Not sure if this is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. Steps are usually only used for composite operations. I guess this is also true for this use case. I suggest to talk to Brian, to clarify the exact response structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, but I think console use only composite operation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but that might change - and there might be other operations which cause these response headers. So it would be more robust to be prepared for warnings which are not wrapped inside steps.