-
Notifications
You must be signed in to change notification settings - Fork 215
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
Confluence as source plugin #5404
Merged
kkondaka
merged 21 commits into
opensearch-project:main
from
san81:confluence-as-source-plugin
Feb 11, 2025
Merged
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ae65748
confluence source
san81 d20e6fa
merging main
san81 98660a1
matching config structure to be more inline for Confluence
san81 b358db7
merging main
san81 6f40d65
Functional confluence version
san81 378c41f
Saving page content as text
san81 d9a98d0
injectable plugin metrics
san81 04ac7c0
Introduced atlassian common module
san81 0e89bf0
functional with making use of Atlassian Commons package
san81 66befd5
test cases in a running state
san81 4fde3e9
atlassian commons gradle file
san81 6bd3451
moved the test to the atlassian commons
san81 f8e8d45
additional code coverage
san81 47ee223
better names
san81 15e0b4a
better naming
san81 14a5870
making a default implementation
san81 6ae21b9
Merge branch 'main' of github.com:san81/data-prepper into confluence-…
san81 f207bcc
addressing review comments
san81 aaaf3fc
validating page type filter
san81 b68fd99
fixed failing tests
san81 928e253
using InvalidPluginConfigurationException instead of BadRequestException
san81 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
import org.opensearch.dataprepper.plugins.source.confluence.models.ConfluenceSearchResults; | ||
import org.opensearch.dataprepper.plugins.source.confluence.rest.ConfluenceRestClient; | ||
import org.opensearch.dataprepper.plugins.source.confluence.utils.ConfluenceConfigHelper; | ||
import org.opensearch.dataprepper.plugins.source.confluence.utils.ConfluenceContentType; | ||
import org.opensearch.dataprepper.plugins.source.source_crawler.exception.BadRequestException; | ||
import org.opensearch.dataprepper.plugins.source.source_crawler.model.ItemInfo; | ||
import org.springframework.util.CollectionUtils; | ||
|
@@ -136,6 +137,11 @@ private StringBuilder createContentFilterCriteria(ConfluenceSourceConfig configu | |
if (!CollectionUtils.isEmpty(ConfluenceConfigHelper.getSpacesNameIncludeFilter(configuration)) || !CollectionUtils.isEmpty(ConfluenceConfigHelper.getSpacesNameExcludeFilter(configuration))) { | ||
validateSpaceFilters(configuration); | ||
} | ||
|
||
if (!CollectionUtils.isEmpty(ConfluenceConfigHelper.getContentTypeIncludeFilter(configuration)) || !CollectionUtils.isEmpty(ConfluenceConfigHelper.getContentTypeExcludeFilter(configuration))) { | ||
validatePageTypeFilters(configuration); | ||
} | ||
|
||
String formattedTimeStamp = LocalDateTime.ofInstant(ts, ZoneId.systemDefault()) | ||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); | ||
StringBuilder cQl = new StringBuilder(LAST_MODIFIED + GREATER_THAN_EQUALS + "\"" + formattedTimeStamp + "\""); | ||
|
@@ -164,6 +170,48 @@ private StringBuilder createContentFilterCriteria(ConfluenceSourceConfig configu | |
return cQl; | ||
} | ||
|
||
/** | ||
* Method for Validating Page Type Filters. | ||
* | ||
* @param configuration Input Parameter | ||
*/ | ||
private void validatePageTypeFilters(ConfluenceSourceConfig configuration) { | ||
log.trace("Validating Page Type filters"); | ||
List<String> badFilters = new ArrayList<>(); | ||
Set<String> includedPageType = new HashSet<>(); | ||
List<String> includedAndExcludedPageType = new ArrayList<>(); | ||
ConfluenceConfigHelper.getContentTypeIncludeFilter(configuration).forEach(pageTypeFilter -> { | ||
if (ConfluenceContentType.fromString(pageTypeFilter) == null) { | ||
badFilters.add(pageTypeFilter); | ||
} else { | ||
includedPageType.add(pageTypeFilter); | ||
} | ||
}); | ||
ConfluenceConfigHelper.getContentTypeExcludeFilter(configuration).forEach(pageTypeFilter -> { | ||
if (includedPageType.contains(pageTypeFilter)) { | ||
includedAndExcludedPageType.add(pageTypeFilter); | ||
} | ||
if (ConfluenceContentType.fromString(pageTypeFilter) == null) { | ||
badFilters.add(pageTypeFilter); | ||
} | ||
}); | ||
if (!badFilters.isEmpty()) { | ||
String filters = String.join("\"" + badFilters + "\"", ", "); | ||
log.error("One or more invalid Page Types found in filter configuration: {}", badFilters); | ||
throw new BadRequestException("Bad request exception occurred " + | ||
"Invalid Page Type key found in filter configuration " | ||
+ filters); | ||
} | ||
if (!includedAndExcludedPageType.isEmpty()) { | ||
String filters = String.join("\"" + includedAndExcludedPageType + "\"", ", "); | ||
log.error("One or more Page types found in both include and exclude: {}", includedAndExcludedPageType); | ||
throw new BadRequestException("Bad request exception occurred " + | ||
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. Throw 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. changed to throw |
||
"Page Type filters is invalid because the following Page types are listed in both include and exclude" | ||
+ filters); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Method for Validating Space Filters. | ||
* | ||
|
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
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.
Please throw
InvalidPluginConfigurationException
here.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.
Changed to
InvalidPluginConfigurationException