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

Fixed the DOI connection Error by Automatically Removing all Special Characters at the end of DOI #8215

Closed
wants to merge 14 commits into from

Conversation

jiezheng5
Copy link
Contributor

@jiezheng5 jiezheng5 commented Nov 7, 2021

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@jiezheng5 jiezheng5 marked this pull request as ready for review November 7, 2021 09:06
@jiezheng5
Copy link
Contributor Author

I fixed all the checkstyle errors.

}
}

// char[] lcharDoi = doiStr.toCharArray();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really in the spirit of open source contribution. You requested to work on this issue after me and I have started working on it.

Copy link
Contributor Author

@jiezheng5 jiezheng5 Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really in the spirit of open source contribution. You requested to work on this issue after me and I have started working on it.

I started working on this issue 3 weeks ago. Then I saw your request, I thought maybe I should also post my progress. Do we have to get permission before we can work on any open issues? This is my first time contributing to open source, I am sorry that if I have done something wrong.

thanks,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code

thanks very much for the suggestions, will do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and I have started working on it.

@mrcstan May we see your approach? Maybe it differs significantly of this one - and we can make use of your ideas, too?

@@ -2,7 +2,7 @@
<configuration default="false" name="JabRef Main" type="Application" factoryName="Application" singleton="true">
<option name="MAIN_CLASS_NAME" value="org.jabref.gui.JabRefMain" />
<module name="JabRef.main" />
<option name="VM_PARAMETERS" value="--patch-module test=fastparse_2.12-1.0.0.jar --patch-module test2=fastparse-utils_2.12-1.0.0.jar --patch-module test3=sourcecode_2.12-0.1.4.jar --patch-module org.jabref=build/resources/main --add-exports javafx.controls/com.sun.javafx.scene.control=org.jabref --add-exports org.controlsfx.controls/impl.org.controlsfx.skin=org.jabref --add-opens javafx.controls/javafx.scene.control=org.jabref --add-opens org.controlsfx.controls/org.controlsfx.control.textfield=org.jabref --add-exports javafx.graphics/com.sun.javafx.scene=org.controlsfx.controls --add-exports javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls --add-exports javafx.graphics/com.sun.javafx.css=org.controlsfx.controls --add-exports javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls --add-exports javafx.controls/com.sun.javafx.scene.control=org.controlsfx.controls --add-exports javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls --add-exports javafx.base/com.sun.javafx.event=org.controlsfx.controls --add-exports javafx.base/com.sun.javafx.collections=org.controlsfx.controls --add-exports javafx.base/com.sun.javafx.runtime=org.controlsfx.controls --add-exports javafx.web/com.sun.webkit=org.controlsfx.controls --add-exports javafx.graphics/com.sun.javafx.css=org.controlsfx.controls --add-opens javafx.controls/javafx.scene.control.skin=org.controlsfx.controls --add-opens javafx.graphics/javafx.scene=org.controlsfx.controls --add-exports com.oracle.truffle.regex/com.oracle.truffle.regex=org.graalvm.truffle --add-exports javafx.graphics/com.sun.javafx.stage=com.jfoenix --add-exports javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix" />
<option name="VM_PARAMETERS" value="--patch-module test=fastparse_2.12-1.0.0.jar --patch-module test2=fastparse-utils_2.12-1.0.0.jar --patch-module test3=sourcecode_2.12-0.1.4.jar --patch-module org.jabref=build/resources/main --add-exports javafx.controls/com.sun.javafx.scene.control=org.jabref --add-exports org.controlsfx.controls/impl.org.controlsfx.skin=org.jabref --add-opens javafx.controls/javafx.scene.control=org.jabref --add-opens org.controlsfx.controls/org.controlsfx.control.textfield=org.jabref --add-exports javafx.graphics/com.sun.javafx.scene=org.controlsfx.controls --add-exports javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls --add-exports javafx.graphics/com.sun.javafx.css=org.controlsfx.controls --add-exports javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls --add-exports javafx.controls/com.sun.javafx.scene.control=org.controlsfx.controls --add-exports javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls --add-exports javafx.base/com.sun.javafx.event=org.controlsfx.controls --add-exports javafx.base/com.sun.javafx.collections=org.controlsfx.controls --add-exports javafx.base/com.sun.javafx.runtime=org.controlsfx.controls --add-exports javafx.web/com.sun.webkit=org.controlsfx.controls --add-exports javafx.graphics/com.sun.javafx.css=org.controlsfx.controls --add-opens javafx.controls/javafx.scene.control.skin=org.controlsfx.controls --add-opens javafx.graphics/javafx.scene=org.controlsfx.controls --add-exports com.oracle.truffle.regex/com.oracle.truffle.regex=org.graalvm.truffle --add-exports javafx.graphics/com.sun.javafx.stage=com.jfoenix --add-exports javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix -ea --add-exports=javafx.controls/com.sun.javafx.scene.control=org.jabref --add-exports=org.controlsfx.controls/impl.org.controlsfx.skin=org.jabref --add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED --add-exports javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED --add-exports javafx.graphics/com.sun.javafx.stage=com.jfoenix" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask of the reasons why this file mas modified? IntelliJ runs fine as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask of the reasons why this file mas modified? IntelliJ runs fine as is.

Hi, Kopper:

Thanks very much for the feedback. I think IntelliJ automatically did it. I had lots of trouble running using IntelliJ both on windows and Linux. So I just used gradlew to run, which worked perfectly.

Thanks

@@ -44,6 +44,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed an issue where an invalid DOI should not show "Connection error" [#8127](https://github.com/JabRef/jabref/issues/8127)
- We fixed an issue where an exception ocurred when a linked online file was edited in the entry editor [#8008](https://github.com/JabRef/jabref/issues/8008)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this duplicted line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, will do. Thanks very much.

@@ -106,6 +106,10 @@ public DOI(String doi) {
// Remove whitespace
String trimmedDoi = doi.trim();

// jie add-------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add author markers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks very much for your patience, I forgot to remove it after debugging. will do.

have a great night.

Comment on lines 148 to 172
/**
* Removes all special characters at the end of the DOI string
*
* @param doiStr the DOI/Short DOI string
* @return an DOI string with the special character at the end removed
*/
public static String removeScharDOI(String doiStr) {
// jie add
char[] lcharDoi = doiStr.toCharArray();
int i = lcharDoi.length - 1;
// valid DOI characters are a-z(97-122), A-Z(65-90), 0-9(48-57), -(45), .(46), _(95), ;(59), ( (40), ) (41), /(47)
for (; i >= 0; i--) {
if ((lcharDoi[i] >= 45 && lcharDoi[i] <= 47) ||
(lcharDoi[i] >= 48 && lcharDoi[i] <= 57) ||
(lcharDoi[i] >= 65 && lcharDoi[i] <= 90) ||
(lcharDoi[i] >= 97 && lcharDoi[i] <= 122) ||
lcharDoi[i] == 95 ||
lcharDoi[i] == 59 ||
lcharDoi[i] == 40 ||
lcharDoi[i] == 41
) {
// System.out.println(i);
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach feels a bit hacky. I thought that it is about DOI parsing with the RegEx. Could you please test the RegEx whether it removes the bad character?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, great suggestion. I will refactor the code and test the RegEx.

greatly appreciated all the suggestions

@koppor
Copy link
Member

koppor commented Nov 8, 2021

Fixes #8127

@koppor
Copy link
Member

koppor commented Nov 8, 2021

With more than 3 core developers, we looked at this issue in today's dev call. We found out, that there is DOI.findInText which resolves the issue --> #8227

@jiezheng5 Could you add your test cases to that PR? I would like to ask you to add a new test section below // findDoiInsideArbitraryText with your test cases of this branch.

@koppor
Copy link
Member

koppor commented Nov 8, 2021

I am closing this one, as we think, the tests should be merged with #8227

@koppor koppor closed this Nov 8, 2021
@mrcstan
Copy link
Contributor

mrcstan commented Nov 8, 2021

I guess I just missed this one. I created a PR that uses regexp #8288. Seems like it has been fixed elsewhere. Let me know if I can contribute anything else.

@jiezheng5
Copy link
Contributor Author

With more than 3 core developers, we looked at this issue in today's dev call. We found out, that there is DOI.findInText which resolves the issue --> #8227

@jiezheng5 Could you add your test cases to that PR? I would like to ask you to add a new test section below // findDoiInsideArbitraryText with your test cases of this branch.

my pleasure. will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants