Skip to content

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

Closed
jiezheng5 wants to merge 14 commits into
JabRef:mainfrom
jiezheng5:issue8127
Closed

Fixed the DOI connection Error by Automatically Removing all Special Characters at the end of DOI#8215
jiezheng5 wants to merge 14 commits into
JabRef:mainfrom
jiezheng5:issue8127

Conversation

@jiezheng5

@jiezheng5 jiezheng5 commented Nov 7, 2021

Copy link
Copy Markdown
Contributor
  • 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
Copy Markdown
Contributor Author

I fixed all the checkstyle errors.

}
}

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

Copy link
Copy Markdown
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
Copy Markdown
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.

@jiezheng5 jiezheng5 Nov 8, 2021

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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?

<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
Copy Markdown
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
Copy Markdown
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

Comment thread CHANGELOG.md
### 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
Copy Markdown
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
Copy Markdown
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.

// Remove whitespace
String trimmedDoi = doi.trim();

// jie add-------------------------

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

koppor commented Nov 8, 2021

Copy link
Copy Markdown
Member

Fixes #8127

@koppor

koppor commented Nov 8, 2021

Copy link
Copy Markdown
Member

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

koppor commented Nov 8, 2021

Copy link
Copy Markdown
Member

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

@koppor koppor closed this Nov 8, 2021
@mrcstan

mrcstan commented Nov 8, 2021

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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