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
[CAMEL-15253] camel-oaipmh - basic implementation #3934
Conversation
|
Hi @DenisIstomin @zregvart @oscerd I pulled the last commits from the master branch of apache/camel, also I added a Producer implementation and some tests. Please let me know if you have suggestions. |
|
Good start. Since this is draft, i will give a few suggestions, instead of full review.
And some obvious things, which I believe you know about.
|
- Implement HTTPS test. - Add parameter: ignoreSSLWarnings - Regen
Thank you @juanksega for the PR! I have gave some comments and tips to improve this component further.
components/camel-oaipmh/pom.xml
Outdated
| </plugin> | ||
|
|
||
| <!-- generate camel meta-data --> | ||
| <plugin> |
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.
You don't need this plugin, is already included in the parent pom of the components.
components/camel-oaipmh/pom.xml
Outdated
| </plugin> | ||
| <plugin> | ||
| <groupId>org.codehaus.mojo</groupId> | ||
| <artifactId>build-helper-maven-plugin</artifactId> |
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.
As well here
components/camel-oaipmh/pom.xml
Outdated
| <properties> | ||
| </properties> | ||
|
|
||
| <dependencyManagement> |
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.
You already having the parent dependency, I don't think you need to add the Camel BOM here
components/camel-oaipmh/pom.xml
Outdated
| <build> | ||
| <defaultGoal>install</defaultGoal> | ||
|
|
||
| <plugins> |
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.
and here
| import java.io.IOException; | ||
| import java.net.URI; | ||
| import java.net.URISyntaxException; | ||
| import java.security.KeyManagementException; |
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 see these imports are not used here
|
|
||
| public String doRequest(URI baseURI, String verb, String set, String from, String until, String metadataPrefix, String token, String identifier) throws IOException, URISyntaxException, Exception { | ||
| CloseableHttpClient httpclient = getCloseableHttpClient(); | ||
| try { |
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.
You can replace it with:
| try { | |
| try (CloseableHttpClient httpclient = getCloseableHttpClient()) { |
|
|
||
| if (baseURI.getQuery() != null && !baseURI.getQuery().isEmpty()) { | ||
| for (String param : baseURI.getQuery().split("&")) { | ||
| builder.addParameter(param.split("=")[0], param.split("=")[1]); |
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 am just wondering, do we need to check that we really have two params split with =?
| }; | ||
| String responseBody = httpclient.execute(httpget, responseHandler); | ||
|
|
||
| // String uri = requestLine.getUri(); |
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.
unnecessary comments here
| builder.build()); | ||
| return HttpClients.custom().setSSLSocketFactory( | ||
| sslsf).build(); | ||
| } catch (Exception ex) { |
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.
If you are catching the exception and then throw it again, makes no sense. However, I don't feel comfortable of throwing generic Exception here, please be specific on which exception you want to throw here
| protected CloseableHttpClient getCloseableHttpClient() throws Exception { | ||
| if (isIgnoreSSLWarnings()) { | ||
| try { | ||
| SSLContextBuilder builder = new SSLContextBuilder(); |
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 looks deprecated.
- Remove unnecessary comments. - Add constants file. - Remove deprecated code.
|
Hi @bedlaj @omarsmak @DenisIstomin Thanks so much for your feedback. I think I fixed all your suggestions. Please, let me know if you have other suggestions. |
LGTM. I see some unresolved suggestions, but these should not be blocking the merge:
@bedlaj: For consumer use AsyncCallback in AsyncProcessor instead of try-catch-finally (Look eg to WsConsumer for inspiration)
@omarsmak: I don't think you need to throw all these exception since you are throwing Exception.
LGTM, nice job @juanksega
NIT: inconsistent code comments formatting
|
@oscerd we shall merge this one? |
|
Yeah, let's merge and revisit and improving later |
Google Summer of Code 2020:
Implementation of a camel-oaipmh component.
Student: Juan Segarra
Mentors:
Denis Istomin
Zoran Regvart
Andrea Cosentino
Documentation:
https://camel.apache.org/components/latest/oaipmh-component.html
Camel Examples:
apache/camel-examples#13
Spring Boot Starter:
apache/camel-spring-boot#143
Jira:
https://issues.apache.org/jira/browse/CAMEL-15253
Proposal:
https://docs.google.com/document/d/1zrPhEnhj5gc3VIPRWYXz7n6kJqrIjLbDHRRrCa5wwsg/edit?usp=sharing
Blog:
https://medium.com/@juanksegarraf/implementation-of-a-component-for-the-oai-pmh-protocol-in-apache-camel-94d98ca6908f
Mail threads:
http://camel.465427.n5.nabble.com/camel-oaipmh-quirks-mode-tp5878543.html
http://camel.465427.n5.nabble.com/camel-oaipmh-HTTPS-and-endpoint-schema-tp5871118.html
http://camel.465427.n5.nabble.com/GSoC-2020-Project-suggestion-OAI-PMH-tp5858089.html
*Part of this code was imported from: https://github.com/cbadenes/camel-oaipmh
[ ] Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
[ ] Each commit in the pull request should have a meaningful subject line and body.
[ ] If you're unsure, you can format the pull request title like
[CAMEL-XXX] Fixes bug in camel-file component, where you replaceCAMEL-XXXwith the appropriate JIRA issue.[ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
[ ] Run
mvn clean install -Psourcecheckin your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.Below are the contribution guidelines:
https://github.com/apache/camel/blob/master/CONTRIBUTING.md
The text was updated successfully, but these errors were encountered: