-
Notifications
You must be signed in to change notification settings - Fork 440
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
IdentifyApi Refactored #2083
Closed
Closed
IdentifyApi Refactored #2083
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6b4173a
IdentifyApi Refactored
shnrndk fc5bd93
Identify api method bugs fixed
shnrndk 15f649b
refactored the methods to get resources of apis
chamikasudusinghe 757c5fb
Api invocation bug fixed after enabling api logs
shnrndk 4114329
Api invocation bug fixed after enabling api logs
shnrndk 74dc6e3
Merge remote-tracking branch 'origin/master'
shnrndk 97d23a3
Fixes done to the code after api identification PR review.
shnrndk 3848c18
Merge branch 'wso2:master' into master
shnrndk 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
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 |
---|---|---|
|
@@ -51,19 +51,30 @@ protected boolean dispatchToAPI(Collection<API> apiSet, MessageContext synCtx) { | |
|
||
Object apiObject = synCtx.getProperty(RESTConstants.PROCESSED_API); | ||
if (apiObject != null) { | ||
if (identifyAPI((API) apiObject, synCtx, defaultStrategyApiSet)) { | ||
if (startProcess((API) apiObject, synCtx, defaultStrategyApiSet)) { | ||
return true; | ||
} | ||
} else { | ||
//To avoid apiSet being modified concurrently | ||
List<API> duplicateApiSet = new ArrayList<API>(apiSet); | ||
for (API api : duplicateApiSet) { | ||
if (identifyAPI(api, synCtx, defaultStrategyApiSet)) { | ||
API identifiedApi = (API) synCtx.getProperty(RESTConstants.IDENTIFIED_API); | ||
//If normal path this goes to else, if logging enabled then goes inside the if method. | ||
if (identifiedApi != null | ||
&& duplicateApiSet.contains(identifiedApi)) { | ||
if (startProcess(identifiedApi, synCtx, defaultStrategyApiSet)) { | ||
return true; | ||
} | ||
} else { | ||
for (API api : duplicateApiSet) { | ||
if (startProcess(api, synCtx, defaultStrategyApiSet)) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if(synCtx.getProperty(RESTConstants.IDENTIFIED_API) != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for removing the property? |
||
synCtx.getPropertyKeySet().remove(RESTConstants.IDENTIFIED_API); | ||
} | ||
for (API api : defaultStrategyApiSet) { | ||
api.setLogSetterValue(); | ||
if (api.canProcess(synCtx)) { | ||
|
@@ -110,7 +121,7 @@ protected void apiProcessNonDefaultStrategy(MessageContext synCtx, API api) { | |
} | ||
} | ||
|
||
protected boolean identifyAPI(API api, MessageContext synCtx, List defaultStrategyApiSet) { | ||
protected boolean startProcess(API api, MessageContext synCtx, List defaultStrategyApiSet) { | ||
API defaultAPI = null; | ||
api.setLogSetterValue(); | ||
if ("/".equals(api.getContext())) { | ||
|
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
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
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
Oops, something went wrong.
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.
This logic is not clear to me, can you please explain?
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.
In the api logging flow in the first iteration it needs to identify the api. For that it calls the
identifyApi()
method. If the api is identified then that api gets stored in the IDENTIFIED_API property. Then in the second iteration, we do not need to identify the api again. Therefore we get the identified api from the from the IDENTIFIED_API property. So we do not need to iterate all the apis in the duplicateApiSet to identify the api.But if the api logging is disabled then api is not identified previously, therefore IDENTIFIED_API property is null, So the api needs to be identified by iterating all the apis in the defaultStrategyApiSet.