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

Bug/cite 221 #276

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open

Bug/cite 221 #276

wants to merge 20 commits into from

Conversation

PradnyaC11
Copy link
Contributor

@PradnyaC11 PradnyaC11 commented Jul 16, 2024

Guidelines for Pull Requests

If you haven't yet read our code review guidelines, please do so, You can find them here.

Please confirm the following by adding an x for each item (turn [ ] into [x]).

  • I have removed all code style changes that are not necessary (e.g. changing blanks across the whole file that don’t need to be changed, adding empty lines in parts other than your own code)
  • I am not making any changes to files that don’t have any effect (e.g. imports added that don’t need to be added)
  • I do not have any sysout statements in my code or commented out code that isn’t needed anymore
  • I am not reformatting any files in the wrong format or without cause.
  • I am not changing file encoding or line endings to something else than UTF-8, LF
  • My pull request does not show an insane amount of files being changed although my ticket only requires a few files being changed
  • I have added Javadoc/documentation where appropriate
  • I have added test cases where appropriate
  • I have explained any part of my code/implementation decisions that is not be self-explanatory

Please provide a brief description of your ticket

unique: Spring Data: Unique field in MongoDB document

... Put ticket description here and add link to ticket ...
https://diging.atlassian.net/browse/CITE-221

Are there any other pull requests that this one depends on?

diging/citesphere-model#51
diging/citesphere-model#52

Anything else the reviewer needs to know?

... describe here ...

@diging-jenkins
Copy link

Can one of the admins verify this patch?

@PradnyaC11 PradnyaC11 requested a review from jdamerow July 16, 2024 23:39
@PradnyaC11 PradnyaC11 marked this pull request as draft July 16, 2024 23:41
Copy link
Member

@jdamerow jdamerow left a comment

Choose a reason for hiding this comment

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

I haven't run this but that does not look right. If there is a duplicate key, then the duplicates should be deleted, so that only one group/citation/collection is left. The user should not get an error, instead the issue should be resolved.

@@ -248,13 +250,15 @@ public ICitation updateCitationFromZotero(IUser user, String groupId, String ite
return citation;
} catch (HttpClientErrorException ex) {
throw new CannotFindCitationException(ex);
} catch(DuplicateKeyException ex) {
throw ex;
Copy link
Member

Choose a reason for hiding this comment

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

no point in throwing an exception you catch; you can just let it be thrown

return (ICitationGroup) groupOptional.get();
if (groupOptional.isPresent()) {
ICitationGroup group = groupOptional.get();
if (!group.getUsers().contains(user.getUsername())) {
Copy link
Member

Choose a reason for hiding this comment

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

if the user does not have access to the group, then they shouldn't be added.

@jdamerow jdamerow closed this Jul 17, 2024
@PradnyaC11 PradnyaC11 reopened this Jul 19, 2024
@PradnyaC11 PradnyaC11 requested a review from jdamerow July 19, 2024 22:08
@PradnyaC11 PradnyaC11 marked this pull request as ready for review July 19, 2024 22:08
Copy link
Member

@jdamerow jdamerow left a comment

Choose a reason for hiding this comment

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

A new model version has been published but it doesn't look like pom.xml is being changed?

@PradnyaC11 PradnyaC11 requested a review from jdamerow September 24, 2024 17:27
@jdamerow
Copy link
Member

Resolve conflicts please

@jdamerow jdamerow closed this Oct 25, 2024
@PradnyaC11 PradnyaC11 reopened this Oct 28, 2024
@@ -25,7 +25,7 @@
<spring.kafka.version>2.2.6.RELEASE</spring.kafka.version>
<spring-social-zotero.version>0.12</spring-social-zotero.version>
<citesphere.messages.version>0.4</citesphere.messages.version>
<citesphere.model.version>1.19</citesphere.model.version>
<citesphere.model.version>1.23-SNAPSHOT</citesphere.model.version>
Copy link
Member

Choose a reason for hiding this comment

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

this needs to be a proper version

@@ -379,14 +383,17 @@ public CitationResults getGroupItems(IUser user, String groupId, String collecti

ICitationGroup group = null;
Optional<ICitationGroup> groupOptional = groupRepository.findFirstByGroupId(new Long(groupId));
if (!groupOptional.isPresent() || !groupOptional.get().getUsers().contains(user.getUsername())) {
if (!groupOptional.isPresent()) {
Copy link
Member

Choose a reason for hiding this comment

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

hm, I'm fairly certain this create a security issue here. Basically, doesn't this say "if the group does not yet locally exist, get it from zotero" (that's fine zotero will complain if the user does not have access), however, "if the group does exist, let's just add the user to the group" (this seems wrong, where is the check if the user has access?).

@@ -399,13 +406,14 @@ public CitationResults getGroupItems(IUser user, String groupId, String collecti
long previousVersion = group.getContentVersion();
// first update the group info
// if we are using a previously stored group, delete it
ICitationGroup zeteroGroup = null;
Copy link
Member

Choose a reason for hiding this comment

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

spelling mistake

@jdamerow jdamerow closed this Oct 29, 2024
@PradnyaC11 PradnyaC11 reopened this Oct 29, 2024
@@ -387,6 +391,9 @@ public CitationResults getGroupItems(IUser user, String groupId, String collecti
}
} else {
group = groupOptional.get();
if (!group.getUsers().contains(user.getUsername())){
group.getUsers().add(user.getUsername());
}
Copy link
Member

Choose a reason for hiding this comment

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

this should not be needed, should it? this else should only be called if the group is present and the user has access to it?

@jdamerow jdamerow closed this Oct 29, 2024
@PradnyaC11 PradnyaC11 reopened this Oct 31, 2024
@PradnyaC11 PradnyaC11 requested a review from jdamerow October 31, 2024 18:34
@jdamerow
Copy link
Member

Make it so, Jenkins.

@diging-jenkins
Copy link

Build failed. Maybe you broke the test cases?

@jdamerow
Copy link
Member

Make it so, Jenkins.

@diging-jenkins
Copy link

Build failed. Maybe you broke the test cases?

@jdamerow
Copy link
Member

There are test failures

@jdamerow
Copy link
Member

test_addCitationToReferences_nullReferences(edu.asu.diging.citesphere.core.service.impl.CitationManagerTest)  Time elapsed: 0.004 sec  <<< ERROR!
java.lang.NullPointerException

@jdamerow
Copy link
Member

test_addCitationToReferences_citationFound(edu.asu.diging.citesphere.core.service.impl.CitationManagerTest)

@jdamerow jdamerow closed this Nov 13, 2024
@PradnyaC11 PradnyaC11 reopened this Dec 3, 2024
@diging-jenkins
Copy link

Jenkins successfully deployed Citesphere to be reviewed!

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.

3 participants